mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:17:45 +00:00
LibWeb: Move Layout::Box::is_out_of_flow() to Layout::Node
I want to use this function in inline layout, where we're not just dealing with boxes.
This commit is contained in:
parent
150e6a59c0
commit
74927fd218
4 changed files with 18 additions and 25 deletions
|
@ -29,29 +29,6 @@ Box::~Box()
|
|||
{
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-display-3/#out-of-flow
|
||||
bool Box::is_out_of_flow(FormattingContext const& formatting_context) const
|
||||
{
|
||||
// A box is out of flow if either:
|
||||
|
||||
// 1. It is floated (which requires that floating is not inhibited).
|
||||
if (!formatting_context.inhibits_floating() && computed_values().float_() != CSS::Float::None)
|
||||
return true;
|
||||
|
||||
// 2. It is "absolutely positioned".
|
||||
switch (computed_values().position()) {
|
||||
case CSS::Position::Absolute:
|
||||
case CSS::Position::Fixed:
|
||||
return true;
|
||||
case CSS::Position::Static:
|
||||
case CSS::Position::Relative:
|
||||
case CSS::Position::Sticky:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Box::set_needs_display()
|
||||
{
|
||||
if (!is_inline()) {
|
||||
|
|
|
@ -21,8 +21,6 @@ class Box : public NodeWithStyleAndBoxModelMetrics {
|
|||
public:
|
||||
Painting::PaintableBox const* paint_box() const;
|
||||
|
||||
bool is_out_of_flow(FormattingContext const&) const;
|
||||
|
||||
virtual void set_needs_display() override;
|
||||
|
||||
bool is_body() const;
|
||||
|
|
|
@ -33,6 +33,22 @@ Node::~Node()
|
|||
m_dom_node->set_layout_node({}, nullptr);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/css-display-3/#out-of-flow
|
||||
bool Node::is_out_of_flow(FormattingContext const& formatting_context) const
|
||||
{
|
||||
// A layout node is out of flow if either:
|
||||
|
||||
// 1. It is floated (which requires that floating is not inhibited).
|
||||
if (!formatting_context.inhibits_floating() && computed_values().float_() != CSS::Float::None)
|
||||
return true;
|
||||
|
||||
// 2. It is "absolutely positioned".
|
||||
if (is_absolutely_positioned())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Node::can_contain_boxes_with_position_absolute() const
|
||||
{
|
||||
return computed_values().position() != CSS::Position::Static || is<InitialContainingBlock>(*this);
|
||||
|
|
|
@ -74,6 +74,8 @@ public:
|
|||
|
||||
bool is_inline_block() const;
|
||||
|
||||
bool is_out_of_flow(FormattingContext const&) const;
|
||||
|
||||
// These are used to optimize hot is<T> variants for some classes where dynamic_cast is too slow.
|
||||
virtual bool is_box() const { return false; }
|
||||
virtual bool is_block_container() const { return false; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue