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

change conversion to appunit from float of percentage calcuation #102

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

Conversation

Asun0204
Copy link

@Asun0204 Asun0204 commented Dec 26, 2024

change conversion to appunit from float of percentage calcuation, prevent child box size is calculated too large.

Servo PR: servo/servo#34714

@Asun0204 Asun0204 changed the title [fixbug] change conversion to appunit from float of percentage calcuation change conversion to appunit from float of percentage calcuation Dec 26, 2024
@Loirooriol
Copy link
Contributor

Since we want to test this before publishing a new release of app units, let's inline the code here for now.

@Loirooriol
Copy link
Contributor

BTW, when creating a PR it's better not to use your main branch.

Loirooriol added a commit to Asun0204/servo that referenced this pull request Jan 8, 2025
Signed-off-by: Oriol Brufau <[email protected]>
Loirooriol added a commit to Asun0204/servo that referenced this pull request Jan 8, 2025
Signed-off-by: Oriol Brufau <[email protected]>
Copy link
Contributor

@Loirooriol Loirooriol left a 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:

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.

@Asun0204
Copy link
Author

Asun0204 commented Feb 10, 2025

I'm sorry that the code you commit is overwitten by mistake, can you push the code again? @Loirooriol

@Loirooriol
Copy link
Contributor

What code, 83dad25 ?

@Asun0204
Copy link
Author

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?

@Loirooriol
Copy link
Contributor

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.

Asun0204 added a commit to Asun0204/servo that referenced this pull request Feb 11, 2025
Signed-off-by: Asun0204 <[email protected]>
Asun0204 added a commit to Asun0204/servo that referenced this pull request Feb 11, 2025
{"fail_fast": false, "matrix": [{"name": "Linux", "workflow": "linux", "wpt_layout": "none", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
Asun0204 pushed a commit to Asun0204/servo that referenced this pull request Feb 11, 2025
Signed-off-by: Oriol Brufau <[email protected]>
Asun0204 added a commit to Asun0204/servo that referenced this pull request Feb 11, 2025
{"fail_fast": false, "matrix": [{"name": "Linux", "workflow": "linux", "wpt_layout": "none", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
Asun0204 added a commit to Asun0204/servo that referenced this pull request Feb 11, 2025
{"fail_fast": false, "matrix": [{"name": "Linux", "workflow": "linux", "wpt_layout": "none", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
Asun0204 added a commit to Asun0204/servo that referenced this pull request Feb 11, 2025
{"fail_fast": false, "matrix": [{"name": "Linux (WPT)", "workflow": "linux", "wpt_layout": "2020", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
Asun0204 pushed a commit to Asun0204/servo that referenced this pull request Feb 11, 2025
Signed-off-by: Oriol Brufau <[email protected]>
Asun0204 added a commit to Asun0204/servo that referenced this pull request Feb 11, 2025
{"fail_fast": false, "matrix": [{"name": "Linux (WPT)", "workflow": "linux", "wpt_layout": "2020", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
Asun0204 added a commit to Asun0204/servo that referenced this pull request Feb 11, 2025
{"fail_fast": false, "matrix": [{"name": "Linux (WPT)", "workflow": "linux", "wpt_layout": "2020", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
Asun0204 pushed a commit to Asun0204/servo that referenced this pull request Feb 11, 2025
Signed-off-by: Oriol Brufau <[email protected]>
Asun0204 added a commit to Asun0204/servo that referenced this pull request Feb 11, 2025
{"fail_fast": false, "matrix": [{"name": "Linux (WPT)", "workflow": "linux", "wpt_layout": "2020", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
@Asun0204
Copy link
Author

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.

I don't known how to remove the middle step. Do I need to copy the percenrage calculation in maybe_to_used_value? And it will skip normallized operation provided by Length.

Asun0204 added a commit to Asun0204/servo that referenced this pull request Feb 11, 2025
{"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() {
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Author

@Asun0204 Asun0204 Feb 18, 2025

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.

Copy link
Contributor

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

Copy link
Author

@Asun0204 Asun0204 Feb 19, 2025

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:

  1. The version of app_units is 0.7.7 now, we need upgrade to 0.7.8 and merge it with two interfaces.
  2. Publish app_units crate.
  3. We just merge this pr without upgrading version number because interfaces in stylo are not modified.

Asun0204 added a commit to Asun0204/servo that referenced this pull request Feb 12, 2025
{"fail_fast": false, "matrix": [{"name": "Linux (WPT)", "workflow": "linux", "wpt_layout": "2020", "profile": "release", "unit_tests": false, "build_libservo": false, "bencher": false, "wpt_args": ""}]}
@Asun0204 Asun0204 force-pushed the main branch 4 times, most recently from 3afe828 to 82d5920 Compare February 19, 2025 07:15
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