[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

tonikitoo at webkit.org tonikitoo at webkit.org
Wed Dec 22 13:50:24 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 6e7483d9566f02a3fbad60a10509887747bba11c
Author: tonikitoo at webkit.org <tonikitoo at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Sep 28 02:28:25 2010 +0000

    Make Document::nodesFromRect more flexible
    https://bugs.webkit.org/show_bug.cgi?id=46336
    
    Patch by Antonio Gomes <agomes at rim.com> on 2010-09-23
    Reviewed by Kenneth Christiansen.
    
    The patch changes the API for the Document::nodesFromRect() method as follows:
    
    from
    - RefPtf<NodeList> nodesFromRect(int x, int y, unsigned horizontalPadding, unsigned verticalPadding, bool ignoreClipping)
    
    to
    - RefPtf<NodeList> nodesFromRect(int x, int y, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding,
                                     unsigned leftPadding, bool ignoreClipping)
    
    Previously the method was receiving as parameter horizontal and vertical padding values.
    In practice, the horizontal padding was being used to expand a given center point in both
    right and left directions, while vertical padding was expanding it to the top and bottom directions.
    
    Although this design makes it possible to improve the touch experience on mobile devices
    (Document::nodesFromRect exposes the rect based hit testing system), empirical experiments
    showed that, specially in capacitive touch screens, users tend to tap below elements. So
    for even more accurate results (which means here the possibility of pleasant tapping experience),
    it makes sense to use a region that is offset more above the touch point, favoring elements
    above the touch point.
    
    The patch basically implements that, increasing the API flexible and power by making it possible
    to specify different padding values for each direction in a given orientation.
    
    Changes were made accordingly to the HitTestResult, RenderLayer, RenderImage and RenderLineBoxList
    classes.
    
    WebCore:
    
    * WebCore.exp.in:
    * dom/Document.cpp:
    (WebCore::Document::nodesFromRect):
    * dom/Document.h:
    * page/EventHandler.cpp:
    (WebCore::EventHandler::hitTestResultAtPoint): For simplicity, I did not change the signature
        but the way the padding value passed in as parameter is being used to construct a HitTestResult.
    * rendering/HitTestResult.cpp: Changed the rect-based bits from using IntSize (padding) to separated paddings
        for each direction.
    (WebCore::HitTestResult::HitTestResult): Ditto.
    (WebCore::HitTestResult::operator=): Ditto.
    (WebCore::HitTestResult::rectFromPoint): Ditton.
    * rendering/HitTestResult.h:
    (WebCore::HitTestResult::topPadding): getter for the top padding.
    (WebCore::HitTestResult::rightPadding): getter for the right padding.
    (WebCore::HitTestResult::bottomPadding): getter for the bottom padding.
    (WebCore::HitTestResult::leftPadding): getter for the left padding.
    (WebCore::HitTestResult::rectFromPoint): Added a static method that given a center point and padding values for
        each direction, returns the rect that is going to be used in WebCore's hit testing processing.
    * rendering/RenderImage.cpp: Changed the rect-based bits from using IntSize (padding) to separated paddings for each direction.
    (WebCore::RenderImage::nodeAtPoint): Ditto.
    * rendering/RenderLayer.cpp: Ditto.
    (WebCore::RenderLayer::hitTestLayer): Ditto.
    (WebCore::RenderLayer::hitTestList): Ditto.
    * rendering/RenderLineBoxList.cpp: Ditto.
    (WebCore::RenderLineBoxList::hitTest): Ditto.
    
    LayoutTests:
    
    * fast/dom/nodesFromRect-basic-expected.txt:
    * fast/dom/nodesFromRect-basic.html:
    * fast/dom/resources/nodesFromRect.js:
    (check):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68475 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index fc8d570..b3a563f 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-09-23  Antonio Gomes  <agomes at rim.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Make Document::nodesFromRect more flexible
+        https://bugs.webkit.org/show_bug.cgi?id=46336
+
+        Tests basically adjusted to the new API.
+
+        * fast/dom/nodesFromRect-basic-expected.txt:
+        * fast/dom/nodesFromRect-basic.html:
+        * fast/dom/resources/nodesFromRect.js:
+        (check):
+
 2010-09-27  MORITA Hajime  <morrita at google.com>
 
         Unreviewed, added missing expectations.
diff --git a/LayoutTests/fast/dom/nodesFromRect-basic-expected.txt b/LayoutTests/fast/dom/nodesFromRect-basic-expected.txt
index 89f1ea3..45915fe 100644
--- a/LayoutTests/fast/dom/nodesFromRect-basic-expected.txt
+++ b/LayoutTests/fast/dom/nodesFromRect-basic-expected.txt
@@ -1,26 +1,26 @@
 PASS successfullyParsed is true
 
 TEST COMPLETE
-PASS All correct nodes found for rect [53,71], [0,0]
-PASS All correct nodes found for rect [53,71], [10,0]
-PASS All correct nodes found for rect [53,71], [0,10]
-PASS All correct nodes found for rect [53,71], [10,10]
-PASS All correct nodes found for rect [152,105], [0,10]
-PASS All correct nodes found for rect [152,105], [10,0]
-PASS All correct nodes found for rect [152,105], [10,10]
-PASS All correct nodes found for rect [153,193], [0,0]
-PASS All correct nodes found for rect [153,193], [20,0]
-PASS All correct nodes found for rect [153,193], [0,20]
-PASS All correct nodes found for rect [144,183], [0,0]
-PASS All correct nodes found for rect [144,183], [0,1]
-PASS All correct nodes found for rect [144,183], [1,0]
-PASS All correct nodes found for rect [144,183], [1,1]
-PASS All correct nodes found for rect [77,240], [0,0]
-PASS All correct nodes found for rect [77,240], [10,0]
-PASS All correct nodes found for rect [77,240], [0,10]
-PASS All correct nodes found for rect [77,240], [10,10]
-PASS All correct nodes found for rect [39,212], [0,0]
-PASS All correct nodes found for rect [39,212], [0,10]
-PASS All correct nodes found for rect [39,212], [10,0]
-PASS All correct nodes found for rect [39,212], [10,10]
+PASS All correct nodes found for rect [53,71], [0,0,0,0]
+PASS All correct nodes found for rect [53,71], [0,10,0,10]
+PASS All correct nodes found for rect [53,71], [10,0,10,0]
+PASS All correct nodes found for rect [53,71], [10,10,10,10]
+PASS All correct nodes found for rect [152,105], [10,0,10,0]
+PASS All correct nodes found for rect [152,105], [0,10,0,10]
+PASS All correct nodes found for rect [152,105], [10,10,10,10]
+PASS All correct nodes found for rect [153,193], [0,0,0,0]
+PASS All correct nodes found for rect [153,193], [0,20,0,20]
+PASS All correct nodes found for rect [153,193], [20,0,20,0]
+PASS All correct nodes found for rect [144,183], [0,0,0,0]
+PASS All correct nodes found for rect [144,183], [1,0,1,0]
+PASS All correct nodes found for rect [144,183], [0,1,0,1]
+PASS All correct nodes found for rect [144,183], [1,1,1,1]
+PASS All correct nodes found for rect [77,240], [0,0,0,0]
+PASS All correct nodes found for rect [77,240], [0,10,0,10]
+PASS All correct nodes found for rect [77,240], [10,0,10,0]
+PASS All correct nodes found for rect [77,240], [10,10,10,10]
+PASS All correct nodes found for rect [39,212], [0,0,0,0]
+PASS All correct nodes found for rect [39,212], [10,0,10,0]
+PASS All correct nodes found for rect [39,212], [0,10,0,10]
+PASS All correct nodes found for rect [39,212], [10,10,10,10]
 
diff --git a/LayoutTests/fast/dom/nodesFromRect-basic.html b/LayoutTests/fast/dom/nodesFromRect-basic.html
index 6a4064a..2b43c65 100644
--- a/LayoutTests/fast/dom/nodesFromRect-basic.html
+++ b/LayoutTests/fast/dom/nodesFromRect-basic.html
@@ -22,37 +22,37 @@
 
       window.scrollTo(0, 0);
 
-      check(53, 71, 0, 0, [e.body]);
-      check(53, 71, 10, 0, [e.p3, e.body]);
-      check(53, 71, 0, 10, [e.d1, e.h1, e.body]);
-      check(53, 71, 10, 10, [e.p3, e.d1, e.h1, e.body]);
+      check(53, 71, 0, 0, 0, 0, [e.body]);
+      check(53, 71, 0, 10, 0, 10, [e.p3, e.body]);
+      check(53, 71, 10, 0, 10, 0, [e.d1, e.h1, e.body]);
+      check(53, 71, 10, 10, 10, 10, [e.p3, e.d1, e.h1, e.body]);
 
-      check(152, 105, 0, 10, [e.p3, e.body]);
-      check(152, 105, 10, 0, [e.p4, e.d1, e.body]);
-      check(152, 105, 10, 10, [e.p4, e.p3, e.d1, e.body]);
+      check(152, 105, 10, 0, 10, 0, [e.p3, e.body]);
+      check(152, 105, 0, 10, 0, 10, [e.p4, e.d1, e.body]);
+      check(152, 105, 10, 10, 10, 10, [e.p4, e.p3, e.d1, e.body]);
 
       // e.p1 is invisible and shouldn't appear:
-      check(153,193,0,0,[e.p5]);
+      check(153, 193, 0, 0, 0, 0, [e.p5]);
       // NOTE: [e.p5, e.d2]) should be returned if we did not stop
       // at e.p5, which fully encloses the target rect.
-      check(153,193,20,0, [e.p5]);
-      check(153,193,0,20, [e.p5, e.body]);
+      check(153,193,0, 20, 0, 20, [e.p5]);
+      check(153,193,20, 0, 20, 0, [e.p5, e.body]);
 
       // Precise pixel checks:
-      check(144, 183, 0, 0, [e.body]);
-      check(144, 183, 0, 1, [e.p5, e.body]);
-      check(144, 183, 1, 0, [e.d2, e.body]);
-      check(144, 183, 1, 1, [e.p5, e.d2, e.body]);
-      check(77, 240, 0, 0, [e.p2]);
-      check(77, 240, 10, 0, [e.p2]);
-      check(77, 240, 0, 10, [e.p5, e.span, e.p2]);
-      check(77, 240, 10, 10, [e.p5, e.span, e.p2]);
+      check(144, 183, 0, 0, 0, 0, [e.body]);
+      check(144, 183, 1, 0, 1, 0, [e.p5, e.body]);
+      check(144, 183, 0, 1, 0, 1, [e.d2, e.body]);
+      check(144, 183, 1, 1, 1, 1, [e.p5, e.d2, e.body]);
+      check(77, 240, 0, 0, 0, 0, [e.p2]);
+      check(77, 240, 0, 10, 0, 10, [e.p2]);
+      check(77, 240, 10, 0, 10, 0, [e.p5, e.span, e.p2]);
+      check(77, 240, 10, 10, 10, 10, [e.p5, e.span, e.p2]);
 
       // Expanding area checks:
-      check(39, 212, 0,  0, [e.body]);
-      check(39, 212, 0, 10, [e.d2, e.p2, e.body]);
-      check(39, 212, 10, 0, [e.p5, e.body]);
-      check(39, 212, 10, 10, [e.p5, e.d2, e.p2, e.body]);
+      check(39, 212, 0,  0, 0, 0, [e.body]);
+      check(39, 212, 10, 0, 10, 0, [e.d2, e.p2, e.body]);
+      check(39, 212, 0, 10, 0, 10, [e.p5, e.body]);
+      check(39, 212, 10, 10, 10, 10, [e.p5, e.d2, e.p2, e.body]);
 
       if (window.layoutTestController)
         layoutTestController.notifyDone();
diff --git a/LayoutTests/fast/dom/resources/nodesFromRect.js b/LayoutTests/fast/dom/resources/nodesFromRect.js
index 0671639..42d7f9b 100644
--- a/LayoutTests/fast/dom/resources/nodesFromRect.js
+++ b/LayoutTests/fast/dom/resources/nodesFromRect.js
@@ -3,19 +3,21 @@
  *     * Antonio Gomes <tonikitoo at webkit.org>
  **/
 
-function check(x, y, hPadding, vPadding, list)
+function check(x, y, topPadding, rightPadding, bottomPadding, leftPadding, list)
 {
   if (!window.layoutTestController)
     return;
 
-  var nodes = layoutTestController.nodesFromRect(document, x, y, hPadding, vPadding, true /* ignoreClipping */);
+  var nodes = layoutTestController.nodesFromRect(document, x, y, topPadding, rightPadding, bottomPadding, leftPadding, true /* ignoreClipping */);
   if (!nodes)
     return;
 
   if (nodes.length != list.length) {
     testFailed("Different number of nodes for rect" +
               "[" + x + "," + y + "], " +
-              "[" + hPadding + "," + vPadding + "]: '" + list.length + "' vs '" + nodes.length + "'");
+              "[" + topPadding + "," + rightPadding +
+              "," + bottomPadding + "," + leftPadding +
+              "]: '" + list.length + "' vs '" + nodes.length + "'");
     return;
   }
 
@@ -23,14 +25,16 @@ function check(x, y, hPadding, vPadding, list)
     if (nodes[i] != list[i]) {
       testFailed("Unexpected node #" + i + " for rect " +
                 "[" + x + "," + y + "], " +
-                "[" + hPadding + "," + vPadding + "]" + " - " + nodes[i]);
+                "[" + topPadding + "," + rightPadding +
+                "," + bottomPadding + "," + leftPadding + "]" + " - " + nodes[i]);
       return;
     }
   }
 
   testPassed("All correct nodes found for rect "  +
-           "[" + x + "," + y + "], " +
-           "[" + hPadding + "," + vPadding + "]");
+             "[" + x + "," + y + "], " +
+             "[" + topPadding + "," + rightPadding +
+             "," + bottomPadding + "," + leftPadding + "]");
 }
 
 function getCenterFor(element)
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 160b7d2..c9ad757 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,64 @@
+2010-09-23  Antonio Gomes  <agomes at rim.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Make Document::nodesFromRect more flexible
+        https://bugs.webkit.org/show_bug.cgi?id=46336
+
+        The patch changes the API for the Document::nodesFromRect() method as follows:
+        
+        from
+        - RefPtf<NodeList> nodesFromRect(int x, int y, unsigned horizontalPadding, unsigned verticalPadding, bool ignoreClipping)
+        to
+        - RefPtf<NodeList> nodesFromRect(int x, int y, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding,
+                                         unsigned leftPadding, bool ignoreClipping)
+
+        Previously the method was receiving as parameter horizontal and vertical padding values.
+        In practice, the horizontal padding was being used to expand a given center point in both
+        right and left directions, while vertical padding was expanding it to the top and bottom directions.
+
+        Although this design makes it possible to improve the touch experience on mobile devices
+        (Document::nodesFromRect exposes the rect based hit testing system), empirical experiments
+        showed that, specially in capacitive touch screens, users tend to tap below elements. So
+        for even more accurate results (which means here the possibility of pleasant tapping experience),
+        it makes sense to use a region that is offset more above the touch point, favoring elements
+        above the touch point.
+
+        The patch basically implements that, increasing the API flexible and power by making it possible
+        to specify different padding values for each direction in a given orientation.
+
+        Changes were made accordingly to the HitTestResult, RenderLayer, RenderImage and RenderLineBoxList
+        classes.
+
+        WebCore:
+
+        * WebCore.exp.in:
+        * dom/Document.h: API adjustment.
+        * dom/Document.idl: Ditto.
+        * dom/Document.cpp: API adjustment and method body implementation accordingly.
+        (WebCore::Document::nodesFromRect):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::hitTestResultAtPoint): For simplicity, I did not change the signature
+            but the way the padding value passed in as parameter is being used to construct a HitTestResult.
+        * rendering/HitTestResult.cpp: Changed the rect-based bits from using IntSize (padding) to separated paddings for each direction.
+        (WebCore::HitTestResult::HitTestResult): Ditto.
+        (WebCore::HitTestResult::operator=): Ditto.
+        (WebCore::HitTestResult::rectFromPoint): Ditto.
+        * rendering/HitTestResult.h:
+        (WebCore::HitTestResult::topPadding): getter for the top padding.
+        (WebCore::HitTestResult::rightPadding): getter for the right padding.
+        (WebCore::HitTestResult::bottomPadding): getter for the bottom padding.
+        (WebCore::HitTestResult::leftPadding): getter for the left padding.
+        (WebCore::HitTestResult::rectFromPoint): Added a static method that given a center point and padding values for each direction,
+            returns the rect that is going to be used in WebCore's hit testing processing.
+        * rendering/RenderImage.cpp: Changed the rect-based bits from using IntSize (padding) to separated paddings for each direction.
+        (WebCore::RenderImage::nodeAtPoint): Ditto.
+        * rendering/RenderLayer.cpp: Ditto.
+        (WebCore::RenderLayer::hitTestLayer): Ditto.
+        (WebCore::RenderLayer::hitTestList): Ditto.
+        * rendering/RenderLineBoxList.cpp: Ditto.
+        (WebCore::RenderLineBoxList::hitTest): Ditto.
+
 2010-09-27  Chris Rogers  <crogers at google.com>
 
         Reviewed by James Robinson.
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index ebf1cc3..5357958 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -492,7 +492,6 @@ __ZN7WebCore26contextMenuItemTagFontMenuEv
 __ZN7WebCore26contextMenuItemTagOpenLinkEv
 __ZN7WebCore26usesTestModeFocusRingColorEv
 __ZN7WebCore27CSSComputedStyleDeclarationC1EN3WTF10PassRefPtrINS_4NodeEEEbRKNS1_6StringE
-__ZNK7WebCore8Document13nodesFromRectEiijjb
 __ZN7WebCore27DeviceOrientationClientMock14setOrientationEN3WTF10PassRefPtrINS_17DeviceOrientationEEE
 __ZN7WebCore27DeviceOrientationClientMockC1Ev
 __ZN7WebCore27applicationIsAdobeInstallerEv
@@ -689,6 +688,7 @@ __ZN7WebCore8Document26pageSizeAndMarginsInPixelsEiRNS_7IntSizeERiS3_S3_S3_
 __ZN7WebCore8Document27removeMediaCanStartListenerEPNS_21MediaCanStartListenerE
 __ZN7WebCore8Document36updateLayoutIgnorePendingStylesheetsEv
 __ZN7WebCore8Document4headEv
+__ZNK7WebCore8Document13nodesFromRectEiijjjjb
 __ZN7WebCore10JSDocument6s_infoE
 __ZN7WebCore8FormData6createEPKvm
 __ZN7WebCore8FormDataD1Ev
@@ -923,6 +923,7 @@ __ZNK7WebCore13HitTestResult18titleDisplayStringEv
 __ZNK7WebCore13HitTestResult5imageEv
 __ZNK7WebCore13HitTestResult5titleERNS_13TextDirectionE
 __ZNK7WebCore13HitTestResult9imageRectEv
+__ZN7WebCore13HitTestResult13rectFromPointERKNS_8IntPointEjjjj
 __ZNK7WebCore13ResourceErrorcvP7NSErrorEv
 __ZNK7WebCore14DocumentLoader10requestURLEv
 __ZNK7WebCore14DocumentLoader11frameLoaderEv
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 6ae41f6..0bda797 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -1048,7 +1048,7 @@ KURL Document::baseURI() const
 // * making it receive a rect as parameter, i.e. nodesFromRect(x, y, w, h);
 // * making it receive the expading size of each direction separately,
 //   i.e. nodesFromRect(x, y, topSize, rightSize, bottomSize, leftSize);
-PassRefPtr<NodeList> Document::nodesFromRect(int centerX, int centerY, unsigned hPadding, unsigned vPadding, bool ignoreClipping) const
+PassRefPtr<NodeList> Document::nodesFromRect(int centerX, int centerY, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping) const
 {
     // FIXME: Share code between this, elementFromPoint and caretRangeFromPoint.
     if (!renderer())
@@ -1062,26 +1062,25 @@ PassRefPtr<NodeList> Document::nodesFromRect(int centerX, int centerY, unsigned
 
     float zoomFactor = frame->pageZoomFactor();
     IntPoint point = roundedIntPoint(FloatPoint(centerX * zoomFactor + view()->scrollX(), centerY * zoomFactor + view()->scrollY()));
-    IntSize padding(hPadding, vPadding);
 
     int type = HitTestRequest::ReadOnly | HitTestRequest::Active;
 
     // When ignoreClipping is false, this method returns null for coordinates outside of the viewport.
     if (ignoreClipping)
         type |= HitTestRequest::IgnoreClipping;
-    else if (!frameView->visibleContentRect().intersects(IntRect(point, padding)))
+    else if (!frameView->visibleContentRect().intersects(HitTestResult::rectFromPoint(point, topPadding, rightPadding, bottomPadding, leftPadding)))
         return 0;
 
     HitTestRequest request(type);
 
     // Passing a zero padding will trigger a rect hit test, however for the purposes of nodesFromRect,
     // we special handle this case in order to return a valid NodeList.
-    if (padding.isZero()) {
+    if (!topPadding && !rightPadding && !bottomPadding && !leftPadding) {
         HitTestResult result(point);
         return handleZeroPadding(request, result);
     }
 
-    HitTestResult result(point, padding);
+    HitTestResult result(point, topPadding, rightPadding, bottomPadding, leftPadding);
     renderView()->layer()->hitTest(request, result);
 
     return StaticHashSetNodeList::adopt(result.rectBasedTestResult());
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h
index 1ad7ecd..d5021af 100644
--- a/WebCore/dom/Document.h
+++ b/WebCore/dom/Document.h
@@ -308,7 +308,7 @@ public:
 
     /**
      * Retrieve all nodes that intersect a rect in the window's document, until it is fully enclosed by
-     * the boundaries of node.
+     * the boundaries of a node.
      *
      * @param centerX x reference for the rectangle in CSS pixels
      * @param centerY y reference for the rectangle in CSS pixels
@@ -317,7 +317,8 @@ public:
      * @param ignoreClipping whether or not to ignore the root scroll frame when retrieving the element.
      *        If false, this method returns null for coordinates outside of the viewport.
      */
-    PassRefPtr<NodeList> nodesFromRect(int centerX, int centerY, unsigned hPadding, unsigned vPadding, bool ignoreClipping) const;
+    PassRefPtr<NodeList> nodesFromRect(int centerX, int centerY, unsigned topPadding, unsigned rightPadding,
+                                       unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping) const;
     Element* elementFromPoint(int x, int y) const;
     PassRefPtr<Range> caretRangeFromPoint(int x, int y);
 
diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp
index 8932e5f..d3709fb 100644
--- a/WebCore/page/EventHandler.cpp
+++ b/WebCore/page/EventHandler.cpp
@@ -866,7 +866,7 @@ void EventHandler::allowDHTMLDrag(bool& flagDHTML, bool& flagUA) const
     
 HitTestResult EventHandler::hitTestResultAtPoint(const IntPoint& point, bool allowShadowContent, bool ignoreClipping, HitTestScrollbars testScrollbars, HitTestRequest::HitTestRequestType hitType, const IntSize& padding)
 {
-    HitTestResult result(point, padding);
+    HitTestResult result(point, padding.height(), padding.width(), padding.height(), padding.width());
     if (!m_frame->contentRenderer())
         return result;
     if (ignoreClipping)
@@ -887,7 +887,7 @@ HitTestResult EventHandler::hitTestResultAtPoint(const IntPoint& point, bool all
         FrameView* view = static_cast<FrameView*>(widget);
         IntPoint widgetPoint(result.localPoint().x() + view->scrollX() - renderWidget->borderLeft() - renderWidget->paddingLeft(), 
             result.localPoint().y() + view->scrollY() - renderWidget->borderTop() - renderWidget->paddingTop());
-        HitTestResult widgetHitTestResult(widgetPoint, padding);
+        HitTestResult widgetHitTestResult(widgetPoint, padding.height(), padding.width(), padding.height(), padding.width());
         frame->contentRenderer()->layer()->hitTest(HitTestRequest(hitType), widgetHitTestResult);
         result = widgetHitTestResult;
 
diff --git a/WebCore/rendering/HitTestResult.cpp b/WebCore/rendering/HitTestResult.cpp
index f28692e..35a6d23 100644
--- a/WebCore/rendering/HitTestResult.cpp
+++ b/WebCore/rendering/HitTestResult.cpp
@@ -51,17 +51,27 @@ HitTestResult::HitTestResult(const IntPoint& point)
     : m_point(point)
     , m_isOverWidget(false)
     , m_isRectBased(false)
+    , m_topPadding(0)
+    , m_rightPadding(0)
+    , m_bottomPadding(0)
+    , m_leftPadding(0)
 {
 }
 
-HitTestResult::HitTestResult(const IntPoint& centerPoint, const IntSize& padding)
+HitTestResult::HitTestResult(const IntPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
     : m_point(centerPoint)
     , m_isOverWidget(false)
+    , m_topPadding(topPadding)
+    , m_rightPadding(rightPadding)
+    , m_bottomPadding(bottomPadding)
+    , m_leftPadding(leftPadding)
 {
-    // If a zero padding is passed in or either width or height is negative, then it
-    // is not a valid padding and hence not a rect based hit test.
-    m_isRectBased = !(padding.isZero() || (padding.width() < 0 || padding.height() < 0));
-    m_padding = m_isRectBased ? padding : IntSize();
+    // If all padding values passed in are zero then it is not a rect based hit test.
+    m_isRectBased = topPadding || rightPadding || bottomPadding || leftPadding;
+
+    // Make sure all padding values are clamped to zero if it is not a rect hit test.
+    if (!m_isRectBased)
+        m_topPadding = m_rightPadding = m_bottomPadding = m_leftPadding = 0;
 }
 
 HitTestResult::HitTestResult(const HitTestResult& other)
@@ -76,9 +86,13 @@ HitTestResult::HitTestResult(const HitTestResult& other)
     // Only copy the padding and ListHashSet in case of rect hit test.
     // Copying the later is rather expensive.
     if ((m_isRectBased = other.isRectBasedTest())) {
-        m_padding = other.padding();
+        m_topPadding = other.m_topPadding;
+        m_rightPadding = other.m_rightPadding;
+        m_bottomPadding = other.m_bottomPadding;
+        m_leftPadding = other.m_leftPadding;
         m_rectBasedTestResult = other.rectBasedTestResult();
-    }
+    } else
+        m_topPadding = m_rightPadding = m_bottomPadding = m_leftPadding = 0;
 }
 
 HitTestResult::~HitTestResult()
@@ -97,9 +111,13 @@ HitTestResult& HitTestResult::operator=(const HitTestResult& other)
     // Only copy the padding and ListHashSet in case of rect hit test.
     // Copying the later is rather expensive.
     if ((m_isRectBased = other.isRectBasedTest())) {
-        m_padding = other.padding();
+        m_topPadding = other.m_topPadding;
+        m_rightPadding = other.m_rightPadding;
+        m_bottomPadding = other.m_bottomPadding;
+        m_leftPadding = other.m_leftPadding;
         m_rectBasedTestResult = other.rectBasedTestResult();
-    }
+    } else
+        m_topPadding = m_rightPadding = m_bottomPadding = m_leftPadding = 0;
     return *this;
 }
 
@@ -534,4 +552,16 @@ void HitTestResult::append(const HitTestResult& other)
         m_rectBasedTestResult.add(it->get());
 }
 
+IntRect HitTestResult::rectFromPoint(const IntPoint& point, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
+{
+    IntPoint actualPoint(point);
+    actualPoint -= IntSize(leftPadding, topPadding);
+
+    IntSize actualPadding(leftPadding + rightPadding, topPadding + bottomPadding);
+    // As IntRect is left inclusive and right exclusive (seeing IntRect::contains(x, y)), adding "1".
+    actualPadding += IntSize(1, 1);
+
+    return IntRect(actualPoint, actualPadding);
+}
+
 } // namespace WebCore
diff --git a/WebCore/rendering/HitTestResult.h b/WebCore/rendering/HitTestResult.h
index 31e88f1..1304e22 100644
--- a/WebCore/rendering/HitTestResult.h
+++ b/WebCore/rendering/HitTestResult.h
@@ -44,8 +44,8 @@ class Scrollbar;
 class HitTestResult {
 public:
     HitTestResult(const IntPoint&);
-    // Pass a non-negative IntSize value as padding to perform a rect-based hit test.
-    HitTestResult(const IntPoint& centerPoint, const IntSize& padding);
+    // Pass non-negative padding values to perform a rect-based hit test.
+    HitTestResult(const IntPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
     HitTestResult(const HitTestResult&);
     ~HitTestResult();
     HitTestResult& operator=(const HitTestResult&);
@@ -100,9 +100,12 @@ public:
     bool isRectBasedTest() const { return m_isRectBased; }
     IntRect rectFromPoint(int x, int y) const;
     IntRect rectFromPoint(const IntPoint&) const;
-    IntSize padding() const { return m_padding; }
-    int paddingWidth() const { return m_padding.width(); }
-    int paddingHeight() const { return m_padding.height(); }
+    static IntRect rectFromPoint(const IntPoint&, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
+    int topPadding() const { return m_topPadding; }
+    int rightPadding() const { return m_rightPadding; }
+    int bottomPadding() const { return m_bottomPadding; }
+    int leftPadding() const { return m_leftPadding; }
+
     // Returns true if it is rect-based hit test and needs to continue until the rect is fully
     // enclosed by the boundaries of a node.
     bool addNodeToRectBasedTestResult(Node*, int x, int y, const IntRect& rect = IntRect());
@@ -124,34 +127,26 @@ private:
     RefPtr<Scrollbar> m_scrollbar;
     bool m_isOverWidget; // Returns true if we are over a widget (and not in the border/padding area of a RenderWidget for example).
     bool m_isRectBased;
-    IntSize m_padding;
+    int m_topPadding;
+    int m_rightPadding;
+    int m_bottomPadding;
+    int m_leftPadding;
     ListHashSet<RefPtr<Node> > m_rectBasedTestResult;
 };
 
 inline IntRect HitTestResult::rectFromPoint(int x, int y) const
 {
-    return rectFromPoint(IntPoint(x, y));
+    return rectFromPoint(IntPoint(x, y), m_topPadding, m_rightPadding, m_bottomPadding, m_leftPadding);
 }
 
 // Formula:
-// x = p.x() - padding.width()
-// y = p.y() - padding.height()
-// width = 2 * padding.width() + 1
-// height = 2 * m_padding.height() + 1
+// x = p.x() - rightPadding
+// y = p.y() - topPadding
+// width = leftPadding + rightPadding + 1
+// height = topPadding + bottomPadding + 1
 inline IntRect HitTestResult::rectFromPoint(const IntPoint& point) const
 {
-    IntPoint realPoint(point);
-    IntSize realPadding(m_padding);
-
-    // Real IntPoint for the rect.
-    realPadding.clampNegativeToZero();
-    realPoint -= realPadding;
-
-    // Real IntSize for the rect.
-    realPadding.scale(2);
-    realPadding += IntSize(1, 1);
-
-    return IntRect(realPoint, realPadding);
+    return rectFromPoint(point, m_topPadding, m_rightPadding, m_bottomPadding, m_leftPadding);
 }
 
 String displayString(const String&, const Node*);
diff --git a/WebCore/rendering/RenderImage.cpp b/WebCore/rendering/RenderImage.cpp
index 2bd60a3..a220ca2 100644
--- a/WebCore/rendering/RenderImage.cpp
+++ b/WebCore/rendering/RenderImage.cpp
@@ -359,7 +359,7 @@ HTMLMapElement* RenderImage::imageMap() const
 
 bool RenderImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction hitTestAction)
 {
-    HitTestResult tempResult(result.point(), result.padding());
+    HitTestResult tempResult(result.point(), result.topPadding(), result.rightPadding(), result.bottomPadding(), result.leftPadding());
     bool inside = RenderReplaced::nodeAtPoint(request, tempResult, x, y, tx, ty, hitTestAction);
 
     if (tempResult.innerNode() && node()) {
diff --git a/WebCore/rendering/RenderLayer.cpp b/WebCore/rendering/RenderLayer.cpp
index 14e2af8..1b4b1da 100644
--- a/WebCore/rendering/RenderLayer.cpp
+++ b/WebCore/rendering/RenderLayer.cpp
@@ -2901,7 +2901,7 @@ RenderLayer* RenderLayer::hitTestLayer(RenderLayer* rootLayer, RenderLayer* cont
     // Next we want to see if the mouse pos is inside the child RenderObjects of the layer.
     if (fgRect.intersects(hitTestArea) && isSelfPaintingLayer()) {
         // Hit test with a temporary HitTestResult, because we only want to commit to 'result' if we know we're frontmost.
-        HitTestResult tempResult(result.point(), result.padding());
+        HitTestResult tempResult(result.point(), result.topPadding(), result.rightPadding(), result.bottomPadding(), result.leftPadding());
         if (hitTestContents(request, tempResult, layerBounds, hitTestPoint, HitTestDescendants) &&
             isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTransformState.get())) {
             if (result.isRectBasedTest())
@@ -2930,7 +2930,7 @@ RenderLayer* RenderLayer::hitTestLayer(RenderLayer* rootLayer, RenderLayer* cont
         return candidateLayer;
 
     if (bgRect.intersects(hitTestArea) && isSelfPaintingLayer()) {
-        HitTestResult tempResult(result.point(), result.padding());
+        HitTestResult tempResult(result.point(), result.topPadding(), result.rightPadding(), result.bottomPadding(), result.leftPadding());
         if (hitTestContents(request, tempResult, layerBounds, hitTestPoint, HitTestSelf) &&
             isHitCandidate(this, false, zOffsetForContentsPtr, unflattenedTransformState.get())) {
             if (result.isRectBasedTest())
@@ -2987,7 +2987,7 @@ RenderLayer* RenderLayer::hitTestList(Vector<RenderLayer*>* list, RenderLayer* r
     for (int i = list->size() - 1; i >= 0; --i) {
         RenderLayer* childLayer = list->at(i);
         RenderLayer* hitLayer = 0;
-        HitTestResult tempResult(result.point(), result.padding());
+        HitTestResult tempResult(result.point(), result.topPadding(), result.rightPadding(), result.bottomPadding(), result.leftPadding());
         if (childLayer->isPaginated())
             hitLayer = hitTestPaginatedChildLayer(childLayer, rootLayer, request, tempResult, hitTestRect, hitTestPoint, transformState, zOffsetForDescendants);
         else
diff --git a/WebCore/rendering/RenderLineBoxList.cpp b/WebCore/rendering/RenderLineBoxList.cpp
index 45e66eb..760d2ea 100644
--- a/WebCore/rendering/RenderLineBoxList.cpp
+++ b/WebCore/rendering/RenderLineBoxList.cpp
@@ -246,16 +246,16 @@ bool RenderLineBoxList::hitTest(RenderBoxModelObject* renderer, const HitTestReq
     // contain the point.  This is a quick short-circuit that we can take to avoid walking any lines.
     // FIXME: This check is flawed in the following extremely obscure way:
     // if some line in the middle has a huge overflow, it might actually extend below the last line.
-    if (y - result.paddingHeight() >= ty + lastLineBox()->root()->bottomVisibleOverflow()
-     || y + result.paddingHeight() < ty + firstLineBox()->root()->topVisibleOverflow())
+    if (y - result.topPadding() >= ty + lastLineBox()->root()->bottomVisibleOverflow()
+     || y + result.bottomPadding() < ty + firstLineBox()->root()->topVisibleOverflow())
         return false;
 
     // See if our root lines contain the point.  If so, then we hit test
     // them further.  Note that boxes can easily overlap, so we can't make any assumptions
     // based off positions of our first line box or our last line box.
     for (InlineFlowBox* curr = lastLineBox(); curr; curr = curr->prevLineBox()) {
-        if (y + result.paddingHeight() >= ty + curr->root()->topVisibleOverflow()
-         && y - result.paddingHeight() < ty + curr->root()->bottomVisibleOverflow()) {
+        if (y + result.bottomPadding() >= ty + curr->root()->topVisibleOverflow()
+         && y - result.topPadding() < ty + curr->root()->bottomVisibleOverflow()) {
             bool inside = curr->nodeAtPoint(request, result, x, y, tx, ty);
             if (inside) {
                 renderer->updateHitTestResult(result, IntPoint(x - tx, y - ty));
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
index 1a0437a..1fca8d1 100644
--- a/WebKit/mac/WebView/WebView.mm
+++ b/WebKit/mac/WebView/WebView.mm
@@ -6057,7 +6057,7 @@ static void glibContextIterationCallback(CFRunLoopObserverRef, CFRunLoopActivity
 
 @implementation WebView (WebViewPrivateNodesFromRect)
 
-- (JSValueRef)_nodesFromRect:(JSContextRef)context forDocument:(JSValueRef)value x:(int)x  y:(int)y hPadding:(unsigned)hPadding vPadding:(unsigned)vPadding ignoreClipping:(BOOL)ignoreClipping
+- (JSValueRef)_nodesFromRect:(JSContextRef)context forDocument:(JSValueRef)value x:(int)x  y:(int)y top:(unsigned)top right:(unsigned)right bottom:(unsigned)bottom left:(unsigned)left ignoreClipping:(BOOL)ignoreClipping
 {
     JSLock lock(SilenceAssertionsOnly);
     ExecState* exec = toJS(context);
@@ -6068,7 +6068,7 @@ static void glibContextIterationCallback(CFRunLoopObserverRef, CFRunLoopActivity
         return JSValueMakeUndefined(context);
     JSDocument* jsDocument = static_cast<JSDocument*>(asObject(jsValue));
     Document* document = jsDocument->impl();
-    RefPtr<NodeList> nodes = document->nodesFromRect(x, y, hPadding, vPadding, ignoreClipping);
+    RefPtr<NodeList> nodes = document->nodesFromRect(x, y, top, right, bottom, left, ignoreClipping);
     return toRef(exec, toJS(exec, jsDocument->globalObject(), nodes.get()));
 }
 
diff --git a/WebKit/mac/WebView/WebViewPrivate.h b/WebKit/mac/WebView/WebViewPrivate.h
index 873e8e1..749eeb3 100644
--- a/WebKit/mac/WebView/WebViewPrivate.h
+++ b/WebKit/mac/WebView/WebViewPrivate.h
@@ -631,7 +631,7 @@ Could be worth adding to the API.
 @end
 
 @interface WebView (WebViewPrivateNodesFromRect)
-- (JSValueRef)_nodesFromRect:(JSContextRef)context forDocument:(JSValueRef)value x:(int)x  y:(int)y hPadding:(unsigned)hPadding vPadding:(unsigned)vPadding ignoreClipping:(BOOL)ignoreClipping;
+- (JSValueRef)_nodesFromRect:(JSContextRef)context forDocument:(JSValueRef)value x:(int)x  y:(int)y top:(unsigned)top right:(unsigned)right bottom:(unsigned)bottom left:(unsigned)left ignoreClipping:(BOOL)ignoreClipping;
 @end
 
 @interface NSObject (WebFrameLoadDelegatePrivate)
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
index 730f5c7..ee44325 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
@@ -515,18 +515,20 @@ static JSValueRef computedStyleIncludingVisitedInfoCallback(JSContextRef context
 
 static JSValueRef nodesFromRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    if (argumentCount != 6)
+    if (argumentCount != 8)
         return JSValueMakeUndefined(context);
 
     int x = JSValueToNumber(context, arguments[1], NULL);
     int y = JSValueToNumber(context, arguments[2], NULL);
-    int hPadding = static_cast<unsigned>(JSValueToNumber(context, arguments[3], NULL));
-    int vPadding = static_cast<unsigned>(JSValueToNumber(context, arguments[4], NULL));
-    bool ignoreClipping = JSValueToBoolean(context, arguments[5]);
+    int top = static_cast<unsigned>(JSValueToNumber(context, arguments[3], NULL));
+    int right = static_cast<unsigned>(JSValueToNumber(context, arguments[4], NULL));
+    int bottom = static_cast<unsigned>(JSValueToNumber(context, arguments[5], NULL));
+    int left = static_cast<unsigned>(JSValueToNumber(context, arguments[6], NULL));
+    bool ignoreClipping = JSValueToBoolean(context, arguments[7]);
 
     // Has mac implementation.
     LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
-    return controller->nodesFromRect(context, arguments[0], x, y, hPadding, vPadding, ignoreClipping);
+    return controller->nodesFromRect(context, arguments[0], x, y, top, right, bottom, left, ignoreClipping);
 }
 
 static JSValueRef layerTreeAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h
index 4d20301..755a2b2 100644
--- a/WebKitTools/DumpRenderTree/LayoutTestController.h
+++ b/WebKitTools/DumpRenderTree/LayoutTestController.h
@@ -60,7 +60,7 @@ public:
     bool isCommandEnabled(JSStringRef name);
     void keepWebHistory();
     JSValueRef computedStyleIncludingVisitedInfo(JSContextRef, JSValueRef);
-    JSValueRef nodesFromRect(JSContextRef, JSValueRef, int x, int y, unsigned hPadding, unsigned vPadding, bool ignoreClipping);
+    JSValueRef nodesFromRect(JSContextRef, JSValueRef, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping);
     void notifyDone();
     int numberOfPages(float pageWidthInPixels, float pageHeightInPixels);
     void overridePreference(JSStringRef key, JSStringRef value);
diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
index 246bbb4..d831076 100644
--- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
@@ -137,7 +137,7 @@ JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSContextRef
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef LayoutTestController::nodesFromRect(JSContextRef context, JSValueRef value, int , int, unsigned, unsigned, bool)
+JSValueRef LayoutTestController::nodesFromRect(JSContextRef context, JSValueRef value, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping)
 {
     // FIXME: Implement this.
     return JSValueMakeUndefined(context);
diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
index d4423d3..d2a6f79 100644
--- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
+++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
@@ -198,9 +198,9 @@ JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSContextRef
     return [[mainFrame webView] _computedStyleIncludingVisitedInfo:context forElement:value];
 }
 
-JSValueRef LayoutTestController::nodesFromRect(JSContextRef context, JSValueRef value, int x, int y, unsigned hPadding, unsigned vPadding, bool ignoreClipping)
+JSValueRef LayoutTestController::nodesFromRect(JSContextRef context, JSValueRef value, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping)
 {
-    return [[mainFrame webView] _nodesFromRect:context forDocument:value x:x y:y hPadding:hPadding vPadding:vPadding ignoreClipping:ignoreClipping];
+    return [[mainFrame webView] _nodesFromRect:context forDocument:value x:x y:y top:top right:right bottom:bottom left:left ignoreClipping:ignoreClipping];
 }
 
 JSRetainPtr<JSStringRef> LayoutTestController::layerTreeAsText() const
diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
index 07b10fc..6dd609c 100644
--- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
+++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
@@ -179,7 +179,7 @@ JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSContextRef
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef LayoutTestController::nodesFromRect(JSContextRef context, JSValueRef value, int , int, unsigned, unsigned, bool)
+JSValueRef LayoutTestController::nodesFromRect(JSContextRef context, JSValueRef value, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping)
 {
     // FIXME: Implement this.
     return JSValueMakeUndefined(context);
diff --git a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
index 6fa396a..5fba1cf 100644
--- a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
+++ b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp
@@ -486,7 +486,7 @@ JSValueRef LayoutTestController::computedStyleIncludingVisitedInfo(JSContextRef,
     return 0;
 }
 
-JSValueRef LayoutTestController::nodesFromRect(JSContextRef context, JSValueRef value, int , int, unsigned, unsigned, bool)
+JSValueRef LayoutTestController::nodesFromRect(JSContextRef context, JSValueRef value, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping)
 {
     // FIXME: Implement this.
     return 0;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list