Commit graph

11 commits

Author SHA1 Message Date
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
Ben Wiederhake
560133a0c6 Everywhere: Remove unused DeprecatedString includes 2023-04-09 22:00:54 +02:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01: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