mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 02:13:56 +09:00
LibWeb: Do not forget to unapply empty masks
This commit is contained in:
parent
0402179331
commit
f52df06a2a
Notes:
github-actions[bot]
2025-05-13 08:32:02 +00:00
Author: https://github.com/Psychpsyo
Commit: f52df06a2a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4708
3 changed files with 27 additions and 12 deletions
|
@ -63,7 +63,7 @@ void SVGSVGPaintable::paint_svg_box(PaintContext& context, PaintableBox const& s
|
|||
|
||||
Gfx::CompositingAndBlendingOperator compositing_and_blending_operator = mix_blend_mode_to_compositing_and_blending_operator(computed_values.mix_blend_mode());
|
||||
|
||||
auto needs_to_save_state = computed_values.isolation() == CSS::Isolation::Isolate || compositing_and_blending_operator != Gfx::CompositingAndBlendingOperator::Normal || svg_box.has_css_transform() || svg_box.get_masking_area().has_value();
|
||||
auto needs_to_save_state = computed_values.isolation() == CSS::Isolation::Isolate || compositing_and_blending_operator != Gfx::CompositingAndBlendingOperator::Normal || svg_box.has_css_transform() || masking_area.has_value();
|
||||
|
||||
if (needs_to_save_state) {
|
||||
context.display_list_recorder().save();
|
||||
|
@ -88,22 +88,27 @@ void SVGSVGPaintable::paint_svg_box(PaintContext& context, PaintableBox const& s
|
|||
context.display_list_recorder().apply_transform(transform_origin.scaled(to_device_pixels_scale), matrix_with_scaled_translation(transform_matrix, to_device_pixels_scale));
|
||||
}
|
||||
|
||||
bool skip_painting = false;
|
||||
if (masking_area.has_value()) {
|
||||
if (masking_area->is_empty())
|
||||
return;
|
||||
auto mask_bitmap = svg_box.calculate_mask(context, *masking_area);
|
||||
if (mask_bitmap) {
|
||||
auto source_paintable_rect = context.enclosing_device_rect(*masking_area).template to_type<int>();
|
||||
auto origin = source_paintable_rect.location();
|
||||
context.display_list_recorder().apply_mask_bitmap(origin, mask_bitmap.release_nonnull(), *svg_box.get_mask_type());
|
||||
if (masking_area->is_empty()) {
|
||||
skip_painting = true;
|
||||
} else {
|
||||
auto mask_bitmap = svg_box.calculate_mask(context, *masking_area);
|
||||
if (mask_bitmap) {
|
||||
auto source_paintable_rect = context.enclosing_device_rect(*masking_area).template to_type<int>();
|
||||
auto origin = source_paintable_rect.location();
|
||||
context.display_list_recorder().apply_mask_bitmap(origin, mask_bitmap.release_nonnull(), *svg_box.get_mask_type());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
svg_box.before_paint(context, PaintPhase::Foreground);
|
||||
svg_box.paint(context, PaintPhase::Foreground);
|
||||
svg_box.after_paint(context, PaintPhase::Foreground);
|
||||
if (!skip_painting) {
|
||||
svg_box.before_paint(context, PaintPhase::Foreground);
|
||||
svg_box.paint(context, PaintPhase::Foreground);
|
||||
svg_box.after_paint(context, PaintPhase::Foreground);
|
||||
|
||||
paint_descendants(context, svg_box, phase);
|
||||
paint_descendants(context, svg_box, phase);
|
||||
}
|
||||
|
||||
if (compositing_and_blending_operator != Gfx::CompositingAndBlendingOperator::Normal) {
|
||||
context.display_list_recorder().restore();
|
||||
|
|
3
Tests/LibWeb/Ref/expected/svg/zero-area-mask-ref.html
Normal file
3
Tests/LibWeb/Ref/expected/svg/zero-area-mask-ref.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<!DOCTYPE html>
|
||||
This should be visible.
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="width: 0px"></svg>
|
7
Tests/LibWeb/Ref/input/svg/zero-area-mask.html
Normal file
7
Tests/LibWeb/Ref/input/svg/zero-area-mask.html
Normal file
|
@ -0,0 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<link rel="match" href="../../expected/svg/zero-area-mask-ref.html" />
|
||||
This should be visible.
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="width: 0px">
|
||||
<mask id="abc"></mask>
|
||||
<g mask="url(#abc)"></g>
|
||||
</svg>
|
Loading…
Add table
Add a link
Reference in a new issue