[Cocoa] Report the first paint after committing a load as a rendering progress event
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Jul 2015 07:01:49 +0000 (07:01 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Jul 2015 07:01:49 +0000 (07:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=146765

Reviewed by Tim Horton.

* Shared/API/Cocoa/_WKRenderingProgressEvents.h: Added _WKRenderingProgressEventFirstPaint.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _didCommitLayerTree:]): If this is the first layer tree commit since the load
was committed, and the delegate is observing _WKRenderingProgressEventFirstPaint, call
NavigationState::didFirstPaint.

* UIProcess/Cocoa/NavigationState.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::didFirstPaint): Added. Calls -_webView:renderingProgressDidChange:
with _WKRenderingProgressEventFirstPaint.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/Cocoa/_WKRenderingProgressEvents.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/Cocoa/NavigationState.h
Source/WebKit2/UIProcess/Cocoa/NavigationState.mm

index 1900dcf..29e55ec 100644 (file)
@@ -1,3 +1,22 @@
+2015-07-09  Dan Bernstein  <mitz@apple.com>
+
+        [Cocoa] Report the first paint after committing a load as a rendering progress event
+        https://bugs.webkit.org/show_bug.cgi?id=146765
+
+        Reviewed by Tim Horton.
+
+        * Shared/API/Cocoa/_WKRenderingProgressEvents.h: Added _WKRenderingProgressEventFirstPaint.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _didCommitLayerTree:]): If this is the first layer tree commit since the load
+        was committed, and the delegate is observing _WKRenderingProgressEventFirstPaint, call
+        NavigationState::didFirstPaint.
+
+        * UIProcess/Cocoa/NavigationState.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::didFirstPaint): Added. Calls -_webView:renderingProgressDidChange:
+        with _WKRenderingProgressEventFirstPaint.
+
 2015-07-08  Jinwoo Song  <jinwoo7.song@samsung.com>
 
         [EFL] When closing inspector window, EwkView is not released properly.
index df6feb4..fc7e2d6 100644 (file)
@@ -33,7 +33,8 @@ typedef NS_OPTIONS(NSUInteger, _WKRenderingProgressEvents) {
     _WKRenderingProgressEventFirstPaintWithSignificantArea = 1 << 2,
     _WKRenderingProgressEventReachedSessionRestorationRenderTreeSizeThreshold WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA) = 1 << 3,
     _WKRenderingProgressEventFirstLayoutAfterSuppressedIncrementalRendering WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA) = 1 << 4,
-    _WKRenderingProgressEventFirstPaintAfterSuppressedIncrementalRendering WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA) = 1 << 5
+    _WKRenderingProgressEventFirstPaintAfterSuppressedIncrementalRendering WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA) = 1 << 5,
+    _WKRenderingProgressEventFirstPaint WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA) = 1 << 6,
 } WK_ENUM_AVAILABLE(10_10, 8_0);
 
 #endif
index 5ce7551..3ff0b46 100644 (file)
@@ -971,6 +971,8 @@ static inline bool areEssentiallyEqualAsFloat(float a, float b)
         _needsResetViewStateAfterCommitLoadForMainFrame = NO;
         [_scrollView setContentOffset:[self _adjustedContentOffset:CGPointZero]];
         [self _updateVisibleContentRects];
+        if (_observedRenderingProgressEvents & _WKRenderingProgressEventFirstPaint)
+            _navigationState->didFirstPaint();
     }
 
     bool isTransactionAfterPageRestore = layerTreeTransaction.transactionID() >= _firstTransactionIDAfterPageRestore;
index 9ed1ce9..d5526a1 100644 (file)
@@ -73,6 +73,8 @@ public:
     void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&);
     void willRecordNavigationSnapshot(WebBackForwardListItem&);
 
+    void didFirstPaint();
+
 private:
     class NavigationClient final : public API::NavigationClient {
     public:
index 507bb62..5e7e28b 100644 (file)
@@ -224,6 +224,18 @@ void NavigationState::willRecordNavigationSnapshot(WebBackForwardListItem& item)
     [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate) _webView:m_webView willSnapshotBackForwardListItem:wrapper(item)];
 }
 
+void NavigationState::didFirstPaint()
+{
+    if (!m_navigationDelegateMethods.webViewRenderingProgressDidChange)
+        return;
+
+    auto navigationDelegate = m_navigationDelegate.get();
+    if (!navigationDelegate)
+        return;
+
+    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate) _webView:m_webView renderingProgressDidChange:_WKRenderingProgressEventFirstPaint];
+}
+
 NavigationState::NavigationClient::NavigationClient(NavigationState& navigationState)
     : m_navigationState(navigationState)
 {