Changeset 167937 in webkit
- Timestamp:
- Apr 29, 2014 9:36:43 AM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r167652 r167937 1226 1226 css/CSSSupportsRule.cpp 1227 1227 css/CSSTimingFunctionValue.cpp 1228 css/CSSToLengthConversionData.cpp 1228 1229 css/CSSToStyleMap.cpp 1229 1230 css/CSSUnicodeRangeValue.cpp -
trunk/Source/WebCore/ChangeLog
r167936 r167937 1 2014-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 1 156 2014-04-29 Zoltan Horvath <zoltan@webkit.org> 2 157 -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
r167670 r167937 9523 9523 </ClCompile> 9524 9524 <ClCompile Include="..\css\CSSToStyleMap.cpp" /> 9525 <ClCompile Include="..\css\CSSToLengthConversionData.cpp" /> 9525 9526 <ClCompile Include="..\css\CSSUnicodeRangeValue.cpp"> 9526 9527 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> … … 19914 19915 <ClInclude Include="..\css\CSSTimingFunctionValue.h" /> 19915 19916 <ClInclude Include="..\css\CSSToStyleMap.h" /> 19917 <ClInclude Include="..\css\CSSToLengthConversionData.h" /> 19916 19918 <ClInclude Include="..\css\CSSUnicodeRangeValue.h" /> 19917 19919 <ClInclude Include="..\css\CSSUnknownRule.h" /> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r167830 r167937 3577 3577 9A528E8317D7F52F00AA9518 /* FloatingObjects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A528E8117D7F52F00AA9518 /* FloatingObjects.cpp */; }; 3578 3578 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 */; }; 3579 3581 9B1AB07C1648C7C40051F3F2 /* JSHTMLFormControlsCollectionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B1AB07B1648C7C40051F3F2 /* JSHTMLFormControlsCollectionCustom.cpp */; }; 3580 3582 9B24DE8E15194B9500C59C27 /* HTMLBDIElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B24DE8C15194B9500C59C27 /* HTMLBDIElement.h */; }; … … 10643 10645 9A528E8117D7F52F00AA9518 /* FloatingObjects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatingObjects.cpp; sourceTree = "<group>"; }; 10644 10646 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>"; }; 10645 10649 9B1AB0791648C69D0051F3F2 /* HTMLFormControlsCollection.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = HTMLFormControlsCollection.idl; sourceTree = "<group>"; }; 10646 10650 9B1AB07B1648C7C40051F3F2 /* JSHTMLFormControlsCollectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLFormControlsCollectionCustom.cpp; sourceTree = "<group>"; }; … … 21750 21754 BC80C9850CD294EE00A0B7B3 /* CSSTimingFunctionValue.cpp */, 21751 21755 BC80C9860CD294EE00A0B7B3 /* CSSTimingFunctionValue.h */, 21756 9AB1F37E18E2489A00534743 /* CSSToLengthConversionData.h */, 21757 9AB1F37F18E2489A00534743 /* CSSToLengthConversionData.cpp */, 21752 21758 A882DA1F1593846A000115ED /* CSSToStyleMap.cpp */, 21753 21759 A882DA221593848D000115ED /* CSSToStyleMap.h */, … … 24141 24147 D66817FB166FE6D700FA07B4 /* HTMLTemplateElement.h in Headers */, 24142 24148 A81369D6097374F600D74463 /* HTMLTextAreaElement.h in Headers */, 24149 9AB1F38018E2489A00534743 /* CSSToLengthConversionData.h in Headers */, 24143 24150 9BC6C21B13CCC97B008E0337 /* HTMLTextFormControlElement.h in Headers */, 24144 24151 A871DC280A15205700B12A68 /* HTMLTitleElement.h in Headers */, … … 27767 27774 E125F85118283A5600D84CD9 /* JSCryptoKeySerializationJWK.cpp in Sources */, 27768 27775 E125F83D182411E700D84CD9 /* JSCryptoOperationData.cpp in Sources */, 27776 9AB1F38118E2489A00534743 /* CSSToLengthConversionData.cpp in Sources */, 27769 27777 BC46C1FA0C0DDC8F0020CFC3 /* JSCSSCharsetRule.cpp in Sources */, 27770 27778 409EBDC516B7F3CA00CBA3FC /* JSCSSFontFaceLoadEvent.cpp in Sources */, -
trunk/Source/WebCore/css/BasicShapeFunctions.cpp
r167936 r167937 128 128 } 129 129 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)130 static Length convertToLength(const CSSToLengthConversionData& conversionData, CSSPrimitiveValue* value) 131 { 132 return value->convertToLength<FixedIntegerConversion | FixedFloatConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(conversionData); 133 } 134 135 static LengthSize convertToLengthSize(const CSSToLengthConversionData& conversionData, CSSPrimitiveValue* value) 136 136 { 137 137 if (!value) … … 139 139 140 140 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 144 static BasicShapeCenterCoordinate convertToCenterCoordinate(const CSSToLengthConversionData& conversionData, CSSPrimitiveValue* value) 145 145 { 146 146 BasicShapeCenterCoordinate::Direction direction; … … 154 154 else if (Pair* pair = value->getPairValue()) { 155 155 keyword = pair->first()->getValueID(); 156 offset = convertToLength( style, rootStyle, pair->second());156 offset = convertToLength(conversionData, pair->second()); 157 157 } else 158 offset = convertToLength( style, rootStyle, value);158 offset = convertToLength(conversionData, value); 159 159 160 160 switch (keyword) { … … 180 180 } 181 181 182 static BasicShapeRadius cssValueToBasicShapeRadius(const RenderStyle* style, const RenderStyle* rootStyle, PassRefPtr<CSSPrimitiveValue> radius)182 static BasicShapeRadius cssValueToBasicShapeRadius(const CSSToLengthConversionData& conversionData, PassRefPtr<CSSPrimitiveValue> radius) 183 183 { 184 184 if (!radius) … … 197 197 } 198 198 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 202 PassRefPtr<BasicShape> basicShapeForValue(const CSSToLengthConversionData& conversionData, const CSSBasicShape* basicShapeValue) 203 203 { 204 204 RefPtr<BasicShape> basicShape; … … 209 209 RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create(); 210 210 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())); 214 214 215 215 basicShape = circle.release(); … … 220 220 RefPtr<BasicShapeEllipse> ellipse = BasicShapeEllipse::create(); 221 221 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())); 227 227 228 228 basicShape = ellipse.release(); … … 236 236 const Vector<RefPtr<CSSPrimitiveValue>>& values = polygonValue->values(); 237 237 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())); 239 239 240 240 basicShape = polygon.release(); … … 245 245 RefPtr<BasicShapeInset> rect = BasicShapeInset::create(); 246 246 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())); 256 256 257 257 basicShape = rect.release(); -
trunk/Source/WebCore/css/BasicShapeFunctions.h
r165472 r167937 38 38 class CSSBasicShape; 39 39 class CSSPrimitiveValue; 40 class CSSToLengthConversionData; 40 41 class CSSValue; 41 42 class RenderStyle; 42 43 43 44 PassRefPtr<CSSValue> valueForBasicShape(const RenderStyle*, const BasicShape*); 44 PassRefPtr<BasicShape> basicShapeForValue(const RenderStyle*, const RenderStyle* rootStyle, const CSSBasicShape*);45 PassRefPtr<BasicShape> basicShapeForValue(const CSSToLengthConversionData&, const CSSBasicShape*); 45 46 46 47 float floatValueForCenterCoordinate(const BasicShapeCenterCoordinate&, float); -
trunk/Source/WebCore/css/CSSCalculationValue.cpp
r166860 r167937 172 172 } 173 173 174 double CSSCalcValue::computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const175 { 176 return clampToPermittedRange(m_expression->computeLengthPx(c urrentStyle, rootStyle, multiplier, computingFontSize));174 double CSSCalcValue::computeLengthPx(const CSSToLengthConversionData& conversionData) const 175 { 176 return clampToPermittedRange(m_expression->computeLengthPx(conversionData)); 177 177 } 178 178 … … 203 203 } 204 204 205 virtual std::unique_ptr<CalcExpressionNode> createCalcExpression(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const override205 virtual std::unique_ptr<CalcExpressionNode> createCalcExpression(const CSSToLengthConversionData& conversionData) const override 206 206 { 207 207 switch (category()) { … … 209 209 return std::make_unique<CalcExpressionNumber>(m_value->getFloatValue()); 210 210 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)); 212 212 case CalcPercent: 213 213 case CalcPercentLength: { 214 214 CSSPrimitiveValue* primitiveValue = m_value.get(); 215 215 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)); 217 217 } 218 218 // Only types that could be part of a Length expression can be converted … … 233 233 } 234 234 235 virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const override235 virtual double computeLengthPx(const CSSToLengthConversionData& conversionData) const override 236 236 { 237 237 switch (category()) { 238 238 case CalcLength: 239 return m_value->computeLength<double>(c urrentStyle, rootStyle, multiplier, computingFontSize);239 return m_value->computeLength<double>(conversionData); 240 240 case CalcPercent: 241 241 case CalcNumber: … … 395 395 } 396 396 397 virtual std::unique_ptr<CalcExpressionNode> createCalcExpression(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const override398 { 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)); 400 400 if (!left) 401 401 return nullptr; 402 std::unique_ptr<CalcExpressionNode> right(m_rightSide->createCalcExpression( style, rootStyle, zoom));402 std::unique_ptr<CalcExpressionNode> right(m_rightSide->createCalcExpression(conversionData)); 403 403 if (!right) 404 404 return nullptr; … … 411 411 } 412 412 413 virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const override414 { 415 const double leftValue = m_leftSide->computeLengthPx(c urrentStyle, rootStyle, multiplier, computingFontSize);416 const double rightValue = m_rightSide->computeLengthPx(c urrentStyle, 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); 417 417 return evaluate(leftValue, rightValue); 418 418 } -
trunk/Source/WebCore/css/CSSCalculationValue.h
r166860 r167937 38 38 namespace WebCore { 39 39 40 class CSSToLengthConversionData; 40 41 class RenderStyle; 41 42 … … 58 59 virtual ~CSSCalcExpressionNode() { } 59 60 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; 61 62 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; 63 64 virtual String customCSSText() const = 0; 64 65 virtual bool equals(const CSSCalcExpressionNode& other) const { return m_category == other.m_category && m_isInteger == other.m_isInteger; } … … 90 91 double doubleValue() const; 91 92 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; 93 94 94 PassRef<CalculationValue> createCalculationValue(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double zoom = 1.0) const;95 PassRef<CalculationValue> createCalculationValue(const CSSToLengthConversionData&) const; 95 96 96 97 String customCSSText() const; … … 113 114 } 114 115 115 inline PassRef<CalculationValue> CSSCalcValue::createCalculationValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom) const116 inline PassRef<CalculationValue> CSSCalcValue::createCalculationValue(const CSSToLengthConversionData& conversionData) const 116 117 { 117 return CalculationValue::create(m_expression->createCalcExpression( style, rootStyle, zoom),118 return CalculationValue::create(m_expression->createCalcExpression(conversionData), 118 119 m_shouldClampToNonNegative ? CalculationRangeNonNegative : CalculationRangeAll); 119 120 } -
trunk/Source/WebCore/css/CSSGradientValue.cpp
r166860 r167937 28 28 29 29 #include "CSSCalculationValue.h" 30 #include "CSSToLengthConversionData.h" 30 31 #include "CSSValueKeywords.h" 31 32 #include "FloatSize.h" … … 129 130 } 130 131 131 void CSSGradientValue::addStops(Gradient* gradient, RenderElement* renderer, const RenderStyle& rootStyle, float maxLengthForRepeat) 132 { 133 RenderStyle& style = renderer->style(); 134 132 void CSSGradientValue::addStops(Gradient* gradient, const CSSToLengthConversionData& conversionData, float maxLengthForRepeat) 133 { 135 134 if (m_gradientType == CSSDeprecatedLinearGradient || m_gradientType == CSSDeprecatedRadialGradient) { 136 135 sortStopsIfNeeded(); … … 182 181 float length; 183 182 if (stop.m_position->isLength()) 184 length = stop.m_position->computeLength<float>( &style, &rootStyle, style.effectiveZoom());183 length = stop.m_position->computeLength<float>(conversionData); 185 184 else { 186 Ref<CalculationValue> calculationValue { stop.m_position->cssCalcValue()->createCalculationValue( &style, &rootStyle, style.effectiveZoom()) };185 Ref<CalculationValue> calculationValue { stop.m_position->cssCalcValue()->createCalculationValue(conversionData) }; 187 186 length = calculationValue->evaluate(gradientLength); 188 187 } … … 393 392 } 394 393 395 static float positionFromValue(CSSPrimitiveValue* value, const RenderStyle& style, const RenderStyle& rootStyle, const FloatSize& size, bool isHorizontal) 396 { 397 float zoomFactor = style.effectiveZoom(); 398 394 static float positionFromValue(CSSPrimitiveValue* value, const CSSToLengthConversionData& conversionData, const FloatSize& size, bool isHorizontal) 395 { 399 396 if (value->isNumber()) 400 return value->getFloatValue() * zoomFactor;397 return value->getFloatValue() * conversionData.zoom(); 401 398 402 399 int edgeDistance = isHorizontal ? size.width() : size.height(); … … 405 402 406 403 if (value->isCalculatedPercentageWithLength()) { 407 Ref<CalculationValue> calculationValue { value->cssCalcValue()->createCalculationValue( &style, &rootStyle, style.effectiveZoom()) };404 Ref<CalculationValue> calculationValue { value->cssCalcValue()->createCalculationValue(conversionData) }; 408 405 return calculationValue->evaluate(edgeDistance); 409 406 } … … 426 423 } 427 424 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 428 FloatPoint CSSGradientValue::computeEndPoint(CSSPrimitiveValue* horizontal, CSSPrimitiveValue* vertical, const CSSToLengthConversionData& conversionData, const FloatSize& size) 432 429 { 433 430 FloatPoint result; 434 431 435 432 if (horizontal) 436 result.setX(positionFromValue(horizontal, style, rootStyle, size, true));433 result.setX(positionFromValue(horizontal, conversionData, size, true)); 437 434 438 435 if (vertical) 439 result.setY(positionFromValue(vertical, style, rootStyle, size, false));436 result.setY(positionFromValue(vertical, conversionData, size, false)); 440 437 441 438 return result; … … 648 645 ASSERT(!size.isEmpty()); 649 646 650 RenderStyle& rootStyle = *renderer->document().documentElement()->renderStyle();647 CSSToLengthConversionData conversionData(&renderer->style(), renderer->document().documentElement()->renderStyle()); 651 648 652 649 FloatPoint firstPoint; … … 658 655 switch (m_gradientType) { 659 656 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); 661 658 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); 663 660 else { 664 661 if (m_firstX) … … 669 666 break; 670 667 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); 672 669 if (m_firstX) 673 670 secondPoint.setX(size.width() - firstPoint.x()); … … 688 685 endPointsFromAngle(angle, size, firstPoint, secondPoint, m_gradientType); 689 686 } 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); 691 688 if (m_firstX) 692 689 firstPoint.setX(size.width() - secondPoint.x()); … … 705 702 706 703 // Now add the stops. 707 addStops(gradient.get(), renderer, rootStyle, 1);704 addStops(gradient.get(), conversionData, 1); 708 705 709 706 return gradient.release(); … … 892 889 } 893 890 894 float CSSRadialGradientValue::resolveRadius(CSSPrimitiveValue* radius, const RenderStyle& style, const RenderStyle& rootStyle, float* widthOrHeight) 895 { 896 float zoomFactor = style.effectiveZoom(); 897 891 float CSSRadialGradientValue::resolveRadius(CSSPrimitiveValue* radius, const CSSToLengthConversionData& conversionData, float* widthOrHeight) 892 { 898 893 float result = 0; 899 894 if (radius->isNumber()) // Can the radius be a percentage? 900 result = radius->getFloatValue() * zoomFactor;895 result = radius->getFloatValue() * conversionData.zoom(); 901 896 else if (widthOrHeight && radius->isPercentage()) 902 897 result = *widthOrHeight * radius->getFloatValue() / 100; 903 898 else 904 result = radius->computeLength<float>( &style, &rootStyle, zoomFactor);899 result = radius->computeLength<float>(conversionData); 905 900 906 901 return result; … … 988 983 ASSERT(!size.isEmpty()); 989 984 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); 993 988 if (!m_firstX) 994 989 firstPoint.setX(size.width() / 2); … … 996 991 firstPoint.setY(size.height() / 2); 997 992 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); 999 994 if (!m_secondX) 1000 995 secondPoint.setX(size.width() / 2); … … 1004 999 float firstRadius = 0; 1005 1000 if (m_firstRadius) 1006 firstRadius = resolveRadius(m_firstRadius.get(), renderer->style(), rootStyle);1001 firstRadius = resolveRadius(m_firstRadius.get(), conversionData); 1007 1002 1008 1003 float secondRadius = 0; 1009 1004 float aspectRatio = 1; // width / height. 1010 1005 if (m_secondRadius) 1011 secondRadius = resolveRadius(m_secondRadius.get(), renderer->style(), rootStyle);1006 secondRadius = resolveRadius(m_secondRadius.get(), conversionData); 1012 1007 else if (m_endHorizontalSize) { 1013 1008 float width = size.width(); 1014 1009 float height = size.height(); 1015 secondRadius = resolveRadius(m_endHorizontalSize.get(), renderer->style(), rootStyle, &width);1010 secondRadius = resolveRadius(m_endHorizontalSize.get(), conversionData, &width); 1016 1011 if (m_endVerticalSize) 1017 aspectRatio = secondRadius / resolveRadius(m_endVerticalSize.get(), renderer->style(), rootStyle, &height);1012 aspectRatio = secondRadius / resolveRadius(m_endVerticalSize.get(), conversionData, &height); 1018 1013 else 1019 1014 aspectRatio = 1; … … 1121 1116 1122 1117 // Now add the stops. 1123 addStops(gradient.get(), renderer, rootStyle, maxExtent);1118 addStops(gradient.get(), conversionData, maxExtent); 1124 1119 1125 1120 return gradient.release(); -
trunk/Source/WebCore/css/CSSGradientValue.h
r166642 r167937 110 110 } 111 111 112 void addStops(Gradient*, RenderElement*, const RenderStyle& rootStyle, float maxLengthForRepeat = 0);112 void addStops(Gradient*, const CSSToLengthConversionData&, float maxLengthForRepeat = 0); 113 113 114 114 // 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&); 116 116 117 117 bool isCacheable() const; … … 219 219 220 220 // 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); 222 222 223 223 // These may be null for non-deprecated gradients. -
trunk/Source/WebCore/css/CSSPrimitiveValue.cpp
r167936 r167937 27 27 #include "CSSParser.h" 28 28 #include "CSSPropertyNames.h" 29 #include "CSSToLengthConversionData.h" 29 30 #include "CSSValueKeywords.h" 30 31 #include "CalculationValue.h" … … 555 556 } 556 557 557 template<> int CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const558 { 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) const563 { 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) const558 template<> int CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const 559 { 560 return roundForImpreciseConversion<int>(computeLengthDouble(conversionData)); 561 } 562 563 template<> unsigned CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const 564 { 565 return roundForImpreciseConversion<unsigned>(computeLengthDouble(conversionData)); 566 } 567 568 template<> Length CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const 568 569 { 569 570 #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); 571 572 #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); 573 574 #endif 574 575 } 575 576 576 template<> short CSSPrimitiveValue::computeLength(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const577 { 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) const582 { 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) const587 { 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) const592 { 593 return computeLengthDouble( style, rootStyle, multiplier, computingFontSize);594 } 595 596 double CSSPrimitiveValue::computeLengthDouble(const RenderStyle* style, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const577 template<> short CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const 578 { 579 return roundForImpreciseConversion<short>(computeLengthDouble(conversionData)); 580 } 581 582 template<> unsigned short CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const 583 { 584 return roundForImpreciseConversion<unsigned short>(computeLengthDouble(conversionData)); 585 } 586 587 template<> float CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const 588 { 589 return static_cast<float>(computeLengthDouble(conversionData)); 590 } 591 592 template<> double CSSPrimitiveValue::computeLength(const CSSToLengthConversionData& conversionData) const 593 { 594 return computeLengthDouble(conversionData); 595 } 596 597 double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& conversionData) const 597 598 { 598 599 if (m_primitiveUnitType == CSS_CALC) 599 600 // 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); 601 602 602 603 double factor; … … 604 605 switch (primitiveType()) { 605 606 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(); 607 609 break; 608 610 case CSS_EXS: 611 ASSERT(conversionData.style()); 609 612 // FIXME: We have a bug right now where the zoom will be applied twice to EX units. 610 613 // We really need to compute EX using fontMetrics for the original specifiedSize and not use 611 614 // 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(); 614 617 else 615 factor = (co mputingFontSize ? style->fontDescription().specifiedSize() : style->fontDescription().computedSize()) / 2.0;618 factor = (conversionData.computingFontSize() ? conversionData.style()->fontDescription().specifiedSize() : conversionData.style()->fontDescription().computedSize()) / 2.0; 616 619 break; 617 620 case CSS_REMS: 618 if ( rootStyle)619 factor = co mputingFontSize ? rootStyle->fontDescription().specifiedSize() : rootStyle->fontDescription().computedSize();621 if (conversionData.rootStyle()) 622 factor = conversionData.computingFontSize() ? conversionData.rootStyle()->fontDescription().specifiedSize() : conversionData.rootStyle()->fontDescription().computedSize(); 620 623 else 621 624 factor = 1.0; 622 625 break; 623 626 case CSS_CHS: 624 factor = style->fontMetrics().zeroWidth(); 627 ASSERT(conversionData.style()); 628 factor = conversionData.style()->fontMetrics().zeroWidth(); 625 629 break; 626 630 case CSS_PX: … … 662 666 // as well as enforcing the implicit "smart minimum." 663 667 double result = getDoubleValue() * factor; 664 if (co mputingFontSize|| isFontRelativeLength())668 if (conversionData.computingFontSize() || isFontRelativeLength()) 665 669 return result; 666 670 667 return result * multiplier;671 return result * conversionData.zoom(); 668 672 } 669 673 -
trunk/Source/WebCore/css/CSSPrimitiveValue.h
r167936 r167937 34 34 35 35 class CSSCalcValue; 36 class CSSToLengthConversionData; 36 37 class Counter; 37 38 class DashboardRegion; … … 266 267 * and some tool to calibrate. 267 268 */ 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; 269 270 270 271 // 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; 272 273 273 274 // use with care!!! … … 379 380 bool getDoubleValueInternal(UnitTypes targetUnitType, double* result) const; 380 381 381 double computeLengthDouble(const RenderStyle* currentStyle, const RenderStyle* rootStyle, float multiplier, bool computingFontSize) const;382 double computeLengthDouble(const CSSToLengthConversionData&) const; 382 383 383 384 union { -
trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h
r167786 r167937 34 34 #include "CSSPrimitiveValue.h" 35 35 #include "CSSReflectionDirection.h" 36 #include "CSSToLengthConversionData.h" 36 37 #include "ColorSpace.h" 37 38 #include "CSSValueKeywords.h" … … 4632 4633 }; 4633 4634 4634 template<int supported> Length CSSPrimitiveValue::convertToLength(const RenderStyle* style, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const4635 { 4636 if ((supported & (FixedIntegerConversion | FixedFloatConversion)) && isFontRelativeLength() && (! style || !rootStyle))4635 template<int supported> Length CSSPrimitiveValue::convertToLength(const CSSToLengthConversionData& conversionData) const 4636 { 4637 if ((supported & (FixedIntegerConversion | FixedFloatConversion)) && isFontRelativeLength() && (!conversionData.style() || !conversionData.rootStyle())) 4637 4638 return Length(Undefined); 4638 4639 if ((supported & FixedIntegerConversion) && isLength()) 4639 return computeLength<Length>( style, rootStyle, multiplier, computingFontSize);4640 return computeLength<Length>(conversionData); 4640 4641 if ((supported & FixedFloatConversion) && isLength()) 4641 return Length(computeLength<double>( style, rootStyle, multiplier), Fixed);4642 return Length(computeLength<double>(conversionData), Fixed); 4642 4643 if ((supported & PercentConversion) && isPercentage()) 4643 4644 return Length(getDoubleValue(), Percent); … … 4647 4648 return Length(Auto); 4648 4649 if ((supported & CalculatedConversion) && isCalculated()) 4649 return Length(cssCalcValue()->createCalculationValue( style, rootStyle, multiplier));4650 return Length(cssCalcValue()->createCalculationValue(conversionData)); 4650 4651 if ((supported & ViewportPercentageConversion) && isViewportPercentageLength()) 4651 4652 return viewportPercentageLength(); -
trunk/Source/WebCore/css/CSSToStyleMap.cpp
r166860 r167937 42 42 namespace WebCore { 43 43 44 CSSToStyleMap::CSSToStyleMap(StyleResolver* resolver) 45 : m_resolver(resolver) 46 { 47 } 48 44 49 RenderStyle* CSSToStyleMap::style() const 45 50 { … … 204 209 } 205 210 206 float zoomFactor = style()->effectiveZoom();207 208 211 Length firstLength; 209 212 Length secondLength; … … 212 215 CSSPrimitiveValue* first = static_cast<CSSPrimitiveValue*>(pair->first()); 213 216 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()); 216 219 } else { 217 firstLength = primitiveValue->convertToLength<AnyConversion>( style(), rootElementStyle(), zoomFactor);220 firstLength = primitiveValue->convertToLength<AnyConversion>(m_resolver->state().cssToLengthConversionData()); 218 221 secondLength = Length(); 219 222 } … … 236 239 if (!value->isPrimitiveValue()) 237 240 return; 238 239 float zoomFactor = style()->effectiveZoom();240 241 241 242 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); … … 248 249 Length length; 249 250 if (primitiveValue->isLength()) 250 length = primitiveValue->computeLength<Length>( style(), rootElementStyle(), zoomFactor);251 length = primitiveValue->computeLength<Length>(m_resolver->state().cssToLengthConversionData()); 251 252 else if (primitiveValue->isPercentage()) 252 253 length = Length(primitiveValue->getDoubleValue(), Percent); 253 254 else if (primitiveValue->isCalculatedPercentageWithLength()) 254 length = Length(primitiveValue->cssCalcValue()->createCalculationValue( style(), rootElementStyle(), zoomFactor));255 length = Length(primitiveValue->cssCalcValue()->createCalculationValue(m_resolver->state().cssToLengthConversionData())); 255 256 else if (primitiveValue->isViewportPercentageLength()) 256 257 length = primitiveValue->viewportPercentageLength(); … … 272 273 if (!value->isPrimitiveValue()) 273 274 return; 274 275 float zoomFactor = style()->effectiveZoom();276 275 277 276 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); … … 284 283 Length length; 285 284 if (primitiveValue->isLength()) 286 length = primitiveValue->computeLength<Length>( style(), rootElementStyle(), zoomFactor);285 length = primitiveValue->computeLength<Length>(m_resolver->state().cssToLengthConversionData()); 287 286 else if (primitiveValue->isPercentage()) 288 287 length = Length(primitiveValue->getDoubleValue(), Percent); 289 288 else if (primitiveValue->isCalculatedPercentageWithLength()) 290 length = Length(primitiveValue->cssCalcValue()->createCalculationValue( style(), rootElementStyle(), zoomFactor));289 length = Length(primitiveValue->cssCalcValue()->createCalculationValue(m_resolver->state().cssToLengthConversionData())); 291 290 else if (primitiveValue->isViewportPercentageLength()) 292 291 length = primitiveValue->viewportPercentageLength(); … … 634 633 635 634 // 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(); 637 636 638 637 // Retrieve the primitive value. … … 647 646 box.m_top = Length(slices->top()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); 648 647 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); 650 649 651 650 if (slices->right()->isNumber()) … … 654 653 box.m_right = Length(slices->right()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); 655 654 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); 657 656 658 657 if (slices->bottom()->isNumber()) … … 661 660 box.m_bottom = Length(slices->bottom()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); 662 661 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); 664 663 665 664 if (slices->left()->isNumber()) … … 668 667 box.m_left = Length(slices->left()->getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent); 669 668 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); 671 670 672 671 return box; -
trunk/Source/WebCore/css/CSSToStyleMap.h
r166860 r167937 44 44 45 45 public: 46 CSSToStyleMap(StyleResolver* resolver) : m_resolver(resolver) { }46 CSSToStyleMap(StyleResolver*); 47 47 48 48 void mapFillAttachment(CSSPropertyID, FillLayer*, CSSValue*); -
trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp
r167518 r167937 221 221 setValue(styleResolver->style(), *primitiveValue); 222 222 else if (valueType == ComputeLength) 223 setValue(styleResolver->style(), primitiveValue->computeLength<T>(styleResolver->st yle(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()));223 setValue(styleResolver->style(), primitiveValue->computeLength<T>(styleResolver->state().cssToLengthConversionData())); 224 224 } 225 225 … … 231 231 static Length convertToLength(StyleResolver* styleResolver, CSSPrimitiveValue* value) 232 232 { 233 return value->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | AutoConversion>(styleResolver->st yle(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());233 return value->convertToLength<FixedIntegerConversion | PercentConversion | FractionConversion | AutoConversion>(styleResolver->state().cssToLengthConversionData()); 234 234 } 235 235 public: … … 388 388 setValue(styleResolver->style(), Length()); 389 389 else if (primitiveValue->isLength()) { 390 Length length = primitiveValue->computeLength<Length>(styleResolver->st yle(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());390 Length length = primitiveValue->computeLength<Length>(styleResolver->state().cssToLengthConversionData()); 391 391 length.setHasQuirk(primitiveValue->isQuirkValue()); 392 392 setValue(styleResolver->style(), length); … … 394 394 setValue(styleResolver->style(), Length(primitiveValue->getDoubleValue(), Percent)); 395 395 else if (primitiveValue->isCalculatedPercentageWithLength()) 396 setValue(styleResolver->style(), Length(primitiveValue->cssCalcValue()->createCalculationValue(styleResolver->st yle(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom())));396 setValue(styleResolver->style(), Length(primitiveValue->cssCalcValue()->createCalculationValue(styleResolver->state().cssToLengthConversionData()))); 397 397 else if (primitiveValue->isViewportPercentageLength()) 398 398 setValue(styleResolver->style(), primitiveValue->viewportPercentageLength()); … … 443 443 return; 444 444 445 CSSToLengthConversionData conversionData = styleResolver->state().cssToLengthConversionData(); 445 446 Length radiusWidth; 446 447 if (pair->first()->isPercentage()) … … 449 450 radiusWidth = Length(styleResolver->viewportPercentageValue(*pair->first(), pair->first()->getIntValue()), Fixed); 450 451 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)); 452 453 else 453 radiusWidth = pair->first()->computeLength<Length>( styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());454 radiusWidth = pair->first()->computeLength<Length>(conversionData); 454 455 455 456 Length radiusHeight; … … 459 460 radiusHeight = Length(styleResolver->viewportPercentageValue(*pair->second(), pair->second()->getIntValue()), Fixed); 460 461 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)); 462 463 else 463 radiusHeight = pair->second()->computeLength<Length>( styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());464 radiusHeight = pair->second()->computeLength<Length>(conversionData); 464 465 465 466 if (radiusWidth.isNegative() || radiusHeight.isNegative()) … … 612 613 length = 5; 613 614 } 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(); 615 616 616 617 // Any original result that was >= 1 should not be allowed to fall below 1. 617 618 // 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)); 621 622 if (originalLength >= 1.0) 622 623 length = 1.0; … … 869 870 || !(primitiveValue->isPercentage() || primitiveValue->isFontRelativeLength())); 870 871 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)); 872 873 else if (primitiveValue->isPercentage()) 873 874 size = (primitiveValue->getFloatValue() * parentSize) / 100.0f; 874 875 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)) }; 876 877 size = calculationValue->evaluate(parentSize); 877 878 } else if (primitiveValue->isViewportPercentageLength()) … … 1293 1294 } 1294 1295 1296 static 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 1295 1304 class ApplyPropertyTextDecorationSkip { 1296 1305 public: … … 1337 1346 } 1338 1347 } else { 1339 Length marqueeLength = styleResolver->convertToIntLength(primitiveValue, styleResolver->st yle(), styleResolver->rootElementStyle());1348 Length marqueeLength = styleResolver->convertToIntLength(primitiveValue, styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f)); 1340 1349 if (!marqueeLength.isUndefined()) 1341 1350 styleResolver->style()->setMarqueeIncrement(marqueeLength); … … 1443 1452 lineHeight = RenderStyle::initialLineHeight(); 1444 1453 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)); 1449 1455 } else if (primitiveValue->isPercentage()) { 1450 1456 // FIXME: percentage should not be restricted to an integer here. … … 1481 1487 lineHeight = RenderStyle::initialLineHeight(); 1482 1488 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)); 1489 1490 if (styleResolver->style()->textSizeAdjust().isPercentage()) 1490 1491 lineHeight = Length(lineHeight.value() * styleResolver->style()->textSizeAdjust().multiplier(), Fixed); … … 1538 1539 wordSpacing = RenderStyle::initialWordSpacing(); 1539 1540 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)); 1544 1542 } else if (primitiveValue->isPercentage()) 1545 1543 wordSpacing = Length(primitiveValue->getDoubleValue(), Percent); … … 1564 1562 { 1565 1563 Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(mm, CSSPrimitiveValue::CSS_MM)); 1566 return value.get().computeLength<Length>( 0, 0);1564 return value.get().computeLength<Length>(CSSToLengthConversionData()); 1567 1565 } 1568 1566 static Length inchLength(double inch) 1569 1567 { 1570 1568 Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(inch, CSSPrimitiveValue::CSS_IN)); 1571 return value.get().computeLength<Length>( 0, 0);1569 return value.get().computeLength<Length>(CSSToLengthConversionData()); 1572 1570 } 1573 1571 static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height) … … 1665 1663 if (!second->isLength()) 1666 1664 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); 1669 1668 } else { 1670 1669 // <page-size> <orientation> … … 1684 1683 // <length> 1685 1684 pageSizeType = PAGE_SIZE_RESOLVED; 1686 width = height = primitiveValue->computeLength<Length>(styleResolver->st yle(), styleResolver->rootElementStyle());1685 width = height = primitiveValue->computeLength<Length>(styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f)); 1687 1686 } else { 1688 1687 switch (primitiveValue->getValueID()) { … … 1962 1961 return styleResolver->style()->setVerticalAlign(*primitiveValue); 1963 1962 1964 styleResolver->style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(styleResolver->st yle(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom()));1963 styleResolver->style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(styleResolver->state().cssToLengthConversionData())); 1965 1964 } 1966 1965 … … 2140 2139 auto& primitiveValue = toCSSPrimitiveValue(*valueList.itemWithoutBoundsCheck(i)); 2141 2140 if (primitiveValue.isShape() && !operation) 2142 operation = ShapeClipPathOperation::create(basicShapeForValue(styleResolver->st yle(), styleResolver->rootElementStyle(), primitiveValue.getShapeValue()));2141 operation = ShapeClipPathOperation::create(basicShapeForValue(styleResolver->state().cssToLengthConversionData(), primitiveValue.getShapeValue())); 2143 2142 else if ((primitiveValue.getValueID() == CSSValueContentBox 2144 2143 || primitiveValue.getValueID() == CSSValueBorderBox … … 2189 2188 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->itemWithoutBoundsCheck(i)); 2190 2189 if (primitiveValue->isShape()) 2191 shape = basicShapeForValue(styleResolver->st yle(), styleResolver->rootElementStyle(), primitiveValue->getShapeValue());2190 shape = basicShapeForValue(styleResolver->state().cssToLengthConversionData(), primitiveValue->getShapeValue()); 2192 2191 else if (primitiveValue->getValueID() == CSSValueContentBox 2193 2192 || primitiveValue->getValueID() == CSSValueBorderBox … … 2302 2301 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(item); 2303 2302 if (!primitiveValue->getValueID()) 2304 lengthOrPercentageValue = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(styleResolver->st yle(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom());2303 lengthOrPercentageValue = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | ViewportPercentageConversion>(styleResolver->state().cssToLengthConversionData()); 2305 2304 #if ENABLE(CSS3_TEXT) 2306 2305 else if (primitiveValue->getValueID() == CSSValueWebkitEachLine) -
trunk/Source/WebCore/css/MediaQueryEvaluator.cpp
r165676 r167937 32 32 #include "CSSAspectRatioValue.h" 33 33 #include "CSSPrimitiveValue.h" 34 #include "CSSToLengthConversionData.h" 34 35 #include "CSSValueKeywords.h" 35 36 #include "CSSValueList.h" … … 70 71 enum MediaFeaturePrefix { MinPrefix, MaxPrefix, NoPrefix }; 71 72 72 typedef bool (*EvalFunc)(CSSValue*, RenderStyle*, Frame*, MediaFeaturePrefix);73 typedef bool (*EvalFunc)(CSSValue*, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix); 73 74 typedef HashMap<AtomicStringImpl*, EvalFunc> FunctionMap; 74 75 static FunctionMap* gFunctionMap; … … 204 205 } 205 206 206 static bool colorMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)207 static bool colorMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix op) 207 208 { 208 209 int bitsPerComponent = screenDepthPerComponent(frame->page()->mainFrame().view()); … … 214 215 } 215 216 216 static bool color_indexMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op)217 static bool color_indexMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix op) 217 218 { 218 219 // FIXME: It's unknown how to retrieve the information if the display mode is indexed … … 225 226 } 226 227 227 static bool monochromeMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)228 static bool monochromeMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix op) 228 229 { 229 230 if (!screenIsMonochrome(frame->page()->mainFrame().view())) { … … 235 236 } 236 237 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 241 static bool orientationMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix) 241 242 { 242 243 FrameView* view = frame->view(); … … 257 258 } 258 259 259 static bool aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)260 static bool aspect_ratioMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix op) 260 261 { 261 262 FrameView* view = frame->view(); … … 271 272 } 272 273 273 static bool device_aspect_ratioMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)274 static bool device_aspect_ratioMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix op) 274 275 { 275 276 if (value) { … … 315 316 } 316 317 317 static bool device_pixel_ratioMediaFeatureEval(CSSValue *value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)318 static bool device_pixel_ratioMediaFeatureEval(CSSValue *value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix op) 318 319 { 319 320 return (!value || toCSSPrimitiveValue(value)->isNumber()) && evalResolution(value, frame, op); 320 321 } 321 322 322 static bool resolutionMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)323 static bool resolutionMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix op) 323 324 { 324 325 #if ENABLE(RESOLUTION_MEDIA_QUERY) … … 332 333 } 333 334 334 static bool gridMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op)335 static bool gridMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix op) 335 336 { 336 337 // if output device is bitmap, grid: 0 == true … … 342 343 } 343 344 344 static bool computeLength(CSSValue* value, bool strict, RenderStyle* style, RenderStyle* rootStyle, int& result)345 static bool computeLength(CSSValue* value, bool strict, const CSSToLengthConversionData& conversionData, int& result) 345 346 { 346 347 if (!value->isPrimitiveValue()) … … 355 356 356 357 if (primitiveValue->isLength()) { 357 result = primitiveValue->computeLength<int>( style, rootStyle);358 result = primitiveValue->computeLength<int>(conversionData); 358 359 return true; 359 360 } … … 362 363 } 363 364 364 static bool device_heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)365 static bool device_heightMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix op) 365 366 { 366 367 if (value) { 367 368 FloatRect sg = screenRect(frame->page()->mainFrame().view()); 368 RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();369 369 int length; 370 370 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); 372 372 } 373 373 // ({,min-,max-}device-height) … … 376 376 } 377 377 378 static bool device_widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)378 static bool device_widthMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix op) 379 379 { 380 380 if (value) { 381 381 FloatRect sg = screenRect(frame->page()->mainFrame().view()); 382 RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();383 382 int length; 384 383 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); 386 385 } 387 386 // ({,min-,max-}device-width) … … 390 389 } 391 390 392 static bool heightMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)391 static bool heightMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix op) 393 392 { 394 393 FrameView* view = frame->view(); … … 400 399 if (RenderView* renderView = frame->document()->renderView()) 401 400 height = adjustForAbsoluteZoom(height, *renderView); 402 RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();403 401 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); 405 403 } 406 404 … … 408 406 } 409 407 410 static bool widthMediaFeatureEval(CSSValue* value, RenderStyle* style, Frame* frame, MediaFeaturePrefix op)408 static bool widthMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix op) 411 409 { 412 410 FrameView* view = frame->view(); … … 418 416 if (RenderView* renderView = frame->document()->renderView()) 419 417 width = adjustForAbsoluteZoom(width, *renderView); 420 RenderStyle* rootStyle = frame->document()->documentElement()->renderStyle();421 418 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); 423 420 } 424 421 … … 428 425 // rest of the functions are trampolines which set the prefix according to the media feature expression used 429 426 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)427 static bool min_colorMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 428 { 429 return colorMediaFeatureEval(value, conversionData, frame, MinPrefix); 430 } 431 432 static bool max_colorMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 433 { 434 return colorMediaFeatureEval(value, conversionData, frame, MaxPrefix); 435 } 436 437 static bool min_color_indexMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 438 { 439 return color_indexMediaFeatureEval(value, conversionData, frame, MinPrefix); 440 } 441 442 static bool max_color_indexMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 443 { 444 return color_indexMediaFeatureEval(value, conversionData, frame, MaxPrefix); 445 } 446 447 static bool min_monochromeMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 448 { 449 return monochromeMediaFeatureEval(value, conversionData, frame, MinPrefix); 450 } 451 452 static bool max_monochromeMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 453 { 454 return monochromeMediaFeatureEval(value, conversionData, frame, MaxPrefix); 455 } 456 457 static bool min_aspect_ratioMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 458 { 459 return aspect_ratioMediaFeatureEval(value, conversionData, frame, MinPrefix); 460 } 461 462 static bool max_aspect_ratioMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 463 { 464 return aspect_ratioMediaFeatureEval(value, conversionData, frame, MaxPrefix); 465 } 466 467 static 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 472 static 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 477 static 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 482 static 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 487 static bool min_heightMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 488 { 489 return heightMediaFeatureEval(value, conversionData, frame, MinPrefix); 490 } 491 492 static bool max_heightMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 493 { 494 return heightMediaFeatureEval(value, conversionData, frame, MaxPrefix); 495 } 496 497 static bool min_widthMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 498 { 499 return widthMediaFeatureEval(value, conversionData, frame, MinPrefix); 500 } 501 502 static bool max_widthMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 503 { 504 return widthMediaFeatureEval(value, conversionData, frame, MaxPrefix); 505 } 506 507 static bool min_device_heightMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 508 { 509 return device_heightMediaFeatureEval(value, conversionData, frame, MinPrefix); 510 } 511 512 static bool max_device_heightMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 513 { 514 return device_heightMediaFeatureEval(value, conversionData, frame, MaxPrefix); 515 } 516 517 static bool min_device_widthMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 518 { 519 return device_widthMediaFeatureEval(value, conversionData, frame, MinPrefix); 520 } 521 522 static bool max_device_widthMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 523 { 524 return device_widthMediaFeatureEval(value, conversionData, frame, MaxPrefix); 525 } 526 527 static bool min_resolutionMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 528 { 529 return resolutionMediaFeatureEval(value, conversionData, frame, MinPrefix); 530 } 531 532 static bool max_resolutionMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData& conversionData, Frame* frame, MediaFeaturePrefix) 533 { 534 return resolutionMediaFeatureEval(value, conversionData, frame, MaxPrefix); 535 } 536 537 static bool animationMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix op) 541 538 { 542 539 if (value) { … … 547 544 } 548 545 549 static bool transitionMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op)546 static bool transitionMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix op) 550 547 { 551 548 if (value) { … … 556 553 } 557 554 558 static bool transform_2dMediaFeatureEval(CSSValue* value, RenderStyle*, Frame*, MediaFeaturePrefix op)555 static bool transform_2dMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix op) 559 556 { 560 557 if (value) { … … 565 562 } 566 563 567 static bool transform_3dMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)564 static bool transform_3dMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix op) 568 565 { 569 566 bool returnValueIfNoParameter; … … 591 588 592 589 #if ENABLE(VIEW_MODE_CSS_MEDIA) 593 static bool view_modeMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix op)590 static bool view_modeMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix op) 594 591 { 595 592 UNUSED_PARAM(op); … … 636 633 } 637 634 638 static bool video_playable_inlineMediaFeatureEval(CSSValue*, RenderStyle*, Frame* frame, MediaFeaturePrefix)635 static bool video_playable_inlineMediaFeatureEval(CSSValue*, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix) 639 636 { 640 637 return !isRunningOnIPhoneOrIPod() || frame->settings().mediaPlaybackAllowsInline(); … … 658 655 } 659 656 660 static bool hoverMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix)657 static bool hoverMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix) 661 658 { 662 659 PointerDeviceType pointer = leastCapablePrimaryPointerDeviceType(frame); … … 679 676 } 680 677 681 static bool pointerMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* frame, MediaFeaturePrefix)678 static bool pointerMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix) 682 679 { 683 680 PointerDeviceType pointer = leastCapablePrimaryPointerDeviceType(frame); … … 728 725 // used 729 726 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 } 732 731 733 732 return false; -
trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp
r165676 r167937 594 594 return; 595 595 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; 599 599 Color color; 600 600 if (item->color) -
trunk/Source/WebCore/css/StyleResolver.cpp
r167877 r167937 244 244 m_filtersWithPendingSVGDocuments.clear(); 245 245 #endif 246 m_cssToLengthConversionData = CSSToLengthConversionData(nullptr, nullptr); 246 247 } 247 248 … … 423 424 m_pendingImageProperties.clear(); 424 425 m_fontDirty = false; 426 427 m_cssToLengthConversionData = CSSToLengthConversionData(m_style.get(), m_rootElementStyle); 425 428 } 426 429 … … 1449 1452 // this is mostly boring stuff on how to apply a certain rule to the renderstyle... 1450 1453 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);1454 Length StyleResolver::convertToIntLength(const CSSPrimitiveValue* primitiveValue, const CSSToLengthConversionData& conversionData) 1455 { 1456 return primitiveValue ? primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(conversionData) : Length(Undefined); 1457 } 1458 1459 Length StyleResolver::convertToFloatLength(const CSSPrimitiveValue* primitiveValue, const CSSToLengthConversionData& conversionData) 1460 { 1461 return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(conversionData) : Length(Undefined); 1459 1462 } 1460 1463 … … 1857 1860 } 1858 1861 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()); 1860 1863 if (workingLength.length().isUndefined()) 1861 1864 return false; … … 2022 2025 2023 2026 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimitiveValue(value) : 0; 2024 2025 float zoomFactor = state.style()->effectiveZoom();2026 2027 2027 2028 // What follows is a list that maps the CSS properties into their corresponding front-end … … 2302 2303 continue; 2303 2304 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()); 2305 2306 if (item->x->isViewportPercentageLength()) 2306 2307 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()); 2308 2309 if (item->y->isViewportPercentageLength()) 2309 2310 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; 2311 2312 if (item->blur && item->blur->isViewportPercentageLength()) 2312 2313 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; 2314 2315 if (item->spread && item->spread->isViewportPercentageLength()) 2315 2316 spread = viewportPercentageValue(*item->spread, spread); … … 2343 2344 reflection->setDirection(*reflectValue->direction()); 2344 2345 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())); 2346 2347 NinePieceImage mask; 2347 2348 mask.setMaskDefaults(); … … 2404 2405 DashboardRegion* first = region; 2405 2406 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)); 2410 2411 2411 2412 if (top.isUndefined()) … … 2443 2444 result *= 5; 2444 2445 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()); 2446 2447 break; 2447 2448 } 2448 2449 default: 2449 width = primitiveValue->computeLength<float>(state. style(), state.rootElementStyle(), zoomFactor);2450 width = primitiveValue->computeLength<float>(state.cssToLengthConversionData()); 2450 2451 break; 2451 2452 } … … 2456 2457 HANDLE_INHERIT_AND_INITIAL(transform, Transform); 2457 2458 TransformOperations operations; 2458 transformsForValue( state.style(), state.rootElementStyle(), value, operations);2459 transformsForValue(value, state.cssToLengthConversionData(), operations); 2459 2460 state.style()->setTransform(operations); 2460 2461 return; … … 2473 2474 float perspectiveValue; 2474 2475 if (primitiveValue->isLength()) 2475 perspectiveValue = primitiveValue->computeLength<float>(state. style(), state.rootElementStyle(), zoomFactor);2476 perspectiveValue = primitiveValue->computeLength<float>(state.cssToLengthConversionData()); 2476 2477 else if (primitiveValue->isNumber()) { 2477 2478 // For backward compatibility, treat valueless numbers as px. 2478 2479 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()); 2480 2481 } else 2481 2482 return; … … 3315 3316 { 3316 3317 State& state = m_state; 3317 RenderStyle* style = state.style();3318 RenderStyle* rootStyle = state.rootElementStyle();3319 3318 ASSERT(outOperations.isEmpty()); 3320 3319 … … 3331 3330 return false; 3332 3331 3333 float zoomFactor = style ? style->effectiveZoom() : 1;3334 3332 FilterOperations operations; 3335 3333 for (CSSValueListIterator i = inValue; i.hasMore(); i.advance()) { … … 3417 3415 Length stdDeviation = Length(0, Fixed); 3418 3416 if (filterValue->length() >= 1) 3419 stdDeviation = convertToFloatLength(firstValue, st yle, rootStyle, zoomFactor);3417 stdDeviation = convertToFloatLength(firstValue, state.cssToLengthConversionData()); 3420 3418 if (stdDeviation.isUndefined()) 3421 3419 return false; … … 3433 3431 3434 3432 CSSShadowValue* item = toCSSShadowValue(cssValue); 3435 int x = item->x->computeLength<int>(st yle, rootStyle, zoomFactor);3433 int x = item->x->computeLength<int>(state.cssToLengthConversionData()); 3436 3434 if (item->x->isViewportPercentageLength()) 3437 3435 x = viewportPercentageValue(*item->x, x); 3438 int y = item->y->computeLength<int>(st yle, rootStyle, zoomFactor);3436 int y = item->y->computeLength<int>(state.cssToLengthConversionData()); 3439 3437 if (item->y->isViewportPercentageLength()) 3440 3438 y = viewportPercentageValue(*item->y, y); 3441 3439 IntPoint location(x, y); 3442 int blur = item->blur ? item->blur->computeLength<int>(st yle, rootStyle, zoomFactor) : 0;3440 int blur = item->blur ? item->blur->computeLength<int>(state.cssToLengthConversionData()) : 0; 3443 3441 if (item->blur && item->blur->isViewportPercentageLength()) 3444 3442 blur = viewportPercentageValue(*item->blur, blur); -
trunk/Source/WebCore/css/StyleResolver.h
r166299 r167937 23 23 #define StyleResolver_h 24 24 25 #include "CSSToLengthConversionData.h" 25 26 #include "CSSToStyleMap.h" 26 27 #include "CSSValueList.h" … … 355 356 Element* element() const { return m_element; } 356 357 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 } 358 363 RenderStyle* style() const { return m_style.get(); } 359 364 PassRef<RenderStyle> takeStyle() { return m_style.releaseNonNull(); } … … 397 402 398 403 bool useSVGZoomRules() const { return m_element && m_element->isSVGElement(); } 404 405 CSSToLengthConversionData cssToLengthConversionData() const { return m_cssToLengthConversionData; } 399 406 400 407 private: … … 429 436 FillLayer m_backgroundData; 430 437 Color m_backgroundColor; 438 439 CSSToLengthConversionData m_cssToLengthConversionData; 431 440 }; 432 441 … … 446 455 bool applyPropertyToVisitedLinkStyle() const { return m_state.applyPropertyToVisitedLinkStyle(); } 447 456 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&); 450 459 451 460 CSSToStyleMap* styleMap() { return &m_styleMap; } -
trunk/Source/WebCore/css/TransformFunctions.cpp
r156705 r167937 77 77 } 78 78 79 static Length convertToFloatLength(const CSSPrimitiveValue* primitiveValue, const RenderStyle* style, const RenderStyle* rootStyle, double multiplier)79 static Length convertToFloatLength(const CSSPrimitiveValue* primitiveValue, const CSSToLengthConversionData& conversionData) 80 80 { 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); 82 82 } 83 83 84 bool transformsForValue( const RenderStyle* style, const RenderStyle* rootStyle, CSSValue* value, TransformOperations& outOperations)84 bool transformsForValue(CSSValue* value, const CSSToLengthConversionData& conversionData, TransformOperations& outOperations) 85 85 { 86 86 if (!value || !value->isValueList()) { … … 89 89 } 90 90 91 float zoomFactor = style ? style->effectiveZoom() : 1;92 91 TransformOperations operations; 93 92 for (CSSValueListIterator i = value; i.hasMore(); i.advance()) { … … 166 165 Length ty = Length(0, Fixed); 167 166 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); 171 170 if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) { 172 171 if (transformValue->length() > 1) { 173 172 CSSPrimitiveValue* secondValue = toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(1)); 174 ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor);173 ty = convertToFloatLength(secondValue, conversionData); 175 174 } 176 175 } … … 189 188 Length tz = Length(0, Fixed); 190 189 if (transformValue->operationType() == WebKitCSSTransformValue::TranslateZTransformOperation) 191 tz = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);190 tz = convertToFloatLength(firstValue, conversionData); 192 191 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); 196 195 if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) { 197 196 if (transformValue->length() > 2) { 198 197 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); 204 203 } 205 204 } … … 274 273 double c = toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(2))->getDoubleValue(); 275 274 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(); 278 277 operations.operations().append(MatrixTransformOperation::create(a, b, c, d, e, f)); 279 278 break; … … 294 293 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(10))->getDoubleValue(), 295 294 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(), 298 297 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(14))->getDoubleValue(), 299 298 toCSSPrimitiveValue(transformValue->itemWithoutBoundsCheck(15))->getDoubleValue()); … … 304 303 Length p = Length(0, Fixed); 305 304 if (firstValue->isLength()) 306 p = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);305 p = convertToFloatLength(firstValue, conversionData); 307 306 else { 308 307 // This is a quirk that should go away when 3d transforms are finalized. -
trunk/Source/WebCore/css/TransformFunctions.h
r148753 r167937 35 35 namespace WebCore { 36 36 37 class CSSToLengthConversionData; 37 38 class CSSValue; 38 39 class RenderStyle; 39 40 class WebKitCSSTransformValue; 40 41 41 bool transformsForValue( const RenderStyle*, const RenderStyle* rootStyle, CSSValue*, TransformOperations&);42 bool transformsForValue(CSSValue*, const CSSToLengthConversionData&, TransformOperations&); 42 43 43 44 } -
trunk/Source/WebCore/css/WebKitCSSMatrix.cpp
r159856 r167937 29 29 #include "CSSParser.h" 30 30 #include "CSSPropertyNames.h" 31 #include "CSSToLengthConversionData.h" 31 32 #include "CSSValueKeywords.h" 32 33 #include "ExceptionCode.h" … … 67 68 68 69 TransformOperations operations; 69 if (!transformsForValue( 0, 0, value.get(), operations)) {70 if (!transformsForValue(value.get(), CSSToLengthConversionData(), operations)) { 70 71 ec = SYNTAX_ERR; 71 72 return; -
trunk/Source/WebCore/rendering/RenderThemeIOS.mm
r167771 r167937 527 527 Document& document = element->document(); 528 528 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())); 530 530 style->setPaddingBox(LengthBox(0, pixels, 0, pixels)); 531 531 } … … 935 935 // Since the element might not be in a document, just pass nullptr for the root element style. 936 936 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)); 938 938 style->setPaddingBox(LengthBox(0, pixels, 0, pixels)); 939 939
Note: See TracChangeset
for help on using the changeset viewer.