[IntersectionObserver] Regression: No initial observation when nothing else triggers...
authorajuma@chromium.org <ajuma@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 May 2019 13:54:56 +0000 (13:54 +0000)
committerajuma@chromium.org <ajuma@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 May 2019 13:54:56 +0000 (13:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197891

Reviewed by Simon Fraser.

Source/WebCore:

Schedule a rendering update whenever a new IntersectionObserver target is added.

Test: intersection-observer/initial-observation.html

* page/IntersectionObserver.cpp:
(WebCore::IntersectionObserver::observe):

LayoutTests:

Add a test where other timers that can schedule rendering updates are disabled,
in order to verify that IntersectionObserver is scheduling rendering updates
itself.

* intersection-observer/initial-observation.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245396 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/intersection-observer/initial-observation-expected.txt [new file with mode: 0644]
LayoutTests/intersection-observer/initial-observation.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/IntersectionObserver.cpp

index ab3bd9d..a8108e7 100644 (file)
@@ -1,3 +1,16 @@
+2019-05-16  Ali Juma  <ajuma@chromium.org>
+
+        [IntersectionObserver] Regression: No initial observation when nothing else triggers rendering
+        https://bugs.webkit.org/show_bug.cgi?id=197891
+
+        Reviewed by Simon Fraser.
+
+        Add a test where other timers that can schedule rendering updates are disabled,
+        in order to verify that IntersectionObserver is scheduling rendering updates
+        itself.
+
+        * intersection-observer/initial-observation.html: Added.
+
 2019-05-15  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: user gesture toggle should also force user interaction flag
diff --git a/LayoutTests/intersection-observer/initial-observation-expected.txt b/LayoutTests/intersection-observer/initial-observation-expected.txt
new file mode 100644 (file)
index 0000000..b6bd13f
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS An initial observation is fired even when nothing else triggers rendering 
+
diff --git a/LayoutTests/intersection-observer/initial-observation.html b/LayoutTests/intersection-observer/initial-observation.html
new file mode 100644 (file)
index 0000000..6292047
--- /dev/null
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<script>
+if (window.internals) {
+    // Disable timers that trigger delayed flushes, since these will make
+    // this test pass spuriously, even if IntersectionObserver never
+    // schedules any rendering updates.
+    internals.setSpeculativeTilingDelayDisabledForTesting(true);
+    internals.disableTileSizeUpdateDelay();
+}
+
+window.onload = function() {
+async_test((t) => {
+    var observer = new IntersectionObserver(t.step_func_done(() => {
+        observer.disconnect();
+    }));
+    requestAnimationFrame(() => {
+        requestAnimationFrame(() => {
+            setTimeout(() => {
+                observer.observe(document.getElementById("target"));
+            }, 0);
+        });
+    });
+}, "An initial observation is fired even when nothing else triggers rendering");
+};
+</script>
+
+<style>
+#target {
+  width: 100px;
+  height: 100px;
+  background-color: green;
+}
+</style>
+
+<div id="target"></div>
+
index 1757f4f..0bd242b 100644 (file)
@@ -1,3 +1,17 @@
+2019-05-16  Ali Juma  <ajuma@chromium.org>
+
+        [IntersectionObserver] Regression: No initial observation when nothing else triggers rendering
+        https://bugs.webkit.org/show_bug.cgi?id=197891
+
+        Reviewed by Simon Fraser.
+
+        Schedule a rendering update whenever a new IntersectionObserver target is added.
+
+        Test: intersection-observer/initial-observation.html
+
+        * page/IntersectionObserver.cpp:
+        (WebCore::IntersectionObserver::observe):
+
 2019-05-16  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [FreeType] Some character sequences with a variation selector are not rendered
index 1836278..669b86f 100644 (file)
@@ -158,6 +158,7 @@ void IntersectionObserver::observe(Element& target)
     auto* document = trackingDocument();
     if (!hadObservationTargets)
         document->addIntersectionObserver(*this);
+    document->scheduleRenderingUpdate();
 }
 
 void IntersectionObserver::unobserve(Element& target)