1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:38:11 +00:00

LibWeb: Add SVG-presentation-attribute-parsing mode to CSS parser

When parsing these, <number> is allowed anywhere that would usually
allow a <length>, <length-percentage>, or <angle>. The spec is not
clear on exactly how this should work
(see https://github.com/w3c/svgwg/issues/792 ) so I'm using some
artistic license until things are clearer:
- If we expected a <length>, treat the <number> as pixels.
- If we expected an <angle>, treat the <number> as degrees.
- Only allow direct <number> tokens, not calc() or other functions.

From what I can tell this is what the spec *intended* but I may be very
wrong. In any case, telling the ParsingContext whether we're parsing
one of these attributes is a cleaner approach and more correct than
temporarily enabling quirks mode, which we did previously.
This commit is contained in:
Sam Atkins 2023-09-25 15:26:33 +01:00 committed by Andreas Kling
parent c46ce53ce3
commit 79a30c209d
3 changed files with 43 additions and 8 deletions

View file

@ -13,29 +13,33 @@
namespace Web::CSS::Parser {
ParsingContext::ParsingContext(JS::Realm& realm)
ParsingContext::ParsingContext(JS::Realm& realm, Mode mode)
: m_realm(realm)
, m_mode(mode)
{
}
ParsingContext::ParsingContext(DOM::Document const& document, AK::URL url)
ParsingContext::ParsingContext(DOM::Document const& document, AK::URL url, Mode mode)
: m_realm(const_cast<JS::Realm&>(document.realm()))
, m_document(&document)
, m_url(move(url))
, m_mode(mode)
{
}
ParsingContext::ParsingContext(DOM::Document const& document)
ParsingContext::ParsingContext(DOM::Document const& document, Mode mode)
: m_realm(const_cast<JS::Realm&>(document.realm()))
, m_document(&document)
, m_url(document.url())
, m_mode(mode)
{
}
ParsingContext::ParsingContext(DOM::ParentNode& parent_node)
ParsingContext::ParsingContext(DOM::ParentNode& parent_node, Mode mode)
: m_realm(parent_node.realm())
, m_document(&parent_node.document())
, m_url(parent_node.document().url())
, m_mode(mode)
{
}