RESOLVED FIXED 85792
NodesFromRect and area-based hit-testing can not handle CSS transforms
https://bugs.webkit.org/show_bug.cgi?id=85792
Summary NodesFromRect and area-based hit-testing can not handle CSS transforms
Allan Sandfeld Jensen
Reported 2012-05-07 05:06:24 PDT
If CSS transforms such as scale() or rotate() are applied to an element nodesFromRect will not return the correct nodes in the rect, since the transforms are ignored on the rectangle dimensions. The problem is that only the central pointer is transformed when recursing down the document tree, while the rectangle is not. To solve this hit-testing must include a transformed area and not just a transformed pointer. Also we will need a fast way to test intersection between a rectangle and a transformed rectangle (a FloatQuad).
Attachments
WIP (131.06 KB, patch)
2012-05-08 02:24 PDT, Allan Sandfeld Jensen
no flags
Patch (145.10 KB, patch)
2012-05-08 07:10 PDT, Allan Sandfeld Jensen
buildbot: commit-queue-
Patch (151.04 KB, patch)
2012-05-08 07:51 PDT, Allan Sandfeld Jensen
no flags
Patch (128.00 KB, patch)
2012-05-16 01:37 PDT, Allan Sandfeld Jensen
no flags
Patch (137.83 KB, patch)
2012-05-16 01:53 PDT, Allan Sandfeld Jensen
no flags
Patch (137.30 KB, patch)
2012-05-16 02:34 PDT, Allan Sandfeld Jensen
no flags
Archive of layout-test-results from ec2-cr-linux-04 (526.50 KB, application/zip)
2012-05-16 05:29 PDT, WebKit Review Bot
no flags
Patch (137.36 KB, patch)
2012-05-16 06:09 PDT, Allan Sandfeld Jensen
no flags
Patch (129.85 KB, patch)
2012-05-30 02:31 PDT, Allan Sandfeld Jensen
no flags
Patch (31.74 KB, patch)
2012-06-19 03:28 PDT, Allan Sandfeld Jensen
no flags
Patch (35.80 KB, patch)
2012-06-25 06:39 PDT, Allan Sandfeld Jensen
no flags
Patch (34.23 KB, patch)
2012-06-25 07:21 PDT, Allan Sandfeld Jensen
no flags
Archive of layout-test-results from ec2-cr-linux-02 (788.99 KB, application/zip)
2012-06-25 10:19 PDT, WebKit Review Bot
no flags
Patch (37.68 KB, patch)
2012-06-26 04:55 PDT, Allan Sandfeld Jensen
no flags
Patch (37.73 KB, patch)
2012-06-26 05:11 PDT, Allan Sandfeld Jensen
webkit.review.bot: commit-queue-
Archive of layout-test-results from ec2-cr-linux-01 (620.22 KB, application/zip)
2012-06-26 06:14 PDT, WebKit Review Bot
no flags
Patch (36.68 KB, patch)
2012-06-26 08:09 PDT, Allan Sandfeld Jensen
eric: review+
Allan Sandfeld Jensen
Comment 1 2012-05-08 02:24:35 PDT
Created attachment 140697 [details] WIP This patch is not for review. It is still missing ChangeLog. There is still Qt instrumentation. Automated testing is not yet complete. And I am still searching for a source of a few weird results. But I do think the code is mostly complete and the strategy and logic can be examined and commented on.
Allan Sandfeld Jensen
Comment 2 2012-05-08 07:10:08 PDT
Build Bot
Comment 3 2012-05-08 07:32:33 PDT
Antonio Gomes
Comment 4 2012-05-08 07:33:25 PDT
did not review, just a request: lets factor out HitTestPoint one its on patch.
Early Warning System Bot
Comment 5 2012-05-08 07:40:59 PDT
Early Warning System Bot
Comment 6 2012-05-08 07:47:46 PDT
Allan Sandfeld Jensen
Comment 7 2012-05-08 07:51:43 PDT
Created attachment 140719 [details] Patch Include build-system updates.
Allan Sandfeld Jensen
Comment 8 2012-05-08 07:55:21 PDT
(In reply to comment #4) > did not review, just a request: lets factor out HitTestPoint one its on patch. We could do that. It is a very small change actually. The only issue is that the patch looks kind of odd on its own.
Eric Seidel (no email)
Comment 9 2012-05-09 02:35:06 PDT
I'm amazed that WebKit has two separate DOM apis for this: https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIDOMWindowUtils#nodesFromRect() and http://trac.webkit.org/browser/trunk/Source/WebCore/svg/SVGSVGElement.cpp#L362 :) One which uses SVG types, and one which uses bare values. (Assuming nodesFromRect is what WebKit implements here.) Also that these hit testing systems are presumably implemented separately, since getIntersectionList does not use HitTestResult. :( http://trac.webkit.org/browser/trunk/Source/WebCore/svg/SVGSVGElement.cpp#L342
Eric Seidel (no email)
Comment 10 2012-05-09 02:36:58 PDT
Ah, looks like this is currently only exposed via internals? http://trac.webkit.org/browser/trunk/LayoutTests/fast/dom/resources/nodesFromRect.js#L14 Do we expose rect-based hittesting in any other fashion? Do you know? My hittesting knowledge is rather dated at this point.
Allan Sandfeld Jensen
Comment 11 2012-05-09 03:27:23 PDT
(In reply to comment #10) > Ah, looks like this is currently only exposed via internals? > http://trac.webkit.org/browser/trunk/LayoutTests/fast/dom/resources/nodesFromRect.js#L14 > > Do we expose rect-based hittesting in any other fashion? Do you know? My hittesting knowledge is rather dated at this point. Well, it is not in Document.idl, so probably not. This means it is only used for touch-based hit-testing.
Allan Sandfeld Jensen
Comment 12 2012-05-16 01:37:56 PDT
Kenneth Rohde Christiansen
Comment 13 2012-05-16 01:47:35 PDT
Comment on attachment 142196 [details] Patch You forgot the tests
Allan Sandfeld Jensen
Comment 14 2012-05-16 01:53:00 PDT
Created attachment 142198 [details] Patch Now including the tests
Build Bot
Comment 15 2012-05-16 02:12:36 PDT
Allan Sandfeld Jensen
Comment 16 2012-05-16 02:34:27 PDT
Created attachment 142205 [details] Patch Fix win build
Allan Sandfeld Jensen
Comment 17 2012-05-16 03:29:40 PDT
Comment on attachment 142205 [details] Patch With green bot, promote to candidate to commit.
WebKit Review Bot
Comment 18 2012-05-16 05:29:05 PDT
Comment on attachment 142205 [details] Patch Attachment 142205 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/12717189 New failing tests: touchadjustment/scroll-delegation/iframe-with-mainframe-scroll-offset.html
WebKit Review Bot
Comment 19 2012-05-16 05:29:12 PDT
Created attachment 142227 [details] Archive of layout-test-results from ec2-cr-linux-04 The attached test failures were seen while running run-webkit-tests on the chromium-ews. Bot: ec2-cr-linux-04 Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'> Platform: Linux-2.6.35-28-virtual-x86_64-with-Ubuntu-10.10-maverick
Allan Sandfeld Jensen
Comment 20 2012-05-16 06:09:46 PDT
Created attachment 142236 [details] Patch Correct area used in touch-adjustment functions
Allan Sandfeld Jensen
Comment 21 2012-05-25 05:11:02 PDT
Comment on attachment 142236 [details] Patch Requires slight rebasing after review.
Allan Sandfeld Jensen
Comment 22 2012-05-30 02:31:05 PDT
Created attachment 144767 [details] Patch Patch rebased to apply on top of patch from bug 86605, do not feed to bots until that patch has landed. Also cleaned the two test-cases based on reviewer feedback.
Julien Chaffraix
Comment 23 2012-06-08 11:06:01 PDT
Comment on attachment 144767 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=144767&action=review After a quick glance, the direction seems OK. I haven't spotted anything too bad but it's difficult to look into the details when the patch is so big. Several of the refactorings could be pushed to blocking bugs to ease review though. > Source/WebCore/rendering/HitTestResult.h:56 > + HitTestPoint(const FloatPoint&, const FloatQuad&); > + HitTestPoint(const LayoutPoint& centerPoint, const IntRect&); Shouldn't we make those constructor also explicit for consistency? > Source/WebCore/rendering/HitTestResult.h:87 > + IntRect m_boundingRect; I would move part of this refactoring to a new bug. The change is already pretty massive. > Source/WebCore/rendering/RenderEmbeddedObject.cpp:275 > - IntPoint roundedPoint = roundedIntPoint(pointInContainer); > + IntPoint roundedPoint = pointInContainer.roundedPoint(); You could keep the external function pattern here to avoid having 2 ways between LayoutPoint/IntPoint and HitTestPoints. > Source/WebCore/rendering/RenderFlowThread.cpp:310 > + LayoutSize renderFlowThreadOffset; This change is arguable and WebKit as a project hasn't done a good job at saying how an offset should be represented... If it can be avoided, I would rather not changing the type from Point to Size but I don't feel strongly about it. > Source/WebCore/rendering/RenderObject.h:654 > + virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction); OVERRIDE :)
Allan Sandfeld Jensen
Comment 24 2012-06-10 09:12:09 PDT
(In reply to comment #23) > (From update of attachment 144767 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=144767&action=review > > After a quick glance, the direction seems OK. I haven't spotted anything too bad but it's difficult to look into the details when the patch is so big. Several of the refactorings could be pushed to blocking bugs to ease review though. > I can separate a few more things out, you also bring up a good option for that, but the final patch is still going to be large because changing the input type for nodeAtPoint requires minor changes in many files. > > Source/WebCore/rendering/HitTestResult.h:56 > > + HitTestPoint(const FloatPoint&, const FloatQuad&); > > + HitTestPoint(const LayoutPoint& centerPoint, const IntRect&); > > Shouldn't we make those constructor also explicit for consistency? > No, since these constructors takes two arguments explicit is not necessary, and might not even be allowed. > > Source/WebCore/rendering/RenderObject.h:654 > > + virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction); > > OVERRIDE :) No, not this one. It is the base declaration. Funny enough I had override on it until I actually got to test it with GCC 4.7 in C++11 mode, and realized it was wrong :)
Allan Sandfeld Jensen
Comment 25 2012-06-19 02:26:38 PDT
I have separated the largest but also most harmless change into bug #89448, this is simply changing the API of nodeAtPoint, and a naturally continuation of bug #85965 which was separated earlier.
Allan Sandfeld Jensen
Comment 26 2012-06-19 03:28:37 PDT
Eric Seidel (no email)
Comment 27 2012-06-19 06:38:45 PDT
Allan: Again here, the patch looks sane, and I'm happy to help review once I slog through more of my post-vacation backlog. I'm still missing (likely due to my oversight!) a high-level overview of why we have rect-based-hittesting implemented in this manner, and how it's different from the other rect-based hit testing mentioned in comment 9. Is there a webkit-dev post (or bug or bug comment) you could point me to about understanding the rational behind this work? Specifically I'm interested in the following: 1. What are we adding with this new rect-based hittesting work? (Fixing an exiting feature, or adding new functionality?) 2. What's this functionality for (a device? a DOM API? which ports does it affect?) 3. How does this relate to our existing "rect based hit testing" (assuming I'm understanding those other APIs correctly). Are they going to move to this model? 4. I'd kinda like a general overview of how much work there is on this feature. Is this patch 1 of 35? Or 1 of 4? Anyway, if you could point me to those answers, I'm happy to be a reviewer on this (and any future!) rect-based hit-testing patches. Thank you in advance!
Allan Sandfeld Jensen
Comment 28 2012-06-19 06:52:34 PDT
(In reply to comment #27) > Allan: Again here, the patch looks sane, and I'm happy to help review once I slog through more of my post-vacation backlog. > > I'm still missing (likely due to my oversight!) a high-level overview of why we have rect-based-hittesting implemented in this manner, and how it's different from the other rect-based hit testing mentioned in comment 9. > > Is there a webkit-dev post (or bug or bug comment) you could point me to about understanding the rational behind this work? Specifically I'm interested in the following: > > 1. What are we adding with this new rect-based hittesting work? (Fixing an exiting feature, or adding new functionality?) > This is bug-fix to nodesFromRect, but nodesFromRect is an internal API, but is used by all the touch resolution code. NodesFromRect currently doesn't handle SVG, though this patch should make it possible to fix that later now. > 2. What's this functionality for (a device? a DOM API? which ports does it affect?) > It affects touch devices. It means you will be able to actually touch-activate transformed elements, were you are currently likely to activate a wrong element on the screen, or at least show the activation high-light on the wrong element, but end up activating the right one any way (depending on platform. > 3. How does this relate to our existing "rect based hit testing" (assuming I'm understanding those other APIs correctly). Are they going to move to this model? > This is a fix to the existing rect-based hit testing model. It doesn't change, the patch just adds the ability for the area being tested to have been transformed instead of staying the same size and shape. > 4. I'd kinda like a general overview of how much work there is on this feature. Is this patch 1 of 35? Or 1 of 4? > > Anyway, if you could point me to those answers, I'm happy to be a reviewer on this (and any future!) rect-based hit-testing patches. Thank you in advance! This is the final patch for this bug fix. Originally it was the only patch, but due to the size of it, several reviewers has asked me to split it into several parts.
Eric Seidel (no email)
Comment 29 2012-06-19 16:43:13 PDT
(In reply to comment #28) > (In reply to comment #27) Thank you for your helpful answers! > > 2. What's this functionality for (a device? a DOM API? which ports does it affect?) > > > It affects touch devices. It means you will be able to actually touch-activate transformed elements, were you are currently likely to activate a wrong element on the screen, or at least show the activation high-light on the wrong element, but end up activating the right one any way (depending on platform. Which platforms use this touch code? Qt? Do you know if iOS WebKit does?
Allan Sandfeld Jensen
Comment 30 2012-06-20 01:52:41 PDT
(In reply to comment #29) > > Which platforms use this touch code? Qt? Do you know if iOS WebKit does? I can't know for sure, the code that does touch is only shipped as compiled binaries in the iOS source dump, but I suspect that they do. But I know Qt, Android, Blackberry and Chromium for Android uses nodesFromRect.
Eric Seidel (no email)
Comment 31 2012-06-20 05:17:16 PDT
(In reply to comment #30) > (In reply to comment #29) > > > > Which platforms use this touch code? Qt? Do you know if iOS WebKit does? > > I can't know for sure, the code that does touch is only shipped as compiled binaries in the iOS source dump, but I suspect that they do. > > But I know Qt, Android, Blackberry and Chromium for Android uses nodesFromRect. Thank you again. So this is common support, which i just simply wasn't aware of. :)
Eric Seidel (no email)
Comment 32 2012-06-20 08:44:56 PDT
Simon Fraser is probably your best reviewer for this, but I can also do so if needed. I trust his recall of basic geometry more than my own. :)
Allan Sandfeld Jensen
Comment 33 2012-06-25 06:39:45 PDT
Created attachment 149282 [details] Patch Rebased on landed requisite patches
Allan Sandfeld Jensen
Comment 34 2012-06-25 06:45:42 PDT
After this patch it will make sense to remove m_lastPlanarPoint and m_lastPlanarQuad from HitTestingTransformState. They are only used from one remaining function now, and doesn't really belong there. Moving m_region from HitTestResult to HitTestPoint might also make sense now, and would eliminate saving and restoring of HitTestResult::region in RenderFlowThread::hitTestRegion. Neither are directly required for this bug-fix though.
Gustavo Noronha (kov)
Comment 35 2012-06-25 07:04:37 PDT
Build Bot
Comment 36 2012-06-25 07:06:20 PDT
WebKit Review Bot
Comment 37 2012-06-25 07:07:28 PDT
Comment on attachment 149282 [details] Patch Attachment 149282 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/13099069
Allan Sandfeld Jensen
Comment 38 2012-06-25 07:21:55 PDT
WebKit Review Bot
Comment 39 2012-06-25 10:18:59 PDT
Comment on attachment 149287 [details] Patch Attachment 149287 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/13090206 New failing tests: transforms/3d/hit-testing/perspective-clipped.html transforms/3d/hit-testing/coplanar-with-camera.html transforms/3d/point-mapping/3d-point-mapping-overlapping.html transforms/3d/point-mapping/3d-point-mapping-preserve-3d.html transforms/3d/hit-testing/rotated-hit-test2.html transforms/3d/hit-testing/rotated-hit-test.html transforms/3d/hit-testing/rotated-hit-test-with-child.html transforms/3d/point-mapping/3d-point-mapping-origins.html transforms/3d/point-mapping/3d-point-mapping.html
WebKit Review Bot
Comment 40 2012-06-25 10:19:05 PDT
Created attachment 149314 [details] Archive of layout-test-results from ec2-cr-linux-02 The attached test failures were seen while running run-webkit-tests on the chromium-ews. Bot: ec2-cr-linux-02 Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'> Platform: Linux-2.6.35-28-virtual-x86_64-with-Ubuntu-10.10-maverick
Allan Sandfeld Jensen
Comment 41 2012-06-26 04:55:01 PDT
Early Warning System Bot
Comment 42 2012-06-26 05:05:27 PDT
Early Warning System Bot
Comment 43 2012-06-26 05:09:48 PDT
Gyuyoung Kim
Comment 44 2012-06-26 05:09:52 PDT
Allan Sandfeld Jensen
Comment 45 2012-06-26 05:11:44 PDT
Created attachment 149513 [details] Patch Re-add accidentally removed line
WebKit Review Bot
Comment 46 2012-06-26 06:14:07 PDT
Comment on attachment 149513 [details] Patch Attachment 149513 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/13090497 New failing tests: svg/text/select-x-list-4.svg
WebKit Review Bot
Comment 47 2012-06-26 06:14:13 PDT
Created attachment 149521 [details] Archive of layout-test-results from ec2-cr-linux-01 The attached test failures were seen while running run-webkit-tests on the chromium-ews. Bot: ec2-cr-linux-01 Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'> Platform: Linux-2.6.35-28-virtual-x86_64-with-Ubuntu-10.10-maverick
Allan Sandfeld Jensen
Comment 48 2012-06-26 08:09:03 PDT
Created attachment 149534 [details] Patch Keep the rounding in SVG-text unchanged to floored ints.
Allan Sandfeld Jensen
Comment 49 2012-07-13 02:08:19 PDT
Comment on attachment 149534 [details] Patch Will need to have the test-cases moved before landing.
Eric Seidel (no email)
Comment 50 2012-07-25 08:51:14 PDT
Comment on attachment 149534 [details] Patch Looks reasonable.
Allan Sandfeld Jensen
Comment 51 2012-07-25 09:10:17 PDT
Note You need to log in before you can comment on or make changes to this bug.