mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
Prior to this change, SVGs were following the CSS painting order, which means SVG boxes could have established stacking context and be sorted by z-index. There is a section in the spec that defines what kind of SVG boxes should create a stacking context https://www.w3.org/TR/SVG2/render.html#EstablishingStackingContex Although this spec is marked as a draft and rendering order described in this spec does not match what other engines do. This spec issue comment has a good summary of what other engines actually do regarding painting order https://github.com/w3c/svgwg/issues/264#issuecomment-246432360 "as long as you're relying solely on the default z-index (which SVG1 does, by definition), nothing ever changes order when you apply opacity/filter/etc". This change aligns our implementation with other engines by forbidding SVGs to create a formatting context and painting them in order they are defined in tree tree.
113 lines
4.4 KiB
C++
113 lines
4.4 KiB
C++
/*
|
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Forward.h>
|
|
#include <AK/NonnullRefPtr.h>
|
|
#include <AK/SegmentedVector.h>
|
|
#include <AK/Utf8View.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibGfx/AntiAliasingPainter.h>
|
|
#include <LibGfx/Color.h>
|
|
#include <LibGfx/Forward.h>
|
|
#include <LibGfx/Gradients.h>
|
|
#include <LibGfx/ImmutableBitmap.h>
|
|
#include <LibGfx/PaintStyle.h>
|
|
#include <LibGfx/Palette.h>
|
|
#include <LibGfx/Point.h>
|
|
#include <LibGfx/Rect.h>
|
|
#include <LibGfx/Size.h>
|
|
#include <LibGfx/TextAlignment.h>
|
|
#include <LibGfx/TextLayout.h>
|
|
#include <LibWeb/CSS/Enums.h>
|
|
#include <LibWeb/Painting/BorderRadiiData.h>
|
|
#include <LibWeb/Painting/BorderRadiusCornerClipper.h>
|
|
#include <LibWeb/Painting/Command.h>
|
|
#include <LibWeb/Painting/GradientData.h>
|
|
#include <LibWeb/Painting/PaintBoxShadowParams.h>
|
|
#include <LibWeb/Painting/ScrollFrame.h>
|
|
|
|
namespace Web::Painting {
|
|
|
|
class DisplayList;
|
|
|
|
class DisplayListPlayer {
|
|
public:
|
|
virtual ~DisplayListPlayer() = default;
|
|
|
|
void execute(DisplayList& display_list);
|
|
|
|
private:
|
|
virtual void draw_glyph_run(DrawGlyphRun const&) = 0;
|
|
virtual void fill_rect(FillRect const&) = 0;
|
|
virtual void draw_scaled_bitmap(DrawScaledBitmap const&) = 0;
|
|
virtual void draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) = 0;
|
|
virtual void draw_repeated_immutable_bitmap(DrawRepeatedImmutableBitmap const&) = 0;
|
|
virtual void save(Save const&) = 0;
|
|
virtual void restore(Restore const&) = 0;
|
|
virtual void add_clip_rect(AddClipRect const&) = 0;
|
|
virtual void push_stacking_context(PushStackingContext const&) = 0;
|
|
virtual void pop_stacking_context(PopStackingContext const&) = 0;
|
|
virtual void paint_linear_gradient(PaintLinearGradient const&) = 0;
|
|
virtual void paint_radial_gradient(PaintRadialGradient const&) = 0;
|
|
virtual void paint_conic_gradient(PaintConicGradient const&) = 0;
|
|
virtual void paint_outer_box_shadow(PaintOuterBoxShadow const&) = 0;
|
|
virtual void paint_inner_box_shadow(PaintInnerBoxShadow const&) = 0;
|
|
virtual void paint_text_shadow(PaintTextShadow const&) = 0;
|
|
virtual void fill_rect_with_rounded_corners(FillRectWithRoundedCorners const&) = 0;
|
|
virtual void fill_path_using_color(FillPathUsingColor const&) = 0;
|
|
virtual void fill_path_using_paint_style(FillPathUsingPaintStyle const&) = 0;
|
|
virtual void stroke_path_using_color(StrokePathUsingColor const&) = 0;
|
|
virtual void stroke_path_using_paint_style(StrokePathUsingPaintStyle const&) = 0;
|
|
virtual void draw_ellipse(DrawEllipse const&) = 0;
|
|
virtual void fill_ellipse(FillEllipse const&) = 0;
|
|
virtual void draw_line(DrawLine const&) = 0;
|
|
virtual void apply_backdrop_filter(ApplyBackdropFilter const&) = 0;
|
|
virtual void draw_rect(DrawRect const&) = 0;
|
|
virtual void draw_triangle_wave(DrawTriangleWave const&) = 0;
|
|
virtual void add_rounded_rect_clip(AddRoundedRectClip const&) = 0;
|
|
virtual void add_mask(AddMask const&) = 0;
|
|
virtual void paint_nested_display_list(PaintNestedDisplayList const&) = 0;
|
|
virtual void paint_scrollbar(PaintScrollBar const&) = 0;
|
|
virtual void apply_opacity(ApplyOpacity const&) = 0;
|
|
virtual void apply_transform(ApplyTransform const&) = 0;
|
|
virtual void apply_mask_bitmap(ApplyMaskBitmap const&) = 0;
|
|
virtual bool would_be_fully_clipped_by_painter(Gfx::IntRect) const = 0;
|
|
};
|
|
|
|
class DisplayList : public RefCounted<DisplayList> {
|
|
public:
|
|
static NonnullRefPtr<DisplayList> create()
|
|
{
|
|
return adopt_ref(*new DisplayList());
|
|
}
|
|
|
|
void append(Command&& command, Optional<i32> scroll_frame_id);
|
|
|
|
struct CommandListItem {
|
|
Optional<i32> scroll_frame_id;
|
|
Command command;
|
|
};
|
|
|
|
AK::SegmentedVector<CommandListItem, 512> const& commands() const { return m_commands; }
|
|
|
|
void set_scroll_state(Vector<RefPtr<ScrollFrame>> scroll_state) { m_scroll_state = move(scroll_state); }
|
|
|
|
Vector<RefPtr<ScrollFrame>> const& scroll_state() const { return m_scroll_state; }
|
|
|
|
void set_device_pixels_per_css_pixel(double device_pixels_per_css_pixel) { m_device_pixels_per_css_pixel = device_pixels_per_css_pixel; }
|
|
double device_pixels_per_css_pixel() const { return m_device_pixels_per_css_pixel; }
|
|
|
|
private:
|
|
DisplayList() = default;
|
|
|
|
AK::SegmentedVector<CommandListItem, 512> m_commands;
|
|
Vector<RefPtr<ScrollFrame>> m_scroll_state;
|
|
double m_device_pixels_per_css_pixel;
|
|
};
|
|
|
|
}
|