Changeset 254229 in webkit
- Timestamp:
- Jan 8, 2020 3:38:47 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r254193 r254229 1 2020-01-08 Noam Rosenthal <noam@webkit.org> 2 3 <img>.naturalWidth should return the density-corrected intrinsic width 4 https://bugs.webkit.org/show_bug.cgi?id=150443 5 6 Reviewed by Simon Fraser. 7 8 Updated expected results. 9 10 * web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt: 11 All tests now pass. 12 13 * web-platform-tests/html/semantics/embedded-content/the-img-element/intrinsicsize/intrinsicsize-with-responsive-images.tentative-expected.txt: 14 Still fails but failure values are different. 15 1 16 2020-01-08 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 17 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt
r206240 r254229 2 2 PASS <img src="/images/green-256x256.png" data-expect="256"> 3 3 PASS <img srcset="/images/green-256x256.png 1x" data-expect="256"> 4 FAIL <img srcset="/images/green-256x256.png 1.6x" data-expect="160"> assert_equals: naturalWidth expected 160 but got 256 5 FAIL <img srcset="/images/green-256x256.png 2x" data-expect="128"> assert_equals: naturalWidth expected 128 but got 256 6 FAIL <img srcset="/images/green-256x256.png 10000x" data-expect="0"> assert_equals: naturalWidth expected 0 but got 256 4 PASS <img srcset="/images/green-256x256.png 1.6x" data-expect="160"> 5 PASS <img srcset="/images/green-256x256.png 2x" data-expect="128"> 6 PASS <img srcset="/images/green-256x256.png 10000x" data-expect="0"> 7 7 PASS <img srcset="/images/green-256x256.png 9e99999999999999999999999x" data-expect="0"> 8 8 PASS <img srcset="/images/green-256x256.png 256w" sizes="256px" data-expect="256"> 9 FAIL <img srcset="/images/green-256x256.png 512w" sizes="256px" data-expect="128"> assert_equals: naturalWidth expected 128 but got 256 10 FAIL <img srcset="/images/green-256x256.png 256w" sizes="512px" data-expect="512"> assert_equals: naturalWidth expected 512 but got 256 11 FAIL <img srcset="/images/green-256x256.png 256w" sizes="1px" data-expect="1"> assert_equals: naturalWidth expected 1 but got 256 12 FAIL <img srcset="/images/green-256x256.png 256w" sizes="0px" data-expect="0"> assert_equals: naturalWidth expected 0 but got 256 9 PASS <img srcset="/images/green-256x256.png 512w" sizes="256px" data-expect="128"> 10 PASS <img srcset="/images/green-256x256.png 256w" sizes="512px" data-expect="512"> 11 PASS <img srcset="/images/green-256x256.png 256w" sizes="1px" data-expect="1"> 12 PASS <img srcset="/images/green-256x256.png 256w" sizes="0px" data-expect="0"> 13 13 PASS <img srcset="data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='-1%20-1%202%202'%20width='20'%20height='20'><circle%20r='1'/></svg> 2x" data-expect="10"> 14 14 PASS <img srcset="data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='-1%20-1%202%202'%20width='20'><circle%20r='1'/></svg> 2x" data-expect="10"> -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/intrinsicsize/intrinsicsize-with-responsive-images.tentative-expected.txt
r242595 r254229 6 6 FAIL Test image /images/green.png with no specified sizes, width, or height assert_equals: width expected 400 but got 33 7 7 FAIL Test image /images/green.png with width = 800, no specified sizes, or height assert_equals: height expected 1000 but got 400 8 FAIL Test image /images/green.png with width = 800, height = 800, and no specified sizes assert_equals: naturalWidth expected 400 but got 1008 FAIL Test image /images/green.png with width = 800, height = 800, and no specified sizes assert_equals: naturalWidth expected 400 but got 33 9 9 FAIL Test image (32 x 32) with sizes = 100 and srcset descriptor = 32w assert_equals: height expected 125 but got 100 10 10 -
trunk/Source/WebCore/ChangeLog
r254228 r254229 1 2020-01-08 Noam Rosenthal <noam@webkit.org> 2 3 <img>.naturalWidth should return the density-corrected intrinsic width 4 https://bugs.webkit.org/show_bug.cgi?id=150443 5 6 Reviewed by Simon Fraser. 7 8 Take image's density into account when requesting naturalWidth/naturalHeight, not in SVG. 9 10 This now complies with the standard (https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-naturalwidth) 11 It also matches the behavior on Chrome and on Firefox. 12 13 Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic.html 14 Updaded expected results 15 16 * html/HTMLImageElement.cpp: 17 (WebCore::HTMLImageElement::effectiveImageDevicePixelRatio const): 18 (WebCore::HTMLImageElement::naturalWidth const): 19 (WebCore::HTMLImageElement::naturalHeight const): 20 * html/HTMLImageElement.h: 21 Use effective image devicePixelRatio for naturalWidth/height calculation 22 23 * loader/cache/CachedImage.cpp: 24 (WebCore::CachedImage::unclampedImageSizeForRenderer const): 25 (WebCore::CachedImage::imageSizeForRenderer const): 26 * loader/cache/CachedImage.h: 27 Don't clamp to 1 when calculating naturalWidth/naturalHeight, as this has 28 nothing to do with zoomed images. Zoomed images behavior remains the same. 29 1 30 2020-01-08 Devin Rousso <drousso@apple.com> 2 31 -
trunk/Source/WebCore/html/HTMLImageElement.cpp
-
Property
svn:executable
set to
*
r253975 r254229 532 532 } 533 533 534 float HTMLImageElement::effectiveImageDevicePixelRatio() const 535 { 536 if (!m_imageLoader->image()) 537 return 1.0f; 538 539 auto* image = m_imageLoader->image()->image(); 540 541 if (image && image->isSVGImage()) 542 return 1.0f; 543 544 return m_imageDevicePixelRatio; 545 } 546 534 547 int HTMLImageElement::naturalWidth() const 535 548 { … … 537 550 return 0; 538 551 539 return m_imageLoader->image()-> imageSizeForRenderer(renderer(), 1.0f).width();552 return m_imageLoader->image()->unclampedImageSizeForRenderer(renderer(), effectiveImageDevicePixelRatio()).width(); 540 553 } 541 554 … … 545 558 return 0; 546 559 547 return m_imageLoader->image()-> imageSizeForRenderer(renderer(), 1.0f).height();560 return m_imageLoader->image()->unclampedImageSizeForRenderer(renderer(), effectiveImageDevicePixelRatio()).height(); 548 561 } 549 562 -
Property
svn:executable
set to
-
trunk/Source/WebCore/html/HTMLImageElement.h
r252828 r254229 178 178 179 179 void copyNonAttributePropertiesFromElement(const Element&) final; 180 181 float effectiveImageDevicePixelRatio() const; 180 182 181 183 #if ENABLE(SERVICE_CONTROLS) -
trunk/Source/WebCore/loader/cache/CachedImage.cpp
r249364 r254229 287 287 } 288 288 289 LayoutSize CachedImage::imageSizeForRenderer(const RenderElement* renderer, float multiplier, SizeType sizeType) const 289 290 LayoutSize CachedImage::unclampedImageSizeForRenderer(const RenderElement* renderer, float multiplier, SizeType sizeType) const 290 291 { 291 292 LayoutSize imageSize = LayoutSize(imageSizeForRenderer(renderer, sizeType)); … … 293 294 return imageSize; 294 295 295 // Don't let images that have a width/height >= 1 shrink below 1 when zoomed.296 296 float widthScale = m_image->hasRelativeWidth() ? 1.0f : multiplier; 297 297 float heightScale = m_image->hasRelativeHeight() ? 1.0f : multiplier; 298 imageSize.scale(widthScale, heightScale); 299 return imageSize; 300 } 301 302 LayoutSize CachedImage::imageSizeForRenderer(const RenderElement* renderer, float multiplier, SizeType sizeType) const 303 { 304 auto imageSize = unclampedImageSizeForRenderer(renderer, multiplier, sizeType); 305 if (imageSize.isEmpty() || multiplier == 1.0f) 306 return imageSize; 307 308 // Don't let images that have a width/height >= 1 shrink below 1 when zoomed. 298 309 LayoutSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0 ? 1 : 0); 299 imageSize.scale(widthScale, heightScale);300 310 imageSize.clampToMinimumSize(minimumSize); 311 301 312 ASSERT(multiplier != 1.0f || (imageSize.width().fraction() == 0.0f && imageSize.height().fraction() == 0.0f)); 302 313 return imageSize; -
trunk/Source/WebCore/loader/cache/CachedImage.h
r251708 r254229 79 79 // This method takes a zoom multiplier that can be used to increase the natural size of the image by the zoom. 80 80 LayoutSize imageSizeForRenderer(const RenderElement*, float multiplier, SizeType = UsedSize) const; // returns the size of the complete image. 81 LayoutSize unclampedImageSizeForRenderer(const RenderElement* renderer, float multiplier, SizeType = UsedSize) const; 81 82 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio); 82 83
Note: See TracChangeset
for help on using the changeset viewer.