-
-
Notifications
You must be signed in to change notification settings - Fork 902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LibWeb: Parse the rotate css property #1823
base: master
Are you sure you want to change the base?
Conversation
Angle m_angle; | ||
FloatVector3 m_rotation_vector; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not add new places that don't support calc()
. Keep the angle and axis in CSSStyleValue form - maybe the axis can always be 3 values if that's the most convenient.
|
||
namespace Web::CSS { | ||
|
||
class RotationStyleValue : public CSSUnitValue { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it makes sense for this to be a CSSUnitValue. You can't do arithmetic on it.
auto const& other_angle = other.as_rotation(); | ||
return m_angle == other_angle.m_angle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're not checking the axis.
if (tokens.remaining_token_count() == 1) { | ||
auto transaction = tokens.begin_transaction(); | ||
if (auto keyword = parse_keyword_value(tokens)) { | ||
if (keyword->to_keyword() == Keyword::None) { | ||
transaction.commit(); | ||
return keyword; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a helper for this now: parse_all_as_single_keyword_value(tokens, Keyword::None)
.
if (auto angle = parse_angle_value(tokens)) { | ||
// FIXME: Handle calc() | ||
if (angle->is_angle()) | ||
return RotationStyleValue::create(angle->as_angle().angle(), 0, 0, 1); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The [ x | y | z | <number>{3} ] && <angle>
form can have the <angle>
first, (any ||
or &&
in the grammar means it happens in any order,) which this would parse incorrectly.
} | ||
|
||
// [ x | y | z ] && <angle> | ||
if (tokens.remaining_token_count() == 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch also needs to handle either order.
// <number>{3} && <angle> | ||
if (tokens.remaining_token_count() == 4) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order again. At least you the angle is either at the start or the end, not mixed in with the numbers. 😅
Adds support for parsing the rotate property