summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-03-17 12:32:21 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-18 15:18:48 +0100
commit15dc48b43125210f3376f019cdc60babd82f568b (patch)
tree072cdd2dc64f758529288592a516e8a9a9eb8bb5 /Userland
parentef8a72ff3f653094f615110efe30d72f8b54733d (diff)
downloadserenity-15dc48b43125210f3376f019cdc60babd82f568b.zip
LibWeb: Make PaintableBox::enclosing_stacking_context() cheaper
No need to call the expensive establishes_stacking_context() here, as we've already built the stacking context tree and can simply test for the presence of existing stacking contexts.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Painting/PaintableBox.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
index a4c65f1b3e..e0685a5b07 100644
--- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
+++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
@@ -86,10 +86,8 @@ Painting::StackingContext* PaintableBox::enclosing_stacking_context()
if (!is<Layout::Box>(ancestor))
continue;
auto& ancestor_box = static_cast<Layout::Box&>(const_cast<Layout::NodeWithStyle&>(*ancestor));
- if (!ancestor_box.establishes_stacking_context())
- continue;
- VERIFY(ancestor_box.paint_box()->stacking_context());
- return const_cast<StackingContext*>(ancestor_box.paint_box()->stacking_context());
+ if (auto* ancestor_paint_box = ancestor_box.paint_box(); ancestor_paint_box && ancestor_paint_box->stacking_context())
+ return const_cast<StackingContext*>(ancestor_paint_box->stacking_context());
}
// We should always reach the Layout::InitialContainingBlock stacking context.
VERIFY_NOT_REACHED();