Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSParserToken.cpp

Issue 1914693002: Clamp CSS numbers to float range at parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "core/css/parser/CSSParserToken.h" 5 #include "core/css/parser/CSSParserToken.h"
6 6
7 #include "core/css/CSSMarkup.h" 7 #include "core/css/CSSMarkup.h"
8 #include "core/css/parser/CSSPropertyParser.h" 8 #include "core/css/parser/CSSPropertyParser.h"
9 #include "wtf/HashMap.h" 9 #include "wtf/HashMap.h"
10 #include "wtf/text/StringBuilder.h" 10 #include "wtf/text/StringBuilder.h"
(...skipping 23 matching lines...) Expand all
34 initValueFromCSSParserString(value); 34 initValueFromCSSParserString(value);
35 m_id = -1; 35 m_id = -1;
36 } 36 }
37 37
38 CSSParserToken::CSSParserToken(CSSParserTokenType type, double numericValue, Num ericValueType numericValueType, NumericSign sign) 38 CSSParserToken::CSSParserToken(CSSParserTokenType type, double numericValue, Num ericValueType numericValueType, NumericSign sign)
39 : m_type(type) 39 : m_type(type)
40 , m_blockType(NotBlock) 40 , m_blockType(NotBlock)
41 , m_numericValueType(numericValueType) 41 , m_numericValueType(numericValueType)
42 , m_numericSign(sign) 42 , m_numericSign(sign)
43 , m_unit(static_cast<unsigned>(CSSPrimitiveValue::UnitType::Number)) 43 , m_unit(static_cast<unsigned>(CSSPrimitiveValue::UnitType::Number))
44 , m_numericValue(numericValue)
45 { 44 {
45 if (!std::isfinite(numericValue)) {
46 m_numericValue = 0.0;
rune 2016/04/25 12:24:29 Shouldn't +/-inf be clamped too? Why is 0 a good
47 } else {
48 m_numericValue = clampTo<float>(numericValue);
49 }
46 ASSERT(type == NumberToken); 50 ASSERT(type == NumberToken);
47 } 51 }
48 52
49 CSSParserToken::CSSParserToken(CSSParserTokenType type, UChar32 start, UChar32 e nd) 53 CSSParserToken::CSSParserToken(CSSParserTokenType type, UChar32 start, UChar32 e nd)
50 : m_type(UnicodeRangeToken) 54 : m_type(UnicodeRangeToken)
51 , m_blockType(NotBlock) 55 , m_blockType(NotBlock)
52 { 56 {
53 ASSERT_UNUSED(type, type == UnicodeRangeToken); 57 ASSERT_UNUSED(type, type == UnicodeRangeToken);
54 m_unicodeRange.start = start; 58 m_unicodeRange.start = start;
55 m_unicodeRange.end = end; 59 m_unicodeRange.end = end;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 return builder.append('}'); 238 return builder.append('}');
235 239
236 case EOFToken: 240 case EOFToken:
237 case CommentToken: 241 case CommentToken:
238 ASSERT_NOT_REACHED(); 242 ASSERT_NOT_REACHED();
239 return; 243 return;
240 } 244 }
241 } 245 }
242 246
243 } // namespace blink 247 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698