Changeset 205655 in webkit
- Timestamp:
- Sep 8, 2016 12:46:10 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r205653 r205655 1 2016-09-08 Chris Dumez <cdumez@apple.com> 2 3 HTMLImageElement.width / height attributes should be unsigned 4 https://bugs.webkit.org/show_bug.cgi?id=161730 5 6 Reviewed by Alex Christensen. 7 8 Update existing test to reflect behavior change. 9 10 * js/dom/custom-constructors-expected.txt: 11 * js/dom/script-tests/custom-constructors.js: 12 1 13 2016-09-08 Commit Queue <commit-queue@webkit.org> 2 14 -
trunk/LayoutTests/imported/w3c/ChangeLog
r205565 r205655 1 2016-09-08 Chris Dumez <cdumez@apple.com> 2 3 HTMLImageElement.width / height attributes should be unsigned 4 https://bugs.webkit.org/show_bug.cgi?id=161730 5 6 Reviewed by Alex Christensen. 7 8 Rebaseline W3C test now that more checks are passing. 9 10 * web-platform-tests/html/dom/reflection-embedded-expected.txt: 11 1 12 2016-09-07 Chris Dumez <cdumez@apple.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt
r204090 r205655 1148 1148 PASS img.width: IDL set to "-0" followed by IDL get 1149 1149 PASS img.width: IDL set to 2147483648 should not throw 1150 FAIL img.width: IDL set to 2147483648 followed by getAttribute() assert_equals: expected "0" but got "-2147483648" 1151 FAIL img.width: IDL set to 2147483648 followed by IDL get assert_equals: expected 0 but got -2147483648 1150 PASS img.width: IDL set to 2147483648 followed by getAttribute() 1151 PASS img.width: IDL set to 2147483648 followed by IDL get 1152 1152 PASS img.width: IDL set to 4294967295 should not throw 1153 FAIL img.width: IDL set to 4294967295 followed by getAttribute() assert_equals: expected "0" but got "-1" 1154 FAIL img.width: IDL set to 4294967295 followed by IDL get assert_equals: expected 0 but got -1 1153 PASS img.width: IDL set to 4294967295 followed by getAttribute() 1154 PASS img.width: IDL set to 4294967295 followed by IDL get 1155 1155 PASS img.height: typeof IDL attribute 1156 1156 PASS img.height: IDL get with DOM attribute unset … … 1171 1171 PASS img.height: IDL set to "-0" followed by IDL get 1172 1172 PASS img.height: IDL set to 2147483648 should not throw 1173 FAIL img.height: IDL set to 2147483648 followed by getAttribute() assert_equals: expected "0" but got "-2147483648" 1174 FAIL img.height: IDL set to 2147483648 followed by IDL get assert_equals: expected 0 but got -2147483648 1173 PASS img.height: IDL set to 2147483648 followed by getAttribute() 1174 PASS img.height: IDL set to 2147483648 followed by IDL get 1175 1175 PASS img.height: IDL set to 4294967295 should not throw 1176 FAIL img.height: IDL set to 4294967295 followed by getAttribute() assert_equals: expected "0" but got "-1" 1177 FAIL img.height: IDL set to 4294967295 followed by IDL get assert_equals: expected 0 but got -1 1176 PASS img.height: IDL set to 4294967295 followed by getAttribute() 1177 PASS img.height: IDL set to 4294967295 followed by IDL get 1178 1178 PASS img.name: typeof IDL attribute 1179 1179 PASS img.name: IDL get with DOM attribute unset -
trunk/LayoutTests/js/dom/custom-constructors-expected.txt
r189507 r205655 10 10 PASS new Image(100).width is 100 11 11 PASS new Image(100, 200).height is 200 12 PASS new Image(-100).width is -10013 PASS new Image(-100, -200).height is -20012 PASS new Image(-100).width is 0 13 PASS new Image(-100, -200).height is 0 14 14 PASS new Image().outerHTML is "<img>" 15 15 PASS new Image(100, 100).outerHTML.replace(/"/g, "'") is "<img width='100' height='100'>" -
trunk/LayoutTests/js/dom/script-tests/custom-constructors.js
r189507 r205655 11 11 shouldBe("new Image(100).width", "100"); 12 12 shouldBe("new Image(100, 200).height", "200"); 13 shouldBe("new Image(-100).width", " -100");14 shouldBe("new Image(-100, -200).height", " -200");13 shouldBe("new Image(-100).width", "0"); 14 shouldBe("new Image(-100, -200).height", "0"); 15 15 16 16 shouldBeEqualToString("new Image().outerHTML","<img>"); -
trunk/LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt
r204096 r205655 1148 1148 PASS img.width: IDL set to "-0" followed by IDL get 1149 1149 PASS img.width: IDL set to 2147483648 should not throw 1150 FAIL img.width: IDL set to 2147483648 followed by getAttribute() assert_equals: expected "0" but got "-2147483648" 1151 FAIL img.width: IDL set to 2147483648 followed by IDL get assert_equals: expected 0 but got -2147483648 1150 PASS img.width: IDL set to 2147483648 followed by getAttribute() 1151 PASS img.width: IDL set to 2147483648 followed by IDL get 1152 1152 PASS img.width: IDL set to 4294967295 should not throw 1153 FAIL img.width: IDL set to 4294967295 followed by getAttribute() assert_equals: expected "0" but got "-1" 1154 FAIL img.width: IDL set to 4294967295 followed by IDL get assert_equals: expected 0 but got -1 1153 PASS img.width: IDL set to 4294967295 followed by getAttribute() 1154 PASS img.width: IDL set to 4294967295 followed by IDL get 1155 1155 PASS img.height: typeof IDL attribute 1156 1156 PASS img.height: IDL get with DOM attribute unset … … 1171 1171 PASS img.height: IDL set to "-0" followed by IDL get 1172 1172 PASS img.height: IDL set to 2147483648 should not throw 1173 FAIL img.height: IDL set to 2147483648 followed by getAttribute() assert_equals: expected "0" but got "-2147483648" 1174 FAIL img.height: IDL set to 2147483648 followed by IDL get assert_equals: expected 0 but got -2147483648 1173 PASS img.height: IDL set to 2147483648 followed by getAttribute() 1174 PASS img.height: IDL set to 2147483648 followed by IDL get 1175 1175 PASS img.height: IDL set to 4294967295 should not throw 1176 FAIL img.height: IDL set to 4294967295 followed by getAttribute() assert_equals: expected "0" but got "-1" 1177 FAIL img.height: IDL set to 4294967295 followed by IDL get assert_equals: expected 0 but got -1 1176 PASS img.height: IDL set to 4294967295 followed by getAttribute() 1177 PASS img.height: IDL set to 4294967295 followed by IDL get 1178 1178 PASS img.name: typeof IDL attribute 1179 1179 PASS img.name: IDL get with DOM attribute unset -
trunk/Source/WebCore/ChangeLog
r205654 r205655 1 2016-09-08 Chris Dumez <cdumez@apple.com> 2 3 HTMLImageElement.width / height attributes should be unsigned 4 https://bugs.webkit.org/show_bug.cgi?id=161730 5 6 Reviewed by Alex Christensen. 7 8 HTMLImageElement.width / height attributes should be unsigned as per 9 the HTML specification: 10 - https://html.spec.whatwg.org/#htmlimageelement 11 12 However, they are signed in WebKit. Firefox agrees with the 13 specification. 14 15 No new tests, rebaselined existing test. 16 17 * bindings/js/JSImageConstructor.cpp: 18 (WebCore::JSImageConstructor::construct): 19 (WebCore::createImageConstructor): Deleted. 20 * html/HTMLImageElement.cpp: 21 (WebCore::HTMLImageElement::createForJSConstructor): 22 (WebCore::HTMLImageElement::width): 23 (WebCore::HTMLImageElement::height): 24 (WebCore::HTMLImageElement::setHeight): 25 (WebCore::HTMLImageElement::setWidth): 26 * html/HTMLImageElement.h: 27 * html/HTMLImageElement.idl: 28 * html/ImageDocument.cpp: 29 (WebCore::ImageDocument::restoreImageSize): 30 1 31 2016-09-08 Filip Pizlo <fpizlo@apple.com> 2 32 -
trunk/Source/WebCore/bindings/js/JSImageConstructor.cpp
r205198 r205655 59 59 // will be called, which will cause the image element to be marked if necessary. 60 60 toJS(state, jsConstructor->globalObject(), *document); 61 int width; 62 int height; 63 int* optionalWidth = 0; 64 int* optionalHeight = 0; 61 Optional<unsigned> width; 62 Optional<unsigned> height; 65 63 if (state->argumentCount() > 0) { 66 width = state->argument(0).toInt32(state); 67 optionalWidth = &width; 68 } 69 if (state->argumentCount() > 1) { 70 height = state->argument(1).toInt32(state); 71 optionalHeight = &height; 64 width = state->uncheckedArgument(0).toUInt32(state); 65 if (state->argumentCount() > 1) 66 height = state->uncheckedArgument(1).toUInt32(state); 72 67 } 73 68 74 69 return JSValue::encode(asObject(toJS(state, jsConstructor->globalObject(), 75 HTMLImageElement::createForJSConstructor(*document, optionalWidth, optionalHeight))));70 HTMLImageElement::createForJSConstructor(*document, width, height)))); 76 71 } 77 72 -
trunk/Source/WebCore/html/HTMLImageElement.cpp
r203383 r205655 90 90 } 91 91 92 Ref<HTMLImageElement> HTMLImageElement::createForJSConstructor(Document& document, const int* optionalWidth, const int* optionalHeight)93 { 94 Ref<HTMLImageElement>image = adoptRef(*new HTMLImageElement(imgTag, document));95 if ( optionalWidth)96 image->setWidth( *optionalWidth);97 if ( optionalHeight)98 image->setHeight( *optionalHeight);92 Ref<HTMLImageElement> HTMLImageElement::createForJSConstructor(Document& document, Optional<unsigned> width, Optional<unsigned> height) 93 { 94 auto image = adoptRef(*new HTMLImageElement(imgTag, document)); 95 if (width) 96 image->setWidth(width.value()); 97 if (height) 98 image->setHeight(height.value()); 99 99 return image; 100 100 } … … 377 377 } 378 378 379 intHTMLImageElement::width(bool ignorePendingStylesheets)379 unsigned HTMLImageElement::width(bool ignorePendingStylesheets) 380 380 { 381 381 if (!renderer()) { 382 382 // check the attribute first for an explicit pixel value 383 bool ok; 384 int width = attributeWithoutSynchronization(widthAttr).toInt(&ok); 385 if (ok) 386 return width; 383 Optional<int> width = parseHTMLNonNegativeInteger(attributeWithoutSynchronization(widthAttr)); 384 if (width) 385 return width.value(); 387 386 388 387 // if the image is available, use its width 389 388 if (m_imageLoader.image()) 390 return m_imageLoader.image()->imageSizeForRenderer(renderer(), 1.0f).width() ;389 return m_imageLoader.image()->imageSizeForRenderer(renderer(), 1.0f).width().toUnsigned(); 391 390 } 392 391 … … 403 402 } 404 403 405 intHTMLImageElement::height(bool ignorePendingStylesheets)404 unsigned HTMLImageElement::height(bool ignorePendingStylesheets) 406 405 { 407 406 if (!renderer()) { 408 407 // check the attribute first for an explicit pixel value 409 bool ok; 410 int height = attributeWithoutSynchronization(heightAttr).toInt(&ok); 411 if (ok) 412 return height; 408 Optional<int> height = parseHTMLNonNegativeInteger(attributeWithoutSynchronization(heightAttr)); 409 if (height) 410 return height.value(); 413 411 414 412 // if the image is available, use its height 415 413 if (m_imageLoader.image()) 416 return m_imageLoader.image()->imageSizeForRenderer(renderer(), 1.0f).height() ;414 return m_imageLoader.image()->imageSizeForRenderer(renderer(), 1.0f).height().toUnsigned(); 417 415 } 418 416 … … 502 500 } 503 501 504 void HTMLImageElement::setHeight( intvalue)505 { 506 set IntegralAttribute(heightAttr, value);502 void HTMLImageElement::setHeight(unsigned value) 503 { 504 setUnsignedIntegralAttribute(heightAttr, value); 507 505 } 508 506 … … 517 515 } 518 516 519 void HTMLImageElement::setWidth( intvalue)520 { 521 set IntegralAttribute(widthAttr, value);517 void HTMLImageElement::setWidth(unsigned value) 518 { 519 setUnsignedIntegralAttribute(widthAttr, value); 522 520 } 523 521 -
trunk/Source/WebCore/html/HTMLImageElement.h
r204717 r205655 40 40 static Ref<HTMLImageElement> create(Document&); 41 41 static Ref<HTMLImageElement> create(const QualifiedName&, Document&, HTMLFormElement*); 42 static Ref<HTMLImageElement> createForJSConstructor(Document&, const int* optionalWidth, const int* optionalHeight);42 static Ref<HTMLImageElement> createForJSConstructor(Document&, Optional<unsigned> width, Optional<unsigned> height); 43 43 44 44 virtual ~HTMLImageElement(); 45 45 46 WEBCORE_EXPORT intwidth(bool ignorePendingStylesheets = false);47 WEBCORE_EXPORT intheight(bool ignorePendingStylesheets = false);46 WEBCORE_EXPORT unsigned width(bool ignorePendingStylesheets = false); 47 WEBCORE_EXPORT unsigned height(bool ignorePendingStylesheets = false); 48 48 49 49 WEBCORE_EXPORT int naturalWidth() const; … … 65 65 WEBCORE_EXPORT const AtomicString& alt() const; 66 66 67 WEBCORE_EXPORT void setHeight( int);67 WEBCORE_EXPORT void setHeight(unsigned); 68 68 69 69 URL src() const; … … 73 73 WEBCORE_EXPORT String crossOrigin() const; 74 74 75 WEBCORE_EXPORT void setWidth( int);75 WEBCORE_EXPORT void setWidth(unsigned); 76 76 77 77 WEBCORE_EXPORT int x() const; -
trunk/Source/WebCore/html/HTMLImageElement.idl
r204259 r205655 28 28 [Reflect, TreatNullAs=EmptyString] attribute DOMString border; 29 29 attribute DOMString? crossOrigin; 30 attribute long height;30 attribute unsigned long height; 31 31 [Reflect] attribute long hspace; 32 32 [Reflect] attribute boolean isMap; … … 38 38 [Reflect] attribute DOMString useMap; 39 39 [Reflect] attribute long vspace; 40 attribute long width;40 attribute unsigned long width; 41 41 42 42 // Extensions -
trunk/Source/WebCore/html/ImageDocument.cpp
r205106 r205655 314 314 315 315 LayoutSize imageSize = this->imageSize(); 316 m_imageElement->setWidth(imageSize.width() );317 m_imageElement->setHeight(imageSize.height() );316 m_imageElement->setWidth(imageSize.width().toUnsigned()); 317 m_imageElement->setHeight(imageSize.height().toUnsigned()); 318 318 319 319 if (imageFitsInWindow())
Note: See TracChangeset
for help on using the changeset viewer.