mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:07:44 +00:00
LibWeb: Support transform: translate(...)
by percentage
This commit is contained in:
parent
bc5d39493b
commit
dc94879b83
4 changed files with 43 additions and 32 deletions
|
@ -72,7 +72,7 @@ public:
|
|||
|
||||
struct Transformation {
|
||||
CSS::TransformFunction function;
|
||||
Vector<Variant<CSS::Length, float>> values;
|
||||
Vector<Variant<CSS::LengthPercentage, float>> values;
|
||||
};
|
||||
|
||||
struct TransformOrigin {
|
||||
|
|
|
@ -3976,6 +3976,11 @@ RefPtr<StyleValue> Parser::parse_transform_value(Vector<StyleComponentValueRule>
|
|||
} else if (value.is(Token::Type::Number)) {
|
||||
auto number = parse_numeric_value(value);
|
||||
values.append(number.release_nonnull());
|
||||
} else if (value.is(Token::Type::Percentage)) {
|
||||
auto percentage = parse_dimension_value(value);
|
||||
if (!percentage || !percentage->is_percentage())
|
||||
return nullptr;
|
||||
values.append(percentage.release_nonnull());
|
||||
} else {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "FIXME: Unsupported value type for transformation!");
|
||||
return nullptr;
|
||||
|
|
|
@ -329,10 +329,12 @@ Vector<CSS::Transformation> StyleProperties::transformations() const
|
|||
auto& transformation_style_value = it.as_transformation();
|
||||
CSS::Transformation transformation;
|
||||
transformation.function = transformation_style_value.transform_function();
|
||||
Vector<Variant<CSS::Length, float>> values;
|
||||
Vector<Variant<CSS::LengthPercentage, float>> values;
|
||||
for (auto& transformation_value : transformation_style_value.values()) {
|
||||
if (transformation_value.is_length()) {
|
||||
values.append({ transformation_value.to_length() });
|
||||
} else if (transformation_value.is_percentage()) {
|
||||
values.append({ transformation_value.as_percentage().percentage() });
|
||||
} else if (transformation_value.is_numeric()) {
|
||||
values.append({ transformation_value.to_number() });
|
||||
} else if (transformation_value.is_angle()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue