Conversation
|
EWS run on previous version of this PR (hash 95e1fb2) Details |
| if (!m_observer) { | ||
| auto callback = LazyImageLoadIntersectionObserverCallback::create(document); | ||
| auto callback = LazyLoadIntersectionObserverCallback::create(document); | ||
| static NeverDestroyed<const String> lazyLoadingScrollMarginFallback(MAKE_STATIC_STRING_IMPL("100%")); |
There was a problem hiding this comment.
One thing to call out here is that the lazy loading behavior for <iframe> will change. LazyLoadFrameObserver didn't previously specify custom scrollMargin, meaning that <iframe> elements would only "intersect" when they entered the viewport. Here, we are setting this value to be 100%, which is what was done for LazyLoadImageObserver and LazyLoadModelObserver.
The HTML spec suggests that we should be reusing the lazy load observer instance across <img> and <iframe>:
For img and iframe elements that will lazy load, these steps are run from the lazy load intersection observer's callback or when their lazy loading attribute is set to the Eager state. This causes the element to continue loading.
Therefore, this change would ensure that Webkit is following this standard outlined by the spec but I'm curious to know what people think about this behavioral change.
There was a problem hiding this comment.
Seems OK, but I'd like the behavior change to be confirmed by a new test (or a newly passing test). Are there any WPT for iframe lazy loading that use scroll-margin?
There was a problem hiding this comment.
WPT tests typically seem to allow generous scroll margins so that browsers can implement lazy-loading to their liking. I did run existing WPT tests against this patch and seems like this implementation matches existing behavior, and additionally gets us passing a few more tests actually:
<iframe> loading tests in Safari |
<iframe> loading tests in MiniBrowser (with changes from this patch) |
|---|---|
![]() |
![]() |
| if (!m_observer) { | ||
| auto callback = LazyImageLoadIntersectionObserverCallback::create(document); | ||
| auto callback = LazyLoadIntersectionObserverCallback::create(document); | ||
| static NeverDestroyed<const String> lazyLoadingScrollMarginFallback(MAKE_STATIC_STRING_IMPL("100%")); |
There was a problem hiding this comment.
Seems OK, but I'd like the behavior change to be confirmed by a new test (or a newly passing test). Are there any WPT for iframe lazy loading that use scroll-margin?
| element->document().lazyLoadImageObserver().unobserve(*element, element->document()); | ||
| } | ||
| if (RefPtr element = dynamicDowncast<HTMLImageElement>(entry->target())) | ||
| element->lazyLoadIntersectionCallbackInvoked(entry->isIntersecting()); |
There was a problem hiding this comment.
Maybe Element could have a virtual lazyLoadIntersectionCallbackInvoked, so you don't need to dynamicDowncast here
There was a problem hiding this comment.
That could certainly clean things up here, but it kind of feels like overkill for Element to be aware of this, since it only impacts a few specific elements for now. However, I'm happy to make this change if we think this is a better approach!
| element->document().lazyLoadImageObserver().unobserve(*element, element->document()); | ||
| } | ||
| if (RefPtr element = dynamicDowncast<HTMLImageElement>(entry->target())) | ||
| element->lazyLoadIntersectionCallbackInvoked(entry->isIntersecting()); |
There was a problem hiding this comment.
Maybe Element could have a virtual lazyLoadIntersectionCallbackInvoked, so you don't need to dynamicDowncast here
macOS Safer C++ Build #83729 (95e1fb2)❌ Found 2 failing files with 8 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
iOS Safer C++ Build #2019 (95e1fb2)❌ Found 3 failing files with 9 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
95e1fb2 to
d7bb612
Compare
|
EWS run on previous version of this PR (hash d7bb612) Details |
macOS Safer C++ Build #83792 (d7bb612)
|
iOS Safer C++ Build #2082 (d7bb612)❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
|
d7bb612 to
aa6db59
Compare
|
EWS run on previous version of this PR (hash aa6db59) Details |
|
Thanks for doing the cleanup! |
macOS Safer C++ Build #83945 (aa6db59)
|
https://bugs.webkit.org/show_bug.cgi?id=309078 Reviewed by NOBODY (OOPS!). Consolidates LazyLoadImageObserver, LazyLoadFrameObserver, and LazyLoadModelObserver to a single LazyLoadElementObserver. * Source/WebCore/Modules/model-element/HTMLModelElement.cpp: (WebCore::HTMLModelElement::~HTMLModelElement): (WebCore::HTMLModelElement::stop): (WebCore::HTMLModelElement::insertedIntoAncestor): (WebCore::HTMLModelElement::removedFromAncestor): (WebCore::HTMLModelElement::lazyLoadIntersectionCallbackInvoked): (WebCore::HTMLModelElement::viewportIntersectionChanged): Deleted. * Source/WebCore/Modules/model-element/HTMLModelElement.h: * Source/WebCore/Modules/model-element/LazyLoadModelObserver.cpp: Removed. * Source/WebCore/Modules/model-element/LazyLoadModelObserver.h: Removed. * Source/WebCore/Modules/webtransport/WebTransportDatagramsWritable.h: * Source/WebCore/SaferCPPExpectations/NoDeleteCheckerExpectations: * Source/WebCore/SaferCPPExpectations/UncheckedCallArgsCheckerExpectations: * Source/WebCore/SaferCPPExpectations/UncountedCallArgsCheckerExpectations: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/dom/Document.cpp: (WebCore::Document::lazyLoadElementObserver): (WebCore::Document::lazyLoadImageObserver): Deleted. (WebCore::Document::lazyLoadModelObserver): Deleted. * Source/WebCore/dom/Document.h: * Source/WebCore/html/HTMLIFrameElement.cpp: (WebCore::HTMLIFrameElement::attributeChanged): (WebCore::HTMLIFrameElement::referrerPolicy const): (WebCore::HTMLIFrameElement::shouldLoadFrameLazily): (WebCore::HTMLIFrameElement::isLazyLoadObserverActive const): (WebCore::HTMLIFrameElement::loadDeferredFrame): (WebCore::HTMLIFrameElement::lazyLoadIntersectionCallbackInvoked): (WebCore::HTMLIFrameElement::lazyLoadFrameObserver): Deleted. * Source/WebCore/html/HTMLIFrameElement.h: * Source/WebCore/html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::lazyLoadIntersectionCallbackInvoked): * Source/WebCore/html/HTMLImageElement.h: * Source/WebCore/html/LazyLoadElementObserver.cpp: Renamed from Source/WebCore/html/LazyLoadImageObserver.cpp. (WebCore::LazyLoadElementObserver::observe): (WebCore::LazyLoadElementObserver::unobserve): (WebCore::LazyLoadElementObserver::intersectionObserver): (WebCore::LazyLoadElementObserver::isObserved const): * Source/WebCore/html/LazyLoadElementObserver.h: Renamed from Source/WebCore/html/LazyLoadImageObserver.h. * Source/WebCore/html/LazyLoadFrameObserver.cpp: Removed. * Source/WebCore/html/LazyLoadFrameObserver.h: Removed. * Source/WebCore/html/Origin.cpp: * Source/WebCore/html/shadow/ProgressShadowElement.cpp: * Source/WebCore/loader/ImageLoader.cpp: (WebCore::ImageLoader::didUpdateCachedImage): (WebCore::ImageLoader::notifyFinished): (WebCore::ImageLoader::resetLazyImageLoading):
aa6db59 to
583d2f0
Compare
|
EWS run on current version of this PR (hash 583d2f0) Details |


583d2f0
🛠 playstation