Title: [139462] branches/chromium/1364
- Revision
- 139462
- Author
- [email protected]
- Date
- 2013-01-11 10:59:24 -0800 (Fri, 11 Jan 2013)
Log Message
Merge 139346
> ScrollingCoordinator touch event hit rects aren't converted to proper coordinates when in nested views
> https://bugs.webkit.org/show_bug.cgi?id=106383
>
> Reviewed by James Robinson.
>
> Source/WebCore:
>
> ScrollingCoordinator uses clippedOverflowRectForRepaint(0) to generate the bounds for a renderer's hit
> testing rect. The rect this returns is in the coordinates of its document. This change converts the
> rect to the outermost view's coordinate system using convertToContainingView.
>
> Tests: platform/chromium/fast/events/touch/touch-hit-rects-in-iframe.html
>
> * page/scrolling/ScrollingCoordinator.cpp:
> (WebCore::accumulateRendererTouchEventTargetRects):
>
> LayoutTests:
>
> * platform/chromium/fast/events/touch/resources: Added.
> * platform/chromium/fast/events/touch/resources/frame-with-touch-handler.html: Added.
> * platform/chromium/fast/events/touch/touch-hit-rects-in-iframe-expected.txt: Added.
> * platform/chromium/fast/events/touch/touch-hit-rects-in-iframe.html: Added.
>
[email protected]
Review URL: https://codereview.chromium.org/11865013
Modified Paths
Added Paths
Diff
Copied: branches/chromium/1364/LayoutTests/platform/chromium/fast/events/touch/touch-hit-rects-in-iframe-expected.txt (from rev 139346, trunk/LayoutTests/platform/chromium/fast/events/touch/touch-hit-rects-in-iframe-expected.txt) (0 => 139462)
--- branches/chromium/1364/LayoutTests/platform/chromium/fast/events/touch/touch-hit-rects-in-iframe-expected.txt (rev 0)
+++ branches/chromium/1364/LayoutTests/platform/chromium/fast/events/touch/touch-hit-rects-in-iframe-expected.txt 2013-01-11 18:59:24 UTC (rev 139462)
@@ -0,0 +1,4 @@
+This test validates that touch hit tests rects are created in the coordinates of the outermost view, not their containing view. This test only works in DumpRenderTree.
+[0]: (60, 110, 50, 50)
+[1]: (420, 170, 50, 50)
+
Copied: branches/chromium/1364/LayoutTests/platform/chromium/fast/events/touch/touch-hit-rects-in-iframe.html (from rev 139346, trunk/LayoutTests/platform/chromium/fast/events/touch/touch-hit-rects-in-iframe.html) (0 => 139462)
--- branches/chromium/1364/LayoutTests/platform/chromium/fast/events/touch/touch-hit-rects-in-iframe.html (rev 0)
+++ branches/chromium/1364/LayoutTests/platform/chromium/fast/events/touch/touch-hit-rects-in-iframe.html 2013-01-11 18:59:24 UTC (rev 139462)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+#iframe1 {
+ position: absolute;
+ top: 100px;
+ left: 50px;
+ width: 200px;
+ height: 200px;
+}
+#iframe2 {
+ position: absolute;
+ top: 100px;
+ left: 400px;
+ width: 200px;
+ height: 200px;
+}
+</style>
+<body _onload_="runTest();">
+<div>This test validates that touch hit tests rects are created in the coordinates of the outermost view, not their containing view.
+This test only works in DumpRenderTree.</div>
+<div id="console"></div>
+<iframe id="iframe1" src=""
+<iframe id="iframe2"></iframe>
+<script>
+
+var iframeDocument = document.getElementById("iframe2").contentWindow.document;
+iframeDocument.open('text/html', 'replace');
+iframeDocument.write("<!DOCTYPE html>\n<html><body><iframe src="" style=\"position: relative; top: 50px;\"></iframe></body>");
+iframeDocument.close();
+
+function log(msg) {
+ var span = document.createElement("span");
+ document.getElementById("console").appendChild(span);
+ span.innerHTML = msg + '<br />';
+}
+
+function sortRects(a, b) {
+ return a.top - b.top;
+}
+
+function runTest() {
+ if (!window.testRunner)
+ return;
+ window.testRunner.dumpAsText();
+
+ rects = window.internals.touchEventTargetClientRects(document);
+ var sortedRects = new Array();
+ for (var i = 0; i < rects.length; ++i)
+ sortedRects[i] = rects[i];
+ sortedRects.sort(sortRects);
+ for (var i = 0; i < rects.length; ++i)
+ log("[" + i + "]: (" + sortedRects[i].left + ", " + sortedRects[i].top + ", " + sortedRects[i].width + ", " + sortedRects[i].height + ")");
+}
+</script>
+</body>
Modified: branches/chromium/1364/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp (139461 => 139462)
--- branches/chromium/1364/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp 2013-01-11 18:57:42 UTC (rev 139461)
+++ branches/chromium/1364/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp 2013-01-11 18:59:24 UTC (rev 139462)
@@ -185,9 +185,16 @@
if (parentRect.isEmpty() || renderer->isFloating() || renderer->isPositioned() || renderer->hasTransform()) {
// FIXME: This method is O(N^2) as it walks the tree to the root for every renderer. RenderGeometryMap would fix this.
IntRect r = enclosingIntRect(renderer->clippedOverflowRectForRepaint(0));
- if (!r.isEmpty() && !parentRect.contains(r)) {
- rects.append(r);
- adjustedParentRect = r;
+ if (!r.isEmpty()) {
+ // Convert to the top-level view's coordinates.
+ ASSERT(renderer->document()->view());
+ for (ScrollView* view = renderer->document()->view(); view && view->parent(); view = view->parent())
+ r = view->convertToContainingView(r);
+
+ if (!parentRect.contains(r)) {
+ rects.append(r);
+ adjustedParentRect = r;
+ }
}
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes