Clean up subpixel unit handling in hit testing code
authoreae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Apr 2012 18:59:59 +0000 (18:59 +0000)
committereae@chromium.org <eae@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Apr 2012 18:59:59 +0000 (18:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84496

Reviewed by Eric Seidel.

Fix use of IntRect and LayoutRect in hit testing code in preparation for
subpixel layout.

No new tests, no change in functionality.

* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::rectForPoint):
Revert rectForPoint to IntRect as all call sites converted it to an
IntRect anyway to compare it with an IntPoint or another IntRect.

* rendering/HitTestingTransformState.cpp:
(WebCore::HitTestingTransformState::boundsOfMappedQuad):
* rendering/HitTestingTransformState.h:
Convert boundsOfMappedQuad to LayoutRect as the TransformationMatrix now
has subpixel precision.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@114926 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/HitTestResult.cpp
Source/WebCore/rendering/HitTestResult.h
Source/WebCore/rendering/HitTestingTransformState.cpp
Source/WebCore/rendering/HitTestingTransformState.h

index de534ef..523a860 100644 (file)
@@ -1,3 +1,26 @@
+2012-04-23  Emil A Eklund  <eae@chromium.org>
+
+        Clean up subpixel unit handling in hit testing code
+        https://bugs.webkit.org/show_bug.cgi?id=84496
+
+        Reviewed by Eric Seidel.
+
+        Fix use of IntRect and LayoutRect in hit testing code in preparation for
+        subpixel layout.
+
+        No new tests, no change in functionality.
+
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::rectForPoint):
+        Revert rectForPoint to IntRect as all call sites converted it to an
+        IntRect anyway to compare it with an IntPoint or another IntRect.
+
+        * rendering/HitTestingTransformState.cpp:
+        (WebCore::HitTestingTransformState::boundsOfMappedQuad):
+        * rendering/HitTestingTransformState.h:
+        Convert boundsOfMappedQuad to LayoutRect as the TransformationMatrix now
+        has subpixel precision.
+
 2012-04-23  Kentaro Hara  <haraken@chromium.org>
 
         [V8] Pass Isolate to toV8() (Part3)
index 2a2ef2a..c19f122 100644 (file)
@@ -652,16 +652,16 @@ void HitTestResult::append(const HitTestResult& other)
     }
 }
 
-LayoutRect HitTestResult::rectForPoint(const LayoutPoint& point, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
+IntRect HitTestResult::rectForPoint(const LayoutPoint& point, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
 {
-    LayoutPoint actualPoint(point);
-    actualPoint -= LayoutSize(leftPadding, topPadding);
+    IntPoint actualPoint(roundedIntPoint(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 LayoutRect(actualPoint, actualPadding);
+    return IntRect(actualPoint, actualPadding);
 }
 
 const HitTestResult::NodeSet& HitTestResult::rectBasedTestResult() const
index 062c1d4..e919472 100644 (file)
@@ -112,8 +112,8 @@ public:
 
     // Rect-based hit test related methods.
     bool isRectBasedTest() const { return m_isRectBased; }
-    LayoutRect rectForPoint(const LayoutPoint&) const;
-    static LayoutRect rectForPoint(const LayoutPoint&, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
+    IntRect rectForPoint(const LayoutPoint&) const;
+    static IntRect rectForPoint(const LayoutPoint&, 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; }
@@ -162,7 +162,7 @@ private:
 // y = p.y() - topPadding
 // width = leftPadding + rightPadding + 1
 // height = topPadding + bottomPadding + 1
-inline LayoutRect HitTestResult::rectForPoint(const LayoutPoint& point) const
+inline IntRect HitTestResult::rectForPoint(const LayoutPoint& point) const
 {
     return rectForPoint(point, m_topPadding, m_rightPadding, m_bottomPadding, m_leftPadding);
 }
index cb1e1d6..4934a7b 100644 (file)
@@ -73,7 +73,7 @@ FloatQuad HitTestingTransformState::mappedQuad() const
     return m_accumulatedTransform.inverse().projectQuad(m_lastPlanarQuad);
 }
 
-IntRect HitTestingTransformState::boundsOfMappedQuad() const
+LayoutRect HitTestingTransformState::boundsOfMappedQuad() const
 {
     return m_accumulatedTransform.inverse().clampedBoundsOfProjectedQuad(m_lastPlanarQuad);
 }
index 6aea66c..2439dff 100644 (file)
@@ -58,7 +58,7 @@ public:
 
     FloatPoint mappedPoint() const;
     FloatQuad mappedQuad() const;
-    IntRect boundsOfMappedQuad() const;
+    LayoutRect boundsOfMappedQuad() const;
     void flatten();
 
     FloatPoint m_lastPlanarPoint;