Repository navigation
Add support for video and audio element lazy-loading via the loading attribute - #11980
Conversation
Specify support for the loading attribute for video using similar conventions to img and iframe, where the attribute has precedent. It has possible values of eager and lazy. When the loading attribute value is lazy, loading of any video or poster image data, as well as autoplay playback, must defer until layout is known and the video is in the viewport. This commit contains examples for how the loading attribute should take precedence over the preload, poster, and autoplay attributes. These were informed by experiments with local patch implementations to several user agents.
|
cc @whatwg/media |
|
This direction makes sense to me, but I'm not personally able to make a commitment to implement in Chromium. @zcorpan I think you've mentioned this feature, perhaps you have feedback? |
Add detail for video element lazy loading behavior when loading state is lazy. This involves returning early to prevent poster and video data loading and defining resumption steps to resume when loading state changes to eager. Also includes notes about autoplay eligibility and precedence over the preload attribute.
Adjust language of this statement about precedence of the loading attribute over the preload attribute so that it reiterates a fact.
Remove mention as audio is not mentioned in this proposed attribute addition
…g attribute These tests support the proposal for the addition of a loading attribute on the video element, designed to enable lazy-loading for video and poster data. HTML Standard PR here whatwg/html#11980 Co-authored-by: Zach Lysobey <[email protected]> Co-authored-by: Brad Frost <[email protected]> Co-authored-by: Credo Duarte <[email protected]>
|
Added and linked up a PR with web platform tests web-platform-tests/wpt#57051 small note: it says my entity is unverified above, but I think it's registered correctly now and needs a check |
|
@scottjehl I tried to push changes to this branch but was denied. Can you enable "Allow edits from maintainers"? |
|
@zcorpan I looked into how to do that and it sounds like the option may not be available for forks made by an organization, such as this one. Any other way we can help? Perhaps if the changes are in a public fork of yours I could pull them from there? |
|
@zcorpan looked great, thanks. Merged here! |
First page of the weekly MDN-upgrade backlog (133 old-shape pages). The old page was static prose with a hand-written support table, no Baseline banner, no live example, and plain-text citations. In-place upgrade, identity and lede preserved: - Baseline banner from webstatus.dev (loading-lazy-media, Baseline 'limited': Chrome/Chrome Android 150, Edge 150, no Firefox/Safari). - Formal Syntax section: keyword/state grammar from the merged HTML Standard (whatwg/html#11980 has landed since the page was written; all spec links re-pointed from the PR to media.html#attr-media-loading) plus the verbatim IDL line ([CEReactions] attribute DOMString loading; on HTMLMediaElement) and the limited-to-known-values reflection contract. - Real per-version BCD compat table (html.elements.video.loading / audio.loading): Chrome 150 full, 148-149 partial (not for <source>, crbug 514611050), Edge/Chrome Android via mirror + webstatus dates, Firefox/Safari not-supported rows with tracking bugs + positions. - Live showcase demo embedded (scroll-detector concept, HEAD-checked 200); all five live concept routes linked; stale '(when built)' text removed. - Warn-block reframed honestly: documents the v147 dev-trial stage with the real flag (LazyLoadVideoAndAudio) and the shipped 148/150 timeline. - Behavior/lifecycle, invalid-value defaults, security/privacy sections added; every citation now links its artifact directly. - New reference-contract.json (implementation-sufficient, 2 items x 9 dimensions) and _questions.json (guidanceConsulted: css-layout, accessibility, optimize-image-priority). Verified: suite 19 pass / 0 fail / 5 blocked; responsive matrix desktop:ok mobile:ok (screenshots read); validate-artifacts + test-reference-contract + check-routes PASS. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TxJjQpAcTzXzR2XW5TVJQp
whatwg/html#11980 has merged, so point `spec:` at the built HTML spec anchor instead of the PR. Drop the "Expecting" placeholder BCD comment: the correct BCD keys (api.HTMLMediaElement.loading rather than separate HTMLAudioElement and HTMLVideoElement) are already tagged web-features:loading-lazy-media in @mdn/browser-compat-data, so dist.ts derives compat_features from those tags automatically without needing them listed here too.
…ttribute https://bugs.webkit.org/show_bug.cgi?id=303995 Reviewed by NOBODY (OOPS!). This patch implements a loading attribute for video and audio elements, enabling lazy loading of media sources and video poster images, and deferring autoplay. This was added to the HTML spec here: whatwg/html#11980 Synced test from upstream wpt: - Commit: web-platform-tests/wpt@7d9d48d - Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-autoplay-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-source-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-auto-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-autoplay-when-visible-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-scroller-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-viewport-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-load-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-poster-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-resume-on-loading-attribute-change-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/w3c-import.log: * LayoutTests/imported/w3c/web-platform-tests/media/A4.webm: Added. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/dom/Document.h: * Source/WebCore/html/HTMLIFrameElement.cpp: (WebCore::HTMLIFrameElement::attributeChanged): (WebCore::isFrameLazyLoadable): (WebCore::HTMLIFrameElement::shouldLoadFrameLazily): * Source/WebCore/html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::attributeChanged): (WebCore::HTMLImageElement::isLazyLoadable const): (WebCore::HTMLImageElement::hasLazyLoadableAttributeValue): Deleted. * Source/WebCore/html/HTMLImageElement.h: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::didMoveToNewDocument): (WebCore::HTMLMediaElement::attributeChanged): (WebCore::HTMLMediaElement::shouldLazyLoadMediaResource const): (WebCore::HTMLMediaElement::deferMediaResourceLoadIfNeeded): (WebCore::HTMLMediaElement::clearLazyLoadState): (WebCore::HTMLMediaElement::resumeDeferredMediaResourceLoad): (WebCore::HTMLMediaElement::runLazyLoadResumptionSteps): (WebCore::HTMLMediaElement::lazyLoadIntersectionCallbackInvoked): (WebCore::HTMLMediaElement::prepareForLoad): (WebCore::HTMLMediaElement::selectMediaResource): (WebCore::HTMLMediaElement::queueSelectMediaResourceTask): (WebCore::HTMLMediaElement::playInternal): (WebCore::HTMLMediaElement::sourceWasAdded): * Source/WebCore/html/HTMLMediaElement.h: (WebCore::HTMLMediaElement::isIntersectingViewport const): (WebCore::HTMLMediaElement::tracksViewportIntersection const): (WebCore::HTMLMediaElement::viewportIntersectionChanged): (WebCore::HTMLMediaElement::isMediaResourceLoadDeferred const): (WebCore::HTMLMediaElement::shouldObserveViewportIntersection const): * Source/WebCore/html/HTMLMediaElement.idl: * Source/WebCore/html/HTMLVideoElement.cpp: (WebCore::HTMLVideoElement::rendererIsNeeded): (WebCore::HTMLVideoElement::didAttachRenderers): (WebCore::HTMLVideoElement::computeAcceleratedRenderingStateAndUpdateMediaPlayer): (WebCore::HTMLVideoElement::attributeChanged): (WebCore::HTMLVideoElement::webkitEnterFullscreen): (WebCore::HTMLVideoElement::didMoveToNewDocument): (WebCore::HTMLVideoElement::viewportIntersectionChanged): (WebCore::HTMLVideoElement::runLazyLoadResumptionSteps): (WebCore::HTMLVideoElement::loadDeferredPosterImage): (WebCore::HTMLVideoElement::resumePosterLoadIfAlreadyVisible): (WebCore::HTMLVideoElement::~HTMLVideoElement): Deleted. (WebCore::HTMLVideoElement::lazyLoadIntersectionCallbackInvoked): Deleted. * Source/WebCore/html/HTMLVideoElement.h: * Source/WebCore/html/LazyLoadElementObserver.cpp: (WebCore::LazyLoading::hasLazyAttributeValue): (WebCore::LazyLoading::isLazyLoadable): (WebCore::LazyLoadElementObserver::unobserve): (WebCore::LazyLoadElementObserver::unobserveIfLazyLoadOnly): (WebCore::LazyLoadElementObserver::isObserved const): Deleted. * Source/WebCore/html/LazyLoadElementObserver.h: * Source/WebCore/html/parser/HTMLPreloadScanner.cpp: (WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest): (WebCore::TokenPreloadScanner::StartTagScanner::isLazyloadingImage const): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): * Source/WebCore/loader/ImageLoader.cpp: (WebCore::shouldLazyLoadImageForElement): (WebCore::ImageLoader::updateFromElement): (WebCore::ImageLoader::notifyFinished): (WebCore::ImageLoader::updatedHasPendingEvent): (WebCore::ImageLoader::decode): (WebCore::ImageLoader::resetLazyImageLoading):
…ttribute https://bugs.webkit.org/show_bug.cgi?id=303995 Reviewed by NOBODY (OOPS!). This patch implements a loading attribute for video and audio elements, enabling lazy loading of media sources and video poster images, and deferring autoplay. This was added to the HTML spec here: whatwg/html#11980 Synced test from upstream wpt: - Commit: web-platform-tests/wpt@7d9d48d - Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1251_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1252_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-autoplay-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-source-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-auto-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-autoplay-when-visible-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-scroller-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-viewport-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-load-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-poster-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-resume-on-loading-attribute-change-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/w3c-import.log: * LayoutTests/imported/w3c/web-platform-tests/media/A4.webm: Added. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-in-viewport-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-window-onload-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: Removed. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/dom/Document.h: * Source/WebCore/html/HTMLIFrameElement.cpp: (WebCore::HTMLIFrameElement::attributeChanged): (WebCore::isFrameLazyLoadable): (WebCore::HTMLIFrameElement::shouldLoadFrameLazily): * Source/WebCore/html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::attributeChanged): (WebCore::HTMLImageElement::isLazyLoadable const): (WebCore::HTMLImageElement::hasLazyLoadableAttributeValue): Deleted. * Source/WebCore/html/HTMLImageElement.h: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::didMoveToNewDocument): (WebCore::HTMLMediaElement::attributeChanged): (WebCore::HTMLMediaElement::shouldLazyLoadMediaResource const): (WebCore::HTMLMediaElement::deferMediaResourceLoadIfNeeded): (WebCore::HTMLMediaElement::clearLazyLoadState): (WebCore::HTMLMediaElement::resumeDeferredMediaResourceLoad): (WebCore::HTMLMediaElement::runLazyLoadResumptionSteps): (WebCore::HTMLMediaElement::lazyLoadIntersectionCallbackInvoked): (WebCore::HTMLMediaElement::prepareForLoad): (WebCore::HTMLMediaElement::selectMediaResource): (WebCore::HTMLMediaElement::queueSelectMediaResourceTask): (WebCore::HTMLMediaElement::playInternal): (WebCore::HTMLMediaElement::sourceWasAdded): * Source/WebCore/html/HTMLMediaElement.h: (WebCore::HTMLMediaElement::isIntersectingViewport const): (WebCore::HTMLMediaElement::tracksViewportIntersection const): (WebCore::HTMLMediaElement::viewportIntersectionChanged): (WebCore::HTMLMediaElement::isMediaResourceLoadDeferred const): (WebCore::HTMLMediaElement::shouldObserveViewportIntersection const): * Source/WebCore/html/HTMLMediaElement.idl: * Source/WebCore/html/HTMLVideoElement.cpp: (WebCore::HTMLVideoElement::rendererIsNeeded): (WebCore::HTMLVideoElement::didAttachRenderers): (WebCore::HTMLVideoElement::computeAcceleratedRenderingStateAndUpdateMediaPlayer): (WebCore::HTMLVideoElement::attributeChanged): (WebCore::HTMLVideoElement::webkitEnterFullscreen): (WebCore::HTMLVideoElement::didMoveToNewDocument): (WebCore::HTMLVideoElement::viewportIntersectionChanged): (WebCore::HTMLVideoElement::runLazyLoadResumptionSteps): (WebCore::HTMLVideoElement::loadDeferredPosterImage): (WebCore::HTMLVideoElement::resumePosterLoadIfAlreadyVisible): (WebCore::HTMLVideoElement::~HTMLVideoElement): Deleted. (WebCore::HTMLVideoElement::lazyLoadIntersectionCallbackInvoked): Deleted. * Source/WebCore/html/HTMLVideoElement.h: * Source/WebCore/html/LazyLoadElementObserver.cpp: (WebCore::LazyLoading::hasLazyAttributeValue): (WebCore::LazyLoading::isLazyLoadable): (WebCore::LazyLoadElementObserver::unobserve): (WebCore::LazyLoadElementObserver::unobserveIfLazyLoadOnly): (WebCore::LazyLoadElementObserver::isObserved const): Deleted. * Source/WebCore/html/LazyLoadElementObserver.h: * Source/WebCore/html/parser/HTMLPreloadScanner.cpp: (WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest): (WebCore::TokenPreloadScanner::StartTagScanner::isLazyloadingImage const): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): * Source/WebCore/loader/ImageLoader.cpp: (WebCore::shouldLazyLoadImageForElement): (WebCore::ImageLoader::updateFromElement): (WebCore::ImageLoader::notifyFinished): (WebCore::ImageLoader::updatedHasPendingEvent): (WebCore::ImageLoader::decode): (WebCore::ImageLoader::resetLazyImageLoading):
…ttribute https://bugs.webkit.org/show_bug.cgi?id=303995 Reviewed by NOBODY (OOPS!). This patch implements a loading attribute for video and audio elements, enabling lazy loading of media sources and video poster images, and deferring autoplay. This was added to the HTML spec here: whatwg/html#11980 Synced test from upstream wpt: - Commit: web-platform-tests/wpt@7d9d48d - Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1251_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1252_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-autoplay-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-source-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-auto-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-autoplay-when-visible-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-scroller-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-viewport-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-load-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-poster-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-resume-on-loading-attribute-change-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/w3c-import.log: * LayoutTests/imported/w3c/web-platform-tests/media/A4.webm: Added. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-in-viewport-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-window-onload-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: Removed. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/dom/Document.h: * Source/WebCore/html/HTMLIFrameElement.cpp: (WebCore::HTMLIFrameElement::attributeChanged): (WebCore::isFrameLazyLoadable): (WebCore::HTMLIFrameElement::shouldLoadFrameLazily): * Source/WebCore/html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::attributeChanged): (WebCore::HTMLImageElement::isLazyLoadable const): (WebCore::HTMLImageElement::hasLazyLoadableAttributeValue): Deleted. * Source/WebCore/html/HTMLImageElement.h: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::didMoveToNewDocument): (WebCore::HTMLMediaElement::attributeChanged): (WebCore::HTMLMediaElement::shouldLazyLoadMediaResource const): (WebCore::HTMLMediaElement::deferMediaResourceLoadIfNeeded): (WebCore::HTMLMediaElement::clearLazyLoadState): (WebCore::HTMLMediaElement::resumeDeferredMediaResourceLoad): (WebCore::HTMLMediaElement::runLazyLoadResumptionSteps): (WebCore::HTMLMediaElement::lazyLoadIntersectionCallbackInvoked): (WebCore::HTMLMediaElement::prepareForLoad): (WebCore::HTMLMediaElement::selectMediaResource): (WebCore::HTMLMediaElement::queueSelectMediaResourceTask): (WebCore::HTMLMediaElement::playInternal): (WebCore::HTMLMediaElement::sourceWasAdded): * Source/WebCore/html/HTMLMediaElement.h: (WebCore::HTMLMediaElement::isIntersectingViewport const): (WebCore::HTMLMediaElement::tracksViewportIntersection const): (WebCore::HTMLMediaElement::viewportIntersectionChanged): (WebCore::HTMLMediaElement::isMediaResourceLoadDeferred const): (WebCore::HTMLMediaElement::shouldObserveViewportIntersection const): * Source/WebCore/html/HTMLMediaElement.idl: * Source/WebCore/html/HTMLVideoElement.cpp: (WebCore::HTMLVideoElement::rendererIsNeeded): (WebCore::HTMLVideoElement::didAttachRenderers): (WebCore::HTMLVideoElement::computeAcceleratedRenderingStateAndUpdateMediaPlayer): (WebCore::HTMLVideoElement::attributeChanged): (WebCore::HTMLVideoElement::webkitEnterFullscreen): (WebCore::HTMLVideoElement::didMoveToNewDocument): (WebCore::HTMLVideoElement::viewportIntersectionChanged): (WebCore::HTMLVideoElement::runLazyLoadResumptionSteps): (WebCore::HTMLVideoElement::loadDeferredPosterImage): (WebCore::HTMLVideoElement::resumePosterLoadIfAlreadyVisible): (WebCore::HTMLVideoElement::~HTMLVideoElement): Deleted. (WebCore::HTMLVideoElement::lazyLoadIntersectionCallbackInvoked): Deleted. * Source/WebCore/html/HTMLVideoElement.h: * Source/WebCore/html/LazyLoadElementObserver.cpp: (WebCore::LazyLoading::hasLazyAttributeValue): (WebCore::LazyLoading::isLazyLoadable): (WebCore::LazyLoadElementObserver::unobserve): (WebCore::LazyLoadElementObserver::unobserveIfLazyLoadOnly): (WebCore::LazyLoadElementObserver::isObserved const): Deleted. * Source/WebCore/html/LazyLoadElementObserver.h: * Source/WebCore/html/parser/HTMLPreloadScanner.cpp: (WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest): (WebCore::TokenPreloadScanner::StartTagScanner::isLazyloadingImage const): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): * Source/WebCore/loader/ImageLoader.cpp: (WebCore::shouldLazyLoadImageForElement): (WebCore::ImageLoader::updateFromElement): (WebCore::ImageLoader::notifyFinished): (WebCore::ImageLoader::updatedHasPendingEvent): (WebCore::ImageLoader::decode): (WebCore::ImageLoader::resetLazyImageLoading):
…ttribute https://bugs.webkit.org/show_bug.cgi?id=303995 Reviewed by NOBODY (OOPS!). This patch implements a loading attribute for video and audio elements, enabling lazy loading of media sources and video poster images, and deferring autoplay. This was added to the HTML spec here: whatwg/html#11980 Synced test from upstream wpt: - Commit: web-platform-tests/wpt@7d9d48d - Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1251_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1252_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-autoplay-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-source-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-auto-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-autoplay-when-visible-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-scroller-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-viewport-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-load-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-poster-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-resume-on-loading-attribute-change-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/w3c-import.log: * LayoutTests/imported/w3c/web-platform-tests/media/A4.webm: Added. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-in-viewport-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-window-onload-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: Removed. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/dom/Document.h: * Source/WebCore/html/HTMLIFrameElement.cpp: (WebCore::HTMLIFrameElement::attributeChanged): (WebCore::isFrameLazyLoadable): (WebCore::HTMLIFrameElement::shouldLoadFrameLazily): * Source/WebCore/html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::attributeChanged): (WebCore::HTMLImageElement::isLazyLoadable const): (WebCore::HTMLImageElement::hasLazyLoadableAttributeValue): Deleted. * Source/WebCore/html/HTMLImageElement.h: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::didMoveToNewDocument): (WebCore::HTMLMediaElement::attributeChanged): (WebCore::HTMLMediaElement::shouldLazyLoadMediaResource const): (WebCore::HTMLMediaElement::deferMediaResourceLoadIfNeeded): (WebCore::HTMLMediaElement::clearLazyLoadState): (WebCore::HTMLMediaElement::resumeDeferredMediaResourceLoad): (WebCore::HTMLMediaElement::runLazyLoadResumptionSteps): (WebCore::HTMLMediaElement::lazyLoadIntersectionCallbackInvoked): (WebCore::HTMLMediaElement::prepareForLoad): (WebCore::HTMLMediaElement::selectMediaResource): (WebCore::HTMLMediaElement::queueSelectMediaResourceTask): (WebCore::HTMLMediaElement::playInternal): (WebCore::HTMLMediaElement::sourceWasAdded): * Source/WebCore/html/HTMLMediaElement.h: (WebCore::HTMLMediaElement::isIntersectingViewport const): (WebCore::HTMLMediaElement::tracksViewportIntersection const): (WebCore::HTMLMediaElement::viewportIntersectionChanged): (WebCore::HTMLMediaElement::isMediaResourceLoadDeferred const): (WebCore::HTMLMediaElement::shouldObserveViewportIntersection const): * Source/WebCore/html/HTMLMediaElement.idl: * Source/WebCore/html/HTMLVideoElement.cpp: (WebCore::HTMLVideoElement::rendererIsNeeded): (WebCore::HTMLVideoElement::didAttachRenderers): (WebCore::HTMLVideoElement::computeAcceleratedRenderingStateAndUpdateMediaPlayer): (WebCore::HTMLVideoElement::attributeChanged): (WebCore::HTMLVideoElement::webkitEnterFullscreen): (WebCore::HTMLVideoElement::didMoveToNewDocument): (WebCore::HTMLVideoElement::viewportIntersectionChanged): (WebCore::HTMLVideoElement::runLazyLoadResumptionSteps): (WebCore::HTMLVideoElement::loadDeferredPosterImage): (WebCore::HTMLVideoElement::resumePosterLoadIfAlreadyVisible): (WebCore::HTMLVideoElement::~HTMLVideoElement): Deleted. (WebCore::HTMLVideoElement::lazyLoadIntersectionCallbackInvoked): Deleted. * Source/WebCore/html/HTMLVideoElement.h: * Source/WebCore/html/LazyLoadElementObserver.cpp: (WebCore::LazyLoading::hasLazyAttributeValue): (WebCore::LazyLoading::isLazyLoadable): (WebCore::LazyLoadElementObserver::unobserve): (WebCore::LazyLoadElementObserver::unobserveIfLazyLoadOnly): (WebCore::LazyLoadElementObserver::isObserved const): Deleted. * Source/WebCore/html/LazyLoadElementObserver.h: * Source/WebCore/html/parser/HTMLPreloadScanner.cpp: (WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest): (WebCore::TokenPreloadScanner::StartTagScanner::isLazyloadingImage const): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): * Source/WebCore/loader/ImageLoader.cpp: (WebCore::shouldLazyLoadImageForElement): (WebCore::ImageLoader::updateFromElement): (WebCore::ImageLoader::notifyFinished): (WebCore::ImageLoader::updatedHasPendingEvent): (WebCore::ImageLoader::decode): (WebCore::ImageLoader::resetLazyImageLoading):
…ttribute https://bugs.webkit.org/show_bug.cgi?id=303995 Reviewed by NOBODY (OOPS!). This patch implements a loading attribute for video and audio elements, enabling lazy loading of media sources and video poster images, and deferring autoplay. This was added to the HTML spec here: whatwg/html#11980 Synced test from upstream wpt: - Commit: web-platform-tests/wpt@7d9d48d - Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1251_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1252_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-autoplay-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-source-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-auto-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-autoplay-when-visible-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-scroller-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-viewport-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-load-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-poster-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-resume-on-loading-attribute-change-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/w3c-import.log: * LayoutTests/imported/w3c/web-platform-tests/media/A4.webm: Added. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-in-viewport-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-window-onload-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: Removed. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/dom/Document.h: * Source/WebCore/html/HTMLIFrameElement.cpp: (WebCore::HTMLIFrameElement::attributeChanged): (WebCore::isFrameLazyLoadable): (WebCore::HTMLIFrameElement::shouldLoadFrameLazily): * Source/WebCore/html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::attributeChanged): (WebCore::HTMLImageElement::isLazyLoadable const): (WebCore::HTMLImageElement::hasLazyLoadableAttributeValue): Deleted. * Source/WebCore/html/HTMLImageElement.h: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::didMoveToNewDocument): (WebCore::HTMLMediaElement::attributeChanged): (WebCore::HTMLMediaElement::shouldLazyLoadMediaResource const): (WebCore::HTMLMediaElement::deferMediaResourceLoadIfNeeded): (WebCore::HTMLMediaElement::clearLazyLoadState): (WebCore::HTMLMediaElement::resumeDeferredMediaResourceLoad): (WebCore::HTMLMediaElement::runLazyLoadResumptionSteps): (WebCore::HTMLMediaElement::lazyLoadIntersectionCallbackInvoked): (WebCore::HTMLMediaElement::prepareForLoad): (WebCore::HTMLMediaElement::selectMediaResource): (WebCore::HTMLMediaElement::queueSelectMediaResourceTask): (WebCore::HTMLMediaElement::playInternal): (WebCore::HTMLMediaElement::sourceWasAdded): * Source/WebCore/html/HTMLMediaElement.h: (WebCore::HTMLMediaElement::isIntersectingViewport const): (WebCore::HTMLMediaElement::tracksViewportIntersection const): (WebCore::HTMLMediaElement::viewportIntersectionChanged): (WebCore::HTMLMediaElement::isMediaResourceLoadDeferred const): (WebCore::HTMLMediaElement::shouldObserveViewportIntersection const): * Source/WebCore/html/HTMLMediaElement.idl: * Source/WebCore/html/HTMLVideoElement.cpp: (WebCore::HTMLVideoElement::rendererIsNeeded): (WebCore::HTMLVideoElement::didAttachRenderers): (WebCore::HTMLVideoElement::computeAcceleratedRenderingStateAndUpdateMediaPlayer): (WebCore::HTMLVideoElement::attributeChanged): (WebCore::HTMLVideoElement::webkitEnterFullscreen): (WebCore::HTMLVideoElement::didMoveToNewDocument): (WebCore::HTMLVideoElement::viewportIntersectionChanged): (WebCore::HTMLVideoElement::runLazyLoadResumptionSteps): (WebCore::HTMLVideoElement::loadDeferredPosterImage): (WebCore::HTMLVideoElement::resumePosterLoadIfAlreadyVisible): (WebCore::HTMLVideoElement::~HTMLVideoElement): Deleted. (WebCore::HTMLVideoElement::lazyLoadIntersectionCallbackInvoked): Deleted. * Source/WebCore/html/HTMLVideoElement.h: * Source/WebCore/html/LazyLoadElementObserver.cpp: (WebCore::LazyLoading::hasLazyAttributeValue): (WebCore::LazyLoading::isLazyLoadable): (WebCore::LazyLoadElementObserver::unobserve): (WebCore::LazyLoadElementObserver::unobserveIfLazyLoadOnly): (WebCore::LazyLoadElementObserver::isObserved const): Deleted. * Source/WebCore/html/LazyLoadElementObserver.h: * Source/WebCore/html/parser/HTMLPreloadScanner.cpp: (WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest): (WebCore::TokenPreloadScanner::StartTagScanner::isLazyloadingImage const): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): * Source/WebCore/loader/ImageLoader.cpp: (WebCore::shouldLazyLoadImageForElement): (WebCore::ImageLoader::updateFromElement): (WebCore::ImageLoader::notifyFinished): (WebCore::ImageLoader::updatedHasPendingEvent): (WebCore::ImageLoader::decode): (WebCore::ImageLoader::resetLazyImageLoading):
…o elements. r=dom-core-reviewers,media-playback-reviewers,webidl,layout-reviewers,smaug,emilio,pehrsons,alwu,jjaschke Add support for the `loading` attribute on <video> and <audio> elements, mirroring the existing behavior for <img> and <iframe>. The attribute accepts `eager` (default) and `lazy`. When `loading="lazy"` is set, loading of the media resource and poster image, as well as autoplay, is deferred via an intersection observer until the element is near the viewport. Gated behind the media.lazy_loading.enabled pref. Spec: https://html.spec.whatwg.org/multipage/media.html#attr-media-loading Spec PR: whatwg/html#11980 Co-authored-by: Scott Jehl <[email protected]> Differential Revision: https://phabricator.services.mozilla.com/D278547
…o elements. r=dom-core-reviewers,media-playback-reviewers,webidl,layout-reviewers,smaug,emilio,pehrsons,alwu,jjaschke Add support for the `loading` attribute on <video> and <audio> elements, mirroring the existing behavior for <img> and <iframe>. The attribute accepts `eager` (default) and `lazy`. When `loading="lazy"` is set, loading of the media resource and poster image, as well as autoplay, is deferred via an intersection observer until the element is near the viewport. Gated behind the media.lazy_loading.enabled pref. Spec: https://html.spec.whatwg.org/multipage/media.html#attr-media-loading Spec PR: whatwg/html#11980 Co-authored-by: Scott Jehl <[email protected]> Differential Revision: https://phabricator.services.mozilla.com/D278547
…o elements. r=dom-core-reviewers,media-playback-reviewers,webidl,layout-reviewers,smaug,emilio,pehrsons,alwu Add support for the `loading` attribute on <video> and <audio> elements, mirroring the existing behavior for <img> and <iframe>. The attribute accepts `eager` (default) and `lazy`. When `loading="lazy"` is set, loading of the media resource and poster image, as well as autoplay, is deferred via an intersection observer until the element is near the viewport. Gated behind the media.lazy_loading.enabled pref. Spec: https://html.spec.whatwg.org/multipage/media.html#attr-media-loading Spec PR: whatwg/html#11980 Co-authored-by: Scott Jehl <[email protected]> Differential Revision: https://phabricator.services.mozilla.com/D278547
…o elements. r=dom-core-reviewers,media-playback-reviewers,webidl,layout-reviewers,smaug,emilio,pehrsons,alwu,keithamus Add support for the `loading` attribute on <video> and <audio> elements, mirroring the existing behavior for <img> and <iframe>. The attribute accepts `eager` (default) and `lazy`. When `loading="lazy"` is set, loading of the media resource and poster image, as well as autoplay, is deferred via an intersection observer until the element is near the viewport. Gated behind the media.lazy_loading.enabled pref. Spec: https://html.spec.whatwg.org/multipage/media.html#attr-media-loading Spec PR: whatwg/html#11980 Co-authored-by: Scott Jehl <[email protected]> Differential Revision: https://phabricator.services.mozilla.com/D278547
…o elements. r=dom-core-reviewers,media-playback-reviewers,webidl,layout-reviewers,smaug,emilio,pehrsons,alwu,keithamus Add support for the `loading` attribute on <video> and <audio> elements, mirroring the existing behavior for <img> and <iframe>. The attribute accepts `eager` (default) and `lazy`. When `loading="lazy"` is set, loading of the media resource and poster image, as well as autoplay, is deferred via an intersection observer until the element is near the viewport. Gated behind the media.lazy_loading.enabled pref. Spec: https://html.spec.whatwg.org/multipage/media.html#attr-media-loading Spec PR: whatwg/html#11980 Co-authored-by: Scott Jehl <[email protected]> Differential Revision: https://phabricator.services.mozilla.com/D278547
…o elements. r=dom-core-reviewers,media-playback-reviewers,webidl,layout-reviewers,smaug,emilio,pehrsons,alwu,jjaschke Add support for the `loading` attribute on <video> and <audio> elements, mirroring the existing behavior for <img> and <iframe>. The attribute accepts `eager` (default) and `lazy`. When `loading="lazy"` is set, loading of the media resource and poster image, as well as autoplay, is deferred via an intersection observer until the element is near the viewport. Gated behind the media.lazy_loading.enabled pref. Spec: https://html.spec.whatwg.org/multipage/media.html#attr-media-loading Spec PR: whatwg/html#11980 Co-authored-by: Scott Jehl <sjehlsquarespace.com> Differential Revision: https://phabricator.services.mozilla.com/D278547 UltraBlame original commit: a45c639e32bf0476b658e8aa537c5efa84f533ba
…o elements. r=dom-core-reviewers,media-playback-reviewers,webidl,layout-reviewers,smaug,emilio,pehrsons,alwu,jjaschke Add support for the `loading` attribute on <video> and <audio> elements, mirroring the existing behavior for <img> and <iframe>. The attribute accepts `eager` (default) and `lazy`. When `loading="lazy"` is set, loading of the media resource and poster image, as well as autoplay, is deferred via an intersection observer until the element is near the viewport. Gated behind the media.lazy_loading.enabled pref. Spec: https://html.spec.whatwg.org/multipage/media.html#attr-media-loading Spec PR: whatwg/html#11980 Co-authored-by: Scott Jehl <sjehlsquarespace.com> Differential Revision: https://phabricator.services.mozilla.com/D278547 UltraBlame original commit: d1ef6f26f579ea71b34a22cb8997b819d0a6d0e7
…o elements. r=dom-core-reviewers,media-playback-reviewers,webidl,layout-reviewers,smaug,emilio,pehrsons,alwu,jjaschke Add support for the `loading` attribute on <video> and <audio> elements, mirroring the existing behavior for <img> and <iframe>. The attribute accepts `eager` (default) and `lazy`. When `loading="lazy"` is set, loading of the media resource and poster image, as well as autoplay, is deferred via an intersection observer until the element is near the viewport. Gated behind the media.lazy_loading.enabled pref. Spec: https://html.spec.whatwg.org/multipage/media.html#attr-media-loading Spec PR: whatwg/html#11980 Co-authored-by: Scott Jehl <sjehlsquarespace.com> Differential Revision: https://phabricator.services.mozilla.com/D278547 UltraBlame original commit: a45c639e32bf0476b658e8aa537c5efa84f533ba
…o elements. r=dom-core-reviewers,media-playback-reviewers,webidl,layout-reviewers,smaug,emilio,pehrsons,alwu,jjaschke Add support for the `loading` attribute on <video> and <audio> elements, mirroring the existing behavior for <img> and <iframe>. The attribute accepts `eager` (default) and `lazy`. When `loading="lazy"` is set, loading of the media resource and poster image, as well as autoplay, is deferred via an intersection observer until the element is near the viewport. Gated behind the media.lazy_loading.enabled pref. Spec: https://html.spec.whatwg.org/multipage/media.html#attr-media-loading Spec PR: whatwg/html#11980 Co-authored-by: Scott Jehl <sjehlsquarespace.com> Differential Revision: https://phabricator.services.mozilla.com/D278547 UltraBlame original commit: d1ef6f26f579ea71b34a22cb8997b819d0a6d0e7
…o elements. r=dom-core-reviewers,media-playback-reviewers,webidl,layout-reviewers,smaug,emilio,pehrsons,alwu,jjaschke Add support for the `loading` attribute on <video> and <audio> elements, mirroring the existing behavior for <img> and <iframe>. The attribute accepts `eager` (default) and `lazy`. When `loading="lazy"` is set, loading of the media resource and poster image, as well as autoplay, is deferred via an intersection observer until the element is near the viewport. Gated behind the media.lazy_loading.enabled pref. Spec: https://html.spec.whatwg.org/multipage/media.html#attr-media-loading Spec PR: whatwg/html#11980 Co-authored-by: Scott Jehl <sjehlsquarespace.com> Differential Revision: https://phabricator.services.mozilla.com/D278547 UltraBlame original commit: a45c639e32bf0476b658e8aa537c5efa84f533ba
…o elements. r=dom-core-reviewers,media-playback-reviewers,webidl,layout-reviewers,smaug,emilio,pehrsons,alwu,jjaschke Add support for the `loading` attribute on <video> and <audio> elements, mirroring the existing behavior for <img> and <iframe>. The attribute accepts `eager` (default) and `lazy`. When `loading="lazy"` is set, loading of the media resource and poster image, as well as autoplay, is deferred via an intersection observer until the element is near the viewport. Gated behind the media.lazy_loading.enabled pref. Spec: https://html.spec.whatwg.org/multipage/media.html#attr-media-loading Spec PR: whatwg/html#11980 Co-authored-by: Scott Jehl <sjehlsquarespace.com> Differential Revision: https://phabricator.services.mozilla.com/D278547 UltraBlame original commit: d1ef6f26f579ea71b34a22cb8997b819d0a6d0e7
…ttribute https://bugs.webkit.org/show_bug.cgi?id=303995 Reviewed by NOBODY (OOPS!). This patch implements a loading attribute for video and audio elements, enabling lazy loading of media sources and video poster images, and deferring autoplay. This was added to the HTML spec here: whatwg/html#11980 Synced test from upstream wpt: - Commit: web-platform-tests/wpt@7d9d48d - Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1251_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1252_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-autoplay-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-source-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-auto-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-autoplay-when-visible-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-scroller-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-viewport-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-load-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-poster-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-resume-on-loading-attribute-change-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/w3c-import.log: * LayoutTests/imported/w3c/web-platform-tests/media/A4.webm: Added. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-in-viewport-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-window-onload-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: Removed. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/dom/Document.h: * Source/WebCore/html/HTMLIFrameElement.cpp: (WebCore::HTMLIFrameElement::attributeChanged): (WebCore::isFrameLazyLoadable): (WebCore::HTMLIFrameElement::shouldLoadFrameLazily): * Source/WebCore/html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::attributeChanged): (WebCore::HTMLImageElement::isLazyLoadable const): (WebCore::HTMLImageElement::hasLazyLoadableAttributeValue): Deleted. * Source/WebCore/html/HTMLImageElement.h: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::didMoveToNewDocument): (WebCore::HTMLMediaElement::attributeChanged): (WebCore::HTMLMediaElement::shouldLazyLoadMediaResource const): (WebCore::HTMLMediaElement::deferMediaResourceLoadIfNeeded): (WebCore::HTMLMediaElement::clearLazyLoadState): (WebCore::HTMLMediaElement::resumeDeferredMediaResourceLoad): (WebCore::HTMLMediaElement::runLazyLoadResumptionSteps): (WebCore::HTMLMediaElement::lazyLoadIntersectionCallbackInvoked): (WebCore::HTMLMediaElement::prepareForLoad): (WebCore::HTMLMediaElement::selectMediaResource): (WebCore::HTMLMediaElement::queueSelectMediaResourceTask): (WebCore::HTMLMediaElement::playInternal): (WebCore::HTMLMediaElement::sourceWasAdded): * Source/WebCore/html/HTMLMediaElement.h: (WebCore::HTMLMediaElement::isIntersectingViewport const): (WebCore::HTMLMediaElement::tracksViewportIntersection const): (WebCore::HTMLMediaElement::viewportIntersectionChanged): (WebCore::HTMLMediaElement::isMediaResourceLoadDeferred const): (WebCore::HTMLMediaElement::shouldObserveViewportIntersection const): * Source/WebCore/html/HTMLMediaElement.idl: * Source/WebCore/html/HTMLVideoElement.cpp: (WebCore::HTMLVideoElement::rendererIsNeeded): (WebCore::HTMLVideoElement::didAttachRenderers): (WebCore::HTMLVideoElement::computeAcceleratedRenderingStateAndUpdateMediaPlayer): (WebCore::HTMLVideoElement::attributeChanged): (WebCore::HTMLVideoElement::webkitEnterFullscreen): (WebCore::HTMLVideoElement::didMoveToNewDocument): (WebCore::HTMLVideoElement::viewportIntersectionChanged): (WebCore::HTMLVideoElement::runLazyLoadResumptionSteps): (WebCore::HTMLVideoElement::loadDeferredPosterImage): (WebCore::HTMLVideoElement::resumePosterLoadIfAlreadyVisible): (WebCore::HTMLVideoElement::~HTMLVideoElement): Deleted. (WebCore::HTMLVideoElement::lazyLoadIntersectionCallbackInvoked): Deleted. * Source/WebCore/html/HTMLVideoElement.h: * Source/WebCore/html/LazyLoadElementObserver.cpp: (WebCore::LazyLoadElementObserver::unobserve): (WebCore::LazyLoadElementObserver::unobserveIfLazyLoadOnly): (WebCore::LazyLoadElementObserver::isObserved const): Deleted. * Source/WebCore/html/LazyLoadElementObserver.h: * Source/WebCore/html/LazyLoading.cpp: Copied from Source/WebCore/html/LazyLoadElementObserver.h. (WebCore::LazyLoading::hasLazyAttributeValue): (WebCore::LazyLoading::isLazyLoadable): * Source/WebCore/html/LazyLoading.h: Copied from Source/WebCore/html/LazyLoadElementObserver.h. * Source/WebCore/html/parser/HTMLPreloadScanner.cpp: (WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest): (WebCore::TokenPreloadScanner::StartTagScanner::isLazyloadingImage const): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): * Source/WebCore/loader/ImageLoader.cpp: (WebCore::shouldLazyLoadImageForElement): (WebCore::ImageLoader::updateFromElement): (WebCore::ImageLoader::notifyFinished): (WebCore::ImageLoader::updatedHasPendingEvent): (WebCore::ImageLoader::decode): (WebCore::ImageLoader::resetLazyImageLoading):
…ttribute https://bugs.webkit.org/show_bug.cgi?id=303995 Reviewed by NOBODY (OOPS!). This patch implements a loading attribute for video and audio elements, enabling lazy loading of media sources and video poster images, and deferring autoplay. This was added to the HTML spec here: whatwg/html#11980 Synced test from upstream wpt: - Commit: web-platform-tests/wpt@7d9d48d - Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1251_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1252_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-autoplay-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-source-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-auto-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-autoplay-when-visible-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-scroller-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-viewport-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-load-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-poster-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-resume-on-loading-attribute-change-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/w3c-import.log: * LayoutTests/imported/w3c/web-platform-tests/media/A4.webm: Added. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-in-viewport-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-window-onload-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: Removed. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/dom/Document.h: * Source/WebCore/html/HTMLIFrameElement.cpp: (WebCore::HTMLIFrameElement::attributeChanged): (WebCore::isFrameLazyLoadable): (WebCore::HTMLIFrameElement::shouldLoadFrameLazily): * Source/WebCore/html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::attributeChanged): (WebCore::HTMLImageElement::isLazyLoadable const): (WebCore::HTMLImageElement::hasLazyLoadableAttributeValue): Deleted. * Source/WebCore/html/HTMLImageElement.h: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::didMoveToNewDocument): (WebCore::HTMLMediaElement::attributeChanged): (WebCore::HTMLMediaElement::shouldLazyLoadMediaResource const): (WebCore::HTMLMediaElement::deferMediaResourceLoadIfNeeded): (WebCore::HTMLMediaElement::clearLazyLoadState): (WebCore::HTMLMediaElement::resumeDeferredMediaResourceLoad): (WebCore::HTMLMediaElement::runLazyLoadResumptionSteps): (WebCore::HTMLMediaElement::lazyLoadIntersectionCallbackInvoked): (WebCore::HTMLMediaElement::prepareForLoad): (WebCore::HTMLMediaElement::selectMediaResource): (WebCore::HTMLMediaElement::queueSelectMediaResourceTask): (WebCore::HTMLMediaElement::playInternal): (WebCore::HTMLMediaElement::sourceWasAdded): * Source/WebCore/html/HTMLMediaElement.h: (WebCore::HTMLMediaElement::isIntersectingViewport const): (WebCore::HTMLMediaElement::tracksViewportIntersection const): (WebCore::HTMLMediaElement::viewportIntersectionChanged): (WebCore::HTMLMediaElement::isMediaResourceLoadDeferred const): (WebCore::HTMLMediaElement::shouldObserveViewportIntersection const): * Source/WebCore/html/HTMLMediaElement.idl: * Source/WebCore/html/HTMLVideoElement.cpp: (WebCore::HTMLVideoElement::rendererIsNeeded): (WebCore::HTMLVideoElement::didAttachRenderers): (WebCore::HTMLVideoElement::computeAcceleratedRenderingStateAndUpdateMediaPlayer): (WebCore::HTMLVideoElement::attributeChanged): (WebCore::HTMLVideoElement::webkitEnterFullscreen): (WebCore::HTMLVideoElement::didMoveToNewDocument): (WebCore::HTMLVideoElement::viewportIntersectionChanged): (WebCore::HTMLVideoElement::runLazyLoadResumptionSteps): (WebCore::HTMLVideoElement::loadDeferredPosterImage): (WebCore::HTMLVideoElement::resumePosterLoadIfAlreadyVisible): (WebCore::HTMLVideoElement::~HTMLVideoElement): Deleted. (WebCore::HTMLVideoElement::lazyLoadIntersectionCallbackInvoked): Deleted. * Source/WebCore/html/HTMLVideoElement.h: * Source/WebCore/html/LazyLoadElementObserver.cpp: (WebCore::LazyLoadElementObserver::unobserve): (WebCore::LazyLoadElementObserver::unobserveIfLazyLoadOnly): (WebCore::LazyLoadElementObserver::isObserved const): Deleted. * Source/WebCore/html/LazyLoadElementObserver.h: * Source/WebCore/html/LazyLoading.cpp: Copied from Source/WebCore/html/LazyLoadElementObserver.h. (WebCore::LazyLoading::hasLazyAttributeValue): (WebCore::LazyLoading::isLazyLoadable): * Source/WebCore/html/LazyLoading.h: Copied from Source/WebCore/html/LazyLoadElementObserver.h. * Source/WebCore/html/parser/HTMLPreloadScanner.cpp: (WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest): (WebCore::TokenPreloadScanner::StartTagScanner::isLazyloadingImage const): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): * Source/WebCore/loader/ImageLoader.cpp: (WebCore::shouldLazyLoadImageForElement): (WebCore::ImageLoader::updateFromElement): (WebCore::ImageLoader::notifyFinished): (WebCore::ImageLoader::updatedHasPendingEvent): (WebCore::ImageLoader::decode): (WebCore::ImageLoader::resetLazyImageLoading):
…ttribute https://bugs.webkit.org/show_bug.cgi?id=303995 Reviewed by NOBODY (OOPS!). This patch implements a loading attribute for video and audio elements, enabling lazy loading of media sources and video poster images, and deferring autoplay. This was added to the HTML spec here: whatwg/html#11980 Synced test from upstream wpt: - Commit: web-platform-tests/wpt@7d9d48d - Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1251_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1252_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-autoplay-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-source-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-auto-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-autoplay-when-visible-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-scroller-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-viewport-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-load-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-poster-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-resume-on-loading-attribute-change-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/w3c-import.log: * LayoutTests/imported/w3c/web-platform-tests/media/A4.webm: Added. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-in-viewport-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-window-onload-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: Removed. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/dom/Document.h: * Source/WebCore/html/HTMLIFrameElement.cpp: (WebCore::HTMLIFrameElement::attributeChanged): (WebCore::isFrameLazyLoadable): (WebCore::HTMLIFrameElement::shouldLoadFrameLazily): * Source/WebCore/html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::bestFitSourceFromPictureElement): (WebCore::HTMLImageElement::selectImageSource): (WebCore::HTMLImageElement::attributeChanged): (WebCore::HTMLImageElement::didAttachRenderers): (WebCore::HTMLImageElement::allowsAutoSizes const): (WebCore::HTMLImageElement::hasLazyLoadableAttributeValue): Deleted. (WebCore::HTMLImageElement::isLazyLoadable const): Deleted. * Source/WebCore/html/HTMLImageElement.h: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::didMoveToNewDocument): (WebCore::HTMLMediaElement::attributeChanged): (WebCore::HTMLMediaElement::shouldLazyLoadMediaResource const): (WebCore::HTMLMediaElement::deferMediaResourceLoadIfNeeded): (WebCore::HTMLMediaElement::clearLazyLoadState): (WebCore::HTMLMediaElement::resumeDeferredMediaResourceLoad): (WebCore::HTMLMediaElement::runLazyLoadResumptionSteps): (WebCore::HTMLMediaElement::lazyLoadIntersectionCallbackInvoked): (WebCore::HTMLMediaElement::prepareForLoad): (WebCore::HTMLMediaElement::selectMediaResource): (WebCore::HTMLMediaElement::queueSelectMediaResourceTask): (WebCore::HTMLMediaElement::playInternal): (WebCore::HTMLMediaElement::sourceWasAdded): * Source/WebCore/html/HTMLMediaElement.h: (WebCore::HTMLMediaElement::isIntersectingViewport const): (WebCore::HTMLMediaElement::tracksViewportIntersection const): (WebCore::HTMLMediaElement::viewportIntersectionChanged): (WebCore::HTMLMediaElement::isMediaResourceLoadDeferred const): (WebCore::HTMLMediaElement::shouldObserveViewportIntersection const): * Source/WebCore/html/HTMLMediaElement.idl: * Source/WebCore/html/HTMLVideoElement.cpp: (WebCore::HTMLVideoElement::rendererIsNeeded): (WebCore::HTMLVideoElement::didAttachRenderers): (WebCore::HTMLVideoElement::computeAcceleratedRenderingStateAndUpdateMediaPlayer): (WebCore::HTMLVideoElement::attributeChanged): (WebCore::HTMLVideoElement::webkitEnterFullscreen): (WebCore::HTMLVideoElement::didMoveToNewDocument): (WebCore::HTMLVideoElement::viewportIntersectionChanged): (WebCore::HTMLVideoElement::runLazyLoadResumptionSteps): (WebCore::HTMLVideoElement::loadDeferredPosterImage): (WebCore::HTMLVideoElement::resumePosterLoadIfAlreadyVisible): (WebCore::HTMLVideoElement::~HTMLVideoElement): Deleted. (WebCore::HTMLVideoElement::lazyLoadIntersectionCallbackInvoked): Deleted. * Source/WebCore/html/HTMLVideoElement.h: * Source/WebCore/html/LazyLoadElementObserver.cpp: (WebCore::LazyLoadElementObserver::unobserve): (WebCore::LazyLoadElementObserver::unobserveIfLazyLoadOnly): (WebCore::LazyLoadElementObserver::isObserved const): Deleted. * Source/WebCore/html/LazyLoadElementObserver.h: * Source/WebCore/html/LazyLoading.cpp: Added. (WebCore::LazyLoading::hasLazyAttributeValue): (WebCore::LazyLoading::isInLazyState): (WebCore::LazyLoading::isLazyLoadingEnabled): (WebCore::LazyLoading::isLazyLoadable): * Source/WebCore/html/LazyLoading.h: Copied from Source/WebCore/html/LazyLoadElementObserver.h. * Source/WebCore/html/parser/HTMLPreloadScanner.cpp: (WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest): (WebCore::TokenPreloadScanner::StartTagScanner::isLazyloadingImage const): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): * Source/WebCore/loader/ImageLoader.cpp: (WebCore::ImageLoader::updateFromElement): (WebCore::ImageLoader::notifyFinished): (WebCore::ImageLoader::updatedHasPendingEvent): (WebCore::ImageLoader::decode): (WebCore::ImageLoader::resetLazyImageLoading): * Source/WebCore/rendering/RenderImage.cpp: (WebCore::RenderImage::layout):
…ttribute https://bugs.webkit.org/show_bug.cgi?id=303995 Reviewed by NOBODY (OOPS!). This patch implements a loading attribute for video and audio elements, enabling lazy loading of media sources and video poster images, and deferring autoplay. This was added to the HTML spec here: whatwg/html#11980 Synced test from upstream wpt: - Commit: web-platform-tests/wpt@7d9d48d - Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1251_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1252_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-autoplay-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-source-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-auto-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-autoplay-when-visible-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-scroller-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-viewport-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-load-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-poster-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-resume-on-loading-attribute-change-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/w3c-import.log: * LayoutTests/imported/w3c/web-platform-tests/media/A4.webm: Added. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-in-viewport-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-window-onload-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: Removed. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/dom/Document.h: * Source/WebCore/html/HTMLIFrameElement.cpp: (WebCore::HTMLIFrameElement::attributeChanged): (WebCore::isFrameLazyLoadable): (WebCore::HTMLIFrameElement::shouldLoadFrameLazily): * Source/WebCore/html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::bestFitSourceFromPictureElement): (WebCore::HTMLImageElement::selectImageSource): (WebCore::HTMLImageElement::attributeChanged): (WebCore::HTMLImageElement::didAttachRenderers): (WebCore::HTMLImageElement::allowsAutoSizes const): (WebCore::HTMLImageElement::hasLazyLoadableAttributeValue): Deleted. (WebCore::HTMLImageElement::isLazyLoadable const): Deleted. * Source/WebCore/html/HTMLImageElement.h: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::didMoveToNewDocument): (WebCore::HTMLMediaElement::attributeChanged): (WebCore::HTMLMediaElement::shouldLazyLoadMediaResource const): (WebCore::HTMLMediaElement::deferMediaResourceLoadIfNeeded): (WebCore::HTMLMediaElement::clearLazyLoadState): (WebCore::HTMLMediaElement::resumeDeferredMediaResourceLoad): (WebCore::HTMLMediaElement::runLazyLoadResumptionSteps): (WebCore::HTMLMediaElement::lazyLoadIntersectionCallbackInvoked): (WebCore::HTMLMediaElement::prepareForLoad): (WebCore::HTMLMediaElement::selectMediaResource): (WebCore::HTMLMediaElement::queueSelectMediaResourceTask): (WebCore::HTMLMediaElement::playInternal): (WebCore::HTMLMediaElement::sourceWasAdded): * Source/WebCore/html/HTMLMediaElement.h: (WebCore::HTMLMediaElement::isIntersectingViewport const): (WebCore::HTMLMediaElement::tracksViewportIntersection const): (WebCore::HTMLMediaElement::viewportIntersectionChanged): (WebCore::HTMLMediaElement::isMediaResourceLoadDeferred const): (WebCore::HTMLMediaElement::shouldObserveViewportIntersection const): * Source/WebCore/html/HTMLMediaElement.idl: * Source/WebCore/html/HTMLVideoElement.cpp: (WebCore::HTMLVideoElement::rendererIsNeeded): (WebCore::HTMLVideoElement::didAttachRenderers): (WebCore::HTMLVideoElement::computeAcceleratedRenderingStateAndUpdateMediaPlayer): (WebCore::HTMLVideoElement::attributeChanged): (WebCore::HTMLVideoElement::webkitEnterFullscreen): (WebCore::HTMLVideoElement::didMoveToNewDocument): (WebCore::HTMLVideoElement::viewportIntersectionChanged): (WebCore::HTMLVideoElement::runLazyLoadResumptionSteps): (WebCore::HTMLVideoElement::loadDeferredPosterImage): (WebCore::HTMLVideoElement::resumePosterLoadIfAlreadyVisible): (WebCore::HTMLVideoElement::~HTMLVideoElement): Deleted. (WebCore::HTMLVideoElement::lazyLoadIntersectionCallbackInvoked): Deleted. * Source/WebCore/html/HTMLVideoElement.h: * Source/WebCore/html/LazyLoadElementObserver.cpp: (WebCore::LazyLoadElementObserver::unobserve): (WebCore::LazyLoadElementObserver::unobserveIfLazyLoadOnly): (WebCore::LazyLoadElementObserver::isObserved const): Deleted. * Source/WebCore/html/LazyLoadElementObserver.h: * Source/WebCore/html/LazyLoading.cpp: Added. (WebCore::LazyLoading::hasLazyAttributeValue): (WebCore::LazyLoading::isInLazyState): (WebCore::LazyLoading::isLazyLoadingEnabled): (WebCore::LazyLoading::isLazyLoadable): * Source/WebCore/html/LazyLoading.h: Copied from Source/WebCore/html/LazyLoadElementObserver.h. * Source/WebCore/html/parser/HTMLPreloadScanner.cpp: (WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest): (WebCore::TokenPreloadScanner::StartTagScanner::isLazyloadingImage const): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): * Source/WebCore/loader/ImageLoader.cpp: (WebCore::ImageLoader::updateFromElement): (WebCore::ImageLoader::notifyFinished): (WebCore::ImageLoader::updatedHasPendingEvent): (WebCore::ImageLoader::decode): (WebCore::ImageLoader::resetLazyImageLoading): * Source/WebCore/rendering/RenderImage.cpp: (WebCore::RenderImage::layout):
…ttribute https://bugs.webkit.org/show_bug.cgi?id=303995 Reviewed by Anne van Kesteren. This patch implements a loading attribute for video and audio elements, enabling lazy loading of media sources and video poster images, and deferring autoplay. This was added to the HTML spec here: whatwg/html#11980 Synced test from upstream wpt: - Commit: web-platform-tests/wpt@7d9d48d - Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1251_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1252_include=loading-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-autoplay-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-source-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-auto-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-autoplay-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-autoplay-when-visible-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-disconnected-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-scroller-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-in-viewport-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-load-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-not-rendered-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-poster-when-visible-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-resume-on-loading-attribute-change-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-inserted-load-event.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-source-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-lazy-to-eager-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video-loading-poster-deferred-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/w3c-import.log: * LayoutTests/imported/w3c/web-platform-tests/media/A4.webm: Added. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-in-viewport-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-lazy-window-onload-expected.txt: Removed. * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-audio-element/audio-loading-load-preload-metadata-deferred-expected.txt: Removed. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/dom/Document.h: * Source/WebCore/html/HTMLIFrameElement.cpp: (WebCore::HTMLIFrameElement::attributeChanged): (WebCore::isFrameLazyLoadable): (WebCore::HTMLIFrameElement::shouldLoadFrameLazily): * Source/WebCore/html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::bestFitSourceFromPictureElement): (WebCore::HTMLImageElement::selectImageSource): (WebCore::HTMLImageElement::attributeChanged): (WebCore::HTMLImageElement::didAttachRenderers): (WebCore::HTMLImageElement::allowsAutoSizes const): (WebCore::HTMLImageElement::hasLazyLoadableAttributeValue): Deleted. (WebCore::HTMLImageElement::isLazyLoadable const): Deleted. * Source/WebCore/html/HTMLImageElement.h: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::didMoveToNewDocument): (WebCore::HTMLMediaElement::attributeChanged): (WebCore::HTMLMediaElement::shouldLazyLoadMediaResource const): (WebCore::HTMLMediaElement::deferMediaResourceLoadIfNeeded): (WebCore::HTMLMediaElement::clearLazyLoadState): (WebCore::HTMLMediaElement::resumeDeferredMediaResourceLoad): (WebCore::HTMLMediaElement::runLazyLoadResumptionSteps): (WebCore::HTMLMediaElement::lazyLoadIntersectionCallbackInvoked): (WebCore::HTMLMediaElement::prepareForLoad): (WebCore::HTMLMediaElement::selectMediaResource): (WebCore::HTMLMediaElement::queueSelectMediaResourceTask): (WebCore::HTMLMediaElement::playInternal): (WebCore::HTMLMediaElement::sourceWasAdded): * Source/WebCore/html/HTMLMediaElement.h: (WebCore::HTMLMediaElement::isIntersectingViewport const): (WebCore::HTMLMediaElement::tracksViewportIntersection const): (WebCore::HTMLMediaElement::viewportIntersectionChanged): (WebCore::HTMLMediaElement::isMediaResourceLoadDeferred const): (WebCore::HTMLMediaElement::shouldObserveViewportIntersection const): * Source/WebCore/html/HTMLMediaElement.idl: * Source/WebCore/html/HTMLVideoElement.cpp: (WebCore::HTMLVideoElement::rendererIsNeeded): (WebCore::HTMLVideoElement::didAttachRenderers): (WebCore::HTMLVideoElement::computeAcceleratedRenderingStateAndUpdateMediaPlayer): (WebCore::HTMLVideoElement::attributeChanged): (WebCore::HTMLVideoElement::webkitEnterFullscreen): (WebCore::HTMLVideoElement::didMoveToNewDocument): (WebCore::HTMLVideoElement::viewportIntersectionChanged): (WebCore::HTMLVideoElement::runLazyLoadResumptionSteps): (WebCore::HTMLVideoElement::loadDeferredPosterImage): (WebCore::HTMLVideoElement::resumePosterLoadIfAlreadyVisible): (WebCore::HTMLVideoElement::~HTMLVideoElement): Deleted. (WebCore::HTMLVideoElement::lazyLoadIntersectionCallbackInvoked): Deleted. * Source/WebCore/html/HTMLVideoElement.h: * Source/WebCore/html/LazyLoadElementObserver.cpp: (WebCore::LazyLoadElementObserver::unobserve): (WebCore::LazyLoadElementObserver::unobserveIfLazyLoadOnly): (WebCore::LazyLoadElementObserver::isObserved const): Deleted. * Source/WebCore/html/LazyLoadElementObserver.h: * Source/WebCore/html/LazyLoading.cpp: Added. (WebCore::LazyLoading::hasLazyAttributeValue): (WebCore::LazyLoading::isInLazyState): (WebCore::LazyLoading::isLazyLoadingEnabled): (WebCore::LazyLoading::isLazyLoadable): * Source/WebCore/html/LazyLoading.h: Copied from Source/WebCore/html/LazyLoadElementObserver.h. * Source/WebCore/html/parser/HTMLPreloadScanner.cpp: (WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest): (WebCore::TokenPreloadScanner::StartTagScanner::isLazyloadingImage const): (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): * Source/WebCore/loader/ImageLoader.cpp: (WebCore::ImageLoader::updateFromElement): (WebCore::ImageLoader::notifyFinished): (WebCore::ImageLoader::updatedHasPendingEvent): (WebCore::ImageLoader::decode): (WebCore::ImageLoader::resetLazyImageLoading): * Source/WebCore/rendering/RenderImage.cpp: (WebCore::RenderImage::layout): Canonical link: https://commits.webkit.org/325572@main
…lazy load resumption steps run (lazymedia1) HTML 2.5.7 / 4.8.11 (whatwg/html#11980, #12970, #12972): a media element whose will lazy load element steps are true defers its resource selection until the lazy load intersection observer, the loading attribute turning Eager or play() runs its lazy load resumption steps. - Integrator ruling (6:44 AM ET), Chrome's ordering: the deferral is at step 12, before NETWORK_LOADING and loadstart, with networkState NETWORK_IDLE and the load event no longer delayed (Blink HTMLMediaElement:: SelectMediaResource, LazyMediaHelper::ShouldDeferMediaLoad; whatwg/html#12973 by the editor), as audio/video-loading-lazy- disconnected and -not-rendered assert (no loadstart). LoadState.deferLazy / resumeLazy; the resumed selection is awaited in a task (Blink posts LoadDeferredMediaIfNeededInternal) and runs on without the lazy check until the next load algorithm (Blink kFullMedia / InvokeLoadAlgorithm). - Observed when connected; a disconnected one at its insertion (Blink InsertedInto -> StartMonitoring); not rendered (display:none, an audio without controls) never intersects. - Step 4 and children step 24 delay the load event only for the Eager state (#12972); the invocation-time delay skips a lazy element. - load(): its resumption steps are cleared and the load algorithm defers again (#12975; Chrome 158 agrees: no load). The src attribute and srcObject run the load algorithm, not load(). - play() step 3 invokes them: integrator ruling (7:51 AM ET), golden rule 2's lag case (#11980's revision, #12975; Chrome's LoadDeferredMediaIfNeeded call sites predate it). - the loading attribute turning Eager: the media element's steps here, a video's poster steps in HTMLVideoElement (4.8.11.2 steps 5-6). Test: tests/wpt/crane/blk9-media-lazy-loading.html.
Specify support for the loading attribute for the video element and audio element using similar conventions to img and iframe, where the attribute already has precedent. Loading has possible values of eager and lazy. When a media element's loading attribute value is lazy, loading of any video or poster image data, as well as autoplay playback, will defer until layout is known and the video is in the viewport.
Note Jan 22, 2026: Broadening PR to include Audio Element support.
Fixes #10376
Fixes #6636
(See WHATWG Working Mode: Changes for more details.)
/acknowledgements.html ( diff )
/indices.html ( diff )
/media.html ( diff )
/urls-and-fetching.html ( diff )