Title: [164049] trunk/Source/WebKit2
Revision
164049
Author
[email protected]
Date
2014-02-13 13:14:05 -0800 (Thu, 13 Feb 2014)

Log Message

Add rendering progress events SPI
https://bugs.webkit.org/show_bug.cgi?id=128752

Reviewed by Dan Bernstein.

* UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _observedRenderingProgressEvents]):
(layoutMilestones):
(-[WKWebView _setObservedRenderingProgressEvents:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
(NS_OPTIONS):
* UIProcess/Cocoa/NavigationState.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::setNavigationDelegate):
(WebKit::renderingProgressEvents):
(WebKit::NavigationState::LoaderClient::didLayout):
* WebKit2.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (164048 => 164049)


--- trunk/Source/WebKit2/ChangeLog	2014-02-13 20:46:48 UTC (rev 164048)
+++ trunk/Source/WebKit2/ChangeLog	2014-02-13 21:14:05 UTC (rev 164049)
@@ -1,5 +1,26 @@
 2014-02-13  Anders Carlsson  <[email protected]>
 
+        Add rendering progress events SPI
+        https://bugs.webkit.org/show_bug.cgi?id=128752
+
+        Reviewed by Dan Bernstein.
+
+        * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h: Copied from Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h.
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _observedRenderingProgressEvents]):
+        (layoutMilestones):
+        (-[WKWebView _setObservedRenderingProgressEvents:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        (NS_OPTIONS):
+        * UIProcess/Cocoa/NavigationState.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::setNavigationDelegate):
+        (WebKit::renderingProgressEvents):
+        (WebKit::NavigationState::LoaderClient::didLayout):
+        * WebKit2.xcodeproj/project.pbxproj:
+
+2014-02-13  Anders Carlsson  <[email protected]>
+
         Disable XPC for plug-ins that need executable heap
         https://bugs.webkit.org/show_bug.cgi?id=128744
         <rdar://problem/15962958>

Copied: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h (from rev 164035, trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h) (0 => 164049)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h	2014-02-13 21:14:05 UTC (rev 164049)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2014 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 <WebKit2/WKNavigationDelegate.h>
+#import <WebKit2/WKWebViewPrivate.h>
+
+#if WK_API_ENABLED
+
+@protocol WKNavigationDelegatePrivate <WKNavigationDelegate>
+
+@optional
+
+- (void)_webView:(WKWebView *)webView renderingProgressDidChange:(_WKRenderingProgressEvents)progressEvents;
+
+@end
+
+#endif

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (164048 => 164049)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-02-13 20:46:48 UTC (rev 164048)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-02-13 21:14:05 UTC (rev 164049)
@@ -58,6 +58,7 @@
     std::unique_ptr<WebKit::NavigationState> _navigationState;
 
     RetainPtr<WKRemoteObjectRegistry> _remoteObjectRegistry;
+    _WKRenderingProgressEvents _observedRenderingProgressEvents;
 
 #if PLATFORM(IOS)
     RetainPtr<WKScrollView> _scrollView;
@@ -372,6 +373,30 @@
     return _remoteObjectRegistry.get();
 }
 
+- (_WKRenderingProgressEvents)_observedRenderingProgressEvents
+{
+    return _observedRenderingProgressEvents;
+}
+
+static inline WebCore::LayoutMilestones layoutMilestones(_WKRenderingProgressEvents events)
+{
+    WebCore::LayoutMilestones milestones = 0;
+
+    if (events & _WKRenderingProgressEventFirstLayout)
+        milestones |= WebCore::DidFirstLayout;
+
+    if (events & WKRenderingProgressEventFirstPaintWithSignificantArea)
+        milestones |= WebCore::DidHitRelevantRepaintedObjectsAreaThreshold;
+
+    return milestones;
+}
+
+- (void)_setObservedRenderingProgressEvents:(_WKRenderingProgressEvents)observedRenderingProgressEvents
+{
+    _observedRenderingProgressEvents = observedRenderingProgressEvents;
+    _page->listenForLayoutMilestones(layoutMilestones(observedRenderingProgressEvents));
+}
+
 #pragma mark iOS-specific methods
 
 #if PLATFORM(IOS)

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (164048 => 164049)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2014-02-13 20:46:48 UTC (rev 164048)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2014-02-13 21:14:05 UTC (rev 164049)
@@ -27,11 +27,17 @@
 
 #if WK_API_ENABLED
 
+typedef NS_OPTIONS(NSUInteger, _WKRenderingProgressEvents) {
+    _WKRenderingProgressEventFirstLayout = 1 << 0,
+    _WKRenderingProgressEventFirstPaintWithSignificantArea = 1 << 2,
+};
+
 @class WKRemoteObjectRegistry;
 
 @interface WKWebView (WKPrivate)
 
 @property (nonatomic, readonly) WKRemoteObjectRegistry *_remoteObjectRegistry;
+@property (nonatomic, setter=_setObservedRenderingProgressEvents:) _WKRenderingProgressEvents _observedRenderingProgressEvents;
 
 #if TARGET_OS_IPHONE
 @property (nonatomic, setter=_setMinimumLayoutSizeOverride:) CGSize _minimumLayoutSizeOverride;

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h (164048 => 164049)


--- trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h	2014-02-13 20:46:48 UTC (rev 164048)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h	2014-02-13 21:14:05 UTC (rev 164049)
@@ -82,7 +82,8 @@
         virtual void didFailProvisionalLoadWithErrorForFrame(WebPageProxy*, WebFrameProxy*, uint64_t navigationID, const WebCore::ResourceError&, API::Object*) override;
         virtual void didCommitLoadForFrame(WebPageProxy*, WebFrameProxy*, uint64_t navigationID, API::Object*) override;
         virtual void didFinishLoadForFrame(WebPageProxy*, WebFrameProxy*, uint64_t navigationID, API::Object*) override;
-        virtual void didFailLoadWithErrorForFrame(WebPageProxy*, WebFrameProxy*, uint64_t navigationID, const WebCore::ResourceError&, API::Object* userData) override;
+        virtual void didFailLoadWithErrorForFrame(WebPageProxy*, WebFrameProxy*, uint64_t navigationID, const WebCore::ResourceError&, API::Object*) override;
+        virtual void didLayout(WebKit::WebPageProxy*, WebCore::LayoutMilestones, API::Object*) override;
 
         NavigationState& m_navigationState;
     };
@@ -112,6 +113,8 @@
         bool webViewDidCommitNavigation : 1;
         bool webViewDidFinishLoadingNavigation : 1;
         bool webViewDidFailNavigationWithError : 1;
+
+        bool webViewRenderingProgressDidChange : 1;
     } m_navigationDelegateMethods;
 
     HashMap<uint64_t, RetainPtr<WKNavigation>> m_navigations;

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm (164048 => 164049)


--- trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm	2014-02-13 20:46:48 UTC (rev 164048)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm	2014-02-13 21:14:05 UTC (rev 164049)
@@ -32,7 +32,7 @@
 #import "PageLoadState.h"
 #import "WKFrameInfoInternal.h"
 #import "WKNavigationActionInternal.h"
-#import "WKNavigationDelegate.h"
+#import "WKNavigationDelegatePrivate.h"
 #import "WKNavigationInternal.h"
 #import "WKNavigationResponseInternal.h"
 #import "WKWebViewInternal.h"
@@ -83,6 +83,8 @@
     m_navigationDelegateMethods.webViewDidCommitNavigation = [delegate respondsToSelector:@selector(webView:didCommitNavigation:)];
     m_navigationDelegateMethods.webViewDidFinishLoadingNavigation = [delegate respondsToSelector:@selector(webView:didFinishLoadingNavigation:)];
     m_navigationDelegateMethods.webViewDidFailNavigationWithError = [delegate respondsToSelector:@selector(webView:didFailNavigation:withError:)];
+
+    m_navigationDelegateMethods.webViewRenderingProgressDidChange = [delegate respondsToSelector:@selector(_webView:renderingProgressDidChange:)];
 }
 
 RetainPtr<WKNavigation> NavigationState::createLoadRequestNavigation(uint64_t navigationID, NSURLRequest *request)
@@ -345,6 +347,31 @@
     [navigationDelegate webView:m_navigationState.m_webView didFailNavigation:navigation withError:error];
 }
 
+static _WKRenderingProgressEvents renderingProgressEvents(WebCore::LayoutMilestones milestones)
+{
+    _WKRenderingProgressEvents events = 0;
+
+    if (milestones & WebCore::DidFirstLayout)
+        events |= _WKRenderingProgressEventFirstLayout;
+
+    if (milestones & WebCore::DidHitRelevantRepaintedObjectsAreaThreshold)
+        events |= _WKRenderingProgressEventFirstPaintWithSignificantArea;
+
+    return events;
+}
+
+void NavigationState::LoaderClient::didLayout(WebKit::WebPageProxy*, WebCore::LayoutMilestones layoutMilestones, API::Object*)
+{
+    if (!m_navigationState.m_navigationDelegateMethods.webViewRenderingProgressDidChange)
+        return;
+
+    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
+    if (!navigationDelegate)
+        return;
+
+    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView renderingProgressDidChange:renderingProgressEvents(layoutMilestones)];
+}
+
 void NavigationState::willChangeIsLoading()
 {
     [m_webView willChangeValueForKey:@"loading"];

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (164048 => 164049)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-02-13 20:46:48 UTC (rev 164048)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-02-13 21:14:05 UTC (rev 164049)
@@ -243,6 +243,7 @@
 		1A9E329F1822FEDD00F5D04C /* WKRemoteObjectCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9E329D1822FEDD00F5D04C /* WKRemoteObjectCoder.h */; };
 		1A9E32A11823018900F5D04C /* WKRemoteObjectRegistryInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9E32A01823018900F5D04C /* WKRemoteObjectRegistryInternal.h */; };
 		1A9FBA8D13FF04E600DEED67 /* PluginComplexTextInputState.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9FBA8C13FF04E600DEED67 /* PluginComplexTextInputState.h */; };
+		1AA20D5118AD50E0005D1ED4 /* WKNavigationDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA20D5018AD50E0005D1ED4 /* WKNavigationDelegatePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1AA2E51D12E4C05E00BC4966 /* CGUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA2E51B12E4C05E00BC4966 /* CGUtilities.h */; };
 		1AA2E51E12E4C05E00BC4966 /* CGUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA2E51C12E4C05E00BC4966 /* CGUtilities.cpp */; };
 		1AA3D75B1651B44F008713D0 /* RemoteLayerTreeHost.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AA3D7591651B44F008713D0 /* RemoteLayerTreeHost.mm */; };
@@ -1920,6 +1921,7 @@
 		1AA1C7DE100E846E0078DEBC /* _javascript_Core.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = _javascript_Core.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		1AA1CC5C100FA1A10078DEBC /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = "<absolute>"; };
 		1AA1CD06100FA1BA0078DEBC /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
+		1AA20D5018AD50E0005D1ED4 /* WKNavigationDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationDelegatePrivate.h; sourceTree = "<group>"; };
 		1AA2E51B12E4C05E00BC4966 /* CGUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CGUtilities.h; sourceTree = "<group>"; };
 		1AA2E51C12E4C05E00BC4966 /* CGUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CGUtilities.cpp; sourceTree = "<group>"; };
 		1AA3D7591651B44F008713D0 /* RemoteLayerTreeHost.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerTreeHost.mm; sourceTree = "<group>"; };
@@ -4373,6 +4375,7 @@
 				1A256E3518A1A788006FB922 /* WKNavigationAction.mm */,
 				1A256E3918A1A7DF006FB922 /* WKNavigationActionInternal.h */,
 				1ABC3DFB1899F51C004F0626 /* WKNavigationDelegate.h */,
+				1AA20D5018AD50E0005D1ED4 /* WKNavigationDelegatePrivate.h */,
 				1ABC3DF01899C6B6004F0626 /* WKNavigationInternal.h */,
 				1A1B0EB418A424950038481A /* WKNavigationResponse.h */,
 				1A1B0EB318A424950038481A /* WKNavigationResponse.mm */,
@@ -6511,6 +6514,7 @@
 				E18E6918169B667B009B6670 /* SecItemShimProxyMessages.h in Headers */,
 				33152976130D0CB200ED2483 /* SecurityOriginData.h in Headers */,
 				518D2CCB12D51DFB003BB93B /* SessionState.h in Headers */,
+				1AA20D5118AD50E0005D1ED4 /* WKNavigationDelegatePrivate.h in Headers */,
 				1A6420E512DCE2FF00CAAE2C /* ShareableBitmap.h in Headers */,
 				51217461164C20E30037A5C1 /* ShareableResource.h in Headers */,
 				1A24BED5120894D100FBB059 /* SharedMemory.h in Headers */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to