Skip to content

Commit 9b7a0ea

Browse files
committed
LibWeb: Restrict style-derived layout predicates
Move layout predicates that require computed values from Node to NodeWithStyle. Make their style dependency explicit and remove repeated runtime checks that treated TextNode as a false result. Keep generic flow classification on Node because text nodes participate in flow, while routing styled nodes through the direct implementation.
1 parent 9cb93a0 commit 9b7a0ea

5 files changed

Lines changed: 119 additions & 134 deletions

File tree

Libraries/LibWeb/Layout/FormattingContext.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1802,7 +1802,8 @@ static Optional<CSSPixelRect> compute_inline_containing_block_rect(InlineNode co
18021802
}
18031803

18041804
for (auto child = node.first_child(); child; child = child->next_sibling()) {
1805-
if (child->is_absolutely_positioned() || child->is_floating())
1805+
auto const* child_with_style = as_if<NodeWithStyle>(*child);
1806+
if (child_with_style && (child_with_style->is_absolutely_positioned() || child_with_style->is_floating()))
18061807
continue;
18071808
auto const* child_used_values = state.try_get(*child);
18081809
auto child_offset = child_used_values ? offset + child_used_values->content_offset() : offset;

Libraries/LibWeb/Layout/InlineLevelIterator.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ Optional<InlineLevelIterator::Item> InlineLevelIterator::generate_next_item()
379379
return item;
380380
}
381381

382-
if (m_current_node->is_absolutely_positioned()) {
382+
auto const& current_node_with_style = as<NodeWithStyle>(*m_current_node);
383+
if (current_node_with_style.is_absolutely_positioned()) {
383384
auto const& node = *m_current_node;
384385
auto has_unattached_inline_start_edges = m_extra_leading_metrics.has_value()
385386
&& (m_extra_leading_metrics->margin != 0 || m_extra_leading_metrics->border != 0 || m_extra_leading_metrics->padding != 0);
@@ -391,7 +392,7 @@ Optional<InlineLevelIterator::Item> InlineLevelIterator::generate_next_item()
391392
};
392393
}
393394

394-
if (m_current_node->is_floating()) {
395+
if (current_node_with_style.is_floating()) {
395396
auto const& node = *m_current_node;
396397
skip_to_next();
397398
return Item {

0 commit comments

Comments
 (0)