Changeset 279429 in webkit
- Timestamp:
- Jun 30, 2021 1:07:25 PM (13 months ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-syntax/decimal-points-in-numbers-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/parser/CSSParserFastPaths.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r279427 r279429 1 2021-06-30 Darin Adler <darin@apple.com> 2 3 CSS specification prohibits numbers with trailing decimal point (e.g. "1.px"), but we allow them 4 https://bugs.webkit.org/show_bug.cgi?id=227517 5 6 Reviewed by Sam Weinig. 7 8 * web-platform-tests/css/css-syntax/decimal-points-in-numbers-expected.txt: 9 Expect a pass instead of a fail. 10 1 11 2021-06-30 Chris Dumez <cdumez@apple.com> 2 12 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-syntax/decimal-points-in-numbers-expected.txt
r267650 r279429 5 5 PASS decimal point between digits is valid in a dimension 6 6 PASS decimal point before digits is valid in a dimension 7 FAIL decimal point after digits is invalid in a dimension assert_not_equals: got disallowed value "1px" 7 PASS decimal point after digits is invalid in a dimension 8 8 -
trunk/Source/WebCore/ChangeLog
r279424 r279429 1 2021-06-30 Darin Adler <darin@apple.com> 2 3 CSS specification prohibits numbers with trailing decimal point (e.g. "1.px"), but we allow them 4 https://bugs.webkit.org/show_bug.cgi?id=227517 5 6 Reviewed by Sam Weinig. 7 8 Test: imported/w3c/web-platform-tests/css/css-syntax/decimal-points-in-numbers.html 9 10 * css/parser/CSSParserFastPaths.cpp: 11 (WebCore::parseCSSNumber): Added. Checks for the trailing decimal point. Also uses 12 std::optional instead of a bool plus an out argument; should refactor the other functions 13 to work that way at some point. 14 (WebCore::parseSimpleLength): Use parseCSSNumber and isASCIIAlphaCaselessEqual. 15 (WebCore::parseSimpleAngle): Ditto. 16 (WebCore::parseTransformNumberArguments): Ditto. 17 1 18 2021-06-30 Kimmo Kinnunen <kkinnunen@apple.com> 2 19 -
trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp
r278253 r279429 100 100 } 101 101 102 template<typename CharacterType> static inline std::optional<double> parseCSSNumber(const CharacterType* characters, unsigned length) 103 { 104 // The charactersToDouble() function allows a trailing '.' but that is not allowed in CSS number values. 105 if (length && characters[length - 1] == '.') 106 return std::nullopt; 107 // FIXME: If we don't want to skip over leading spaces, we should use parseDouble, not charactersToDouble. 108 bool ok; 109 auto number = charactersToDouble(characters, length, &ok); 110 if (!ok) 111 return std::nullopt; 112 return number; 113 } 114 102 115 template <typename CharacterType> 103 116 static inline bool parseSimpleLength(const CharacterType* characters, unsigned length, CSSUnitType& unit, double& number) 104 117 { 105 if (length > 2 && (characters[length - 2] | 0x20) == 'p' && (characters[length - 1] | 0x20) == 'x') {118 if (length > 2 && isASCIIAlphaCaselessEqual(characters[length - 2], 'p') && isASCIIAlphaCaselessEqual(characters[length - 1], 'x')) { 106 119 length -= 2; 107 120 unit = CSSUnitType::CSS_PX; … … 111 124 } 112 125 113 // We rely on charactersToDouble for validation as well. The function 114 // will set "ok" to "false" if the entire passed-in character range does 115 // not represent a double. 116 bool ok; 117 number = charactersToDouble(characters, length, &ok); 118 if (!ok) 119 return false; 120 return true; 126 auto parsedNumber = parseCSSNumber(characters, length); 127 number = parsedNumber.value_or(0); 128 return parsedNumber.has_value(); 121 129 } 122 130 … … 128 136 return false; 129 137 130 if ( (characters[length - 3] | 0x20) == 'd' && (characters[length - 2] | 0x20) == 'e' && (characters[length - 1] | 0x20) == 'g') {138 if (isASCIIAlphaCaselessEqual(characters[length - 3], 'd') && isASCIIAlphaCaselessEqual(characters[length - 2], 'e') && isASCIIAlphaCaselessEqual(characters[length - 1], 'g')) { 131 139 length -= 3; 132 140 unit = CSSUnitType::CSS_DEG; 133 } else if ( (characters[length - 3] | 0x20) == 'r' && (characters[length - 2] | 0x20) == 'a' && (characters[length - 1] | 0x20) == 'd') {141 } else if (isASCIIAlphaCaselessEqual(characters[length - 3], 'r') && isASCIIAlphaCaselessEqual(characters[length - 2], 'a') && isASCIIAlphaCaselessEqual(characters[length - 1], 'd')) { 134 142 length -= 3; 135 143 unit = CSSUnitType::CSS_RAD; … … 137 145 return false; 138 146 139 // We rely on charactersToDouble for validation as well. The function 140 // will set "ok" to "false" if the entire passed-in character range does 141 // not represent a double. 142 bool ok; 143 number = charactersToDouble(characters, length, &ok); 144 if (!ok) 145 return false; 146 return true; 147 auto parsedNumber = parseCSSNumber(characters, length); 148 number = parsedNumber.value_or(0); 149 return parsedNumber.has_value(); 147 150 } 148 151 … … 1169 1172 return false; 1170 1173 unsigned argumentLength = static_cast<unsigned>(delimiter); 1171 bool ok; 1172 double number = charactersToDouble(pos, argumentLength, &ok); 1173 if (!ok) 1174 auto number = parseCSSNumber(pos, argumentLength); 1175 if (!number) 1174 1176 return false; 1175 transformValue->append(CSSPrimitiveValue::create( number, CSSUnitType::CSS_NUMBER));1177 transformValue->append(CSSPrimitiveValue::create(*number, CSSUnitType::CSS_NUMBER)); 1176 1178 pos += argumentLength + 1; 1177 1179 --expectedCount;
Note: See TracChangeset
for help on using the changeset viewer.