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
Cleaning up CalcLengthOrPercentage #15063
Conversation
r? @heycam |
@bors-servo r+ |
📌 Commit 6cf9fc0 has been approved by |
Cleaning up CalcLengthOrPercentage <!-- Please describe your changes on the following line: --> We don't really need enum variants in `CalcLengthOrPercentage`. Given that we already have the information (whether it's `vw`, `ch`, etc.) in the struct fields, we could just store `Option<CSSFloat>` there, and modify our `ToCss` implementation a bit. cc #15061 r? @Manishearth or anyone interested --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [x] These changes do not require tests because it's a refactor <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15063) <!-- Reviewable:end -->
Can you also remove the option and represent None with zero? |
In https://drafts.csswg.org/css-values/#calc-serialize it says "(Terms with a value of zero must be preserved in this summation.)" which I think means we need to continue distinguishing zero from a value with that unit not being specified. |
💔 Test failed - linux-rel-wpt |
@bors-servo r=heycam |
📌 Commit b5f4033 has been approved by |
Cleaning up CalcLengthOrPercentage <!-- Please describe your changes on the following line: --> We don't really need enum variants in `CalcLengthOrPercentage`. Given that we already have the information (whether it's `vw`, `ch`, etc.) in the struct fields, we could just store `Option<CSSFloat>` there, and modify our `ToCss` implementation a bit. cc #15061 r? @Manishearth or anyone interested --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [x] These changes do not require tests because it's a refactor <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15063) <!-- Reviewable:end -->
💔 Test failed - linux-rel-wpt |
Use Box<CalcLengthOrPercentage> in specified values to avoid bloating inline sizes For #15061 CalcLOP is a large struct, and gets used quite often. While #15063 reduces its size a bit, it will still be much larger than any of the other variants in the `specified::Length*` types, so it will still bloat sizes, especially for specified values that contain many lengths. This change boxes it in the length types, so that it just takes one word. r? @heycam <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15065) <!-- Reviewable:end -->
@bors-servo r=heycam (meh) |
📌 Commit 3ac73ed has been approved by |
Cleaning up CalcLengthOrPercentage <!-- Please describe your changes on the following line: --> We don't really need enum variants in `CalcLengthOrPercentage`. Given that we already have the information (whether it's `vw`, `ch`, etc.) in the struct fields, we could just store `Option<CSSFloat>` there, and modify our `ToCss` implementation a bit. cc #15061 r? @Manishearth or anyone interested --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [x] These changes do not require tests because it's a refactor <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15063) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-gnu-dev, windows-msvc-dev |
Use Box<CalcLengthOrPercentage> in specified values to avoid bloating inline sizes For #15061 CalcLOP is a large struct, and gets used quite often. While #15063 reduces its size a bit, it will still be much larger than any of the other variants in the `specified::Length*` types, so it will still bloat sizes, especially for specified values that contain many lengths. This change boxes it in the length types, so that it just takes one word. r? @heycam <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15065) <!-- Reviewable:end -->
We don't really need enum variants in
CalcLengthOrPercentage
. Given that we already have the information (whether it'svw
,ch
, etc.) in the struct fields, we could just storeOption<CSSFloat>
there, and modify ourToCss
implementation a bit.cc #15061
r? @Manishearth or anyone interested
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is