Title: [276158] branches/safari-611-branch/Source
Revision
276158
Author
[email protected]
Date
2021-04-16 12:26:25 -0700 (Fri, 16 Apr 2021)

Log Message

Cherry-pick r275485. rdar://problem/76412930

    Make sure we no longer show the previous page when running a JS prompt
    https://bugs.webkit.org/show_bug.cgi?id=215782
    <rdar://problem/67698601>

    Reviewed by Darin Adler.

    Source/WebCore:

    Add linked-on-after check for the behavior change to minimize the risk of
    breakage.

    * platform/cocoa/VersionChecks.h:

    Source/WebKit:

    Make sure we no longer show the previous page when running a JS prompt.
    If we have not yet done a layer tree commit since the last load commit, then
    we are likely still showing the previous page. If we are asked to run a JS
    prompt / alert / confirm at this point, it would be confusing to still show
    the previous page. In order to address the issue, we now make the view blank
    in such scenario (ideally, we'd have painted the new page but this is
    currently not a trivial thing to do).

    To make the view blank, the approach chosen is the set the opacity of our
    root layer to 0 when the JS prompt is requested (before the first paint) and
    set the opacity back to 1 after the first paint.

    To minimize the risks of breakage, the behavior change is behind a
    linked-on-after check. Also, we only trigger this behavior if the WKWebView
    client actually implements the corresponding JS prompt delegate.

    * UIProcess/Cocoa/UIDelegate.mm:
    (WebKit::UIDelegate::UIClient::runJavaScriptAlert):
    (WebKit::UIDelegate::UIClient::runJavaScriptConfirm):
    (WebKit::UIDelegate::UIClient::runJavaScriptPrompt):
    * UIProcess/PageClient.h:
    (WebKit::PageClient::makeViewBlank):
    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::stopMakingViewBlankDueToLackOfRenderingUpdate):
    (WebKit::WebPageProxy::makeViewBlankIfUnpaintedSinceLastLoadCommit):
    (WebKit::WebPageProxy::didCommitLoadForFrame):
    (WebKit::WebPageProxy::runJavaScriptAlert):
    * UIProcess/WebPageProxy.h:
    * UIProcess/WebPageProxy.messages.in:
    * UIProcess/ios/PageClientImplIOS.h:
    * UIProcess/ios/PageClientImplIOS.mm:
    (WebKit::PageClientImpl::makeViewBlank):
    * UIProcess/ios/WebPageProxyIOS.mm:
    (WebKit::WebPageProxy::didCommitLayerTree):
    * UIProcess/mac/PageClientImplMac.h:
    * UIProcess/mac/PageClientImplMac.mm:
    (WebKit::PageClientImpl::makeViewBlank):
    * UIProcess/mac/WebPageProxyMac.mm:
    (WebKit::WebPageProxy::didUpdateRenderingAfterCommittingLoad):
    * WebProcess/WebCoreSupport/WebChromeClient.cpp:
    (WebKit::WebChromeClient::runJavaScriptAlert):
    (WebKit::WebChromeClient::runJavaScriptConfirm):
    (WebKit::WebChromeClient::runJavaScriptPrompt):
    Add flag to make sure pending async messages are processed *before* the JS prompt sync IPCs.
    Without this, it was possible for the UIProcess to receive the JS prompt IPC *before* the
    DidCommitLoadForFrame IPC, which would confuse our logic, since we would think this is a JS
    prompt for the previous page.

    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::didCommitLoad):
    * WebProcess/WebPage/WebPage.h:
    (WebKit::WebPage::sendSyncWithDelayedReply):
    * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
    (WebKit::TiledCoreAnimationDrawingArea::updateRendering):
    * WebProcess/WebPage/mac/WebPageMac.mm:
    (WebKit::WebPage::didUpdateRendering):

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

Modified Paths

Diff

Modified: branches/safari-611-branch/Source/WebCore/ChangeLog (276157 => 276158)


--- branches/safari-611-branch/Source/WebCore/ChangeLog	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebCore/ChangeLog	2021-04-16 19:26:25 UTC (rev 276158)
@@ -1,5 +1,96 @@
 2021-04-16  Russell Epstein  <[email protected]>
 
+        Cherry-pick r275485. rdar://problem/76412930
+
+    Make sure we no longer show the previous page when running a JS prompt
+    https://bugs.webkit.org/show_bug.cgi?id=215782
+    <rdar://problem/67698601>
+    
+    Reviewed by Darin Adler.
+    
+    Source/WebCore:
+    
+    Add linked-on-after check for the behavior change to minimize the risk of
+    breakage.
+    
+    * platform/cocoa/VersionChecks.h:
+    
+    Source/WebKit:
+    
+    Make sure we no longer show the previous page when running a JS prompt.
+    If we have not yet done a layer tree commit since the last load commit, then
+    we are likely still showing the previous page. If we are asked to run a JS
+    prompt / alert / confirm at this point, it would be confusing to still show
+    the previous page. In order to address the issue, we now make the view blank
+    in such scenario (ideally, we'd have painted the new page but this is
+    currently not a trivial thing to do).
+    
+    To make the view blank, the approach chosen is the set the opacity of our
+    root layer to 0 when the JS prompt is requested (before the first paint) and
+    set the opacity back to 1 after the first paint.
+    
+    To minimize the risks of breakage, the behavior change is behind a
+    linked-on-after check. Also, we only trigger this behavior if the WKWebView
+    client actually implements the corresponding JS prompt delegate.
+    
+    * UIProcess/Cocoa/UIDelegate.mm:
+    (WebKit::UIDelegate::UIClient::runJavaScriptAlert):
+    (WebKit::UIDelegate::UIClient::runJavaScriptConfirm):
+    (WebKit::UIDelegate::UIClient::runJavaScriptPrompt):
+    * UIProcess/PageClient.h:
+    (WebKit::PageClient::makeViewBlank):
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::stopMakingViewBlankDueToLackOfRenderingUpdate):
+    (WebKit::WebPageProxy::makeViewBlankIfUnpaintedSinceLastLoadCommit):
+    (WebKit::WebPageProxy::didCommitLoadForFrame):
+    (WebKit::WebPageProxy::runJavaScriptAlert):
+    * UIProcess/WebPageProxy.h:
+    * UIProcess/WebPageProxy.messages.in:
+    * UIProcess/ios/PageClientImplIOS.h:
+    * UIProcess/ios/PageClientImplIOS.mm:
+    (WebKit::PageClientImpl::makeViewBlank):
+    * UIProcess/ios/WebPageProxyIOS.mm:
+    (WebKit::WebPageProxy::didCommitLayerTree):
+    * UIProcess/mac/PageClientImplMac.h:
+    * UIProcess/mac/PageClientImplMac.mm:
+    (WebKit::PageClientImpl::makeViewBlank):
+    * UIProcess/mac/WebPageProxyMac.mm:
+    (WebKit::WebPageProxy::didUpdateRenderingAfterCommittingLoad):
+    * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+    (WebKit::WebChromeClient::runJavaScriptAlert):
+    (WebKit::WebChromeClient::runJavaScriptConfirm):
+    (WebKit::WebChromeClient::runJavaScriptPrompt):
+    Add flag to make sure pending async messages are processed *before* the JS prompt sync IPCs.
+    Without this, it was possible for the UIProcess to receive the JS prompt IPC *before* the
+    DidCommitLoadForFrame IPC, which would confuse our logic, since we would think this is a JS
+    prompt for the previous page.
+    
+    * WebProcess/WebPage/WebPage.cpp:
+    (WebKit::WebPage::didCommitLoad):
+    * WebProcess/WebPage/WebPage.h:
+    (WebKit::WebPage::sendSyncWithDelayedReply):
+    * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+    (WebKit::TiledCoreAnimationDrawingArea::updateRendering):
+    * WebProcess/WebPage/mac/WebPageMac.mm:
+    (WebKit::WebPage::didUpdateRendering):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275485 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-04-05  Chris Dumez  <[email protected]>
+
+            Make sure we no longer show the previous page when running a JS prompt
+            https://bugs.webkit.org/show_bug.cgi?id=215782
+            <rdar://problem/67698601>
+
+            Reviewed by Darin Adler.
+
+            Add linked-on-after check for the behavior change to minimize the risk of
+            breakage.
+
+            * platform/cocoa/VersionChecks.h:
+
+2021-04-16  Russell Epstein  <[email protected]>
+
         Cherry-pick r274819. rdar://problem/76373741
 
     AVAudioSessionCaptureDeviceManager should use crossThreadCopy

Modified: branches/safari-611-branch/Source/WebCore/platform/cocoa/VersionChecks.h (276157 => 276158)


--- branches/safari-611-branch/Source/WebCore/platform/cocoa/VersionChecks.h	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebCore/platform/cocoa/VersionChecks.h	2021-04-16 19:26:25 UTC (rev 276158)
@@ -69,6 +69,7 @@
     FirstThatObservesClassProperty = DYLD_IOS_VERSION_14_5,
     FirstWithoutWeChatScrollingQuirk = DYLD_IOS_VERSION_14_5,
     FirstWithSharedNetworkProcess = DYLD_IOS_VERSION_14_5,
+    FirstWithBlankViewOnJSPrompt = DYLD_IOS_VERSION_14_5,
 #elif PLATFORM(MAC)
     FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
     FirstWithExceptionsForDuplicateCompletionHandlerCalls = DYLD_MACOSX_VERSION_10_13,
@@ -88,6 +89,7 @@
     FirstWithWKWebsiteDataStoreInitReturningNil = DYLD_MACOSX_VERSION_10_16,
     FirstWithDataURLFragmentRemoval = DYLD_MACOSX_VERSION_11_3,
     FirstWithHTMLDocumentSupportedPropertyNames = DYLD_MACOSX_VERSION_11_3,
+    FirstWithBlankViewOnJSPrompt = DYLD_MACOSX_VERSION_11_3,
 #endif
 };
 

Modified: branches/safari-611-branch/Source/WebKit/ChangeLog (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/ChangeLog	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/ChangeLog	2021-04-16 19:26:25 UTC (rev 276158)
@@ -1,5 +1,148 @@
 2021-04-16  Russell Epstein  <[email protected]>
 
+        Cherry-pick r275485. rdar://problem/76412930
+
+    Make sure we no longer show the previous page when running a JS prompt
+    https://bugs.webkit.org/show_bug.cgi?id=215782
+    <rdar://problem/67698601>
+    
+    Reviewed by Darin Adler.
+    
+    Source/WebCore:
+    
+    Add linked-on-after check for the behavior change to minimize the risk of
+    breakage.
+    
+    * platform/cocoa/VersionChecks.h:
+    
+    Source/WebKit:
+    
+    Make sure we no longer show the previous page when running a JS prompt.
+    If we have not yet done a layer tree commit since the last load commit, then
+    we are likely still showing the previous page. If we are asked to run a JS
+    prompt / alert / confirm at this point, it would be confusing to still show
+    the previous page. In order to address the issue, we now make the view blank
+    in such scenario (ideally, we'd have painted the new page but this is
+    currently not a trivial thing to do).
+    
+    To make the view blank, the approach chosen is the set the opacity of our
+    root layer to 0 when the JS prompt is requested (before the first paint) and
+    set the opacity back to 1 after the first paint.
+    
+    To minimize the risks of breakage, the behavior change is behind a
+    linked-on-after check. Also, we only trigger this behavior if the WKWebView
+    client actually implements the corresponding JS prompt delegate.
+    
+    * UIProcess/Cocoa/UIDelegate.mm:
+    (WebKit::UIDelegate::UIClient::runJavaScriptAlert):
+    (WebKit::UIDelegate::UIClient::runJavaScriptConfirm):
+    (WebKit::UIDelegate::UIClient::runJavaScriptPrompt):
+    * UIProcess/PageClient.h:
+    (WebKit::PageClient::makeViewBlank):
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::stopMakingViewBlankDueToLackOfRenderingUpdate):
+    (WebKit::WebPageProxy::makeViewBlankIfUnpaintedSinceLastLoadCommit):
+    (WebKit::WebPageProxy::didCommitLoadForFrame):
+    (WebKit::WebPageProxy::runJavaScriptAlert):
+    * UIProcess/WebPageProxy.h:
+    * UIProcess/WebPageProxy.messages.in:
+    * UIProcess/ios/PageClientImplIOS.h:
+    * UIProcess/ios/PageClientImplIOS.mm:
+    (WebKit::PageClientImpl::makeViewBlank):
+    * UIProcess/ios/WebPageProxyIOS.mm:
+    (WebKit::WebPageProxy::didCommitLayerTree):
+    * UIProcess/mac/PageClientImplMac.h:
+    * UIProcess/mac/PageClientImplMac.mm:
+    (WebKit::PageClientImpl::makeViewBlank):
+    * UIProcess/mac/WebPageProxyMac.mm:
+    (WebKit::WebPageProxy::didUpdateRenderingAfterCommittingLoad):
+    * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+    (WebKit::WebChromeClient::runJavaScriptAlert):
+    (WebKit::WebChromeClient::runJavaScriptConfirm):
+    (WebKit::WebChromeClient::runJavaScriptPrompt):
+    Add flag to make sure pending async messages are processed *before* the JS prompt sync IPCs.
+    Without this, it was possible for the UIProcess to receive the JS prompt IPC *before* the
+    DidCommitLoadForFrame IPC, which would confuse our logic, since we would think this is a JS
+    prompt for the previous page.
+    
+    * WebProcess/WebPage/WebPage.cpp:
+    (WebKit::WebPage::didCommitLoad):
+    * WebProcess/WebPage/WebPage.h:
+    (WebKit::WebPage::sendSyncWithDelayedReply):
+    * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+    (WebKit::TiledCoreAnimationDrawingArea::updateRendering):
+    * WebProcess/WebPage/mac/WebPageMac.mm:
+    (WebKit::WebPage::didUpdateRendering):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275485 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-04-05  Chris Dumez  <[email protected]>
+
+            Make sure we no longer show the previous page when running a JS prompt
+            https://bugs.webkit.org/show_bug.cgi?id=215782
+            <rdar://problem/67698601>
+
+            Reviewed by Darin Adler.
+
+            Make sure we no longer show the previous page when running a JS prompt.
+            If we have not yet done a layer tree commit since the last load commit, then
+            we are likely still showing the previous page. If we are asked to run a JS
+            prompt / alert / confirm at this point, it would be confusing to still show
+            the previous page. In order to address the issue, we now make the view blank
+            in such scenario (ideally, we'd have painted the new page but this is
+            currently not a trivial thing to do).
+
+            To make the view blank, the approach chosen is the set the opacity of our
+            root layer to 0 when the JS prompt is requested (before the first paint) and
+            set the opacity back to 1 after the first paint.
+
+            To minimize the risks of breakage, the behavior change is behind a
+            linked-on-after check. Also, we only trigger this behavior if the WKWebView
+            client actually implements the corresponding JS prompt delegate.
+
+            * UIProcess/Cocoa/UIDelegate.mm:
+            (WebKit::UIDelegate::UIClient::runJavaScriptAlert):
+            (WebKit::UIDelegate::UIClient::runJavaScriptConfirm):
+            (WebKit::UIDelegate::UIClient::runJavaScriptPrompt):
+            * UIProcess/PageClient.h:
+            (WebKit::PageClient::makeViewBlank):
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::stopMakingViewBlankDueToLackOfRenderingUpdate):
+            (WebKit::WebPageProxy::makeViewBlankIfUnpaintedSinceLastLoadCommit):
+            (WebKit::WebPageProxy::didCommitLoadForFrame):
+            (WebKit::WebPageProxy::runJavaScriptAlert):
+            * UIProcess/WebPageProxy.h:
+            * UIProcess/WebPageProxy.messages.in:
+            * UIProcess/ios/PageClientImplIOS.h:
+            * UIProcess/ios/PageClientImplIOS.mm:
+            (WebKit::PageClientImpl::makeViewBlank):
+            * UIProcess/ios/WebPageProxyIOS.mm:
+            (WebKit::WebPageProxy::didCommitLayerTree):
+            * UIProcess/mac/PageClientImplMac.h:
+            * UIProcess/mac/PageClientImplMac.mm:
+            (WebKit::PageClientImpl::makeViewBlank):
+            * UIProcess/mac/WebPageProxyMac.mm:
+            (WebKit::WebPageProxy::didUpdateRenderingAfterCommittingLoad):
+            * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+            (WebKit::WebChromeClient::runJavaScriptAlert):
+            (WebKit::WebChromeClient::runJavaScriptConfirm):
+            (WebKit::WebChromeClient::runJavaScriptPrompt):
+            Add flag to make sure pending async messages are processed *before* the JS prompt sync IPCs.
+            Without this, it was possible for the UIProcess to receive the JS prompt IPC *before* the
+            DidCommitLoadForFrame IPC, which would confuse our logic, since we would think this is a JS
+            prompt for the previous page.
+
+            * WebProcess/WebPage/WebPage.cpp:
+            (WebKit::WebPage::didCommitLoad):
+            * WebProcess/WebPage/WebPage.h:
+            (WebKit::WebPage::sendSyncWithDelayedReply):
+            * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+            (WebKit::TiledCoreAnimationDrawingArea::updateRendering):
+            * WebProcess/WebPage/mac/WebPageMac.mm:
+            (WebKit::WebPage::didUpdateRendering):
+
+2021-04-16  Russell Epstein  <[email protected]>
+
         Cherry-pick r274565. rdar://problem/76412930
 
     Maybe-regression(STP121): window.open flakily returning null

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm	2021-04-16 19:26:25 UTC (rev 276158)
@@ -301,6 +301,8 @@
         return;
     }
 
+    page.makeViewBlankIfUnpaintedSinceLastLoadCommit();
+
     auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:));
     [delegate webView:m_uiDelegate->m_webView.get().get() runJavaScriptAlertPanelWithMessage:message initiatedByFrame:wrapper(API::FrameInfo::create(WTFMove(frameInfo), &page)) completionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)] {
         if (checker->completionHandlerHasBeenCalled())
@@ -326,6 +328,8 @@
         return;
     }
 
+    page.makeViewBlankIfUnpaintedSinceLastLoadCommit();
+
     auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:));
     [delegate webView:m_uiDelegate->m_webView.get().get() runJavaScriptConfirmPanelWithMessage:message initiatedByFrame:wrapper(API::FrameInfo::create(WTFMove(frameInfo), &page)) completionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)] (BOOL result) mutable {
         if (checker->completionHandlerHasBeenCalled())
@@ -351,6 +355,8 @@
         return;
     }
 
+    page.makeViewBlankIfUnpaintedSinceLastLoadCommit();
+
     auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:));
     [delegate webView:m_uiDelegate->m_webView.get().get() runJavaScriptTextInputPanelWithPrompt:message defaultText:defaultValue initiatedByFrame:wrapper(API::FrameInfo::create(WTFMove(frameInfo), &page)) completionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)] (NSString *result) mutable {
         if (checker->completionHandlerHasBeenCalled())

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/PageClient.h (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/UIProcess/PageClient.h	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/PageClient.h	2021-04-16 19:26:25 UTC (rev 276158)
@@ -503,6 +503,8 @@
 
     virtual void setMouseEventPolicy(WebCore::MouseEventPolicy) { }
 
+    virtual void makeViewBlank(bool) { }
+
 #if PLATFORM(MAC)
     virtual void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object*) = 0;
     virtual NSObject *immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>) = 0;

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-04-16 19:26:25 UTC (rev 276158)
@@ -2395,6 +2395,31 @@
 }
 #endif
 
+void WebPageProxy::stopMakingViewBlankDueToLackOfRenderingUpdate()
+{
+#if PLATFORM(COCOA)
+    ASSERT(m_hasUpdatedRenderingAfterDidCommitLoad);
+    RELEASE_LOG_IF_ALLOWED(Process, "stopMakingViewBlankDueToLackOfRenderingUpdate:");
+    pageClient().makeViewBlank(false);
+#endif
+}
+
+// If we have not painted yet since the last load commit, then we are likely still displaying the previous page.
+// Displaying a JS prompt for the new page with the old page behind would be confusing so we make the view blank
+// until the next paint in such case.
+void WebPageProxy::makeViewBlankIfUnpaintedSinceLastLoadCommit()
+{
+#if PLATFORM(COCOA)
+    if (!m_hasUpdatedRenderingAfterDidCommitLoad) {
+        static bool shouldMakeViewBlank = linkedOnOrAfter(WebCore::SDKVersion::FirstWithBlankViewOnJSPrompt);
+        if (shouldMakeViewBlank) {
+            RELEASE_LOG_IF_ALLOWED(Process, "makeViewBlankIfUnpaintedSinceLastLoadCommit: Making the view blank because of a JS prompt before the first paint for its page");
+            pageClient().makeViewBlank(true);
+        }
+    }
+#endif
+}
+
 void WebPageProxy::discardQueuedMouseEvents()
 {
     while (m_mouseEventQueue.size() > 1)
@@ -4628,10 +4653,12 @@
     m_hasCommittedAnyProvisionalLoads = true;
     m_process->didCommitProvisionalLoad();
 
+#if PLATFORM(COCOA)
+    if (frame->isMainFrame()) {
+        m_hasUpdatedRenderingAfterDidCommitLoad = false;
 #if PLATFORM(IOS_FAMILY)
-    if (frame->isMainFrame()) {
-        m_hasReceivedLayerTreeTransactionAfterDidCommitLoad = false;
         m_firstLayerTreeTransactionIdAfterDidCommitLoad = downcast<RemoteLayerTreeDrawingAreaProxy>(*drawingArea()).nextLayerTreeTransactionID();
+#endif
     }
 #endif
 

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.h (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.h	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.h	2021-04-16 19:26:25 UTC (rev 276158)
@@ -574,6 +574,8 @@
     void setDrawingArea(std::unique_ptr<DrawingAreaProxy>&&);
 
     WeakPtr<SecKeyProxyStore> secKeyProxyStore(const WebCore::AuthenticationChallenge&);
+
+    void makeViewBlankIfUnpaintedSinceLastLoadCommit();
         
     void close();
     bool tryClose();
@@ -2118,6 +2120,8 @@
     void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&);
 #endif
 
+    void stopMakingViewBlankDueToLackOfRenderingUpdate();
+
     // Spelling and grammar.
     void checkSpellingOfString(const String& text, CompletionHandler<void(int32_t misspellingLocation, int32_t misspellingLength)>&&);
     void checkGrammarOfString(const String& text, CompletionHandler<void(Vector<WebCore::GrammarDetail>&&, int32_t badGrammarLocation, int32_t badGrammarLength)>&&);
@@ -2149,6 +2153,7 @@
     void applicationManifestCallback(const Optional<WebCore::ApplicationManifest>&, CallbackID);
 #endif
 #if PLATFORM(MAC)
+    void didUpdateRenderingAfterCommittingLoad();
     void fontAtSelectionCallback(const FontInfo&, double, bool, CallbackID);
 #endif
 #if PLATFORM(IOS_FAMILY)
@@ -2449,7 +2454,6 @@
     Optional<WebCore::InputMode> m_pendingInputModeChange;
     TransactionID m_firstLayerTreeTransactionIdAfterDidCommitLoad;
     int32_t m_deviceOrientation { 0 };
-    bool m_hasReceivedLayerTreeTransactionAfterDidCommitLoad { true };
     bool m_hasNetworkRequestsOnSuspended { false };
     bool m_isKeyboardAnimatingIn { false };
     bool m_isScrollingOrZooming { false };
@@ -2574,6 +2578,10 @@
     bool m_isInPrintingMode { false };
     bool m_isPerformingDOMPrintOperation { false };
 
+#if PLATFORM(COCOA)
+    bool m_hasUpdatedRenderingAfterDidCommitLoad { true };
+#endif
+
     WebCore::ResourceRequest m_decidePolicyForResponseRequest;
     bool m_shouldSuppressAppLinksInNextNavigationPolicyDecision { false };
 

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-04-16 19:26:25 UTC (rev 276158)
@@ -376,6 +376,7 @@
     RecordAutocorrectionResponse(int32_t response, String replacedString, String replacementString);
 
     SetEditableElementIsFocused(bool editableElementIsFocused)
+    DidUpdateRenderingAfterCommittingLoad()
 #endif
 
 #if USE(DICTATION_ALTERNATIVES)

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2021-04-16 19:26:25 UTC (rev 276158)
@@ -144,6 +144,8 @@
     CALayer* acceleratedCompositingRootLayer() const override;
     LayerHostingMode viewLayerHostingMode() override { return LayerHostingMode::OutOfProcess; }
 
+    void makeViewBlank(bool) final;
+
     RefPtr<ViewSnapshot> takeViewSnapshot(Optional<WebCore::IntRect>&&) override;
     void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) override;
 

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2021-04-16 19:26:25 UTC (rev 276158)
@@ -475,6 +475,11 @@
 {
 }
 
+void PageClientImpl::makeViewBlank(bool makeBlank)
+{
+    [m_contentView layer].opacity = makeBlank ? 0 : 1;
+}
+
 void PageClientImpl::showSafeBrowsingWarning(const SafeBrowsingWarning& warning, CompletionHandler<void(Variant<WebKit::ContinueUnsafeLoad, URL>&&)>&& completionHandler)
 {
     if (auto webView = m_webView.get())

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2021-04-16 19:26:25 UTC (rev 276158)
@@ -337,9 +337,10 @@
 {
     m_pageExtendedBackgroundColor = layerTreeTransaction.pageExtendedBackgroundColor();
 
-    if (!m_hasReceivedLayerTreeTransactionAfterDidCommitLoad) {
+    if (!m_hasUpdatedRenderingAfterDidCommitLoad) {
         if (layerTreeTransaction.transactionID() >= m_firstLayerTreeTransactionIdAfterDidCommitLoad) {
-            m_hasReceivedLayerTreeTransactionAfterDidCommitLoad = true;
+            m_hasUpdatedRenderingAfterDidCommitLoad = true;
+            stopMakingViewBlankDueToLackOfRenderingUpdate();
             m_lastVisibleContentRectUpdate = VisibleContentRectUpdateInfo();
         }
     }

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/mac/PageClientImplMac.h (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/UIProcess/mac/PageClientImplMac.h	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/mac/PageClientImplMac.h	2021-04-16 19:26:25 UTC (rev 276158)
@@ -221,6 +221,8 @@
 
     void requestDOMPasteAccess(const WebCore::IntRect&, const String&, CompletionHandler<void(WebCore::DOMPasteAccessResponse)>&&) final;
 
+    void makeViewBlank(bool) final;
+
     NSView *activeView() const;
     NSWindow *activeWindow() const;
 

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/UIProcess/mac/PageClientImplMac.mm	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/mac/PageClientImplMac.mm	2021-04-16 19:26:25 UTC (rev 276158)
@@ -976,6 +976,12 @@
     m_impl->requestDOMPasteAccess(elementRect, originIdentifier, WTFMove(completion));
 }
 
+
+void PageClientImpl::makeViewBlank(bool makeBlank)
+{
+    m_impl->acceleratedCompositingRootLayer().opacity = makeBlank ? 0 : 1;
+}
+
 #if HAVE(APP_ACCENT_COLORS)
 WebCore::Color PageClientImpl::accentColor()
 {

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2021-04-16 19:26:25 UTC (rev 276158)
@@ -651,6 +651,15 @@
     return [pageClient().platformWindow() contentView];
 }
 
+void WebPageProxy::didUpdateRenderingAfterCommittingLoad()
+{
+    if (m_hasUpdatedRenderingAfterDidCommitLoad)
+        return;
+
+    m_hasUpdatedRenderingAfterDidCommitLoad = true;
+    stopMakingViewBlankDueToLackOfRenderingUpdate();
+}
+
 #if ENABLE(UI_PROCESS_PDF_HUD)
 
 void WebPageProxy::createPDFHUD(PDFPluginIdentifier identifier, const WebCore::IntRect& rect)

Modified: branches/safari-611-branch/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2021-04-16 19:26:25 UTC (rev 276158)
@@ -457,7 +457,7 @@
     HangDetectionDisabler hangDetectionDisabler;
     IPC::UnboundedSynchronousIPCScope unboundedSynchronousIPCScope;
 
-    m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), webFrame->info(), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply());
+    m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), webFrame->info(), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), IPC::SendSyncOption::MaintainOrderingWithAsyncMessages);
 }
 
 bool WebChromeClient::runJavaScriptConfirm(Frame& frame, const String& message)
@@ -475,7 +475,7 @@
     IPC::UnboundedSynchronousIPCScope unboundedSynchronousIPCScope;
 
     bool result = false;
-    if (!m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), webFrame->info(), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result)))
+    if (!m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), webFrame->info(), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), IPC::SendSyncOption::MaintainOrderingWithAsyncMessages))
         return false;
 
     return result;
@@ -495,7 +495,7 @@
     HangDetectionDisabler hangDetectionDisabler;
     IPC::UnboundedSynchronousIPCScope unboundedSynchronousIPCScope;
 
-    if (!m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), webFrame->info(), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result)))
+    if (!m_page.sendSyncWithDelayedReply(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), webFrame->info(), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), IPC::SendSyncOption::MaintainOrderingWithAsyncMessages))
         return false;
 
     return !result.isNull();

Modified: branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-04-16 19:26:25 UTC (rev 276158)
@@ -6085,6 +6085,9 @@
             scalePage(1, IntPoint());
     }
 
+#if PLATFORM(MAC)
+    m_didUpdateRenderingAfterCommittingLoad = false;
+#endif
 #if PLATFORM(IOS_FAMILY)
     m_hasReceivedVisibleContentRectsAfterDidCommitLoad = false;
     m_hasRestoredExposedContentRectAfterDidCommitLoad = false;

Modified: branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/WebPage.h (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-04-16 19:26:25 UTC (rev 276158)
@@ -623,6 +623,8 @@
 #if PLATFORM(MAC)
     void setTopOverhangImage(WebImage*);
     void setBottomOverhangImage(WebImage*);
+
+    void didUpdateRendering();
     
     void setUseSystemAppearance(bool);
 
@@ -1264,10 +1266,11 @@
     void didReceiveWebPageMessage(IPC::Connection&, IPC::Decoder&);
 
     template<typename T>
-    SendSyncResult sendSyncWithDelayedReply(T&& message, typename T::Reply&& reply)
+    SendSyncResult sendSyncWithDelayedReply(T&& message, typename T::Reply&& reply, OptionSet<IPC::SendSyncOption> sendSyncOptions = { })
     {
         cancelGesturesBlockedOnSynchronousReplies();
-        return sendSync(WTFMove(message), WTFMove(reply), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend);
+        sendSyncOptions = sendSyncOptions | IPC::SendSyncOption::InformPlatformProcessWillSuspend;
+        return sendSync(WTFMove(message), WTFMove(reply), Seconds::infinity(), sendSyncOptions);
     }
 
     WebCore::DOMPasteAccessResponse requestDOMPasteAccess(const String& originIdentifier);
@@ -2187,6 +2190,10 @@
 #endif
     bool m_canUseCredentialStorage { true };
 
+#if PLATFORM(MAC)
+    bool m_didUpdateRenderingAfterCommittingLoad { false };
+#endif
+
     Vector<String> m_corsDisablingPatterns;
 
 #if ENABLE(IPC_TESTING_API)

Modified: branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2021-04-16 19:26:25 UTC (rev 276158)
@@ -481,6 +481,7 @@
         }
 
         sendDidFirstLayerFlushIfNeeded();
+        m_webPage.didUpdateRendering();
         handleActivityStateChangeCallbacksIfNeeded();
         invalidateRenderingUpdateRunLoopObserver();
     }

Modified: branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (276157 => 276158)


--- branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2021-04-16 19:26:19 UTC (rev 276157)
+++ branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2021-04-16 19:26:25 UTC (rev 276158)
@@ -1028,6 +1028,15 @@
 {
 }
 
+void WebPage::didUpdateRendering()
+{
+    if (m_didUpdateRenderingAfterCommittingLoad)
+        return;
+
+    m_didUpdateRenderingAfterCommittingLoad = true;
+    send(Messages::WebPageProxy::DidUpdateRenderingAfterCommittingLoad());
+}
+
 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY)
 void WebPage::playbackTargetSelected(PlaybackTargetClientContextIdentifier contextId, const WebCore::MediaPlaybackTargetContext& targetContext) const
 {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to