From 8aaa9324b2b81bf4983bea1a17da45611a0b12c6 Mon Sep 17 00:00:00 2001 From: Psychpsyo Date: Sat, 23 Nov 2024 22:08:36 +0100 Subject: [PATCH] LibWeb: Unapply CSS filters after applying them to SVG --- Libraries/LibWeb/Painting/SVGSVGPaintable.cpp | 5 +++-- Tests/LibWeb/Ref/expected/svg-restore-after-filter.html | 5 +++++ Tests/LibWeb/Ref/input/svg-restore-after-filter.html | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 Tests/LibWeb/Ref/expected/svg-restore-after-filter.html create mode 100644 Tests/LibWeb/Ref/input/svg-restore-after-filter.html diff --git a/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp b/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp index 39d45b09205..90f59a86ecf 100644 --- a/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp +++ b/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp @@ -59,8 +59,9 @@ void SVGSVGPaintable::paint_descendants(PaintContext& context, PaintableBox cons auto paint_svg_box = [&](auto& svg_box) { auto const& computed_values = svg_box.computed_values(); + auto filters = paintable.computed_values().filter(); 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(); + auto needs_to_save_state = computed_values.opacity() < 1 || svg_box.has_css_transform() || svg_box.get_masking_area().has_value() || !filters.is_none(); if (needs_to_save_state) { context.display_list_recorder().save(); @@ -70,7 +71,7 @@ void SVGSVGPaintable::paint_descendants(PaintContext& context, PaintableBox cons context.display_list_recorder().apply_opacity(computed_values.opacity()); } - context.display_list_recorder().apply_filters(paintable.computed_values().filter()); + context.display_list_recorder().apply_filters(filters); if (svg_box.has_css_transform()) { auto transform_matrix = svg_box.transform(); diff --git a/Tests/LibWeb/Ref/expected/svg-restore-after-filter.html b/Tests/LibWeb/Ref/expected/svg-restore-after-filter.html new file mode 100644 index 00000000000..2ddb49cf93b --- /dev/null +++ b/Tests/LibWeb/Ref/expected/svg-restore-after-filter.html @@ -0,0 +1,5 @@ + + + + +This should be visible. diff --git a/Tests/LibWeb/Ref/input/svg-restore-after-filter.html b/Tests/LibWeb/Ref/input/svg-restore-after-filter.html new file mode 100644 index 00000000000..a605153608e --- /dev/null +++ b/Tests/LibWeb/Ref/input/svg-restore-after-filter.html @@ -0,0 +1,6 @@ + + + + + +This should be visible.