Unreviewed, rolling out r251269, r251294, and r251328.
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Oct 2019 22:40:07 +0000 (22:40 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Oct 2019 22:40:07 +0000 (22:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203384

Probably made many animation tests flaky (Requested by rniwa
on #webkit).

Reverted changesets:

"Integrate resize event with HTML5 event loop"
https://bugs.webkit.org/show_bug.cgi?id=202964
https://trac.webkit.org/changeset/251269

"Flaky Test: fast/events/resize-subframe-in-rendering-
update.html"
https://bugs.webkit.org/show_bug.cgi?id=203140
https://trac.webkit.org/changeset/251294

"Flaky Test: fast/events/resize-subframe-in-rendering-
update.html"
https://bugs.webkit.org/show_bug.cgi?id=203140
https://trac.webkit.org/changeset/251328

Patch by Commit Queue <commit-queue@webkit.org> on 2019-10-24

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

LayoutTests/ChangeLog
LayoutTests/fast/events/resize-subframe-in-rendering-update-expected.txt [deleted file]
LayoutTests/fast/events/resize-subframe-in-rendering-update.html [deleted file]
LayoutTests/fast/shadow-dom/trusted-event-scoped-flags.html
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/VisualViewport.cpp

index 8fb6389..a55da76 100644 (file)
@@ -1,3 +1,27 @@
+2019-10-24  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r251269, r251294, and r251328.
+        https://bugs.webkit.org/show_bug.cgi?id=203384
+
+        Probably made many animation tests flaky (Requested by rniwa
+        on #webkit).
+
+        Reverted changesets:
+
+        "Integrate resize event with HTML5 event loop"
+        https://bugs.webkit.org/show_bug.cgi?id=202964
+        https://trac.webkit.org/changeset/251269
+
+        "Flaky Test: fast/events/resize-subframe-in-rendering-
+        update.html"
+        https://bugs.webkit.org/show_bug.cgi?id=203140
+        https://trac.webkit.org/changeset/251294
+
+        "Flaky Test: fast/events/resize-subframe-in-rendering-
+        update.html"
+        https://bugs.webkit.org/show_bug.cgi?id=203140
+        https://trac.webkit.org/changeset/251328
+
 2019-10-24  Sihui Liu  <sihui_liu@apple.com>
 
         [ Mac WK1 ] REGRESSION (r251261): Layout Test inspector/console/webcore-logging.html is consistently Failing
diff --git a/LayoutTests/fast/events/resize-subframe-in-rendering-update-expected.txt b/LayoutTests/fast/events/resize-subframe-in-rendering-update-expected.txt
deleted file mode 100644 (file)
index 27af3b1..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-This tests that resize event is not dispatched as a part of updateLayout
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-iframeB.style.width = "200px"; updateLayout(iframeB)
-iframeA.style.width = "200px"; updateLayout(iframeA)
-iframeAA.style.width = "200px"; 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
-
diff --git a/LayoutTests/fast/events/resize-subframe-in-rendering-update.html b/LayoutTests/fast/events/resize-subframe-in-rendering-update.html
deleted file mode 100644 (file)
index 2881805..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-<script src="../../resources/js-test.js"></script>
-<script>
-
-description('This tests that resize event is not dispatched as a part of updateLayout');
-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 = '<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.contentWindow.addEventListener('resize', () => logs.push('AA'));
-        iframeA.contentWindow.addEventListener('resize', () => logs.push('A'));
-        iframeB.contentWindow.addEventListener('resize', () => logs.push('B'));
-
-        evalAndLog('iframeB.style.width = "200px"; updateLayout(iframeB)');
-        evalAndLog('iframeA.style.width = "200px"; updateLayout(iframeA)');
-        evalAndLog('iframeAA.style.width = "200px"; updateLayout(iframeAA)');
-        shouldBe('logs.length', '0');
-        requestAnimationFrame(() => {
-            debug('After requestAnimationFrame');
-            shouldBe('logs.length', '3');
-            shouldBeEqualToString('logs.join(", ")', 'A, AA, B');
-            iframeA.remove();
-            iframeB.remove();
-            finishJSTest();
-        });
-    }, 0);
-});
-
-</script>
-</body>
-</html>
index a6a6b95..60f4902 100644 (file)
@@ -110,19 +110,17 @@ function testResizeEvent() {
     iframe.style.height = '100px';
 
     iframe.onload = function () {
-        requestAnimationFrame(function () {
+        iframe.contentDocument.body.getBoundingClientRect();
+        log(iframe.contentWindow, "resize");
+        setTimeout(function () {
+            iframe.style.width = '200px';
+            iframe.style.height = '200px';
+            iframe.contentDocument.body.getBoundingClientRect();
             setTimeout(function () {
-                iframe.contentDocument.body.getBoundingClientRect();
-                log(iframe.contentWindow, "resize");
-                iframe.style.width = '200px';
-                iframe.style.height = '200px';
-                iframe.contentDocument.body.getBoundingClientRect();
-                requestAnimationFrame(function () {
-                    checkFlags('', {eventType: 'resize', composed: false});
-                    finishJSTest();
-                });
+                checkFlags('', {eventType: 'resize', composed: false});
+                finishJSTest();
             }, 0);
-        });
+        }, 0);
     }
 
     document.body.appendChild(iframe);
index 0d17971..3feba50 100644 (file)
@@ -1,3 +1,27 @@
+2019-10-24  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r251269, r251294, and r251328.
+        https://bugs.webkit.org/show_bug.cgi?id=203384
+
+        Probably made many animation tests flaky (Requested by rniwa
+        on #webkit).
+
+        Reverted changesets:
+
+        "Integrate resize event with HTML5 event loop"
+        https://bugs.webkit.org/show_bug.cgi?id=202964
+        https://trac.webkit.org/changeset/251269
+
+        "Flaky Test: fast/events/resize-subframe-in-rendering-
+        update.html"
+        https://bugs.webkit.org/show_bug.cgi?id=203140
+        https://trac.webkit.org/changeset/251294
+
+        "Flaky Test: fast/events/resize-subframe-in-rendering-
+        update.html"
+        https://bugs.webkit.org/show_bug.cgi?id=203140
+        https://trac.webkit.org/changeset/251328
+
 2019-10-23  Ryosuke Niwa  <rniwa@webkit.org>
 
         Add a mechanism to find and manipulate text by paragraphs
index 3627c25..43a9046 100644 (file)
 #include "ValidationMessageClient.h"
 #include "VisibilityChangeClient.h"
 #include "VisitedLinkState.h"
-#include "VisualViewport.h"
 #include "WebAnimation.h"
 #include "WheelEvent.h"
 #include "WindowEventLoop.h"
@@ -3966,35 +3965,6 @@ void Document::updateViewportUnitsOnResize()
     }
 }
 
-void Document::setNeedsDOMWindowResizeEvent()
-{
-    m_needsDOMWindowResizeEvent = true;
-    scheduleTimedRenderingUpdate();
-}
-
-void Document::setNeedsVisualViewportResize()
-{
-    m_needsVisualViewportResizeEvent = true;
-    scheduleTimedRenderingUpdate();
-}
-
-// https://drafts.csswg.org/cssom-view/#run-the-resize-steps
-void Document::runResizeSteps()
-{
-    // FIXME: The order of dispatching is not specified: https://github.com/WICG/visual-viewport/issues/65.
-    if (m_needsDOMWindowResizeEvent) {
-        LOG(Events, "Document %p sending resize events to window", this);
-        m_needsDOMWindowResizeEvent = false;
-        dispatchWindowEvent(Event::create(eventNames().resizeEvent, Event::CanBubble::No, Event::IsCancelable::No));
-    }
-    if (m_needsVisualViewportResizeEvent) {
-        LOG(Events, "Document %p sending resize events to visualViewport", this);
-        m_needsVisualViewportResizeEvent = false;
-        if (auto* window = domWindow())
-            window->visualViewport().dispatchEvent(Event::create(eventNames().resizeEvent, Event::CanBubble::No, Event::IsCancelable::No));
-    }
-}
-
 void Document::addAudioProducer(MediaProducer& audioProducer)
 {
     m_audioProducers.add(audioProducer);
index 3efdd36..42e79f3 100644 (file)
@@ -1360,10 +1360,6 @@ public:
     bool hasStyleWithViewportUnits() const { return m_hasStyleWithViewportUnits; }
     void updateViewportUnitsOnResize();
 
-    void setNeedsDOMWindowResizeEvent();
-    void setNeedsVisualViewportResize();
-    void runResizeSteps();
-
     WEBCORE_EXPORT void addAudioProducer(MediaProducer&);
     WEBCORE_EXPORT void removeAudioProducer(MediaProducer&);
     MediaProducer::MediaStateFlags mediaState() const { return m_mediaState; }
@@ -2016,8 +2012,6 @@ private:
     bool m_hasPreparedForDestruction { false };
 
     bool m_hasStyleWithViewportUnits { false };
-    bool m_needsDOMWindowResizeEvent { false };
-    bool m_needsVisualViewportResizeEvent { false };
     bool m_isTimerThrottlingEnabled { false };
     bool m_isSuspended { false };
 
index 20cce99..c974abc 100644 (file)
@@ -3422,10 +3422,21 @@ void FrameView::sendResizeEventIfNeeded()
     }
 #endif
 
-    LOG(Events, "FrameView %p sendResizeEventIfNeeded scheduling resize event for document %p, size %dx%d", this, frame().document(), currentSize.width(), currentSize.height());
-    frame().document()->setNeedsDOMWindowResizeEvent();
-
     bool isMainFrame = frame().isMainFrame();
+    bool canSendResizeEventSynchronously = isMainFrame && !m_shouldAutoSize;
+
+    LOG(Events, "FrameView %p sendResizeEventIfNeeded sending resize event, size %dx%d (canSendResizeEventSynchronously %d)", this, currentSize.width(), currentSize.height(), canSendResizeEventSynchronously);
+
+    Ref<Event> resizeEvent = Event::create(eventNames().resizeEvent, Event::CanBubble::No, Event::IsCancelable::No);
+    if (canSendResizeEventSynchronously)
+        frame().document()->dispatchWindowEvent(resizeEvent);
+    else {
+        // FIXME: Queueing this event for an unpredictable time in the future seems
+        // intrinsically racy. By the time this resize event fires, the frame might
+        // be resized again, so we could end up with two resize events for the same size.
+        frame().document()->enqueueWindowEvent(WTFMove(resizeEvent));
+    }
+
     if (InspectorInstrumentation::hasFrontends() && isMainFrame) {
         if (Page* page = frame().page()) {
             if (InspectorClient* inspectorClient = page->inspectorController().inspectorClient())
index 9093f8c..4e09699 100644 (file)
@@ -1294,17 +1294,20 @@ void Page::updateRendering()
 
     SetForScope<bool> change(m_inUpdateRendering, true);
 
-    layoutIfNeeded();
+    Vector<RefPtr<Document>> documents;
 
-    for (auto& document : collectDocuments())
-        document->runResizeSteps();
+    // The requestAnimationFrame callbacks may change the frame hierarchy of the page
+    forEachDocument([&documents] (Document& document) {
+        documents.append(&document);
+    });
+
+    // FIXME: Run the resize steps
 
     // FIXME: Run the scroll steps
 
     for (auto& document : collectDocuments())
         document->evaluateMediaQueriesAndReportChanges();
 
-    Vector<Ref<Document>> documents = collectDocuments(); // The requestAnimationFrame callbacks may change the frame hierarchy of the page
     for (auto& document : documents) {
         DOMHighResTimeStamp timestamp = document->domWindow()->nowTimestamp();
         document->updateAnimationsAndSendEvents(timestamp);
@@ -2871,18 +2874,6 @@ void Page::forEachDocument(const Function<void(Document&)>& functor)
     }
 }
 
-Vector<Ref<Document>> Page::collectDocuments()
-{
-    Vector<Ref<Document>> documents;
-    for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
-        auto* document = frame->document();
-        if (!document)
-            continue;
-        documents.append(*document);
-    }
-    return documents;
-}
-
 void Page::applicationWillResignActive()
 {
     forEachDocument([&] (Document& document) {
index 3462741..831f0a0 100644 (file)
@@ -750,7 +750,6 @@ private:
     void handleLowModePowerChange(bool);
 
     void forEachDocument(const WTF::Function<void(Document&)>&);
-    Vector<Ref<Document>> collectDocuments();
 
     enum class TimerThrottlingState { Disabled, Enabled, EnabledIncreasing };
     void hiddenPageDOMTimerThrottlingStateChanged();
index cc28edc..bb07f84 100644 (file)
@@ -185,7 +185,8 @@ void VisualViewport::enqueueResizeEvent()
     auto* frame = this->frame();
     if (!frame)
         return;
-    frame->document()->setNeedsVisualViewportResize();
+
+    frame->document()->eventQueue().enqueueResizeEvent(*this, Event::CanBubble::No, Event::IsCancelable::No);
 }
 
 void VisualViewport::enqueueScrollEvent()