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