Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d620932d8ce37cf83f60d5c50dace2d50fed4f80
https://github.com/WebKit/WebKit/commit/d620932d8ce37cf83f60d5c50dace2d50fed4f80
Author: Sam Weinig <[email protected]>
Date: 2026-09-27 (Sun, 27 Sep 2026)
Changed paths:
A LayoutTests/fast/canvas/createImageBitmap-svg-not-rendered-expected.txt
A LayoutTests/fast/canvas/createImageBitmap-svg-not-rendered.html
A LayoutTests/fast/canvas/createImageBitmap-svg-sized-by-image-expected.txt
A LayoutTests/fast/canvas/createImageBitmap-svg-sized-by-image.html
A
LayoutTests/fast/webcodecs/videoframe-from-image-orientation-and-density-expected.txt
A
LayoutTests/fast/webcodecs/videoframe-from-image-orientation-and-density.html
A
LayoutTests/fast/webcodecs/videoframe-from-svg-without-natural-size-expected.txt
A LayoutTests/fast/webcodecs/videoframe-from-svg-without-natural-size.html
M LayoutTests/http/wpt/webcodecs/videoFrame-rect.html
M
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/imagebitmap/createImageBitmap-invalid-args-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/imagebitmap/imagebitmap-replication-exif-orientation-expected.txt
M Source/WebCore/Headers.cmake
A Source/WebCore/Modules/webcodecs/VideoFrameImageSizing.h
M Source/WebCore/Modules/webcodecs/WebCodecsVideoFrame.cpp
M Source/WebCore/Modules/webcodecs/WebCodecsVideoFrame.h
M Source/WebCore/Modules/webcodecs/WebCodecsVideoFrame.idl
M Source/WebCore/Sources.txt
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
A Source/WebCore/html/ApplyImageDevicePixelRatio.h
M Source/WebCore/html/HTMLImageElement.cpp
M Source/WebCore/html/HTMLImageElement.h
M Source/WebCore/html/ImageBitmap.cpp
M Source/WebCore/html/ImageBitmap.h
A Source/WebCore/html/ImageRequestState.h
A Source/WebCore/html/canvas/CanvasDrawImageSizing.h
A Source/WebCore/html/canvas/CanvasImageSource+OriginClean.cpp
A Source/WebCore/html/canvas/CanvasImageSource+OriginClean.h
A Source/WebCore/html/canvas/CanvasImageSource+Usability.cpp
A Source/WebCore/html/canvas/CanvasImageSource+Usability.h
A Source/WebCore/html/canvas/CanvasImageSource.h
A Source/WebCore/html/canvas/CanvasPatternSizing.h
M Source/WebCore/html/canvas/CanvasRenderingContext.cpp
M Source/WebCore/html/canvas/CanvasRenderingContext.h
M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h
M Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
M Source/WebCore/html/canvas/WebGLRenderingContextBase.h
M Source/WebCore/inspector/InspectorCanvas.cpp
M Source/WebCore/loader/ImageLoader.cpp
M Source/WebCore/loader/ImageLoader.h
M Source/WebCore/loader/cache/CachedImage.cpp
M Source/WebCore/loader/cache/CachedImage.h
A Source/WebCore/platform/graphics/DefaultSizing.h
M Source/WebCore/platform/graphics/GraphicsContext.cpp
M Source/WebCore/platform/graphics/GraphicsContext.h
M Source/WebCore/platform/graphics/Image.cpp
M Source/WebCore/platform/graphics/Image.h
A Source/WebCore/platform/graphics/ImageSizingContext.cpp
A Source/WebCore/platform/graphics/ImageSizingContext.h
A Source/WebCore/platform/graphics/SizedImage.h
M Source/WebCore/svg/SVGImageElement.cpp
M Source/WebCore/svg/SVGImageElement.h
M Source/WebCore/svg/graphics/SVGImage.cpp
M Source/WebCore/svg/graphics/SVGImage.h
Log Message:
-----------
[Image Redux] Size canvas image sources with the CSS object size negotiation
https://bugs.webkit.org/show_bug.cgi?id=325314
Reviewed by Darin Adler.
Refactors usage of `CanvasImageSource` (canvas drawImage()/createPattern(),
createImageBitmap(), WebGL and VideoFrame) to use shared functionality
including adopting the new shared CSS object size negotiation.
Refactoring existing types and logic, the `CanvasImageSource` now has a single
definition in CanvasImageSource.h and the origin checks and image usability
checks each user performs were centralized into to new
CanvasImageSource+Usability.h
and CanvasImageSource+OriginClean.h headers. To aid this, HTMLImageElement and
SVGImageElement now have standard accessors for spec defined state like the
`currentRequestState`.
More central to the on going image sizing changes, these users now use the
shared CSS object size negotiation to get the appropriate size to draw at. The
system works by contexts defining their own `ImageSizingContext` subclass where
the inputs to their specific negotiation can be defined.
This change adds a default / fallback sizing context, `DefaultSizing`, for use
when specifications don't define what to do, which implements the default sizing
algorithm with the standard 300x150 default objects size.
Additionally it adds CanvasDrawImageSizing, CanvasPatternSizing and
VideoFrameImageSizing
contexts which implement specific rules from their corresponding specs.
CanvasDrawImageSizing is
also used by WebGL as it historically has just followed what canvas does.
While in their current form, these contexts might seem a bit like overkill, they
will be needed for implementing proper support for all CSS image types, some of
which, cross-fade() in particular, require passing in the context to be used
recursively.
Tests: fast/canvas/createImageBitmap-svg-not-rendered.html
fast/canvas/createImageBitmap-svg-sized-by-image.html
fast/webcodecs/videoframe-from-image-orientation-and-density.html
fast/webcodecs/videoframe-from-svg-without-natural-size.html
* LayoutTests/fast/canvas/createImageBitmap-svg-not-rendered-expected.txt:
Added.
* LayoutTests/fast/canvas/createImageBitmap-svg-not-rendered.html: Added.
* LayoutTests/fast/canvas/createImageBitmap-svg-sized-by-image-expected.txt:
Added.
* LayoutTests/fast/canvas/createImageBitmap-svg-sized-by-image.html: Added.
*
LayoutTests/fast/webcodecs/videoframe-from-image-orientation-and-density-expected.txt:
Added.
*
LayoutTests/fast/webcodecs/videoframe-from-image-orientation-and-density.html:
Added.
*
LayoutTests/fast/webcodecs/videoframe-from-svg-without-natural-size-expected.txt:
Added.
* LayoutTests/fast/webcodecs/videoframe-from-svg-without-natural-size.html:
Added.
* LayoutTests/http/wpt/webcodecs/videoFrame-rect.html:
*
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/imagebitmap/createImageBitmap-invalid-args-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/manual/imagebitmap/imagebitmap-replication-exif-orientation-expected.txt:
* Source/WebCore/Headers.cmake:
* Source/WebCore/Modules/webcodecs/VideoFrameImageSizing.h: Added.
* Source/WebCore/Modules/webcodecs/WebCodecsVideoFrame.cpp:
* Source/WebCore/Modules/webcodecs/WebCodecsVideoFrame.h:
* Source/WebCore/Modules/webcodecs/WebCodecsVideoFrame.idl:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/html/ApplyImageDevicePixelRatio.h: Added.
* Source/WebCore/html/HTMLImageElement.cpp:
* Source/WebCore/html/HTMLImageElement.h:
* Source/WebCore/html/ImageBitmap.cpp:
* Source/WebCore/html/ImageBitmap.h:
* Source/WebCore/html/ImageRequestState.h: Added.
* Source/WebCore/html/canvas/CanvasDrawImageSizing.h: Added.
* Source/WebCore/html/canvas/CanvasImageSource+OriginClean.cpp: Added.
* Source/WebCore/html/canvas/CanvasImageSource+OriginClean.h: Added.
* Source/WebCore/html/canvas/CanvasImageSource+Usability.cpp: Added.
* Source/WebCore/html/canvas/CanvasImageSource+Usability.h: Added.
* Source/WebCore/html/canvas/CanvasImageSource.h: Added.
* Source/WebCore/html/canvas/CanvasPatternSizing.h: Added.
* Source/WebCore/html/canvas/CanvasRenderingContext.cpp:
* Source/WebCore/html/canvas/CanvasRenderingContext.h:
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.h:
* Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp:
* Source/WebCore/html/canvas/WebGLRenderingContextBase.h:
* Source/WebCore/inspector/InspectorCanvas.cpp:
* Source/WebCore/loader/ImageLoader.cpp:
* Source/WebCore/loader/ImageLoader.h:
* Source/WebCore/loader/cache/CachedImage.cpp:
* Source/WebCore/loader/cache/CachedImage.h:
* Source/WebCore/platform/graphics/DefaultSizing.h: Added.
* Source/WebCore/platform/graphics/GraphicsContext.cpp:
* Source/WebCore/platform/graphics/GraphicsContext.h:
* Source/WebCore/platform/graphics/Image.cpp:
* Source/WebCore/platform/graphics/Image.h:
* Source/WebCore/platform/graphics/ImageSizingContext.cpp: Added.
* Source/WebCore/platform/graphics/ImageSizingContext.h: Added.
* Source/WebCore/platform/graphics/SizedImage.h: Added.
* Source/WebCore/svg/SVGImageElement.cpp:
* Source/WebCore/svg/SVGImageElement.h:
* Source/WebCore/svg/graphics/SVGImage.cpp:
* Source/WebCore/svg/graphics/SVGImage.h:
Canonical link: https://commits.webkit.org/322003@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications