From 50225474d4ef24e90f3b988324fa400573823f3d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 24 Mar 2025 22:47:35 +0000 Subject: [PATCH] LibWeb: Skip "overlay" paint phase when there's no inspected node This avoids a bunch of tree traversal that doesn't find anything to paint anyway. --- Libraries/LibWeb/Painting/StackingContext.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Libraries/LibWeb/Painting/StackingContext.cpp b/Libraries/LibWeb/Painting/StackingContext.cpp index 67e5abc5861..bab8fa1791a 100644 --- a/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Libraries/LibWeb/Painting/StackingContext.cpp @@ -93,7 +93,8 @@ void StackingContext::paint_node_as_stacking_context(Paintable const& paintable, paint_node(paintable, context, PaintPhase::Foreground); paint_descendants(context, paintable, StackingContextPaintPhase::Foreground); paint_node(paintable, context, PaintPhase::Outline); - paint_node(paintable, context, PaintPhase::Overlay); + if (paintable.document().highlighted_layout_node()) + paint_node(paintable, context, PaintPhase::Overlay); paint_descendants(context, paintable, StackingContextPaintPhase::FocusAndOverlay); } @@ -186,7 +187,8 @@ void StackingContext::paint_descendants(PaintContext& context, Paintable const& break; case StackingContextPaintPhase::FocusAndOverlay: paint_node(child, context, PaintPhase::Outline); - paint_node(child, context, PaintPhase::Overlay); + if (child.document().highlighted_layout_node()) + paint_node(child, context, PaintPhase::Overlay); paint_descendants(context, child, phase); break; } @@ -278,7 +280,8 @@ void StackingContext::paint_internal(PaintContext& context) const paint_node(paintable_box(), context, PaintPhase::Outline); if (context.should_paint_overlay()) { - paint_node(paintable_box(), context, PaintPhase::Overlay); + if (paintable_box().document().highlighted_layout_node()) + paint_node(paintable_box(), context, PaintPhase::Overlay); paint_descendants(context, paintable_box(), StackingContextPaintPhase::FocusAndOverlay); } }