summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-22 03:36:37 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-22 03:36:37 +0000
commit67bfb83fbdd401bba2cfdbe330edebf2b3105a6f (patch)
treea7ed2dc89b3161efdb13cf5b163aa1a61d2e07b6 /webkit/plugins/ppapi
parent88de6c013ddad04c6896f10714c787ce21cf858a (diff)
downloadchromium_src-67bfb83fbdd401bba2cfdbe330edebf2b3105a6f.zip
chromium_src-67bfb83fbdd401bba2cfdbe330edebf2b3105a6f.tar.gz
chromium_src-67bfb83fbdd401bba2cfdbe330edebf2b3105a6f.tar.bz2
Mouse lock implementation, including the renderer side and the Windows version of the browser side.
BUG=41781 TEST=Manual test in ppapi/examples/mouse_lock Review URL: http://codereview.chromium.org/7863003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi')
-rw-r--r--webkit/plugins/ppapi/event_conversion.cc13
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.cc8
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.h2
-rw-r--r--webkit/plugins/ppapi/plugin_delegate.h14
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc13
5 files changed, 32 insertions, 18 deletions
diff --git a/webkit/plugins/ppapi/event_conversion.cc b/webkit/plugins/ppapi/event_conversion.cc
index d9ac4c6..80df1f6 100644
--- a/webkit/plugins/ppapi/event_conversion.cc
+++ b/webkit/plugins/ppapi/event_conversion.cc
@@ -135,10 +135,8 @@ void AppendMouseEvent(const WebInputEvent& event,
result.mouse_position.x = mouse_event.x;
result.mouse_position.y = mouse_event.y;
result.mouse_click_count = mouse_event.clickCount;
-
- // TODO(yzshen): Make the change after WebMouseEvent adds movementX/Y.
- result.mouse_movement.x = 0; // mouse_event.movementX
- result.mouse_movement.y = 0; // mouse_event.movementY
+ result.mouse_movement.x = mouse_event.movementX;
+ result.mouse_movement.y = mouse_event.movementY;
result_events->push_back(result);
}
@@ -229,11 +227,8 @@ WebMouseEvent* BuildMouseEvent(const InputEventData& event) {
mouse_event->x = event.mouse_position.x;
mouse_event->y = event.mouse_position.y;
mouse_event->clickCount = event.mouse_click_count;
-
- // TODO(yzshen): Uncomment the following lines after WebMouseEvent adds
- // movementX/Y.
- // mouse_event->movementX = event.mouse_position.x;
- // mouse_event->movementY = event.mouse_position.y;
+ mouse_event->movementX = event.mouse_movement.x;
+ mouse_event->movementY = event.mouse_movement.y;
return mouse_event;
}
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc
index c34643a..010814a 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.cc
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc
@@ -7,6 +7,7 @@
#include "base/message_loop_proxy.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/shared_impl/ppapi_preferences.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
namespace webkit {
namespace ppapi {
@@ -284,5 +285,12 @@ base::SharedMemory* MockPluginDelegate::CreateAnonymousSharedMemory(
return ::ppapi::Preferences();
}
+void MockPluginDelegate::LockMouse(PluginInstance* instance) {
+ instance->OnLockMouseACK(PP_ERROR_FAILED);
+}
+
+void MockPluginDelegate::UnlockMouse(PluginInstance* instance) {
+}
+
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h
index 04382e0..82d3cff 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.h
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.h
@@ -118,6 +118,8 @@ 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 void UnlockMouse(PluginInstance* instance);
};
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h
index f63276e..193777e 100644
--- a/webkit/plugins/ppapi/plugin_delegate.h
+++ b/webkit/plugins/ppapi/plugin_delegate.h
@@ -446,6 +446,20 @@ 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;
+
+ // Unlocks the mouse if |instance| currently owns the mouse lock. Whenever an
+ // plugin instance has lost the mouse lock, it will be notified by
+ // PluginInstance::OnMouseLockLost(). Please note that UnlockMouse() is not
+ // the only cause of losing mouse lock. For example, a user may press the Esc
+ // key to quit the mouse lock mode, which also results in an OnMouseLockLost()
+ // call to the current mouse lock owner.
+ virtual void UnlockMouse(PluginInstance* instance) = 0;
};
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 13934ef..a31f43e 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -1584,20 +1584,15 @@ int32_t PluginInstance::LockMouse(PP_Instance instance,
if (lock_mouse_callback_.func)
return PP_ERROR_INPROGRESS;
- // TODO(yzshen): Uncomment the following lines after adding implementation in
- // the delegate.
- // lock_mouse_callback_ = callback;
+ lock_mouse_callback_ = callback;
// We will be notified on completion via OnLockMouseACK(), either
// synchronously or asynchronously.
- // delegate()->LockMouse(this);
- // return PP_OK_COMPLETIONPENDING;
- return PP_ERROR_FAILED;
+ delegate()->LockMouse(this);
+ return PP_OK_COMPLETIONPENDING;
}
void PluginInstance::UnlockMouse(PP_Instance instance) {
- // TODO(yzshen): Uncomment the following after adding implementation in the
- // delegate.
- // delegate()->UnlockMouse(this);
+ delegate()->UnlockMouse(this);
}
void PluginInstance::SubscribeToPolicyUpdates(PP_Instance instance) {