From bbf4f546af4706da24da7bda24209ce2069ea03d Mon Sep 17 00:00:00 2001 From: Gingeh <39150378+Gingeh@users.noreply.github.com> Date: Sun, 13 Apr 2025 18:58:40 +1000 Subject: [PATCH] LibWeb: Only create backdrop when originating element is invalidated --- Libraries/LibWeb/Layout/TreeBuilder.cpp | 3 +++ .../dialog-backdrop-update.txt | 26 +++++++++++++++++++ .../dialog-backdrop-update.html | 13 ++++++++++ 3 files changed, 42 insertions(+) create mode 100644 Tests/LibWeb/Layout/expected/layout-tree-update/dialog-backdrop-update.txt create mode 100644 Tests/LibWeb/Layout/input/layout-tree-update/dialog-backdrop-update.html diff --git a/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Libraries/LibWeb/Layout/TreeBuilder.cpp index a91f6f43a74..04eeafde4d7 100644 --- a/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -570,6 +570,9 @@ void TreeBuilder::update_layout_tree(DOM::Node& dom_node, TreeBuilder::Context& if (top_layer_element->rendered_in_top_layer()) { // Each element rendered in the top layer has a ::backdrop pseudo-element, for which it is the originating element. [&]() { + if (!should_create_layout_node && !top_layer_element->needs_layout_tree_update()) + return; + if (top_layer_element->has_inclusive_ancestor_with_display_none()) return; diff --git a/Tests/LibWeb/Layout/expected/layout-tree-update/dialog-backdrop-update.txt b/Tests/LibWeb/Layout/expected/layout-tree-update/dialog-backdrop-update.txt new file mode 100644 index 00000000000..0d8d58ad42b --- /dev/null +++ b/Tests/LibWeb/Layout/expected/layout-tree-update/dialog-backdrop-update.txt @@ -0,0 +1,26 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x16 [BFC] children: not-inline + BlockContainer
at (8,8) content-size 784x0 children: inline + TextNode <#text> + TextNode <#text> + TextNode <#text> + BlockContainer <(anonymous)> at (0,0) content-size 800x600 positioned [BFC] children: not-inline + BlockContainer