LibWeb: Cache a pointer to the IFC root in InlineLevelIterator

This commit is contained in:
Andreas Kling 2022-07-06 20:14:40 +02:00
parent 4935055407
commit 8abbbdf6fa
Notes: sideshowbarker 2024-07-17 09:38:29 +09:00
2 changed files with 6 additions and 6 deletions

View File

@ -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;

View File

@ -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;