Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Issue 705783002: Decouple font unit conversion in computeLengthDouble from RenderStyle. (Closed)

Created:
6 years, 1 month ago by andersr
Modified:
6 years, 1 month ago
Reviewers:
Timothy Loh, dglazkov
CC:
blink-reviews, kenneth.christiansen, blink-reviews-css, ed+blinkwatch_opera.com, dglazkov+blink, apavlov+blink_chromium.org, darktears, rwlbuis
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Project:
blink
Visibility:
Public.

Description

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. 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). #

Unified diffs Side-by-side diffs Delta from patch set Stats (+127 lines, -100 lines) Patch
M Source/core/css/CSSCalculationValueTest.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/core/css/CSSGradientValue.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/core/css/CSSMatrix.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/core/css/CSSPrimitiveValue.cpp View 2 chunks +5 lines, -18 lines 0 comments Download
M Source/core/css/CSSToLengthConversionData.h View 1 2 2 chunks +45 lines, -15 lines 0 comments Download
M Source/core/css/CSSToLengthConversionData.cpp View 1 2 3 4 5 1 chunk +41 lines, -30 lines 0 comments Download
M Source/core/css/resolver/StyleBuilderConverter.cpp View 1 2 3 4 1 chunk +5 lines, -20 lines 0 comments Download
M Source/core/css/resolver/StyleResolver.cpp View 1 2 6 chunks +20 lines, -11 lines 0 comments Download
M Source/core/css/resolver/StyleResolverState.h View 1 2 2 chunks +5 lines, -1 line 0 comments Download
M Source/core/css/resolver/StyleResolverState.cpp View 1 chunk +0 lines, -1 line 0 comments Download
M Source/core/css/resolver/ViewportStyleResolver.cpp View 1 2 1 chunk +3 lines, -1 line 0 comments Download

Messages

Total messages: 17 (4 generated)
andersr
Somewhat related patch: "Improve RAII of StyleResolverState" https://codereview.chromium.org/686723002/ This patch currently uses delegated constructors, which ...
6 years, 1 month ago (2014-11-06 16:19:49 UTC) #2
Timothy Loh
Seems fine overall. Will look more closely later. https://codereview.chromium.org/705783002/diff/20001/Source/core/css/CSSToLengthConversionData.cpp File Source/core/css/CSSToLengthConversionData.cpp (right): https://codereview.chromium.org/705783002/diff/20001/Source/core/css/CSSToLengthConversionData.cpp#newcode49 Source/core/css/CSSToLengthConversionData.cpp:49: : ...
6 years, 1 month ago (2014-11-06 16:24:01 UTC) #3
andersr
Well, that was quick. https://codereview.chromium.org/705783002/diff/20001/Source/core/css/resolver/StyleResolver.cpp File Source/core/css/resolver/StyleResolver.cpp (right): https://codereview.chromium.org/705783002/diff/20001/Source/core/css/resolver/StyleResolver.cpp#newcode1429 Source/core/css/resolver/StyleResolver.cpp:1429: updateFont(state); On 2014/11/06 16:24:01, Timothy ...
6 years, 1 month ago (2014-11-06 16:35:27 UTC) #4
andersr
PTAL. Still haven't allowed C++11 delegate constructors here. It's probably better to do that separately ...
6 years, 1 month ago (2014-11-07 10:43:11 UTC) #5
Timothy Loh
OK, lgtm We can probably just always use specified font size and always apply zoom ...
6 years, 1 month ago (2014-11-07 17:59:38 UTC) #6
andersr
> We can probably just always use specified font size and always apply zoom (in ...
6 years, 1 month ago (2014-11-08 01:39:46 UTC) #7
andersr
On 2014/11/08 01:39:46, andersr wrote: > > We can probably just always use specified font ...
6 years, 1 month ago (2014-11-08 01:41:15 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/705783002/60001
6 years, 1 month ago (2014-11-10 08:53:11 UTC) #10
andersr
https://codereview.chromium.org/705783002/diff/40001/Source/core/css/CSSToLengthConversionData.h File Source/core/css/CSSToLengthConversionData.h (right): https://codereview.chromium.org/705783002/diff/40001/Source/core/css/CSSToLengthConversionData.h#newcode103 Source/core/css/CSSToLengthConversionData.h:103: ViewportSize m_viewportSize; On 2014/11/07 17:59:37, Timothy Loh wrote: > ...
6 years, 1 month ago (2014-11-10 08:56:10 UTC) #11
commit-bot: I haz the power
Try jobs failed on following builders: linux_blink_rel on tryserver.blink (http://build.chromium.org/p/tryserver.blink/builders/linux_blink_rel/builds/32775)
6 years, 1 month ago (2014-11-10 09:48:37 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/705783002/100001
6 years, 1 month ago (2014-11-10 11:48:25 UTC) #15
andersr
https://codereview.chromium.org/705783002/diff/20001/Source/core/css/CSSToLengthConversionData.cpp File Source/core/css/CSSToLengthConversionData.cpp (right): https://codereview.chromium.org/705783002/diff/20001/Source/core/css/CSSToLengthConversionData.cpp#newcode49 Source/core/css/CSSToLengthConversionData.cpp:49: : CSSToLengthFontSizes(style->computedFontSize(), rootStyle ? rootStyle->computedFontSize() : 1.0f, &style->font()) On ...
6 years, 1 month ago (2014-11-10 11:49:57 UTC) #16
commit-bot: I haz the power
6 years, 1 month ago (2014-11-10 13:04:45 UTC) #17
Message was sent while issue was closed.
Committed patchset #6 (id:100001) as 185033

Powered by Google App Engine
This is Rietveld 408576698