1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:17:36 +00:00

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.
This commit is contained in:
Sam Atkins 2022-02-11 15:48:42 +00:00 committed by Andreas Kling
parent 82308fb71a
commit 9424c67ed5
2 changed files with 57 additions and 1 deletions

View file

@ -39,6 +39,10 @@ public:
Vector<PathInstruction> parse_path_data();
static Optional<float> parse_coordinate(StringView input);
static Optional<float> parse_length(StringView input);
static Optional<float> parse_positive_length(StringView input);
private:
void parse_drawto();
@ -53,6 +57,7 @@ private:
void parse_smooth_quadratic_bezier_curveto();
void parse_elliptical_arc();
float parse_length();
float parse_coordinate();
Vector<float> parse_coordinate_pair();
Vector<float> parse_coordinate_sequence();
@ -71,6 +76,7 @@ private:
bool match_whitespace() const;
bool match_comma_whitespace() const;
bool match_coordinate() const;
bool match_length() const;
bool match(char c) const { return !done() && ch() == c; }
bool done() const { return m_cursor >= m_source.length(); }