Title: [252205] trunk
Revision
252205
Author
[email protected]
Date
2019-11-07 14:18:37 -0800 (Thu, 07 Nov 2019)

Log Message

Integrate scroll event into HTML5 event loop
https://bugs.webkit.org/show_bug.cgi?id=203839
<rdar://problem/56890922>

Reviewed by Simon Fraser.

Source/WebCore:

Dispatch scroll events on each pending scroll event targets inside the update-the-rendering step
of the event loop as specified in the HTML5 and CSSOM View Module specifications:
https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering
https://drafts.csswg.org/cssom-view/#run-the-scroll-steps

The new behavior also matches that of Chrome and Firefox.

Like resize event, the current visual viewport specification does not specify when scroll event
is dispatched on visualViewport interface: https://github.com/WICG/visual-viewport/issues/66
For now, we always dispatch upon it after dispatching on all pending scroll event targets.

Tests: fast/events/scroll-multiple-elements-in-rendering-update.html
       fast/events/scroll-subframe-in-rendering-update.html
       fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe.html

* dom/Document.cpp:
(WebCore::Document::addPendingScrollEventTarget): Added.
(WebCore::Document::setNeedsVisualViewportScrollEvent): Added.
(WebCore::Document::runScrollSteps): Added. This implements run the scroll steps in CSS OM View.
* dom/Document.h:
* dom/DocumentEventQueue.cpp:
(WebCore::DocumentEventQueue::enqueueOrDispatchScrollEvent): Deleted.
(WebCore::DocumentEventQueue::enqueueScrollEvent): Deleted.
* dom/DocumentEventQueue.h:
* page/EventHandler.cpp:
(WebCore::EventHandler::sendScrollEvent):
* page/Page.cpp:
(WebCore::Page::updateRendering): Invoke runScrollSteps on each document in the frame tree order.
* page/VisualViewport.cpp:
(WebCore::VisualViewport::update):
(WebCore::VisualViewport::enqueueScrollEvent): Deleted.
* page/VisualViewport.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollTo):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::scrollTo):

LayoutTests:

Added tests to test the timing at which scroll events are fired across multiple elements and documents,
and with visualViewport, and updated the existing tests to work with the new timing.

* editing/selection/overflow-scroll-while-selecting-text.html:
* fast/events/scroll-multiple-elements-in-rendering-update-expected.txt: Added.
* fast/events/scroll-multiple-elements-in-rendering-update.html: Added.
* fast/events/scroll-subframe-in-rendering-update-expected.txt: Added.
* fast/events/scroll-subframe-in-rendering-update.html: Added.
* fast/scrolling/programmatic-scroll-to-negative-offset.html:
* fast/shadow-dom/trusted-event-scoped-flags.html:
* fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe-expected.txt: Added.
* fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe.html: Added.
* tiled-drawing/scrolling/fast-scroll-div-latched-mainframe.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (252204 => 252205)


--- trunk/LayoutTests/ChangeLog	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/LayoutTests/ChangeLog	2019-11-07 22:18:37 UTC (rev 252205)
@@ -1,3 +1,25 @@
+2019-11-06  Ryosuke Niwa  <[email protected]>
+
+        Integrate scroll event into HTML5 event loop
+        https://bugs.webkit.org/show_bug.cgi?id=203839
+        <rdar://problem/56890922>
+
+        Reviewed by Simon Fraser.
+
+        Added tests to test the timing at which scroll events are fired across multiple elements and documents,
+        and with visualViewport, and updated the existing tests to work with the new timing.
+
+        * editing/selection/overflow-scroll-while-selecting-text.html:
+        * fast/events/scroll-multiple-elements-in-rendering-update-expected.txt: Added.
+        * fast/events/scroll-multiple-elements-in-rendering-update.html: Added.
+        * fast/events/scroll-subframe-in-rendering-update-expected.txt: Added.
+        * fast/events/scroll-subframe-in-rendering-update.html: Added.
+        * fast/scrolling/programmatic-scroll-to-negative-offset.html:
+        * fast/shadow-dom/trusted-event-scoped-flags.html:
+        * fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe-expected.txt: Added.
+        * fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe.html: Added.
+        * tiled-drawing/scrolling/fast-scroll-div-latched-mainframe.html:
+
 2019-11-07  Justin Fan  <[email protected]>
 
         REGRESSION: r252121 introduced timeout in webgl/1.0.3/conformance/glsl/misc/shader-with-non-reserved-words.html

Modified: trunk/LayoutTests/editing/selection/overflow-scroll-while-selecting-text.html (252204 => 252205)


--- trunk/LayoutTests/editing/selection/overflow-scroll-while-selecting-text.html	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/LayoutTests/editing/selection/overflow-scroll-while-selecting-text.html	2019-11-07 22:18:37 UTC (rev 252205)
@@ -30,11 +30,13 @@
 
 const text = document.getElementById("text");
 text.scrollTo(0, 1000);
-addEventListener("load", () => text.scrollTo(0, 500));
-text.addEventListener("scroll", () => {
-    text.textContent = "";
-    testPassed("Successfully removed the text.");
-    finishJSTest();
+addEventListener("load", () => {
+    text.addEventListener("scroll", () => {
+        text.textContent = "";
+        testPassed("Successfully removed the text.");
+        finishJSTest();
+    });
+    text.scrollTo(0, 500);
 });
 </script>
 </html>

Added: trunk/LayoutTests/fast/events/scroll-subframe-in-rendering-update-expected.txt (0 => 252205)


--- trunk/LayoutTests/fast/events/scroll-subframe-in-rendering-update-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/scroll-subframe-in-rendering-update-expected.txt	2019-11-07 22:18:37 UTC (rev 252205)
@@ -0,0 +1,16 @@
+This tests that scroll event is dispatched in the update-the-rendering step in the event loop across all relevant frames
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+iframeB.contentWindow.scrollTo(0, 1000); updateLayout(iframeB)
+iframeA.contentWindow.scrollTo(0, 1000); updateLayout(iframeA)
+iframeAA.contentWindow.scrollTo(0, 1000); updateLayout(iframeAA)
+PASS logs.length is 0
+After requestAnimationFrame
+PASS logs.length is 3
+PASS logs.join(", ") is "A, AA, B"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/scroll-subframe-in-rendering-update.html (0 => 252205)


--- trunk/LayoutTests/fast/events/scroll-subframe-in-rendering-update.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/scroll-subframe-in-rendering-update.html	2019-11-07 22:18:37 UTC (rev 252205)
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+
+description('This tests that scroll event is dispatched in the update-the-rendering step in the event loop across all relevant frames');
+jsTestIsAsync = true;
+
+function createIframe(parentDocument)
+{
+    const iframe = document.createElement('iframe');
+    iframe.style.width = '100px';
+    iframe.style.height = '100px';
+    parentDocument.body.appendChild(iframe);
+    iframe.contentDocument.body.innerHTML = '<style> body { height: 2000px; } </style><span>hello, world</span>';
+    return iframe;
+}
+
+function updateLayout(iframe)
+{
+    iframe.contentDocument.querySelector("span").getBoundingClientRect();
+}
+
+const iframeA = createIframe(document);
+const iframeAA = createIframe(iframeA.contentDocument);
+const iframeB = createIframe(document);
+
+const logs = [];
+requestAnimationFrame(() => {
+    setTimeout(() => {
+        iframeAA.contentDocument.addEventListener('scroll', () => logs.push('AA'));
+        iframeA.contentDocument.addEventListener('scroll', () => logs.push('A'));
+        iframeB.contentDocument.addEventListener('scroll', () => logs.push('B'));
+
+        evalAndLog('iframeB.contentWindow.scrollTo(0, 1000); updateLayout(iframeB)');
+        evalAndLog('iframeA.contentWindow.scrollTo(0, 1000); updateLayout(iframeA)');
+        evalAndLog('iframeAA.contentWindow.scrollTo(0, 1000); updateLayout(iframeAA)');
+        shouldBe('logs.length', '0');
+        setTimeout(() => {
+            requestAnimationFrame(() => {
+                debug('After requestAnimationFrame');
+                shouldBe('logs.length', '3');
+                shouldBeEqualToString('logs.join(", ")', 'A, AA, B');
+                iframeA.remove();
+                iframeB.remove();
+                finishJSTest();
+            });
+        }, 0);
+    }, 0);
+});
+
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/fast/scrolling/programmatic-scroll-to-negative-offset.html (252204 => 252205)


--- trunk/LayoutTests/fast/scrolling/programmatic-scroll-to-negative-offset.html	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/LayoutTests/fast/scrolling/programmatic-scroll-to-negative-offset.html	2019-11-07 22:18:37 UTC (rev 252205)
@@ -25,13 +25,13 @@
             scroller = document.getElementById('scroller');
 			scroller.scrollLeft = 50;
 
-			scroller.addEventListener('scroll', (event) => {
-				shouldBe("scroller.scrollLeft", "0");
-				shouldBe("scroller.scrollLeft", "0");
-				finishJSTest();
-			}, false);
+			setTimeout(() => {
+    			scroller.addEventListener('scroll', (event) => {
+    				shouldBe("scroller.scrollLeft", "0");
+    				shouldBe("scroller.scrollLeft", "0");
+    				finishJSTest();
+    			}, false);
 
-			setTimeout(() => {
 				scroller.scrollLeft = -200;
 				scroller.scrollTop = -100;
 			}, 0)

Modified: trunk/LayoutTests/fast/shadow-dom/trusted-event-scoped-flags.html (252204 => 252205)


--- trunk/LayoutTests/fast/shadow-dom/trusted-event-scoped-flags.html	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/LayoutTests/fast/shadow-dom/trusted-event-scoped-flags.html	2019-11-07 22:18:37 UTC (rev 252205)
@@ -96,11 +96,13 @@
     log(window, 'scroll');
     setTimeout(function () {
         window.scrollTo(0, 1000);
-        setTimeout(function () {
-            checkFlags('', {eventType: 'scroll', composed: false});
-            window.scrollTo(0, 0);
-            testResizeEvent();
-        }, 0);
+        requestAnimationFrame(() => {
+            setTimeout(function () {
+                checkFlags('', {eventType: 'scroll', composed: false});
+                window.scrollTo(0, 0);
+                testResizeEvent();
+            }, 0);
+        });
     }, 0);
 }
 

Added: trunk/LayoutTests/fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe-expected.txt (0 => 252205)


--- trunk/LayoutTests/fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe-expected.txt	2019-11-07 22:18:37 UTC (rev 252205)
@@ -0,0 +1,9 @@
+Tests that scroll event on visualViewport fires after resize event in a subframe. To manually test, pinch zoom.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe.html (0 => 252205)


--- trunk/LayoutTests/fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe.html	                        (rev 0)
+++ trunk/LayoutTests/fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe.html	2019-11-07 22:18:37 UTC (rev 252205)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<body style="width: 2000px; height: 2000px;">
+<script src=""
+<script>
+
+description('Tests that scroll event on visualViewport fires after resize event in a subframe. To manually test, pinch zoom.');
+
+const jsTestIsAsync = true;
+
+const iframe = document.createElement('iframe');
+document.body.appendChild(iframe);
+iframe.contentDocument.body.innerHTML = '<span>hi</span>';
+        
+async function zoom() {
+    if (!window.testRunner) {
+        return new Promise((resolve) => {
+            window.visualViewport.addEventListener('resize', resolve);
+        });
+    }
+
+    return new Promise((resolve) => {
+        testRunner.runUIScript(`(function() {
+            uiController.zoomToScale(${pageScaleFactor}, function() {
+                uiController.uiScriptComplete(uiController.zoomScale);
+            });
+        })();`, resolve);
+    });
+}
+
+const events = [];
+
+window._onload_ = async function () {
+    requestAnimationFrame(async () => {
+        await zoom();
+
+        iframe.contentWindow.addEventListener('resize', () => {
+            events.push('resize');
+        });
+        window.visualViewport.addEventListener('scroll', () => {
+            events.push('scroll');
+        });
+        window.scrollTo(1000, 1000);
+
+        iframe.style.width = '100px';
+        iframe.style.height = '100px';
+        window.rect = iframe.contentDocument.querySelector('span').getBoundingClientRect();
+
+        requestAnimationFrame(() => {
+            shouldBeEqualToString('events.join(", ")', 'resize, scroll');
+        });
+    });
+};
+
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe.html (252204 => 252205)


--- trunk/LayoutTests/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe.html	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/LayoutTests/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe.html	2019-11-07 22:18:37 UTC (rev 252205)
@@ -47,8 +47,13 @@
         checkForScroll();
 }
 
+let didCheck = false;
 function checkForScroll()
 {
+    if (didCheck)
+        return;
+    didCheck = true;
+
     // The div should not have scrolled at all.
     var pageScrollPositionAfter = document.scrollingElement.scrollTop;
     var divScrollPositionAfter = divTarget.scrollTop;
@@ -96,7 +101,9 @@
         testRunner.waitUntilDone();
 
         eventSender.monitorWheelEvents();
-        setTimeout(scrollTest, 0);
+        requestIdleCallback(() => {
+            setTimeout(scrollTest, 0);
+        });
     } else {
         var messageLocation = document.getElementById('parent');
         var message = document.createElement('div');

Modified: trunk/Source/WebCore/ChangeLog (252204 => 252205)


--- trunk/Source/WebCore/ChangeLog	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/Source/WebCore/ChangeLog	2019-11-07 22:18:37 UTC (rev 252205)
@@ -1,3 +1,48 @@
+2019-11-06  Ryosuke Niwa  <[email protected]>
+
+        Integrate scroll event into HTML5 event loop
+        https://bugs.webkit.org/show_bug.cgi?id=203839
+        <rdar://problem/56890922>
+
+        Reviewed by Simon Fraser.
+
+        Dispatch scroll events on each pending scroll event targets inside the update-the-rendering step
+        of the event loop as specified in the HTML5 and CSSOM View Module specifications:
+        https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering
+        https://drafts.csswg.org/cssom-view/#run-the-scroll-steps
+
+        The new behavior also matches that of Chrome and Firefox.
+
+        Like resize event, the current visual viewport specification does not specify when scroll event
+        is dispatched on visualViewport interface: https://github.com/WICG/visual-viewport/issues/66
+        For now, we always dispatch upon it after dispatching on all pending scroll event targets.
+
+        Tests: fast/events/scroll-multiple-elements-in-rendering-update.html
+               fast/events/scroll-subframe-in-rendering-update.html
+               fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::addPendingScrollEventTarget): Added.
+        (WebCore::Document::setNeedsVisualViewportScrollEvent): Added.
+        (WebCore::Document::runScrollSteps): Added. This implements run the scroll steps in CSS OM View.
+        * dom/Document.h:
+        * dom/DocumentEventQueue.cpp:
+        (WebCore::DocumentEventQueue::enqueueOrDispatchScrollEvent): Deleted.
+        (WebCore::DocumentEventQueue::enqueueScrollEvent): Deleted.
+        * dom/DocumentEventQueue.h:
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::sendScrollEvent):
+        * page/Page.cpp:
+        (WebCore::Page::updateRendering): Invoke runScrollSteps on each document in the frame tree order.
+        * page/VisualViewport.cpp:
+        (WebCore::VisualViewport::update):
+        (WebCore::VisualViewport::enqueueScrollEvent): Deleted.
+        * page/VisualViewport.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollTo):
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::scrollTo):
+
 2019-11-07  Zalan Bujtas  <[email protected]>
 
         [LFC][MarginCollapsing] Drag anonymous block level boxes into margin collapsing

Modified: trunk/Source/WebCore/dom/Document.cpp (252204 => 252205)


--- trunk/Source/WebCore/dom/Document.cpp	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/Source/WebCore/dom/Document.cpp	2019-11-07 22:18:37 UTC (rev 252205)
@@ -4001,6 +4001,48 @@
     }
 }
 
+void Document::addPendingScrollEventTarget(ContainerNode& target)
+{
+    if (m_pendingScrollEventTargets.contains(&target))
+        return;
+
+    if (m_pendingScrollEventTargets.isEmpty())
+        scheduleTimedRenderingUpdate();
+
+    m_pendingScrollEventTargets.append(makeWeakPtr(target));
+}
+
+void Document::setNeedsVisualViewportScrollEvent()
+{
+    if (!m_needsVisualViewportScrollEvent)
+        scheduleTimedRenderingUpdate();
+    m_needsVisualViewportScrollEvent = true;
+}
+
+// https://drafts.csswg.org/cssom-view/#run-the-scroll-steps
+void Document::runScrollSteps()
+{
+    // FIXME: The order of dispatching is not specified: https://github.com/WICG/visual-viewport/issues/66.
+    if (!m_pendingScrollEventTargets.isEmpty()) {
+        LOG_WITH_STREAM(Events, stream << "Document" << this << "sending scroll events to pending scroll event targets");
+        auto currentTargets = WTFMove(m_pendingScrollEventTargets);
+        for (auto target : currentTargets) {
+            auto protectedTarget = makeRefPtr(target.get());
+            ASSERT(protectedTarget);
+            if (!protectedTarget)
+                continue;
+            auto bubbles = protectedTarget->isDocumentNode() ? Event::CanBubble::Yes : Event::CanBubble::No;
+            protectedTarget->dispatchEvent(Event::create(eventNames().scrollEvent, bubbles, Event::IsCancelable::No));
+        }
+    }
+    if (m_needsVisualViewportScrollEvent) {
+        LOG_WITH_STREAM(Events, stream << "Document" << this << "sending scroll events to visualViewport");
+        m_needsVisualViewportResizeEvent = false;
+        if (auto* window = domWindow())
+            window->visualViewport().dispatchEvent(Event::create(eventNames().scrollEvent, Event::CanBubble::No, Event::IsCancelable::No));
+    }
+}
+
 void Document::addAudioProducer(MediaProducer& audioProducer)
 {
     m_audioProducers.add(audioProducer);

Modified: trunk/Source/WebCore/dom/Document.h (252204 => 252205)


--- trunk/Source/WebCore/dom/Document.h	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/Source/WebCore/dom/Document.h	2019-11-07 22:18:37 UTC (rev 252205)
@@ -1364,6 +1364,10 @@
     void setNeedsVisualViewportResize();
     void runResizeSteps();
 
+    void addPendingScrollEventTarget(ContainerNode&);
+    void setNeedsVisualViewportScrollEvent();
+    void runScrollSteps();
+
     WEBCORE_EXPORT void addAudioProducer(MediaProducer&);
     WEBCORE_EXPORT void removeAudioProducer(MediaProducer&);
     MediaProducer::MediaStateFlags mediaState() const { return m_mediaState; }
@@ -2019,6 +2023,7 @@
     bool m_hasStyleWithViewportUnits { false };
     bool m_needsDOMWindowResizeEvent { false };
     bool m_needsVisualViewportResizeEvent { false };
+    bool m_needsVisualViewportScrollEvent { false };
     bool m_isTimerThrottlingEnabled { false };
     bool m_isSuspended { false };
 
@@ -2035,6 +2040,8 @@
     bool m_isTelephoneNumberParsingAllowed { true };
 #endif
 
+    Vector<WeakPtr<ContainerNode>> m_pendingScrollEventTargets;
+
 #if ENABLE(MEDIA_STREAM)
     HashSet<HTMLMediaElement*> m_mediaStreamStateChangeElements;
     String m_idHashSalt;

Modified: trunk/Source/WebCore/dom/DocumentEventQueue.cpp (252204 => 252205)


--- trunk/Source/WebCore/dom/DocumentEventQueue.cpp	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/Source/WebCore/dom/DocumentEventQueue.cpp	2019-11-07 22:18:37 UTC (rev 252205)
@@ -81,30 +81,6 @@
     return true;
 }
 
-void DocumentEventQueue::enqueueOrDispatchScrollEvent(Node& target)
-{
-    ASSERT(&target.document() == &m_document);
-
-    // Per the W3C CSSOM View Module, scroll events fired at the document should bubble, others should not.
-    enqueueScrollEvent(target, target.isDocumentNode() ? Event::CanBubble::Yes : Event::CanBubble::No, Event::IsCancelable::No);
-}
-
-void DocumentEventQueue::enqueueScrollEvent(EventTarget& target, Event::CanBubble canBubble, Event::IsCancelable cancelable)
-{
-    if (m_isClosed)
-        return;
-
-    if (!m_document.hasListenerType(Document::SCROLL_LISTENER))
-        return;
-
-    if (!m_targetsWithQueuedScrollEvents.add(&target).isNewEntry)
-        return;
-
-    Ref<Event> scrollEvent = Event::create(eventNames().scrollEvent, canBubble, cancelable);
-    scrollEvent->setTarget(&target);
-    enqueueEvent(WTFMove(scrollEvent));
-}
-
 bool DocumentEventQueue::cancelEvent(Event& event)
 {
     bool found = m_queuedEvents.remove(&event);

Modified: trunk/Source/WebCore/dom/DocumentEventQueue.h (252204 => 252205)


--- trunk/Source/WebCore/dom/DocumentEventQueue.h	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/Source/WebCore/dom/DocumentEventQueue.h	2019-11-07 22:18:37 UTC (rev 252205)
@@ -47,8 +47,6 @@
     bool cancelEvent(Event&) override;
     void close() override;
 
-    void enqueueOrDispatchScrollEvent(Node&);
-    void enqueueScrollEvent(EventTarget&, Event::CanBubble, Event::IsCancelable);
 
 private:
     void pendingEventTimerFired();

Modified: trunk/Source/WebCore/page/EventHandler.cpp (252204 => 252205)


--- trunk/Source/WebCore/page/EventHandler.cpp	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2019-11-07 22:18:37 UTC (rev 252205)
@@ -4029,8 +4029,12 @@
 {
     Ref<Frame> protectedFrame(m_frame);
     setFrameWasScrolledByUser();
-    if (m_frame.view() && m_frame.document())
-        m_frame.document()->eventQueue().enqueueOrDispatchScrollEvent(*m_frame.document());
+    if (!m_frame.view())
+        return;
+    auto document = makeRefPtr(m_frame.document());
+    if (!document)
+        return;
+    document->addPendingScrollEventTarget(*document);
 }
 
 void EventHandler::setFrameWasScrolledByUser()

Modified: trunk/Source/WebCore/page/Page.cpp (252204 => 252205)


--- trunk/Source/WebCore/page/Page.cpp	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/Source/WebCore/page/Page.cpp	2019-11-07 22:18:37 UTC (rev 252205)
@@ -1290,11 +1290,15 @@
 
     layoutIfNeeded();
 
+    // Flush autofocus candidates
+
     forEachDocument([&](Document& document) {
         document.runResizeSteps();
     });
 
-    // FIXME: Run the scroll steps
+    forEachDocument([&](Document& document) {
+        document.runScrollSteps();
+    });
 
     forEachDocument([&](Document& document) {
         document.evaluateMediaQueriesAndReportChanges();        
@@ -1319,9 +1323,6 @@
         document->updateResizeObservations(*this);
 #endif
 
-    // FIXME: Flush autofocus candidates
-    // https://github.com/whatwg/html/issues/4992
-
     layoutIfNeeded();
 }
 

Modified: trunk/Source/WebCore/page/VisualViewport.cpp (252204 => 252205)


--- trunk/Source/WebCore/page/VisualViewport.cpp	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/Source/WebCore/page/VisualViewport.cpp	2019-11-07 22:18:37 UTC (rev 252205)
@@ -168,14 +168,16 @@
             scale = page->pageScaleFactor();
     }
 
+    RefPtr<Document> document = frame ? frame->document() : nullptr;
     if (m_offsetLeft != offsetLeft || m_offsetTop != offsetTop) {
-        enqueueScrollEvent();
+        if (document)
+            document->setNeedsVisualViewportScrollEvent();
         m_offsetLeft = offsetLeft;
         m_offsetTop = offsetTop;
     }
     if (m_width != width || m_height != height || m_scale != scale) {
-        if (auto* frame = this->frame())
-            frame->document()->setNeedsVisualViewportResize();
+        if (document)
+            document->setNeedsVisualViewportResize();
         m_width = width;
         m_height = height;
         m_scale = scale;
@@ -182,13 +184,4 @@
     }
 }
 
-void VisualViewport::enqueueScrollEvent()
-{
-    auto* frame = this->frame();
-    if (!frame)
-        return;
-
-    frame->document()->eventQueue().enqueueScrollEvent(*this, Event::CanBubble::No, Event::IsCancelable::No);
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/VisualViewport.h (252204 => 252205)


--- trunk/Source/WebCore/page/VisualViewport.h	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/Source/WebCore/page/VisualViewport.h	2019-11-07 22:18:37 UTC (rev 252205)
@@ -60,9 +60,6 @@
     void refEventTarget() final { ref(); }
     void derefEventTarget() final { deref(); }
 
-    void enqueueResizeEvent();
-    void enqueueScrollEvent();
-
     void updateFrameLayout() const;
 
     double m_offsetLeft { 0 };

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (252204 => 252205)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2019-11-07 22:18:37 UTC (rev 252205)
@@ -2673,7 +2673,7 @@
 
     // Schedule the scroll and scroll-related DOM events.
     if (Element* element = renderer().element())
-        element->document().eventQueue().enqueueOrDispatchScrollEvent(*element);
+        element->document().addPendingScrollEventTarget(*element);
 
     if (scrollsOverflow())
         view.frameView().didChangeScrollOffset();

Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (252204 => 252205)


--- trunk/Source/WebCore/rendering/RenderListBox.cpp	2019-11-07 21:34:15 UTC (rev 252204)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp	2019-11-07 22:18:37 UTC (rev 252205)
@@ -713,7 +713,7 @@
     computeFirstIndexesVisibleInPaddingTopBottomAreas();
 
     repaint();
-    document().eventQueue().enqueueOrDispatchScrollEvent(selectElement());
+    document().addPendingScrollEventTarget(selectElement());
 }
 
 LayoutUnit RenderListBox::itemHeight() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to