Repository: LadybirdBrowser/ladybird
File: Libraries/LibWeb/Painting/DisplayListRecorder.h (C/C++)

Code before:
    // Streamlined text drawing routine that does no wrapping/elision/alignment.
    void draw_glyph_run(Gfx::FloatPoint baseline_start, Gfx::GlyphRun const& glyph_run, Color color, Gfx::IntRect const& rect, double scale, Gfx::Orientation);

    void add_clip_rect(Gfx::IntRect const& rect);

    void translate(Gfx::IntPoint delta);

    void push_scroll_frame_id(Optional<i32> id);
    void pop_scroll_frame_id();

    void push_clip_frame(RefPtr<ClipFrame const>);
    void pop_clip_frame();

    void save();
    void save_layer();
    void restore();

    struct PushStackingContextParams {
        float opacity;
        Gfx::CompositingAndBlendingOperator compositing_and_blending_operator;
        bool isolate;
        StackingContextTransform transform;
        Optional<Gfx::Path> clip_path = {};
        Optional<Gfx::IntRect> bounding_rect {};

        bool has_effect() const { return opacity != 1.0f || compositing_and_blending_operator != Gfx::CompositingAndBlendingOperator::Normal || isolate || clip_path.has_value() || !transform.is_identity() || bounding_rect.has_value(); }
    };
    void push_stacking_context(PushStackingContextParams params);
    void pop_stacking_context();

    void paint_nested_display_list(RefPtr<DisplayList> display_list, Gfx::IntRect rect);

    void add_rounded_rect_clip(CornerRadii corner_radii, Gfx::IntRect border_rect, CornerClip corner_clip);
    void add_mask(RefPtr<DisplayList> display_list, Gfx::IntRect rect);

    void apply_backdrop_filter(Gfx::IntRect const& backdrop_region, BorderRadiiData const& border_radii_data, Gfx::Filter const& backdrop_filter);

    void paint_outer_box_shadow(PaintBoxShadowParams params);
    void paint_inner_box_shadow(PaintBoxShadowParams params);
    void paint_text_shadow(int blur_radius, Gfx::IntRect bounding_rect, Gfx::IntRect text_rect, Gfx::GlyphRun const&, double glyph_run_scale, Color color, Gfx::FloatPoint draw_location);

    void fill_rect_with_rounded_corners(Gfx::IntRect const& rect, Color color, CornerRadii const&);
    void fill_rect_with_rounded_corners(Gfx::IntRect const& a_rect, Color color, int radius);
    void fill_rect_with_rounded_corners(Gfx::IntRect const& a_rect, Color color, int top_left_radius, int top_right_radius, int bottom_right_radius, int bottom_left_radius);

    void paint_scrollbar(int scroll_frame_id, Gfx::IntRect gutter_rect, Gfx::IntRect thumb_rect, CSSPixelFraction scroll_size, Color thumb_color, Color track_color, bool vertical);

    void apply_opacity(float opacity);
    void apply_compositing_and_blending_operator(Gfx::CompositingAndBlendingOperator compositing_and_blending_operator);
    void apply_filter(Gfx::Filter filter);
    void apply_transform(Gfx::FloatPoint origin, Gfx::FloatMatrix4x4);

Review comment (suggestion):
we don't need `bounding_rect.has_value()` here, because paint containment doesn't produce any visual effect. otherwise LGTM.

Code after:
    // Streamlined text drawing routine that does no wrapping/elision/alignment.
    void draw_glyph_run(Gfx::FloatPoint baseline_start, Gfx::GlyphRun const& glyph_run, Color color, Gfx::IntRect const& rect, double scale, Gfx::Orientation);

    void add_clip_rect(Gfx::IntRect const& rect);

    void translate(Gfx::IntPoint delta);

    void push_scroll_frame_id(Optional<i32> id);
    void pop_scroll_frame_id();

    void push_clip_frame(RefPtr<ClipFrame const>);
    void pop_clip_frame();

    void save();
    void save_layer();
    void restore();

    struct PushStackingContextParams {
        float opacity;
        Gfx::CompositingAndBlendingOperator compositing_and_blending_operator;
        bool isolate;
        StackingContextTransform transform;
        Optional<Gfx::Path> clip_path = {};
        Optional<Gfx::IntRect> bounding_rect {};

        bool has_effect() const { return opacity != 1.0f || compositing_and_blending_operator != Gfx::CompositingAndBlendingOperator::Normal || isolate || clip_path.has_value() || !transform.is_identity(); }
    };
    void push_stacking_context(PushStackingContextParams params);
    void pop_stacking_context();

    void paint_nested_display_list(RefPtr<DisplayList> display_list, Gfx::IntRect rect);

    void add_rounded_rect_clip(CornerRadii corner_radii, Gfx::IntRect border_rect, CornerClip corner_clip);
    void add_mask(RefPtr<DisplayList> display_list, Gfx::IntRect rect);

    void apply_backdrop_filter(Gfx::IntRect const& backdrop_region, BorderRadiiData const& border_radii_data, Gfx::Filter const& backdrop_filter);

    void paint_outer_box_shadow(PaintBoxShadowParams params);
    void paint_inner_box_shadow(PaintBoxShadowParams params);
    void paint_text_shadow(int blur_radius, Gfx::IntRect bounding_rect, Gfx::IntRect text_rect, Gfx::GlyphRun const&, double glyph_run_scale, Color color, Gfx::FloatPoint draw_location);

    void fill_rect_with_rounded_corners(Gfx::IntRect const& rect, Color color, CornerRadii const&);
    void fill_rect_with_rounded_corners(Gfx::IntRect const& a_rect, Color color, int radius);
    void fill_rect_with_rounded_corners(Gfx::IntRect const& a_rect, Color color, int top_left_radius, int top_right_radius, int bottom_right_radius, int bottom_left_radius);

    void paint_scrollbar(int scroll_frame_id, Gfx::IntRect gutter_rect, Gfx::IntRect thumb_rect, CSSPixelFraction scroll_size, Color thumb_color, Color track_color, bool vertical);

    void apply_opacity(float opacity);
    void apply_compositing_and_blending_operator(Gfx::CompositingAndBlendingOperator compositing_and_blending_operator);
    void apply_filter(Gfx::Filter filter);
    void apply_transform(Gfx::FloatPoint origin, Gfx::FloatMatrix4x4);