Bug 100542 - [chromium] Transform mouse/gesture event coordinates to account for pinch-zoom in compositor.
Summary: [chromium] Transform mouse/gesture event coordinates to account for pinch-zoo...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: W. James MacLean
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-26 10:58 PDT by W. James MacLean
Modified: 2012-10-30 14:38 PDT (History)
11 users (show)

See Also:


Attachments
Patch (5.84 KB, patch)
2012-10-26 11:02 PDT, W. James MacLean
no flags Details | Formatted Diff | Diff
Patch (4.73 KB, patch)
2012-10-29 10:03 PDT, W. James MacLean
no flags Details | Formatted Diff | Diff
Patch (4.76 KB, patch)
2012-10-29 15:54 PDT, W. James MacLean
no flags Details | Formatted Diff | Diff
Patch (4.87 KB, patch)
2012-10-30 06:48 PDT, W. James MacLean
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description W. James MacLean 2012-10-26 10:58:10 PDT
[chromium] Transform mouse/gesture event coordinates to account for pinch-zoom in compositor.
Comment 1 W. James MacLean 2012-10-26 11:02:01 PDT
Created attachment 170962 [details]
Patch
Comment 2 W. James MacLean 2012-10-26 11:08:53 PDT
Patch for discussion. (Does not compile without changes to CC to expose the implTransform.)

This patch addresses the coordinate transform issue for mouse and gesture events when a non-identity zoom transform is in effect. I'd like some feedback on the approach please:

1) Would it be better to push the computation of the transformed point back into cc (LaterTreeHost)? Then the Web* interface doesn't need to know about the implTransform at all (it could be called something like "adjustEventLocationForZoom").

2) I was surprised I couldn't just invert the implTransform without having to modify it first. Since the modification only applies to the (hidden) zoom translation, there wasn't any obvious way around it.

Tests to come.
Comment 3 Dana Jansens 2012-10-26 11:46:12 PDT
Comment on attachment 170962 [details]
Patch

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

> Source/WebKit/chromium/src/WebViewImpl.cpp:667
> +    m.setM41(m.m41() / m.m11()); // Translation components seem to have had scale applied to them,

Does this mean the implTransform is being computed wrong?

> Source/WebKit/chromium/src/WebViewImpl.cpp:670
> +    return m.inverse().mapPoint(location);

You want projectPoint() when you're using the inverse transform instead of mapPoint()
Comment 4 Dana Jansens 2012-10-26 11:46:45 PDT
(In reply to comment #2)
> Patch for discussion. (Does not compile without changes to CC to expose the implTransform.)
> 
> This patch addresses the coordinate transform issue for mouse and gesture events when a non-identity zoom transform is in effect. I'd like some feedback on the approach please:
> 
> 1) Would it be better to push the computation of the transformed point back into cc (LaterTreeHost)? Then the Web* interface doesn't need to know about the implTransform at all (it could be called something like "adjustEventLocationForZoom").

Personally, I'd like this more as we have things like MathUtil there, which no longer exist on this side of the webkit boundary.

> 2) I was surprised I couldn't just invert the implTransform without having to modify it first. Since the modification only applies to the (hidden) zoom translation, there wasn't any obvious way around it.
> 
> Tests to come.
Comment 5 W. James MacLean 2012-10-26 11:56:02 PDT
(In reply to comment #3)
> (From update of attachment 170962 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=170962&action=review
> 
> > Source/WebKit/chromium/src/WebViewImpl.cpp:667
> > +    m.setM41(m.m41() / m.m11()); // Translation components seem to have had scale applied to them,
> 
> Does this mean the implTransform is being computed wrong?

Maybe, or it may mean I'm missing something about what implTransform is supposed to do.

> > Source/WebKit/chromium/src/WebViewImpl.cpp:670
> > +    return m.inverse().mapPoint(location);
> 
> You want projectPoint() when you're using the inverse transform instead of mapPoint()

I'll try that and see if it fixes the problem above.
Comment 6 Tien-Ren Chen 2012-10-26 12:58:14 PDT
(In reply to comment #4)
> (In reply to comment #2)
> > Patch for discussion. (Does not compile without changes to CC to expose the implTransform.)
> > 
> > This patch addresses the coordinate transform issue for mouse and gesture events when a non-identity zoom transform is in effect. I'd like some feedback on the approach please:
> > 
> > 1) Would it be better to push the computation of the transformed point back into cc (LaterTreeHost)? Then the Web* interface doesn't need to know about the implTransform at all (it could be called something like "adjustEventLocationForZoom").
> 
> Personally, I'd like this more as we have things like MathUtil there, which no longer exist on this side of the webkit boundary.

I'd vote for the LayerTreeHost approach. Ideally the WebKit/WebCore should know nothing about the page scale. It feels weird to me that the embedder (either the compositor or RenderViewImpl) applies the scale when rendering, while input events are inverted-scaled in WebViewImpl.
Comment 7 James Robinson 2012-10-26 13:10:43 PDT
(In reply to comment #6)
> I'd vote for the LayerTreeHost approach. Ideally the WebKit/WebCore should know nothing about the page scale. It feels weird to me that the embedder (either the compositor or RenderViewImpl) applies the scale when rendering, while input events are inverted-scaled in WebViewImpl.

+1 to this
Comment 8 W. James MacLean 2012-10-26 13:30:54 PDT
(In reply to comment #6)
> (In reply to comment #4)
> > (In reply to comment #2)
> > > Patch for discussion. (Does not compile without changes to CC to expose the implTransform.)
> > > 
> > > This patch addresses the coordinate transform issue for mouse and gesture events when a non-identity zoom transform is in effect. I'd like some feedback on the approach please:
> > > 
> > > 1) Would it be better to push the computation of the transformed point back into cc (LaterTreeHost)? Then the Web* interface doesn't need to know about the implTransform at all (it could be called something like "adjustEventLocationForZoom").
> > 
> > Personally, I'd like this more as we have things like MathUtil there, which no longer exist on this side of the webkit boundary.
> 
> I'd vote for the LayerTreeHost approach. Ideally the WebKit/WebCore should know nothing about the page scale. It feels weird to me that the embedder (either the compositor or RenderViewImpl) applies the scale when rendering, while input events are inverted-scaled in WebViewImpl.

Agreed!
Comment 9 W. James MacLean 2012-10-29 10:03:49 PDT
Created attachment 171272 [details]
Patch
Comment 10 WebKit Review Bot 2012-10-29 10:07:08 PDT
Please wait for approval from abarth@webkit.org, dglazkov@chromium.org, fishd@chromium.org, jamesr@chromium.org or tkent@chromium.org before submitting, as this patch contains changes to the Chromium public API. See also https://trac.webkit.org/wiki/ChromiumWebKitAPI.
Comment 11 Dana Jansens 2012-10-29 10:14:50 PDT
Comment on attachment 171272 [details]
Patch

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

> Source/WebKit/chromium/src/WebViewImpl.cpp:2006
> +        mouseEvent = *static_cast<const WebMouseEvent*>(&inputEvent);

why all the * and & back and forth?

Why not just:
WebInputEvent inputEventTransformed = inputEvent;
mouseEvent = static_cast<WebMouseEvent>(inputEvent);
etc?
Comment 12 Dana Jansens 2012-10-29 10:17:07 PDT
Comment on attachment 171272 [details]
Patch

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

> Source/Platform/chromium/public/WebLayerTreeView.h:36
> +#include "WebTransformationMatrix.h"

nit: unused header
Comment 13 W. James MacLean 2012-10-29 10:18:26 PDT
(In reply to comment #11)
> (From update of attachment 171272 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=171272&action=review
> 
> > Source/WebKit/chromium/src/WebViewImpl.cpp:2006
> > +        mouseEvent = *static_cast<const WebMouseEvent*>(&inputEvent);
> 
> why all the * and & back and forth?
> 
> Why not just:
> WebInputEvent inputEventTransformed = inputEvent;
> mouseEvent = static_cast<WebMouseEvent>(inputEvent);
> etc?

Won't this slice off the extra fields (x, y, globalX, etc.) in the derived classes WebMouseEvent, WebGestureEvent ?

Will remove the extra header (oops!).
Comment 14 Dana Jansens 2012-10-29 10:23:15 PDT
Comment on attachment 171272 [details]
Patch

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

>>> Source/WebKit/chromium/src/WebViewImpl.cpp:2006
>>> +        mouseEvent = *static_cast<const WebMouseEvent*>(&inputEvent);
>> 
>> why all the * and & back and forth?
>> 
>> Why not just:
>> WebInputEvent inputEventTransformed = inputEvent;
>> mouseEvent = static_cast<WebMouseEvent>(inputEvent);
>> etc?
> 
> Won't this slice off the extra fields (x, y, globalX, etc.) in the derived classes WebMouseEvent, WebGestureEvent ?
> 
> Will remove the extra header (oops!).

Ah I see, okay! I guess this is just awkward since it's being given, and passing on, a reference instead of a pointer.
Comment 15 W. James MacLean 2012-10-29 10:28:38 PDT
(In reply to comment #14)
> (From update of attachment 171272 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=171272&action=review
> 
> >>> Source/WebKit/chromium/src/WebViewImpl.cpp:2006
> >>> +        mouseEvent = *static_cast<const WebMouseEvent*>(&inputEvent);
> >> 
> >> why all the * and & back and forth?
> >> 
> >> Why not just:
> >> WebInputEvent inputEventTransformed = inputEvent;
> >> mouseEvent = static_cast<WebMouseEvent>(inputEvent);
> >> etc?
> > 
> > Won't this slice off the extra fields (x, y, globalX, etc.) in the derived classes WebMouseEvent, WebGestureEvent ?
> > 
> > Will remove the extra header (oops!).
> 
> Ah I see, okay! I guess this is just awkward since it's being given, and passing on, a reference instead of a pointer.

Yeah, the const-references can be a bit hard if you actually need to transform a value ...
Comment 16 W. James MacLean 2012-10-29 15:54:36 PDT
Created attachment 171329 [details]
Patch
Comment 17 WebKit Review Bot 2012-10-29 19:36:04 PDT
Comment on attachment 171329 [details]
Patch

Attachment 171329 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14641301

New failing tests:
fast/frames/iframe-window-focus.html
fast/frames/frame-programmatic-noresize.html
fast/frames/frame-deep-nested-resize.html
fast/frames/frame-with-noresize-can-be-resized-after-setting-noResize-to-false.html
fast/frames/frame-set-rotation-hit.html
fast/frames/frame-dead-region.html
fast/frames/frame-inherit-noresize-from-frameset.html
fast/frames/hover-timer-crash.html
fast/frames/frame-with-noresize-can-be-resized-after-removal-of-noresize.html
fast/frames/frames-with-frameborder-zero-can-be-resized.html
fast/frames/frame-set-scaling-hit.html
Comment 18 W. James MacLean 2012-10-30 06:48:50 PDT
Created attachment 171438 [details]
Patch
Comment 19 W. James MacLean 2012-10-30 06:50:32 PDT
This patch fixes null pointer dereference on m_layerTreeView.
Comment 20 James Robinson 2012-10-30 14:04:25 PDT
Comment on attachment 171438 [details]
Patch

R=me
Comment 21 WebKit Review Bot 2012-10-30 14:38:19 PDT
Comment on attachment 171438 [details]
Patch

Clearing flags on attachment: 171438

Committed r132946: <http://trac.webkit.org/changeset/132946>
Comment 22 WebKit Review Bot 2012-10-30 14:38:24 PDT
All reviewed patches have been landed.  Closing bug.