Diff
Modified: trunk/Source/WebKit/ChangeLog (234153 => 234154)
--- trunk/Source/WebKit/ChangeLog 2018-07-24 17:25:25 UTC (rev 234153)
+++ trunk/Source/WebKit/ChangeLog 2018-07-24 17:27:15 UTC (rev 234154)
@@ -1,5 +1,49 @@
2018-07-24 Alex Christensen <[email protected]>
+ Reduce getters/setters in WebFramePolicyListenerProxy
+ https://bugs.webkit.org/show_bug.cgi?id=187830
+
+ Reviewed by Dean Jackson.
+
+ This is a step towards making it a lambda, which has no getters or setters.
+ No change in behavior.
+
+ setApplyPolicyInNewProcessIfPossible can be replaced by passing another parameter.
+ This bit was just piggy-backing on the WebFramePolicyListenerProxy.
+
+ isMainFrame was only used in an assert, which has a corresponding ObjC exception in
+ NavigationState::NavigationClient::decidePolicyForNavigationAction for the one relevant client.
+
+ * UIProcess/API/C/WKFramePolicyListener.cpp:
+ (WKFramePolicyListenerUseInNewProcess):
+ (useWithPolicies):
+ (WKFramePolicyListenerUseWithPolicies):
+ (WKFramePolicyListenerUseInNewProcessWithPolicies):
+ * UIProcess/Cocoa/NavigationState.mm:
+ (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
+ * UIProcess/WebFramePolicyListenerProxy.cpp:
+ (WebKit::WebFramePolicyListenerProxy::receivedPolicyDecision):
+ (WebKit::WebFramePolicyListenerProxy::use):
+ (WebKit::WebFramePolicyListenerProxy::download):
+ (WebKit::WebFramePolicyListenerProxy::ignore):
+ (WebKit::WebFramePolicyListenerProxy::isMainFrame const): Deleted.
+ * UIProcess/WebFramePolicyListenerProxy.h:
+ (WebKit::WebFramePolicyListenerProxy::setApplyPolicyInNewProcessIfPossible): Deleted.
+ (WebKit::WebFramePolicyListenerProxy::applyPolicyInNewProcessIfPossible const): Deleted.
+ * UIProcess/WebFrameProxy.cpp:
+ (WebKit::WebFrameProxy::receivedPolicyDecision):
+ * UIProcess/WebFrameProxy.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::receivedPolicyDecision):
+ (WebKit::WebPageProxy::decidePolicyForNavigationAction):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::processForNavigation):
+ (WebKit::WebProcessPool::processForNavigationInternal):
+ * UIProcess/WebProcessPool.h:
+
+2018-07-24 Alex Christensen <[email protected]>
+
Remove WebFramePolicyListenerProxy::invalidate
https://bugs.webkit.org/show_bug.cgi?id=187833
Modified: trunk/Source/WebKit/UIProcess/API/C/WKFramePolicyListener.cpp (234153 => 234154)
--- trunk/Source/WebKit/UIProcess/API/C/WKFramePolicyListener.cpp 2018-07-24 17:25:25 UTC (rev 234153)
+++ trunk/Source/WebKit/UIProcess/API/C/WKFramePolicyListener.cpp 2018-07-24 17:27:15 UTC (rev 234154)
@@ -31,6 +31,7 @@
#include "WKAPICast.h"
#include "WebFramePolicyListenerProxy.h"
#include "WebFrameProxy.h"
+#include "WebProcessPool.h"
#include "WebsitePoliciesData.h"
using namespace WebKit;
@@ -47,11 +48,10 @@
void WKFramePolicyListenerUseInNewProcess(WKFramePolicyListenerRef policyListenerRef)
{
- toImpl(policyListenerRef)->setApplyPolicyInNewProcessIfPossible(true);
- toImpl(policyListenerRef)->use(std::nullopt);
+ toImpl(policyListenerRef)->use(std::nullopt, ShouldProcessSwapIfPossible::Yes);
}
-void WKFramePolicyListenerUseWithPolicies(WKFramePolicyListenerRef policyListenerRef, WKWebsitePoliciesRef websitePolicies)
+static void useWithPolicies(WKFramePolicyListenerRef policyListenerRef, WKWebsitePoliciesRef websitePolicies, ShouldProcessSwapIfPossible shouldProcessSwapIfPossible)
{
auto data = ""
@@ -58,18 +58,21 @@
if (data.websiteDataStoreParameters) {
auto& sessionID = data.websiteDataStoreParameters->networkSessionParameters.sessionID;
RELEASE_ASSERT_WITH_MESSAGE(sessionID.isEphemeral() || sessionID == PAL::SessionID::defaultSessionID(), "If WebsitePolicies specifies a WebsiteDataStore, the data store's session must be default or non-persistent.");
- RELEASE_ASSERT_WITH_MESSAGE(toImpl(policyListenerRef)->isMainFrame(), "WebsitePolicies cannot specify a WebsiteDataStore for subframe navigations.");
toImpl(policyListenerRef)->changeWebsiteDataStore(toImpl(websitePolicies)->websiteDataStore()->websiteDataStore());
}
- toImpl(policyListenerRef)->use(WTFMove(data));
+ toImpl(policyListenerRef)->use(WTFMove(data), shouldProcessSwapIfPossible);
}
+void WKFramePolicyListenerUseWithPolicies(WKFramePolicyListenerRef policyListenerRef, WKWebsitePoliciesRef websitePolicies)
+{
+ useWithPolicies(policyListenerRef, websitePolicies, ShouldProcessSwapIfPossible::No);
+}
+
void WKFramePolicyListenerUseInNewProcessWithPolicies(WKFramePolicyListenerRef policyListenerRef, WKWebsitePoliciesRef websitePolicies)
{
- toImpl(policyListenerRef)->setApplyPolicyInNewProcessIfPossible(true);
- WKFramePolicyListenerUseWithPolicies(policyListenerRef, websitePolicies);
+ useWithPolicies(policyListenerRef, websitePolicies, ShouldProcessSwapIfPossible::Yes);
}
void WKFramePolicyListenerDownload(WKFramePolicyListenerRef policyListenerRef)
Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm (234153 => 234154)
--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm 2018-07-24 17:25:25 UTC (rev 234153)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm 2018-07-24 17:27:15 UTC (rev 234154)
@@ -551,13 +551,12 @@
case _WKNavigationActionPolicyAllowInNewProcess:
#pragma clang diagnostic pop
tryAppLink(WTFMove(navigationAction), mainFrameURLString, [actionPolicy, localListener = WTFMove(localListener), data = "" followedLinkToApp) mutable {
- localListener->setApplyPolicyInNewProcessIfPossible(actionPolicy == _WKNavigationActionPolicyAllowInNewProcess);
if (followedLinkToApp) {
localListener->ignore();
return;
}
- localListener->use(WTFMove(data));
+ localListener->use(WTFMove(data), actionPolicy == _WKNavigationActionPolicyAllowInNewProcess ? ShouldProcessSwapIfPossible::Yes : ShouldProcessSwapIfPossible::No);
});
break;
Modified: trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp (234153 => 234154)
--- trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp 2018-07-24 17:25:25 UTC (rev 234153)
+++ trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp 2018-07-24 17:27:15 UTC (rev 234154)
@@ -40,12 +40,12 @@
{
}
-void WebFramePolicyListenerProxy::receivedPolicyDecision(WebCore::PolicyAction action, std::optional<WebsitePoliciesData>&& data)
+void WebFramePolicyListenerProxy::receivedPolicyDecision(WebCore::PolicyAction action, std::optional<WebsitePoliciesData>&& data, ShouldProcessSwapIfPossible swap)
{
if (!m_frame)
return;
- m_frame->receivedPolicyDecision(action, m_listenerID, m_navigation.get(), WTFMove(data));
+ m_frame->receivedPolicyDecision(action, m_listenerID, m_navigation.get(), WTFMove(data), swap);
m_frame = nullptr;
}
@@ -57,32 +57,24 @@
m_frame->changeWebsiteDataStore(websiteDataStore);
}
-bool WebFramePolicyListenerProxy::isMainFrame() const
-{
- if (!m_frame)
- return false;
-
- return m_frame->isMainFrame();
-}
-
void WebFramePolicyListenerProxy::setNavigation(Ref<API::Navigation>&& navigation)
{
m_navigation = WTFMove(navigation);
}
-void WebFramePolicyListenerProxy::use(std::optional<WebsitePoliciesData>&& data)
+void WebFramePolicyListenerProxy::use(std::optional<WebsitePoliciesData>&& data, ShouldProcessSwapIfPossible swap)
{
- receivedPolicyDecision(WebCore::PolicyAction::Use, WTFMove(data));
+ receivedPolicyDecision(WebCore::PolicyAction::Use, WTFMove(data), swap);
}
void WebFramePolicyListenerProxy::download()
{
- receivedPolicyDecision(WebCore::PolicyAction::Download, std::nullopt);
+ receivedPolicyDecision(WebCore::PolicyAction::Download, std::nullopt, ShouldProcessSwapIfPossible::No);
}
void WebFramePolicyListenerProxy::ignore()
{
- receivedPolicyDecision(WebCore::PolicyAction::Ignore, std::nullopt);
+ receivedPolicyDecision(WebCore::PolicyAction::Ignore, std::nullopt, ShouldProcessSwapIfPossible::No);
}
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.h (234153 => 234154)
--- trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.h 2018-07-24 17:25:25 UTC (rev 234153)
+++ trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.h 2018-07-24 17:27:15 UTC (rev 234154)
@@ -51,6 +51,8 @@
Response,
};
+enum class ShouldProcessSwapIfPossible { No, Yes };
+
class WebFramePolicyListenerProxy : public API::ObjectImpl<API::Object::Type::FramePolicyListener> {
public:
@@ -59,7 +61,7 @@
return adoptRef(*new WebFramePolicyListenerProxy(frame, listenerID, policyType));
}
- void use(std::optional<WebsitePoliciesData>&&);
+ void use(std::optional<WebsitePoliciesData>&&, ShouldProcessSwapIfPossible = ShouldProcessSwapIfPossible::No);
void download();
void ignore();
@@ -70,21 +72,16 @@
void setNavigation(Ref<API::Navigation>&&);
void changeWebsiteDataStore(WebsiteDataStore&);
- bool isMainFrame() const;
- void setApplyPolicyInNewProcessIfPossible(bool applyPolicyInNewProcessIfPossible) { m_applyPolicyInNewProcessIfPossible = applyPolicyInNewProcessIfPossible; }
- bool applyPolicyInNewProcessIfPossible() const { return m_applyPolicyInNewProcessIfPossible; }
-
private:
WebFramePolicyListenerProxy(WebFrameProxy*, uint64_t listenerID, PolicyListenerType);
- void receivedPolicyDecision(WebCore::PolicyAction, std::optional<WebsitePoliciesData>&&);
+ void receivedPolicyDecision(WebCore::PolicyAction, std::optional<WebsitePoliciesData>&&, ShouldProcessSwapIfPossible);
PolicyListenerType m_policyType;
RefPtr<WebFrameProxy> m_frame;
uint64_t m_listenerID { 0 };
RefPtr<API::Navigation> m_navigation;
- bool m_applyPolicyInNewProcessIfPossible { false };
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp (234153 => 234154)
--- trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp 2018-07-24 17:25:25 UTC (rev 234153)
+++ trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp 2018-07-24 17:27:15 UTC (rev 234154)
@@ -178,7 +178,7 @@
m_title = title;
}
-void WebFrameProxy::receivedPolicyDecision(PolicyAction action, uint64_t listenerID, API::Navigation* navigation, std::optional<WebsitePoliciesData>&& data)
+void WebFrameProxy::receivedPolicyDecision(PolicyAction action, uint64_t listenerID, API::Navigation* navigation, std::optional<WebsitePoliciesData>&& data, ShouldProcessSwapIfPossible swap)
{
if (!m_page)
return;
@@ -185,7 +185,7 @@
ASSERT(m_activeListener);
ASSERT(m_activeListener->listenerID() == listenerID);
- m_page->receivedPolicyDecision(action, *this, listenerID, navigation, WTFMove(data));
+ m_page->receivedPolicyDecision(action, *this, listenerID, navigation, WTFMove(data), swap);
}
WebFramePolicyListenerProxy& WebFrameProxy::setUpPolicyListenerProxy(uint64_t listenerID, PolicyListenerType policyListenerType)
Modified: trunk/Source/WebKit/UIProcess/WebFrameProxy.h (234153 => 234154)
--- trunk/Source/WebKit/UIProcess/WebFrameProxy.h 2018-07-24 17:25:25 UTC (rev 234153)
+++ trunk/Source/WebKit/UIProcess/WebFrameProxy.h 2018-07-24 17:27:15 UTC (rev 234154)
@@ -52,6 +52,7 @@
class WebFramePolicyListenerProxy;
class WebPageProxy;
class WebsiteDataStore;
+enum class ShouldProcessSwapIfPossible;
enum class PolicyListenerType;
struct WebsitePoliciesData;
@@ -116,7 +117,7 @@
void didChangeTitle(const String&);
// Policy operations.
- void receivedPolicyDecision(WebCore::PolicyAction, uint64_t listenerID, API::Navigation*, std::optional<WebsitePoliciesData>&&);
+ void receivedPolicyDecision(WebCore::PolicyAction, uint64_t listenerID, API::Navigation*, std::optional<WebsitePoliciesData>&&, ShouldProcessSwapIfPossible);
WebFramePolicyListenerProxy& setUpPolicyListenerProxy(uint64_t listenerID, PolicyListenerType);
WebFramePolicyListenerProxy* activePolicyListenerProxy();
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (234153 => 234154)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-07-24 17:25:25 UTC (rev 234153)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-07-24 17:27:15 UTC (rev 234154)
@@ -2406,7 +2406,7 @@
m_process->send(Messages::WebPage::CenterSelectionInVisibleArea(), m_pageID);
}
-void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy& frame, uint64_t listenerID, API::Navigation* navigation, std::optional<WebsitePoliciesData>&& websitePolicies)
+void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy& frame, uint64_t listenerID, API::Navigation* navigation, std::optional<WebsitePoliciesData>&& websitePolicies, ShouldProcessSwapIfPossible shouldProcessSwapIfPossible)
{
if (!isValid())
return;
@@ -2438,7 +2438,7 @@
ASSERT(activePolicyListener->listenerID() == listenerID);
if (action == PolicyAction::Use && navigation && frame.isMainFrame()) {
- auto proposedProcess = process().processPool().processForNavigation(*this, *navigation, activePolicyListener->applyPolicyInNewProcessIfPossible(), action);
+ auto proposedProcess = process().processPool().processForNavigation(*this, *navigation, shouldProcessSwapIfPossible, action);
if (proposedProcess.ptr() != &process()) {
LOG(ProcessSwapping, "(ProcessSwapping) Switching from process %i to new process (%i) for navigation %" PRIu64 " '%s'", processIdentifier(), proposedProcess->processIdentifier(), navigation->navigationID(), navigation->loggingString());
@@ -4028,7 +4028,7 @@
#if ENABLE(CONTENT_FILTERING)
if (frame->didHandleContentFilterUnblockNavigation(request))
- return receivedPolicyDecision(PolicyAction::Ignore, *frame, listenerID, &m_navigationState->navigation(newNavigationID), { });
+ return receivedPolicyDecision(PolicyAction::Ignore, *frame, listenerID, &m_navigationState->navigation(newNavigationID), std::nullopt, ShouldProcessSwapIfPossible::No);
#else
UNUSED_PARAM(newNavigationID);
#endif
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (234153 => 234154)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-07-24 17:25:25 UTC (rev 234153)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-07-24 17:27:15 UTC (rev 234154)
@@ -259,6 +259,8 @@
struct WebPopupItem;
struct URLSchemeTaskParameters;
+enum class ShouldProcessSwapIfPossible;
+
#if USE(QUICK_LOOK)
class QuickLookDocumentData;
#endif
@@ -906,7 +908,7 @@
void performDictionaryLookupOfCurrentSelection();
#endif
- void receivedPolicyDecision(WebCore::PolicyAction, WebFrameProxy&, uint64_t listenerID, API::Navigation* navigationID, std::optional<WebsitePoliciesData>&&);
+ void receivedPolicyDecision(WebCore::PolicyAction, WebFrameProxy&, uint64_t listenerID, API::Navigation*, std::optional<WebsitePoliciesData>&&, ShouldProcessSwapIfPossible);
void backForwardRemovedItem(const WebCore::BackForwardItemIdentifier&);
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (234153 => 234154)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-07-24 17:25:25 UTC (rev 234153)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-07-24 17:27:15 UTC (rev 234154)
@@ -2107,7 +2107,7 @@
m_swappedProcesses.remove(origin);
}
-Ref<WebProcessProxy> WebProcessPool::processForNavigation(WebPageProxy& page, const API::Navigation& navigation, bool shouldProcessSwapIfPossible, PolicyAction& action)
+Ref<WebProcessProxy> WebProcessPool::processForNavigation(WebPageProxy& page, const API::Navigation& navigation, ShouldProcessSwapIfPossible shouldProcessSwapIfPossible, PolicyAction& action)
{
auto process = processForNavigationInternal(page, navigation, shouldProcessSwapIfPossible, action);
@@ -2125,9 +2125,9 @@
return process;
}
-Ref<WebProcessProxy> WebProcessPool::processForNavigationInternal(WebPageProxy& page, const API::Navigation& navigation, bool shouldProcessSwapIfPossible, PolicyAction& action)
+Ref<WebProcessProxy> WebProcessPool::processForNavigationInternal(WebPageProxy& page, const API::Navigation& navigation, ShouldProcessSwapIfPossible shouldProcessSwapIfPossible, PolicyAction& action)
{
- if (!m_configuration->processSwapsOnNavigation() && !shouldProcessSwapIfPossible)
+ if (!m_configuration->processSwapsOnNavigation() && shouldProcessSwapIfPossible == ShouldProcessSwapIfPossible::No)
return page.process();
if (page.inspectorFrontendCount() > 0)
@@ -2171,7 +2171,7 @@
}
auto targetURL = navigation.currentRequest().url();
- if (!shouldProcessSwapIfPossible) {
+ if (shouldProcessSwapIfPossible == ShouldProcessSwapIfPossible::No) {
if (navigation.treatAsSameOriginNavigation())
return page.process();
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (234153 => 234154)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.h 2018-07-24 17:25:25 UTC (rev 234153)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h 2018-07-24 17:27:15 UTC (rev 234154)
@@ -110,6 +110,8 @@
int webProcessThroughputQOS();
#endif
+enum class ShouldProcessSwapIfPossible;
+
class WebProcessPool final : public API::ObjectImpl<API::Object::Type::ProcessPool>, public CanMakeWeakPtr<WebProcessPool>, private IPC::MessageReceiver {
public:
static Ref<WebProcessPool> create(API::ProcessPoolConfiguration&);
@@ -452,7 +454,7 @@
BackgroundWebProcessToken backgroundWebProcessToken() const { return BackgroundWebProcessToken(m_backgroundWebProcessCounter.count()); }
#endif
- Ref<WebProcessProxy> processForNavigation(WebPageProxy&, const API::Navigation&, bool shouldProcessSwapIfPossible, WebCore::PolicyAction&);
+ Ref<WebProcessProxy> processForNavigation(WebPageProxy&, const API::Navigation&, ShouldProcessSwapIfPossible, WebCore::PolicyAction&);
void registerSuspendedPageProxy(SuspendedPageProxy&);
void unregisterSuspendedPageProxy(SuspendedPageProxy&);
void didReachGoodTimeToPrewarm();
@@ -470,7 +472,7 @@
void platformInitializeWebProcess(WebProcessCreationParameters&);
void platformInvalidateContext();
- Ref<WebProcessProxy> processForNavigationInternal(WebPageProxy&, const API::Navigation&, bool shouldProcessSwapIfPossible, WebCore::PolicyAction&);
+ Ref<WebProcessProxy> processForNavigationInternal(WebPageProxy&, const API::Navigation&, ShouldProcessSwapIfPossible, WebCore::PolicyAction&);
RefPtr<WebProcessProxy> tryTakePrewarmedProcess(WebsiteDataStore&);