summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorscheib@chromium.org <scheib@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 07:33:11 +0000
committerscheib@chromium.org <scheib@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 07:33:11 +0000
commit217690df70c213c482039242dd935786c37dcd3c (patch)
tree8d0a579099bf69e51866cffb682c28ba44330b4f /webkit
parent15f08dde26dbb02c8e4441492ab967cb48fcd4e4 (diff)
downloadchromium_src-217690df70c213c482039242dd935786c37dcd3c.zip
chromium_src-217690df70c213c482039242dd935786c37dcd3c.tar.gz
chromium_src-217690df70c213c482039242dd935786c37dcd3c.tar.bz2
Mouse Lock is currently supported in Pepper, but not yet supported from WebKit.
Move the render thread logic for managing the mouse lock state out of the pepper_plugin_delegate_impl, and into a higher level dispatcher for render_view_impl. Handle mouse lock / pointer lock requests from both pepper and webkit (WebKit API not yet landed, small TODOs left in this code to enable once that lands). BUG=109957 TEST=Pepper examples/mouse_lock and NaCl mouse lock examples still work. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=119206 Review URL: http://codereview.chromium.org/8970016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119406 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.cc8
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.h3
-rw-r--r--webkit/plugins/ppapi/plugin_delegate.h13
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc30
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h7
5 files changed, 43 insertions, 18 deletions
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc
index da371c54..780bf4c 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.cc
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc
@@ -348,13 +348,17 @@ base::SharedMemory* MockPluginDelegate::CreateAnonymousSharedMemory(
return ::ppapi::Preferences();
}
-void MockPluginDelegate::LockMouse(PluginInstance* instance) {
- instance->OnLockMouseACK(PP_ERROR_FAILED);
+bool MockPluginDelegate::LockMouse(PluginInstance* instance) {
+ return false;
}
void MockPluginDelegate::UnlockMouse(PluginInstance* instance) {
}
+bool MockPluginDelegate::IsMouseLocked(PluginInstance* instance) {
+ return false;
+}
+
void MockPluginDelegate::DidChangeCursor(PluginInstance* instance,
const WebKit::WebCursorInfo& cursor) {
}
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h
index fbd961a..4768080 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.h
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.h
@@ -148,8 +148,9 @@ class MockPluginDelegate : public PluginDelegate {
virtual std::string GetFlashCommandLineArgs();
virtual base::SharedMemory* CreateAnonymousSharedMemory(uint32_t size);
virtual ::ppapi::Preferences GetPreferences();
- virtual void LockMouse(PluginInstance* instance);
+ virtual bool LockMouse(PluginInstance* instance);
virtual void UnlockMouse(PluginInstance* instance);
+ virtual bool IsMouseLocked(PluginInstance* instance);
virtual void DidChangeCursor(PluginInstance* instance,
const WebKit::WebCursorInfo& cursor);
virtual void DidReceiveMouseEvent(PluginInstance* instance);
diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h
index 6f9a17e..d91621c 100644
--- a/webkit/plugins/ppapi/plugin_delegate.h
+++ b/webkit/plugins/ppapi/plugin_delegate.h
@@ -490,11 +490,11 @@ class PluginDelegate {
// Returns the current preferences.
virtual ::ppapi::Preferences GetPreferences() = 0;
- // Locks the mouse for |instance|. It will call
- // PluginInstance::OnLockMouseACK() to notify the instance when the operation
- // is completed. The call to OnLockMouseACK() may be synchronous (i.e., it may
- // be called when LockMouse() is still on the stack).
- virtual void LockMouse(PluginInstance* instance) = 0;
+ // Locks the mouse for |instance|. If false is returned, the lock is not
+ // possible. If true is returned then the lock is pending. Success or
+ // failure will be delivered asynchronously via
+ // PluginInstance::OnLockMouseACK().
+ virtual bool LockMouse(PluginInstance* instance) = 0;
// Unlocks the mouse if |instance| currently owns the mouse lock. Whenever an
// plugin instance has lost the mouse lock, it will be notified by
@@ -504,6 +504,9 @@ class PluginDelegate {
// call to the current mouse lock owner.
virtual void UnlockMouse(PluginInstance* instance) = 0;
+ // Returns true iff |instance| currently owns the mouse lock.
+ virtual bool IsMouseLocked(PluginInstance* instance) = 0;
+
// Notifies that |instance| has changed the cursor.
// This will update the cursor appearance if it is currently over the plugin
// instance.
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 7f849f6..23a1862 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -1675,13 +1675,13 @@ bool PluginInstance::IsFullPagePlugin() const {
return frame->view()->mainFrame()->document().isPluginDocument();
}
-void PluginInstance::OnLockMouseACK(int32_t result) {
+void PluginInstance::OnLockMouseACK(bool succeeded) {
if (!lock_mouse_callback_.func) {
NOTREACHED();
return;
}
-
- PP_RunAndClearCompletionCallback(&lock_mouse_callback_, result);
+ PP_RunAndClearCompletionCallback(&lock_mouse_callback_,
+ succeeded ? PP_OK : PP_ERROR_FAILED);
}
void PluginInstance::OnMouseLockLost() {
@@ -1689,6 +1689,13 @@ void PluginInstance::OnMouseLockLost() {
plugin_mouse_lock_interface_->MouseLockLost(pp_instance());
}
+void PluginInstance::HandleMouseLockedInputEvent(
+ const WebKit::WebMouseEvent& event) {
+ // |cursor_info| is ignored since it is hidden when the mouse is locked.
+ WebKit::WebCursorInfo cursor_info;
+ HandleInputEvent(event, &cursor_info);
+}
+
void PluginInstance::SimulateInputEvent(const InputEventData& input_event) {
WebView* web_view = container()->element().document().frame()->view();
if (!web_view) {
@@ -1974,16 +1981,21 @@ int32_t PluginInstance::LockMouse(PP_Instance instance,
// Don't support synchronous call.
return PP_ERROR_BLOCKS_MAIN_THREAD;
}
- if (lock_mouse_callback_.func)
+ if (lock_mouse_callback_.func) // A lock is pending.
return PP_ERROR_INPROGRESS;
+
+ if (delegate()->IsMouseLocked(this))
+ return PP_OK;
+
if (!CanAccessMainFrame())
return PP_ERROR_NOACCESS;
- lock_mouse_callback_ = callback;
- // We will be notified on completion via OnLockMouseACK(), either
- // synchronously or asynchronously.
- delegate()->LockMouse(this);
- return PP_OK_COMPLETIONPENDING;
+ if (delegate()->LockMouse(this)) {
+ lock_mouse_callback_ = callback;
+ return PP_OK_COMPLETIONPENDING;
+ } else {
+ return PP_ERROR_FAILED;
+ }
}
void PluginInstance::UnlockMouse(PP_Instance instance) {
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index 086125f..c8a6332 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -52,6 +52,7 @@ class TransportDIB;
namespace WebKit {
class WebInputEvent;
+class WebMouseEvent;
class WebPluginContainer;
struct WebCompositionUnderline;
struct WebCursorInfo;
@@ -305,8 +306,12 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
// or embedded in a page).
bool IsFullPagePlugin() const;
- void OnLockMouseACK(int32_t result);
+ // A mouse lock request was pending and this reports success or failure.
+ void OnLockMouseACK(bool succeeded);
+ // A mouse lock was in place, but has been lost.
void OnMouseLockLost();
+ // A mouse lock is enabled and mouse events are being delievered.
+ void HandleMouseLockedInputEvent(const WebKit::WebMouseEvent& event);
// Simulates an input event to the plugin by passing it down to WebKit,
// which sends it back up to the plugin as if it came from the user.