From 9937fcc5e1a4350c294d2d9048bfe67559f7039a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 31 Jul 2023 08:26:30 +0200 Subject: [PATCH] LibWeb: Don't assume opacity values are CSS numbers ...since they can also be percentages. Better to resolve them to a pair of absolute values, and then compare those. :^) Regressed in 921aee8c666fbab2dcdba27cbefc942f1a144180. --- .../css/element-opacity-change-invalidation.txt | 1 + .../css/element-opacity-change-invalidation.html | 12 ++++++++++++ Userland/Libraries/LibWeb/DOM/Element.cpp | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/css/element-opacity-change-invalidation.txt create mode 100644 Tests/LibWeb/Text/input/css/element-opacity-change-invalidation.html diff --git a/Tests/LibWeb/Text/expected/css/element-opacity-change-invalidation.txt b/Tests/LibWeb/Text/expected/css/element-opacity-change-invalidation.txt new file mode 100644 index 00000000000..cbed30a0877 --- /dev/null +++ b/Tests/LibWeb/Text/expected/css/element-opacity-change-invalidation.txt @@ -0,0 +1 @@ +Didn't crash :^) diff --git a/Tests/LibWeb/Text/input/css/element-opacity-change-invalidation.html b/Tests/LibWeb/Text/input/css/element-opacity-change-invalidation.html new file mode 100644 index 00000000000..3591f9e349e --- /dev/null +++ b/Tests/LibWeb/Text/input/css/element-opacity-change-invalidation.html @@ -0,0 +1,12 @@ + + diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index aa9feaafcb4..a305a316c5a 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -425,8 +425,8 @@ static Element::RequiredInvalidationAfterStyleChange compute_required_invalidati // OPTIMIZATION: An element creates a stacking context when its opacity changes from 1 to less than 1 // and stops to create one when opacity returns to 1. So stacking context tree rebuild is // not required for opacity changes within the range below 1. - auto old_value_opacity = old_value.has_value() ? old_value->style->as_number().number() : 1; - auto new_value_opacity = new_value.has_value() ? new_value->style->as_number().number() : 1; + auto old_value_opacity = old_style.opacity(); + auto new_value_opacity = new_style.opacity(); if (old_value_opacity != new_value_opacity && (old_value_opacity == 1 || new_value_opacity == 1)) { invalidation.rebuild_stacking_context_tree = true; }