summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-07-06 20:14:40 +0200
committerAndreas Kling <kling@serenityos.org>2022-07-06 20:31:27 +0200
commit8abbbdf6fa0eeeaded8edd69f0acae56b36d78ff (patch)
treeaa9ba3dbf53fd2f01a824397af9d56ad687f3159
parent4935055407e62196379b7b49baabafb6f92a70cf (diff)
downloadserenity-8abbbdf6fa0eeeaded8edd69f0acae56b36d78ff.zip
LibWeb: Cache a pointer to the IFC root in InlineLevelIterator
-rw-r--r--Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp11
-rw-r--r--Userland/Libraries/LibWeb/Layout/InlineLevelIterator.h1
2 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp b/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp
index 4c2c9d980e..cc76581386 100644
--- a/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp
+++ b/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp
@@ -17,6 +17,7 @@ InlineLevelIterator::InlineLevelIterator(Layout::InlineFormattingContext& inline
: m_inline_formatting_context(inline_formatting_context)
, m_formatting_state(formatting_state)
, m_container(container)
+ , m_container_state(formatting_state.get(container))
, m_next_node(container.first_child())
, m_layout_mode(layout_mode)
{
@@ -31,12 +32,11 @@ void InlineLevelIterator::enter_node_with_box_model_metrics(Layout::NodeWithStyl
// FIXME: It's really weird that *this* is where we assign box model metrics for these layout nodes..
auto& node_state = m_formatting_state.get_mutable(node);
- auto const& container_state = m_formatting_state.get(m_container);
auto const& computed_values = node.computed_values();
- node_state.margin_left = computed_values.margin().left.resolved(node, CSS::Length::make_px(container_state.content_width)).to_px(node);
+ node_state.margin_left = computed_values.margin().left.resolved(node, CSS::Length::make_px(m_container_state.content_width)).to_px(node);
node_state.border_left = computed_values.border_left().width;
- node_state.padding_left = computed_values.padding().left.resolved(node, CSS::Length::make_px(container_state.content_width)).to_px(node);
+ node_state.padding_left = computed_values.padding().left.resolved(node, CSS::Length::make_px(m_container_state.content_width)).to_px(node);
m_extra_leading_metrics->margin += node_state.margin_left;
m_extra_leading_metrics->border += node_state.border_left;
@@ -52,12 +52,11 @@ void InlineLevelIterator::exit_node_with_box_model_metrics()
auto& node = m_box_model_node_stack.last();
auto& node_state = m_formatting_state.get_mutable(node);
- auto const& container_state = m_formatting_state.get(m_container);
auto const& computed_values = node.computed_values();
- node_state.margin_right = computed_values.margin().right.resolved(node, CSS::Length::make_px(container_state.content_width)).to_px(node);
+ node_state.margin_right = computed_values.margin().right.resolved(node, CSS::Length::make_px(m_container_state.content_width)).to_px(node);
node_state.border_right = computed_values.border_right().width;
- node_state.padding_right = computed_values.padding().right.resolved(node, CSS::Length::make_px(container_state.content_width)).to_px(node);
+ node_state.padding_right = computed_values.padding().right.resolved(node, CSS::Length::make_px(m_container_state.content_width)).to_px(node);
m_extra_trailing_metrics->margin += node_state.margin_right;
m_extra_trailing_metrics->border += node_state.border_right;
diff --git a/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.h b/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.h
index 21b7dd1a5e..7d26ebada4 100644
--- a/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.h
+++ b/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.h
@@ -68,6 +68,7 @@ private:
Layout::InlineFormattingContext& m_inline_formatting_context;
Layout::FormattingState& m_formatting_state;
Layout::BlockContainer const& m_container;
+ Layout::FormattingState::NodeState const& m_container_state;
Layout::Node const* m_current_node { nullptr };
Layout::Node const* m_next_node { nullptr };
LayoutMode const m_layout_mode;