Decouple 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.

Review URL: https://codereview.chromium.org/705783002

git-svn-id: svn://svn.chromium.org/blink/trunk@185033 bbb929c8-8fbe-4397-9dbb-9b2b20218538
11 files changed
tree: ab53e41dd31cbc435d8dc930b0fdccf3d8fb20fc
  1. third_party/