mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-28 14:02:51 +00:00
LibWeb: Ensure transform of SVG <use> updates with x and y attributes
Rather than modify the transform of the parent (which could change independently), this adds a new override element_transform() where element specific tranfroms can be applied. This will always stay in sync with the attributes. A ref test comparing a .svg and .html version of the same file is added as due to differences in attribute parsing order, the .svg version was previously drawn incorrectly. Fixes #20859
This commit is contained in:
parent
90af21aef4
commit
720c27efbd
Notes:
sideshowbarker
2024-07-17 01:04:03 +09:00
Author: https://github.com/MacDue
Commit: 720c27efbd
Pull-request: https://github.com/SerenityOS/serenity/pull/20861
Issue: https://github.com/SerenityOS/serenity/issues/20859
Reviewed-by: https://github.com/AtkinsSJ ✅
7 changed files with 38 additions and 6 deletions
|
@ -72,13 +72,16 @@ Optional<StringView> SVGUseElement::parse_id_from_href(DeprecatedString const& h
|
|||
return href.substring_view(id_seperator.value() + 1);
|
||||
}
|
||||
|
||||
Gfx::AffineTransform SVGUseElement::element_transform() const
|
||||
{
|
||||
// The x and y properties define an additional transformation (translate(x,y), where x and y represent the computed value of the corresponding property)
|
||||
// to be applied to the ‘use’ element, after any transformations specified with other properties
|
||||
return Base::element_transform().translate(m_x.value_or(0), m_y.value_or(0));
|
||||
}
|
||||
|
||||
void SVGUseElement::inserted()
|
||||
{
|
||||
Base::inserted();
|
||||
|
||||
// The x and y properties define an additional transformation (translate(x,y), where x and y represent the computed value of the corresponding property)
|
||||
// to be applied to the ‘use’ element, after any transformations specified with other properties
|
||||
m_transform.translate(m_x.value_or(0), m_y.value_or(0));
|
||||
}
|
||||
|
||||
void SVGUseElement::svg_element_changed(SVGElement& svg_element)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue