diff options
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 17 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/TransformFunctions.json | 63 |
2 files changed, 58 insertions, 22 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 5ee33377fe..6441f64180 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -5531,7 +5531,13 @@ RefPtr<StyleValue> Parser::parse_transform_value(Vector<ComponentValue> const& c NonnullRefPtrVector<StyleValue> values; auto argument_tokens = TokenStream { part.function().values() }; argument_tokens.skip_whitespace(); + size_t argument_index = 0; while (argument_tokens.has_next_token()) { + if (argument_index == function_metadata.parameters.size()) { + dbgln_if(CSS_PARSER_DEBUG, "Too many arguments to {}. max: {}", part.function().name(), function_metadata.parameters.size()); + return nullptr; + } + auto const& value = argument_tokens.next_token(); RefPtr<CalculatedStyleValue> maybe_calc_value; if (auto maybe_dynamic_value = parse_dynamic_value(value)) { @@ -5542,7 +5548,7 @@ RefPtr<StyleValue> Parser::parse_transform_value(Vector<ComponentValue> const& c maybe_calc_value = maybe_dynamic_value->as_calculated(); } - switch (function_metadata.parameter_type) { + switch (function_metadata.parameters[argument_index].type) { case TransformFunctionParameterType::Angle: { // These are `<angle> | <zero>` in the spec, so we have to check for both kinds. if (maybe_calc_value && maybe_calc_value->resolves_to_angle()) { @@ -5596,15 +5602,12 @@ RefPtr<StyleValue> Parser::parse_transform_value(Vector<ComponentValue> const& c if (!argument_tokens.has_next_token()) return nullptr; } - } - if (values.size() < function_metadata.min_parameters) { - dbgln_if(CSS_PARSER_DEBUG, "Not enough arguments to {}. min: {}, given: {}", part.function().name(), function_metadata.min_parameters, values.size()); - return nullptr; + argument_index++; } - if (values.size() > function_metadata.max_parameters) { - dbgln_if(CSS_PARSER_DEBUG, "Too many arguments to {}. max: {}, given: {}", part.function().name(), function_metadata.max_parameters, values.size()); + if (argument_index < function_metadata.parameters.size() && function_metadata.parameters[argument_index].required) { + dbgln_if(CSS_PARSER_DEBUG, "Required parameter at position {} is missing", argument_index); return nullptr; } diff --git a/Userland/Libraries/LibWeb/CSS/TransformFunctions.json b/Userland/Libraries/LibWeb/CSS/TransformFunctions.json index 510f73bcdb..bca5b145bb 100644 --- a/Userland/Libraries/LibWeb/CSS/TransformFunctions.json +++ b/Userland/Libraries/LibWeb/CSS/TransformFunctions.json @@ -1,47 +1,80 @@ { "matrix": { - "parameters": "<number>{6}" + "parameters": [ + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true } + ] }, "matrix3d": { - "parameters": "<number>{16}" + "parameters": [ + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true }, + { "type": "<number>", "required": true } + ] }, "translate": { - "parameters": "<length-percentage>{1,2}" + "parameters": [ + { "type": "<length-percentage>", "required": true }, + { "type": "<length-percentage>", "required": false } + ] }, "translateX": { - "parameters": "<length-percentage>" + "parameters": [{ "type": "<length-percentage>", "required": true }] }, "translateY": { - "parameters": "<length-percentage>" + "parameters": [{ "type": "<length-percentage>", "required": true }] }, "scale": { - "parameters": "<number>{1,2}" + "parameters": [ + { "type": "<number>", "required": true }, + { "type": "<number>", "required": false } + ] }, "scaleX": { - "parameters": "<number>" + "parameters": [{ "type": "<number>", "required": true }] }, "scaleY": { - "parameters": "<number>" + "parameters": [{ "type": "<number>", "required": true }] }, "rotate": { - "parameters": "<angle>" + "parameters": [{ "type": "<angle>", "required": true }] }, "rotateX": { - "parameters": "<angle>" + "parameters": [{ "type": "<angle>", "required": true }] }, "rotateY": { - "parameters": "<angle>" + "parameters": [{ "type": "<angle>", "required": true }] }, "rotateZ": { - "parameters": "<angle>" + "parameters": [{ "type": "<angle>", "required": true }] }, "skew": { - "parameters": "<angle>{1,2}" + "parameters": [ + { "type": "<angle>", "required": true }, + { "type": "<angle>", "required": false } + ] }, "skewX": { - "parameters": "<angle>" + "parameters": [{ "type": "<angle>", "required": true }] }, "skewY": { - "parameters": "<angle>" + "parameters": [{ "type": "<angle>", "required": true }] } } |