You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Servo's CSS parser converts absolute-unit lengths to a fixed-point representation even for specified values #15729
A-styloC-assignedThere is someone working on resolving the issueC-has-open-prThere is a PR open that resolves the issueE-more-complexVariable effort required; may require a mentor. Recommended solution is clearly described in the iss
In servo this logs "0.31666666px". It should really preserve the original "0.33px" value.
In Gecko, specified values are stored as floating point plus unit, and not converted to 1/60 px integers until computed value time.
And even then, note that servo above is converting by truncation, whereas Gecko uses rounding. Specifically, Gecko does NSToCoordRoundWithClamp which checks for overflow issues, then rounds to nearest via NSToCoordRound.
Relevant code is in components/style/values/specified/length.rs. Changes to do:
Replace Au with f32 in specified value types. (They should already be in enum variants that indicate the unit. If/where they’re not, add newtypes that do.)
Move the unit conversion from parsing code to to_computed_value methods
In these conversions, do clamping and rounding. Something like:
.min(::std::i32::MAX as f64)
.max(::std::i32::MIN as f64)
Fwiw, we're going to need more clamping than that going into Gecko code, but presumably that will be somewhere Gecko-specific? For Gecko, the relevant clamping points are 1<<30 and -(1<<30), at least when not NS_COORD_IS_FLOAT... Please file a separate issue for that in the right place, whatever that is?
I didn’t know that Gecko clamps to a smaller range. Is it to allow some amount of arithmetic on the results without overflow? That sounds like a good idea, let’s do that instead of i32::MAX / i32::MIN for Servo too.
A-styloC-assignedThere is someone working on resolving the issueC-has-open-prThere is a PR open that resolves the issueE-more-complexVariable effort required; may require a mentor. Recommended solution is clearly described in the iss
Activity
SimonSapin commentedon Feb 24, 2017
Relevant code is in
components/style/values/specified/length.rs. Changes to do:Auwithf32in specified value types. (They should already be in enum variants that indicate the unit. If/where they’re not, add newtypes that do.)to_computed_valuemethodsbzbarsky commentedon Feb 24, 2017
Fwiw, we're going to need more clamping than that going into Gecko code, but presumably that will be somewhere Gecko-specific? For Gecko, the relevant clamping points are
1<<30and-(1<<30), at least when not NS_COORD_IS_FLOAT... Please file a separate issue for that in the right place, whatever that is?SimonSapin commentedon Feb 24, 2017
I didn’t know that Gecko clamps to a smaller range. Is it to allow some amount of arithmetic on the results without overflow? That sounds like a good idea, let’s do that instead of
i32::MAX/i32::MINfor Servo too.What is
NS_COORD_IS_FLOAT?bzbarsky commentedon Feb 24, 2017
I don't think so. I don't recall offhand why we did that instead of i32::MAX and -i32::MAX (not i32::MIN, because we want symmetric behavior).
We used to have magic values of nscoord to represent "auto", I think, so maybe that's why? @dbaron might recall offhand.
Compile-time switch to use floats for nscoord instead. May or may not build nowadays...
mcaveniathor commentedon Mar 14, 2017
I'm looking for a first contribution to make as I learn Rust -- if mentored, I would love to help with this in any way I can.
emilio commentedon Mar 26, 2017
Yes, please! I'm happy to mentor this, please ask any questions you may have here (or open a PR with your progress and request feedback). Thanks!
emilio commentedon Mar 26, 2017
(Oh, and sorry for the delay replying to this, @SimonSapin is away for a few weeks I believe, and I wasn't cc'd here).
Let me watch stylo issues.
Auto merge of #172 - servo:emilio-watch-stylo, r=jdm
Auto merge of #16229 - tomhoule:fix-lengths, r=<try>
Auto merge of #16229 - tomhoule:fix-lengths, r=emilio
Auto merge of #16229 - tomhoule:fix-lengths, r=emilio
Auto merge of #16229 - tomhoule:fix-lengths, r=emilio
Auto merge of #16229 - tomhoule:fix-lengths, r=emilio