mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:37:43 +00:00
LibWeb: Start implementing proper layout of replaced elements
LayoutReplaced now has intrinsic width, height and ratio. Only some of the values may be present. The layout algorithm takes the various configurations into account per the CSS specification. This is still pretty immature but at least we're moving forward. :^)
This commit is contained in:
parent
7fcf61be35
commit
4d5ecf6e32
10 changed files with 215 additions and 22 deletions
|
@ -62,12 +62,15 @@ bool LayoutNode::can_contain_boxes_with_position_absolute() const
|
|||
|
||||
const LayoutBlock* LayoutNode::containing_block() const
|
||||
{
|
||||
if (is_text()) {
|
||||
auto nearest_block_ancestor = [this] {
|
||||
auto* ancestor = parent();
|
||||
while (ancestor && ((ancestor->is_inline() && !is<LayoutReplaced>(*ancestor)) || !is<LayoutBlock>(*ancestor)))
|
||||
while (ancestor && !is<LayoutBlock>(*ancestor))
|
||||
ancestor = ancestor->parent();
|
||||
return to<LayoutBlock>(ancestor);
|
||||
}
|
||||
};
|
||||
|
||||
if (is_text())
|
||||
return nearest_block_ancestor();
|
||||
|
||||
if (is_absolutely_positioned()) {
|
||||
auto* ancestor = parent();
|
||||
|
@ -81,10 +84,7 @@ const LayoutBlock* LayoutNode::containing_block() const
|
|||
if (style().position() == CSS::Position::Fixed)
|
||||
return &root();
|
||||
|
||||
auto* ancestor = parent();
|
||||
while (ancestor && ((ancestor->is_inline() && !is<LayoutReplaced>(*ancestor)) || !is<LayoutBlock>(*ancestor)))
|
||||
ancestor = ancestor->parent();
|
||||
return to<LayoutBlock>(ancestor);
|
||||
return nearest_block_ancestor();
|
||||
}
|
||||
|
||||
void LayoutNode::render(RenderingContext& context)
|
||||
|
@ -185,5 +185,4 @@ bool LayoutNode::is_absolutely_positioned() const
|
|||
return style().position() == CSS::Position::Absolute;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue