mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-10 05:02:54 +00:00
LibWeb: Update SVG get_path()
API to take a viewport size
This will allow resolving paths that use sizes that are relative to the viewport. This necessarily removes the on element caching, which has been redundant for a while as computed paths are stored on the paintable.
This commit is contained in:
parent
1fbf1073ab
commit
b9afea40e6
Notes:
sideshowbarker
2024-07-19 01:59:31 +09:00
Author: https://github.com/MacDue
Commit: b9afea40e6
Pull-request: https://github.com/SerenityOS/serenity/pull/23455
Issue: https://github.com/SerenityOS/serenity/issues/23121
16 changed files with 55 additions and 126 deletions
|
@ -30,24 +30,17 @@ void SVGLineElement::attribute_changed(FlyString const& name, Optional<String> c
|
|||
|
||||
if (name == SVG::AttributeNames::x1) {
|
||||
m_x1 = AttributeParser::parse_coordinate(value.value_or(String {}));
|
||||
m_path.clear();
|
||||
} else if (name == SVG::AttributeNames::y1) {
|
||||
m_y1 = AttributeParser::parse_coordinate(value.value_or(String {}));
|
||||
m_path.clear();
|
||||
} else if (name == SVG::AttributeNames::x2) {
|
||||
m_x2 = AttributeParser::parse_coordinate(value.value_or(String {}));
|
||||
m_path.clear();
|
||||
} else if (name == SVG::AttributeNames::y2) {
|
||||
m_y2 = AttributeParser::parse_coordinate(value.value_or(String {}));
|
||||
m_path.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Gfx::Path& SVGLineElement::get_path()
|
||||
Gfx::Path SVGLineElement::get_path(CSSPixelSize)
|
||||
{
|
||||
if (m_path.has_value())
|
||||
return m_path.value();
|
||||
|
||||
Gfx::Path path;
|
||||
float x1 = m_x1.value_or(0);
|
||||
float y1 = m_y1.value_or(0);
|
||||
|
@ -60,8 +53,7 @@ Gfx::Path& SVGLineElement::get_path()
|
|||
// 2. perform an absolute lineto operation to absolute location (x2,y2)
|
||||
path.line_to({ x2, y2 });
|
||||
|
||||
m_path = move(path);
|
||||
return m_path.value();
|
||||
return path;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/SVG11/shapes.html#LineElementX1Attribute
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue