Bug 104074 - Web Inspector: Add command for dispatching mouse events
Summary: Web Inspector: Add command for dispatching mouse events
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Ken Kania
URL:
Keywords:
Depends on:
Blocks: 105019
  Show dependency treegraph
 
Reported: 2012-12-04 18:00 PST by Ken Kania
Modified: 2012-12-14 06:50 PST (History)
9 users (show)

See Also:


Attachments
Patch (11.15 KB, patch)
2012-12-06 15:26 PST, Ken Kania
no flags Details | Formatted Diff | Diff
Patch (11.14 KB, patch)
2012-12-10 10:24 PST, Ken Kania
no flags Details | Formatted Diff | Diff
Patch (12.75 KB, patch)
2012-12-10 12:45 PST, Ken Kania
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ken Kania 2012-12-04 18:00:48 PST
We'd like to be able to dispatch mouse events via the remote debugging protocol. I plan on adding a hidden Input.dispatchMouseEvent command, which just calls the EventHandler handleMouse*Event methods.
Comment 1 Ken Kania 2012-12-06 15:26:33 PST
Created attachment 178092 [details]
Patch
Comment 2 Yury Semikhatsky 2012-12-07 02:31:52 PST
Comment on attachment 178092 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=178092&action=review

> Source/WebCore/inspector/Inspector.json:3291
> +                    { "name": "button", "type": "string", "enum": ["none", "left", "middle", "right"], "optional": true, "description": "Mouse button (default: \"none\")." },

What would be a reason for sending button=none or clickCount=0? Does it make any sense?

> Source/WebCore/inspector/Inspector.json:3293
> +                    { "name": "x", "type": "integer", "description": "X coordinate of the event relative to the frame's viewport."},

It is always relative to the _main_ frame, the description should reflect this. Alternatively we may pass frame id to specify in which frame the event should be dispatched.

> Source/WebCore/inspector/InspectorInputAgent.cpp:101
> +    else if (type == "mouseReleased")

I think we should teach CodeGeneratorInspector.py to generate string values for enum elements to  avoid using constant values like this. But this is not directly related to this change and should be addressed separately.
Comment 3 Ken Kania 2012-12-10 10:24:52 PST
Created attachment 178584 [details]
Patch
Comment 4 Ken Kania 2012-12-10 10:28:51 PST
(In reply to comment #2)
> (From update of attachment 178092 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=178092&action=review
> 
> > Source/WebCore/inspector/Inspector.json:3291
> > +                    { "name": "button", "type": "string", "enum": ["none", "left", "middle", "right"], "optional": true, "description": "Mouse button (default: \"none\")." },
> 
> What would be a reason for sending button=none or clickCount=0? Does it make any sense?
> 

button=none and clickCount=0 make sense for mouse moves where the user isn't holding a button down.

> > Source/WebCore/inspector/Inspector.json:3293
> > +                    { "name": "x", "type": "integer", "description": "X coordinate of the event relative to the frame's viewport."},
> 
> It is always relative to the _main_ frame, the description should reflect this. Alternatively we may pass frame id to specify in which frame the event should be dispatched.

I think its best to always use the main frame. Clarified this for the x and y parameters.

> 
> > Source/WebCore/inspector/InspectorInputAgent.cpp:101
> > +    else if (type == "mouseReleased")
> 
> I think we should teach CodeGeneratorInspector.py to generate string values for enum elements to  avoid using constant values like this. But this is not directly related to this change and should be addressed separately.
Comment 5 Pavel Feldman 2012-12-10 10:40:32 PST
Comment on attachment 178584 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=178584&action=review

> Source/WebCore/inspector/InspectorInputAgent.cpp:134
> +        modifiers ? *modifiers & PlatformEvent::ShiftKey : false,

you could do int convertedModifiers = modifiers ? *modifiers : 0; to improve the readability here.

> LayoutTests/inspector-protocol/input/dispatchMouseEvent.html:57
> +            InspectorTest.sendCommand("Input.dispatchMouseEvent", events.shift(), continueTest);

As with keyboard, these will be naturally serialized, so you don't need to wait for previous command to finish in order to start the new one. You only need to wait for the last one to complete before calling completeTest()
Comment 6 Ken Kania 2012-12-10 12:45:23 PST
Created attachment 178611 [details]
Patch
Comment 7 Ken Kania 2012-12-10 12:45:54 PST
(In reply to comment #5)
> (From update of attachment 178584 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=178584&action=review
> 
> > Source/WebCore/inspector/InspectorInputAgent.cpp:134
> > +        modifiers ? *modifiers & PlatformEvent::ShiftKey : false,
> 
> you could do int convertedModifiers = modifiers ? *modifiers : 0; to improve the readability here.

done

> 
> > LayoutTests/inspector-protocol/input/dispatchMouseEvent.html:57
> > +            InspectorTest.sendCommand("Input.dispatchMouseEvent", events.shift(), continueTest);
> 
> As with keyboard, these will be naturally serialized, so you don't need to wait for previous command to finish in order to start the new one. You only need to wait for the last one to complete before calling completeTest()

done
Comment 8 WebKit Review Bot 2012-12-11 04:28:40 PST
Comment on attachment 178611 [details]
Patch

Clearing flags on attachment: 178611

Committed r137291: <http://trac.webkit.org/changeset/137291>
Comment 9 WebKit Review Bot 2012-12-11 04:28:44 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Yury Semikhatsky 2012-12-14 06:42:18 PST
This patch introduced the following closure compiler error:

yurys@yurys-lin:/sources/WebKit (master)$ Source/WebCore/inspector/compile-front-end.py 

....                                                                                  ^

Source/WebCore/inspector/front-end/protocol-externs.js:2939: WARNING - optional arguments must be at the end
InputAgent.dispatchMouseEvent = function(type, opt_modifiers, opt_timestamp, opt_button, opt_clickCount, x, y, opt_callback) {}
                                ^

...


We should reorder parameters to pass required ones first.