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
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=119406
I apologize for late reply. The change mostly looks good. http://codereview.chromium.org/8970016/diff/1/content/renderer/render_view_impl.cc File content/renderer/render_view_impl.cc (right): http://codereview.chromium.org/8970016/diff/1/content/renderer/render_view_impl.cc#newcode4847 ...
8 years, 11 months ago
(2012-01-04 00:50:00 UTC)
#1
Thanks for previous review, I've addressed concerns and this should be in a state for ...
8 years, 11 months ago
(2012-01-12 19:36:47 UTC)
#2
Thanks for previous review, I've addressed concerns and this should be in a
state for final review. (however, landing this is predicated on landing WebKit:
https://bugs.webkit.org/show_bug.cgi?id=75762)
yzshen1
The first part of comments. Thanks! http://codereview.chromium.org/8970016/diff/13001/content/renderer/render_view_impl.cc File content/renderer/render_view_impl.cc (right): http://codereview.chromium.org/8970016/diff/13001/content/renderer/render_view_impl.cc#newcode435 content/renderer/render_view_impl.cc:435: mouse_lock_dispatcher_ = new ...
8 years, 11 months ago
(2012-01-12 19:49:25 UTC)
#3
Added the missing files... sorry. http://codereview.chromium.org/8970016/diff/13001/content/renderer/render_view_impl.cc File content/renderer/render_view_impl.cc (right): http://codereview.chromium.org/8970016/diff/13001/content/renderer/render_view_impl.cc#newcode435 content/renderer/render_view_impl.cc:435: mouse_lock_dispatcher_ = new MouseLockDispatcher(this); ...
8 years, 11 months ago
(2012-01-12 21:25:19 UTC)
#4
Added the missing files... sorry.
http://codereview.chromium.org/8970016/diff/13001/content/renderer/render_vie...
File content/renderer/render_view_impl.cc (right):
http://codereview.chromium.org/8970016/diff/13001/content/renderer/render_vie...
content/renderer/render_view_impl.cc:435: mouse_lock_dispatcher_ = new
MouseLockDispatcher(this);
On 2012/01/12 19:49:25, yzshen1 wrote:
> - This is not 'lazily initialized' as the comment in the .h file says, right?
> - Currently the object is leaked. You probably want to use scoped_ptr.
> - It seems you haven't included the dispatcher implementation in the CL.
Fixed comment; cut paste error.
The object is a RenderViewObserver, which will self delete when the RenderView
is destroyed.
Added missing files.
yzshen1
http://codereview.chromium.org/8970016/diff/15001/content/renderer/mouse_lock_dispatcher.cc File content/renderer/mouse_lock_dispatcher.cc (right): http://codereview.chromium.org/8970016/diff/15001/content/renderer/mouse_lock_dispatcher.cc#newcode1 content/renderer/mouse_lock_dispatcher.cc:1: // Copyright (c) 2011 The Chromium Authors. All rights ...
8 years, 11 months ago
(2012-01-16 07:50:34 UTC)
#5
Brett, could you OWNERS review? I've removed the WebKit API dependency to allow this to ...
8 years, 11 months ago
(2012-01-17 23:14:48 UTC)
#7
Brett, could you OWNERS review?
I've removed the WebKit API dependency to allow this to land before that lands
and rolls, with a minimal patch to re-couple to it later.
8 years, 11 months ago
(2012-01-18 17:54:58 UTC)
#9
http://codereview.chromium.org/8970016/diff/15001/content/renderer/mouse_lock...
File content/renderer/mouse_lock_dispatcher.h (right):
http://codereview.chromium.org/8970016/diff/15001/content/renderer/mouse_lock...
content/renderer/mouse_lock_dispatcher.h:30: bool LockMouse(WebKit::WebWidget*
webwidget,
On 2012/01/17 23:39:25, yzshen1 wrote:
> On 2012/01/17 22:05:36, scheib wrote:
> > On 2012/01/16 07:50:35, yzshen1 wrote:
> > > It is better to have the same interface for webwidget/pinstance to either
> > > inherit or compose.
> > > So we don't need to handle the two explicitly.
> > >
> > > Is there any difficulty to do that?
> >
> >
> > I started that way, and showed darin. He did not like the idea of defining
> that
> > interface in the WebKit repository and then also using it for pepper.
Because
> > the interface is so minor, and there are only two users of it, we agreed
> > together that a 'raw access' special casing the two was preferable.
>
> Okay, if that has been carefully considered.
>
> Please note that even if you don't define that interface in WebKit, you still
> can use an adapter to wrap the webwidget, and expose an interface that is
shared
> by PluginInstance.
> That seems better to me. But I will let you decide. :)
>
> If you decide to leave it unchanged, please comment somewhere why you do it
this
> way. So that others can understand the decision easily.
We did consider an adapter as well, but that would require adding a pure
interface, an adapter, wrapping in the adapter, vs a few lines where we deal
with two pointers directly. We sided on the direct implementation, pros: clarity
of operation, still encapsulated in the dispatcher, not more lines of code and
files and indirection.
I've added comments describing the decision.
http://codereview.chromium.org/8970016/diff/20009/content/renderer/mouse_lock...
File content/renderer/mouse_lock_dispatcher.cc (right):
http://codereview.chromium.org/8970016/diff/20009/content/renderer/mouse_lock...
content/renderer/mouse_lock_dispatcher.cc:26: webkit::ppapi::PluginInstance*
plugin) {
On 2012/01/17 23:39:25, yzshen1 wrote:
> According to our style guide, it should align with WebKit::WebWidget*
webwidget
Done.
http://codereview.chromium.org/8970016/diff/20009/content/renderer/mouse_lock...
content/renderer/mouse_lock_dispatcher.cc:42: webkit::ppapi::PluginInstance*
plugin) {
On 2012/01/17 23:39:25, yzshen1 wrote:
> Ditto.
Done.
http://codereview.chromium.org/8970016/diff/20009/webkit/plugins/ppapi/ppapi_...
File webkit/plugins/ppapi/ppapi_plugin_instance.h (right):
http://codereview.chromium.org/8970016/diff/20009/webkit/plugins/ppapi/ppapi_...
webkit/plugins/ppapi/ppapi_plugin_instance.h:309: // A mouse lock request was
pending, and the success is being returned.
On 2012/01/17 23:39:25, yzshen1 wrote:
> the success -> the result?
Done.
yzshen1
lgtm
8 years, 11 months ago
(2012-01-18 18:13:29 UTC)
#10
lgtm
scheib
piman, can you do Owner review. (brettw not available)
8 years, 11 months ago
(2012-01-18 18:18:28 UTC)
#11
piman, can you do Owner review. (brettw not available)
piman
The ownership logic is a bit subtle, especially in the context of asynchronous messages. Could ...
8 years, 11 months ago
(2012-01-18 19:00:59 UTC)
#12
I've introduced an interface LockTarget that eases testing and removed the dual pointers from MouseLockDispatcher. ...
8 years, 11 months ago
(2012-01-24 01:51:42 UTC)
#15
I've introduced an interface LockTarget that eases testing and removed the dual
pointers from MouseLockDispatcher.
I've created unit tests around multiple targets and handling the asynchronous
responses.
Other issues also addressed.
http://codereview.chromium.org/8970016/diff/37001/content/renderer/mouse_lock...
File content/renderer/mouse_lock_dispatcher.cc (right):
http://codereview.chromium.org/8970016/diff/37001/content/renderer/mouse_lock...
content/renderer/mouse_lock_dispatcher.cc:27: DCHECK(!(webwidget && plugin)); //
Only one mouse lock target at a time.
On 2012/01/18 19:00:59, piman wrote:
> Is it valid to lock with no owner at all?
Refactoring has removed this issue, there is only one target now.
http://codereview.chromium.org/8970016/diff/37001/content/renderer/mouse_lock...
content/renderer/mouse_lock_dispatcher.cc:42: webkit::ppapi::PluginInstance*
plugin) {
On 2012/01/18 19:00:59, piman wrote:
> This gets called when the plugin instance gets deleted. From my reading of the
> logic, we're still hanging on to the PluginInstance pointer so that we can
send
> a callback when the unlock actually happened. But at that point the pointer
will
> be stale.
Addressed by creating a new method UnlockMouseAndClearPointer(). Also, verified
the old error by upgrading the mouse_lock sample and that the new code works.
http://codereview.chromium.org/8970016/diff/37001/content/renderer/mouse_lock...
content/renderer/mouse_lock_dispatcher.cc:48: plugin ==
mouse_lock_plugin_owner_) {
On 2012/01/18 19:00:59, piman wrote:
> This test should be stricter. E.g. if I do LockMouse(NULL, plugin_instance1);
> UnlockMouse(NULL, plugin_instance2); then mouse_lock_webwidget_owner_==NULL,
and
> webwidget==NULL here, so it will succeed.
Done.
http://codereview.chromium.org/8970016/diff/37001/content/renderer/mouse_lock...
content/renderer/mouse_lock_dispatcher.cc:96:
render_view_impl_->webwidget()->mouseCaptureLost();
On 2012/01/18 19:00:59, piman wrote:
> could this callback re-enter and cause, say, the content to try to release the
> lock? Are we doing the right thing in that case?
Moved to after all state changes to prevent reentrant issues.
http://codereview.chromium.org/8970016/diff/37001/content/renderer/mouse_lock...
content/renderer/mouse_lock_dispatcher.cc:109: if (mouse_lock_webwidget_owner_
|| mouse_lock_plugin_owner_) {
On 2012/01/18 19:00:59, piman wrote:
> (similar question as above) can this be false?
Now with UnlockAndClearPointer it is possible for no owner to be on record when
a response comes in. However, I've removed the if() bracket because the code is
safe to false/null owners regardless.
http://codereview.chromium.org/8970016/diff/37001/content/renderer/mouse_lock...
File content/renderer/mouse_lock_dispatcher.h (right):
http://codereview.chromium.org/8970016/diff/37001/content/renderer/mouse_lock...
content/renderer/mouse_lock_dispatcher.h:36: bool
IsMouseLockedTo(webkit::ppapi::PluginInstance* plugin);
On 2012/01/18 19:00:59, piman wrote:
> On these 2 functions, they seem identical except for the type of owner.
> Shouldn't they have the same name (tagged with a type for the overload)?
> e.g. IsMouseLockedToWebWidget/IsMouseLockedToPluginInstance ?
Refactoring has resulted in only one set of functions, with the two differing
interfaces (pepper, webwidget) encapsulated in LockTarget subclasses.
http://codereview.chromium.org/8970016/diff/37001/content/renderer/mouse_lock...
content/renderer/mouse_lock_dispatcher.h:74: WebKit::WebWidget*
mouse_lock_webwidget_owner_;
On 2012/01/18 19:00:59, piman wrote:
> Looking at the code, it seems that the only possible webwidget owner would be
> render_view_impl_'s webwidget. It seems that we could simplify the logic a
> little bit by always going through the RenderViewImpl to get to the webwidget
> (and that may help with lifetime issues), making this a bool
> "render_view_is_owner_" or something.
Refactoring has removed this issue, there is only one target now.
http://codereview.chromium.org/8970016/diff/37001/content/renderer/render_vie...
File content/renderer/render_view_impl.cc (right):
http://codereview.chromium.org/8970016/diff/37001/content/renderer/render_vie...
content/renderer/render_view_impl.cc:443: mouse_lock_dispatcher_ = new
MouseLockDispatcher(this);
On 2012/01/18 19:00:59, piman wrote:
> Where is this deleted? Should mouse_lock_dispatcher_ be a scoped_ptr?
I agree it's confusing, I've added the existing comment in the header file to
the .cc as well:
// The next group of objects all implement RenderViewObserver, so are deleted
// along with the RenderView automatically. This is why we just store
// weak references.
piman
Very nice test! I think there's a missing delete, the rest is nits. http://codereview.chromium.org/8970016/diff/15002/content/renderer/mouse_lock_dispatcher.cc File ...
8 years, 11 months ago
(2012-01-24 02:27:37 UTC)
#16
http://codereview.chromium.org/8970016/diff/15002/content/renderer/mouse_lock_dispatcher.h File content/renderer/mouse_lock_dispatcher.h (right): http://codereview.chromium.org/8970016/diff/15002/content/renderer/mouse_lock_dispatcher.h#newcode45 content/renderer/mouse_lock_dispatcher.h:45: // Lock the mouse to the |target|. If true ...
8 years, 11 months ago
(2012-01-25 18:10:00 UTC)
#19
http://codereview.chromium.org/8970016/diff/56001/content/renderer/mouse_lock_dispatcher.h File content/renderer/mouse_lock_dispatcher.h (right): http://codereview.chromium.org/8970016/diff/56001/content/renderer/mouse_lock_dispatcher.h#newcode80 content/renderer/mouse_lock_dispatcher.h:80: // owning reference here that must be cleared by ...
8 years, 11 months ago
(2012-01-26 01:31:26 UTC)
#20
http://codereview.chromium.org/8970016/diff/56001/content/renderer/mouse_lock_dispatcher.h File content/renderer/mouse_lock_dispatcher.h (right): http://codereview.chromium.org/8970016/diff/56001/content/renderer/mouse_lock_dispatcher.h#newcode80 content/renderer/mouse_lock_dispatcher.h:80: // owning reference here that must be cleared by ...
8 years, 11 months ago
(2012-01-26 01:37:59 UTC)
#21
Issue 8970016: refactoring mouse lock to support pepper and WebKit
(Closed)
Created 9 years ago by scheib
Modified 8 years, 11 months ago
Reviewers: yzshen1, piman
Base URL: svn://svn.chromium.org/chrome/trunk/src
Comments: 130