Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7a59ef69ef562614ed25ae6bd54081a674e44d23
      
https://github.com/WebKit/WebKit/commit/7a59ef69ef562614ed25ae6bd54081a674e44d23
  Author: Anne van Kesteren <[email protected]>
  Date:   2026-05-04 (Mon, 04 May 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-width-height-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/svg-img-density-vs-zoom-expected.txt
    M Source/WebCore/html/HTMLImageElement.cpp
    M Source/WebCore/html/HTMLImageElement.h
    M Source/WebCore/loader/cache/CachedImage.cpp
    M Source/WebCore/loader/cache/CachedImage.h
    M Source/WebCore/platform/graphics/GeneratedImage.h
    M Source/WebCore/platform/graphics/Image.h
    M Source/WebCore/rendering/RenderImageResource.cpp
    M Source/WebCore/rendering/svg/RenderSVGRoot.cpp
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.cpp
    M Source/WebCore/style/values/images/kinds/StyleCachedImage.cpp
    M Source/WebCore/svg/graphics/SVGImage.cpp
    M Source/WebCore/svg/graphics/SVGImage.h

  Log Message:
  -----------
  Improve <img>'s naturalWidth & naturalHeight with SVG images
https://bugs.webkit.org/show_bug.cgi?id=284341
rdar://141196049

Reviewed by Said Abou-Hallawa (OOPS\!).

For SVG images that lack some intrinsic dimensions, we need to use the
300 x 150 CSS defaults for naturalWidth & naturalHeight. However,
srcset's density should only scale intrinsic dimensions, not these
defaults. This is standardized in HTML and more background is
available here:

    https://github.com/whatwg/html/issues/11287

To fix this we add SVGImage::resolvedIntrinsicSize(density) which
resolves missing dimensions using the defaults and the aspect ratio, if
any, applying density only to intrinsic dimensions. We add
SVGImage::hasIntrinsicWidth/Height() (and the corresponding Image
virtuals) so callers can query which dimensions exist.

We thread a density parameter through CachedImage's sizing methods
(separate from the existing multiplier) so that
StyleCachedImage::imageSize() can pass it from the renderer's
imageDevicePixelRatio to internalImageSizeForRenderer().

Canonical link: https://commits.webkit.org/312552@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to