Add new compatibility mode API on WKNavigation
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Apr 2019 23:38:53 +0000 (23:38 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Apr 2019 23:38:53 +0000 (23:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197069
<rdar://problem/50025800>

Reviewed by Tim Horton.

Source/WebKit:

Adds a new property on WKNavigation.

* Shared/WebCompatibilityMode.h:

Drive-by fix: make this enum class 8 bits wide.

* UIProcess/API/APINavigation.h:
(API::Navigation::setEffectiveCompatibilityMode):
(API::Navigation::effectiveCompatibilityMode const):

Add a new member variable to API::Navigation.

* UIProcess/API/Cocoa/WKNavigation.h:
* UIProcess/API/Cocoa/WKNavigation.mm:
* UIProcess/API/Cocoa/WKWebpagePreferences.mm:
* UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h:

Add various hooks into WebKitAdditions.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::decidePolicyForNavigationAction):

Set API::Navigation's effective compatibility mode.

(WebKit::WebPageProxy::effectiveCompatibilityModeAfterAdjustingPolicies):

Renamed and refactored this method to return the effective compatibility mode, chosen while adjusting website
policies.

(WebKit::WebPageProxy::adjustPoliciesForCompatibilityMode): Deleted.
* UIProcess/WebPageProxy.h:

Tools:

Add a block property for -didCommitNavigation to TestNavigationDelegate.

* TestWebKitAPI/cocoa/TestNavigationDelegate.h:
* TestWebKitAPI/cocoa/TestNavigationDelegate.mm:
(-[TestNavigationDelegate webView:didCommitNavigation:]):

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

12 files changed:
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebCompatibilityMode.h
Source/WebKit/UIProcess/API/APINavigation.h
Source/WebKit/UIProcess/API/Cocoa/WKNavigation.h
Source/WebKit/UIProcess/API/Cocoa/WKNavigation.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Tools/ChangeLog
Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.h
Tools/TestWebKitAPI/cocoa/TestNavigationDelegate.mm

index 427920a..7457e49 100644 (file)
@@ -1,3 +1,43 @@
+2019-04-18  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Add new compatibility mode API on WKNavigation
+        https://bugs.webkit.org/show_bug.cgi?id=197069
+        <rdar://problem/50025800>
+
+        Reviewed by Tim Horton.
+
+        Adds a new property on WKNavigation.
+
+        * Shared/WebCompatibilityMode.h:
+
+        Drive-by fix: make this enum class 8 bits wide.
+
+        * UIProcess/API/APINavigation.h:
+        (API::Navigation::setEffectiveCompatibilityMode):
+        (API::Navigation::effectiveCompatibilityMode const):
+
+        Add a new member variable to API::Navigation.
+
+        * UIProcess/API/Cocoa/WKNavigation.h:
+        * UIProcess/API/Cocoa/WKNavigation.mm:
+        * UIProcess/API/Cocoa/WKWebpagePreferences.mm:
+        * UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h:
+
+        Add various hooks into WebKitAdditions.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::decidePolicyForNavigationAction):
+
+        Set API::Navigation's effective compatibility mode.
+
+        (WebKit::WebPageProxy::effectiveCompatibilityModeAfterAdjustingPolicies):
+
+        Renamed and refactored this method to return the effective compatibility mode, chosen while adjusting website
+        policies.
+
+        (WebKit::WebPageProxy::adjustPoliciesForCompatibilityMode): Deleted.
+        * UIProcess/WebPageProxy.h:
+
 2019-04-18  Don Olmstead  <don.olmstead@sony.com>
 
         [CMake] Make WebCore headers copies
index 91b5bb1..cedf18f 100644 (file)
@@ -29,7 +29,7 @@
 
 namespace WebKit {
 
-enum class WebCompatibilityMode {
+enum class WebCompatibilityMode : uint8_t {
     Recommended,
     Legacy,
     Modern,
index bba0719..92418f8 100644 (file)
@@ -30,6 +30,7 @@
 #include "FrameInfoData.h"
 #include "NavigationActionData.h"
 #include "WebBackForwardListItem.h"
+#include "WebCompatibilityMode.h"
 #include <WebCore/AdClickAttribution.h>
 #include <WebCore/ProcessIdentifier.h>
 #include <WebCore/ResourceRequest.h>
@@ -141,6 +142,9 @@ public:
     void setDestinationFrameSecurityOrigin(const WebCore::SecurityOriginData& origin) { m_destinationFrameSecurityOrigin = origin; }
     const WebCore::SecurityOriginData& destinationFrameSecurityOrigin() const { return m_destinationFrameSecurityOrigin; }
 
+    void setEffectiveCompatibilityMode(WebKit::WebCompatibilityMode compatibilityMode) { m_effectiveCompatibilityMode = compatibilityMode; }
+    WebKit::WebCompatibilityMode effectiveCompatibilityMode() const { return m_effectiveCompatibilityMode; }
+
 #if !LOG_DISABLED
     const char* loggingString() const;
 #endif
@@ -169,6 +173,7 @@ private:
     WebKit::FrameInfoData m_originatingFrameInfo;
     WebCore::SecurityOriginData m_destinationFrameSecurityOrigin;
     bool m_userContentExtensionsEnabled { true };
+    WebKit::WebCompatibilityMode m_effectiveCompatibilityMode { WebKit::WebCompatibilityMode::Recommended };
 };
 
 } // namespace API
index 357451e..e881dfc 100644 (file)
@@ -26,6 +26,7 @@
 #import <WebKit/WKFoundation.h>
 
 #import <Foundation/Foundation.h>
+#import <WebKit/WKWebpagePreferences.h>
 
 /*! A WKNavigation object can be used for tracking the loading progress of a webpage.
  @discussion A navigation is returned from the web view load methods, and is
@@ -35,4 +36,8 @@
 WK_CLASS_AVAILABLE(macos(10.10), ios(8.0))
 @interface WKNavigation : NSObject
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WKNavigationAdditions.h>
+#endif
+
 @end
index fdb4490..905309c 100644 (file)
@@ -25,6 +25,7 @@
 
 #import "config.h"
 #import "WKNavigationInternal.h"
+#import "WKWebpagePreferencesInternal.h"
 
 #import "APINavigation.h"
 
     return _navigation->originalRequest().nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody);
 }
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WKNavigationAdditions.mm>
+#endif
+
 #pragma mark WKObject protocol implementation
 
 - (API::Object&)_apiObject
index b431d84..9f5cd76 100644 (file)
 #import "_WKWebsitePoliciesInternal.h"
 #import <wtf/RetainPtr.h>
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WKWebpagePreferencesAdditionsBefore.mm>
+#endif
+
 @implementation WKWebpagePreferences
 
 + (instancetype)defaultPreferences
@@ -278,7 +282,7 @@ static _WKWebsiteDeviceOrientationAndMotionAccessPolicy toWKWebsiteDeviceOrienta
 }
 
 #if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKWebpagePreferencesAdditions.mm>
+#import <WebKitAdditions/WKWebpagePreferencesAdditionsAfter.mm>
 #endif
 
 @end
index 6d8130f..db61188 100644 (file)
@@ -36,6 +36,10 @@ template<> struct WrapperTraits<API::WebsitePolicies> {
     using WrapperClass = WKWebpagePreferences;
 };
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WKWebpagePreferencesInternalAdditions.h>
+#endif
+
 }
 
 @interface WKWebpagePreferences () <WKObject> {
index bbf043f..14ca021 100644 (file)
@@ -4592,7 +4592,7 @@ void WebPageProxy::decidePolicyForNavigationAction(Ref<WebProcessProxy>&& proces
                         policies = defaultPolicies->copy();
                 }
                 if (policies)
-                    adjustPoliciesForCompatibilityMode(*policies);
+                    navigation->setEffectiveCompatibilityMode(effectiveCompatibilityModeAfterAdjustingPolicies(*policies));
             }
             receivedNavigationPolicyDecision(policyAction, navigation.get(), processSwapRequestedByClient, frame, policies.get(), WTFMove(sender));
         };
@@ -8999,8 +8999,9 @@ void WebPageProxy::speechSynthesisResume(CompletionHandler<void()>&& completionH
 
 #if !PLATFORM(IOS_FAMILY) || !USE(APPLE_INTERNAL_SDK)
 
-void WebPageProxy::adjustPoliciesForCompatibilityMode(API::WebsitePolicies&)
+WebCompatibilityMode WebPageProxy::effectiveCompatibilityModeAfterAdjustingPolicies(API::WebsitePolicies&)
 {
+    return WebCompatibilityMode::Recommended;
 }
 
 #endif // !PLATFORM(IOS_FAMILY) || !USE(APPLE_INTERNAL_SDK)
index 0845d15..8f812fb 100644 (file)
@@ -293,6 +293,7 @@ struct URLSchemeTaskParameters;
 
 enum class ProcessSwapRequestedByClient;
 enum class UndoOrRedo : bool;
+enum class WebCompatibilityMode : uint8_t;
 
 #if USE(QUICK_LOOK)
 class QuickLookDocumentData;
@@ -1625,7 +1626,7 @@ private:
     void unableToImplementPolicy(uint64_t frameID, const WebCore::ResourceError&, const UserData&);
     void beginSafeBrowsingCheck(const URL&, bool, WebFramePolicyListenerProxy&);
 
-    void adjustPoliciesForCompatibilityMode(API::WebsitePolicies&);
+    WebCompatibilityMode effectiveCompatibilityModeAfterAdjustingPolicies(API::WebsitePolicies&);
 
     void willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const Vector<std::pair<String, String>>& textFieldValues, uint64_t listenerID, const UserData&);
 
index 108af91..ccae8d9 100644 (file)
@@ -1,3 +1,17 @@
+2019-04-18  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Add new compatibility mode API on WKNavigation
+        https://bugs.webkit.org/show_bug.cgi?id=197069
+        <rdar://problem/50025800>
+
+        Reviewed by Tim Horton.
+
+        Add a block property for -didCommitNavigation to TestNavigationDelegate.
+
+        * TestWebKitAPI/cocoa/TestNavigationDelegate.h:
+        * TestWebKitAPI/cocoa/TestNavigationDelegate.mm:
+        (-[TestNavigationDelegate webView:didCommitNavigation:]):
+
 2019-04-18  Don Olmstead  <don.olmstead@sony.com>
 
         [CMake] Make WebCore headers copies
index 75a83c2..effbd49 100644 (file)
@@ -33,6 +33,7 @@
 @property (nonatomic, copy) void (^decidePolicyForNavigationAction)(WKNavigationAction *, void (^)(WKNavigationActionPolicy));
 @property (nonatomic, copy) void (^didFailProvisionalNavigation)(WKWebView *, WKNavigation *, NSError *);
 @property (nonatomic, copy) void (^didStartProvisionalNavigation)(WKWebView *, WKNavigation *);
+@property (nonatomic, copy) void (^didCommitNavigation)(WKWebView *, WKNavigation *);
 @property (nonatomic, copy) void (^didFinishNavigation)(WKWebView *, WKNavigation *);
 @property (nonatomic, copy) void (^renderingProgressDidChange)(WKWebView *, _WKRenderingProgressEvents);
 @property (nonatomic, copy) void (^webContentProcessDidTerminate)(WKWebView *);
index 9a18358..742ac7a 100644 (file)
         _didStartProvisionalNavigation(webView, navigation);
 }
 
+- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation
+{
+    if (_didCommitNavigation)
+        _didCommitNavigation(webView, navigation);
+}
+
 - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
 {
     if (_didFailProvisionalNavigation)