Title: [134135] trunk
Revision
134135
Author
commit-qu...@webkit.org
Date
2012-11-09 16:16:52 -0800 (Fri, 09 Nov 2012)

Log Message

Correct hit-test point scaling for document.elementFromPoint
https://bugs.webkit.org/show_bug.cgi?id=101798

Patch by Tien-Ren Chen <trc...@chromium.org> on 2012-11-09
Reviewed by Adam Barth.

The hit-test point come from user _javascript_ is in the document coordinate.
Convert to the frame coordinate with correct scale factor for hit test.

Source/WebCore:

Test: fast/dom/elementFromPoint-scaled-scrolled.html

* dom/Document.cpp:
(WebCore::nodeFromPoint):

LayoutTests:

* fast/dom/elementFromPoint-scaled-scrolled-expected.txt: Added.
* fast/dom/elementFromPoint-scaled-scrolled.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (134134 => 134135)


--- trunk/LayoutTests/ChangeLog	2012-11-10 00:15:43 UTC (rev 134134)
+++ trunk/LayoutTests/ChangeLog	2012-11-10 00:16:52 UTC (rev 134135)
@@ -1,3 +1,16 @@
+2012-11-09  Tien-Ren Chen  <trc...@chromium.org>
+
+        Correct hit-test point scaling for document.elementFromPoint
+        https://bugs.webkit.org/show_bug.cgi?id=101798
+
+        Reviewed by Adam Barth.
+
+        The hit-test point come from user _javascript_ is in the document coordinate.
+        Convert to the frame coordinate with correct scale factor for hit test.
+
+        * fast/dom/elementFromPoint-scaled-scrolled-expected.txt: Added.
+        * fast/dom/elementFromPoint-scaled-scrolled.html: Added.
+
 2012-11-09  Raphael Kubo da Costa  <raphael.kubo.da.co...@intel.com>
 
         [EFL] More gardening.

Added: trunk/LayoutTests/fast/dom/elementFromPoint-scaled-scrolled-expected.txt (0 => 134135)


--- trunk/LayoutTests/fast/dom/elementFromPoint-scaled-scrolled-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/elementFromPoint-scaled-scrolled-expected.txt	2012-11-10 00:16:52 UTC (rev 134135)
@@ -0,0 +1,3 @@
+B1B2B3
+This test is successful if elementFromPoint returns the correct element.
+B3

Added: trunk/LayoutTests/fast/dom/elementFromPoint-scaled-scrolled.html (0 => 134135)


--- trunk/LayoutTests/fast/dom/elementFromPoint-scaled-scrolled.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/elementFromPoint-scaled-scrolled.html	2012-11-10 00:16:52 UTC (rev 134135)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body _onload_="runTest();" style="width:2000px;height:2000px;margin:0px;padding:100px">
+<button style="width:50px;height:50px;">B1</button><button style="width:50px;height:50px;">B2</button><button style="width:50px;height:50px;">B3</button>
+<div>This test is successful if elementFromPoint returns the correct element.</div>
+<div id="result"></div>
+<script>
+function runTest() {
+    if (window.internals)
+        window.internals.settings.setPageScaleFactor(2, 0, 0);
+    window.scrollTo(100,100);
+
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    document.getElementById("result").innerText = document.elementFromPoint(125, 25).innerText;
+}
+</script>
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (134134 => 134135)


--- trunk/Source/WebCore/ChangeLog	2012-11-10 00:15:43 UTC (rev 134134)
+++ trunk/Source/WebCore/ChangeLog	2012-11-10 00:16:52 UTC (rev 134135)
@@ -1,3 +1,18 @@
+2012-11-09  Tien-Ren Chen  <trc...@chromium.org>
+
+        Correct hit-test point scaling for document.elementFromPoint
+        https://bugs.webkit.org/show_bug.cgi?id=101798
+
+        Reviewed by Adam Barth.
+
+        The hit-test point come from user _javascript_ is in the document coordinate.
+        Convert to the frame coordinate with correct scale factor for hit test.
+
+        Test: fast/dom/elementFromPoint-scaled-scrolled.html
+
+        * dom/Document.cpp:
+        (WebCore::nodeFromPoint):
+
 2012-11-09  Alec Flett  <alecfl...@chromium.org>
 
         IndexedDB: Combine IDBBackingStore and IDBLevelDBBackingStore

Modified: trunk/Source/WebCore/dom/Document.cpp (134134 => 134135)


--- trunk/Source/WebCore/dom/Document.cpp	2012-11-10 00:15:43 UTC (rev 134134)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-11-10 00:16:52 UTC (rev 134135)
@@ -1436,8 +1436,8 @@
     if (!frameView)
         return 0;
 
-    float zoomFactor = frame->pageZoomFactor();
-    IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor  + frameView->scrollX(), y * zoomFactor + frameView->scrollY()));
+    float scaleFactor = frame->pageZoomFactor() * frame->frameScaleFactor();
+    IntPoint point = roundedIntPoint(FloatPoint(x * scaleFactor  + frameView->scrollX(), y * scaleFactor + frameView->scrollY()));
 
     if (!frameView->visibleContentRect().contains(point))
         return 0;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to