[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor-browser] 26/73: Bug 1785186 - Use zero threshold for lazyload observer. r=hiro, a=RyanVM
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch geckoview-102.3.0esr-12.0-1
in repository tor-browser.
commit 8e154d75a8894c9e1c13a2142e5cd2c7297524ac
Author: Emilio Cobos Álvarez <emilio@xxxxxxxxx>
AuthorDate: Thu Aug 25 02:34:37 2022 +0000
Bug 1785186 - Use zero threshold for lazyload observer. r=hiro, a=RyanVM
This matches WebKit, and the spec:
https://html.spec.whatwg.org/#lazy-load-intersection-observer
Blink has very weird behavior where it treats a zero-area intersection
in this particular case with an intersectionRatio of one:
https://bugs.chromium.org/p/chromium/issues/detail?id=1356250
Which causes them to load the image even though they have a
numeric_limits::min threshold.
So this works in Chromium by chance, but should work per spec.
Differential Revision: https://phabricator.services.mozilla.com/D155501
---
dom/base/DOMIntersectionObserver.cpp | 4 ++--
.../image-loading-lazy-zero-intersection-area.html | 19 +++++++++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/dom/base/DOMIntersectionObserver.cpp b/dom/base/DOMIntersectionObserver.cpp
index 23c807c3470d7..78450a64c816e 100644
--- a/dom/base/DOMIntersectionObserver.cpp
+++ b/dom/base/DOMIntersectionObserver.cpp
@@ -178,7 +178,7 @@ already_AddRefed<DOMIntersectionObserver>
DOMIntersectionObserver::CreateLazyLoadObserver(Document& aDocument) {
RefPtr<DOMIntersectionObserver> observer =
new DOMIntersectionObserver(aDocument, LazyLoadCallback);
- observer->mThresholds.AppendElement(std::numeric_limits<double>::min());
+ observer->mThresholds.AppendElement(0.0f);
#define SET_MARGIN(side_, side_lower_) \
observer->mRootMargin.Get(eSide##side_) = PrefMargin( \
@@ -198,7 +198,7 @@ already_AddRefed<DOMIntersectionObserver>
DOMIntersectionObserver::CreateLazyLoadObserverViewport(Document& aDocument) {
RefPtr<DOMIntersectionObserver> observer =
new DOMIntersectionObserver(aDocument, LazyLoadCallbackReachViewport);
- observer->mThresholds.AppendElement(std::numeric_limits<double>::min());
+ observer->mThresholds.AppendElement(0.0f);
return observer.forget();
}
diff --git a/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/image-loading-lazy-zero-intersection-area.html b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/image-loading-lazy-zero-intersection-area.html
new file mode 100644
index 0000000000000..9962ce7837a9a
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/embedded-content/the-img-element/image-loading-lazy-zero-intersection-area.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Image with zero intersection area is lazy-loaded</title>
+<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@xxxxxxxxx">
+<link rel="author" title="Mozilla" href="https://mozilla.org">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-img-element">
+<link rel="help" href="https://html.spec.whatwg.org/#lazy-load-intersection-observer">
+<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1785186">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div style="height: 0; overflow: hidden;">
+ <img style="display: block" id=target loading="lazy" width="100" height="100">
+</div>
+<script>
+ async_test(function(t) {
+ target.addEventListener("load", t.step_func_done(function() {}));
+ target.src = "resources/image.png?zero-intersection-area";
+ });
+</script>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits