-
Notifications
You must be signed in to change notification settings - Fork 31
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
change conversion to appunit from float of percentage calcuation #102
base: main
Are you sure you want to change the base?
Conversation
Since we want to test this before publishing a new release of app units, let's inline the code here for now. |
BTW, when creating a PR it's better not to use your main branch. |
Signed-off-by: Oriol Brufau <[email protected]>
Signed-off-by: Oriol Brufau <[email protected]>
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.
It may make more sense to modify this instead:
stylo/style/values/computed/length.rs
Lines 496 to 501 in 7e529e8
impl From<CSSPixelLength> for Au { | |
#[inline] | |
fn from(len: CSSPixelLength) -> Self { | |
Au::from_f32_px(len.0) | |
} | |
} |
I thought that would be more likely to affect Firefox, but I have tried commenting that (and its callers) out, and Firefox compiles fine, so it's not used.
6259dd8
to
8fd98ee
Compare
I'm sorry that the code you commit is overwitten by mistake, can you push the code again? @Loirooriol |
What code, 83dad25 ? |
Yes. And this opration that truncate in au construction not only in the percentage will expose another problem of #servo34714. The parameter of Timing Function style is f32 while it is f64 data type used in bezier function calculation. Loss can be produced in this progress. Could we just use truncate method in percentage, just like firefox? |
Sure, you can try that. But currently the logic first resolves LengthPercentage into a Length and then to an Au. You will need to remove the middle step. |
Signed-off-by: Asun0204 <[email protected]>
{"fail_fast": false, "matrix": [{"name": "Linux", "workflow": "linux", "wpt_layout": "none", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
Signed-off-by: Oriol Brufau <[email protected]>
{"fail_fast": false, "matrix": [{"name": "Linux", "workflow": "linux", "wpt_layout": "none", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
{"fail_fast": false, "matrix": [{"name": "Linux", "workflow": "linux", "wpt_layout": "none", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
{"fail_fast": false, "matrix": [{"name": "Linux (WPT)", "workflow": "linux", "wpt_layout": "2020", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
Signed-off-by: Oriol Brufau <[email protected]>
{"fail_fast": false, "matrix": [{"name": "Linux (WPT)", "workflow": "linux", "wpt_layout": "2020", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
{"fail_fast": false, "matrix": [{"name": "Linux (WPT)", "workflow": "linux", "wpt_layout": "2020", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
Signed-off-by: Oriol Brufau <[email protected]>
{"fail_fast": false, "matrix": [{"name": "Linux (WPT)", "workflow": "linux", "wpt_layout": "2020", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
I don't known how to remove the middle step. Do I need to copy the percenrage calculation in |
{"fail_fast": false, "matrix": [{"name": "Linux (WPT)", "workflow": "linux", "wpt_layout": "2020", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
@@ -562,8 +562,11 @@ impl LengthPercentage { | |||
/// Convert the computed value into used value. | |||
#[inline] | |||
pub fn maybe_to_used_value(&self, container_len: Option<Au>) -> Option<Au> { | |||
self.maybe_percentage_relative_to(container_len.map(Length::from)) | |||
.map(Au::from) | |||
if let Unpacked::Percentage(_) = self.unpack() { |
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.
Probably Unpacked::Calc
should truncate too.
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.
Two wpt cases failed about calc, including calc-rounding-001.html
and calc-rounding-003.html
. Do we need to change Unpacked::Calc
to truncate?
width: calc((100% - 4.5em) / 4);
and width: calc((var(--width) - 4.5em) / 4);
are compared in calc-rounding-001.html
. But width: calc((var(--width) - 4.5em) / 4);
is calcuated as a Length
value instead of Calc
.
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.
Test case of calc-rounding-001.html
is also failed on firefox. The case on servo is passed but it looks differently than chrome and edge. So should we mark it failed as firefox or just modify percentage to truncate? @Loirooriol
Test case of calc-rounding-003.html
has been already marked as expected: FAIL
, I don't known why it's on the failed result.
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.
Rounding for calc()
is better according to https://phabricator.services.mozilla.com/D202746
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 workflow that I just change the percenrage method using truncate has been passed. So should we merge app_units pr firstly? Then the stylo pr could be merged. @Loirooriol
https://github.com/Asun0204/servo/actions/runs/13385320860
Steps to merge this pr:
- The version of app_units is 0.7.7 now, we need upgrade to 0.7.8 and merge it with two interfaces.
- Publish app_units crate.
- We just merge this pr without upgrading version number because interfaces in stylo are not modified.
{"fail_fast": false, "matrix": [{"name": "Linux (WPT)", "workflow": "linux", "wpt_layout": "2020", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
3afe828
to
82d5920
Compare
…tion Signed-off-by: Asun0204 <[email protected]>
change conversion to appunit from float of percentage calcuation, prevent child box size is calculated too large.
Servo PR: servo/servo#34714