Changeset 167937 in webkit


Ignore:
Timestamp:
Apr 29, 2014 9:36:43 AM (10 years ago)
Author:
Bem Jones-Bey
Message:

Wrap CSS length conversion arguments in an object
https://bugs.webkit.org/show_bug.cgi?id=131552

Reviewed by Andreas Kling.

This patch introduces a class CSSToLengthConversionData to wrap the
data required to convert CSS lengths to Lengths. This simplifies the
plumbing that goes on whenever we need to resolve CSS lengths and
makes it easier to update the arguments needed for resolving these (in
particular adding a RenderView for resolving viewport units at style
recalc time; removing the computingFontSize bool also appears
possible).

Note that the zoom argument, which was previously a float in some
places and a double in others is now a float.

This is a port of a Blink patch by timloh@chromium.org.

No new tests, no behavior change.

  • CMakeLists.txt:
  • WebCore.vcxproj/WebCore.vcxproj:
  • WebCore.xcodeproj/project.pbxproj:
  • css/BasicShapeFunctions.cpp:

(WebCore::convertToLength):
(WebCore::convertToLengthSize):
(WebCore::convertToCenterCoordinate):
(WebCore::cssValueToBasicShapeRadius):
(WebCore::basicShapeForValue):

  • css/BasicShapeFunctions.h:
  • css/CSSCalculationValue.cpp:

(WebCore::CSSCalcValue::computeLengthPx):
(WebCore::determineCategory):

  • css/CSSCalculationValue.h:

(WebCore::CSSCalcValue::createCalculationValue):

  • css/CSSGradientValue.cpp:

(WebCore::CSSGradientValue::addStops):
(WebCore::positionFromValue):
(WebCore::CSSGradientValue::computeEndPoint):
(WebCore::CSSLinearGradientValue::createGradient):
(WebCore::CSSRadialGradientValue::resolveRadius):
(WebCore::CSSRadialGradientValue::createGradient):

  • css/CSSGradientValue.h:
  • css/CSSPrimitiveValue.cpp:

(WebCore::CSSPrimitiveValue::computeLength):
(WebCore::CSSPrimitiveValue::computeLengthDouble):

  • css/CSSPrimitiveValue.h:
  • css/CSSPrimitiveValueMappings.h:

(WebCore::CSSPrimitiveValue::convertToLength):

  • css/CSSToLengthConversionData.cpp: Added.

(WebCore::CSSToLengthConversionData::zoom):

  • css/CSSToLengthConversionData.h: Added.

(WebCore::CSSToLengthConversionData::CSSToLengthConversionData):
(WebCore::CSSToLengthConversionData::style):
(WebCore::CSSToLengthConversionData::rootStyle):
(WebCore::CSSToLengthConversionData::computingFontSize):
(WebCore::CSSToLengthConversionData::copyWithAdjustedZoom):

  • css/CSSToStyleMap.cpp:

(WebCore::CSSToStyleMap::CSSToStyleMap):
(WebCore::CSSToStyleMap::mapFillSize):
(WebCore::CSSToStyleMap::mapFillXPosition):
(WebCore::CSSToStyleMap::mapFillYPosition):
(WebCore::CSSToStyleMap::mapNinePieceImageQuad):

  • css/CSSToStyleMap.h:

(WebCore::CSSToStyleMap::CSSToStyleMap): Deleted.

  • css/DeprecatedStyleBuilder.cpp:

(WebCore::ApplyPropertyAuto::applyValue):
(WebCore::ApplyPropertyClip::convertToLength):
(WebCore::ApplyPropertyLength::applyValue):
(WebCore::ApplyPropertyBorderRadius::applyValue):
(WebCore::ApplyPropertyComputeLength::applyValue):
(WebCore::ApplyPropertyFontSize::applyValue):
(WebCore::csstoLengthConversionDataWithTextZoomFactor):
(WebCore::ApplyPropertyMarqueeIncrement::applyValue):
(WebCore::ApplyPropertyLineHeight::applyValue):
(WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue):
(WebCore::ApplyPropertyWordSpacing::applyValue):
(WebCore::ApplyPropertyPageSize::mmLength):
(WebCore::ApplyPropertyPageSize::inchLength):
(WebCore::ApplyPropertyPageSize::applyValue):
(WebCore::ApplyPropertyVerticalAlign::applyValue):
(WebCore::ApplyPropertyClipPath::applyValue):
(WebCore::ApplyPropertyShape::applyValue):
(WebCore::ApplyPropertyTextIndent::applyValue):

  • css/MediaQueryEvaluator.cpp:

(WebCore::colorMediaFeatureEval):
(WebCore::color_indexMediaFeatureEval):
(WebCore::monochromeMediaFeatureEval):
(WebCore::orientationMediaFeatureEval):
(WebCore::aspect_ratioMediaFeatureEval):
(WebCore::device_aspect_ratioMediaFeatureEval):
(WebCore::device_pixel_ratioMediaFeatureEval):
(WebCore::resolutionMediaFeatureEval):
(WebCore::gridMediaFeatureEval):
(WebCore::computeLength):
(WebCore::device_heightMediaFeatureEval):
(WebCore::device_widthMediaFeatureEval):
(WebCore::heightMediaFeatureEval):
(WebCore::widthMediaFeatureEval):
(WebCore::min_colorMediaFeatureEval):
(WebCore::max_colorMediaFeatureEval):
(WebCore::min_color_indexMediaFeatureEval):
(WebCore::max_color_indexMediaFeatureEval):
(WebCore::min_monochromeMediaFeatureEval):
(WebCore::max_monochromeMediaFeatureEval):
(WebCore::min_aspect_ratioMediaFeatureEval):
(WebCore::max_aspect_ratioMediaFeatureEval):
(WebCore::min_device_aspect_ratioMediaFeatureEval):
(WebCore::max_device_aspect_ratioMediaFeatureEval):
(WebCore::min_device_pixel_ratioMediaFeatureEval):
(WebCore::max_device_pixel_ratioMediaFeatureEval):
(WebCore::min_heightMediaFeatureEval):
(WebCore::max_heightMediaFeatureEval):
(WebCore::min_widthMediaFeatureEval):
(WebCore::max_widthMediaFeatureEval):
(WebCore::min_device_heightMediaFeatureEval):
(WebCore::max_device_heightMediaFeatureEval):
(WebCore::min_device_widthMediaFeatureEval):
(WebCore::max_device_widthMediaFeatureEval):
(WebCore::min_resolutionMediaFeatureEval):
(WebCore::max_resolutionMediaFeatureEval):
(WebCore::animationMediaFeatureEval):
(WebCore::transitionMediaFeatureEval):
(WebCore::transform_2dMediaFeatureEval):
(WebCore::transform_3dMediaFeatureEval):
(WebCore::view_modeMediaFeatureEval):
(WebCore::video_playable_inlineMediaFeatureEval):
(WebCore::hoverMediaFeatureEval):
(WebCore::pointerMediaFeatureEval):
(WebCore::MediaQueryEvaluator::eval):

  • css/SVGCSSStyleSelector.cpp:

(WebCore::StyleResolver::applySVGProperty):

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::State::clear):
(WebCore::StyleResolver::State::initForStyleResolve):
(WebCore::StyleResolver::convertToIntLength):
(WebCore::StyleResolver::convertToFloatLength):
(WebCore::createGridTrackBreadth):
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::createFilterOperations):

  • css/StyleResolver.h:

(WebCore::StyleResolver::State::setStyle):
(WebCore::StyleResolver::State::cssToLengthConversionData):

  • css/TransformFunctions.cpp:

(WebCore::convertToFloatLength):
(WebCore::transformsForValue):

  • css/TransformFunctions.h:
  • css/WebKitCSSMatrix.cpp:

(WebCore::WebKitCSSMatrix::setMatrixValue):

  • rendering/RenderThemeIOS.mm:

(WebCore::applyCommonButtonPaddingToStyle):
(WebCore::RenderThemeIOS::adjustButtonStyle):

Location:
trunk/Source/WebCore
Files:
2 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r167652 r167937  
    12261226    css/CSSSupportsRule.cpp
    12271227    css/CSSTimingFunctionValue.cpp
     1228    css/CSSToLengthConversionData.cpp
    12281229    css/CSSToStyleMap.cpp
    12291230    css/CSSUnicodeRangeValue.cpp
  • trunk/Source/WebCore/ChangeLog

    r167936 r167937  
     12014-04-29  Bem Jones-Bey  <bjonesbe@adobe.com>
     2
     3        Wrap CSS length conversion arguments in an object
     4        https://bugs.webkit.org/show_bug.cgi?id=131552
     5
     6        Reviewed by Andreas Kling.
     7
     8        This patch introduces a class CSSToLengthConversionData to wrap the
     9        data required to convert CSS lengths to Lengths. This simplifies the
     10        plumbing that goes on whenever we need to resolve CSS lengths and
     11        makes it easier to update the arguments needed for resolving these (in
     12        particular adding a RenderView for resolving viewport units at style
     13        recalc time; removing the computingFontSize bool also appears
     14        possible).
     15
     16        Note that the zoom argument, which was previously a float in some
     17        places and a double in others is now a float.
     18
     19        This is a port of a Blink patch by timloh@chromium.org.
     20
     21        No new tests, no behavior change.
     22
     23        * CMakeLists.txt:
     24        * WebCore.vcxproj/WebCore.vcxproj:
     25        * WebCore.xcodeproj/project.pbxproj:
     26        * css/BasicShapeFunctions.cpp:
     27        (WebCore::convertToLength):
     28        (WebCore::convertToLengthSize):
     29        (WebCore::convertToCenterCoordinate):
     30        (WebCore::cssValueToBasicShapeRadius):
     31        (WebCore::basicShapeForValue):
     32        * css/BasicShapeFunctions.h:
     33        * css/CSSCalculationValue.cpp:
     34        (WebCore::CSSCalcValue::computeLengthPx):
     35        (WebCore::determineCategory):
     36        * css/CSSCalculationValue.h:
     37        (WebCore::CSSCalcValue::createCalculationValue):
     38        * css/CSSGradientValue.cpp:
     39        (WebCore::CSSGradientValue::addStops):
     40        (WebCore::positionFromValue):
     41        (WebCore::CSSGradientValue::computeEndPoint):
     42        (WebCore::CSSLinearGradientValue::createGradient):
     43        (WebCore::CSSRadialGradientValue::resolveRadius):
     44        (WebCore::CSSRadialGradientValue::createGradient):
     45        * css/CSSGradientValue.h:
     46        * css/CSSPrimitiveValue.cpp:
     47        (WebCore::CSSPrimitiveValue::computeLength):
     48        (WebCore::CSSPrimitiveValue::computeLengthDouble):
     49        * css/CSSPrimitiveValue.h:
     50        * css/CSSPrimitiveValueMappings.h:
     51        (WebCore::CSSPrimitiveValue::convertToLength):
     52        * css/CSSToLengthConversionData.cpp: Added.
     53        (WebCore::CSSToLengthConversionData::zoom):
     54        * css/CSSToLengthConversionData.h: Added.
     55        (WebCore::CSSToLengthConversionData::CSSToLengthConversionData):
     56        (WebCore::CSSToLengthConversionData::style):
     57        (WebCore::CSSToLengthConversionData::rootStyle):
     58        (WebCore::CSSToLengthConversionData::computingFontSize):
     59        (WebCore::CSSToLengthConversionData::copyWithAdjustedZoom):
     60        * css/CSSToStyleMap.cpp:
     61        (WebCore::CSSToStyleMap::CSSToStyleMap):
     62        (WebCore::CSSToStyleMap::mapFillSize):
     63        (WebCore::CSSToStyleMap::mapFillXPosition):
     64        (WebCore::CSSToStyleMap::mapFillYPosition):
     65        (WebCore::CSSToStyleMap::mapNinePieceImageQuad):
     66        * css/CSSToStyleMap.h:
     67        (WebCore::CSSToStyleMap::CSSToStyleMap): Deleted.
     68        * css/DeprecatedStyleBuilder.cpp:
     69        (WebCore::ApplyPropertyAuto::applyValue):
     70        (WebCore::ApplyPropertyClip::convertToLength):
     71        (WebCore::ApplyPropertyLength::applyValue):
     72        (WebCore::ApplyPropertyBorderRadius::applyValue):
     73        (WebCore::ApplyPropertyComputeLength::applyValue):
     74        (WebCore::ApplyPropertyFontSize::applyValue):
     75        (WebCore::csstoLengthConversionDataWithTextZoomFactor):
     76        (WebCore::ApplyPropertyMarqueeIncrement::applyValue):
     77        (WebCore::ApplyPropertyLineHeight::applyValue):
     78        (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue):
     79        (WebCore::ApplyPropertyWordSpacing::applyValue):
     80        (WebCore::ApplyPropertyPageSize::mmLength):
     81        (WebCore::ApplyPropertyPageSize::inchLength):
     82        (WebCore::ApplyPropertyPageSize::applyValue):
     83        (WebCore::ApplyPropertyVerticalAlign::applyValue):
     84        (WebCore::ApplyPropertyClipPath::applyValue):
     85        (WebCore::ApplyPropertyShape::applyValue):
     86        (WebCore::ApplyPropertyTextIndent::applyValue):
     87        * css/MediaQueryEvaluator.cpp:
     88        (WebCore::colorMediaFeatureEval):
     89        (WebCore::color_indexMediaFeatureEval):
     90        (WebCore::monochromeMediaFeatureEval):
     91        (WebCore::orientationMediaFeatureEval):
     92        (WebCore::aspect_ratioMediaFeatureEval):
     93        (WebCore::device_aspect_ratioMediaFeatureEval):
     94        (WebCore::device_pixel_ratioMediaFeatureEval):
     95        (WebCore::resolutionMediaFeatureEval):
     96        (WebCore::gridMediaFeatureEval):
     97        (WebCore::computeLength):
     98        (WebCore::device_heightMediaFeatureEval):
     99        (WebCore::device_widthMediaFeatureEval):
     100        (WebCore::heightMediaFeatureEval):
     101        (WebCore::widthMediaFeatureEval):
     102        (WebCore::min_colorMediaFeatureEval):
     103        (WebCore::max_colorMediaFeatureEval):
     104        (WebCore::min_color_indexMediaFeatureEval):
     105        (WebCore::max_color_indexMediaFeatureEval):
     106        (WebCore::min_monochromeMediaFeatureEval):
     107        (WebCore::max_monochromeMediaFeatureEval):
     108        (WebCore::min_aspect_ratioMediaFeatureEval):
     109        (WebCore::max_aspect_ratioMediaFeatureEval):
     110        (WebCore::min_device_aspect_ratioMediaFeatureEval):
     111        (WebCore::max_device_aspect_ratioMediaFeatureEval):
     112        (WebCore::min_device_pixel_ratioMediaFeatureEval):
     113        (WebCore::max_device_pixel_ratioMediaFeatureEval):
     114        (WebCore::min_heightMediaFeatureEval):
     115        (WebCore::max_heightMediaFeatureEval):
     116        (WebCore::min_widthMediaFeatureEval):
     117        (WebCore::max_widthMediaFeatureEval):
     118        (WebCore::min_device_heightMediaFeatureEval):
     119        (WebCore::max_device_heightMediaFeatureEval):
     120        (WebCore::min_device_widthMediaFeatureEval):
     121        (WebCore::max_device_widthMediaFeatureEval):
     122        (WebCore::min_resolutionMediaFeatureEval):
     123        (WebCore::max_resolutionMediaFeatureEval):
     124        (WebCore::animationMediaFeatureEval):
     125        (WebCore::transitionMediaFeatureEval):
     126        (WebCore::transform_2dMediaFeatureEval):
     127        (WebCore::transform_3dMediaFeatureEval):
     128        (WebCore::view_modeMediaFeatureEval):
     129        (WebCore::video_playable_inlineMediaFeatureEval):
     130        (WebCore::hoverMediaFeatureEval):
     131        (WebCore::pointerMediaFeatureEval):
     132        (WebCore::MediaQueryEvaluator::eval):
     133        * css/SVGCSSStyleSelector.cpp:
     134        (WebCore::StyleResolver::applySVGProperty):
     135        * css/StyleResolver.cpp:
     136        (WebCore::StyleResolver::State::clear):
     137        (WebCore::StyleResolver::State::initForStyleResolve):
     138        (WebCore::StyleResolver::convertToIntLength):
     139        (WebCore::StyleResolver::convertToFloatLength):
     140        (WebCore::createGridTrackBreadth):
     141        (WebCore::StyleResolver::applyProperty):
     142        (WebCore::StyleResolver::createFilterOperations):
     143        * css/StyleResolver.h:
     144        (WebCore::StyleResolver::State::setStyle):
     145        (WebCore::StyleResolver::State::cssToLengthConversionData):
     146        * css/TransformFunctions.cpp:
     147        (WebCore::convertToFloatLength):
     148        (WebCore::transformsForValue):
     149        * css/TransformFunctions.h:
     150        * css/WebKitCSSMatrix.cpp:
     151        (WebCore::WebKitCSSMatrix::setMatrixValue):
     152        * rendering/RenderThemeIOS.mm:
     153        (WebCore::applyCommonButtonPaddingToStyle):
     154        (WebCore::RenderThemeIOS::adjustButtonStyle):
     155
    11562014-04-29  Zoltan Horvath  <zoltan@webkit.org>
    2157
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r167670 r167937  
    95239523    </ClCompile>
    95249524    <ClCompile Include="..\css\CSSToStyleMap.cpp" />
     9525    <ClCompile Include="..\css\CSSToLengthConversionData.cpp" />
    95259526    <ClCompile Include="..\css\CSSUnicodeRangeValue.cpp">
    95269527      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
     
    1991419915    <ClInclude Include="..\css\CSSTimingFunctionValue.h" />
    1991519916    <ClInclude Include="..\css\CSSToStyleMap.h" />
     19917    <ClInclude Include="..\css\CSSToLengthConversionData.h" />
    1991619918    <ClInclude Include="..\css\CSSUnicodeRangeValue.h" />
    1991719919    <ClInclude Include="..\css\CSSUnknownRule.h" />
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r167830 r167937  
    35773577                9A528E8317D7F52F00AA9518 /* FloatingObjects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A528E8117D7F52F00AA9518 /* FloatingObjects.cpp */; };
    35783578                9A528E8417D7F52F00AA9518 /* FloatingObjects.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A528E8217D7F52F00AA9518 /* FloatingObjects.h */; settings = {ATTRIBUTES = (Private, ); }; };
     3579                9AB1F38018E2489A00534743 /* CSSToLengthConversionData.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AB1F37E18E2489A00534743 /* CSSToLengthConversionData.h */; };
     3580                9AB1F38118E2489A00534743 /* CSSToLengthConversionData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AB1F37F18E2489A00534743 /* CSSToLengthConversionData.cpp */; };
    35793581                9B1AB07C1648C7C40051F3F2 /* JSHTMLFormControlsCollectionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B1AB07B1648C7C40051F3F2 /* JSHTMLFormControlsCollectionCustom.cpp */; };
    35803582                9B24DE8E15194B9500C59C27 /* HTMLBDIElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B24DE8C15194B9500C59C27 /* HTMLBDIElement.h */; };
     
    1064310645                9A528E8117D7F52F00AA9518 /* FloatingObjects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatingObjects.cpp; sourceTree = "<group>"; };
    1064410646                9A528E8217D7F52F00AA9518 /* FloatingObjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatingObjects.h; sourceTree = "<group>"; };
     10647                9AB1F37E18E2489A00534743 /* CSSToLengthConversionData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSToLengthConversionData.h; sourceTree = "<group>"; };
     10648                9AB1F37F18E2489A00534743 /* CSSToLengthConversionData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSToLengthConversionData.cpp; sourceTree = "<group>"; };
    1064510649                9B1AB0791648C69D0051F3F2 /* HTMLFormControlsCollection.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = HTMLFormControlsCollection.idl; sourceTree = "<group>"; };
    1064610650                9B1AB07B1648C7C40051F3F2 /* JSHTMLFormControlsCollectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLFormControlsCollectionCustom.cpp; sourceTree = "<group>"; };
     
    2175021754                                BC80C9850CD294EE00A0B7B3 /* CSSTimingFunctionValue.cpp */,
    2175121755                                BC80C9860CD294EE00A0B7B3 /* CSSTimingFunctionValue.h */,
     21756                                9AB1F37E18E2489A00534743 /* CSSToLengthConversionData.h */,
     21757                                9AB1F37F18E2489A00534743 /* CSSToLengthConversionData.cpp */,
    2175221758                                A882DA1F1593846A000115ED /* CSSToStyleMap.cpp */,
    2175321759                                A882DA221593848D000115ED /* CSSToStyleMap.h */,
     
    2414124147                                D66817FB166FE6D700FA07B4 /* HTMLTemplateElement.h in Headers */,
    2414224148                                A81369D6097374F600D74463 /* HTMLTextAreaElement.h in Headers */,
     24149                                9AB1F38018E2489A00534743 /* CSSToLengthConversionData.h in Headers */,
    2414324150                                9BC6C21B13CCC97B008E0337 /* HTMLTextFormControlElement.h in Headers */,
    2414424151                                A871DC280A15205700B12A68 /* HTMLTitleElement.h in Headers */,
     
    2776727774                                E125F85118283A5600D84CD9 /* JSCryptoKeySerializationJWK.cpp in Sources */,
    2776827775                                E125F83D182411E700D84CD9 /* JSCryptoOperationData.cpp in Sources */,
     27776                                9AB1F38118E2489A00534743 /* CSSToLengthConversionData.cpp in Sources */,
    2776927777                                BC46C1FA0C0DDC8F0020CFC3 /* JSCSSCharsetRule.cpp in Sources */,
    2777027778                                409EBDC516B7F3CA00CBA3FC /* JSCSSFontFaceLoadEvent.cpp in Sources */,
  • trunk/Source/WebCore/css/BasicShapeFunctions.cpp

    r167936 r167937  
    128128}
    129129
    130 static Length convertToLength(const RenderStyle* style, const RenderStyle* rootStyle, CSSPrimitiveValue* value)
    131 {
    132     return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(style, rootStyle, style->effectiveZoom());
    133 }
    134 
    135 static LengthSize convertToLengthSize(const RenderStyle* style, const RenderStyle* rootStyle, CSSPrimitiveValue* value)
     130static Length convertToLength(const CSSToLengthConversionData& conversionData, CSSPrimitiveValue* value)
     131{
     132    return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(conversionData);
     133}
     134
     135static LengthSize convertToLengthSize(const CSSToLengthConversionData& conversionData, CSSPrimitiveValue* value)
    136136{
    137137    if (!value)
     
    139139
    140140    Pair* pair = value->getPairValue();
    141     return LengthSize(convertToLength(style, rootStyle, pair->first()), convertToLength(style, rootStyle, pair->second()));
    142 }
    143 
    144 static BasicShapeCenterCoordinate convertToCenterCoordinate(const RenderStyle* style, const RenderStyle* rootStyle, CSSPrimitiveValue* value)
     141    return LengthSize(convertToLength(conversionData, pair->first()), convertToLength(conversionData, pair->second()));
     142}
     143
     144static BasicShapeCenterCoordinate convertToCenterCoordinate(const CSSToLengthConversionData& conversionData, CSSPrimitiveValue* value)
    145145{
    146146    BasicShapeCenterCoordinate::Direction direction;
     
    154154    else if (Pair* pair = value->getPairValue()) {
    155155        keyword = pair->first()->getValueID();
    156         offset = convertToLength(style, rootStyle, pair->second());
     156        offset = convertToLength(conversionData, pair->second());
    157157    } else
    158         offset = convertToLength(style, rootStyle, value);
     158        offset = convertToLength(conversionData, value);
    159159
    160160    switch (keyword) {
     
    180180}
    181181
    182 static BasicShapeRadius cssValueToBasicShapeRadius(const RenderStyle* style, const RenderStyle* rootStyle, PassRefPtr<CSSPrimitiveValue> radius)
     182static BasicShapeRadius cssValueToBasicShapeRadius(const CSSToLengthConversionData& conversionData, PassRefPtr<CSSPrimitiveValue> radius)
    183183{
    184184    if (!radius)
     
    197197    }
    198198
    199     return BasicShapeRadius(convertToLength(style, rootStyle, radius.get()));
    200 }
    201 
    202 PassRefPtr<BasicShape> basicShapeForValue(const RenderStyle* style, const RenderStyle* rootStyle, const CSSBasicShape* basicShapeValue)
     199    return BasicShapeRadius(convertToLength(conversionData, radius.get()));
     200}
     201
     202PassRefPtr<BasicShape> basicShapeForValue(const CSSToLengthConversionData& conversionData, const CSSBasicShape* basicShapeValue)
    203203{
    204204    RefPtr<BasicShape> basicShape;
     
    209209        RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create();
    210210
    211         circle->setCenterX(convertToCenterCoordinate(style, rootStyle, circleValue->centerX()));
    212         circle->setCenterY(convertToCenterCoordinate(style, rootStyle, circleValue->centerY()));
    213         circle->setRadius(cssValueToBasicShapeRadius(style, rootStyle, circleValue->radius()));
     211        circle->setCenterX(convertToCenterCoordinate(conversionData, circleValue->centerX()));
     212        circle->setCenterY(convertToCenterCoordinate(conversionData, circleValue->centerY()));
     213        circle->setRadius(cssValueToBasicShapeRadius(conversionData, circleValue->radius()));
    214214
    215215        basicShape = circle.release();
     
    220220        RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create();
    221221
    222         ellipse->setCenterX(convertToCenterCoordinate(style, rootStyle, ellipseValue->centerX()));
    223         ellipse->setCenterY(convertToCenterCoordinate(style, rootStyle, ellipseValue->centerY()));
    224 
    225         ellipse->setRadiusX(cssValueToBasicShapeRadius(style, rootStyle, ellipseValue->radiusX()));
    226         ellipse->setRadiusY(cssValueToBasicShapeRadius(style, rootStyle, ellipseValue->radiusY()));
     222        ellipse->setCenterX(convertToCenterCoordinate(conversionData, ellipseValue->centerX()));
     223        ellipse->setCenterY(convertToCenterCoordinate(conversionData, ellipseValue->centerY()));
     224
     225        ellipse->setRadiusX(cssValueToBasicShapeRadius(conversionData, ellipseValue->radiusX()));
     226        ellipse->setRadiusY(cssValueToBasicShapeRadius(conversionData, ellipseValue->radiusY()));
    227227
    228228        basicShape = ellipse.release();
     
    236236        const Vector<RefPtr<CSSPrimitiveValue>>& values = polygonValue->values();
    237237        for (unsigned i = 0; i < values.size(); i += 2)
    238             polygon->appendPoint(convertToLength(style, rootStyle, values.at(i).get()), convertToLength(style, rootStyle, values.at(i + 1).get()));
     238            polygon->appendPoint(convertToLength(conversionData, values.at(i).get()), convertToLength(conversionData, values.at(i + 1).get()));
    239239
    240240        basicShape = polygon.release();
     
    245245        RefPtr<BasicShapeInset> rect = BasicShapeInset::create();
    246246
    247         rect->setTop(convertToLength(style, rootStyle, rectValue->top()));
    248         rect->setRight(convertToLength(style, rootStyle, rectValue->right()));
    249         rect->setBottom(convertToLength(style, rootStyle, rectValue->bottom()));
    250         rect->setLeft(convertToLength(style, rootStyle, rectValue->left()));
    251 
    252         rect->setTopLeftRadius(convertToLengthSize(style, rootStyle, rectValue->topLeftRadius()));
    253         rect->setTopRightRadius(convertToLengthSize(style, rootStyle, rectValue->topRightRadius()));
    254         rect->setBottomRightRadius(convertToLengthSize(style, rootStyle, rectValue->bottomRightRadius()));
    255         rect->setBottomLeftRadius(convertToLengthSize(style, rootStyle, rectValue->bottomLeftRadius()));
     247        rect->setTop(convertToLength(conversionData, rectValue->top()));
     248        rect->setRight(convertToLength(conversionData, rectValue->right()));
     249        rect->setBottom(convertToLength(conversionData, rectValue->bottom()));
     250        rect->setLeft(convertToLength(conversionData, rectValue->left()));
     251
     252        rect->setTopLeftRadius(convertToLengthSize(conversionData, rectValue->topLeftRadius()));
     253        rect->setTopRightRadius(convertToLengthSize(conversionData, rectValue->topRightRadius()));
     254        rect->setBottomRightRadius(convertToLengthSize(conversionData, rectValue->bottomRightRadius()));
     255        rect->setBottomLeftRadius(convertToLengthSize(conversionData, rectValue->bottomLeftRadius()));
    256256
    257257        basicShape = rect.release();
  • trunk/Source/WebCore/css/BasicShapeFunctions.h

    r165472 r167937  
    3838class CSSBasicShape;
    3939class CSSPrimitiveValue;
     40class CSSToLengthConversionData;
    4041class CSSValue;
    4142class RenderStyle;
    4243
    4344PassRefPtr<CSSValue> valueForBasicShape(const RenderStyle*, const BasicShape*);
    44 PassRefPtr<BasicShape> basicShapeForValue(const RenderStyle*, const RenderStyle* rootStyle, const CSSBasicShape*);
     45PassRefPtr<BasicShape> basicShapeForValue(const CSSToLengthConversionData&, const CSSBasicShape*);
    4546
    4647float floatValueForCenterCoordinate(const BasicShapeCenterCoordinate&, float);
  • trunk/Source/WebCore/css/CSSCalculationValue.cpp

    r166860 r167937  
    172172}
    173173
    174 double CSSCalcValue::computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
    175 {
    176     return clampToPermittedRange(m_expression->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize));
     174double CSSCalcValue::computeLengthPx(const CSSToLengthConversionData& conversionData) const
     175{
     176    return clampToPermittedRange(m_expression->computeLengthPx(conversionData));
    177177}
    178178
     
    203203    }
    204204
    205     virtual std::unique_ptr<CalcExpressionNode> createCalcExpression(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const override
     205    virtual std::unique_ptr<CalcExpressionNode> createCalcExpression(const CSSToLengthConversionData& conversionData) const override
    206206    {
    207207        switch (category()) {
     
    209209            return std::make_unique<CalcExpressionNumber>(m_value->getFloatValue());
    210210        case CalcLength:
    211             return std::make_unique<CalcExpressionLength>(Length(m_value->computeLength<float>(style, rootStyle, zoom), WebCore::Fixed));
     211            return std::make_unique<CalcExpressionLength>(Length(m_value->computeLength<float>(conversionData), WebCore::Fixed));
    212212        case CalcPercent:
    213213        case CalcPercentLength: {
    214214            CSSPrimitiveValue* primitiveValue = m_value.get();
    215215            return std::make_unique<CalcExpressionLength>(primitiveValue
    216                 ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | FractionConversion>(style, rootStyle, zoom) : Length(Undefined));
     216                ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | FractionConversion>(conversionData) : Length(Undefined));
    217217        }
    218218        // Only types that could be part of a Length expression can be converted
     
    233233    }
    234234
    235     virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const override
     235    virtual double computeLengthPx(const CSSToLengthConversionData& conversionData) const override
    236236    {
    237237        switch (category()) {
    238238        case CalcLength:
    239             return m_value->computeLength<double>(currentStyle, rootStyle, multiplier, computingFontSize);
     239            return m_value->computeLength<double>(conversionData);
    240240        case CalcPercent:
    241241        case CalcNumber:
     
    395395    }
    396396
    397     virtual std::unique_ptr<CalcExpressionNode> createCalcExpression(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const override
    398     {
    399         std::unique_ptr<CalcExpressionNode> left(m_leftSide->createCalcExpression(style, rootStyle, zoom));
     397    virtual std::unique_ptr<CalcExpressionNode> createCalcExpression(const CSSToLengthConversionData& conversionData) const override
     398    {
     399        std::unique_ptr<CalcExpressionNode> left(m_leftSide->createCalcExpression(conversionData));
    400400        if (!left)
    401401            return nullptr;
    402         std::unique_ptr<CalcExpressionNode> right(m_rightSide->createCalcExpression(style, rootStyle, zoom));
     402        std::unique_ptr<CalcExpressionNode> right(m_rightSide->createCalcExpression(conversionData));
    403403        if (!right)
    404404            return nullptr;
     
    411411    }
    412412
    413     virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const override
    414     {
    415         const double leftValue = m_leftSide->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize);
    416         const double rightValue = m_rightSide->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize);
     413    virtual double computeLengthPx(const CSSToLengthConversionData& conversionData) const override
     414    {
     415        const double leftValue = m_leftSide->computeLengthPx(conversionData);
     416        const double rightValue = m_rightSide->computeLengthPx(conversionData);
    417417        return evaluate(leftValue, rightValue);
    418418    }
  • trunk/Source/WebCore/css/CSSCalculationValue.h

    r166860 r167937  
    3838namespace WebCore {
    3939
     40class CSSToLengthConversionData;
    4041class RenderStyle;
    4142
     
    5859    virtual ~CSSCalcExpressionNode() { }
    5960    virtual bool isZero() const = 0;
    60     virtual std::unique_ptr<CalcExpressionNode> createCalcExpression(const RenderStyle*, const RenderStyle* rootStyle, double zoom = 1.0) const = 0;
     61    virtual std::unique_ptr<CalcExpressionNode> createCalcExpression(const CSSToLengthConversionData&) const = 0;
    6162    virtual double doubleValue() const = 0;
    62     virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0;
     63    virtual double computeLengthPx(const CSSToLengthConversionData&) const = 0;
    6364    virtual String customCSSText() const = 0;
    6465    virtual bool equals(const CSSCalcExpressionNode& other) const { return m_category == other.m_category && m_isInteger == other.m_isInteger; }
     
    9091    double doubleValue() const;
    9192    bool isNegative() const { return m_expression->doubleValue() < 0; }
    92     double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const;
     93    double computeLengthPx(const CSSToLengthConversionData&) const;
    9394
    94     PassRef<CalculationValue> createCalculationValue(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double zoom = 1.0) const;
     95    PassRef<CalculationValue> createCalculationValue(const CSSToLengthConversionData&) const;
    9596
    9697    String customCSSText() const;
     
    113114}
    114115
    115 inline PassRef<CalculationValue> CSSCalcValue::createCalculationValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const
     116inline PassRef<CalculationValue> CSSCalcValue::createCalculationValue(const CSSToLengthConversionData& conversionData) const
    116117{
    117     return CalculationValue::create(m_expression->createCalcExpression(style, rootStyle, zoom),
     118    return CalculationValue::create(m_expression->createCalcExpression(conversionData),
    118119        m_shouldClampToNonNegative ? CalculationRangeNonNegative : CalculationRangeAll);
    119120}
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r166860 r167937  
    2828
    2929#include "CSSCalculationValue.h"
     30#include "CSSToLengthConversionData.h"
    3031#include "CSSValueKeywords.h"
    3132#include "FloatSize.h"
     
    129130}
    130131
    131 void CSSGradientValue::addStops(Gradient* gradient, RenderElement* renderer, const RenderStyle& rootStyle, float maxLengthForRepeat)
    132 {
    133     RenderStyle& style = renderer->style();
    134 
     132void CSSGradientValue::addStops(Gradient* gradient, const CSSToLengthConversionData& conversionData, float maxLengthForRepeat)
     133{
    135134    if (m_gradientType == CSSDeprecatedLinearGradient || m_gradientType == CSSDeprecatedRadialGradient) {
    136135        sortStopsIfNeeded();
     
    182181                float length;
    183182                if (stop.m_position->isLength())
    184                     length = stop.m_position->computeLength<float>(&style, &rootStyle, style.effectiveZoom());
     183                    length = stop.m_position->computeLength<float>(conversionData);
    185184                else {
    186                     Ref<CalculationValue> calculationValue { stop.m_position->cssCalcValue()->createCalculationValue(&style, &rootStyle, style.effectiveZoom()) };
     185                    Ref<CalculationValue> calculationValue { stop.m_position->cssCalcValue()->createCalculationValue(conversionData) };
    187186                    length = calculationValue->evaluate(gradientLength);
    188187                }
     
    393392}
    394393
    395 static float positionFromValue(CSSPrimitiveValue* value, const RenderStyle& style, const RenderStyle& rootStyle, const FloatSize& size, bool isHorizontal)
    396 {
    397     float zoomFactor = style.effectiveZoom();
    398 
     394static float positionFromValue(CSSPrimitiveValue* value, const CSSToLengthConversionData& conversionData, const FloatSize& size, bool isHorizontal)
     395{
    399396    if (value->isNumber())
    400         return value->getFloatValue() * zoomFactor;
     397        return value->getFloatValue() * conversionData.zoom();
    401398
    402399    int edgeDistance = isHorizontal ? size.width() : size.height();
     
    405402
    406403    if (value->isCalculatedPercentageWithLength()) {
    407         Ref<CalculationValue> calculationValue { value->cssCalcValue()->createCalculationValue(&style, &rootStyle, style.effectiveZoom()) };
     404        Ref<CalculationValue> calculationValue { value->cssCalcValue()->createCalculationValue(conversionData) };
    408405        return calculationValue->evaluate(edgeDistance);
    409406    }
     
    426423    }
    427424
    428     return value->computeLength<float>(&style, &rootStyle, zoomFactor);
    429 }
    430 
    431 FloatPoint CSSGradientValue::computeEndPoint(CSSPrimitiveValue* horizontal, CSSPrimitiveValue* vertical, const RenderStyle& style, const RenderStyle& rootStyle, const FloatSize& size)
     425    return value->computeLength<float>(conversionData);
     426}
     427
     428FloatPoint CSSGradientValue::computeEndPoint(CSSPrimitiveValue* horizontal, CSSPrimitiveValue* vertical, const CSSToLengthConversionData& conversionData, const FloatSize& size)
    432429{
    433430    FloatPoint result;
    434431
    435432    if (horizontal)
    436         result.setX(positionFromValue(horizontal, style, rootStyle, size, true));
     433        result.setX(positionFromValue(horizontal, conversionData, size, true));
    437434
    438435    if (vertical)
    439         result.setY(positionFromValue(vertical, style, rootStyle, size, false));
     436        result.setY(positionFromValue(vertical, conversionData, size, false));
    440437
    441438    return result;
     
    648645    ASSERT(!size.isEmpty());
    649646
    650     RenderStyle& rootStyle = *renderer->document().documentElement()->renderStyle();
     647    CSSToLengthConversionData conversionData(&renderer->style(), renderer->document().documentElement()->renderStyle());
    651648
    652649    FloatPoint firstPoint;
     
    658655        switch (m_gradientType) {
    659656        case CSSDeprecatedLinearGradient:
    660             firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), renderer->style(), rootStyle, size);
     657            firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), conversionData, size);
    661658            if (m_secondX || m_secondY)
    662                 secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), renderer->style(), rootStyle, size);
     659                secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), conversionData, size);
    663660            else {
    664661                if (m_firstX)
     
    669666            break;
    670667        case CSSPrefixedLinearGradient:
    671             firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), renderer->style(), rootStyle, size);
     668            firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), conversionData, size);
    672669            if (m_firstX)
    673670                secondPoint.setX(size.width() - firstPoint.x());
     
    688685                endPointsFromAngle(angle, size, firstPoint, secondPoint, m_gradientType);
    689686            } else if (m_firstX || m_firstY) {
    690                 secondPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), renderer->style(), rootStyle, size);
     687                secondPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), conversionData, size);
    691688                if (m_firstX)
    692689                    firstPoint.setX(size.width() - secondPoint.x());
     
    705702
    706703    // Now add the stops.
    707     addStops(gradient.get(), renderer, rootStyle, 1);
     704    addStops(gradient.get(), conversionData, 1);
    708705
    709706    return gradient.release();
     
    892889}
    893890
    894 float CSSRadialGradientValue::resolveRadius(CSSPrimitiveValue* radius, const RenderStyle& style, const RenderStyle& rootStyle, float* widthOrHeight)
    895 {
    896     float zoomFactor = style.effectiveZoom();
    897 
     891float CSSRadialGradientValue::resolveRadius(CSSPrimitiveValue* radius, const CSSToLengthConversionData& conversionData, float* widthOrHeight)
     892{
    898893    float result = 0;
    899894    if (radius->isNumber()) // Can the radius be a percentage?
    900         result = radius->getFloatValue() * zoomFactor;
     895        result = radius->getFloatValue() * conversionData.zoom();
    901896    else if (widthOrHeight && radius->isPercentage())
    902897        result = *widthOrHeight * radius->getFloatValue() / 100;
    903898    else
    904         result = radius->computeLength<float>(&style, &rootStyle, zoomFactor);
     899        result = radius->computeLength<float>(conversionData);
    905900
    906901    return result;
     
    988983    ASSERT(!size.isEmpty());
    989984
    990     RenderStyle& rootStyle = *renderer->document().documentElement()->renderStyle();
    991 
    992     FloatPoint firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), renderer->style(), rootStyle, size);
     985    CSSToLengthConversionData conversionData(&renderer->style(), renderer->document().documentElement()->renderStyle());
     986
     987    FloatPoint firstPoint = computeEndPoint(m_firstX.get(), m_firstY.get(), conversionData, size);
    993988    if (!m_firstX)
    994989        firstPoint.setX(size.width() / 2);
     
    996991        firstPoint.setY(size.height() / 2);
    997992
    998     FloatPoint secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), renderer->style(), rootStyle, size);
     993    FloatPoint secondPoint = computeEndPoint(m_secondX.get(), m_secondY.get(), conversionData, size);
    999994    if (!m_secondX)
    1000995        secondPoint.setX(size.width() / 2);
     
    1004999    float firstRadius = 0;
    10051000    if (m_firstRadius)
    1006         firstRadius = resolveRadius(m_firstRadius.get(), renderer->style(), rootStyle);
     1001        firstRadius = resolveRadius(m_firstRadius.get(), conversionData);
    10071002
    10081003    float secondRadius = 0;
    10091004    float aspectRatio = 1; // width / height.
    10101005    if (m_secondRadius)
    1011         secondRadius = resolveRadius(m_secondRadius.get(), renderer->style(), rootStyle);
     1006        secondRadius = resolveRadius(m_secondRadius.get(), conversionData);
    10121007    else if (m_endHorizontalSize) {
    10131008        float width = size.width();
    10141009        float height = size.height();
    1015         secondRadius = resolveRadius(m_endHorizontalSize.get(), renderer->style(), rootStyle, &width);
     1010        secondRadius = resolveRadius(m_endHorizontalSize.get(), conversionData, &width);
    10161011        if (m_endVerticalSize)
    1017             aspectRatio = secondRadius / resolveRadius(m_endVerticalSize.get(), renderer->style(), rootStyle, &height);
     1012            aspectRatio = secondRadius / resolveRadius(m_endVerticalSize.get(), conversionData, &height);
    10181013        else
    10191014            aspectRatio = 1;
     
    11211116
    11221117    // Now add the stops.
    1123     addStops(gradient.get(), renderer, rootStyle, maxExtent);
     1118    addStops(gradient.get(), conversionData, maxExtent);
    11241119
    11251120    return gradient.release();
  • trunk/Source/WebCore/css/CSSGradientValue.h

    r166642 r167937  
    110110    }
    111111
    112     void addStops(Gradient*, RenderElement*, const RenderStyle& rootStyle, float maxLengthForRepeat = 0);
     112    void addStops(Gradient*, const CSSToLengthConversionData&, float maxLengthForRepeat = 0);
    113113
    114114    // Resolve points/radii to front end values.
    115     FloatPoint computeEndPoint(CSSPrimitiveValue*, CSSPrimitiveValue*, const RenderStyle&, const RenderStyle& rootStyle, const FloatSize&);
     115    FloatPoint computeEndPoint(CSSPrimitiveValue*, CSSPrimitiveValue*, const CSSToLengthConversionData&, const FloatSize&);
    116116
    117117    bool isCacheable() const;
     
    219219
    220220    // Resolve points/radii to front end values.
    221     float resolveRadius(CSSPrimitiveValue*, const RenderStyle&, const RenderStyle& rootStyle, float* widthOrHeight = 0);
     221    float resolveRadius(CSSPrimitiveValue*, const CSSToLengthConversionData&, float* widthOrHeight = 0);
    222222
    223223    // These may be null for non-deprecated gradients.
  • trunk/Source/WebCore/css/CSSPrimitiveValue.cpp

    r167936 r167937  
    2727#include "CSSParser.h"
    2828#include "CSSPropertyNames.h"
     29#include "CSSToLengthConversionData.h"
    2930#include "CSSValueKeywords.h"
    3031#include "CalculationValue.h"
     
    555556}
    556557
    557 template<> int CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
    558 {
    559     return roundForImpreciseConversion<int>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    560 }
    561 
    562 template<> unsigned CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
    563 {
    564     return roundForImpreciseConversion<unsigned>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    565 }
    566 
    567 template<> Length CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
     558template<> int CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
     559{
     560    return roundForImpreciseConversion<int>(computeLengthDouble(conversionData));
     561}
     562
     563template<> unsigned CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
     564{
     565    return roundForImpreciseConversion<unsigned>(computeLengthDouble(conversionData));
     566}
     567
     568template<> Length CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
    568569{
    569570#if ENABLE(SUBPIXEL_LAYOUT)
    570     return Length(clampTo<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize), minValueForCssLength, maxValueForCssLength), Fixed);
     571    return Length(clampTo<float>(computeLengthDouble(conversionData), minValueForCssLength, maxValueForCssLength), Fixed);
    571572#else
    572     return Length(clampTo<float>(roundForImpreciseConversion<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize)), minValueForCssLength, maxValueForCssLength), Fixed);
     573    return Length(clampTo<float>(roundForImpreciseConversion<float>(computeLengthDouble(conversionData)), minValueForCssLength, maxValueForCssLength), Fixed);
    573574#endif
    574575}
    575576
    576 template<> short CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
    577 {
    578     return roundForImpreciseConversion<short>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    579 }
    580 
    581 template<> unsigned short CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
    582 {
    583     return roundForImpreciseConversion<unsigned short>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    584 }
    585 
    586 template<> float CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
    587 {
    588     return static_cast<float>(computeLengthDouble(style, rootStyle, multiplier, computingFontSize));
    589 }
    590 
    591 template<> double CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
    592 {
    593     return computeLengthDouble(style, rootStyle, multiplier, computingFontSize);
    594 }
    595 
    596 double CSSPrimitiveValue::computeLengthDouble(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const
     577template<> short CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
     578{
     579    return roundForImpreciseConversion<short>(computeLengthDouble(conversionData));
     580}
     581
     582template<> unsigned short CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
     583{
     584    return roundForImpreciseConversion<unsigned short>(computeLengthDouble(conversionData));
     585}
     586
     587template<> float CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
     588{
     589    return static_cast<float>(computeLengthDouble(conversionData));
     590}
     591
     592template<> double CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const
     593{
     594    return computeLengthDouble(conversionData);
     595}
     596
     597double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& conversionData) const
    597598{
    598599    if (m_primitiveUnitType == CSS_CALC)
    599600        // The multiplier and factor is applied to each value in the calc expression individually
    600         return m_value.calc->computeLengthPx(style, rootStyle, multiplier, computingFontSize);
     601        return m_value.calc->computeLengthPx(conversionData);
    601602
    602603    double factor;
     
    604605    switch (primitiveType()) {
    605606    case CSS_EMS:
    606         factor = computingFontSize ? style->fontDescription().specifiedSize() : style->fontDescription().computedSize();
     607        ASSERT(conversionData.style());
     608        factor = conversionData.computingFontSize() ? conversionData.style()->fontDescription().specifiedSize() : conversionData.style()->fontDescription().computedSize();
    607609        break;
    608610    case CSS_EXS:
     611        ASSERT(conversionData.style());
    609612        // FIXME: We have a bug right now where the zoom will be applied twice to EX units.
    610613        // We really need to compute EX using fontMetrics for the original specifiedSize and not use
    611614        // our actual constructed rendering font.
    612         if (style->fontMetrics().hasXHeight())
    613             factor = style->fontMetrics().xHeight();
     615        if (conversionData.style()->fontMetrics().hasXHeight())
     616            factor = conversionData.style()->fontMetrics().xHeight();
    614617        else
    615             factor = (computingFontSize ? style->fontDescription().specifiedSize() : style->fontDescription().computedSize()) / 2.0;
     618            factor = (conversionData.computingFontSize() ? conversionData.style()->fontDescription().specifiedSize() : conversionData.style()->fontDescription().computedSize()) / 2.0;
    616619        break;
    617620    case CSS_REMS:
    618         if (rootStyle)
    619             factor = computingFontSize ? rootStyle->fontDescription().specifiedSize() : rootStyle->fontDescription().computedSize();
     621        if (conversionData.rootStyle())
     622            factor = conversionData.computingFontSize() ? conversionData.rootStyle()->fontDescription().specifiedSize() : conversionData.rootStyle()->fontDescription().computedSize();
    620623        else
    621624            factor = 1.0;
    622625        break;
    623626    case CSS_CHS:
    624         factor = style->fontMetrics().zeroWidth();
     627        ASSERT(conversionData.style());
     628        factor = conversionData.style()->fontMetrics().zeroWidth();
    625629        break;
    626630    case CSS_PX:
     
    662666    // as well as enforcing the implicit "smart minimum."
    663667    double result = getDoubleValue() * factor;
    664     if (computingFontSize || isFontRelativeLength())
     668    if (conversionData.computingFontSize() || isFontRelativeLength())
    665669        return result;
    666670
    667     return result * multiplier;
     671    return result * conversionData.zoom();
    668672}
    669673
  • trunk/Source/WebCore/css/CSSPrimitiveValue.h

    r167936 r167937  
    3434
    3535class CSSCalcValue;
     36class CSSToLengthConversionData;
    3637class Counter;
    3738class DashboardRegion;
     
    266267     * and some tool to calibrate.
    267268     */
    268     template<typename T> T computeLength(const RenderStyle* currStyle, const RenderStyle* rootStyle, float multiplier = 1.0f, bool computingFontSize = false) const;
     269    template<typename T> T computeLength(const CSSToLengthConversionData&) const;
    269270
    270271    // Converts to a Length, mapping various unit types appropriately.
    271     template<int> Length convertToLength(const RenderStyle* currStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const;
     272    template<int> Length convertToLength(const CSSToLengthConversionData&) const;
    272273
    273274    // use with care!!!
     
    379380    bool getDoubleValueInternal(UnitTypes targetUnitType, double* result) const;
    380381
    381     double computeLengthDouble(const RenderStyle* currentStyle, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const;
     382    double computeLengthDouble(const CSSToLengthConversionData&) const;
    382383
    383384    union {
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r167786 r167937  
    3434#include "CSSPrimitiveValue.h"
    3535#include "CSSReflectionDirection.h"
     36#include "CSSToLengthConversionData.h"
    3637#include "ColorSpace.h"
    3738#include "CSSValueKeywords.h"
     
    46324633};
    46334634
    4634 template<int supported> Length CSSPrimitiveValue::convertToLength(const RenderStyle* style, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const
    4635 {
    4636     if ((supported & (FixedIntegerConversion | FixedFloatConversion)) && isFontRelativeLength() && (!style || !rootStyle))
     4635template<int supported> Length CSSPrimitiveValue::convertToLength(const CSSToLengthConversionData& conversionData) const
     4636{
     4637    if ((supported & (FixedIntegerConversion | FixedFloatConversion)) && isFontRelativeLength() && (!conversionData.style() || !conversionData.rootStyle()))
    46374638        return Length(Undefined);
    46384639    if ((supported & FixedIntegerConversion) && isLength())
    4639         return computeLength<Length>(style, rootStyle, multiplier, computingFontSize);
     4640        return computeLength<Length>(conversionData);
    46404641    if ((supported & FixedFloatConversion) && isLength())
    4641         return Length(computeLength<double>(style, rootStyle, multiplier), Fixed);
     4642        return Length(computeLength<double>(conversionData), Fixed);
    46424643    if ((supported & PercentConversion) && isPercentage())
    46434644        return Length(getDoubleValue(), Percent);
     
    46474648        return Length(Auto);
    46484649    if ((supported & CalculatedConversion) && isCalculated())
    4649         return Length(cssCalcValue()->createCalculationValue(style, rootStyle, multiplier));
     4650        return Length(cssCalcValue()->createCalculationValue(conversionData));
    46504651    if ((supported & ViewportPercentageConversion) && isViewportPercentageLength())
    46514652        return viewportPercentageLength();
  • trunk/Source/WebCore/css/CSSToStyleMap.cpp

    r166860 r167937  
    4242namespace WebCore {
    4343
     44CSSToStyleMap::CSSToStyleMap(StyleResolver* resolver)
     45    : m_resolver(resolver)
     46{
     47}
     48
    4449RenderStyle* CSSToStyleMap::style() const
    4550{
     
    204209    }
    205210
    206     float zoomFactor = style()->effectiveZoom();
    207 
    208211    Length firstLength;
    209212    Length secondLength;
     
    212215        CSSPrimitiveValue* first = static_cast<CSSPrimitiveValue*>(pair->first());
    213216        CSSPrimitiveValue* second = static_cast<CSSPrimitiveValue*>(pair->second());
    214         firstLength = first->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor);
    215         secondLength = second->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor);
     217        firstLength = first->convertToLength<AnyConversion>(m_resolver->state().cssToLengthConversionData());
     218        secondLength = second->convertToLength<AnyConversion>(m_resolver->state().cssToLengthConversionData());
    216219    } else {
    217         firstLength = primitiveValue->convertToLength<AnyConversion>(style(), rootElementStyle(), zoomFactor);
     220        firstLength = primitiveValue->convertToLength<AnyConversion>(m_resolver->state().cssToLengthConversionData());
    218221        secondLength = Length();
    219222    }
     
    236239    if (!value->isPrimitiveValue())
    237240        return;
    238 
    239     float zoomFactor = style()->effectiveZoom();
    240241
    241242    CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
     
    248249    Length length;
    249250    if (primitiveValue->isLength())
    250         length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), zoomFactor);
     251        length = primitiveValue->computeLength<Length>(m_resolver->state().cssToLengthConversionData());
    251252    else if (primitiveValue->isPercentage())
    252253        length = Length(primitiveValue->getDoubleValue(), Percent);
    253254    else if (primitiveValue->isCalculatedPercentageWithLength())
    254         length = Length(primitiveValue->cssCalcValue()->createCalculationValue(style(), rootElementStyle(), zoomFactor));
     255        length = Length(primitiveValue->cssCalcValue()->createCalculationValue(m_resolver->state().cssToLengthConversionData()));
    255256    else if (primitiveValue->isViewportPercentageLength())
    256257        length = primitiveValue->viewportPercentageLength();
     
    272273    if (!value->isPrimitiveValue())
    273274        return;
    274 
    275     float zoomFactor = style()->effectiveZoom();
    276275
    277276    CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
     
    284283    Length length;
    285284    if (primitiveValue->isLength())
    286         length = primitiveValue->computeLength<Length>(style(), rootElementStyle(), zoomFactor);
     285        length = primitiveValue->computeLength<Length>(m_resolver->state().cssToLengthConversionData());
    287286    else if (primitiveValue->isPercentage())
    288287        length = Length(primitiveValue->getDoubleValue(), Percent);
    289288    else if (primitiveValue->isCalculatedPercentageWithLength())
    290         length = Length(primitiveValue->cssCalcValue()->createCalculationValue(style(), rootElementStyle(), zoomFactor));
     289        length = Length(primitiveValue->cssCalcValue()->createCalculationValue(m_resolver->state().cssToLengthConversionData()));
    291290    else if (primitiveValue->isViewportPercentageLength())
    292291        length = primitiveValue->viewportPercentageLength();
     
    634633
    635634    // Get our zoom value.
    636     float zoom = useSVGZoomRules() ? 1.0f : style()->effectiveZoom();
     635    CSSToLengthConversionData conversionData = useSVGZoomRules() ? m_resolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f) : m_resolver->state().cssToLengthConversionData();
    637636
    638637    // Retrieve the primitive value.
     
    647646        box.m_top = Length(slices->top()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
    648647    else if (slices->top()->getValueID() != CSSValueAuto)
    649         box.m_top = slices->top()->computeLength<Length>(style(), rootElementStyle(), zoom);
     648        box.m_top = slices->top()->computeLength<Length>(conversionData);
    650649
    651650    if (slices->right()->isNumber())
     
    654653        box.m_right = Length(slices->right()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
    655654    else if (slices->right()->getValueID() != CSSValueAuto)
    656         box.m_right = slices->right()->computeLength<Length>(style(), rootElementStyle(), zoom);
     655        box.m_right = slices->right()->computeLength<Length>(conversionData);
    657656
    658657    if (slices->bottom()->isNumber())
     
    661660        box.m_bottom = Length(slices->bottom()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
    662661    else if (slices->bottom()->getValueID() != CSSValueAuto)
    663         box.m_bottom = slices->bottom()->computeLength<Length>(style(), rootElementStyle(), zoom);
     662        box.m_bottom = slices->bottom()->computeLength<Length>(conversionData);
    664663
    665664    if (slices->left()->isNumber())
     
    668667        box.m_left = Length(slices->left()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
    669668    else if (slices->left()->getValueID() != CSSValueAuto)
    670         box.m_left = slices->left()->computeLength<Length>(style(), rootElementStyle(), zoom);
     669        box.m_left = slices->left()->computeLength<Length>(conversionData);
    671670
    672671    return box;
  • trunk/Source/WebCore/css/CSSToStyleMap.h

    r166860 r167937  
    4444
    4545public:
    46     CSSToStyleMap(StyleResolver* resolver) : m_resolver(resolver) { }
     46    CSSToStyleMap(StyleResolver*);
    4747
    4848    void mapFillAttachment(CSSPropertyID, FillLayer*, CSSValue*);
  • trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp

    r167518 r167937  
    221221            setValue(styleResolver->style(), *primitiveValue);
    222222        else if (valueType == ComputeLength)
    223             setValue(styleResolver->style(), primitiveValue->computeLength<T>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()));
     223            setValue(styleResolver->style(), primitiveValue->computeLength<T>(styleResolver->state().cssToLengthConversionData()));
    224224    }
    225225
     
    231231    static Length convertToLength(StyleResolver* styleResolver, CSSPrimitiveValue* value)
    232232    {
    233         return value->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | AutoConversion>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());
     233        return value->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | AutoConversion>(styleResolver->state().cssToLengthConversionData());
    234234    }
    235235public:
     
    388388            setValue(styleResolver->style(), Length());
    389389        else if (primitiveValue->isLength()) {
    390             Length length = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());
     390            Length length = primitiveValue->computeLength<Length>(styleResolver->state().cssToLengthConversionData());
    391391            length.setHasQuirk(primitiveValue->isQuirkValue());
    392392            setValue(styleResolver->style(), length);
     
    394394            setValue(styleResolver->style(), Length(primitiveValue->getDoubleValue(), Percent));
    395395        else if (primitiveValue->isCalculatedPercentageWithLength())
    396             setValue(styleResolver->style(), Length(primitiveValue->cssCalcValue()->createCalculationValue(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom())));
     396            setValue(styleResolver->style(), Length(primitiveValue->cssCalcValue()->createCalculationValue(styleResolver->state().cssToLengthConversionData())));
    397397        else if (primitiveValue->isViewportPercentageLength())
    398398            setValue(styleResolver->style(), primitiveValue->viewportPercentageLength());
     
    443443            return;
    444444
     445        CSSToLengthConversionData conversionData = styleResolver->state().cssToLengthConversionData();
    445446        Length radiusWidth;
    446447        if (pair->first()->isPercentage())
     
    449450            radiusWidth = Length(styleResolver->viewportPercentageValue(*pair->first(), pair->first()->getIntValue()), Fixed);
    450451        else if (pair->first()->isCalculatedPercentageWithLength())
    451             radiusWidth = Length(pair->first()->cssCalcValue()->createCalculationValue(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()));
     452            radiusWidth = Length(pair->first()->cssCalcValue()->createCalculationValue(conversionData));
    452453        else
    453             radiusWidth = pair->first()->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());
     454            radiusWidth = pair->first()->computeLength<Length>(conversionData);
    454455
    455456        Length radiusHeight;
     
    459460            radiusHeight = Length(styleResolver->viewportPercentageValue(*pair->second(), pair->second()->getIntValue()), Fixed);
    460461        else if (pair->second()->isCalculatedPercentageWithLength())
    461             radiusHeight = Length(pair->second()->cssCalcValue()->createCalculationValue(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()));
     462            radiusHeight = Length(pair->second()->cssCalcValue()->createCalculationValue(conversionData));
    462463        else
    463             radiusHeight = pair->second()->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());
     464            radiusHeight = pair->second()->computeLength<Length>(conversionData);
    464465
    465466        if (radiusWidth.isNegative() || radiusHeight.isNegative())
     
    612613            length = 5;
    613614        } else if (ident == CSSValueInvalid) {
    614             float zoom = (svgZoomEnabled && styleResolver->useSVGZoomRules()) ? 1.0f : styleResolver->style()->effectiveZoom();
     615            CSSToLengthConversionData conversionData = (svgZoomEnabled && styleResolver->useSVGZoomRules()) ? styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f) : styleResolver->state().cssToLengthConversionData();
    615616
    616617            // Any original result that was >= 1 should not be allowed to fall below 1.
    617618            // This keeps border lines from vanishing.
    618             length = primitiveValue->computeLength<T>(styleResolver->style(), styleResolver->rootElementStyle(), zoom);
    619             if (zoom < 1.0f && length < 1.0) {
    620                 T originalLength = primitiveValue->computeLength<T>(styleResolver->style(), styleResolver->rootElementStyle(), 1.0);
     619            length = primitiveValue->computeLength<T>(conversionData);
     620            if (conversionData.zoom() < 1.0f && length < 1.0) {
     621                T originalLength = primitiveValue->computeLength<T>(conversionData.copyWithAdjustedZoom(1.0f));
    621622                if (originalLength >= 1.0)
    622623                    length = 1.0;
     
    869870                                              || !(primitiveValue->isPercentage() || primitiveValue->isFontRelativeLength()));
    870871            if (primitiveValue->isLength())
    871                 size = primitiveValue->computeLength<float>(styleResolver->parentStyle(), styleResolver->rootElementStyle(), 1.0, true);
     872                size = primitiveValue->computeLength<float>(CSSToLengthConversionData(styleResolver->parentStyle(), styleResolver->rootElementStyle(), 1.0f, true));
    872873            else if (primitiveValue->isPercentage())
    873874                size = (primitiveValue->getFloatValue() * parentSize) / 100.0f;
    874875            else if (primitiveValue->isCalculatedPercentageWithLength()) {
    875                 Ref<CalculationValue> calculationValue { primitiveValue->cssCalcValue()->createCalculationValue(styleResolver->parentStyle(), styleResolver->rootElementStyle()) };
     876                Ref<CalculationValue> calculationValue { primitiveValue->cssCalcValue()->createCalculationValue(styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f)) };
    876877                size = calculationValue->evaluate(parentSize);
    877878            } else if (primitiveValue->isViewportPercentageLength())
     
    12931294}
    12941295
     1296static inline CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver& styleResolver)
     1297{
     1298    if (Frame* frame = styleResolver.document().frame())
     1299        return styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(styleResolver.style()->effectiveZoom() * frame->textZoomFactor());
     1300
     1301    return styleResolver.state().cssToLengthConversionData();
     1302}
     1303
    12951304class ApplyPropertyTextDecorationSkip {
    12961305public:
     
    13371346            }
    13381347        } else {
    1339             Length marqueeLength = styleResolver->convertToIntLength(primitiveValue, styleResolver->style(), styleResolver->rootElementStyle());
     1348            Length marqueeLength = styleResolver->convertToIntLength(primitiveValue, styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f));
    13401349            if (!marqueeLength.isUndefined())
    13411350                styleResolver->style()->setMarqueeIncrement(marqueeLength);
     
    14431452            lineHeight = RenderStyle::initialLineHeight();
    14441453        else if (primitiveValue->isLength()) {
    1445             double multiplier = styleResolver->style()->effectiveZoom();
    1446             if (Frame* frame = styleResolver->document().frame())
    1447                 multiplier *= frame->textZoomFactor();
    1448             lineHeight = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), multiplier);
     1454            lineHeight = primitiveValue->computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(*styleResolver));
    14491455        } else if (primitiveValue->isPercentage()) {
    14501456            // FIXME: percentage should not be restricted to an integer here.
     
    14811487            lineHeight = RenderStyle::initialLineHeight();
    14821488        else if (primitiveValue->isLength()) {
    1483             double multiplier = styleResolver->style()->effectiveZoom();
    1484             if (styleResolver->style()->textSizeAdjust().isNone()) {
    1485                 if (Frame* frame = styleResolver->document().frame())
    1486                     multiplier *= frame->textZoomFactor();
    1487             }
    1488             lineHeight = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), multiplier);
     1489            lineHeight = primitiveValue->computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(*styleResolver));
    14891490            if (styleResolver->style()->textSizeAdjust().isPercentage())
    14901491                lineHeight = Length(lineHeight.value() * styleResolver->style()->textSizeAdjust().multiplier(), Fixed);
     
    15381539            wordSpacing = RenderStyle::initialWordSpacing();
    15391540        else if (primitiveValue->isLength()) {
    1540             double multiplier = styleResolver->style()->effectiveZoom();
    1541             if (Frame* frame = styleResolver->document().frame())
    1542                 multiplier *= frame->textZoomFactor();
    1543             wordSpacing = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), multiplier);
     1541            wordSpacing = primitiveValue->computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(*styleResolver));
    15441542        } else if (primitiveValue->isPercentage())
    15451543            wordSpacing = Length(primitiveValue->getDoubleValue(), Percent);
     
    15641562    {
    15651563        Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(mm, CSSPrimitiveValue::CSS_MM));
    1566         return value.get().computeLength<Length>(0, 0);
     1564        return value.get().computeLength<Length>(CSSToLengthConversionData());
    15671565    }
    15681566    static Length inchLength(double inch)
    15691567    {
    15701568        Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(inch, CSSPrimitiveValue::CSS_IN));
    1571         return value.get().computeLength<Length>(0, 0);
     1569        return value.get().computeLength<Length>(CSSToLengthConversionData());
    15721570    }
    15731571    static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height)
     
    16651663                if (!second->isLength())
    16661664                    return;
    1667                 width = first->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle());
    1668                 height = second->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle());
     1665                CSSToLengthConversionData conversionData = styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f);
     1666                width = first->computeLength<Length>(conversionData);
     1667                height = second->computeLength<Length>(conversionData);
    16691668            } else {
    16701669                // <page-size> <orientation>
     
    16841683                // <length>
    16851684                pageSizeType = PAGE_SIZE_RESOLVED;
    1686                 width = height = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle());
     1685                width = height = primitiveValue->computeLength<Length>(styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f));
    16871686            } else {
    16881687                switch (primitiveValue->getValueID()) {
     
    19621961            return styleResolver->style()->setVerticalAlign(*primitiveValue);
    19631962
    1964         styleResolver->style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()));
     1963        styleResolver->style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(styleResolver->state().cssToLengthConversionData()));
    19651964    }
    19661965
     
    21402139            auto& primitiveValue = toCSSPrimitiveValue(*valueList.itemWithoutBoundsCheck(i));
    21412140            if (primitiveValue.isShape() && !operation)
    2142                 operation = ShapeClipPathOperation::create(basicShapeForValue(styleResolver->style(), styleResolver->rootElementStyle(), primitiveValue.getShapeValue()));
     2141                operation = ShapeClipPathOperation::create(basicShapeForValue(styleResolver->state().cssToLengthConversionData(), primitiveValue.getShapeValue()));
    21432142            else if ((primitiveValue.getValueID() == CSSValueContentBox
    21442143                || primitiveValue.getValueID() == CSSValueBorderBox
     
    21892188                CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->itemWithoutBoundsCheck(i));
    21902189                if (primitiveValue->isShape())
    2191                     shape = basicShapeForValue(styleResolver->style(), styleResolver->rootElementStyle(), primitiveValue->getShapeValue());
     2190                    shape = basicShapeForValue(styleResolver->state().cssToLengthConversionData(), primitiveValue->getShapeValue());
    21922191                else if (primitiveValue->getValueID() == CSSValueContentBox
    21932192                    || primitiveValue->getValueID() == CSSValueBorderBox
     
    23022301            CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(item);
    23032302            if (!primitiveValue->getValueID())
    2304                 lengthOrPercentageValue = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());
     2303                lengthOrPercentageValue = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(styleResolver->state().cssToLengthConversionData());
    23052304#if ENABLE(CSS3_TEXT)
    23062305            else if (primitiveValue->getValueID() == CSSValueWebkitEachLine)
  • trunk/Source/WebCore/css/MediaQueryEvaluator.cpp

    r165676 r167937  
    3232#include "CSSAspectRatioValue.h"
    3333#include "CSSPrimitiveValue.h"
     34#include "CSSToLengthConversionData.h"
    3435#include "CSSValueKeywords.h"
    3536#include "CSSValueList.h"
     
    7071enum MediaFeaturePrefix { MinPrefix, MaxPrefix, NoPrefix };
    7172
    72 typedef bool (*EvalFunc)(CSSValue*, RenderStyle*, Frame*, MediaFeaturePrefix);
     73typedef bool (*EvalFunc)(CSSValue*, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix);
    7374typedef HashMap<AtomicStringImpl*, EvalFunc> FunctionMap;
    7475static FunctionMap* gFunctionMap;
     
    204205}
    205206
    206 static bool colorMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)
     207static bool colorMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix op)
    207208{
    208209    int bitsPerComponent = screenDepthPerComponent(frame->page()->mainFrame().view());
     
    214215}
    215216
    216 static bool color_indexMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op)
     217static bool color_indexMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix op)
    217218{
    218219    // FIXME: It's unknown how to retrieve the information if the display mode is indexed
     
    225226}
    226227
    227 static bool monochromeMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)
     228static bool monochromeMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix op)
    228229{
    229230    if (!screenIsMonochrome(frame->page()->mainFrame().view())) {
     
    235236    }
    236237
    237     return colorMediaFeatureEval(value, style, frame, op);
    238 }
    239 
    240 static bool orientationMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix)
     238    return colorMediaFeatureEval(value, conversionData, frame, op);
     239}
     240
     241static bool orientationMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix)
    241242{
    242243    FrameView* view = frame->view();
     
    257258}
    258259
    259 static bool aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)
     260static bool aspect_ratioMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix op)
    260261{
    261262    FrameView* view = frame->view();
     
    271272}
    272273
    273 static bool device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)
     274static bool device_aspect_ratioMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix op)
    274275{
    275276    if (value) {
     
    315316}
    316317
    317 static bool device_pixel_ratioMediaFeatureEval(CSSValue *value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)
     318static bool device_pixel_ratioMediaFeatureEval(CSSValue *value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix op)
    318319{
    319320    return (!value || toCSSPrimitiveValue(value)->isNumber()) && evalResolution(value, frame, op);
    320321}
    321322
    322 static bool resolutionMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)
     323static bool resolutionMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix op)
    323324{
    324325#if ENABLE(RESOLUTION_MEDIA_QUERY)
     
    332333}
    333334
    334 static bool gridMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op)
     335static bool gridMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix op)
    335336{
    336337    // if output device is bitmap, grid: 0 == true
     
    342343}
    343344
    344 static bool computeLength(CSSValue* value, bool strict, RenderStyle* style, RenderStyle* rootStyle, int& result)
     345static bool computeLength(CSSValue* value, bool strict, const CSSToLengthConversionData& conversionData, int& result)
    345346{
    346347    if (!value->isPrimitiveValue())
     
    355356
    356357    if (primitiveValue->isLength()) {
    357         result = primitiveValue->computeLength<int>(style, rootStyle);
     358        result = primitiveValue->computeLength<int>(conversionData);
    358359        return true;
    359360    }
     
    362363}
    363364
    364 static bool device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)
     365static bool device_heightMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix op)
    365366{
    366367    if (value) {
    367368        FloatRect sg = screenRect(frame->page()->mainFrame().view());
    368         RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
    369369        int length;
    370370        long height = sg.height();
    371         return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(static_cast<int>(height), length, op);
     371        return computeLength(value, !frame->document()->inQuirksMode(), conversionData, length) && compareValue(static_cast<int>(height), length, op);
    372372    }
    373373    // ({,min-,max-}device-height)
     
    376376}
    377377
    378 static bool device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)
     378static bool device_widthMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix op)
    379379{
    380380    if (value) {
    381381        FloatRect sg = screenRect(frame->page()->mainFrame().view());
    382         RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
    383382        int length;
    384383        long width = sg.width();
    385         return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(static_cast<int>(width), length, op);
     384        return computeLength(value, !frame->document()->inQuirksMode(), conversionData, length) && compareValue(static_cast<int>(width), length, op);
    386385    }
    387386    // ({,min-,max-}device-width)
     
    390389}
    391390
    392 static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)
     391static bool heightMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix op)
    393392{
    394393    FrameView* view = frame->view();
     
    400399        if (RenderView* renderView = frame->document()->renderView())
    401400            height = adjustForAbsoluteZoom(height, *renderView);
    402         RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
    403401        int length;
    404         return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(height, length, op);
     402        return computeLength(value, !frame->document()->inQuirksMode(), conversionData, length) && compareValue(height, length, op);
    405403    }
    406404
     
    408406}
    409407
    410 static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)
     408static bool widthMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix op)
    411409{
    412410    FrameView* view = frame->view();
     
    418416        if (RenderView* renderView = frame->document()->renderView())
    419417            width = adjustForAbsoluteZoom(width, *renderView);
    420         RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();
    421418        int length;
    422         return computeLength(value, !frame->document()->inQuirksMode(), style, rootStyle, length) && compareValue(width, length, op);
     419        return computeLength(value, !frame->document()->inQuirksMode(), conversionData, length) && compareValue(width, length, op);
    423420    }
    424421
     
    428425// rest of the functions are trampolines which set the prefix according to the media feature expression used
    429426
    430 static bool min_colorMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    431 {
    432     return colorMediaFeatureEval(value, style, frame, MinPrefix);
    433 }
    434 
    435 static bool max_colorMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    436 {
    437     return colorMediaFeatureEval(value, style, frame, MaxPrefix);
    438 }
    439 
    440 static bool min_color_indexMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    441 {
    442     return color_indexMediaFeatureEval(value, style, frame, MinPrefix);
    443 }
    444 
    445 static bool max_color_indexMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    446 {
    447     return color_indexMediaFeatureEval(value, style, frame, MaxPrefix);
    448 }
    449 
    450 static bool min_monochromeMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    451 {
    452     return monochromeMediaFeatureEval(value, style, frame, MinPrefix);
    453 }
    454 
    455 static bool max_monochromeMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    456 {
    457     return monochromeMediaFeatureEval(value, style, frame, MaxPrefix);
    458 }
    459 
    460 static bool min_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    461 {
    462     return aspect_ratioMediaFeatureEval(value, style, frame, MinPrefix);
    463 }
    464 
    465 static bool max_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    466 {
    467     return aspect_ratioMediaFeatureEval(value, style, frame, MaxPrefix);
    468 }
    469 
    470 static bool min_device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    471 {
    472     return device_aspect_ratioMediaFeatureEval(value, style, frame, MinPrefix);
    473 }
    474 
    475 static bool max_device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    476 {
    477     return device_aspect_ratioMediaFeatureEval(value, style, frame, MaxPrefix);
    478 }
    479 
    480 static bool min_device_pixel_ratioMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    481 {
    482     return device_pixel_ratioMediaFeatureEval(value, style, frame, MinPrefix);
    483 }
    484 
    485 static bool max_device_pixel_ratioMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    486 {
    487     return device_pixel_ratioMediaFeatureEval(value, style, frame, MaxPrefix);
    488 }
    489 
    490 static bool min_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    491 {
    492     return heightMediaFeatureEval(value, style, frame, MinPrefix);
    493 }
    494 
    495 static bool max_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    496 {
    497     return heightMediaFeatureEval(value, style, frame, MaxPrefix);
    498 }
    499 
    500 static bool min_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    501 {
    502     return widthMediaFeatureEval(value, style, frame, MinPrefix);
    503 }
    504 
    505 static bool max_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    506 {
    507     return widthMediaFeatureEval(value, style, frame, MaxPrefix);
    508 }
    509 
    510 static bool min_device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    511 {
    512     return device_heightMediaFeatureEval(value, style, frame, MinPrefix);
    513 }
    514 
    515 static bool max_device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    516 {
    517     return device_heightMediaFeatureEval(value, style, frame, MaxPrefix);
    518 }
    519 
    520 static bool min_device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    521 {
    522     return device_widthMediaFeatureEval(value, style, frame, MinPrefix);
    523 }
    524 
    525 static bool max_device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    526 {
    527     return device_widthMediaFeatureEval(value, style, frame, MaxPrefix);
    528 }
    529 
    530 static bool min_resolutionMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    531 {
    532     return resolutionMediaFeatureEval(value, style, frame, MinPrefix);
    533 }
    534 
    535 static bool max_resolutionMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix)
    536 {
    537     return resolutionMediaFeatureEval(value, style, frame, MaxPrefix);
    538 }
    539 
    540 static bool animationMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op)
     427static bool min_colorMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     428{
     429    return colorMediaFeatureEval(value, conversionData, frame, MinPrefix);
     430}
     431
     432static bool max_colorMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     433{
     434    return colorMediaFeatureEval(value, conversionData, frame, MaxPrefix);
     435}
     436
     437static bool min_color_indexMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     438{
     439    return color_indexMediaFeatureEval(value, conversionData, frame, MinPrefix);
     440}
     441
     442static bool max_color_indexMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     443{
     444    return color_indexMediaFeatureEval(value, conversionData, frame, MaxPrefix);
     445}
     446
     447static bool min_monochromeMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     448{
     449    return monochromeMediaFeatureEval(value, conversionData, frame, MinPrefix);
     450}
     451
     452static bool max_monochromeMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     453{
     454    return monochromeMediaFeatureEval(value, conversionData, frame, MaxPrefix);
     455}
     456
     457static bool min_aspect_ratioMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     458{
     459    return aspect_ratioMediaFeatureEval(value, conversionData, frame, MinPrefix);
     460}
     461
     462static bool max_aspect_ratioMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     463{
     464    return aspect_ratioMediaFeatureEval(value, conversionData, frame, MaxPrefix);
     465}
     466
     467static bool min_device_aspect_ratioMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     468{
     469    return device_aspect_ratioMediaFeatureEval(value, conversionData, frame, MinPrefix);
     470}
     471
     472static bool max_device_aspect_ratioMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     473{
     474    return device_aspect_ratioMediaFeatureEval(value, conversionData, frame, MaxPrefix);
     475}
     476
     477static bool min_device_pixel_ratioMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     478{
     479    return device_pixel_ratioMediaFeatureEval(value, conversionData, frame, MinPrefix);
     480}
     481
     482static bool max_device_pixel_ratioMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     483{
     484    return device_pixel_ratioMediaFeatureEval(value, conversionData, frame, MaxPrefix);
     485}
     486
     487static bool min_heightMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     488{
     489    return heightMediaFeatureEval(value, conversionData, frame, MinPrefix);
     490}
     491
     492static bool max_heightMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     493{
     494    return heightMediaFeatureEval(value, conversionData, frame, MaxPrefix);
     495}
     496
     497static bool min_widthMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     498{
     499    return widthMediaFeatureEval(value, conversionData, frame, MinPrefix);
     500}
     501
     502static bool max_widthMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     503{
     504    return widthMediaFeatureEval(value, conversionData, frame, MaxPrefix);
     505}
     506
     507static bool min_device_heightMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     508{
     509    return device_heightMediaFeatureEval(value, conversionData, frame, MinPrefix);
     510}
     511
     512static bool max_device_heightMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     513{
     514    return device_heightMediaFeatureEval(value, conversionData, frame, MaxPrefix);
     515}
     516
     517static bool min_device_widthMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     518{
     519    return device_widthMediaFeatureEval(value, conversionData, frame, MinPrefix);
     520}
     521
     522static bool max_device_widthMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     523{
     524    return device_widthMediaFeatureEval(value, conversionData, frame, MaxPrefix);
     525}
     526
     527static bool min_resolutionMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     528{
     529    return resolutionMediaFeatureEval(value, conversionData, frame, MinPrefix);
     530}
     531
     532static bool max_resolutionMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix)
     533{
     534    return resolutionMediaFeatureEval(value, conversionData, frame, MaxPrefix);
     535}
     536
     537static bool animationMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix op)
    541538{
    542539    if (value) {
     
    547544}
    548545
    549 static bool transitionMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op)
     546static bool transitionMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix op)
    550547{
    551548    if (value) {
     
    556553}
    557554
    558 static bool transform_2dMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op)
     555static bool transform_2dMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix op)
    559556{
    560557    if (value) {
     
    565562}
    566563
    567 static bool transform_3dMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)
     564static bool transform_3dMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix op)
    568565{
    569566    bool returnValueIfNoParameter;
     
    591588
    592589#if ENABLE(VIEW_MODE_CSS_MEDIA)
    593 static bool view_modeMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)
     590static bool view_modeMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix op)
    594591{
    595592    UNUSED_PARAM(op);
     
    636633}
    637634
    638 static bool video_playable_inlineMediaFeatureEval(CSSValue*, RenderStyle*, Frame* frame, MediaFeaturePrefix)
     635static bool video_playable_inlineMediaFeatureEval(CSSValue*, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix)
    639636{
    640637    return !isRunningOnIPhoneOrIPod() || frame->settings().mediaPlaybackAllowsInline();
     
    658655}
    659656
    660 static bool hoverMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix)
     657static bool hoverMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix)
    661658{
    662659    PointerDeviceType pointer = leastCapablePrimaryPointerDeviceType(frame);
     
    679676}
    680677
    681 static bool pointerMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix)
     678static bool pointerMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix)
    682679{
    683680    PointerDeviceType pointer = leastCapablePrimaryPointerDeviceType(frame);
     
    728725    // used
    729726    EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl());
    730     if (func)
    731         return func(expr->value(), m_style.get(), m_frame, NoPrefix);
     727    if (func) {
     728        CSSToLengthConversionData conversionData(m_style.get(), m_frame->document()->documentElement()->renderStyle());
     729        return func(expr->value(), conversionData, m_frame, NoPrefix);
     730    }
    732731
    733732    return false;
  • trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp

    r165676 r167937  
    594594                return;
    595595            CSSShadowValue* item = toCSSShadowValue(firstValue);
    596             IntPoint location(item->x->computeLength<int>(state.style(), state.rootElementStyle()),
    597                 item->y->computeLength<int>(state.style(), state.rootElementStyle()));
    598             int blur = item->blur ? item->blur->computeLength<int>(state.style(), state.rootElementStyle()) : 0;
     596            IntPoint location(item->x->computeLength<int>(state.cssToLengthConversionData().copyWithAdjustedZoom(1.0f)),
     597                item->y->computeLength<int>(state.cssToLengthConversionData().copyWithAdjustedZoom(1.0f)));
     598            int blur = item->blur ? item->blur->computeLength<int>(state.cssToLengthConversionData().copyWithAdjustedZoom(1.0f)) : 0;
    599599            Color color;
    600600            if (item->color)
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r167877 r167937  
    244244    m_filtersWithPendingSVGDocuments.clear();
    245245#endif
     246    m_cssToLengthConversionData = CSSToLengthConversionData(nullptr, nullptr);
    246247}
    247248
     
    423424    m_pendingImageProperties.clear();
    424425    m_fontDirty = false;
     426
     427    m_cssToLengthConversionData = CSSToLengthConversionData(m_style.get(), m_rootElementStyle);
    425428}
    426429
     
    14491452// this is mostly boring stuff on how to apply a certain rule to the renderstyle...
    14501453
    1451 Length StyleResolver::convertToIntLength(const CSSPrimitiveValue* primitiveValue, const RenderStyle* style, const RenderStyle* rootStyle, double multiplier)
    1452 {
    1453     return primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
    1454 }
    1455 
    1456 Length StyleResolver::convertToFloatLength(const CSSPrimitiveValue* primitiveValue, const RenderStyle* style, const RenderStyle* rootStyle, double multiplier)
    1457 {
    1458     return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
     1454Length StyleResolver::convertToIntLength(const CSSPrimitiveValue* primitiveValue, const CSSToLengthConversionData& conversionData)
     1455{
     1456    return primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(conversionData) : Length(Undefined);
     1457}
     1458
     1459Length StyleResolver::convertToFloatLength(const CSSPrimitiveValue* primitiveValue, const CSSToLengthConversionData& conversionData)
     1460{
     1461    return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(conversionData) : Length(Undefined);
    14591462}
    14601463
     
    18571860    }
    18581861
    1859     workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | CalculatedConversion | AutoConversion>(state.style(), state.rootElementStyle(), state.style()->effectiveZoom());
     1862    workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | CalculatedConversion | AutoConversion>(state.cssToLengthConversionData());
    18601863    if (workingLength.length().isUndefined())
    18611864        return false;
     
    20222025
    20232026    CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimitiveValue(value) : 0;
    2024 
    2025     float zoomFactor = state.style()->effectiveZoom();
    20262027
    20272028    // What follows is a list that maps the CSS properties into their corresponding front-end
     
    23022303                continue;
    23032304            CSSShadowValue* item = toCSSShadowValue(currValue);
    2304             int x = item->x->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor);
     2305            int x = item->x->computeLength<int>(state.cssToLengthConversionData());
    23052306            if (item->x->isViewportPercentageLength())
    23062307                x = viewportPercentageValue(*item->x, x);
    2307             int y = item->y->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor);
     2308            int y = item->y->computeLength<int>(state.cssToLengthConversionData());
    23082309            if (item->y->isViewportPercentageLength())
    23092310                y = viewportPercentageValue(*item->y, y);
    2310             int blur = item->blur ? item->blur->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor) : 0;
     2311            int blur = item->blur ? item->blur->computeLength<int>(state.cssToLengthConversionData()) : 0;
    23112312            if (item->blur && item->blur->isViewportPercentageLength())
    23122313                blur = viewportPercentageValue(*item->blur, blur);
    2313             int spread = item->spread ? item->spread->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor) : 0;
     2314            int spread = item->spread ? item->spread->computeLength<int>(state.cssToLengthConversionData()) : 0;
    23142315            if (item->spread && item->spread->isViewportPercentageLength())
    23152316                spread = viewportPercentageValue(*item->spread, spread);
     
    23432344        reflection->setDirection(*reflectValue->direction());
    23442345        if (reflectValue->offset())
    2345             reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(state.style(), state.rootElementStyle(), zoomFactor));
     2346            reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(state.cssToLengthConversionData()));
    23462347        NinePieceImage mask;
    23472348        mask.setMaskDefaults();
     
    24042405        DashboardRegion* first = region;
    24052406        while (region) {
    2406             Length top = convertToIntLength(region->top(), state.style(), state.rootElementStyle());
    2407             Length right = convertToIntLength(region->right(), state.style(), state.rootElementStyle());
    2408             Length bottom = convertToIntLength(region->bottom(), state.style(), state.rootElementStyle());
    2409             Length left = convertToIntLength(region->left(), state.style(), state.rootElementStyle());
     2407            Length top = convertToIntLength(region->top(), state.cssToLengthConversionData().copyWithAdjustedZoom(1.0f));
     2408            Length right = convertToIntLength(region->right(), state.cssToLengthConversionData().copyWithAdjustedZoom(1.0f));
     2409            Length bottom = convertToIntLength(region->bottom(), state.cssToLengthConversionData().copyWithAdjustedZoom(1.0f));
     2410            Length left = convertToIntLength(region->left(), state.cssToLengthConversionData().copyWithAdjustedZoom(1.0f));
    24102411
    24112412            if (top.isUndefined())
     
    24432444                result *= 5;
    24442445            Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(result, CSSPrimitiveValue::CSS_EMS));
    2445             width = value.get().computeLength<float>(state.style(), state.rootElementStyle(), zoomFactor);
     2446            width = value.get().computeLength<float>(state.cssToLengthConversionData());
    24462447            break;
    24472448        }
    24482449        default:
    2449             width = primitiveValue->computeLength<float>(state.style(), state.rootElementStyle(), zoomFactor);
     2450            width = primitiveValue->computeLength<float>(state.cssToLengthConversionData());
    24502451            break;
    24512452        }
     
    24562457        HANDLE_INHERIT_AND_INITIAL(transform, Transform);
    24572458        TransformOperations operations;
    2458         transformsForValue(state.style(), state.rootElementStyle(), value, operations);
     2459        transformsForValue(value, state.cssToLengthConversionData(), operations);
    24592460        state.style()->setTransform(operations);
    24602461        return;
     
    24732474        float perspectiveValue;
    24742475        if (primitiveValue->isLength())
    2475             perspectiveValue = primitiveValue->computeLength<float>(state.style(), state.rootElementStyle(), zoomFactor);
     2476            perspectiveValue = primitiveValue->computeLength<float>(state.cssToLengthConversionData());
    24762477        else if (primitiveValue->isNumber()) {
    24772478            // For backward compatibility, treat valueless numbers as px.
    24782479            Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(primitiveValue->getDoubleValue(), CSSPrimitiveValue::CSS_PX));
    2479             perspectiveValue = value.get().computeLength<float>(state.style(), state.rootElementStyle(), zoomFactor);
     2480            perspectiveValue = value.get().computeLength<float>(state.cssToLengthConversionData());
    24802481        } else
    24812482            return;
     
    33153316{
    33163317    State& state = m_state;
    3317     RenderStyle* style = state.style();
    3318     RenderStyle* rootStyle = state.rootElementStyle();
    33193318    ASSERT(outOperations.isEmpty());
    33203319   
     
    33313330        return false;
    33323331
    3333     float zoomFactor = style ? style->effectiveZoom() : 1;
    33343332    FilterOperations operations;
    33353333    for (CSSValueListIterator i = inValue; i.hasMore(); i.advance()) {
     
    34173415            Length stdDeviation = Length(0, Fixed);
    34183416            if (filterValue->length() >= 1)
    3419                 stdDeviation = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
     3417                stdDeviation = convertToFloatLength(firstValue, state.cssToLengthConversionData());
    34203418            if (stdDeviation.isUndefined())
    34213419                return false;
     
    34333431
    34343432            CSSShadowValue* item = toCSSShadowValue(cssValue);
    3435             int x = item->x->computeLength<int>(style, rootStyle, zoomFactor);
     3433            int x = item->x->computeLength<int>(state.cssToLengthConversionData());
    34363434            if (item->x->isViewportPercentageLength())
    34373435                x = viewportPercentageValue(*item->x, x);
    3438             int y = item->y->computeLength<int>(style, rootStyle, zoomFactor);
     3436            int y = item->y->computeLength<int>(state.cssToLengthConversionData());
    34393437            if (item->y->isViewportPercentageLength())
    34403438                y = viewportPercentageValue(*item->y, y);
    34413439            IntPoint location(x, y);
    3442             int blur = item->blur ? item->blur->computeLength<int>(style, rootStyle, zoomFactor) : 0;
     3440            int blur = item->blur ? item->blur->computeLength<int>(state.cssToLengthConversionData()) : 0;
    34433441            if (item->blur && item->blur->isViewportPercentageLength())
    34443442                blur = viewportPercentageValue(*item->blur, blur);
  • trunk/Source/WebCore/css/StyleResolver.h

    r166299 r167937  
    2323#define StyleResolver_h
    2424
     25#include "CSSToLengthConversionData.h"
    2526#include "CSSToStyleMap.h"
    2627#include "CSSValueList.h"
     
    355356        Element* element() const { return m_element; }
    356357        StyledElement* styledElement() const { return m_styledElement; }
    357         void setStyle(PassRef<RenderStyle> style) { m_style = std::move(style); }
     358        void setStyle(PassRef<RenderStyle> style)
     359        {
     360            m_style = std::move(style);
     361            m_cssToLengthConversionData = CSSToLengthConversionData(m_style.get(), m_rootElementStyle);
     362        }
    358363        RenderStyle* style() const { return m_style.get(); }
    359364        PassRef<RenderStyle> takeStyle() { return m_style.releaseNonNull(); }
     
    397402
    398403        bool useSVGZoomRules() const { return m_element && m_element->isSVGElement(); }
     404
     405        CSSToLengthConversionData cssToLengthConversionData() const { return m_cssToLengthConversionData; }
    399406
    400407    private:
     
    429436        FillLayer m_backgroundData;
    430437        Color m_backgroundColor;
     438
     439        CSSToLengthConversionData m_cssToLengthConversionData;
    431440    };
    432441
     
    446455    bool applyPropertyToVisitedLinkStyle() const { return m_state.applyPropertyToVisitedLinkStyle(); }
    447456
    448     static Length convertToIntLength(const CSSPrimitiveValue*, const RenderStyle*, const RenderStyle* rootStyle, double multiplier = 1);
    449     static Length convertToFloatLength(const CSSPrimitiveValue*, const RenderStyle*, const RenderStyle* rootStyle, double multiplier = 1);
     457    static Length convertToIntLength(const CSSPrimitiveValue*, const CSSToLengthConversionData&);
     458    static Length convertToFloatLength(const CSSPrimitiveValue*, const CSSToLengthConversionData&);
    450459
    451460    CSSToStyleMap* styleMap() { return &m_styleMap; }
  • trunk/Source/WebCore/css/TransformFunctions.cpp

    r156705 r167937  
    7777}
    7878
    79 static Length convertToFloatLength(const CSSPrimitiveValue* primitiveValue, const RenderStyle* style, const RenderStyle* rootStyle, double multiplier)
     79static Length convertToFloatLength(const CSSPrimitiveValue* primitiveValue, const CSSToLengthConversionData& conversionData)
    8080{
    81     return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
     81    return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(conversionData) : Length(Undefined);
    8282}
    8383
    84 bool transformsForValue(const RenderStyle* style, const RenderStyle* rootStyle, CSSValue* value, TransformOperations& outOperations)
     84bool transformsForValue(CSSValue* value, const CSSToLengthConversionData& conversionData, TransformOperations& outOperations)
    8585{
    8686    if (!value || !value->isValueList()) {
     
    8989    }
    9090
    91     float zoomFactor = style ? style->effectiveZoom() : 1;
    9291    TransformOperations operations;
    9392    for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
     
    166165            Length ty = Length(0, Fixed);
    167166            if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
    168                 ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
    169             else {
    170                 tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
     167                ty = convertToFloatLength(firstValue, conversionData);
     168            else {
     169                tx = convertToFloatLength(firstValue, conversionData);
    171170                if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
    172171                    if (transformValue->length() > 1) {
    173172                        CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(1));
    174                         ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor);
     173                        ty = convertToFloatLength(secondValue, conversionData);
    175174                    }
    176175                }
     
    189188            Length tz = Length(0, Fixed);
    190189            if (transformValue->operationType() == WebKitCSSTransformValue::TranslateZTransformOperation)
    191                 tz = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
     190                tz = convertToFloatLength(firstValue, conversionData);
    192191            else if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
    193                 ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
    194             else {
    195                 tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
     192                ty = convertToFloatLength(firstValue, conversionData);
     193            else {
     194                tx = convertToFloatLength(firstValue, conversionData);
    196195                if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
    197196                    if (transformValue->length() > 2) {
    198197                        CSSPrimitiveValue* thirdValue = toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(2));
    199                         tz = convertToFloatLength(thirdValue, style, rootStyle, zoomFactor);
    200                     }
    201                     if (transformValue->length() > 1) {
    202                         CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(1));
    203                         ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor);
     198                        tz = convertToFloatLength(thirdValue, conversionData);
     199                    }
     200                    if (transformValue->length() > 1) {
     201                        CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(1));
     202                        ty = convertToFloatLength(secondValue, conversionData);
    204203                    }
    205204                }
     
    274273            double c = toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(2))->getDoubleValue();
    275274            double d = toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(3))->getDoubleValue();
    276             double e = zoomFactor * toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(4))->getDoubleValue();
    277             double f = zoomFactor * toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(5))->getDoubleValue();
     275            double e = conversionData.zoom() * toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(4))->getDoubleValue();
     276            double f = conversionData.zoom() * toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(5))->getDoubleValue();
    278277            operations.operations().append(MatrixTransformOperation::create(a, b, c, d, e, f));
    279278            break;
     
    294293                toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(10))->getDoubleValue(),
    295294                toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(11))->getDoubleValue(),
    296                 zoomFactor * toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(12))->getDoubleValue(),
    297                 zoomFactor * toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(13))->getDoubleValue(),
     295                conversionData.zoom() * toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(12))->getDoubleValue(),
     296                conversionData.zoom() * toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(13))->getDoubleValue(),
    298297                toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(14))->getDoubleValue(),
    299298                toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(15))->getDoubleValue());
     
    304303            Length p = Length(0, Fixed);
    305304            if (firstValue->isLength())
    306                 p = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
     305                p = convertToFloatLength(firstValue, conversionData);
    307306            else {
    308307                // This is a quirk that should go away when 3d transforms are finalized.
  • trunk/Source/WebCore/css/TransformFunctions.h

    r148753 r167937  
    3535namespace WebCore {
    3636
     37class CSSToLengthConversionData;
    3738class CSSValue;
    3839class RenderStyle;
    3940class WebKitCSSTransformValue;
    4041
    41 bool transformsForValue(const RenderStyle*, const RenderStyle* rootStyle, CSSValue*, TransformOperations&);
     42bool transformsForValue(CSSValue*, const CSSToLengthConversionData&, TransformOperations&);
    4243
    4344}
  • trunk/Source/WebCore/css/WebKitCSSMatrix.cpp

    r159856 r167937  
    2929#include "CSSParser.h"
    3030#include "CSSPropertyNames.h"
     31#include "CSSToLengthConversionData.h"
    3132#include "CSSValueKeywords.h"
    3233#include "ExceptionCode.h"
     
    6768
    6869        TransformOperations operations;
    69         if (!transformsForValue(0, 0, value.get(), operations)) {
     70        if (!transformsForValue(value.get(), CSSToLengthConversionData(), operations)) {
    7071            ec = SYNTAX_ERR;
    7172            return;
  • trunk/Source/WebCore/rendering/RenderThemeIOS.mm

    r167771 r167937  
    527527    Document& document = element->document();
    528528    RefPtr<CSSPrimitiveValue> emSize = CSSPrimitiveValue::create(0.5, CSSPrimitiveValue::CSS_EMS);
    529     int pixels = emSize->computeLength<int>(style, document.renderStyle(), document.frame()->pageZoomFactor());
     529    int pixels = emSize->computeLength<int>(CSSToLengthConversionData(style, document.renderStyle(), document.frame()->pageZoomFactor()));
    530530    style->setPaddingBox(LengthBox(0, pixels, 0, pixels));
    531531}
     
    935935    // Since the element might not be in a document, just pass nullptr for the root element style.
    936936    RefPtr<CSSPrimitiveValue> emSize = CSSPrimitiveValue::create(1.0, CSSPrimitiveValue::CSS_EMS);
    937     int pixels = emSize->computeLength<int>(style, nullptr);
     937    int pixels = emSize->computeLength<int>(CSSToLengthConversionData(style, nullptr, 1.0));
    938938    style->setPaddingBox(LengthBox(0, pixels, 0, pixels));
    939939
Note: See TracChangeset for help on using the changeset viewer.