Changeset 205663 in webkit
- Timestamp:
- Sep 8, 2016 2:31:54 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r205661 r205663 1 2016-09-08 Chris Dumez <cdumez@apple.com> 2 3 Update parseHTMLNonNegativeInteger() to return an unsigned value 4 https://bugs.webkit.org/show_bug.cgi?id=161759 5 6 Reviewed by Alex Christensen. 7 8 Update parseHTMLNonNegativeInteger() to return an unsigned value instead 9 of a signed one as the value can never be negative. 10 11 * html/HTMLElement.cpp: 12 (WebCore::HTMLElement::parseBorderWidthAttribute): 13 * html/HTMLImageElement.cpp: 14 (WebCore::HTMLImageElement::width): 15 (WebCore::HTMLImageElement::height): 16 * html/HTMLInputElement.cpp: 17 (WebCore::HTMLInputElement::maxLengthAttributeChanged): 18 (WebCore::HTMLInputElement::minLengthAttributeChanged): 19 * html/HTMLTextAreaElement.cpp: 20 (WebCore::HTMLTextAreaElement::maxLengthAttributeChanged): 21 (WebCore::HTMLTextAreaElement::minLengthAttributeChanged): 22 * html/ImageInputType.cpp: 23 (WebCore::ImageInputType::height): 24 (WebCore::ImageInputType::width): 25 * html/parser/HTMLParserIdioms.cpp: 26 (WebCore::parseHTMLNonNegativeInteger): 27 (WebCore::parseHTTPRefreshInternal): 28 * html/parser/HTMLParserIdioms.h: 29 1 30 2016-09-08 Said Abou-Hallawa <sabouhallawa@apple.com> 2 31 -
trunk/Source/WebCore/html/HTMLElement.cpp
r205468 r205663 103 103 unsigned HTMLElement::parseBorderWidthAttribute(const AtomicString& value) const 104 104 { 105 if (Optional< int> borderWidth = parseHTMLNonNegativeInteger(value))105 if (Optional<unsigned> borderWidth = parseHTMLNonNegativeInteger(value)) 106 106 return borderWidth.value(); 107 107 -
trunk/Source/WebCore/html/HTMLImageElement.cpp
r205655 r205663 381 381 if (!renderer()) { 382 382 // check the attribute first for an explicit pixel value 383 Optional< int> width = parseHTMLNonNegativeInteger(attributeWithoutSynchronization(widthAttr));383 Optional<unsigned> width = parseHTMLNonNegativeInteger(attributeWithoutSynchronization(widthAttr)); 384 384 if (width) 385 385 return width.value(); … … 406 406 if (!renderer()) { 407 407 // check the attribute first for an explicit pixel value 408 Optional< int> height = parseHTMLNonNegativeInteger(attributeWithoutSynchronization(heightAttr));408 Optional<unsigned> height = parseHTMLNonNegativeInteger(attributeWithoutSynchronization(heightAttr)); 409 409 if (height) 410 410 return height.value(); -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r205524 r205663 1786 1786 { 1787 1787 unsigned oldEffectiveMaxLength = effectiveMaxLength(); 1788 setMaxLength(parseHTMLNonNegativeInteger(newValue).valueOr(-1)); 1788 if (Optional<unsigned> maxLength = parseHTMLNonNegativeInteger(newValue)) 1789 setMaxLength(maxLength.value()); 1790 else 1791 setMaxLength(-1); 1792 1789 1793 if (oldEffectiveMaxLength != effectiveMaxLength()) 1790 1794 updateValueIfNeeded(); … … 1798 1802 { 1799 1803 int oldMinLength = minLength(); 1800 setMinLength(parseHTMLNonNegativeInteger(newValue).valueOr(-1)); 1804 if (Optional<unsigned> minLength = parseHTMLNonNegativeInteger(newValue)) 1805 setMinLength(minLength.value()); 1806 else 1807 setMinLength(-1); 1808 1801 1809 if (oldMinLength != minLength()) 1802 1810 updateValueIfNeeded(); -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r205524 r205663 206 206 void HTMLTextAreaElement::maxLengthAttributeChanged(const AtomicString& newValue) 207 207 { 208 setMaxLength(parseHTMLNonNegativeInteger(newValue).valueOr(-1)); 208 if (Optional<unsigned> maxLength = parseHTMLNonNegativeInteger(newValue)) 209 setMaxLength(maxLength.value()); 210 else 211 setMaxLength(-1); 212 209 213 updateValidity(); 210 214 } … … 212 216 void HTMLTextAreaElement::minLengthAttributeChanged(const AtomicString& newValue) 213 217 { 214 setMinLength(parseHTMLNonNegativeInteger(newValue).valueOr(-1)); 218 if (Optional<unsigned> minLength = parseHTMLNonNegativeInteger(newValue)) 219 setMinLength(minLength.value()); 220 else 221 setMinLength(-1); 222 215 223 updateValidity(); 216 224 } -
trunk/Source/WebCore/html/ImageInputType.cpp
r205249 r205663 177 177 if (!element->renderer()) { 178 178 // Check the attribute first for an explicit pixel value. 179 if (Optional< int> height = parseHTMLNonNegativeInteger(element->attributeWithoutSynchronization(heightAttr)))179 if (Optional<unsigned> height = parseHTMLNonNegativeInteger(element->attributeWithoutSynchronization(heightAttr))) 180 180 return height.value(); 181 181 … … 198 198 if (!element->renderer()) { 199 199 // Check the attribute first for an explicit pixel value. 200 if (Optional< int> width = parseHTMLNonNegativeInteger(element->attributeWithoutSynchronization(widthAttr)))200 if (Optional<unsigned> width = parseHTMLNonNegativeInteger(element->attributeWithoutSynchronization(widthAttr))) 201 201 return width.value(); 202 202 -
trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp
r205515 r205663 208 208 209 209 // https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-non-negative-integers 210 Optional< int> parseHTMLNonNegativeInteger(const String& input)210 Optional<unsigned> parseHTMLNonNegativeInteger(const String& input) 211 211 { 212 212 Optional<int> signedValue = parseHTMLInteger(input); … … 214 214 return Nullopt; 215 215 216 return s ignedValue;216 return static_cast<unsigned>(signedValue.value()); 217 217 } 218 218 … … 364 364 ++position; 365 365 366 Optional< int> number = parseHTMLNonNegativeInteger(StringView(numberStart, position - numberStart).toStringWithoutCopying());366 Optional<unsigned> number = parseHTMLNonNegativeInteger(StringView(numberStart, position - numberStart).toStringWithoutCopying()); 367 367 if (!number) 368 368 return false; -
trunk/Source/WebCore/html/parser/HTMLParserIdioms.h
r205515 r205663 66 66 67 67 // http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-non-negative-integers 68 WEBCORE_EXPORT Optional< int> parseHTMLNonNegativeInteger(const String&);68 WEBCORE_EXPORT Optional<unsigned> parseHTMLNonNegativeInteger(const String&); 69 69 70 70 // https://html.spec.whatwg.org/#valid-non-negative-integer
Note: See TracChangeset
for help on using the changeset viewer.