Closed Bug 812351 Opened 12 years ago Closed 11 years ago

[metro] Insure pointer/keyboard input is delivered to windowless plugins

Categories

(Core :: Widget: Win32, defect)

x86_64
Windows 8.1
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jimm, Assigned: TimAbraldes)

References

Details

(Whiteboard: [metro-it1][metro-it2])

Attachments

(3 files, 5 obsolete files)

Since we are doing a lot of work on widget input currently, filing this to be sure we have the basics working for windowless plugins:

- precise/keyboard input events need to be delivered properly
- touch input should get translated to precise input initially

We want to emulate desktop event system as much as possible here. Windowless plugins receive standard win32 windowing events for this stuff, so we need to figure out how this is going to be connected up to the winrt widget backend.

We should also leverage existing / or write new tests for this using the test plugin, and get the test plugin enabled in metro mode.
Summary: [metro] Insure pointer input is delivered to windowless plugins → [metro] Insure pointer/keyboard input is delivered to windowless plugins
I'll take a look at this for metro-it1
Status: NEW → ASSIGNED
QA Contact: tabraldes
Whiteboard: [metro-it1]
Looks like I managed to set myself as the QA contact instead of the assignee.  Fixing that.
Assignee: nobody → tabraldes
QA Contact: tabraldes
Attached patch WIP Patch 1 (obsolete) — Splinter Review
This hasn't been tested yet, but the code is pretty straightforward to write after the work in bug 817061
Whiteboard: [metro-it1] → [metro-it1][metro-it2]
Just a quick update: I tested this patch by enabling plugins in metro (plugin.disable = false) then going to a website that uses Flash.  I was able to interact with the Flash content using the mouse.  Typing characters didn't work, likely due to the fact that this patch sends WM_UNICHAR messages but doesn't send WM_CHAR messages.
Attached patch Patch v2 (WIP) (obsolete) — Splinter Review
I "tested" this patch by going to Kongregate and playing a couple of the games.  First set "plugin.disable=false"

Mouse and keyboard input are both working.

Still TODO:
  Handle Unicode characters that don't fit into a single UTF-16 character
  Figure out why only left-mouse-button seems to be working (it's possible that we're correctly sending WM_RBUTTONDOWN but that flash can't do what it normally does)
  Misc cleanup
Attachment #691175 - Attachment is obsolete: true
Do we have event simulation calls such that we can write tests that send touch input that gets translated and picked up by the test plugin?

See bug 806523 for an example mochitest-metro-chrome test that uses the test plugin.
(In reply to Jim Mathies [:jimm] from comment #6)
> Do we have event simulation calls such that we can write tests that send
> touch input that gets translated and picked up by the test plugin?

We cannot yet simulate touch input; only mouse and keyboard input.

> See bug 806523 for an example mochitest-metro-chrome test that uses the test
> plugin.

Thanks for the link!  This afternoon I'll be posting an updated patch for review and attempting to write some tests for this patch that utilize the test plugin
Attached patch Patch v3 (obsolete) — Splinter Review
I'm currently working on the tests for this change (and won't submit without them) but I think this much is ready for review.

A fun way to test this patch is to set "plugin.disable = false" and simply enjoy Youtube.
Attachment #694613 - Attachment is obsolete: true
Attachment #699502 - Flags: review?(jmathies)
Comment on attachment 699502 [details] [diff] [review]
Patch v3

Review of attachment 699502 [details] [diff] [review]:
-----------------------------------------------------------------

Looks great!

::: widget/windows/winrt/MetroInput.cpp
@@ +172,5 @@
> +  //   WM_KEYDOWN
> +  //         /en-us/library/windows/desktop/ms646280%28v=vs.85%29.aspx
> +  //
> +  //   WM_KEYUP
> +  //         /en-us/library/windows/desktop/ms646281%28v=vs.85%29.aspx

nit - these uris break over time, and everybody knows how to punch something into google so, lets ditch the msdn links in comments headers. :)

@@ +256,5 @@
> +  //        /en-us/library/windows/desktop/ms646242%28v=vs.85%29.aspx
> +  //      WM_MOUSEHWHEEL
> +  //        /en-us/library/windows/desktop/ms645614%28v=vs.85%29.aspx
> +  //      WM_MOUSEWHEEL
> +  //        /en-us/library/windows/desktop/ms645617(v=vs.85).aspx

nit - same here.
Attachment #699502 - Flags: review?(jmathies) → review+
Attached patch Patch v4 (obsolete) — Splinter Review
Un-bitrotted patch.  This is different enough that I think I'd like you to take another look at it, jimm.
Attachment #699502 - Attachment is obsolete: true
Attachment #709178 - Flags: review?(jmathies)
This patch contains a bunch of helper functions that I needed for writing the plugin input tests.  It also removes helpers that aren't being used anywhere in our mochitests.
Attachment #709181 - Flags: review?(mbrubeck)
Attached patch Plugin Input tests v1 (obsolete) — Splinter Review
I'm not sure which of you is a more appropriate reviewer for the plugin input tests.
Attachment #709182 - Flags: review?(mbrubeck)
Attachment #709182 - Flags: review?(jmathies)
(In reply to Jim Mathies [:jimm] from comment #9)
> Comment on attachment 699502 [details] [diff] [review]
> Patch v3
> 
> Review of attachment 699502 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Looks great!
> 
> ::: widget/windows/winrt/MetroInput.cpp
> @@ +172,5 @@
> > +  //   WM_KEYDOWN
> > +  //         /en-us/library/windows/desktop/ms646280%28v=vs.85%29.aspx
> > +  //
> > +  //   WM_KEYUP
> > +  //         /en-us/library/windows/desktop/ms646281%28v=vs.85%29.aspx
> 
> nit - these uris break over time, and everybody knows how to punch something
> into google so, lets ditch the msdn links in comments headers. :)
> 
> @@ +256,5 @@
> > +  //        /en-us/library/windows/desktop/ms646242%28v=vs.85%29.aspx
> > +  //      WM_MOUSEHWHEEL
> > +  //        /en-us/library/windows/desktop/ms645614%28v=vs.85%29.aspx
> > +  //      WM_MOUSEWHEEL
> > +  //        /en-us/library/windows/desktop/ms645617(v=vs.85).aspx
> 
> nit - same here.

did you miss addressing these nits?
Comment on attachment 709181 [details] [diff] [review]
Testing Helpers v1

Review of attachment 709181 [details] [diff] [review]:
-----------------------------------------------------------------

Awesome work!

I'm starting to want to use some of these (like waitForEvent) in chrome also; we should think about putting the most useful ones into a JS module in toolkit.

::: browser/metro/base/tests/head.js
@@ +98,5 @@
> + *
> + * @param aMs the number of miliseconds to wait for
> + * @returns a Promise that resolves to true after the time has elapsed
> + */
> +function waitForMs(aMs) {

I notice there's an equivalent task function here:
http://mxr.mozilla.org/mozilla-central/source/toolkit/modules/tests/xpcshell/test_sqlite.js#18

Another reason to create a shared task library...
Attachment #709181 - Flags: review?(mbrubeck) → review+
Comment on attachment 709182 [details] [diff] [review]
Plugin Input tests v1

Review of attachment 709182 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good to me.  Some minor style hints below, from the unwritten Fennec style guide which mfinkle has passed down to me as oral tradition.

::: browser/metro/base/tests/browser_plugin_input_keyboard.js
@@ +10,5 @@
> +  desc: "Plugin keyboard input",
> +  run: function() {
> +    let oldPrefPluginDisable = Services.prefs.getBoolPref("plugin.disable");
> +    let oldPrefPluginsClickToPlay =
> +                        Services.prefs.getBoolPref("plugins.click_to_play");

No need for wrapping here.  (We have no strict line-length limits in /browser/metro, though wrapping somewhere around 100-120 columns is appreciated.)

You can similarly un-wrap several other lines in this file.

@@ +16,5 @@
> +    Services.prefs.setBoolPref("plugins.click_to_play", false);
> +    registerCleanupFunction(
> +                  Services.prefs.setBoolPref.bind(null,
> +                                                  "plugin.disable",
> +                                                  oldPrefPluginDisable));

You can use Services.prefs.clearUserPref here, so you don't need to store the old value.

@@ +46,5 @@
> +                  keyCode: 65,
> +                  modifiers: rightAlt,
> +                  expectedChar: "á" }];
> +
> +    while(keys.length > 0) {

Nit: space after keywords like "while" or "if" (purely for consistency).

::: browser/metro/base/tests/browser_plugin_input_mouse.js
@@ +16,5 @@
> +    Services.prefs.setBoolPref("plugins.click_to_play", false);
> +    registerCleanupFunction(
> +                  Services.prefs.setBoolPref.bind(null,
> +                                                  "plugin.disable",
> +                                                  oldPrefPluginDisable));

See above.

@@ +63,5 @@
> +      synthesizeNativeMouseLDown(plugin, click.x, click.y);
> +      synthesizeNativeMouseLUp(plugin, click.x, click.y);
> +      let success = yield waitForCondition(testMouseUpCount.bind(null,
> +                                                                 plugin,
> +                                                                 curClicks));

I think this would be clearer to me if the condition function were just placed inline here.  Up to you if you want to make this change.
Attachment #709182 - Flags: review?(mbrubeck) → review+
(In reply to Jim Mathies [:jimm] from comment #13)
> (In reply to Jim Mathies [:jimm] from comment #9)
> > Comment on attachment 699502 [details] [diff] [review]
> > Patch v3
> > 
> > Review of attachment 699502 [details] [diff] [review]:
> > -----------------------------------------------------------------
> > 
> > Looks great!
> > 
> > ::: widget/windows/winrt/MetroInput.cpp
> > @@ +172,5 @@
> > > +  //   WM_KEYDOWN
> > > +  //         /en-us/library/windows/desktop/ms646280%28v=vs.85%29.aspx
> > > +  //
> > > +  //   WM_KEYUP
> > > +  //         /en-us/library/windows/desktop/ms646281%28v=vs.85%29.aspx
> > 
> > nit - these uris break over time, and everybody knows how to punch something
> > into google so, lets ditch the msdn links in comments headers. :)
> > 
> > @@ +256,5 @@
> > > +  //        /en-us/library/windows/desktop/ms646242%28v=vs.85%29.aspx
> > > +  //      WM_MOUSEHWHEEL
> > > +  //        /en-us/library/windows/desktop/ms645614%28v=vs.85%29.aspx
> > > +  //      WM_MOUSEWHEEL
> > > +  //        /en-us/library/windows/desktop/ms645617(v=vs.85).aspx
> > 
> > nit - same here.
> 
> did you miss addressing these nits?

Oops!  I certainly did!  Attaching new patch
Attachment #709178 - Attachment is obsolete: true
Attachment #709178 - Flags: review?(jmathies)
Attachment #709224 - Flags: review?(jmathies)
Attachment #709224 - Flags: review?(jmathies) → review+
Comment on attachment 709182 [details] [diff] [review]
Plugin Input tests v1

no need for a review from me, mbrubeck is far more qualified to review front end work.
Attachment #709182 - Flags: review?(jmathies)
Landed on elm:
  Test helpers - https://hg.mozilla.org/projects/elm/rev/f07961894b62
  Patch - https://hg.mozilla.org/projects/elm/rev/9a89257abb4e
  Tests - https://hg.mozilla.org/projects/elm/rev/bd3a90f08a72

First build with these patches:
  https://tbpl.mozilla.org/?tree=Elm&rev=bd3a90f08a72
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Depends on: 839460
OS: Windows 8 Metro → Windows 8.1
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: