2020-01-18 09:38:21 +01:00
|
|
|
/*
|
2022-03-09 23:53:41 +01:00
|
|
|
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2019-10-15 16:48:38 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-06-15 17:29:35 +02:00
|
|
|
#include <AK/OwnPtr.h>
|
2020-07-25 21:31:47 -07:00
|
|
|
#include <LibGfx/Rect.h>
|
2020-11-22 15:53:01 +01:00
|
|
|
#include <LibWeb/Layout/Node.h>
|
2019-10-15 16:48:38 +02:00
|
|
|
|
2020-11-22 15:53:01 +01:00
|
|
|
namespace Web::Layout {
|
2020-03-07 10:27:02 +01:00
|
|
|
|
2022-02-28 12:41:23 +01:00
|
|
|
struct LineBoxFragmentCoordinate {
|
|
|
|
|
size_t line_box_index { 0 };
|
|
|
|
|
size_t fragment_index { 0 };
|
|
|
|
|
};
|
|
|
|
|
|
2020-11-22 15:53:01 +01:00
|
|
|
class Box : public NodeWithStyleAndBoxModelMetrics {
|
2019-10-15 16:48:38 +02:00
|
|
|
public:
|
2022-03-10 15:50:57 +01:00
|
|
|
Painting::PaintableBox const* paint_box() const;
|
2020-06-10 10:42:29 +02:00
|
|
|
|
2019-10-15 16:48:38 +02:00
|
|
|
virtual void set_needs_display() override;
|
|
|
|
|
|
2019-10-19 11:49:46 +02:00
|
|
|
bool is_body() const;
|
|
|
|
|
|
2021-10-14 18:37:24 +02:00
|
|
|
virtual Optional<float> intrinsic_width() const { return {}; }
|
|
|
|
|
virtual Optional<float> intrinsic_height() const { return {}; }
|
2021-10-14 18:48:49 +02:00
|
|
|
virtual Optional<float> intrinsic_aspect_ratio() const { return {}; }
|
2021-10-14 18:37:24 +02:00
|
|
|
|
|
|
|
|
bool has_intrinsic_width() const { return intrinsic_width().has_value(); }
|
|
|
|
|
bool has_intrinsic_height() const { return intrinsic_height().has_value(); }
|
2021-10-14 18:48:49 +02:00
|
|
|
bool has_intrinsic_aspect_ratio() const { return intrinsic_aspect_ratio().has_value(); }
|
2021-10-14 18:37:24 +02:00
|
|
|
|
2022-03-09 23:53:41 +01:00
|
|
|
virtual ~Box() override;
|
2021-01-06 14:10:53 +01:00
|
|
|
|
2020-06-10 10:42:29 +02:00
|
|
|
virtual void did_set_rect() { }
|
2020-06-05 19:13:27 +02:00
|
|
|
|
2022-03-10 22:38:08 +01:00
|
|
|
virtual RefPtr<Painting::Paintable> create_paintable() const override;
|
2022-03-10 14:02:25 +01:00
|
|
|
|
2022-03-09 23:53:41 +01:00
|
|
|
protected:
|
|
|
|
|
Box(DOM::Document&, DOM::Node*, NonnullRefPtr<CSS::StyleProperties>);
|
|
|
|
|
Box(DOM::Document&, DOM::Node*, CSS::ComputedValues);
|
|
|
|
|
|
2019-10-15 16:48:38 +02:00
|
|
|
private:
|
2021-01-07 17:31:26 +01:00
|
|
|
virtual bool is_box() const final { return true; }
|
2019-10-15 16:48:38 +02:00
|
|
|
};
|
|
|
|
|
|
2021-01-07 17:31:26 +01:00
|
|
|
template<>
|
2021-01-17 09:34:01 +01:00
|
|
|
inline bool Node::fast_is<Box>() const { return is_box(); }
|
2021-01-07 17:31:26 +01:00
|
|
|
|
|
|
|
|
}
|