mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:07:35 +00:00
LibWeb: Honor CSS display value in is_inline() and is_inline_block()
These were totally ad-hoc before, is_inline() was based on a boolean flag on Layout::Node that we set in various situations. Meanwhile, is_inline_block() was a combination on is_inline() plus a type check to see if the layout node inherited from BlockContainer. This patch replaces the above mess with simple lookups of the CSS display value. Note that layout nodes without their own style (i.e text nodes) are automatically assumed to be inline and non-blocks. This has to be special-cased since layout nodes without style will consult the style of their parent, so without short-circuiting this would break.
This commit is contained in:
parent
fe03149a47
commit
5989a3ee77
2 changed files with 21 additions and 4 deletions
|
@ -579,9 +579,26 @@ String Node::debug_description() const
|
|||
return builder.to_string();
|
||||
}
|
||||
|
||||
void Node::set_inline(bool) { }
|
||||
|
||||
bool Node::is_inline() const
|
||||
{
|
||||
if (!has_style()) {
|
||||
// NOTE: If this node doesn't have its own style, computed_values() will get style from the parent.
|
||||
// This could give unwanted results. Besides, if we don't have style, we're some kind of inline text node.
|
||||
return true;
|
||||
}
|
||||
return computed_values().display().is_inline_outside();
|
||||
}
|
||||
|
||||
bool Node::is_inline_block() const
|
||||
{
|
||||
return is_inline() && is<BlockContainer>(*this);
|
||||
if (!has_style()) {
|
||||
// NOTE: If this node doesn't have its own style, computed_values() will get style from the parent.
|
||||
// This could give unwanted results. Besides, if we don't have style, we're some kind of inline text node.
|
||||
return false;
|
||||
}
|
||||
return computed_values().display().is_inline_outside() && computed_values().display().is_flow_root_inside();
|
||||
}
|
||||
|
||||
NonnullRefPtr<NodeWithStyle> NodeWithStyle::create_anonymous_wrapper() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue