1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:47:44 +00:00

LibWeb: Flesh out SVGMaskElement a bit

- Add method to resolve the masking area (based on the target element
  size)
- Parse the maskUnits and maskContentUnits attributes
This commit is contained in:
MacDue 2023-09-10 14:00:47 +01:00 committed by Andreas Kling
parent 0af8d81f48
commit 650180811e
5 changed files with 55 additions and 6 deletions

View file

@ -497,15 +497,17 @@ Optional<PreserveAspectRatio> AttributeParser::parse_preserve_aspect_ratio(Strin
}
// https://svgwg.org/svg2-draft/pservers.html#LinearGradientElementGradientUnitsAttribute
Optional<GradientUnits> AttributeParser::parse_gradient_units(StringView input)
// https://drafts.fxtf.org/css-masking/#element-attrdef-mask-maskunits
// https://drafts.fxtf.org/css-masking/#element-attrdef-mask-maskcontentunits
Optional<SVGUnits> AttributeParser::parse_units(StringView input)
{
GenericLexer lexer { input };
lexer.ignore_while(whitespace);
auto gradient_units_string = lexer.consume_until(whitespace);
if (gradient_units_string == "userSpaceOnUse"sv)
return GradientUnits::UserSpaceOnUse;
return SVGUnits::UserSpaceOnUse;
if (gradient_units_string == "objectBoundingBox"sv)
return GradientUnits::ObjectBoundingBox;
return SVGUnits::ObjectBoundingBox;
return {};
}