SVG foreignObject elements expose SVGGraphicsElement methods, including getBBox(), but their layout boxes create SVGForeignObjectPaintable, rather than SVGGraphicsPaintable. Only SVGGraphicsPaintable stores the computed SVG transform data, so use it only when that paintable kind is present. Add reduced crash coverage for calling getBBox() on a rendered foreignObject element.
42 lines
2 KiB
C++
42 lines
2 KiB
C++
/*
|
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Layout/SVGForeignObjectBox.h>
|
|
#include <LibWeb/Painting/PaintableWithLines.h>
|
|
#include <LibWeb/Painting/SVGGraphicsPaintable.h>
|
|
#include <LibWeb/Painting/SVGMaskable.h>
|
|
|
|
namespace Web::Painting {
|
|
|
|
class SVGForeignObjectPaintable final : public PaintableWithLines
|
|
, public SVGMaskable {
|
|
public:
|
|
static NonnullRefPtr<SVGForeignObjectPaintable> create(Layout::SVGForeignObjectBox const&);
|
|
virtual StringView class_name() const override { return "SVGForeignObjectPaintable"sv; }
|
|
|
|
virtual void paint(DisplayListRecordingContext&, PaintPhase) const override;
|
|
|
|
Layout::SVGForeignObjectBox const& layout_box() const;
|
|
|
|
virtual GC::Ptr<DOM::Node const> dom_node_of_svg() const override { return dom_node(); }
|
|
virtual Optional<CSSPixelRect> get_mask_area() const override { return get_svg_mask_area(); }
|
|
virtual Optional<Gfx::MaskKind> get_mask_type() const override { return get_svg_mask_type(); }
|
|
virtual Optional<DisplayListResource> calculate_mask(DisplayListRecordingContext& context, CSSPixelRect const& mask_area) const override { return calculate_svg_mask_display_list(context, mask_area); }
|
|
virtual Optional<CSSPixelRect> get_clip_area() const override { return get_svg_clip_area(); }
|
|
virtual Optional<DisplayListResource> calculate_clip(DisplayListRecordingContext& context, CSSPixelRect const& clip_area) const override { return calculate_svg_clip_display_list(context, clip_area); }
|
|
|
|
void set_computed_transforms(SVGGraphicsPaintable::ComputedTransforms computed_transforms) { m_computed_transforms = computed_transforms; }
|
|
SVGGraphicsPaintable::ComputedTransforms const& computed_transforms() const { return m_computed_transforms; }
|
|
|
|
protected:
|
|
SVGForeignObjectPaintable(Layout::SVGForeignObjectBox const&);
|
|
|
|
SVGGraphicsPaintable::ComputedTransforms m_computed_transforms;
|
|
};
|
|
|
|
}
|