Title: [273456] branches/safari-611-branch/Source/WebKit
Revision
273456
Author
alanc...@apple.com
Date
2021-02-24 16:39:45 -0800 (Wed, 24 Feb 2021)

Log Message

Cherry-pick r272629. rdar://problem/74410251

    Make sure we are 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 Simon Fraser.

    Make sure we are 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 was to add a blank overlay view
    on top of the content. This overlay view gets taken down as soon as we
    paint the view again.

    * SourcesCocoa.txt:
    * UIProcess/API/Cocoa/WKWebView.mm:
    (-[WKWebView _hasBlankOverlay]):
    (-[WKWebView _setHasBlankOverlay:]):
    * UIProcess/API/Cocoa/WKWebViewInternal.h:
    * UIProcess/API/Cocoa/WKWebViewPrivate.h:
    * UIProcess/Cocoa/PageClientImplCocoa.h:
    * UIProcess/Cocoa/PageClientImplCocoa.mm:
    (WebKit::PageClientImplCocoa::setHasBlankOverlay):
    * UIProcess/Cocoa/WKBlankOverlayView.h: Added.
    * UIProcess/Cocoa/WKBlankOverlayView.mm: Added.
    (-[WKBlankOverlayView initWithFrame:]):
    * UIProcess/PageClient.h:
    (WebKit::PageClient::setHasBlankOverlay):
    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::didFirstLayerTreeCommitAfterCommittingLoad):
    (WebKit::WebPageProxy::makeViewBlankIfUnpaintedSinceLastLoadCommit):
    (WebKit::WebPageProxy::didCommitLoadForFrame):
    (WebKit::WebPageProxy::runJavaScriptAlert):
    (WebKit::WebPageProxy::runJavaScriptConfirm):
    (WebKit::WebPageProxy::runJavaScriptPrompt):
    * UIProcess/WebPageProxy.h:
    * UIProcess/WebPageProxy.messages.in:
    * UIProcess/ios/WebPageProxyIOS.mm:
    (WebKit::WebPageProxy::didCommitLayerTree):
    * UIProcess/mac/WebPageProxyMac.mm:
    (WebKit::WebPageProxy::didUpdateRenderingAfterCommittingLoad):
    * WebKit.xcodeproj/project.pbxproj:
    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::didCommitLoad):
    * WebProcess/WebPage/WebPage.h:
    * 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@272629 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-611-branch/Source/WebKit/ChangeLog (273455 => 273456)


--- branches/safari-611-branch/Source/WebKit/ChangeLog	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/ChangeLog	2021-02-25 00:39:45 UTC (rev 273456)
@@ -1,3 +1,119 @@
+2021-02-24  Russell Epstein  <repst...@apple.com>
+
+        Cherry-pick r272629. rdar://problem/74410251
+
+    Make sure we are 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 Simon Fraser.
+    
+    Make sure we are 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 was to add a blank overlay view
+    on top of the content. This overlay view gets taken down as soon as we
+    paint the view again.
+    
+    * SourcesCocoa.txt:
+    * UIProcess/API/Cocoa/WKWebView.mm:
+    (-[WKWebView _hasBlankOverlay]):
+    (-[WKWebView _setHasBlankOverlay:]):
+    * UIProcess/API/Cocoa/WKWebViewInternal.h:
+    * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+    * UIProcess/Cocoa/PageClientImplCocoa.h:
+    * UIProcess/Cocoa/PageClientImplCocoa.mm:
+    (WebKit::PageClientImplCocoa::setHasBlankOverlay):
+    * UIProcess/Cocoa/WKBlankOverlayView.h: Added.
+    * UIProcess/Cocoa/WKBlankOverlayView.mm: Added.
+    (-[WKBlankOverlayView initWithFrame:]):
+    * UIProcess/PageClient.h:
+    (WebKit::PageClient::setHasBlankOverlay):
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::didFirstLayerTreeCommitAfterCommittingLoad):
+    (WebKit::WebPageProxy::makeViewBlankIfUnpaintedSinceLastLoadCommit):
+    (WebKit::WebPageProxy::didCommitLoadForFrame):
+    (WebKit::WebPageProxy::runJavaScriptAlert):
+    (WebKit::WebPageProxy::runJavaScriptConfirm):
+    (WebKit::WebPageProxy::runJavaScriptPrompt):
+    * UIProcess/WebPageProxy.h:
+    * UIProcess/WebPageProxy.messages.in:
+    * UIProcess/ios/WebPageProxyIOS.mm:
+    (WebKit::WebPageProxy::didCommitLayerTree):
+    * UIProcess/mac/WebPageProxyMac.mm:
+    (WebKit::WebPageProxy::didUpdateRenderingAfterCommittingLoad):
+    * WebKit.xcodeproj/project.pbxproj:
+    * WebProcess/WebPage/WebPage.cpp:
+    (WebKit::WebPage::didCommitLoad):
+    * WebProcess/WebPage/WebPage.h:
+    * 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@272629 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-02-09  Chris Dumez  <cdu...@apple.com>
+
+            Make sure we are 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 Simon Fraser.
+
+            Make sure we are 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 was to add a blank overlay view
+            on top of the content. This overlay view gets taken down as soon as we
+            paint the view again.
+
+            * SourcesCocoa.txt:
+            * UIProcess/API/Cocoa/WKWebView.mm:
+            (-[WKWebView _hasBlankOverlay]):
+            (-[WKWebView _setHasBlankOverlay:]):
+            * UIProcess/API/Cocoa/WKWebViewInternal.h:
+            * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+            * UIProcess/Cocoa/PageClientImplCocoa.h:
+            * UIProcess/Cocoa/PageClientImplCocoa.mm:
+            (WebKit::PageClientImplCocoa::setHasBlankOverlay):
+            * UIProcess/Cocoa/WKBlankOverlayView.h: Added.
+            * UIProcess/Cocoa/WKBlankOverlayView.mm: Added.
+            (-[WKBlankOverlayView initWithFrame:]):
+            * UIProcess/PageClient.h:
+            (WebKit::PageClient::setHasBlankOverlay):
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::didFirstLayerTreeCommitAfterCommittingLoad):
+            (WebKit::WebPageProxy::makeViewBlankIfUnpaintedSinceLastLoadCommit):
+            (WebKit::WebPageProxy::didCommitLoadForFrame):
+            (WebKit::WebPageProxy::runJavaScriptAlert):
+            (WebKit::WebPageProxy::runJavaScriptConfirm):
+            (WebKit::WebPageProxy::runJavaScriptPrompt):
+            * UIProcess/WebPageProxy.h:
+            * UIProcess/WebPageProxy.messages.in:
+            * UIProcess/ios/WebPageProxyIOS.mm:
+            (WebKit::WebPageProxy::didCommitLayerTree):
+            * UIProcess/mac/WebPageProxyMac.mm:
+            (WebKit::WebPageProxy::didUpdateRenderingAfterCommittingLoad):
+            * WebKit.xcodeproj/project.pbxproj:
+            * WebProcess/WebPage/WebPage.cpp:
+            (WebKit::WebPage::didCommitLoad):
+            * WebProcess/WebPage/WebPage.h:
+            * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+            (WebKit::TiledCoreAnimationDrawingArea::updateRendering):
+            * WebProcess/WebPage/mac/WebPageMac.mm:
+            (WebKit::WebPage::didUpdateRendering):
+
 2021-02-23  Alan Coon  <alanc...@apple.com>
 
         Cherry-pick r273304. rdar://problem/74622914

Modified: branches/safari-611-branch/Source/WebKit/SourcesCocoa.txt (273455 => 273456)


--- branches/safari-611-branch/Source/WebKit/SourcesCocoa.txt	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/SourcesCocoa.txt	2021-02-25 00:39:45 UTC (rev 273456)
@@ -409,6 +409,7 @@
 UIProcess/Cocoa/WebProcessProxyCocoa.mm
 UIProcess/Cocoa/WebURLSchemeHandlerCocoa.mm
 UIProcess/Cocoa/WebViewImpl.mm
+UIProcess/Cocoa/WKBlankOverlayView.mm
 UIProcess/Cocoa/WKContactPicker.mm
 UIProcess/Cocoa/WKEditCommand.mm
 UIProcess/Cocoa/WKFullKeyboardAccessWatcher.mm

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (273455 => 273456)


--- branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-02-25 00:39:45 UTC (rev 273456)
@@ -1400,6 +1400,25 @@
 
 #endif // ENABLE(ATTACHMENT_ELEMENT)
 
+- (BOOL)_hasBlankOverlay
+{
+    return !!_blankOverlayView;
+}
+
+- (void)_setHasBlankOverlay:(BOOL)hasBlankOverlay
+{
+    if (!!_blankOverlayView == hasBlankOverlay)
+        return;
+
+    if (hasBlankOverlay) {
+        _blankOverlayView = adoptNS([[WKBlankOverlayView alloc] initWithFrame:[self bounds]]);
+        [self addSubview:_blankOverlayView.get()];
+    } else {
+        [_blankOverlayView removeFromSuperview];
+        _blankOverlayView = nullptr;
+    }
+}
+
 - (WKPageRef)_pageForTesting
 {
     return toAPI(_page.get());

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h (273455 => 273456)


--- branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h	2021-02-25 00:39:45 UTC (rev 273456)
@@ -25,6 +25,7 @@
 
 #import "PDFPluginIdentifier.h"
 #import "SameDocumentNavigationType.h"
+#import "WKBlankOverlayView.h"
 #import "WKShareSheet.h"
 #import "WKWebViewConfiguration.h"
 #import "WKWebViewPrivate.h"
@@ -128,6 +129,8 @@
     _WKRenderingProgressEvents _observedRenderingProgressEvents;
     BOOL _usePlatformFindUI;
 
+    RetainPtr<WKBlankOverlayView> _blankOverlayView;
+
 #if PLATFORM(MAC)
     std::unique_ptr<WebKit::WebViewImpl> _impl;
     RetainPtr<WKTextFinderClient> _textFinderClient;

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (273455 => 273456)


--- branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2021-02-25 00:39:45 UTC (rev 273456)
@@ -359,6 +359,8 @@
 
 @property (nonatomic, setter=_setCanUseCredentialStorage:) BOOL _canUseCredentialStorage WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
+@property (nonatomic, setter=_setHasBlankOverlay:) BOOL _hasBlankOverlay WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 @end
 
 #if TARGET_OS_IPHONE

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h (273455 => 273456)


--- branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h	2021-02-25 00:39:45 UTC (rev 273456)
@@ -54,6 +54,8 @@
 
     bool scrollingUpdatesDisabledForTesting() final;
 
+    void setHasBlankOverlay(bool) final;
+
 #if ENABLE(ATTACHMENT_ELEMENT)
     void didInsertAttachment(API::Attachment&, const String& source) final;
     void didRemoveAttachment(API::Attachment&) final;

Modified: branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm (273455 => 273456)


--- branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm	2021-02-25 00:39:45 UTC (rev 273456)
@@ -28,6 +28,7 @@
 
 #import "WKWebViewConfigurationPrivate.h"
 #import "WKWebViewInternal.h"
+#import "WKWebViewPrivate.h"
 #import "WKWebViewPrivateForTesting.h"
 #import <WebCore/AlternativeTextUIController.h>
 #import <wtf/Vector.h>
@@ -59,6 +60,11 @@
     return [m_webView _scrollingUpdatesDisabledForTesting];
 }
 
+void PageClientImplCocoa::setHasBlankOverlay(bool hasBlankOverlay)
+{
+    [m_webView _setHasBlankOverlay:hasBlankOverlay];
+}
+
 #if ENABLE(ATTACHMENT_ELEMENT)
 
 void PageClientImplCocoa::didInsertAttachment(API::Attachment& attachment, const String& source)

Added: branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/WKBlankOverlayView.h (0 => 273456)


--- branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/WKBlankOverlayView.h	                        (rev 0)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/WKBlankOverlayView.h	2021-02-25 00:39:45 UTC (rev 273456)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if PLATFORM(MAC)
+#import <AppKit/AppKit.h>
+
+using ViewType = NSView;
+using RectType = NSRect;
+#else
+#import <UIKit/UIKit.h>
+
+using ViewType = UIView;
+using RectType = CGRect;
+#endif
+
+@interface WKBlankOverlayView : ViewType
+
+- (instancetype)initWithFrame:(RectType)frame;
+
+@end

Added: branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/WKBlankOverlayView.mm (0 => 273456)


--- branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/WKBlankOverlayView.mm	                        (rev 0)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/WKBlankOverlayView.mm	2021-02-25 00:39:45 UTC (rev 273456)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKBlankOverlayView.mm"
+
+@implementation WKBlankOverlayView {
+}
+
+- (instancetype)initWithFrame:(RectType)frame
+{
+    if (!(self = [super initWithFrame:frame]))
+        return nil;
+
+#if PLATFORM(MAC)
+    [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+    [self setWantsLayer:YES];
+    [[self layer] setBackgroundColor:[[NSColor whiteColor] CGColor]];
+#else
+    [self setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
+    [[self layer] setBackgroundColor:[[UIColor whiteColor] CGColor]];
+#endif
+    [[self layer] setName:@"WKBlankOverlayView layer"];
+
+    return self;
+}
+
+@end

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


--- branches/safari-611-branch/Source/WebKit/UIProcess/PageClient.h	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/PageClient.h	2021-02-25 00:39:45 UTC (rev 273456)
@@ -502,7 +502,9 @@
     virtual bool hasSafeBrowsingWarning() const { return false; }
 
     virtual void setMouseEventPolicy(WebCore::MouseEventPolicy) { }
-    
+
+    virtual void setHasBlankOverlay(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 (273455 => 273456)


--- branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-02-25 00:39:45 UTC (rev 273456)
@@ -2395,6 +2395,25 @@
 }
 #endif
 
+void WebPageProxy::stopMakingViewBlankDueToLackOfRenderingUpdate()
+{
+#if PLATFORM(COCOA)
+    ASSERT(m_hasUpdatedRenderingAfterDidCommitLoad);
+    pageClient().setHasBlankOverlay(false);
+#endif
+}
+
+void WebPageProxy::makeViewBlankIfUnpaintedSinceLastLoadCommit()
+{
+#if PLATFORM(COCOA)
+    if (!m_hasUpdatedRenderingAfterDidCommitLoad) {
+        // Add a blank overlay view to make the view blank. This overlay will be taken down once
+        // when we've painted for the first time after committing a load.
+        pageClient().setHasBlankOverlay(true);
+    }
+#endif
+}
+
 void WebPageProxy::discardQueuedMouseEvents()
 {
     while (m_mouseEventQueue.size() > 1)
@@ -4630,10 +4649,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
 
@@ -5623,6 +5644,12 @@
         if (auto* automationSession = process().processPool().automationSession())
             automationSession->willShowJavaScriptDialog(*this);
     }
+
+    // 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 add a blank overlay
+    // on top of the view in this case.
+    makeViewBlankIfUnpaintedSinceLastLoadCommit();
+
     m_uiClient->runJavaScriptAlert(*this, message, frame, WTFMove(frameInfo), WTFMove(reply));
 }
 
@@ -5641,6 +5668,11 @@
             automationSession->willShowJavaScriptDialog(*this);
     }
 
+    // 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 add a blank overlay
+    // on top of the view in this case.
+    makeViewBlankIfUnpaintedSinceLastLoadCommit();
+
     m_uiClient->runJavaScriptConfirm(*this, message, frame, WTFMove(frameInfo), WTFMove(reply));
 }
 
@@ -5659,6 +5691,11 @@
             automationSession->willShowJavaScriptDialog(*this);
     }
 
+    // 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 add a blank overlay
+    // on top of the view in this case.
+    makeViewBlankIfUnpaintedSinceLastLoadCommit();
+
     m_uiClient->runJavaScriptPrompt(*this, message, defaultValue, frame, WTFMove(frameInfo), WTFMove(reply));
 }
 

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


--- branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.h	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.h	2021-02-25 00:39:45 UTC (rev 273456)
@@ -2118,6 +2118,9 @@
     void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&);
 #endif
 
+    void stopMakingViewBlankDueToLackOfRenderingUpdate();
+    void makeViewBlankIfUnpaintedSinceLastLoadCommit();
+
     // 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 +2152,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)
@@ -2445,11 +2449,13 @@
     std::unique_ptr<MediaUsageManager> m_mediaUsageManager;
 #endif
 
+#if PLATFORM(COCOA)
+    bool m_hasUpdatedRenderingAfterDidCommitLoad { true };
+#endif
 #if PLATFORM(IOS_FAMILY)
     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 };

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


--- branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-02-25 00:39:45 UTC (rev 273456)
@@ -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/WebPageProxyIOS.mm (273455 => 273456)


--- branches/safari-611-branch/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2021-02-25 00:39:45 UTC (rev 273456)
@@ -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/WebPageProxyMac.mm (273455 => 273456)


--- branches/safari-611-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2021-02-25 00:39:45 UTC (rev 273456)
@@ -651,8 +651,15 @@
     return [pageClient().platformWindow() contentView];
 }
 
-#if ENABLE(UI_PROCESS_PDF_HUD)
+void WebPageProxy::didUpdateRenderingAfterCommittingLoad()
+{
+    if (m_hasUpdatedRenderingAfterDidCommitLoad)
+        return;
 
+    m_hasUpdatedRenderingAfterDidCommitLoad = true;
+    stopMakingViewBlankDueToLackOfRenderingUpdate();
+}
+
 void WebPageProxy::createPDFHUD(PDFPluginIdentifier identifier, const WebCore::IntRect& rect)
 {
     pageClient().createPDFHUD(identifier, rect);

Modified: branches/safari-611-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj (273455 => 273456)


--- branches/safari-611-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-02-25 00:39:45 UTC (rev 273456)
@@ -950,6 +950,7 @@
 		44EC3EA9247F5C090059489C /* _WKDragActionsInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 44EC3EA8247F5C080059489C /* _WKDragActionsInternal.h */; };
 		460F488F1F996F7100CF4B87 /* WebSWContextManagerConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 460F488D1F996F6C00CF4B87 /* WebSWContextManagerConnectionMessageReceiver.cpp */; };
 		460F48901F996F7100CF4B87 /* WebSWContextManagerConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 460F488E1F996F6C00CF4B87 /* WebSWContextManagerConnectionMessages.h */; };
+		4613A74425D32CCF00A5033A /* WKBlankOverlayView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4613A74225D32CB800A5033A /* WKBlankOverlayView.h */; };
 		461CCCA5231485A700B659B9 /* UIRemoteObjectRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 463236852314833F00A48FA7 /* UIRemoteObjectRegistry.h */; };
 		461CCCA6231485AA00B659B9 /* WebRemoteObjectRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 46323683231481EF00A48FA7 /* WebRemoteObjectRegistry.h */; };
 		463FD4801EB9459600A2982C /* WKProcessTerminationReason.h in Headers */ = {isa = PBXBuildFile; fileRef = 463FD47F1EB9458400A2982C /* WKProcessTerminationReason.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3781,6 +3782,8 @@
 		4603011B234BE31E009C8217 /* WebBackForwardCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebBackForwardCache.h; sourceTree = "<group>"; };
 		460F488D1F996F6C00CF4B87 /* WebSWContextManagerConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSWContextManagerConnectionMessageReceiver.cpp; path = DerivedSources/WebKit2/WebSWContextManagerConnectionMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
 		460F488E1F996F6C00CF4B87 /* WebSWContextManagerConnectionMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSWContextManagerConnectionMessages.h; path = DerivedSources/WebKit2/WebSWContextManagerConnectionMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
+		4613A74225D32CB800A5033A /* WKBlankOverlayView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKBlankOverlayView.h; sourceTree = "<group>"; };
+		4613A74325D32CB900A5033A /* WKBlankOverlayView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKBlankOverlayView.mm; sourceTree = "<group>"; };
 		462107D71F38DBD300DD7810 /* PingLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PingLoad.cpp; sourceTree = "<group>"; };
 		46323683231481EF00A48FA7 /* WebRemoteObjectRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebRemoteObjectRegistry.h; sourceTree = "<group>"; };
 		463236842314825C00A48FA7 /* WebRemoteObjectRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebRemoteObjectRegistry.cpp; sourceTree = "<group>"; };
@@ -6839,6 +6842,8 @@
 				51D124321E6DE521002B2820 /* WebURLSchemeHandlerCocoa.mm */,
 				2DFC7DB91BCCC19500C1548C /* WebViewImpl.h */,
 				2DFC7DBA1BCCC19500C1548C /* WebViewImpl.mm */,
+				4613A74225D32CB800A5033A /* WKBlankOverlayView.h */,
+				4613A74325D32CB900A5033A /* WKBlankOverlayView.mm */,
 				E596DD68251E71D300C275A7 /* WKContactPicker.h */,
 				E596DD69251E71D400C275A7 /* WKContactPicker.mm */,
 				2ECF66CC21D6B77E009E5C3F /* WKEditCommand.h */,
@@ -12249,6 +12254,7 @@
 				BC646C1B11DD399F006455B0 /* WKBackForwardListRef.h in Headers */,
 				BCDDB317124EBD130048D13C /* WKBase.h in Headers */,
 				7CD5EBBB1746A83E000C1C45 /* WKBaseMac.h in Headers */,
+				4613A74425D32CCF00A5033A /* WKBlankOverlayView.h in Headers */,
 				BCBAAC73144E619E0053F82F /* WKBrowsingContextController.h in Headers */,
 				BCBAAC74144E61A50053F82F /* WKBrowsingContextControllerInternal.h in Headers */,
 				3788A05C14743C90006319E5 /* WKBrowsingContextControllerPrivate.h in Headers */,

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


--- branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-02-25 00:39:45 UTC (rev 273456)
@@ -6082,6 +6082,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 (273455 => 273456)


--- branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-02-25 00:39:45 UTC (rev 273456)
@@ -623,6 +623,8 @@
 #if PLATFORM(MAC)
     void setTopOverhangImage(WebImage*);
     void setBottomOverhangImage(WebImage*);
+
+    void didUpdateRendering();
     
     void setUseSystemAppearance(bool);
 
@@ -2090,6 +2092,9 @@
     CompletionHandler<void(InteractionInformationAtPosition&&)> m_pendingSynchronousPositionInformationReply;
     Optional<std::pair<TransactionID, double>> m_lastLayerTreeTransactionIdAndPageScaleBeforeScalingPage;
 #endif
+#if PLATFORM(MAC)
+    bool m_didUpdateRenderingAfterCommittingLoad { false };
+#endif
 
     WebCore::Timer m_layerVolatilityTimer;
     Vector<CompletionHandler<void(bool)>> m_markLayersAsVolatileCompletionHandlers;

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


--- branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2021-02-25 00:39:45 UTC (rev 273456)
@@ -481,6 +481,7 @@
         }
 
         sendDidFirstLayerFlushIfNeeded();
+        m_webPage.didUpdateRendering();
         handleActivityStateChangeCallbacksIfNeeded();
         invalidateRenderingUpdateRunLoopObserver();
     }

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


--- branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2021-02-25 00:37:42 UTC (rev 273455)
+++ branches/safari-611-branch/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2021-02-25 00:39:45 UTC (rev 273456)
@@ -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
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to