mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
LibWeb: Start making our layout system "transactional"
This patch adds a map of Layout::Node to FormattingState::NodeState. Instead of updating layout nodes incrementally as layout progresses through the formatting contexts, all updates are now written to the corresponding NodeState instead. At the end of layout, FormattingState::commit() is called, which transfers all the values from the NodeState objects to the Node. This will soon allow us to perform completely non-destructive layouts which don't affect the tree. Note that there are many imperfections here, and still many places where we assign to the NodeState, but later read directly from the Node instead. I'm just committing at this stage to make subsequent diffs easier to understand.
This commit is contained in:
parent
561612f219
commit
c9700e100e
27 changed files with 754 additions and 571 deletions
|
@ -71,22 +71,6 @@ public:
|
|||
return content_height() + border_box.top + border_box.bottom;
|
||||
}
|
||||
|
||||
Gfx::FloatRect content_box_as_relative_rect() const
|
||||
{
|
||||
return { m_offset, m_content_size };
|
||||
}
|
||||
|
||||
Gfx::FloatRect margin_box_as_relative_rect() const
|
||||
{
|
||||
auto rect = content_box_as_relative_rect();
|
||||
auto margin_box = box_model().margin_box();
|
||||
rect.set_x(rect.x() - margin_box.left);
|
||||
rect.set_width(rect.width() + margin_box.left + margin_box.right);
|
||||
rect.set_y(rect.y() - margin_box.top);
|
||||
rect.set_height(rect.height() + margin_box.top + margin_box.bottom);
|
||||
return rect;
|
||||
}
|
||||
|
||||
float absolute_x() const { return absolute_rect().x(); }
|
||||
float absolute_y() const { return absolute_rect().y(); }
|
||||
Gfx::FloatPoint absolute_position() const { return absolute_rect().location(); }
|
||||
|
@ -141,20 +125,6 @@ public:
|
|||
virtual void before_children_paint(PaintContext&, PaintPhase) override;
|
||||
virtual void after_children_paint(PaintContext&, PaintPhase) override;
|
||||
|
||||
Gfx::FloatRect margin_box_rect_in_ancestor_coordinate_space(Box const& ancestor_box) const
|
||||
{
|
||||
auto rect = margin_box_as_relative_rect();
|
||||
for (auto const* current = parent(); current; current = current->parent()) {
|
||||
if (current == &ancestor_box)
|
||||
break;
|
||||
if (is<Box>(*current)) {
|
||||
auto offset = static_cast<Box const&>(*current).effective_offset();
|
||||
rect.translate_by(offset);
|
||||
}
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
protected:
|
||||
Box(DOM::Document& document, DOM::Node* node, NonnullRefPtr<CSS::StyleProperties> style)
|
||||
: NodeWithStyleAndBoxModelMetrics(document, node, move(style))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue