| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/css/parser/CSSParserFastPaths.h" | 6 #include "core/css/parser/CSSParserFastPaths.h" |
| 7 | 7 |
| 8 #include "core/StylePropertyShorthand.h" | 8 #include "core/StylePropertyShorthand.h" |
| 9 #include "core/css/CSSFunctionValue.h" | 9 #include "core/css/CSSFunctionValue.h" |
| 10 #include "core/css/CSSValuePool.h" | 10 #include "core/css/CSSValuePool.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 if (string.is8Bit()) { | 103 if (string.is8Bit()) { |
| 104 if (!parseSimpleLength(string.characters8(), length, unit, number)) | 104 if (!parseSimpleLength(string.characters8(), length, unit, number)) |
| 105 return nullptr; | 105 return nullptr; |
| 106 } else { | 106 } else { |
| 107 if (!parseSimpleLength(string.characters16(), length, unit, number)) | 107 if (!parseSimpleLength(string.characters16(), length, unit, number)) |
| 108 return nullptr; | 108 return nullptr; |
| 109 } | 109 } |
| 110 | 110 |
| 111 if (unit == CSSPrimitiveValue::UnitType::Number) { | 111 if (unit == CSSPrimitiveValue::UnitType::Number) { |
| 112 bool quirksMode = isQuirksModeBehavior(cssParserMode); | 112 if (cssParserMode == SVGAttributeMode) |
| 113 bool svgMode = cssParserMode == SVGAttributeMode; | 113 unit = CSSPrimitiveValue::UnitType::UserUnits; |
| 114 if (number && (!quirksMode && !svgMode)) | 114 else if (!number) |
| 115 unit = CSSPrimitiveValue::UnitType::Pixels; |
| 116 else |
| 115 return nullptr; | 117 return nullptr; |
| 116 if (svgMode) | |
| 117 unit = CSSPrimitiveValue::UnitType::UserUnits; | |
| 118 else | |
| 119 unit = CSSPrimitiveValue::UnitType::Pixels; | |
| 120 } | 118 } |
| 119 |
| 121 if (number < 0 && !acceptsNegativeNumbers) | 120 if (number < 0 && !acceptsNegativeNumbers) |
| 122 return nullptr; | 121 return nullptr; |
| 123 | 122 |
| 124 return cssValuePool().createValue(number, unit); | 123 return cssValuePool().createValue(number, unit); |
| 125 } | 124 } |
| 126 | 125 |
| 127 static inline bool isColorPropertyID(CSSPropertyID propertyId) | 126 static inline bool isColorPropertyID(CSSPropertyID propertyId) |
| 128 { | 127 { |
| 129 switch (propertyId) { | 128 switch (propertyId) { |
| 130 case CSSPropertyColor: | 129 case CSSPropertyColor: |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 if (isColorPropertyID(propertyID)) | 1028 if (isColorPropertyID(propertyID)) |
| 1030 return parseColor(string, parserMode); | 1029 return parseColor(string, parserMode); |
| 1031 if (RefPtrWillBeRawPtr<CSSValue> keyword = parseKeywordValue(propertyID, str
ing)) | 1030 if (RefPtrWillBeRawPtr<CSSValue> keyword = parseKeywordValue(propertyID, str
ing)) |
| 1032 return keyword.release(); | 1031 return keyword.release(); |
| 1033 if (RefPtrWillBeRawPtr<CSSValue> transform = parseSimpleTransform(propertyID
, string)) | 1032 if (RefPtrWillBeRawPtr<CSSValue> transform = parseSimpleTransform(propertyID
, string)) |
| 1034 return transform.release(); | 1033 return transform.release(); |
| 1035 return nullptr; | 1034 return nullptr; |
| 1036 } | 1035 } |
| 1037 | 1036 |
| 1038 } // namespace blink | 1037 } // namespace blink |
| OLD | NEW |