Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stelar7
Copy link
Contributor

@stelar7 stelar7 commented Oct 16, 2024

Adds support for parsing the rotate property

Comment on lines 37 to 38
Angle m_angle;
FloatVector3 m_rotation_vector;
Copy link
Member

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 {
Copy link
Member

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.

Comment on lines 46 to 47
auto const& other_angle = other.as_rotation();
return m_angle == other_angle.m_angle;
Copy link
Member

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.

Comment on lines 4734 to 4742
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;
}
}
}
Copy link
Member

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).

Comment on lines 4745 to 4749
if (auto angle = parse_angle_value(tokens)) {
// FIXME: Handle calc()
if (angle->is_angle())
return RotationStyleValue::create(angle->as_angle().angle(), 0, 0, 1);
}
Copy link
Member

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) {
Copy link
Member

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.

Comment on lines 4778 to 4779
// <number>{3} && <angle>
if (tokens.remaining_token_count() == 4) {
Copy link
Member

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. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants