Commit 831f35b6 authored by weinig@apple.com's avatar weinig@apple.com

Add modifier key info to policy client functions in WebKit2

<rdar://problem/8185298>
https://bugs.webkit.org/show_bug.cgi?id=44280

Reviewed by Adam Roben.

* UIProcess/API/C/WKAPICast.h:
Add conversion function for modifiers and rename an incorrectly named
toWK to toRef.

* UIProcess/API/C/WKPage.h:
Add WKEventModifiers enum.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didReceiveMessage):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
(WebKit::WebPageProxy::decidePolicyForNewWindowAction):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPolicyClient.cpp:
(WebKit::WebPolicyClient::decidePolicyForNavigationAction):
(WebKit::WebPolicyClient::decidePolicyForNewWindowAction):
* UIProcess/WebPolicyClient.h:
Pipe through modifier info.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::modifiersForNavigationAction):
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
Get modifier info out of the NavigationInfo class in the same manner as
WebKit1.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65699 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 27c09964
2010-08-19 Sam Weinig <sam@webkit.org>
Reviewed by Adam Roben.
Add modifier key info to policy client functions in WebKit2
<rdar://problem/8185298>
https://bugs.webkit.org/show_bug.cgi?id=44280
* UIProcess/API/C/WKAPICast.h:
Add conversion function for modifiers and rename an incorrectly named
toWK to toRef.
* UIProcess/API/C/WKPage.h:
Add WKEventModifiers enum.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didReceiveMessage):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
(WebKit::WebPageProxy::decidePolicyForNewWindowAction):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPolicyClient.cpp:
(WebKit::WebPolicyClient::decidePolicyForNavigationAction):
(WebKit::WebPolicyClient::decidePolicyForNewWindowAction):
* UIProcess/WebPolicyClient.h:
Pipe through modifier info.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::modifiersForNavigationAction):
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
Get modifier info out of the NavigationInfo class in the same manner as
WebKit1.
2010-08-18 Sam Weinig <sam@webkit.org>
Reviewed by Adam Roben.
......
......@@ -28,6 +28,7 @@
#include "WKBase.h"
#include "WKPage.h"
#include "WebEvent.h"
#include "WebString.h"
#include "WebURL.h"
#include <WebCore/FrameLoaderTypes.h>
......@@ -151,12 +152,14 @@ inline WKURLRef toCopiedURLRef(const WTF::String& string)
return toRef(webURL.release().releaseRef());
}
/* Enum conversions */
inline WKTypeID toRef(WebKit::APIObject::Type type)
{
return static_cast<WKTypeID>(type);
}
inline WKFrameNavigationType toWK(WebCore::NavigationType type)
inline WKFrameNavigationType toRef(WebCore::NavigationType type)
{
WKFrameNavigationType wkType = kWKFrameNavigationTypeOther;
......@@ -184,4 +187,18 @@ inline WKFrameNavigationType toWK(WebCore::NavigationType type)
return wkType;
}
inline WKEventModifiers toRef(WebKit::WebEvent::Modifiers modifiers)
{
WKEventModifiers wkModifiers = 0;
if (modifiers & WebKit::WebEvent::ShiftKey)
wkModifiers |= kWKEventModifiersShiftKey;
if (modifiers & WebKit::WebEvent::ControlKey)
wkModifiers |= kWKEventModifiersControlKey;
if (modifiers & WebKit::WebEvent::AltKey)
wkModifiers |= kWKEventModifiersAltKey;
if (modifiers & WebKit::WebEvent::MetaKey)
wkModifiers |= kWKEventModifiersMetaKey;
return wkModifiers;
}
#endif // WKAPICast_h
......@@ -48,6 +48,14 @@ enum {
};
typedef uint32_t WKFrameNavigationType;
enum {
kWKEventModifiersShiftKey = 1 << 0,
kWKEventModifiersControlKey = 1 << 1,
kWKEventModifiersAltKey = 1 << 2,
kWKEventModifiersMetaKey = 1 << 3
};
typedef uint32_t WKEventModifiers;
// FrameLoad Client
typedef void (*WKPageDidStartProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, const void *clientInfo);
typedef void (*WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, const void *clientInfo);
......@@ -100,8 +108,8 @@ struct WKPageLoaderClient {
typedef struct WKPageLoaderClient WKPageLoaderClient;
// Policy Client.
typedef void (*WKPageDecidePolicyForNavigationActionCallback)(WKPageRef page, WKFrameNavigationType navigationType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo);
typedef void (*WKPageDecidePolicyForNewWindowActionCallback)(WKPageRef page, WKFrameNavigationType navigationType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo);
typedef void (*WKPageDecidePolicyForNavigationActionCallback)(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo);
typedef void (*WKPageDecidePolicyForNewWindowActionCallback)(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo);
typedef void (*WKPageDecidePolicyForMIMETypeCallback)(WKPageRef page, WKStringRef MIMEType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo);
struct WKPagePolicyClient {
......
......@@ -521,21 +521,23 @@ void WebPageProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::M
case WebPageProxyMessage::DecidePolicyForNavigationAction: {
uint64_t frameID;
uint32_t navigationType;
uint32_t modifiers;
String url;
uint64_t listenerID;
if (!arguments->decode(CoreIPC::Out(frameID, navigationType, url, listenerID)))
if (!arguments->decode(CoreIPC::Out(frameID, navigationType, modifiers, url, listenerID)))
return;
decidePolicyForNavigationAction(webFrame(frameID), static_cast<NavigationType>(navigationType), url, listenerID);
decidePolicyForNavigationAction(webFrame(frameID), static_cast<NavigationType>(navigationType), static_cast<WebEvent::Modifiers>(modifiers), url, listenerID);
break;
}
case WebPageProxyMessage::DecidePolicyForNewWindowAction: {
uint64_t frameID;
uint32_t navigationType;
uint32_t modifiers;
String url;
uint64_t listenerID;
if (!arguments->decode(CoreIPC::Out(frameID, navigationType, url, listenerID)))
if (!arguments->decode(CoreIPC::Out(frameID, navigationType, modifiers, url, listenerID)))
return;
decidePolicyForNewWindowAction(webFrame(frameID), static_cast<NavigationType>(navigationType), url, listenerID);
decidePolicyForNewWindowAction(webFrame(frameID), static_cast<NavigationType>(navigationType), static_cast<WebEvent::Modifiers>(modifiers), url, listenerID);
break;
}
case WebPageProxyMessage::DecidePolicyForMIMEType: {
......@@ -830,17 +832,17 @@ void WebPageProxy::didFirstVisuallyNonEmptyLayoutForFrame(WebFrameProxy* frame)
// PolicyClient
void WebPageProxy::decidePolicyForNavigationAction(WebFrameProxy* frame, NavigationType navigationType, const String& url, uint64_t listenerID)
void WebPageProxy::decidePolicyForNavigationAction(WebFrameProxy* frame, NavigationType navigationType, WebEvent::Modifiers modifiers, const String& url, uint64_t listenerID)
{
RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
if (!m_policyClient.decidePolicyForNavigationAction(this, navigationType, url, frame, listener.get()))
if (!m_policyClient.decidePolicyForNavigationAction(this, navigationType, modifiers, url, frame, listener.get()))
listener->use();
}
void WebPageProxy::decidePolicyForNewWindowAction(WebFrameProxy* frame, NavigationType navigationType, const String& url, uint64_t listenerID)
void WebPageProxy::decidePolicyForNewWindowAction(WebFrameProxy* frame, NavigationType navigationType, WebEvent::Modifiers modifiers, const String& url, uint64_t listenerID)
{
RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
if (!m_policyClient.decidePolicyForNewWindowAction(this, navigationType, url, frame, listener.get()))
if (!m_policyClient.decidePolicyForNewWindowAction(this, navigationType, modifiers, url, frame, listener.get()))
listener->use();
}
......
......@@ -190,8 +190,8 @@ private:
void didChangeProgress(double);
void didFinishProgress();
void decidePolicyForNavigationAction(WebFrameProxy*, WebCore::NavigationType navigationType, const WTF::String& url, uint64_t listenerID);
void decidePolicyForNewWindowAction(WebFrameProxy*, WebCore::NavigationType navigationType, const WTF::String& url, uint64_t listenerID);
void decidePolicyForNavigationAction(WebFrameProxy*, WebCore::NavigationType navigationType, WebEvent::Modifiers modifiers, const WTF::String& url, uint64_t listenerID);
void decidePolicyForNewWindowAction(WebFrameProxy*, WebCore::NavigationType navigationType, WebEvent::Modifiers modifiers, const WTF::String& url, uint64_t listenerID);
void decidePolicyForMIMEType(WebFrameProxy*, const WTF::String& MIMEType, const WTF::String& url, uint64_t listenerID);
void willSubmitForm(WebFrameProxy* frame, WebFrameProxy* frameSource, Vector<std::pair<WTF::String, WTF::String> >& textFieldValues, uint64_t listenerID);
......
......@@ -45,21 +45,21 @@ void WebPolicyClient::initialize(const WKPagePolicyClient* client)
memset(&m_pagePolicyClient, 0, sizeof(m_pagePolicyClient));
}
bool WebPolicyClient::decidePolicyForNavigationAction(WebPageProxy* page, NavigationType type, const String& url, WebFrameProxy* frame, WebFramePolicyListenerProxy* listener)
bool WebPolicyClient::decidePolicyForNavigationAction(WebPageProxy* page, NavigationType type, WebEvent::Modifiers modifiers, const String& url, WebFrameProxy* frame, WebFramePolicyListenerProxy* listener)
{
if (!m_pagePolicyClient.decidePolicyForNavigationAction)
return false;
m_pagePolicyClient.decidePolicyForNavigationAction(toRef(page), toWK(type), toURLRef(url.impl()), toRef(frame), toRef(listener), m_pagePolicyClient.clientInfo);
m_pagePolicyClient.decidePolicyForNavigationAction(toRef(page), toRef(type), toRef(modifiers), toURLRef(url.impl()), toRef(frame), toRef(listener), m_pagePolicyClient.clientInfo);
return true;
}
bool WebPolicyClient::decidePolicyForNewWindowAction(WebPageProxy* page, NavigationType type, const String& url, WebFrameProxy* frame, WebFramePolicyListenerProxy* listener)
bool WebPolicyClient::decidePolicyForNewWindowAction(WebPageProxy* page, NavigationType type, WebEvent::Modifiers modifiers, const String& url, WebFrameProxy* frame, WebFramePolicyListenerProxy* listener)
{
if (!m_pagePolicyClient.decidePolicyForNewWindowAction)
return false;
m_pagePolicyClient.decidePolicyForNewWindowAction(toRef(page), toWK(type), toURLRef(url.impl()), toRef(frame), toRef(listener), m_pagePolicyClient.clientInfo);
m_pagePolicyClient.decidePolicyForNewWindowAction(toRef(page), toRef(type), toRef(modifiers), toURLRef(url.impl()), toRef(frame), toRef(listener), m_pagePolicyClient.clientInfo);
return true;
}
......
......@@ -27,6 +27,7 @@
#define WebPolicyClient_h
#include "WKPage.h"
#include "WebEvent.h"
#include <WebCore/FrameLoaderTypes.h>
#include <wtf/Forward.h>
......@@ -41,8 +42,8 @@ public:
WebPolicyClient();
void initialize(const WKPagePolicyClient*);
bool decidePolicyForNavigationAction(WebPageProxy*, WebCore::NavigationType, const WTF::String& url, WebFrameProxy*, WebFramePolicyListenerProxy*);
bool decidePolicyForNewWindowAction(WebPageProxy*, WebCore::NavigationType, const WTF::String& url, WebFrameProxy*, WebFramePolicyListenerProxy*);
bool decidePolicyForNavigationAction(WebPageProxy*, WebCore::NavigationType, WebEvent::Modifiers, const WTF::String& url, WebFrameProxy*, WebFramePolicyListenerProxy*);
bool decidePolicyForNewWindowAction(WebPageProxy*, WebCore::NavigationType, WebEvent::Modifiers, const WTF::String& url, WebFrameProxy*, WebFramePolicyListenerProxy*);
bool decidePolicyForMIMEType(WebPageProxy*, const WTF::String&, const WTF::String& url, WebFrameProxy*, WebFramePolicyListenerProxy*);
private:
......
......@@ -32,12 +32,13 @@
#include "PluginView.h"
#include "WebCoreArgumentCoders.h"
#include "WebErrors.h"
#include "WebEvent.h"
#include "WebFrame.h"
#include "WebNavigationDataStore.h"
#include "WebPage.h"
#include "WebPageProxyMessageKinds.h"
#include "WebProcessProxyMessageKinds.h"
#include "WebProcess.h"
#include "WebProcessProxyMessageKinds.h"
#include <JavaScriptCore/APICast.h>
#include <JavaScriptCore/JSObject.h>
#include <WebCore/Chrome.h>
......@@ -53,6 +54,7 @@
#include <WebCore/PluginData.h>
#include <WebCore/ProgressTracker.h>
#include <WebCore/ResourceError.h>
#include <WebCore/UIEventWithKeyState.h>
#include <WebCore/Widget.h>
#include <WebCore/WindowFeatures.h>
......@@ -411,6 +413,23 @@ void WebFrameLoaderClient::dispatchShow()
webPage->show();
}
static uint32_t modifiersForNavigationAction(const NavigationAction& navigationAction)
{
uint32_t modifiers = 0;
if (const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast<Event*>(navigationAction.event()))) {
if (keyStateEvent->shiftKey())
modifiers |= WebEvent::ShiftKey;
if (keyStateEvent->ctrlKey())
modifiers |= WebEvent::ControlKey;
if (keyStateEvent->altKey())
modifiers |= WebEvent::AltKey;
if (keyStateEvent->metaKey())
modifiers |= WebEvent::MetaKey;
}
return modifiers;
}
void WebFrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const String& MIMEType, const ResourceRequest& request)
{
WebPage* webPage = m_frame->page();
......@@ -436,8 +455,10 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFun
// FIXME: Pass the frame name.
const String& url = request.url().string(); // FIXME: Pass entire request.
uint32_t modifiers = modifiersForNavigationAction(navigationAction);
WebProcess::shared().connection()->send(WebPageProxyMessage::DecidePolicyForNewWindowAction, webPage->pageID(),
CoreIPC::In(m_frame->frameID(), (uint32_t)navigationAction.type(), url, listenerID));
CoreIPC::In(m_frame->frameID(), (uint32_t)navigationAction.type(), modifiers, url, listenerID));
}
void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState>)
......@@ -451,8 +472,10 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFu
// FIXME: Pass more than just the navigation action type.
const String& url = request.url().string(); // FIXME: Pass entire request.
uint32_t modifiers = modifiersForNavigationAction(navigationAction);
WebProcess::shared().connection()->send(WebPageProxyMessage::DecidePolicyForNavigationAction, webPage->pageID(),
CoreIPC::In(m_frame->frameID(), (uint32_t)navigationAction.type(), url, listenerID));
CoreIPC::In(m_frame->frameID(), (uint32_t)navigationAction.type(), modifiers, url, listenerID));
}
void WebFrameLoaderClient::cancelPolicyCheck()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment