Skip to content
Permalink
Browse files
Add new compatibility mode API on WKNavigation
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:]):


Canonical link: https://commits.webkit.org/211326@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244444 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
whsieh committed Apr 18, 2019
1 parent ed3954e commit 809b92bd2e752fb3de4c8adc65f9c5a37a85c606
Showing 12 changed files with 91 additions and 5 deletions.
@@ -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
@@ -29,7 +29,7 @@

namespace WebKit {

enum class WebCompatibilityMode {
enum class WebCompatibilityMode : uint8_t {
Recommended,
Legacy,
Modern,
@@ -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 @@ class Navigation : public ObjectImpl<Object::Type::Navigation> {
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 @@ class Navigation : public ObjectImpl<Object::Type::Navigation> {
WebKit::FrameInfoData m_originatingFrameInfo;
WebCore::SecurityOriginData m_destinationFrameSecurityOrigin;
bool m_userContentExtensionsEnabled { true };
WebKit::WebCompatibilityMode m_effectiveCompatibilityMode { WebKit::WebCompatibilityMode::Recommended };
};

} // namespace API
@@ -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
@@ -25,6 +25,7 @@

#import "config.h"
#import "WKNavigationInternal.h"
#import "WKWebpagePreferencesInternal.h"

#import "APINavigation.h"

@@ -44,6 +45,10 @@ - (NSURLRequest *)_request
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
@@ -32,6 +32,10 @@
#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 @@ - (NSString *)_customNavigatorPlatform
}

#if USE(APPLE_INTERNAL_SDK)
#import <WebKitAdditions/WKWebpagePreferencesAdditions.mm>
#import <WebKitAdditions/WKWebpagePreferencesAdditionsAfter.mm>
#endif

@end
@@ -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> {
@@ -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)
@@ -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 @@ WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_1
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&);

@@ -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
@@ -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 *);
@@ -45,6 +45,12 @@ - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation
_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)

0 comments on commit 809b92b

Please sign in to comment.