1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:57:45 +00:00

LibWeb: Expose FormattingContext type

Instead of having a virtual is_block_formatting_context(), let's have a
type() that can tell you exactly which type of formatting context it is.
This commit is contained in:
Andreas Kling 2021-10-15 01:25:12 +02:00
parent b77dad5ba3
commit f2d0e8d0ee
6 changed files with 21 additions and 8 deletions

View file

@ -12,6 +12,14 @@ namespace Web::Layout {
class FormattingContext {
public:
enum class Type {
Block,
Inline,
Flex,
Table,
SVG,
};
virtual void run(Box&, LayoutMode) = 0;
Box& context_box() { return *m_context_box; }
@ -20,7 +28,9 @@ public:
FormattingContext* parent() { return m_parent; }
const FormattingContext* parent() const { return m_parent; }
virtual bool is_block_formatting_context() const { return false; }
Type type() const { return m_type; }
bool is_block_formatting_context() const { return type() == Type::Block; }
virtual bool inhibits_floating() const { return false; }
static bool creates_block_formatting_context(const Box&);
@ -29,7 +39,7 @@ public:
static float compute_height_for_replaced_element(const ReplacedBox&);
protected:
FormattingContext(Box&, FormattingContext* parent = nullptr);
FormattingContext(Type, Box&, FormattingContext* parent = nullptr);
virtual ~FormattingContext();
void layout_inside(Box&, LayoutMode);
@ -52,6 +62,8 @@ protected:
void compute_height_for_absolutely_positioned_non_replaced_element(Box&);
void compute_height_for_absolutely_positioned_replaced_element(ReplacedBox&);
Type m_type {};
FormattingContext* m_parent { nullptr };
Box* m_context_box { nullptr };
};