From 1036e104ef45997af3950cff3c49558f9b151041 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Mon, 25 Mar 2024 12:23:42 +0100 Subject: [PATCH] LibWeb: Remove cache for Paintable::is_visible() ...because it depends on computed values that could be changed without rebuilding paintable tree. --- Tests/LibWeb/Ref/change-opacity.html | 14 ++++++++++++++ Tests/LibWeb/Ref/reference/change-opacity-ref.html | 9 +++++++++ Userland/Libraries/LibWeb/Painting/Paintable.cpp | 8 ++++++-- Userland/Libraries/LibWeb/Painting/Paintable.h | 3 +-- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 Tests/LibWeb/Ref/change-opacity.html create mode 100644 Tests/LibWeb/Ref/reference/change-opacity-ref.html diff --git a/Tests/LibWeb/Ref/change-opacity.html b/Tests/LibWeb/Ref/change-opacity.html new file mode 100644 index 0000000000..3ef454a923 --- /dev/null +++ b/Tests/LibWeb/Ref/change-opacity.html @@ -0,0 +1,14 @@ + + + +
+ diff --git a/Tests/LibWeb/Ref/reference/change-opacity-ref.html b/Tests/LibWeb/Ref/reference/change-opacity-ref.html new file mode 100644 index 0000000000..ef1e2f1863 --- /dev/null +++ b/Tests/LibWeb/Ref/reference/change-opacity-ref.html @@ -0,0 +1,9 @@ + + +
diff --git a/Userland/Libraries/LibWeb/Painting/Paintable.cpp b/Userland/Libraries/LibWeb/Painting/Paintable.cpp index 244fbe8566..74ace4dee4 100644 --- a/Userland/Libraries/LibWeb/Painting/Paintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/Paintable.cpp @@ -17,8 +17,6 @@ Paintable::Paintable(Layout::Node const& layout_node) , m_browsing_context(const_cast(layout_node.browsing_context())) { auto& computed_values = layout_node.computed_values(); - m_visible = computed_values.visibility() == CSS::Visibility::Visible && computed_values.opacity() != 0; - if (layout_node.is_grid_item() && computed_values.z_index().has_value()) { // https://www.w3.org/TR/css-grid-2/#z-order // grid items with z_index should behave as if position were "relative" @@ -48,6 +46,12 @@ void Paintable::visit_edges(Cell::Visitor& visitor) visitor.visit(m_containing_block.value()); } +bool Paintable::is_visible() const +{ + auto const& computed_values = this->computed_values(); + return computed_values.visibility() == CSS::Visibility::Visible && computed_values.opacity() != 0; +} + void Paintable::set_dom_node(JS::GCPtr dom_node) { m_dom_node = dom_node; diff --git a/Userland/Libraries/LibWeb/Painting/Paintable.h b/Userland/Libraries/LibWeb/Painting/Paintable.h index 667cb5eded..bb2dc9d44f 100644 --- a/Userland/Libraries/LibWeb/Painting/Paintable.h +++ b/Userland/Libraries/LibWeb/Painting/Paintable.h @@ -56,7 +56,7 @@ class Paintable public: virtual ~Paintable(); - [[nodiscard]] bool is_visible() const { return m_visible; } + [[nodiscard]] bool is_visible() const; [[nodiscard]] bool is_positioned() const { return m_positioned; } [[nodiscard]] bool is_fixed_position() const { return m_fixed_position; } [[nodiscard]] bool is_absolutely_positioned() const { return m_absolutely_positioned; } @@ -233,7 +233,6 @@ private: SelectionState m_selection_state { SelectionState::None }; - bool m_visible : 1 { false }; bool m_positioned : 1 { false }; bool m_fixed_position : 1 { false }; bool m_absolutely_positioned : 1 { false };