OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 template<typename CharType> | 90 template<typename CharType> |
91 float toFloat(const CharType* attribute, bool& isValid) | 91 float toFloat(const CharType* attribute, bool& isValid) |
92 { | 92 { |
93 // Make sure the is a valid floating point number | 93 // Make sure the is a valid floating point number |
94 // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floa ting-point-number | 94 // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floa ting-point-number |
95 unsigned lengthExcludingDescriptor = length - 1; | 95 unsigned lengthExcludingDescriptor = length - 1; |
96 if (lengthExcludingDescriptor > 0 && *(attribute + start) == '+') { | 96 if (lengthExcludingDescriptor > 0 && *(attribute + start) == '+') { |
97 isValid = false; | 97 isValid = false; |
98 return 0; | 98 return 0; |
99 } | 99 } |
100 return charactersToFloat(attribute + start, lengthExcludingDescriptor, & isValid); | 100 Decimal result = parseToDecimalForNumberType(String(attribute + start, l engthExcludingDescriptor)); |
101 isValid = result.isFinite(); | |
102 if (!isValid) | |
103 return 0; | |
104 return clampTo<float>(result.toDouble()); | |
tkent
2015/08/25 10:02:46
This looks to have a behavior change for numbers g
Yoav Weiss
2015/08/25 10:07:58
I didn't mean for that to be a behavior change. Is
tkent
2015/08/25 10:14:23
AFAIK, static_cast<float>(greater-than-float-max)
| |
101 } | 105 } |
102 }; | 106 }; |
103 | 107 |
104 template<typename CharType> | 108 template<typename CharType> |
105 static void appendDescriptorAndReset(const CharType* attributeStart, const CharT ype*& descriptorStart, const CharType* position, Vector<DescriptorToken>& descri ptors) | 109 static void appendDescriptorAndReset(const CharType* attributeStart, const CharT ype*& descriptorStart, const CharType* position, Vector<DescriptorToken>& descri ptors) |
106 { | 110 { |
107 if (position > descriptorStart) | 111 if (position > descriptorStart) |
108 descriptors.append(DescriptorToken(descriptorStart - attributeStart, pos ition - descriptorStart)); | 112 descriptors.append(DescriptorToken(descriptorStart - attributeStart, pos ition - descriptorStart)); |
109 descriptorStart = 0; | 113 descriptorStart = 0; |
110 } | 114 } |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 Vector<ImageCandidate> imageCandidates; | 435 Vector<ImageCandidate> imageCandidates; |
432 imageCandidates.append(srcsetImageCandidate); | 436 imageCandidates.append(srcsetImageCandidate); |
433 | 437 |
434 if (!srcAttribute.isEmpty()) | 438 if (!srcAttribute.isEmpty()) |
435 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng th(), DescriptorParsingResult(), ImageCandidate::SrcOrigin)); | 439 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng th(), DescriptorParsingResult(), ImageCandidate::SrcOrigin)); |
436 | 440 |
437 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates ).toString(); | 441 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates ).toString(); |
438 } | 442 } |
439 | 443 |
440 } | 444 } |
OLD | NEW |