Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(696)

Unified Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 8970016: refactoring mouse lock to support pepper and WebKit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index f116d6c47af38c8334094379a1a206f86315d8c9..a107380a64339dc5a15448f3efe32cb2ddfd66ac 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -304,6 +304,7 @@ PluginInstance::PluginInstance(
text_input_caret_(0, 0, 0, 0),
text_input_caret_bounds_(0, 0, 0, 0),
text_input_caret_set_(false),
+ mouse_locked_to_this_instance_(false),
lock_mouse_callback_(PP_BlockUntilComplete()) {
pp_instance_ = HostGlobals::Get()->AddInstance(this);
@@ -328,8 +329,10 @@ PluginInstance::~PluginInstance() {
i != plugin_object_copy.end(); ++i)
delete *i;
- if (lock_mouse_callback_.func)
+ if (lock_mouse_callback_.func) {
+ mouse_locked_to_this_instance_ = false;
PP_RunAndClearCompletionCallback(&lock_mouse_callback_, PP_ERROR_ABORTED);
+ }
delegate_->InstanceDeleted(this);
module_->InstanceDeleted(this);
@@ -1570,18 +1573,30 @@ bool PluginInstance::IsFullPagePlugin() const {
return frame->view()->mainFrame()->document().isPluginDocument();
}
-void PluginInstance::OnLockMouseACK(int32_t result) {
+void PluginInstance::OnLockMouseACK2(bool succeeded) {
+ fprintf(stderr, "PluginInstance::OnLockMouseACK2(%d)\n", succeeded);
if (!lock_mouse_callback_.func) {
NOTREACHED();
+ fprintf(stderr, "PluginInstance::OnLockMouseACK2 !!!!!\n");
return;
}
-
- PP_RunAndClearCompletionCallback(&lock_mouse_callback_, result);
+ mouse_locked_to_this_instance_ = succeeded;
+ PP_RunAndClearCompletionCallback(&lock_mouse_callback_,
+ succeeded ? PP_OK : PP_ERROR_FAILED);
}
-void PluginInstance::OnMouseLockLost() {
+void PluginInstance::OnMouseLockLost2() {
+ fprintf(stderr, "PluginInstance::OnMouseLockLost2()\n");
if (LoadMouseLockInterface())
plugin_mouse_lock_interface_->MouseLockLost(pp_instance());
+ mouse_locked_to_this_instance_ = false;
+}
+
+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) {
@@ -1865,23 +1880,37 @@ void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) {
int32_t PluginInstance::LockMouse(PP_Instance instance,
PP_CompletionCallback callback) {
+ fprintf(stderr, "PluginInstance::LockMouse: ");
if (!callback.func) {
// 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
+ {
+ fprintf(stderr, "lock_mouse_callback_.func PP_ERROR_INPROGRESS\n");
return PP_ERROR_INPROGRESS;
+ }
+ if (mouse_locked_to_this_instance_)
+ {
+ fprintf(stderr, "mouse_locked_to_this_instance_ PP_OK\n");
+ 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)) {
yzshen1 2012/01/04 00:50:00 It seems better to *not* have |mouse_locked_to_thi
+ fprintf(stderr, "delegate()->LockMouse(this) == true\n");
+ lock_mouse_callback_ = callback;
+ return PP_OK_COMPLETIONPENDING;
+ } else
+ {
+ fprintf(stderr, "delegate()->LockMouse(this) == false PP_ERROR_FAILED\n");
+ return PP_ERROR_FAILED;
+ }
}
void PluginInstance::UnlockMouse(PP_Instance instance) {
+ fprintf(stderr, "PluginInstance::UnlockMouse\n");
delegate()->UnlockMouse(this);
}
« webkit/plugins/ppapi/plugin_delegate.h ('K') | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698