DescriptionDecouple font unit conversion in computeLengthDouble from RenderStyle.
Simply passing the RenderStyle(s) to computeLengthDouble, and letting it decide
how to convert units is ugly, since the conversion factors depends on context.
(Notably font-size, where parent specified font size is to be used rather than
current computed font size).
The same applies to zoom, where we normally want to use the effective zoom
of some RenderStyle, and in other cases some alternative specific zoom.
To make matters worse, the same RenderStyle from which we produce font unit
factors, and (maybe) effective zoom, is also marked as having viewport units (if
encountered), even though the RenderStyle we want to mark is not always the same
as the one we want to produce factors from.
This patch reworks CSSToLengthConversionData to contain more specific coversion
data, instead of just forwarding RenderStyles into dark places.
CSSToLengthConversionData now consists of:
* CSSToLengthFontSizes which knows which factors to use for em/rem/ex/ch.
The units that only depend on FontDescription (em, rem) are always computed,
and the units which depend on FontMetrics (ex, ch) are computed on demand.
This is to avoid loading of fonts in cases where its metrics weren't really
needed after all.
* CSSToLengthViewportSize just contains the size of the viewport, and exists
only to improve the structure of CSSToLengthConversionData. (Less params).
* Zoom. This is the zoom used in all cases. Effective/non-effective is now
handled by the outside.
* (Private) RenderStyle. Only to mark as having viewport units.
This is better, because:
* The special situation of computing font-size is now handled in the converter
for font-size, not computeLengthDouble, which really shouldn't have to care.
* The RenderStyle we're passing is only used for viewport unit marking, so we
can actually pass the correct one for font-size.
* The ... extravagant ... constructors of CSSToLengthConversionData are now
under control.
Notes:
* StyleResolver now calls inheritFrom on styles before setting the style on the
StyleResolverState. This ensures that correct font unit factors are computed
(as the Font is inheritable).
* An extra updateFont is needed if we inheritFrom a cached style.
* StyleResolver::defaultStyleForElement does not need to use a
StyleResolverState anymore. A FontBuilder will suffice.
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=185033
Patch Set 1 #Patch Set 2 : #
Total comments: 17
Patch Set 3 : Fixed timloh's issues. #
Total comments: 4
Patch Set 4 : Rebase. #Patch Set 5 : Guard against nullptr-rootElementStyle. #Patch Set 6 : Forgot to remove ASSERT(rootStyle). #Messages
Total messages: 17 (4 generated)
|