Closed Bug 726615 Opened 12 years ago Closed 12 years ago

Support W3C touch event instead of MozTouch event

Categories

(Core :: Widget: Win32, defect)

All
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla18
Tracking Status
firefox18 + disabled
firefox19 --- disabled

People

(Reporter: brandon.wallace, Assigned: jimm)

References

(Depends on 1 open bug, )

Details

(Keywords: dev-doc-needed, feature, Whiteboard: [metro-mvp])

Attachments

(2 files, 8 obsolete files)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2

Steps to reproduce:

(Win7 desktop touch device with latest Firefox nightly - 13.0a1 (2012-02-12)

According to the MDN documentation: https://developer.mozilla.org/en/DOM/Touch_events

We should be using "touchstart", "touchend" etc to listen for touch events.


Actual results:

After much experimenting and head-scratching, and setting/unsetting dom.w3c_touch_events.enabled, I finally concluded that "touch*" is not implemented for the desktop browser and I must continue using the experimental MozTouch* events: https://developer.mozilla.org/en/DOM/Touch_events_(Mozilla_experimental)


Expected results:

touch* events should work, or maybe the note at the bottom of the MDN documentation should mention that the desktop browser still uses the deprecated events.
Status: UNCONFIRMED → NEW
Component: Untriaged → Widget: Win32
Ever confirmed: true
Product: Firefox → Core
QA Contact: untriaged → win32
Hardware: x86_64 → All
Summary: Touch Event API not implemented for Desktop Firefox → Support W3C touch event instead of MozTouch event
MozTocuh is Windows platform only, we can remove it after replacing with touch event on Windows
Attached patch Part 1. touch event for Windows (obsolete) — Splinter Review
Attachment #618577 - Attachment is obsolete: true
Attachment #618622 - Attachment is patch: true
Attachment #618622 - Flags: review?(jmathies)
Attachment #618622 - Flags: review?(bugs)
Assignee: nobody → m_kato
Comment on attachment 618622 [details] [diff] [review]
Part 1. touch event for Windows

I don't have any touch enabled Win7 device, so I can't test this.
Does this handle multitouch properly. Also, please test touch event handling when
the page is zoomed in or out.

> 
>   if (mGesture.GetTouchInputInfo((HTOUCHINPUT)lParam, cInputs, pInputs)) {
>+    nsTouchEvent *touchMoveEvent = nsnull;
Could you use nsAutoPtr for this.

>+    nsEventStatus status;
Please initialize status to some value. I know the old code didn't do it,
but nsEventStatus_eIgnore should be ok.

I hope wesj could look at this too, since he implemented support for multitouch.
Attachment #618622 - Flags: review?(wjohnston)
Attachment #618622 - Flags: review?(bugs)
Attachment #618622 - Flags: review+
I'm out of the office today. Will try to get tot his as soon as possible.
Comment on attachment 618622 [details] [diff] [review]
Part 1. touch event for Windows

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

I have a win7 touch screen and can test if/when this is rolled into a nightly build.

Should the MozTouch events be immediately removed though?  Shouldn't they go through some sort of deprecation period to give people time to move to the new API?

::: widget/windows/nsWindow.cpp
@@ +6160,5 @@
> +                           TOUCH_COORD_TO_PIXEL(pInputs[i].cyContact) / 2) :
> +                         nsIntPoint(1,1), /* unknown */
> +                       0.0f,
> +                       0.0f /* unknown */ );
> +

Shouldn't the "force" be set to 1.0 when unknown?
Actually, looks like the W3C spec says "force" should be 0 when unknown, but the MDN documentation says it should be 1.
(In reply to Olli Pettay [:smaug] from comment #5)
> Comment on attachment 618622 [details] [diff] [review]
> Part 1. touch event for Windows
> 
> I don't have any touch enabled Win7 device, so I can't test this.
> Does this handle multitouch properly. Also, please test touch event handling
> when the page is zoomed in or out.

Olli, you might consider getting a samsung tablet with win7 which can be upgraded to win8. Some guidelines can be found here - 

https://wiki.mozilla.org/Firefox/Windows_8_Integration#Samsung_Series_7
I don't see much in the way of handling for these events in the desktop front end code. What's the best way to test to see if these events are working correctly?
This demo by paul irish lets you draw with multiple fingers and works well for some simple testing:

http://paulirish.com/demo/multi

doesn't support things like force, rotation, or radius. I've got a test page locally somewhere that tried to measure those as well.

mbrubeck has a non-official test page for testing preventDefault behaviors:

http://limpet.net/w3/touchevents/preventDefault.html

There's also some manual tests that you can run from the W3:

https://dvcs.w3.org/hg/webevents/file/1950bf275667/tests/touch-events-v1/submissions/Mozilla
Comment on attachment 618622 [details] [diff] [review]
Part 1. touch event for Windows

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

I think brandon is right about the force, but looks good to me!

::: widget/windows/nsWindow.cpp
@@ +6163,5 @@
> +                       0.0f /* unknown */ );
> +
> +      if (msg == NS_TOUCH_START || msg == NS_TOUCH_END) {
> +        if (touchMoveEvent) {
> +          // need dispatch stocked touch move event

NIT: // dispatch stocked touch move event

@@ +6187,5 @@
> +        touchMoveEvent->touches.AppendElement(t);
> +      }
> +    }
> +
> +    // Dispatch remained touch event

NIT: // Dispatch remaining touch event
Attachment #618622 - Flags: review?(wjohnston) → review+
Attachment #618622 - Flags: review?(jmathies) → review+
Is the patch ready to land?
Jimm, Felipe, could you test it a bit?
(In reply to Olli Pettay [:smaug] from comment #13)
> Is the patch ready to land?
> Jimm, Felipe, could you test it a bit?

Sure looks like it, it has all the reviews it needs. Makoto?
Depends on: multitouch
Assignee: m_kato → jmathies
Attached patch Remove MozTouch event (obsolete) — Splinter Review
Attachment #618585 - Attachment is obsolete: true
Attachment #660233 - Flags: review?(bugs)
Comment on attachment 660233 [details] [diff] [review]
Remove MozTouch event

ugh, sorry, loaded with "egg-info" files.
Attachment #660233 - Flags: review?(bugs)
Attached patch Remove MozTouch event (obsolete) — Splinter Review
Attachment #660233 - Attachment is obsolete: true
try run results look good:

https://tbpl.mozilla.org/?noignore=0&tree=Try&rev=89c495c2c52e

I'm going to do some hand testing of the events.
Comment on attachment 660235 [details] [diff] [review]
Remove MozTouch event

This patch was never approved by anyone. It entails a complete back out of all MozTouch related event code.
Attachment #660235 - Flags: review?(bugs)
Sorry for the review spam, that wasn't the latest patch.
Attachment #660235 - Attachment is obsolete: true
Attachment #660235 - Flags: review?(bugs)
Attachment #660395 - Flags: review?(bugs)
Blocks: 769114
> This demo by paul irish lets you draw with multiple fingers and works well
> for some simple testing:
> 
> http://paulirish.com/demo/multi
> 

These builds work fine with this demo.

A few other notes:

- pinch and zoom in the browser work
- most of the demos on the web I found didn't work including all of these:
https://developer.mozilla.org/en-US/demos/tag/tech:multitouch/
- we seem to have a pretty bad conflict with selection and these events
- Unfortunately they didn't fix the clicking issue in the cutthrerope demo. I'll investigate in that bug.
Attachment #618622 - Attachment is obsolete: true
Attachment #660396 - Attachment is obsolete: true
Attached patch widget patch v.1 (obsolete) — Splinter Review
Attachment #660505 - Flags: review?(mbrubeck)
Comment on attachment 660505 [details] [diff] [review]
widget patch v.1

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

I'm happy to review the next version of this patch, but smaug should look at it too.

::: widget/windows/nsWindow.cpp
@@ +6208,5 @@
> +      uint32_t msg;
> +      if (pInputs[i].dwFlags & TOUCHEVENTF_DOWN) {
> +        msg = NS_TOUCH_START;
> +      } else if (pInputs[i].dwFlags & TOUCHEVENTF_UP) {
> +        msg = NS_TOUCH_END;

Looking at PresShell and at the Android widget code, it looks like we actually need a separate path for NS_TOUCH_END.  While NS_TOUCH_START and NS_TOUCH_MOVE events should include every active input in the "touches" list, NS_TOUCH_END events should include only the changed inputs.  (Sorry, this is contrary to what I told you earlier.  This is the case for widget-level nsTouchEvents, and is different for content-level nsIDOMTouchEvents.)

@@ +6212,5 @@
> +        msg = NS_TOUCH_END;
> +      } else if (pInputs[i].dwFlags & TOUCHEVENTF_MOVE) {
> +        msg = NS_TOUCH_MOVE;
> +      } else {
> +        continue;

I think this "continue" should be removed.  For START and MOVE events, the "touches" list should contain all of the inputs, not just ones that have changed.

@@ +6226,5 @@
> +      if (msg == NS_TOUCH_START || msg == NS_TOUCH_END) {
> +        // W3c spec states start/end event should contain moves from existing
> +        // identifier event streams. Pres shell will discard previous event
> +        // streams if we don't have matching identifies in start events.
> +        touchEventToSend->message = msg;

Is it possible that we will have two different "msg" values in a single WM_TOUCH message (e.g. NS_TOUCH_START on one input and NS_TOUCH_MOVE on another)?  If so, this code will ignore the MOVE event and send only a START event; shouldn't we send multiple events if there are multiple changed touches?  And if not, this code is unneeded since we already passed the message to the nsTouchEvent constructor.
Attachment #660505 - Flags: review?(mbrubeck) → review-
Just to make sure its clear, Matt is right. We can trivially fix presShell to not require all the touches on start and move if wanted. For end, I needed some way for presShell to know what was ending.
Comment on attachment 660395 [details] [diff] [review]
Remove MozTouch event

Assuming the commented out code in nsWindow.cpp will be enabled and modified
in the other patch, r=me
Attachment #660395 - Flags: review?(bugs) → review+
(In reply to Matt Brubeck (:mbrubeck) from comment #24)
> Looking at PresShell and at the Android widget code, it looks like we
> actually need a separate path for NS_TOUCH_END.  While NS_TOUCH_START and
> NS_TOUCH_MOVE events should include every active input in the "touches"
> list, NS_TOUCH_END events should include only the changed inputs.  (Sorry,
> this is contrary to what I told you earlier.  This is the case for
> widget-level nsTouchEvents, and is different for content-level
> nsIDOMTouchEvents.)

No problem, this should be easy to fix.

> 
> @@ +6212,5 @@
> > +        msg = NS_TOUCH_END;
> > +      } else if (pInputs[i].dwFlags & TOUCHEVENTF_MOVE) {
> > +        msg = NS_TOUCH_MOVE;
> > +      } else {
> > +        continue;
> 
> I think this "continue" should be removed.


This is filtering out potentially spurious data points. For example (TOUCHEVENTF_INRANGE and TOUCHEVENTF_PALM). 

http://msdn.microsoft.com/en-us/library/windows/desktop/dd317334%28v=vs.85%29.aspx

I haven't seen these come in in practive on my win8 tablet.

> 
> @@ +6226,5 @@
> > +      if (msg == NS_TOUCH_START || msg == NS_TOUCH_END) {
> > +        // W3c spec states start/end event should contain moves from existing
> > +        // identifier event streams. Pres shell will discard previous event
> > +        // streams if we don't have matching identifies in start events.
> > +        touchEventToSend->message = msg;
> 

> Is it possible that we will have two different "msg" values in a single
> WM_TOUCH message (e.g. NS_TOUCH_START on one input and NS_TOUCH_MOVE on
> another)?  If so, this code will ignore the MOVE event and send only a START
> event;

From our discussion yesterday that was what I though was expected. This was to fix the spurious touchend event presshell was generating. So for example:

Windows input data:

id, event
1, move
2, start

Currently, this would be sent as a NS_TOUCH_START.

id, event
1, move
1, move
2, start
2, move

Same here, with all four data points in the touches list.

So I guess there are still some open questions here about how widget layers should package up blocks of events to keep pres shell happy.
> So I guess there are still some open questions here about how widget layers
> should package up blocks of events to keep pres shell happy.

By "blocks of events" I really meant "blocks of active touch point data"
Attached patch widget patch v.2Splinter Review
wesj, feel free to chime in. I want to be sure we are sending a stream of event pres shell will be happy with. This patch appears to, and works on all the demos / tests I have.
Attachment #660505 - Attachment is obsolete: true
Attachment #660876 - Flags: review?(mbrubeck)
One thing I was wondering about, while processing the Windows array I'm splitting touch-up points off for the touchEndEventToSend event. I wonder if these should also be appended to the touchEventToSend event, if it exists.

As I mentioned though all the demos I know of work fine so maybe this isn't needed.
Comment on attachment 660876 [details] [diff] [review]
widget patch v.2

(In reply to Jim Mathies [:jimm] from comment #30)
> One thing I was wondering about, while processing the Windows array I'm
> splitting touch-up points off for the touchEndEventToSend event. I wonder if
> these should also be appended to the touchEventToSend event, if it exists.

I think this is fine, but you might want to reverse the order of the two blocks here, so the NS_TOUCH_END event is dispatched first.  Then PresShell will remove that point from its tracking list and won't be expecting to see it in the next START or MOVE event.  (Otherwise the START event could trigger PresShell's EvictTouchPoint, which would generate its own NS_TOUCH_END event before yours is dispatched.  Though this only matters in practice if Windows ever sends a DOWN for one input and an UP for another in the same message.)

>+    // Dispatch touch start and move event if we have one.
>+    if (touchEventToSend) {
>+      DispatchEvent(touchEventToSend, status);
>+      delete touchEventToSend;
>+    }
>+
>+    // Dispatch touch end event if we have one.
>+    if (touchEndEventToSend) {
>+      DispatchEvent(touchEndEventToSend, status);
>+      delete touchEndEventToSend;
>+    }
>+  }

This patch looks good to me.  I'd like wesj's eyes on it too since I've never really worked with widget code.
Attachment #660876 - Flags: review?(wjohnston)
Attachment #660876 - Flags: review?(mbrubeck)
Attachment #660876 - Flags: review+
wjohnston -> review ping? Sorry to nag but I'd like to promote this to aurora if possible, so I'd like to get it on mc soonish.
Attachment #660876 - Flags: review?(wjohnston) → review+
Comment on attachment 660876 [details] [diff] [review]
widget patch v.2

> +    // Dispatch touch start and move event if we have one.
> +    if (touchEventToSend) {
> +      DispatchEvent(touchEventToSend, status);
> +      delete touchEventToSend;
> +    }
> +
> +    // Dispatch touch end event if we have one.
> +    if (touchEndEventToSend) {
> +      DispatchEvent(touchEndEventToSend, status);
> +      delete touchEndEventToSend;
> +    }

Looks like this isn't safe. Any dispatched DOM events can cause destroying the widget.  You should check mOnDestroyCalled after calling DispatchEvent().
Depends on: 793578
Depends on: 793631
(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #36)
> Comment on attachment 660876 [details] [diff] [review]
> widget patch v.2
> 
> > +    // Dispatch touch start and move event if we have one.
> > +    if (touchEventToSend) {
> > +      DispatchEvent(touchEventToSend, status);
> > +      delete touchEventToSend;
> > +    }
> > +
> > +    // Dispatch touch end event if we have one.
> > +    if (touchEndEventToSend) {
> > +      DispatchEvent(touchEndEventToSend, status);
> > +      delete touchEndEventToSend;
> > +    }
> 
> Looks like this isn't safe. Any dispatched DOM events can cause destroying
> the widget.  You should check mOnDestroyCalled after calling DispatchEvent().

Hmm, I can add that, will file in a follow up.
Depends on: 793902
Depends on: 794007
Depends on: 794066
Yes. I think we want to support both (maybe not at the same time though or something?). Hopefully someday we can deprecate Apple's crazy event model for the more sane one. Details need to be worked out. Can you file something?

Probably more important for the metro work than for Android.
As a web developer, I like the MS spec better than this webkit-based spec.  Not terribly different than the deprecated MozTouch events :)
Depends on: 794375
Depends on: 794711
(In reply to Wesley Johnston (:wesj) from comment #39)
> Yes. I think we want to support both (maybe not at the same time though or
> something?). Hopefully someday we can deprecate Apple's crazy event model
> for the more sane one. Details need to be worked out. Can you file something?
> 
> Probably more important for the metro work than for Android.

Should we consider simply skipping the w3c events in desktop Firefox? It seems like this is going to confuse developers and break web sites as we migrate through the different event models to arrive at one.
It will take some time before pointer events spec is stable enough to implement, or to release.
Depends on: 795861
Depends on: 797143
Depends on: 798127
Depends on: 798804
Support of W3C touch event has broken many webpages (check the list of regressions). Maybe it would be good to disable it by default for the next Aurora merge.
Depends on: 798746
Yes, we have to disable touch events.
Depends on: 798830
Depends on: 798935
Depends on: 799852
Depends on: 800301
Depends on: 800472
Let's pref this off until we have a better handle on the regressions.  We'll want to land this on Aurora for Firefox 18.
Attachment #672550 - Flags: review?(jmathies)
(In reply to Matt Brubeck (:mbrubeck) from comment #45)
> Created attachment 672550 [details] [diff] [review]
> temporarily flip pref to disable touch events on Windows
> 
> Let's pref this off until we have a better handle on the regressions.  We'll
> want to land this on Aurora for Firefox 18.

I think it's the purpose of bug 798821, isn't it? ;)
Comment on attachment 672550 [details] [diff] [review]
temporarily flip pref to disable touch events on Windows

Oops, I missed that.
Attachment #672550 - Attachment is obsolete: true
Attachment #672550 - Flags: review?(jmathies)
Depends on: 802971
Anyone know the best way to get our evangelism team involved in this?

Once bug 798821 lands on mc and aurora, these problems will go away for a short period of time. However in researching Win8 hardware releases, it's pretty clear a large percentage of new laptops, convertibles, and tablets are going to support touch. Which means all the regressions we're seeing are going to come back over the next year or so for anyone purchasing a new device.

It looks like Chrome takes the same approach we are implementing in bug 798821, so Google might be interested in helping out as well.
Keywords: feature
Whiteboard: [metro-mvp]
Depends on: 803512
Depends on: 804084
I guess there's no doc (yet?) which I could point web designers to on what they need to change to fix their website? Or some doc that points out the common causes of this problem?
There is https://developer.mozilla.org/en-US/docs/DOM/Touch_events but it doesn't include much/any info on handling touch and mouse at the same time (which should mean fewer changes to sites than authors currently use).
I guess all the blockers here should be closed as wontfix now?
I don't think so. All those broken websites will still have problems on Windows 8 tablets when using a mouse, no?
(In reply to Frank Wein [:mcsmurf] from comment #52)
> I don't think so. All those broken websites will still have problems on
> Windows 8 tablets when using a mouse, no?

Right, and we're not going to fix those problems through the browser. Site authors will need to address their broken detection. Hence - wontfix.
Right, we should move the bugs to Tech Evangelism product then (some bugs are already in the TE product) to keep track of this. Maybe we should also remove the "blocking" dependency on this bug, not sure.
(In reply to Frank Wein [:mcsmurf] from comment #54)
> Right, we should move the bugs to Tech Evangelism product then (some bugs
> are already in the TE product) to keep track of this. Maybe we should also
> remove the "blocking" dependency on this bug, not sure.

Sounds like a good plan. I'll create a new tracking bug in evang and move them over.
Depends on: 793902
One thing we do need to look out for is bugs in our implementation. For example on the coffee cup demo in bug 794066 I experience some weird interaction between touch and selection. This may be the site, or it may be our implementation. Over time we'll have to sort mozilla bugs from site related bugs.
Depends on: 807121
No longer depends on: 807121
I tried several of the examples referenced to in the dependency bugs, and on Aurora the examples I tried are back to working as expected. I tested on Win7.

I also tried using a Win7 machine with a touchscreen (HP TouchSmart) with and without a mouse, but there is at least one example (bug 798935) where the foxnews videos play well on the touchscreen machine in fx16.0.2, but not in the latest Aurora. Changing the touch event pref from 2 to 0 makes the video play.

I don't know how popular these machines were, but when Aurora goes to release those users will be affected.
We have a telemetry ping for this. Across our entire Windows install base, touch support is a minimal 1.12%. On Windows 8 it's 4.4% over a rather small data set, which isn't surprising considering the os was just released a couple weeks ago.
Alias: win-touch-issues
argh, sorry.
Alias: win-touch-issues
Depends on: 861876
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: