From 511d4951b044bcd9316b6935f3fe438cba3bd5e9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 14 Mar 2022 20:19:18 +0100 Subject: [PATCH] LibWeb: Don't access layout nodes in StyleComputer Style computation always happens *before* layout, so we can't rely on things having (or not having) layout nodes, as that information will always be one step behind. Instead, we have to use the DOM to find all the information we need. --- Userland/Libraries/LibWeb/CSS/StyleComputer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 1120c4be44..cd4561ee5d 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -800,7 +800,7 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele // Percentages refer to parent element's font size auto percentage = font_size->as_percentage().percentage(); auto parent_font_size = size; - if (parent_element && parent_element->layout_node() && parent_element->specified_css_values()) { + if (parent_element && parent_element->specified_css_values()) { auto value = parent_element->specified_css_values()->property(CSS::PropertyID::FontSize).value(); if (value->is_length()) { auto length = static_cast(*value).to_length(); @@ -954,8 +954,8 @@ static BoxTypeTransformation required_box_type_transformation(StyleProperties co // FIXME: Containment in a ruby container inlinifies the box’s display type, as described in [CSS-RUBY-1]. // A parent with a grid or flex display value blockifies the box’s display type. [CSS-GRID-1] [CSS-FLEXBOX-1] - if (element.parent() && element.parent()->layout_node()) { - auto const& parent_display = element.parent()->layout_node()->computed_values().display(); + if (element.parent_element() && element.parent_element()->specified_css_values()) { + auto const& parent_display = element.parent_element()->specified_css_values()->display(); if (parent_display.is_grid_inside() || parent_display.is_flex_inside()) return BoxTypeTransformation::Blockify; }