Changeset 209758 in webkit
- Timestamp:
- Dec 13, 2016, 9:39:27 AM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r209757 r209758 1 2016-12-13 Dave Hyatt <hyatt@apple.com> 2 3 [CSS Parser] Rename CSSPrimitiveValue::UnitTypes to CSSPrimitiveValue::UnitType 4 https://bugs.webkit.org/show_bug.cgi?id=165776 5 6 Reviewed by Zalan Bujtas. 7 8 * css/CSSCalculationValue.cpp: 9 (WebCore::unitCategory): 10 (WebCore::hasDoubleValue): 11 (WebCore::determineCategory): 12 (WebCore::CSSCalcExpressionNodeParser::parseValue): 13 * css/CSSCalculationValue.h: 14 * css/CSSPrimitiveValue.cpp: 15 (WebCore::isValidCSSUnitTypeForDoubleConversion): 16 (WebCore::isStringType): 17 (WebCore::CSSPrimitiveValue::unitCategory): 18 (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): 19 (WebCore::CSSPrimitiveValue::cleanup): 20 (WebCore::CSSPrimitiveValue::computeLengthDouble): 21 (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble): 22 (WebCore::CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor): 23 (WebCore::CSSPrimitiveValue::getFloatValue): 24 (WebCore::CSSPrimitiveValue::doubleValue): 25 (WebCore::CSSPrimitiveValue::canonicalUnitTypeForCategory): 26 (WebCore::CSSPrimitiveValue::doubleValueInternal): 27 (WebCore::CSSPrimitiveValue::cloneForCSSOM): 28 * css/CSSPrimitiveValue.h: 29 (WebCore::CSSPrimitiveValue::isFontRelativeLength): 30 (WebCore::CSSPrimitiveValue::isLength): 31 (WebCore::CSSPrimitiveValue::isResolution): 32 (WebCore::CSSPrimitiveValue::createAllowingMarginQuirk): 33 * css/CSSValue.h: 34 * css/CSSValuePool.cpp: 35 (WebCore::CSSValuePool::createValue): 36 * css/CSSValuePool.h: 37 (WebCore::CSSValuePool::createValue): 38 * css/MediaQueryExp.cpp: 39 (WebCore::featureWithValidDensity): 40 (WebCore::MediaQueryExpression::MediaQueryExpression): 41 * css/parser/CSSParserFastPaths.cpp: 42 (WebCore::parseSimpleLength): 43 (WebCore::parseSimpleLengthValue): 44 (WebCore::parseColorIntOrPercentage): 45 (WebCore::fastParseColorInternal): 46 (WebCore::parseTransformTranslateArguments): 47 (WebCore::parseTransformNumberArguments): 48 * css/parser/CSSParserToken.cpp: 49 (WebCore::cssPrimitiveValueUnitFromTrie): 50 (WebCore::stringToUnitType): 51 (WebCore::CSSParserToken::CSSParserToken): 52 (WebCore::CSSParserToken::convertToPercentage): 53 * css/parser/CSSParserToken.h: 54 (WebCore::CSSParserToken::unitType): 55 * css/parser/CSSPropertyParser.cpp: 56 (WebCore::CSSPropertyParser::consumeTransformOrigin): 57 (WebCore::consumeCounter): 58 (WebCore::consumeAnimationName): 59 (WebCore::consumePerspective): 60 (WebCore::consumePositionLonghand): 61 (WebCore::consumeCounterContent): 62 (WebCore::consumeReflect): 63 (WebCore::consumeGridBreadth): 64 (WebCore::CSSPropertyParser::consumeFlex): 65 * css/parser/CSSPropertyParserHelpers.cpp: 66 (WebCore::CSSPropertyParserHelpers::CalcParser::consumeNumber): 67 (WebCore::CSSPropertyParserHelpers::consumeInteger): 68 (WebCore::CSSPropertyParserHelpers::consumeLength): 69 (WebCore::CSSPropertyParserHelpers::consumePercent): 70 (WebCore::CSSPropertyParserHelpers::consumeAngle): 71 (WebCore::CSSPropertyParserHelpers::consumeTime): 72 (WebCore::CSSPropertyParserHelpers::consumeCustomIdent): 73 (WebCore::CSSPropertyParserHelpers::consumeString): 74 (WebCore::CSSPropertyParserHelpers::consumeUrl): 75 (WebCore::CSSPropertyParserHelpers::consumeDeprecatedGradientPoint): 76 (WebCore::CSSPropertyParserHelpers::consumeDeprecatedGradientColorStop): 77 (WebCore::CSSPropertyParserHelpers::consumeCrossFade): 78 (WebCore::CSSPropertyParserHelpers::consumeImageSet): 79 (WebCore::CSSPropertyParserHelpers::consumeFilterFunction): 80 * css/parser/MediaQueryParser.cpp: 81 (WebCore::MediaQueryParser::readFeatureValue): 82 * css/parser/SizesAttributeParser.cpp: 83 (WebCore::SizesAttributeParser::computeLength): 84 * css/parser/SizesAttributeParser.h: 85 * dom/StyledElement.cpp: 86 (WebCore::StyledElement::setInlineStyleProperty): 87 (WebCore::StyledElement::addPropertyToPresentationAttributeStyle): 88 * dom/StyledElement.h: 89 * svg/SVGLengthValue.cpp: 90 (WebCore::SVGLengthValue::toCSSPrimitiveValue): 91 1 92 2016-12-13 Eric Carlson <eric.carlson@apple.com> 2 93 -
trunk/Source/WebCore/css/CSSCalculationValue.cpp
r209666 r209758 53 53 static RefPtr<CSSCalcExpressionNode> createCSS(const Length&, const RenderStyle&); 54 54 55 static CalculationCategory unitCategory(CSSPrimitiveValue::UnitType stype)55 static CalculationCategory unitCategory(CSSPrimitiveValue::UnitType type) 56 56 { 57 57 switch (type) { … … 91 91 } 92 92 93 static bool hasDoubleValue(CSSPrimitiveValue::UnitType stype)93 static bool hasDoubleValue(CSSPrimitiveValue::UnitType type) 94 94 { 95 95 switch (type) { … … 202 202 } 203 203 204 static RefPtr<CSSCalcPrimitiveValue> create(double value, CSSPrimitiveValue::UnitType stype, bool isInteger)204 static RefPtr<CSSCalcPrimitiveValue> create(double value, CSSPrimitiveValue::UnitType type, bool isInteger) 205 205 { 206 206 if (std::isnan(value) || std::isinf(value)) … … 282 282 283 283 Type type() const final { return CssCalcPrimitiveValue; } 284 CSSPrimitiveValue::UnitType sprimitiveType() const final285 { 286 return CSSPrimitiveValue::UnitType s(m_value->primitiveType());284 CSSPrimitiveValue::UnitType primitiveType() const final 285 { 286 return CSSPrimitiveValue::UnitType(m_value->primitiveType()); 287 287 } 288 288 289 289 private: 290 290 explicit CSSCalcPrimitiveValue(Ref<CSSPrimitiveValue>&& value, bool isInteger) 291 : CSSCalcExpressionNode(unitCategory((CSSPrimitiveValue::UnitType s)value->primitiveType()), isInteger)291 : CSSCalcExpressionNode(unitCategory((CSSPrimitiveValue::UnitType)value->primitiveType()), isInteger) 292 292 , m_value(WTFMove(value)) 293 293 { … … 369 369 // Simplify numbers. 370 370 if (leftCategory == CalcNumber && rightCategory == CalcNumber) { 371 CSSPrimitiveValue::UnitType sevaluationType = CSSPrimitiveValue::CSS_NUMBER;371 CSSPrimitiveValue::UnitType evaluationType = CSSPrimitiveValue::CSS_NUMBER; 372 372 return CSSCalcPrimitiveValue::create(evaluateOperator(op, leftSide->doubleValue(), rightSide->doubleValue()), evaluationType, isInteger); 373 373 } … … 376 376 if (op == CalcAdd || op == CalcSubtract) { 377 377 if (leftCategory == rightSide->category()) { 378 CSSPrimitiveValue::UnitType sleftType = leftSide->primitiveType();378 CSSPrimitiveValue::UnitType leftType = leftSide->primitiveType(); 379 379 if (hasDoubleValue(leftType)) { 380 CSSPrimitiveValue::UnitType srightType = rightSide->primitiveType();380 CSSPrimitiveValue::UnitType rightType = rightSide->primitiveType(); 381 381 if (leftType == rightType) 382 382 return CSSCalcPrimitiveValue::create(evaluateOperator(op, leftSide->doubleValue(), rightSide->doubleValue()), leftType, isInteger); 383 383 CSSPrimitiveValue::UnitCategory leftUnitCategory = CSSPrimitiveValue::unitCategory(leftType); 384 384 if (leftUnitCategory != CSSPrimitiveValue::UOther && leftUnitCategory == CSSPrimitiveValue::unitCategory(rightType)) { 385 CSSPrimitiveValue::UnitType scanonicalType = CSSPrimitiveValue::canonicalUnitTypeForCategory(leftUnitCategory);385 CSSPrimitiveValue::UnitType canonicalType = CSSPrimitiveValue::canonicalUnitTypeForCategory(leftUnitCategory); 386 386 if (canonicalType != CSSPrimitiveValue::CSS_UNKNOWN) { 387 387 double leftValue = leftSide->doubleValue() * CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(leftType); … … 408 408 return nullptr; 409 409 410 CSSPrimitiveValue::UnitType sotherType = otherSide->primitiveType();410 CSSPrimitiveValue::UnitType otherType = otherSide->primitiveType(); 411 411 if (hasDoubleValue(otherType)) 412 412 return CSSCalcPrimitiveValue::create(evaluateOperator(op, otherSide->doubleValue(), number), otherType, isInteger); … … 477 477 Type type() const final { return CssCalcBinaryOperation; } 478 478 479 CSSPrimitiveValue::UnitType sprimitiveType() const final479 CSSPrimitiveValue::UnitType primitiveType() const final 480 480 { 481 481 switch (category()) { … … 489 489 if (m_rightSide->category() == CalcNumber) 490 490 return m_leftSide->primitiveType(); 491 CSSPrimitiveValue::UnitType sleftType = m_leftSide->primitiveType();491 CSSPrimitiveValue::UnitType leftType = m_leftSide->primitiveType(); 492 492 if (leftType == m_rightSide->primitiveType()) 493 493 return leftType; … … 594 594 return false; 595 595 596 CSSPrimitiveValue::UnitType stype = token.unitType();596 CSSPrimitiveValue::UnitType type = token.unitType(); 597 597 if (unitCategory(type) == CalcOther) 598 598 return false; -
trunk/Source/WebCore/css/CSSCalculationValue.h
r209666 r209758 67 67 virtual bool equals(const CSSCalcExpressionNode& other) const { return m_category == other.m_category && m_isInteger == other.m_isInteger; } 68 68 virtual Type type() const = 0; 69 virtual CSSPrimitiveValue::UnitType sprimitiveType() const = 0;69 virtual CSSPrimitiveValue::UnitType primitiveType() const = 0; 70 70 71 71 CalculationCategory category() const { return m_category; } -
trunk/Source/WebCore/css/CSSPrimitiveValue.cpp
r209671 r209758 62 62 namespace WebCore { 63 63 64 static inline bool isValidCSSUnitTypeForDoubleConversion(CSSPrimitiveValue::UnitType sunitType)64 static inline bool isValidCSSUnitTypeForDoubleConversion(CSSPrimitiveValue::UnitType unitType) 65 65 { 66 66 switch (unitType) { … … 135 135 #if !ASSERT_DISABLED 136 136 137 static inline bool isStringType(CSSPrimitiveValue::UnitType stype)137 static inline bool isStringType(CSSPrimitiveValue::UnitType type) 138 138 { 139 139 switch (type) { … … 203 203 #endif // !ASSERT_DISABLED 204 204 205 CSSPrimitiveValue::UnitCategory CSSPrimitiveValue::unitCategory(CSSPrimitiveValue::UnitType stype)205 CSSPrimitiveValue::UnitCategory CSSPrimitiveValue::unitCategory(CSSPrimitiveValue::UnitType type) 206 206 { 207 207 // Here we violate the spec (http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSPrimitiveValue) and allow conversions … … 318 318 } 319 319 320 CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitType stype)320 CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitType type) 321 321 : CSSValue(PrimitiveClass) 322 322 { … … 326 326 } 327 327 328 CSSPrimitiveValue::CSSPrimitiveValue(const String& string, UnitType stype)328 CSSPrimitiveValue::CSSPrimitiveValue(const String& string, UnitType type) 329 329 : CSSValue(PrimitiveClass) 330 330 { … … 507 507 void CSSPrimitiveValue::cleanup() 508 508 { 509 auto type = static_cast<UnitType s>(m_primitiveUnitType);509 auto type = static_cast<UnitType>(m_primitiveUnitType); 510 510 switch (type) { 511 511 case CSS_STRING: … … 662 662 return m_value.calc->computeLengthPx(conversionData); 663 663 664 return computeNonCalcLengthDouble(conversionData, static_cast<UnitType s>(primitiveType()), m_value.num);665 } 666 667 double CSSPrimitiveValue::computeNonCalcLengthDouble(const CSSToLengthConversionData& conversionData, UnitType sprimitiveType, double value)664 return computeNonCalcLengthDouble(conversionData, static_cast<UnitType>(primitiveType()), m_value.num); 665 } 666 667 double CSSPrimitiveValue::computeNonCalcLengthDouble(const CSSToLengthConversionData& conversionData, UnitType primitiveType, double value) 668 668 { 669 669 double factor; … … 753 753 } 754 754 755 double CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(UnitType sunitType)755 double CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(UnitType unitType) 756 756 { 757 757 double factor = 1.0; … … 807 807 ExceptionOr<float> CSSPrimitiveValue::getFloatValue(unsigned short unitType) const 808 808 { 809 auto result = doubleValueInternal(static_cast<UnitType s>(unitType));809 auto result = doubleValueInternal(static_cast<UnitType>(unitType)); 810 810 if (!result) 811 811 return Exception { INVALID_ACCESS_ERR }; … … 813 813 } 814 814 815 double CSSPrimitiveValue::doubleValue(UnitType sunitType) const815 double CSSPrimitiveValue::doubleValue(UnitType unitType) const 816 816 { 817 817 return doubleValueInternal(unitType).value_or(0); … … 824 824 825 825 826 CSSPrimitiveValue::UnitType sCSSPrimitiveValue::canonicalUnitTypeForCategory(UnitCategory category)826 CSSPrimitiveValue::UnitType CSSPrimitiveValue::canonicalUnitTypeForCategory(UnitCategory category) 827 827 { 828 828 // The canonical unit type is chosen according to the way CSSParser::validUnit() chooses the default unit … … 850 850 } 851 851 852 std::optional<double> CSSPrimitiveValue::doubleValueInternal(UnitType srequestedUnitType) const853 { 854 if (!isValidCSSUnitTypeForDoubleConversion(static_cast<UnitType s>(m_primitiveUnitType)) || !isValidCSSUnitTypeForDoubleConversion(requestedUnitType))852 std::optional<double> CSSPrimitiveValue::doubleValueInternal(UnitType requestedUnitType) const 853 { 854 if (!isValidCSSUnitTypeForDoubleConversion(static_cast<UnitType>(m_primitiveUnitType)) || !isValidCSSUnitTypeForDoubleConversion(requestedUnitType)) 855 855 return std::nullopt; 856 856 857 UnitType s sourceUnitType = static_cast<UnitTypes>(primitiveType());857 UnitType sourceUnitType = static_cast<UnitType>(primitiveType()); 858 858 if (requestedUnitType == sourceUnitType || requestedUnitType == CSS_DIMENSION) 859 859 return doubleValue(); … … 862 862 ASSERT(sourceCategory != UOther); 863 863 864 UnitType stargetUnitType = requestedUnitType;864 UnitType targetUnitType = requestedUnitType; 865 865 UnitCategory targetCategory = unitCategory(targetUnitType); 866 866 ASSERT(targetCategory != UOther); … … 1184 1184 case CSS_ATTR: 1185 1185 case CSS_COUNTER_NAME: 1186 result = CSSPrimitiveValue::create(m_value.string, static_cast<UnitType s>(m_primitiveUnitType));1186 result = CSSPrimitiveValue::create(m_value.string, static_cast<UnitType>(m_primitiveUnitType)); 1187 1187 break; 1188 1188 case CSS_FONT_FAMILY: … … 1252 1252 #endif 1253 1253 case CSS_FR: 1254 result = CSSPrimitiveValue::create(m_value.num, static_cast<UnitType s>(m_primitiveUnitType));1254 result = CSSPrimitiveValue::create(m_value.num, static_cast<UnitType>(m_primitiveUnitType)); 1255 1255 break; 1256 1256 case CSS_PROPERTY_ID: -
trunk/Source/WebCore/css/CSSPrimitiveValue.h
r209666 r209758 76 76 class CSSPrimitiveValue final : public CSSValue { 77 77 public: 78 enum UnitType s{78 enum UnitType { 79 79 CSS_UNKNOWN = 0, 80 80 CSS_NUMBER = 1, … … 165 165 UOther 166 166 }; 167 static UnitCategory unitCategory(UnitType s);167 static UnitCategory unitCategory(UnitType); 168 168 169 169 bool isAngle() const; … … 171 171 bool isCounter() const { return m_primitiveUnitType == CSS_COUNTER; } 172 172 bool isFontIndependentLength() const { return m_primitiveUnitType >= CSS_PX && m_primitiveUnitType <= CSS_PC; } 173 static bool isFontRelativeLength(UnitType s);174 bool isFontRelativeLength() const { return isFontRelativeLength(static_cast<UnitType s>(m_primitiveUnitType)); }173 static bool isFontRelativeLength(UnitType); 174 bool isFontRelativeLength() const { return isFontRelativeLength(static_cast<UnitType>(m_primitiveUnitType)); } 175 175 176 bool isQuirkyEms() const { return primitiveType() == UnitType s::CSS_QUIRKY_EMS; }177 178 static bool isViewportPercentageLength(UnitType stype) { return type >= CSS_VW && type <= CSS_VMAX; }179 bool isViewportPercentageLength() const { return isViewportPercentageLength(static_cast<UnitType s>(m_primitiveUnitType)); }180 181 static bool isLength(UnitType s);182 bool isLength() const { return isLength(static_cast<UnitType s>(primitiveType())); }176 bool isQuirkyEms() const { return primitiveType() == UnitType::CSS_QUIRKY_EMS; } 177 178 static bool isViewportPercentageLength(UnitType type) { return type >= CSS_VW && type <= CSS_VMAX; } 179 bool isViewportPercentageLength() const { return isViewportPercentageLength(static_cast<UnitType>(m_primitiveUnitType)); } 180 181 static bool isLength(UnitType); 182 bool isLength() const { return isLength(static_cast<UnitType>(primitiveType())); } 183 183 bool isNumber() const { return primitiveType() == CSS_NUMBER; } 184 184 bool isPercentage() const { return primitiveType() == CSS_PERCENTAGE; } … … 203 203 bool isDotsPerCentimeter() const { return primitiveType() == CSS_DPCM; } 204 204 205 static bool isResolution(UnitType s);206 bool isResolution() const { return isResolution(static_cast<UnitType s>(primitiveType())); }205 static bool isResolution(UnitType); 206 bool isResolution() const { return isResolution(static_cast<UnitType>(primitiveType())); } 207 207 bool isViewportPercentageWidth() const { return m_primitiveUnitType == CSS_VW; } 208 208 bool isViewportPercentageHeight() const { return m_primitiveUnitType == CSS_VH; } … … 215 215 static Ref<CSSPrimitiveValue> createIdentifier(CSSPropertyID propertyID) { return adoptRef(*new CSSPrimitiveValue(propertyID)); } 216 216 217 static Ref<CSSPrimitiveValue> create(double value, UnitType stype) { return adoptRef(*new CSSPrimitiveValue(value, type)); }218 static Ref<CSSPrimitiveValue> create(const String& value, UnitType stype) { return adoptRef(*new CSSPrimitiveValue(value, type)); }217 static Ref<CSSPrimitiveValue> create(double value, UnitType type) { return adoptRef(*new CSSPrimitiveValue(value, type)); } 218 static Ref<CSSPrimitiveValue> create(const String& value, UnitType type) { return adoptRef(*new CSSPrimitiveValue(value, type)); } 219 219 static Ref<CSSPrimitiveValue> create(const Length& value, const RenderStyle& style) { return adoptRef(*new CSSPrimitiveValue(value, style)); } 220 220 static Ref<CSSPrimitiveValue> create(const LengthSize& value, const RenderStyle& style) { return adoptRef(*new CSSPrimitiveValue(value, style)); } … … 226 226 // When the quirky value is used, if you're in quirks mode, the margin will collapse away 227 227 // inside a table cell. 228 static Ref<CSSPrimitiveValue> createAllowingMarginQuirk(double value, UnitType s);228 static Ref<CSSPrimitiveValue> createAllowingMarginQuirk(double value, UnitType); 229 229 230 230 ~CSSPrimitiveValue(); … … 251 251 bool convertingToLengthRequiresNonNullStyle(int lengthConversion) const; 252 252 253 double doubleValue(UnitType s) const;253 double doubleValue(UnitType) const; 254 254 double doubleValue() const; 255 255 256 template<typename T> inline T value(UnitType stype) const { return clampTo<T>(doubleValue(type)); }256 template<typename T> inline T value(UnitType type) const { return clampTo<T>(doubleValue(type)); } 257 257 template<typename T> inline T value() const { return clampTo<T>(doubleValue()); } 258 258 259 float floatValue(UnitType stype) const { return value<float>(type); }259 float floatValue(UnitType type) const { return value<float>(type); } 260 260 float floatValue() const { return value<float>(); } 261 261 262 int intValue(UnitType stype) const { return value<int>(type); }262 int intValue(UnitType type) const { return value<int>(type); } 263 263 int intValue() const { return value<int>(); } 264 264 … … 295 295 bool equals(const CSSPrimitiveValue&) const; 296 296 297 static UnitType scanonicalUnitTypeForCategory(UnitCategory);298 static double conversionToCanonicalUnitsScaleFactor(UnitType s);299 300 static double computeNonCalcLengthDouble(const CSSToLengthConversionData&, UnitType s, double value);297 static UnitType canonicalUnitTypeForCategory(UnitCategory); 298 static double conversionToCanonicalUnitsScaleFactor(UnitType); 299 300 static double computeNonCalcLengthDouble(const CSSToLengthConversionData&, UnitType, double value); 301 301 302 302 #if COMPILER(MSVC) … … 315 315 CSSPrimitiveValue(const Length&, const RenderStyle&); 316 316 CSSPrimitiveValue(const LengthSize&, const RenderStyle&); 317 CSSPrimitiveValue(const String&, UnitType s);318 CSSPrimitiveValue(double, UnitType s);317 CSSPrimitiveValue(const String&, UnitType); 318 CSSPrimitiveValue(double, UnitType); 319 319 320 320 template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMappings.h … … 342 342 #endif 343 343 344 std::optional<double> doubleValueInternal(UnitType stargetUnitType) const;344 std::optional<double> doubleValueInternal(UnitType targetUnitType) const; 345 345 346 346 double computeLengthDouble(const CSSToLengthConversionData&) const; … … 378 378 } 379 379 380 inline bool CSSPrimitiveValue::isFontRelativeLength(UnitType stype)380 inline bool CSSPrimitiveValue::isFontRelativeLength(UnitType type) 381 381 { 382 382 return type == CSS_EMS … … 387 387 } 388 388 389 inline bool CSSPrimitiveValue::isLength(UnitType stype)389 inline bool CSSPrimitiveValue::isLength(UnitType type) 390 390 { 391 391 return (type >= CSS_EMS && type <= CSS_PC) … … 396 396 } 397 397 398 inline bool CSSPrimitiveValue::isResolution(UnitType stype)398 inline bool CSSPrimitiveValue::isResolution(UnitType type) 399 399 { 400 400 return type >= CSS_DPPX && type <= CSS_DPCM; … … 406 406 } 407 407 408 inline Ref<CSSPrimitiveValue> CSSPrimitiveValue::createAllowingMarginQuirk(double value, UnitType stype)408 inline Ref<CSSPrimitiveValue> CSSPrimitiveValue::createAllowingMarginQuirk(double value, UnitType type) 409 409 { 410 410 auto result = adoptRef(*new CSSPrimitiveValue(value, type)); -
trunk/Source/WebCore/css/CSSValue.h
r209666 r209758 253 253 254 254 // CSSPrimitiveValue bits: 255 unsigned m_primitiveUnitType : 7; // CSSPrimitiveValue::UnitType s255 unsigned m_primitiveUnitType : 7; // CSSPrimitiveValue::UnitType 256 256 mutable unsigned m_hasCachedCSSText : 1; 257 257 unsigned m_isQuirkValue : 1; -
trunk/Source/WebCore/css/CSSValuePool.cpp
r209666 r209758 96 96 } 97 97 98 Ref<CSSPrimitiveValue> CSSValuePool::createValue(double value, CSSPrimitiveValue::UnitType stype)98 Ref<CSSPrimitiveValue> CSSValuePool::createValue(double value, CSSPrimitiveValue::UnitType type) 99 99 { 100 100 ASSERT(std::isfinite(value)); -
trunk/Source/WebCore/css/CSSValuePool.h
r208668 r209758 62 62 Ref<CSSPrimitiveValue> createIdentifierValue(CSSPropertyID identifier); 63 63 Ref<CSSPrimitiveValue> createColorValue(const Color&); 64 Ref<CSSPrimitiveValue> createValue(double value, CSSPrimitiveValue::UnitType s);65 Ref<CSSPrimitiveValue> createValue(const String& value, CSSPrimitiveValue::UnitType stype) { return CSSPrimitiveValue::create(value, type); }64 Ref<CSSPrimitiveValue> createValue(double value, CSSPrimitiveValue::UnitType); 65 Ref<CSSPrimitiveValue> createValue(const String& value, CSSPrimitiveValue::UnitType type) { return CSSPrimitiveValue::create(value, type); } 66 66 Ref<CSSPrimitiveValue> createValue(const Length& value, const RenderStyle& style) { return CSSPrimitiveValue::create(value, style); } 67 67 Ref<CSSPrimitiveValue> createValue(const LengthSize& value, const RenderStyle& style) { return CSSPrimitiveValue::create(value, style); } -
trunk/Source/WebCore/css/MediaQueryExp.cpp
r209666 r209758 57 57 static inline bool featureWithValidDensity(const String& mediaFeature, const CSSParserToken& token) 58 58 { 59 if (!CSSPrimitiveValue::isResolution(static_cast<CSSPrimitiveValue::UnitType s>(token.unitType())) || token.numericValue() <= 0)59 if (!CSSPrimitiveValue::isResolution(static_cast<CSSPrimitiveValue::UnitType>(token.unitType())) || token.numericValue() <= 0) 60 60 return false; 61 61 … … 187 187 // Media features that must have non-negative <density>, ie. dppx, dpi or dpcm, 188 188 // or Media features that must have non-negative <length> or number value. 189 m_value = CSSPrimitiveValue::create(token.numericValue(), (CSSPrimitiveValue::UnitType s) token.unitType());189 m_value = CSSPrimitiveValue::create(token.numericValue(), (CSSPrimitiveValue::UnitType) token.unitType()); 190 190 m_isValid = true; 191 191 } else if (featureWithPositiveInteger(m_mediaFeature, token) … … 195 195 // or media features that must have non-negative number value, 196 196 // or media features that must have (0|1) value. 197 m_value = CSSPrimitiveValue::create(token.numericValue(), CSSPrimitiveValue::UnitType s::CSS_NUMBER);197 m_value = CSSPrimitiveValue::create(token.numericValue(), CSSPrimitiveValue::UnitType::CSS_NUMBER); 198 198 m_isValid = true; 199 199 } -
trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp
r209718 r209758 102 102 103 103 template <typename CharacterType> 104 static inline bool parseSimpleLength(const CharacterType* characters, unsigned length, CSSPrimitiveValue::UnitType s& unit, double& number)104 static inline bool parseSimpleLength(const CharacterType* characters, unsigned length, CSSPrimitiveValue::UnitType& unit, double& number) 105 105 { 106 106 if (length > 2 && (characters[length - 2] | 0x20) == 'p' && (characters[length - 1] | 0x20) == 'x') { 107 107 length -= 2; 108 unit = CSSPrimitiveValue::UnitType s::CSS_PX;108 unit = CSSPrimitiveValue::UnitType::CSS_PX; 109 109 } else if (length > 1 && characters[length - 1] == '%') { 110 110 length -= 1; 111 unit = CSSPrimitiveValue::UnitType s::CSS_PERCENTAGE;111 unit = CSSPrimitiveValue::UnitType::CSS_PERCENTAGE; 112 112 } 113 113 … … 133 133 unsigned length = string.length(); 134 134 double number; 135 CSSPrimitiveValue::UnitType s unit = CSSPrimitiveValue::UnitTypes::CSS_NUMBER;135 CSSPrimitiveValue::UnitType unit = CSSPrimitiveValue::UnitType::CSS_NUMBER; 136 136 137 137 if (string.is8Bit()) { … … 143 143 } 144 144 145 if (unit == CSSPrimitiveValue::UnitType s::CSS_NUMBER) {145 if (unit == CSSPrimitiveValue::UnitType::CSS_NUMBER) { 146 146 if (number && cssParserMode != SVGAttributeMode) 147 147 return nullptr; 148 unit = CSSPrimitiveValue::UnitType s::CSS_PX;148 unit = CSSPrimitiveValue::UnitType::CSS_PX; 149 149 } 150 150 … … 257 257 258 258 template <typename CharacterType> 259 static bool parseColorIntOrPercentage(const CharacterType*& string, const CharacterType* end, const char terminator, CSSPrimitiveValue::UnitType s& expect, int& value)259 static bool parseColorIntOrPercentage(const CharacterType*& string, const CharacterType* end, const char terminator, CSSPrimitiveValue::UnitType& expect, int& value) 260 260 { 261 261 const CharacterType* current = string; … … 285 285 return false; 286 286 287 if (expect == CSSPrimitiveValue::UnitType s::CSS_NUMBER && (*current == '.' || *current == '%'))287 if (expect == CSSPrimitiveValue::UnitType::CSS_NUMBER && (*current == '.' || *current == '%')) 288 288 return false; 289 289 … … 301 301 } 302 302 303 if (expect == CSSPrimitiveValue::UnitType s::CSS_PERCENTAGE && *current != '%')303 if (expect == CSSPrimitiveValue::UnitType::CSS_PERCENTAGE && *current != '%') 304 304 return false; 305 305 306 306 if (*current == '%') { 307 expect = CSSPrimitiveValue::UnitType s::CSS_PERCENTAGE;307 expect = CSSPrimitiveValue::UnitType::CSS_PERCENTAGE; 308 308 localValue = localValue / 100.0 * 256.0; 309 309 // Clamp values at 255 for percentages over 100% … … 312 312 current++; 313 313 } else { 314 expect = CSSPrimitiveValue::UnitType s::CSS_NUMBER;314 expect = CSSPrimitiveValue::UnitType::CSS_NUMBER; 315 315 } 316 316 … … 417 417 static Color fastParseColorInternal(const CharacterType* characters, unsigned length, bool quirksMode) 418 418 { 419 CSSPrimitiveValue::UnitType s expect = CSSPrimitiveValue::UnitTypes::CSS_UNKNOWN;419 CSSPrimitiveValue::UnitType expect = CSSPrimitiveValue::UnitType::CSS_UNKNOWN; 420 420 421 421 if (length >= 4 && characters[0] == '#') { … … 1060 1060 return false; 1061 1061 unsigned argumentLength = static_cast<unsigned>(delimiter); 1062 CSSPrimitiveValue::UnitType s unit = CSSPrimitiveValue::UnitTypes::CSS_NUMBER;1062 CSSPrimitiveValue::UnitType unit = CSSPrimitiveValue::UnitType::CSS_NUMBER; 1063 1063 double number; 1064 1064 if (!parseSimpleLength(pos, argumentLength, unit, number)) 1065 1065 return false; 1066 if (unit != CSSPrimitiveValue::UnitType s::CSS_PX && (number || unit != CSSPrimitiveValue::UnitTypes::CSS_NUMBER))1066 if (unit != CSSPrimitiveValue::UnitType::CSS_PX && (number || unit != CSSPrimitiveValue::UnitType::CSS_NUMBER)) 1067 1067 return false; 1068 transformValue->append(CSSPrimitiveValue::create(number, CSSPrimitiveValue::UnitType s::CSS_PX));1068 transformValue->append(CSSPrimitiveValue::create(number, CSSPrimitiveValue::UnitType::CSS_PX)); 1069 1069 pos += argumentLength + 1; 1070 1070 --expectedCount; … … 1085 1085 if (!ok) 1086 1086 return false; 1087 transformValue->append(CSSPrimitiveValue::create(number, CSSPrimitiveValue::UnitType s::CSS_NUMBER));1087 transformValue->append(CSSPrimitiveValue::create(number, CSSPrimitiveValue::UnitType::CSS_NUMBER)); 1088 1088 pos += argumentLength + 1; 1089 1089 --expectedCount; -
trunk/Source/WebCore/css/parser/CSSParserToken.cpp
r209383 r209758 41 41 42 42 template<typename CharacterType> 43 CSSPrimitiveValue::UnitType scssPrimitiveValueUnitFromTrie(const CharacterType* data, unsigned length)43 CSSPrimitiveValue::UnitType cssPrimitiveValueUnitFromTrie(const CharacterType* data, unsigned length) 44 44 { 45 45 ASSERT(data); … … 49 49 switch (toASCIILower(data[0])) { 50 50 case 's': 51 return CSSPrimitiveValue::UnitType s::CSS_S;51 return CSSPrimitiveValue::UnitType::CSS_S; 52 52 } 53 53 break; … … 57 57 switch (toASCIILower(data[1])) { 58 58 case 'h': 59 return CSSPrimitiveValue::UnitType s::CSS_CHS;59 return CSSPrimitiveValue::UnitType::CSS_CHS; 60 60 case 'm': 61 return CSSPrimitiveValue::UnitType s::CSS_CM;61 return CSSPrimitiveValue::UnitType::CSS_CM; 62 62 } 63 63 break; … … 65 65 switch (toASCIILower(data[1])) { 66 66 case 'm': 67 return CSSPrimitiveValue::UnitType s::CSS_EMS;67 return CSSPrimitiveValue::UnitType::CSS_EMS; 68 68 case 'x': 69 return CSSPrimitiveValue::UnitType s::CSS_EXS;69 return CSSPrimitiveValue::UnitType::CSS_EXS; 70 70 } 71 71 break; 72 72 case 'f': 73 73 if (toASCIILower(data[1]) == 'r') 74 return CSSPrimitiveValue::UnitType s::CSS_FR;74 return CSSPrimitiveValue::UnitType::CSS_FR; 75 75 break; 76 76 case 'h': 77 77 if (toASCIILower(data[1]) == 'z') 78 return CSSPrimitiveValue::UnitType s::CSS_HZ;78 return CSSPrimitiveValue::UnitType::CSS_HZ; 79 79 break; 80 80 case 'i': 81 81 if (toASCIILower(data[1]) == 'n') 82 return CSSPrimitiveValue::UnitType s::CSS_IN;82 return CSSPrimitiveValue::UnitType::CSS_IN; 83 83 break; 84 84 case 'm': 85 85 switch (toASCIILower(data[1])) { 86 86 case 'm': 87 return CSSPrimitiveValue::UnitType s::CSS_MM;87 return CSSPrimitiveValue::UnitType::CSS_MM; 88 88 case 's': 89 return CSSPrimitiveValue::UnitType s::CSS_MS;89 return CSSPrimitiveValue::UnitType::CSS_MS; 90 90 } 91 91 break; … … 93 93 switch (toASCIILower(data[1])) { 94 94 case 'c': 95 return CSSPrimitiveValue::UnitType s::CSS_PC;95 return CSSPrimitiveValue::UnitType::CSS_PC; 96 96 case 't': 97 return CSSPrimitiveValue::UnitType s::CSS_PT;97 return CSSPrimitiveValue::UnitType::CSS_PT; 98 98 case 'x': 99 return CSSPrimitiveValue::UnitType s::CSS_PX;99 return CSSPrimitiveValue::UnitType::CSS_PX; 100 100 } 101 101 break; … … 103 103 switch (toASCIILower(data[1])) { 104 104 case 'h': 105 return CSSPrimitiveValue::UnitType s::CSS_VH;105 return CSSPrimitiveValue::UnitType::CSS_VH; 106 106 case 'w': 107 return CSSPrimitiveValue::UnitType s::CSS_VW;107 return CSSPrimitiveValue::UnitType::CSS_VW; 108 108 } 109 109 break; … … 116 116 case 'e': 117 117 if (toASCIILower(data[2]) == 'g') 118 return CSSPrimitiveValue::UnitType s::CSS_DEG;118 return CSSPrimitiveValue::UnitType::CSS_DEG; 119 119 break; 120 120 case 'p': 121 121 if (toASCIILower(data[2]) == 'i') 122 return CSSPrimitiveValue::UnitType s::CSS_DPI;122 return CSSPrimitiveValue::UnitType::CSS_DPI; 123 123 break; 124 124 } … … 126 126 case 'k': 127 127 if (toASCIILower(data[1]) == 'h' && toASCIILower(data[2]) == 'z') 128 return CSSPrimitiveValue::UnitType s::CSS_KHZ;128 return CSSPrimitiveValue::UnitType::CSS_KHZ; 129 129 break; 130 130 case 'r': … … 132 132 case 'a': 133 133 if (toASCIILower(data[2]) == 'd') 134 return CSSPrimitiveValue::UnitType s::CSS_RAD;134 return CSSPrimitiveValue::UnitType::CSS_RAD; 135 135 break; 136 136 case 'e': 137 137 if (toASCIILower(data[2]) == 'm') 138 return CSSPrimitiveValue::UnitType s::CSS_REMS;138 return CSSPrimitiveValue::UnitType::CSS_REMS; 139 139 break; 140 140 } … … 150 150 case 'c': 151 151 if (toASCIILower(data[3]) == 'm') 152 return CSSPrimitiveValue::UnitType s::CSS_DPCM;152 return CSSPrimitiveValue::UnitType::CSS_DPCM; 153 153 break; 154 154 case 'p': 155 155 if (toASCIILower(data[3]) == 'x') 156 return CSSPrimitiveValue::UnitType s::CSS_DPPX;156 return CSSPrimitiveValue::UnitType::CSS_DPPX; 157 157 break; 158 158 } … … 162 162 case 'g': 163 163 if (toASCIILower(data[1]) == 'r' && toASCIILower(data[2]) == 'a' && toASCIILower(data[3]) == 'd') 164 return CSSPrimitiveValue::UnitType s::CSS_GRAD;164 return CSSPrimitiveValue::UnitType::CSS_GRAD; 165 165 break; 166 166 case 't': 167 167 if (toASCIILower(data[1]) == 'u' && toASCIILower(data[2]) == 'r' && toASCIILower(data[3]) == 'n') 168 return CSSPrimitiveValue::UnitType s::CSS_TURN;168 return CSSPrimitiveValue::UnitType::CSS_TURN; 169 169 break; 170 170 case 'v': … … 174 174 case 'a': 175 175 if (toASCIILower(data[3]) == 'x') 176 return CSSPrimitiveValue::UnitType s::CSS_VMAX;176 return CSSPrimitiveValue::UnitType::CSS_VMAX; 177 177 break; 178 178 case 'i': 179 179 if (toASCIILower(data[3]) == 'n') 180 return CSSPrimitiveValue::UnitType s::CSS_VMIN;180 return CSSPrimitiveValue::UnitType::CSS_VMIN; 181 181 break; 182 182 } … … 190 190 case '_': 191 191 if (toASCIILower(data[1]) == '_' && toASCIILower(data[2]) == 'q' && toASCIILower(data[3]) == 'e' && toASCIILower(data[4]) == 'm') 192 return CSSPrimitiveValue::UnitType s::CSS_QUIRKY_EMS;192 return CSSPrimitiveValue::UnitType::CSS_QUIRKY_EMS; 193 193 break; 194 194 } 195 195 break; 196 196 } 197 return CSSPrimitiveValue::UnitType s::CSS_UNKNOWN;198 } 199 200 static CSSPrimitiveValue::UnitType sstringToUnitType(StringView stringView)197 return CSSPrimitiveValue::UnitType::CSS_UNKNOWN; 198 } 199 200 static CSSPrimitiveValue::UnitType stringToUnitType(StringView stringView) 201 201 { 202 202 if (stringView.is8Bit()) … … 233 233 , m_numericValueType(numericValueType) 234 234 , m_numericSign(sign) 235 , m_unit(static_cast<unsigned>(CSSPrimitiveValue::UnitType s::CSS_NUMBER))235 , m_unit(static_cast<unsigned>(CSSPrimitiveValue::UnitType::CSS_NUMBER)) 236 236 { 237 237 ASSERT(type == NumberToken); … … 268 268 ASSERT(m_type == NumberToken); 269 269 m_type = PercentageToken; 270 m_unit = static_cast<unsigned>(CSSPrimitiveValue::UnitType s::CSS_PERCENTAGE);270 m_unit = static_cast<unsigned>(CSSPrimitiveValue::UnitType::CSS_PERCENTAGE); 271 271 } 272 272 -
trunk/Source/WebCore/css/parser/CSSParserToken.h
r209314 r209758 128 128 HashTokenType getHashTokenType() const { ASSERT(m_type == HashToken); return m_hashTokenType; } 129 129 BlockType getBlockType() const { return static_cast<BlockType>(m_blockType); } 130 CSSPrimitiveValue::UnitType s unitType() const { return static_cast<CSSPrimitiveValue::UnitTypes>(m_unit); }130 CSSPrimitiveValue::UnitType unitType() const { return static_cast<CSSPrimitiveValue::UnitType>(m_unit); } 131 131 UChar32 unicodeRangeStart() const { ASSERT(m_type == UnicodeRangeToken); return m_unicodeRange.start; } 132 132 UChar32 unicodeRangeEnd() const { ASSERT(m_type == UnicodeRangeToken); return m_unicodeRange.end; } … … 153 153 unsigned m_numericValueType : 1; // NumericValueType 154 154 unsigned m_numericSign : 2; // NumericSign 155 unsigned m_unit : 7; // CSSPrimitiveValue::UnitType s155 unsigned m_unit : 7; // CSSPrimitiveValue::UnitType 156 156 157 157 bool valueDataCharRawEqual(const CSSParserToken& other) const; -
trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp
r209718 r209758 387 387 addProperty(CSSPropertyTransformOriginX, CSSPropertyTransformOrigin, resultX.releaseNonNull(), important); 388 388 addProperty(CSSPropertyTransformOriginY, CSSPropertyTransformOrigin, resultY.releaseNonNull(), important); 389 addProperty(CSSPropertyTransformOriginZ, CSSPropertyTransformOrigin, resultZ ? resultZ.releaseNonNull() : CSSValuePool::singleton().createValue(0, CSSPrimitiveValue::UnitType s::CSS_PX), important, !hasZ);389 addProperty(CSSPropertyTransformOriginZ, CSSPropertyTransformOrigin, resultZ ? resultZ.releaseNonNull() : CSSValuePool::singleton().createValue(0, CSSPrimitiveValue::UnitType::CSS_PX), important, !hasZ); 390 390 391 391 return true; … … 1042 1042 if (RefPtr<CSSPrimitiveValue> counterValue = consumeInteger(range)) 1043 1043 i = counterValue->intValue(); 1044 list->append(createPrimitiveValuePair(counterName.releaseNonNull(), CSSPrimitiveValue::create(i, CSSPrimitiveValue::UnitType s::CSS_NUMBER), Pair::IdenticalValueEncoding::Coalesce));1044 list->append(createPrimitiveValuePair(counterName.releaseNonNull(), CSSPrimitiveValue::create(i, CSSPrimitiveValue::UnitType::CSS_NUMBER), Pair::IdenticalValueEncoding::Coalesce)); 1045 1045 } while (!range.atEnd()); 1046 1046 return list; … … 1294 1294 return CSSValuePool::singleton().createIdentifierValue(CSSValueNone); 1295 1295 // FIXME-NEWPARSER: Want to use a CSSCustomIdentValue here eventually. 1296 return CSSValuePool::singleton().createValue(token.value().toString(), CSSPrimitiveValue::UnitType s::CSS_STRING);1296 return CSSValuePool::singleton().createValue(token.value().toString(), CSSPrimitiveValue::UnitType::CSS_STRING); 1297 1297 } 1298 1298 … … 1752 1752 if (!consumeNumberRaw(args, perspective) || perspective < 0) 1753 1753 return false; 1754 parsedValue = CSSPrimitiveValue::create(perspective, CSSPrimitiveValue::UnitType s::CSS_PX);1754 parsedValue = CSSPrimitiveValue::create(perspective, CSSPrimitiveValue::UnitType::CSS_PX); 1755 1755 } 1756 1756 if (!parsedValue) … … 1938 1938 return nullptr; 1939 1939 range.consumeIncludingWhitespace(); 1940 return CSSPrimitiveValue::create(percent, CSSPrimitiveValue::UnitType s::CSS_PERCENTAGE);1940 return CSSPrimitiveValue::create(percent, CSSPrimitiveValue::UnitType::CSS_PERCENTAGE); 1941 1941 } 1942 1942 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll); … … 2161 2161 RefPtr<CSSPrimitiveValue> separator; 2162 2162 if (!counters) 2163 separator = CSSPrimitiveValue::create(String(), CSSPrimitiveValue::UnitType s::CSS_STRING);2163 separator = CSSPrimitiveValue::create(String(), CSSPrimitiveValue::UnitType::CSS_STRING); 2164 2164 else { 2165 2165 if (!consumeCommaIncludingWhitespace(args) || args.peek().type() != StringToken) 2166 2166 return nullptr; 2167 separator = CSSPrimitiveValue::create(args.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitType s::CSS_STRING);2167 separator = CSSPrimitiveValue::create(args.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitType::CSS_STRING); 2168 2168 } 2169 2169 … … 2223 2223 if (!consumeNumberRaw(range, perspective)) 2224 2224 return nullptr; 2225 parsedValue = CSSPrimitiveValue::create(perspective, CSSPrimitiveValue::UnitType s::CSS_PX);2225 parsedValue = CSSPrimitiveValue::create(perspective, CSSPrimitiveValue::UnitType::CSS_PX); 2226 2226 } 2227 2227 if (parsedValue && (parsedValue->isCalculated() || parsedValue->doubleValue() > 0)) … … 2783 2783 RefPtr<CSSPrimitiveValue> offset; 2784 2784 if (range.atEnd()) 2785 offset = CSSValuePool::singleton().createValue(0, CSSPrimitiveValue::UnitType s::CSS_PX);2785 offset = CSSValuePool::singleton().createValue(0, CSSPrimitiveValue::UnitType::CSS_PX); 2786 2786 else { 2787 2787 offset = consumeLengthOrPercent(range, context.mode, ValueRangeAll, UnitlessQuirk::Forbid); … … 3204 3204 if (identMatches<CSSValueWebkitMinContent, CSSValueWebkitMaxContent, CSSValueAuto>(token.id())) 3205 3205 return consumeIdent(range); 3206 if (token.type() == DimensionToken && token.unitType() == CSSPrimitiveValue::UnitType s::CSS_FR) {3206 if (token.type() == DimensionToken && token.unitType() == CSSPrimitiveValue::UnitType::CSS_FR) { 3207 3207 if (range.peek().numericValue() < 0) 3208 3208 return nullptr; 3209 return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitType s::CSS_FR);3209 return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitType::CSS_FR); 3210 3210 } 3211 3211 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative, UnitlessQuirk::Allow); … … 4677 4677 flexShrink = num; 4678 4678 else if (!num) // flex only allows a basis of 0 (sans units) if flex-grow and flex-shrink values have already been set. 4679 flexBasis = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType s::CSS_PX);4679 flexBasis = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::CSS_PX); 4680 4680 else 4681 4681 return false; … … 4696 4696 flexShrink = 1; 4697 4697 if (!flexBasis) 4698 flexBasis = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType s::CSS_PX);4698 flexBasis = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::CSS_PX); 4699 4699 } 4700 4700 4701 4701 if (!m_range.atEnd()) 4702 4702 return false; 4703 addProperty(CSSPropertyFlexGrow, CSSPropertyFlex, CSSPrimitiveValue::create(clampTo<float>(flexGrow), CSSPrimitiveValue::UnitType s::CSS_NUMBER), important);4704 addProperty(CSSPropertyFlexShrink, CSSPropertyFlex, CSSPrimitiveValue::create(clampTo<float>(flexShrink), CSSPrimitiveValue::UnitType s::CSS_NUMBER), important);4703 addProperty(CSSPropertyFlexGrow, CSSPropertyFlex, CSSPrimitiveValue::create(clampTo<float>(flexGrow), CSSPrimitiveValue::UnitType::CSS_NUMBER), important); 4704 addProperty(CSSPropertyFlexShrink, CSSPropertyFlex, CSSPrimitiveValue::create(clampTo<float>(flexShrink), CSSPrimitiveValue::UnitType::CSS_NUMBER), important); 4705 4705 addProperty(CSSPropertyFlexBasis, CSSPropertyFlex, flexBasis.releaseNonNull(), important); 4706 4706 return true; -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
r209531 r209758 101 101 return nullptr; 102 102 m_sourceRange = m_range; 103 return CSSValuePool::singleton().createValue(m_calcValue->doubleValue(), CSSPrimitiveValue::UnitType s::CSS_NUMBER);103 return CSSValuePool::singleton().createValue(m_calcValue->doubleValue(), CSSPrimitiveValue::UnitType::CSS_NUMBER); 104 104 } 105 105 … … 136 136 if (token.numericValueType() == NumberValueType || token.numericValue() < minimumValue) 137 137 return nullptr; 138 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitType s::CSS_NUMBER);138 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitType::CSS_NUMBER); 139 139 } 140 140 CalcParser calcParser(range); … … 211 211 if (token.type() == DimensionToken) { 212 212 switch (token.unitType()) { 213 case CSSPrimitiveValue::UnitType s::CSS_QUIRKY_EMS:213 case CSSPrimitiveValue::UnitType::CSS_QUIRKY_EMS: 214 214 if (cssParserMode != UASheetMode) 215 215 return nullptr; 216 216 FALLTHROUGH; 217 case CSSPrimitiveValue::UnitType s::CSS_EMS:218 case CSSPrimitiveValue::UnitType s::CSS_REMS:219 case CSSPrimitiveValue::UnitType s::CSS_CHS:220 case CSSPrimitiveValue::UnitType s::CSS_EXS:221 case CSSPrimitiveValue::UnitType s::CSS_PX:222 case CSSPrimitiveValue::UnitType s::CSS_CM:223 case CSSPrimitiveValue::UnitType s::CSS_MM:224 case CSSPrimitiveValue::UnitType s::CSS_IN:225 case CSSPrimitiveValue::UnitType s::CSS_PT:226 case CSSPrimitiveValue::UnitType s::CSS_PC:227 case CSSPrimitiveValue::UnitType s::CSS_VW:228 case CSSPrimitiveValue::UnitType s::CSS_VH:229 case CSSPrimitiveValue::UnitType s::CSS_VMIN:230 case CSSPrimitiveValue::UnitType s::CSS_VMAX:217 case CSSPrimitiveValue::UnitType::CSS_EMS: 218 case CSSPrimitiveValue::UnitType::CSS_REMS: 219 case CSSPrimitiveValue::UnitType::CSS_CHS: 220 case CSSPrimitiveValue::UnitType::CSS_EXS: 221 case CSSPrimitiveValue::UnitType::CSS_PX: 222 case CSSPrimitiveValue::UnitType::CSS_CM: 223 case CSSPrimitiveValue::UnitType::CSS_MM: 224 case CSSPrimitiveValue::UnitType::CSS_IN: 225 case CSSPrimitiveValue::UnitType::CSS_PT: 226 case CSSPrimitiveValue::UnitType::CSS_PC: 227 case CSSPrimitiveValue::UnitType::CSS_VW: 228 case CSSPrimitiveValue::UnitType::CSS_VH: 229 case CSSPrimitiveValue::UnitType::CSS_VMIN: 230 case CSSPrimitiveValue::UnitType::CSS_VMAX: 231 231 break; 232 232 default: … … 243 243 if (std::isinf(token.numericValue())) 244 244 return nullptr; 245 CSSPrimitiveValue::UnitType s unitType = CSSPrimitiveValue::UnitTypes::CSS_PX;245 CSSPrimitiveValue::UnitType unitType = CSSPrimitiveValue::UnitType::CSS_PX; 246 246 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().numericValue(), unitType); 247 247 } … … 258 258 if ((valueRange == ValueRangeNonNegative && token.numericValue() < 0) || std::isinf(token.numericValue())) 259 259 return nullptr; 260 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitType s::CSS_PERCENTAGE);260 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitType::CSS_PERCENTAGE); 261 261 } 262 262 CalcParser calcParser(range, valueRange); … … 302 302 if (token.type() == DimensionToken) { 303 303 switch (token.unitType()) { 304 case CSSPrimitiveValue::UnitType s::CSS_DEG:305 case CSSPrimitiveValue::UnitType s::CSS_RAD:306 case CSSPrimitiveValue::UnitType s::CSS_GRAD:307 case CSSPrimitiveValue::UnitType s::CSS_TURN:304 case CSSPrimitiveValue::UnitType::CSS_DEG: 305 case CSSPrimitiveValue::UnitType::CSS_RAD: 306 case CSSPrimitiveValue::UnitType::CSS_GRAD: 307 case CSSPrimitiveValue::UnitType::CSS_TURN: 308 308 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().numericValue(), token.unitType()); 309 309 default: … … 312 312 } 313 313 if (token.type() == NumberToken && shouldAcceptUnitlessValue(token.numericValue(), cssParserMode, unitless)) { 314 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitType s::CSS_DEG);314 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitType::CSS_DEG); 315 315 } 316 316 … … 326 326 { 327 327 const CSSParserToken& token = range.peek(); 328 CSSPrimitiveValue::UnitType sunit = token.unitType();328 CSSPrimitiveValue::UnitType unit = token.unitType(); 329 329 bool acceptUnitless = token.type() == NumberToken && shouldAcceptUnitlessValue(token.numericValue(), cssParserMode, unitless); 330 330 if (acceptUnitless) 331 unit = CSSPrimitiveValue::UnitType s::CSS_MS;331 unit = CSSPrimitiveValue::UnitType::CSS_MS; 332 332 if (token.type() == DimensionToken || acceptUnitless) { 333 333 if (valueRange == ValueRangeNonNegative && token.numericValue() < 0) 334 334 return nullptr; 335 if (unit == CSSPrimitiveValue::UnitType s::CSS_MS || unit == CSSPrimitiveValue::UnitTypes::CSS_S)335 if (unit == CSSPrimitiveValue::UnitType::CSS_MS || unit == CSSPrimitiveValue::UnitType::CSS_S) 336 336 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().numericValue(), unit); 337 337 return nullptr; … … 366 366 if (range.peek().type() != IdentToken || isCSSWideKeyword(range.peek().id())) 367 367 return nullptr; 368 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitType s::CSS_STRING);368 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitType::CSS_STRING); 369 369 } 370 370 … … 373 373 if (range.peek().type() != StringToken) 374 374 return nullptr; 375 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitType s::CSS_STRING);375 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitType::CSS_STRING); 376 376 } 377 377 … … 403 403 if (url.isNull()) 404 404 return nullptr; 405 return CSSValuePool::singleton().createValue(url.toString(), CSSPrimitiveValue::UnitType s::CSS_URI);405 return CSSValuePool::singleton().createValue(url.toString(), CSSPrimitiveValue::UnitType::CSS_URI); 406 406 } 407 407 … … 759 759 if (args.peek().type() == IdentToken) { 760 760 if ((horizontal && consumeIdent<CSSValueLeft>(args)) || (!horizontal && consumeIdent<CSSValueTop>(args))) 761 return CSSValuePool::singleton().createValue(0., CSSPrimitiveValue::UnitType s::CSS_PERCENTAGE);761 return CSSValuePool::singleton().createValue(0., CSSPrimitiveValue::UnitType::CSS_PERCENTAGE); 762 762 if ((horizontal && consumeIdent<CSSValueRight>(args)) || (!horizontal && consumeIdent<CSSValueBottom>(args))) 763 return CSSValuePool::singleton().createValue(100., CSSPrimitiveValue::UnitType s::CSS_PERCENTAGE);763 return CSSValuePool::singleton().createValue(100., CSSPrimitiveValue::UnitType::CSS_PERCENTAGE); 764 764 if (consumeIdent<CSSValueCenter>(args)) 765 return CSSValuePool::singleton().createValue(50., CSSPrimitiveValue::UnitType s::CSS_PERCENTAGE);765 return CSSValuePool::singleton().createValue(50., CSSPrimitiveValue::UnitType::CSS_PERCENTAGE); 766 766 return nullptr; 767 767 } … … 804 804 } 805 805 806 stop.m_position = CSSValuePool::singleton().createValue(position, CSSPrimitiveValue::UnitType s::CSS_NUMBER);806 stop.m_position = CSSValuePool::singleton().createValue(position, CSSPrimitiveValue::UnitType::CSS_NUMBER); 807 807 stop.m_color = consumeDeprecatedGradientStopColor(args, cssParserMode); 808 808 return stop.m_color && args.atEnd(); … … 1082 1082 const CSSParserToken& percentageArg = args.consumeIncludingWhitespace(); 1083 1083 if (percentageArg.type() == PercentageToken) 1084 percentage = CSSValuePool::singleton().createValue(clampTo<double>(percentageArg.numericValue() / 100, 0, 1), CSSPrimitiveValue::UnitType s::CSS_NUMBER);1084 percentage = CSSValuePool::singleton().createValue(clampTo<double>(percentageArg.numericValue() / 100, 0, 1), CSSPrimitiveValue::UnitType::CSS_NUMBER); 1085 1085 else if (percentageArg.type() == NumberToken) 1086 percentage = CSSValuePool::singleton().createValue(clampTo<double>(percentageArg.numericValue(), 0, 1), CSSPrimitiveValue::UnitType s::CSS_NUMBER);1086 percentage = CSSValuePool::singleton().createValue(clampTo<double>(percentageArg.numericValue(), 0, 1), CSSPrimitiveValue::UnitType::CSS_NUMBER); 1087 1087 1088 1088 if (!percentage) … … 1184 1184 if (token.value() != "x") 1185 1185 return nullptr; 1186 ASSERT(token.unitType() == CSSPrimitiveValue::UnitType s::CSS_UNKNOWN);1186 ASSERT(token.unitType() == CSSPrimitiveValue::UnitType::CSS_UNKNOWN); 1187 1187 double imageScaleFactor = token.numericValue(); 1188 1188 if (imageScaleFactor <= 0) 1189 1189 return nullptr; 1190 imageSet->append(CSSValuePool::singleton().createValue(imageScaleFactor, CSSPrimitiveValue::UnitType s::CSS_NUMBER));1190 imageSet->append(CSSValuePool::singleton().createValue(imageScaleFactor, CSSPrimitiveValue::UnitType::CSS_NUMBER)); 1191 1191 } while (consumeCommaIncludingWhitespace(args)); 1192 1192 if (!args.atEnd()) … … 1255 1255 double maxAllowed = isPercentage ? 100.0 : 1.0; 1256 1256 if (downcast<CSSPrimitiveValue>(*parsedValue).doubleValue() > maxAllowed) 1257 parsedValue = CSSPrimitiveValue::create(maxAllowed, isPercentage ? CSSPrimitiveValue::UnitType s::CSS_PERCENTAGE : CSSPrimitiveValue::UnitTypes::CSS_NUMBER);1257 parsedValue = CSSPrimitiveValue::create(maxAllowed, isPercentage ? CSSPrimitiveValue::UnitType::CSS_PERCENTAGE : CSSPrimitiveValue::UnitType::CSS_NUMBER); 1258 1258 } 1259 1259 } -
trunk/Source/WebCore/css/parser/MediaQueryParser.cpp
r209726 r209758 185 185 void MediaQueryParser::readFeatureValue(CSSParserTokenType type, const CSSParserToken& token) 186 186 { 187 if (type == DimensionToken && token.unitType() == CSSPrimitiveValue::UnitType s::CSS_UNKNOWN)187 if (type == DimensionToken && token.unitType() == CSSPrimitiveValue::UnitType::CSS_UNKNOWN) 188 188 m_state = SkipUntilComma; 189 189 else { -
trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp
r209466 r209758 41 41 namespace WebCore { 42 42 43 float SizesAttributeParser::computeLength(double value, CSSPrimitiveValue::UnitType stype, const Document& document)43 float SizesAttributeParser::computeLength(double value, CSSPrimitiveValue::UnitType type, const Document& document) 44 44 { 45 45 auto* renderer = document.renderView(); -
trunk/Source/WebCore/css/parser/SizesAttributeParser.h
r205905 r209758 46 46 47 47 static float defaultLength(const Document&); 48 static float computeLength(double value, CSSPrimitiveValue::UnitType s, const Document&);48 static float computeLength(double value, CSSPrimitiveValue::UnitType, const Document&); 49 49 50 50 private: -
trunk/Source/WebCore/dom/StyledElement.cpp
r208485 r209758 252 252 } 253 253 254 bool StyledElement::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSSPrimitiveValue::UnitType sunit, bool important)254 bool StyledElement::setInlineStyleProperty(CSSPropertyID propertyID, double value, CSSPrimitiveValue::UnitType unit, bool important) 255 255 { 256 256 ensureMutableInlineStyle().setProperty(propertyID, CSSValuePool::singleton().createValue(value, unit), important); … … 389 389 } 390 390 391 void StyledElement::addPropertyToPresentationAttributeStyle(MutableStyleProperties& style, CSSPropertyID propertyID, double value, CSSPrimitiveValue::UnitType sunit)391 void StyledElement::addPropertyToPresentationAttributeStyle(MutableStyleProperties& style, CSSPropertyID propertyID, double value, CSSPrimitiveValue::UnitType unit) 392 392 { 393 393 style.setProperty(propertyID, CSSValuePool::singleton().createValue(value, unit)); -
trunk/Source/WebCore/dom/StyledElement.h
r208179 r209758 50 50 bool setInlineStyleProperty(CSSPropertyID, CSSValueID identifier, bool important = false); 51 51 bool setInlineStyleProperty(CSSPropertyID, CSSPropertyID identifier, bool important = false); 52 WEBCORE_EXPORT bool setInlineStyleProperty(CSSPropertyID, double value, CSSPrimitiveValue::UnitType s, bool important = false);52 WEBCORE_EXPORT bool setInlineStyleProperty(CSSPropertyID, double value, CSSPrimitiveValue::UnitType, bool important = false); 53 53 WEBCORE_EXPORT bool setInlineStyleProperty(CSSPropertyID, const String& value, bool important = false); 54 54 bool removeInlineStyleProperty(CSSPropertyID); … … 76 76 77 77 void addPropertyToPresentationAttributeStyle(MutableStyleProperties&, CSSPropertyID, CSSValueID identifier); 78 void addPropertyToPresentationAttributeStyle(MutableStyleProperties&, CSSPropertyID, double value, CSSPrimitiveValue::UnitType s);78 void addPropertyToPresentationAttributeStyle(MutableStyleProperties&, CSSPropertyID, double value, CSSPrimitiveValue::UnitType); 79 79 void addPropertyToPresentationAttributeStyle(MutableStyleProperties&, CSSPropertyID, const String& value); 80 80 -
trunk/Source/WebCore/svg/SVGLengthValue.cpp
r208705 r209758 313 313 Ref<CSSPrimitiveValue> SVGLengthValue::toCSSPrimitiveValue(const SVGLengthValue& length) 314 314 { 315 CSSPrimitiveValue::UnitType scssType = CSSPrimitiveValue::CSS_UNKNOWN;315 CSSPrimitiveValue::UnitType cssType = CSSPrimitiveValue::CSS_UNKNOWN; 316 316 switch (length.unitType()) { 317 317 case LengthTypeUnknown:
Note:
See TracChangeset
for help on using the changeset viewer.