mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Support individual scale
CSS property
This commit is contained in:
parent
66a821e731
commit
9a7c9286c4
Notes:
github-actions[bot]
2024-11-22 19:07:43 +00:00
Author: https://github.com/awesomekling
Commit: 9a7c9286c4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2506
Reviewed-by: https://github.com/shannonbooth
21 changed files with 234 additions and 55 deletions
|
@ -68,6 +68,7 @@
|
|||
#include <LibWeb/CSS/StyleValues/RectStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ResolutionStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/RotationStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ScaleStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ScrollbarGutterStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ShadowStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
|
||||
|
@ -6956,6 +6957,33 @@ RefPtr<CSSStyleValue> Parser::parse_translate_value(TokenStream<ComponentValue>&
|
|||
return TranslationStyleValue::create(maybe_x.release_value(), maybe_y.release_value());
|
||||
}
|
||||
|
||||
RefPtr<CSSStyleValue> Parser::parse_scale_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (tokens.remaining_token_count() == 1) {
|
||||
// "none"
|
||||
if (auto none = parse_all_as_single_keyword_value(tokens, Keyword::None))
|
||||
return none;
|
||||
}
|
||||
|
||||
auto transaction = tokens.begin_transaction();
|
||||
|
||||
auto maybe_x = parse_number_percentage(tokens);
|
||||
if (!maybe_x.has_value())
|
||||
return nullptr;
|
||||
|
||||
if (!tokens.has_next_token()) {
|
||||
transaction.commit();
|
||||
return ScaleStyleValue::create(maybe_x.value(), maybe_x.value());
|
||||
}
|
||||
|
||||
auto maybe_y = parse_number_percentage(tokens);
|
||||
if (!maybe_y.has_value())
|
||||
return nullptr;
|
||||
|
||||
transaction.commit();
|
||||
return ScaleStyleValue::create(maybe_x.release_value(), maybe_y.release_value());
|
||||
}
|
||||
|
||||
Optional<CSS::GridFitContent> Parser::parse_fit_content(Vector<ComponentValue> const& component_values)
|
||||
{
|
||||
// https://www.w3.org/TR/css-grid-2/#valdef-grid-template-columns-fit-content
|
||||
|
@ -7977,6 +8005,10 @@ Parser::ParseErrorOr<NonnullRefPtr<CSSStyleValue>> Parser::parse_css_value(Prope
|
|||
if (auto parsed_value = parse_translate_value(tokens); parsed_value && !tokens.has_next_token())
|
||||
return parsed_value.release_nonnull();
|
||||
return ParseError::SyntaxError;
|
||||
case PropertyID::Scale:
|
||||
if (auto parsed_value = parse_scale_value(tokens); parsed_value && !tokens.has_next_token())
|
||||
return parsed_value.release_nonnull();
|
||||
return ParseError::SyntaxError;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue