Determine viewport distances for lazy image loading
https://bugs.webkit.org/show_bug.cgi?id=203557
Patch by Rob Buis <rbuis@igalia.com> on 2021-10-13
Reviewed by Simon Fraser.
Determine appropriate lazy image loading viewport distances
for desktop and mobile devices by using a lazy load distance
of one viewport in all directions.
* html/LazyLoadImageObserver.cpp:
(WebCore::LazyLoadImageObserver::intersectionObserver):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@284148 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index e5d2029..6c2c66d 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2021-10-13 Rob Buis <rbuis@igalia.com>
+
+ Determine viewport distances for lazy image loading
+ https://bugs.webkit.org/show_bug.cgi?id=203557
+
+ Reviewed by Simon Fraser.
+
+ Determine appropriate lazy image loading viewport distances
+ for desktop and mobile devices by using a lazy load distance
+ of one viewport in all directions.
+
+ * html/LazyLoadImageObserver.cpp:
+ (WebCore::LazyLoadImageObserver::intersectionObserver):
+
2021-10-13 Jean-Yves Avenard <jya@apple.com>
Compilation error: error: definition of implicit copy assignment operator in AppHighlightRangeData.h
diff --git a/Source/WebCore/html/LazyLoadImageObserver.cpp b/Source/WebCore/html/LazyLoadImageObserver.cpp
index 836dc82..176a6ef 100644
--- a/Source/WebCore/html/LazyLoadImageObserver.cpp
+++ b/Source/WebCore/html/LazyLoadImageObserver.cpp
@@ -29,7 +29,6 @@
#include "Frame.h"
#include "HTMLImageElement.h"
#include "IntersectionObserverCallback.h"
-#include "RenderStyle.h"
#include <limits>
@@ -86,7 +85,8 @@
{
if (!m_observer) {
auto callback = LazyImageLoadIntersectionObserverCallback::create(document);
- IntersectionObserver::Init options { std::nullopt, emptyString(), { } };
+ static NeverDestroyed<const String> lazyLoadingRootMarginFallback(MAKE_STATIC_STRING_IMPL("100%"));
+ IntersectionObserver::Init options { std::nullopt, lazyLoadingRootMarginFallback, { } };
auto observer = IntersectionObserver::create(document, WTFMove(callback), WTFMove(options));
if (observer.hasException())
return nullptr;