Ver código fonte

LibWeb: Use separate restore() for each ApplyFilters display list item

ApplyFilter internally calls canvas.saveLayer() which requires a
matching canvas.restore() to be called.

Fixes painting on https://supabase.com/ regressed by
8562b0e33bd057d9aa5be1b6ce66db039bc99576
Aliaksandr Kalenik 7 meses atrás
pai
commit
c94b4316e7

+ 9 - 3
Libraries/LibWeb/Painting/SVGSVGPaintable.cpp

@@ -55,9 +55,9 @@ void SVGSVGPaintable::paint_svg_box(PaintContext& context, PaintableBox const& s
 {
 {
     auto const& computed_values = svg_box.computed_values();
     auto const& computed_values = svg_box.computed_values();
 
 
-    auto filters = svg_box.computed_values().filter();
+    auto const& filter = svg_box.computed_values().filter();
     auto masking_area = svg_box.get_masking_area();
     auto masking_area = svg_box.get_masking_area();
-    auto needs_to_save_state = computed_values.opacity() < 1 || svg_box.has_css_transform() || svg_box.get_masking_area().has_value() || !filters.is_none();
+    auto needs_to_save_state = computed_values.opacity() < 1 || svg_box.has_css_transform() || svg_box.get_masking_area().has_value();
 
 
     if (needs_to_save_state) {
     if (needs_to_save_state) {
         context.display_list_recorder().save();
         context.display_list_recorder().save();
@@ -67,7 +67,9 @@ void SVGSVGPaintable::paint_svg_box(PaintContext& context, PaintableBox const& s
         context.display_list_recorder().apply_opacity(computed_values.opacity());
         context.display_list_recorder().apply_opacity(computed_values.opacity());
     }
     }
 
 
-    context.display_list_recorder().apply_filters(filters);
+    if (!filter.is_none()) {
+        context.display_list_recorder().apply_filters(filter);
+    }
 
 
     if (svg_box.has_css_transform()) {
     if (svg_box.has_css_transform()) {
         auto transform_matrix = svg_box.transform();
         auto transform_matrix = svg_box.transform();
@@ -93,6 +95,10 @@ void SVGSVGPaintable::paint_svg_box(PaintContext& context, PaintableBox const& s
 
 
     paint_descendants(context, svg_box, phase);
     paint_descendants(context, svg_box, phase);
 
 
+    if (!filter.is_none()) {
+        context.display_list_recorder().restore();
+    }
+
     if (needs_to_save_state) {
     if (needs_to_save_state) {
         context.display_list_recorder().restore();
         context.display_list_recorder().restore();
     }
     }

+ 9 - 1
Libraries/LibWeb/Painting/StackingContext.cpp

@@ -327,7 +327,11 @@ void StackingContext::paint(PaintContext& context) const
         context.display_list_recorder().push_scroll_frame_id(*paintable_box().scroll_frame_id());
         context.display_list_recorder().push_scroll_frame_id(*paintable_box().scroll_frame_id());
     }
     }
     context.display_list_recorder().push_stacking_context(push_stacking_context_params);
     context.display_list_recorder().push_stacking_context(push_stacking_context_params);
-    context.display_list_recorder().apply_filters(paintable_box().computed_values().filter());
+
+    auto const& filter = computed_values.filter();
+    if (!filter.is_none()) {
+        context.display_list_recorder().apply_filters(paintable_box().computed_values().filter());
+    }
 
 
     if (auto mask_image = computed_values.mask_image()) {
     if (auto mask_image = computed_values.mask_image()) {
         auto mask_display_list = DisplayList::create();
         auto mask_display_list = DisplayList::create();
@@ -348,6 +352,10 @@ void StackingContext::paint(PaintContext& context) const
         }
         }
     }
     }
 
 
+    if (!filter.is_none()) {
+        context.display_list_recorder().restore();
+    }
+
     paint_internal(context);
     paint_internal(context);
     context.display_list_recorder().pop_stacking_context();
     context.display_list_recorder().pop_stacking_context();
     if (paintable_box().scroll_frame_id().has_value()) {
     if (paintable_box().scroll_frame_id().has_value()) {