Add pixel ratio config, document Style/Layout as logical/physical pixels #478
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
This PR represents the outcome of discussions around how different length units should be interpreted when parsing CSS syntax, in particular #460 (comment). The doc-comment for
set_pixel_ratio
insrc/tree/taffy_tree/tree.rs
details the proposed design.Context
Previous discussion happened in #440 and #460
Feedback wanted
Documentation and API changes are in this first PR draft, but behavior changes (actually applying the pixel ratio) are not implemented yet. The (style) inputs and and eventual (layout) outputs are to use different units, but at what point should the conversion be done? The reduce bug risk I think intermediate computation (including some public APIs like
SizeAndBaselines
,MeasureFunc
, and likely others) should all pick one unit or the other but avoid dealing with both at the same time, with conversion kept in a small number of convenience functions or methods.Style
. Perhaps in the same APIs that resolve percentages. A downside is that a&Taffy
or&TaffyConfig
parameter will need to be added to various functions and methods, and all of their call sitesLayout
value, or mutating them like rounding does. The latter muddies how we define the meaning of that struct, while the former breaks things ifLayout
ever used as an intermediate result for further computation. Is that the case?