From 087fcb84cb568fee1cc22ed949ebf132bccb4f0d Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Thu, 19 Sep 2024 22:51:57 +0100 Subject: [PATCH] LibWeb: Don't crash when resolving grid properties of inline elements Previously, attempting to get the computed value for a grid-template-rows or grid-template-columns property would cause a crash for inline elements. --- ... => getComputedStyle-no-paintable-box.txt} | 0 .../getComputedStyle-no-paintable-box.html | 21 +++++++++++++++++++ .../css/getComputedStyle-no-paintable.html | 15 ------------- .../CSS/ResolvedCSSStyleDeclaration.cpp | 4 ++-- 4 files changed, 23 insertions(+), 17 deletions(-) rename Tests/LibWeb/Text/expected/css/{getComputedStyle-no-paintable.txt => getComputedStyle-no-paintable-box.txt} (100%) create mode 100644 Tests/LibWeb/Text/input/css/getComputedStyle-no-paintable-box.html delete mode 100644 Tests/LibWeb/Text/input/css/getComputedStyle-no-paintable.html diff --git a/Tests/LibWeb/Text/expected/css/getComputedStyle-no-paintable.txt b/Tests/LibWeb/Text/expected/css/getComputedStyle-no-paintable-box.txt similarity index 100% rename from Tests/LibWeb/Text/expected/css/getComputedStyle-no-paintable.txt rename to Tests/LibWeb/Text/expected/css/getComputedStyle-no-paintable-box.txt diff --git a/Tests/LibWeb/Text/input/css/getComputedStyle-no-paintable-box.html b/Tests/LibWeb/Text/input/css/getComputedStyle-no-paintable-box.html new file mode 100644 index 000000000000..a29761227c4b --- /dev/null +++ b/Tests/LibWeb/Text/input/css/getComputedStyle-no-paintable-box.html @@ -0,0 +1,21 @@ + + + diff --git a/Tests/LibWeb/Text/input/css/getComputedStyle-no-paintable.html b/Tests/LibWeb/Text/input/css/getComputedStyle-no-paintable.html deleted file mode 100644 index 59895287277e..000000000000 --- a/Tests/LibWeb/Text/input/css/getComputedStyle-no-paintable.html +++ /dev/null @@ -1,15 +0,0 @@ - - - diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index 87bc7ff1565c..b7af79c58a6a 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -523,14 +523,14 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_propert // For grid-template-columns and grid-template-rows the resolved value is the used value. // https://www.w3.org/TR/css-grid-2/#resolved-track-list-standalone if (property_id == PropertyID::GridTemplateColumns) { - if (layout_node.paintable()) { + if (layout_node.paintable() && layout_node.paintable()->is_paintable_box()) { auto const& paintable_box = verify_cast(*layout_node.paintable()); if (auto used_values_for_grid_template_columns = paintable_box.used_values_for_grid_template_columns()) { return used_values_for_grid_template_columns; } } } else if (property_id == PropertyID::GridTemplateRows) { - if (layout_node.paintable()) { + if (layout_node.paintable() && layout_node.paintable()->is_paintable_box()) { auto const& paintable_box = verify_cast(*layout_node.paintable()); if (auto used_values_for_grid_template_rows = paintable_box.used_values_for_grid_template_rows()) { return used_values_for_grid_template_rows;