[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

eric at webkit.org eric at webkit.org
Thu Oct 29 20:50:48 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 0a521cea4e1c19571d2000b9266294c44d3501c1
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 23 19:48:03 2009 +0000

    2009-10-23  Xiaomei Ji  <xji at chromium.org>
    
            Reviewed by Sam Weinig.
    
            Fix caretRangeFromPoint()/elementFromPoint() returns wrong result
            for a zoomed and scrolled page.
            https://bugs.webkit.org/show_bug.cgi?id=30689.
    
            The real cause is the wrong calculation of event.clientX/Y when
            page is zoomed and scolled.
            After Sam fixed the event.clientX/Y in r49551, the hit test point
            should be recalculated (revert r49490).
    
            * fast/dom/Document/CaretRangeFromPoint/caretRangeFromPoint-in-zoom-and-scroll-expected.txt: Added.
            * fast/dom/Document/CaretRangeFromPoint/caretRangeFromPoint-in-zoom-and-scroll.html: Added.
            * fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport-expected.txt:
            * fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport.html:
            * fast/dom/elementFromPoint-relative-to-viewport-expected.txt:
            * fast/dom/elementFromPoint-relative-to-viewport.html:
    2009-10-23  Xiaomei Ji  <xji at chromium.org>
    
            Reviewed by Sam Weinig.
    
            Fix caretRangeFromPoint()/elementFromPoint() returns wrong result
            for a zoomed and scrolled page.
            https://bugs.webkit.org/show_bug.cgi?id=30689.
    
            The real cause is the wrong calculation of event.clientX/Y when
            page is zoomed and scolled.
            After Sam fixed the event.clientX/Y in r49551, the hit test point
            should be recalculated (revert r49490).
    
            Test: fast/dom/Document/CaretRangeFromPoint/caretRangeFromPoint-in-zoom-and-scroll.html
    
            * dom/Document.cpp:
            (WebCore::Document::elementFromPoint): calculate the correct point
            relative to document when page is zoomed and scrolled.
            (WebCore::Document::caretRangeFromPoint): calculate the correct point
            relative to document when page is zoomed and scrolled.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49990 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index e540a77..5fa11bb 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,23 @@
+2009-10-23  Xiaomei Ji  <xji at chromium.org>
+
+        Reviewed by Sam Weinig.
+
+        Fix caretRangeFromPoint()/elementFromPoint() returns wrong result 
+        for a zoomed and scrolled page.
+        https://bugs.webkit.org/show_bug.cgi?id=30689.
+
+        The real cause is the wrong calculation of event.clientX/Y when
+        page is zoomed and scolled.
+        After Sam fixed the event.clientX/Y in r49551, the hit test point
+        should be recalculated (revert r49490).
+
+        * fast/dom/Document/CaretRangeFromPoint/caretRangeFromPoint-in-zoom-and-scroll-expected.txt: Added.
+        * fast/dom/Document/CaretRangeFromPoint/caretRangeFromPoint-in-zoom-and-scroll.html: Added.
+        * fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport-expected.txt:
+        * fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport.html:
+        * fast/dom/elementFromPoint-relative-to-viewport-expected.txt:
+        * fast/dom/elementFromPoint-relative-to-viewport.html:
+
 2009-10-23  Enrica Casucci  <enrica at apple.com>
 
         Reviewed by Adele Peterson.
diff --git a/LayoutTests/fast/dom/Document/CaretRangeFromPoint/caretRangeFromPoint-in-zoom-and-scroll-expected.txt b/LayoutTests/fast/dom/Document/CaretRangeFromPoint/caretRangeFromPoint-in-zoom-and-scroll-expected.txt
new file mode 100644
index 0000000..995bb3e
--- /dev/null
+++ b/LayoutTests/fast/dom/Document/CaretRangeFromPoint/caretRangeFromPoint-in-zoom-and-scroll-expected.txt
@@ -0,0 +1,17 @@
+This is to test document.caretRangeFromPoint() in a zoom and scrolled page. The point calculation in caretRangeFromPoint() is wrong in a zoom and scrolled page. Same applies to elementFromPoint().
+
+In a window large enough to hold the page without any scroll, click mouse after "S" in "Same" at the above sentence, observe the printed offset.
+
+Now, please resize the window to make the page scroll. Then, scroll the page. Click the mouse after "S" in "Same", observe the printed offset.
+
+
+
+Result: ".
+Success
+Success
+Success
+Success
+Success
+Success
+Success
+Success
diff --git a/LayoutTests/fast/dom/Document/CaretRangeFromPoint/caretRangeFromPoint-in-zoom-and-scroll.html b/LayoutTests/fast/dom/Document/CaretRangeFromPoint/caretRangeFromPoint-in-zoom-and-scroll.html
new file mode 100644
index 0000000..666d362
--- /dev/null
+++ b/LayoutTests/fast/dom/Document/CaretRangeFromPoint/caretRangeFromPoint-in-zoom-and-scroll.html
@@ -0,0 +1,128 @@
+<HTML>
+<HEAD>
+<TITLE>document.caretRangeFromPoint() Method</TITLE>
+<SCRIPT LANGUAGE="JavaScript">
+function log(str) {
+    var li = document.createElement("li");
+    li.appendChild(document.createTextNode(str));
+    var console = document.getElementById("console");
+    console.appendChild(li);
+}
+
+function assertEqual(actual, expected) {
+    if (actual != expected)
+        log("Failure, actual: " + actual + "; expected: " + expected);
+    else
+        log("Success");
+}
+
+function sendClick()
+{
+    eventSender.mouseMoveTo(50, 50);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+function check(event, expected)
+{
+    var range =document.caretRangeFromPoint(event.clientX, event.clientY);
+    var offset = 0;
+    if (range)
+      offset = range.startOffset;
+    else {
+      alert("range is null");
+      return;
+    }
+
+    var element = document.elementFromPoint(event.clientX, event.clientY);
+    assertEqual(element.id, "first");
+    assertEqual(offset, expected);
+}
+
+function checkBase(event)
+{
+    check(event, 54);
+}
+
+function checkScroll(event)
+{
+    check(event, 93);
+}
+
+function checkZoom(event)
+{
+    check(event, 19);
+}
+
+function checkZoomScroll(event)
+{
+    check(event, 64);
+}
+
+function zoomPageIn()
+{
+    if (window.eventSender) {
+        eventSender.zoomPageIn();
+    }
+}
+
+function zoomPageOut()
+{
+    if (window.eventSender) {
+        eventSender.zoomPageOut();
+    }
+}
+
+function scrollPage(x, y)
+{
+    window.scrollTo(x, y);
+}
+
+onload = function()
+{
+    if (!window.layoutTestController)
+        return;
+    
+    layoutTestController.dumpAsText();
+
+    // Base.
+    window.addEventListener("click", checkBase, false);
+    sendClick();
+    window.removeEventListener("click", checkBase, false);
+
+    // Scroll.
+    window.addEventListener("click", checkScroll, false);
+    scrollPage(50, 50);
+    sendClick();
+    scrollPage(0, 0);
+    window.removeEventListener("click", checkScroll, false);
+
+    // Zoom.
+    window.addEventListener("click", checkZoom, false);
+    zoomPageIn(); zoomPageIn(); zoomPageIn();
+    sendClick();
+    zoomPageOut(); zoomPageOut(); zoomPageOut();
+    window.removeEventListener("click", checkZoom, false);
+
+    // Scroll and Zoom.
+    window.addEventListener("click", checkZoomScroll, false);
+    zoomPageIn(); zoomPageIn(); zoomPageIn();
+    scrollPage(50, 50);
+    sendClick();
+    zoomPageOut(); zoomPageOut(); zoomPageOut();
+    scrollPage(0, 0);
+    window.removeEventListener("click", checkZoomScroll, false);
+}
+</SCRIPT>
+</HEAD>
+<BODY style="width: 100px; height: 100px" >
+<P id="first">This is to test document.caretRangeFromPoint() in a zoom and scrolled page. The point calculation in caretRangeFromPoint() is wrong in a zoom and scrolled page. <span id="same">Same applies to elementFromPoint(). 
+</P>
+<P id="second">In a window large enough to hold the page without any scroll, click mouse after "S" in "Same" at the above sentence, observe the printed offset.
+</P>
+<P id="third">Now, please resize the window to make the page scroll. Then, scroll the page. Click the mouse after "S" in "Same", observe the printed offset.
+</P>
+<BR id="fourth"><BR>Result: <SPAN ID="mySpan" STYLE="font-weight:bold"></SPAN>".
+<ul id="console"></ul>
+</BODY>
+</HTML>
diff --git a/LayoutTests/fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport-expected.txt b/LayoutTests/fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport-expected.txt
index efdd5dc..eb8f256 100644
--- a/LayoutTests/fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport-expected.txt
+++ b/LayoutTests/fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport-expected.txt
@@ -24,11 +24,11 @@ PASS Range.startOffset check (got 14, expected 14)
 PASS Range.startContainer check (got [object Text], expected [object Text])
 PASS Range.startOffset check (got 1, expected 1)
 PASS Range.startContainer check (got [object Text], expected [object Text])
-PASS Range.startOffset check (got 7, expected 7)
+PASS Range.startOffset check (got 13, expected 13)
 PASS Range.startContainer check (got [object Text], expected [object Text])
-PASS Range.startOffset check (got 3, expected 3)
+PASS Range.startOffset check (got 4, expected 4)
 PASS Range.startContainer check (got [object Text], expected [object Text])
-PASS Range.startOffset check (got 9, expected 9)
+PASS Range.startOffset check (got 16, expected 16)
  
 PASS successfullyParsed is true
 
diff --git a/LayoutTests/fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport.html b/LayoutTests/fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport.html
index fb21659..d875e99 100644
--- a/LayoutTests/fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport.html
+++ b/LayoutTests/fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport.html
@@ -66,9 +66,9 @@
 
         if (zoomOrNot == "zoom") {
             test(1, 0, 0);
-            test(7, 0, 25);
-            test(3, 50, 0);
-            test(9, 50, 25);
+            test(13, 0, 25);
+            test(4, 50, 0);
+            test(16, 50, 25);
         } else {
             test(0, 0, 0);
             test(12, 0, 25);
diff --git a/LayoutTests/fast/dom/elementFromPoint-relative-to-viewport-expected.txt b/LayoutTests/fast/dom/elementFromPoint-relative-to-viewport-expected.txt
index add9c17..4c4b902 100644
--- a/LayoutTests/fast/dom/elementFromPoint-relative-to-viewport-expected.txt
+++ b/LayoutTests/fast/dom/elementFromPoint-relative-to-viewport-expected.txt
@@ -13,8 +13,8 @@ PASS scrolledRightBoxOffscreen is '3'
 PASS scrolledDownAndRightBoxOffscreen is '8'
 PASS unscrolledBoxInitial is '0'
 PASS scrolledDownBoxInitial is '5'
-PASS scrolledRightBoxInitial is '2'
-PASS scrolledDownAndRightBoxInitial is '7'
+PASS scrolledRightBoxInitial is '3'
+PASS scrolledDownAndRightBoxInitial is '8'
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/fast/dom/elementFromPoint-relative-to-viewport.html b/LayoutTests/fast/dom/elementFromPoint-relative-to-viewport.html
index c173699..bb61725 100644
--- a/LayoutTests/fast/dom/elementFromPoint-relative-to-viewport.html
+++ b/LayoutTests/fast/dom/elementFromPoint-relative-to-viewport.html
@@ -82,8 +82,8 @@
         shouldBe(unscrolledBox, "'0'");
         shouldBe(scrolledDownBox, "'5'");
         if (zoomOrNot == "zoom") {
-            shouldBe(scrolledRightBox, "'2'");
-            shouldBe(scrolledDownAndRightBox, "'7'");
+            shouldBe(scrolledRightBox, "'3'");
+            shouldBe(scrolledDownAndRightBox, "'8'");
         } else {
             shouldBe(scrolledRightBox, "'3'");
             shouldBe(scrolledDownAndRightBox, "'8'");
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d0cbe32..79472de 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2009-10-23  Xiaomei Ji  <xji at chromium.org>
+
+        Reviewed by Sam Weinig.
+
+        Fix caretRangeFromPoint()/elementFromPoint() returns wrong result 
+        for a zoomed and scrolled page.
+        https://bugs.webkit.org/show_bug.cgi?id=30689.
+
+        The real cause is the wrong calculation of event.clientX/Y when
+        page is zoomed and scolled.
+        After Sam fixed the event.clientX/Y in r49551, the hit test point
+        should be recalculated (revert r49490).
+
+        Test: fast/dom/Document/CaretRangeFromPoint/caretRangeFromPoint-in-zoom-and-scroll.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::elementFromPoint): calculate the correct point
+        relative to document when page is zoomed and scrolled.
+        (WebCore::Document::caretRangeFromPoint): calculate the correct point
+        relative to document when page is zoomed and scrolled.
+
 2009-10-22  Dumitru Daniliuc  <dumi at chromium.org>
 
         Reviewed by Dmitry Titov.
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 5505871..5cf9140 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -951,7 +951,7 @@ Element* Document::elementFromPoint(int x, int y) const
         return 0;
 
     float zoomFactor = frame->pageZoomFactor();
-    IntPoint point = roundedIntPoint(FloatPoint((x + view()->scrollX()) * zoomFactor, (y + view()->scrollY()) * zoomFactor));
+    IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor  + view()->scrollX(), y * zoomFactor + view()->scrollY()));
 
     if (!frameView->visibleContentRect().contains(point))
         return 0;
@@ -981,7 +981,7 @@ PassRefPtr<Range> Document::caretRangeFromPoint(int x, int y)
         return 0;
 
     float zoomFactor = frame->pageZoomFactor();
-    IntPoint point = roundedIntPoint(FloatPoint((x + view()->scrollX()) * zoomFactor, (y + view()->scrollY()) * zoomFactor));
+    IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor + view()->scrollX(), y * zoomFactor + view()->scrollY()));
 
     if (!frameView->visibleContentRect().contains(point))
         return 0;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list