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: Stub out simplify_a_calculation_tree #1824

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

Im not sure if this is the best way of handling it, or if it should happen more like this stelar7/serenity@b83e45c

@AtkinsSJ
Copy link
Member

Im not sure if this is the best way of handling it, or if it should happen more like this stelar7/serenity@b83e45c

I think this does need to live somewhere outside of the parser - we need to simplify the calculation at computed-value type (when it's assigned to a node) and later at used-value time. (Though for that last one, just calculating the value directly probably makes more sense, since we won't need to keep the calculation around afterwards.) See https://drafts.csswg.org/css-values-4/#calc-computed-value

I know I've kept changing my mind on calc(), which isn't helpful. It's complicated. 😅

I've looked again at the specs since talking on Discord, and I think the values and typed-om specs are compatible, which is a relief (though the typed-om spec is missing a few things that we'd need to ad-hoc ourselves). Eventually I think what we want to do is (in no particular order):

  • Replace our ad-hoc CalculationResult with CSSNumericValue by implementing the add(), sub(), etc methods on it.
  • Make our calculation nodes be CSSMathValue subclasses, so a calculation is some kind of CSSMathValue containing various kinds of CSSNumericValue.
  • Simplification would then take a CSSMathValue (or be a method on it) and return a CSSMathValue.
  • At some point we should probably add the IDL side to these types too.

So you're welcome to take on however much of that you feel like. Those first two points are probably hard to do separately. You can also try adding simplification without doing those, but it'll mean that code will need modifying later.

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