Commit graph

15 commits

Author SHA1 Message Date
MacDue
6f8c2dc322 LibWeb: Make SVG transform parser less crashy
Previously, this would blindly use parse_number() without checking if
there was a number to parse. This meant we would crash on transforms
like:
	rotate(BAD 32 0)

Now the attribute just gracefully fails to parse.
2023-05-27 18:40:41 +02:00
Cameron Youell
0afdde0eef LibWeb: Consume sign in SVG::parse_elliptical_arg_argument
This was crashing on google.com with the linux chrome user agent,
interestingly it seems like this behavior may have been accidental as
only two of the three `parse_number()` were changed in f7dbcb6
2023-05-26 14:54:00 +02:00
MacDue
3d54b9ffa3 LibWeb: Mark SVG::NumberPercentage accessors as const 2023-05-04 16:50:01 +02:00
MacDue
71938550fa LibWeb: Implement SVGGradientElement
This is the base class for all SVG gradient types. This supports:

- The `gradientUnits` attribute
- The `gradientTransform` attribute
- And following `xlink:hrefs` for inheriting <stops>/attributes
2023-04-28 09:42:28 +02:00
MacDue
297d8eebcd LibWeb: Add stop-color as a CSS property
(This is to set the color of a stop for an SVG gradient)
2023-04-28 09:42:28 +02:00
Andreas Kling
7f79208759 LibWeb: Support implicit lineto commands after moveto in SVG paths
Per SVG2, any coordinate pairs following a moveto command should be
treated as implicit lineto commands with the same absoluteness as the
moveto command.
2023-04-17 14:18:45 +02:00
MacDue
5df4e64eb7 LibWeb: Implement SVG preserveAspectRatio attribute
This attribute is used to define how the viewBox should be scaled.
Previously the behaviour implemented was that of "xMidYMid meet", now
all of them work (expect none :P).

With this the Discord login backend is now correctly scaled/positioned.

This also brings our SVG code a little closer to the spec! With spec
comments and all :^)

(Minor non-visible update to layout tests)
2023-04-17 07:32:31 +02:00
MacDue
62f087bd56 LibWeb: Add SVG transform parsing
This parses SVG transforms using the syntax from CSS Transforms
Module Level 1. Note: This looks very similar to CSS tranforms, but
the syntax is not compatible. For example, SVG rotate() is
rotate(<a> <x> <y>) where all parameters are unitless numbers whereas
CSS rotate() is rotate(<angle> unit) along with separate rotateX/Y/Z().

(At the same time AttributeParser is updated to use GenericLexer which
makes for easier string matching).

There is work needed for error handling (which AttributeParser does not
deal with very gracefully right now).
2023-04-12 07:40:22 +02:00
davidot
1ab6cb1ee9 LibWeb: Make SVG::AttributeParser use the new double parser
Because the result will be a float anyway get rid of the int parsing.
Also the grammar of SVG numbers matches the double parser grammar except
it can't have a sign but that should have been checked by the caller.
2022-10-23 15:48:45 +02:00
Simon Danner
f7dbcb652a LibWeb: SVG parse signed numbers in eliptical arc 2022-02-21 16:32:24 +01:00
Sam Atkins
44b64cb8b0 LibWeb: Make SVG AttributeParser::parse_path_data() static
This is mostly a style thing, but it matches the other APIs.
2022-02-11 21:38:27 +01:00
Sam Atkins
ab440b3e50 LibWeb: Use StringView instead of String in SVG::AttributeParser
This saves copying the string data, since the AttributeParser is always
temporary.
2022-02-11 21:38:27 +01:00
Sam Atkins
116a1f485c LibWeb: Add SVG <polyline> element and test case :^) 2022-02-11 21:38:27 +01:00
Sam Atkins
9424c67ed5 LibWeb: Expose SVG length/coordinate parsing methods
This is all still quite ad-hoc. Eventually these will both need to
support units (like with CSS Lengths) but for now we can continue only
using numbers.
2022-02-11 21:38:27 +01:00
Sam Atkins
82308fb71a LibWeb: Move SVG::PathDataParser into its own file and rename it
I've chosen the name `AttributeParser` since it parses data from
attributes. Rather than duplicate the parsing of numbers and other
basic types, let's make use of this existing parsing code for parsing
the data for `<line>`, `<polyline>`, etc.
2022-02-11 21:38:27 +01:00