mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:17:35 +00:00
LibWeb: Use width & height to create fallback viewBox for SVG-as-image
When embedding an SVG in an img element, if the external SVG's root element has both width and height attributes, but no viewBox attribute, we now create a fallback viewBox with "0 0 width height". This appears to match the behavior of other browsers. Inspired by discussion on Mozilla's bug tracker: https://bugzilla.mozilla.org/show_bug.cgi?id=614649
This commit is contained in:
parent
a0b4987e92
commit
9f24c1b34c
6 changed files with 66 additions and 2 deletions
|
@ -24,9 +24,11 @@ public:
|
|||
virtual bool requires_svg_container() const override { return false; }
|
||||
virtual bool is_svg_container() const override { return true; }
|
||||
|
||||
Optional<ViewBox> const& view_box() const { return m_view_box; }
|
||||
[[nodiscard]] Optional<ViewBox> view_box() const;
|
||||
Optional<PreserveAspectRatio> const& preserve_aspect_ratio() const { return m_preserve_aspect_ratio; }
|
||||
|
||||
void set_fallback_view_box_for_svg_as_image(Optional<ViewBox>);
|
||||
|
||||
private:
|
||||
SVGSVGElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
|
@ -36,8 +38,12 @@ private:
|
|||
|
||||
virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override;
|
||||
|
||||
void update_fallback_view_box_for_svg_as_image();
|
||||
|
||||
Optional<ViewBox> m_view_box;
|
||||
Optional<PreserveAspectRatio> m_preserve_aspect_ratio;
|
||||
|
||||
Optional<ViewBox> m_fallback_view_box_for_svg_as_image;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue