Title: [87101] trunk/Source/WebCore
Revision
87101
Author
[email protected]
Date
2011-05-23 15:15:19 -0700 (Mon, 23 May 2011)

Log Message

2011-05-23  Emil A Eklund  <[email protected]>

        Reviewed by Eric Seidel.

        Change RenderBlock hit testing to use IntPoint instead x,y pair
        https://bugs.webkit.org/show_bug.cgi?id=61146

        Covered by existing tests.

        * platform/graphics/IntPoint.h:
        (WebCore::toSize):
        Add toSize function for converting from point to size.

        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::isPointInOverflowControl):
        (WebCore::RenderBlock::nodeAtPoint):
        (WebCore::RenderBlock::hitTestFloats):
        (WebCore::RenderBlock::hitTestColumns):
        (WebCore::RenderBlock::hitTestContents):
        * rendering/RenderBlock.h:
        Change hit testing code in RenderBlock to use IntPoint.

        * rendering/RenderListBox.cpp:
        (WebCore::RenderListBox::isPointInOverflowControl):
        * rendering/RenderListBox.h:
        Change overridden method to use IntPoint.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (87100 => 87101)


--- trunk/Source/WebCore/ChangeLog	2011-05-23 22:11:15 UTC (rev 87100)
+++ trunk/Source/WebCore/ChangeLog	2011-05-23 22:15:19 UTC (rev 87101)
@@ -1,3 +1,30 @@
+2011-05-23  Emil A Eklund  <[email protected]>
+
+        Reviewed by Eric Seidel.
+
+        Change RenderBlock hit testing to use IntPoint instead x,y pair
+        https://bugs.webkit.org/show_bug.cgi?id=61146
+
+        Covered by existing tests.
+
+        * platform/graphics/IntPoint.h:
+        (WebCore::toSize):
+        Add toSize function for converting from point to size.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::isPointInOverflowControl):
+        (WebCore::RenderBlock::nodeAtPoint):
+        (WebCore::RenderBlock::hitTestFloats):
+        (WebCore::RenderBlock::hitTestColumns):
+        (WebCore::RenderBlock::hitTestContents):
+        * rendering/RenderBlock.h:
+        Change hit testing code in RenderBlock to use IntPoint.
+
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::isPointInOverflowControl):
+        * rendering/RenderListBox.h:
+        Change overridden method to use IntPoint.
+
 2011-05-23  Mike Reed  <[email protected]>
 
         Reviewed by James Robinson.

Modified: trunk/Source/WebCore/platform/graphics/IntPoint.h (87100 => 87101)


--- trunk/Source/WebCore/platform/graphics/IntPoint.h	2011-05-23 22:11:15 UTC (rev 87100)
+++ trunk/Source/WebCore/platform/graphics/IntPoint.h	2011-05-23 22:15:19 UTC (rev 87101)
@@ -205,6 +205,11 @@
     return IntPoint(size.width(), size.height());
 }
 
+inline IntSize toSize(const IntPoint& a)
+{
+    return IntSize(a.x(), a.y());
+}
+
 #if PLATFORM(QT)
 inline QDataStream& operator<<(QDataStream& stream, const IntPoint& point)
 {

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (87100 => 87101)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2011-05-23 22:11:15 UTC (rev 87100)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2011-05-23 22:15:19 UTC (rev 87101)
@@ -3889,12 +3889,12 @@
     return result;
 }
 
-bool RenderBlock::isPointInOverflowControl(HitTestResult& result, int _x, int _y, int _tx, int _ty)
+bool RenderBlock::isPointInOverflowControl(HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty)
 {
     if (!scrollsOverflow())
         return false;
 
-    return layer()->hitTestOverflowControls(result, IntPoint(_x - _tx, _y - _ty));
+    return layer()->hitTestOverflowControls(result, pointInContainer - IntSize(tx, ty));
 }
 
 bool RenderBlock::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty, HitTestAction hitTestAction)
@@ -3909,7 +3909,7 @@
             return false;
     }
 
-    if ((hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground) && isPointInOverflowControl(result, pointInContainer.x(), pointInContainer.y(), localOffset.width(), localOffset.height())) {
+    if ((hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground) && isPointInOverflowControl(result, pointInContainer, localOffset.width(), localOffset.height())) {
         updateHitTestResult(result, pointInContainer - localOffset);
         // FIXME: isPointInOverflowControl() doesn't handle rect-based tests yet.
         if (!result.addNodeToRectBasedTestResult(node(), pointInContainer))
@@ -3930,13 +3930,13 @@
 
         // Hit test contents if we don't have columns.
         if (!hasColumns()) {
-            if (hitTestContents(request, result, pointInContainer.x(), pointInContainer.y(), scrolledOffset.width(), scrolledOffset.height(), hitTestAction)) {
+            if (hitTestContents(request, result, pointInContainer, scrolledOffset.width(), scrolledOffset.height(), hitTestAction)) {
                 updateHitTestResult(result, pointInContainer - localOffset);
                 return true;
             }
-            if (hitTestAction == HitTestFloat && hitTestFloats(request, result, pointInContainer.x(), pointInContainer.y(), scrolledOffset.width(), scrolledOffset.height()))
+            if (hitTestAction == HitTestFloat && hitTestFloats(request, result, pointInContainer, scrolledOffset.width(), scrolledOffset.height()))
                 return true;
-        } else if (hitTestColumns(request, result, pointInContainer.x(), pointInContainer.y(), scrolledOffset.width(), scrolledOffset.height(), hitTestAction)) {
+        } else if (hitTestColumns(request, result, pointInContainer, scrolledOffset.width(), scrolledOffset.height(), hitTestAction)) {
             updateHitTestResult(result, pointInContainer - localOffset);
             return true;
         }
@@ -3955,7 +3955,7 @@
     return false;
 }
 
-bool RenderBlock::hitTestFloats(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty)
+bool RenderBlock::hitTestFloats(const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty)
 {
     if (!m_floatingObjects)
         return false;
@@ -3974,8 +3974,8 @@
             int xOffset = xPositionForFloatIncludingMargin(floatingObject) - floatingObject->m_renderer->x();
             int yOffset = yPositionForFloatIncludingMargin(floatingObject) - floatingObject->m_renderer->y();
             IntPoint childPoint = flipFloatForWritingMode(floatingObject, IntPoint(tx + xOffset, ty + yOffset));
-            if (floatingObject->m_renderer->hitTest(request, result, IntPoint(x, y), childPoint.x(), childPoint.y())) {
-                updateHitTestResult(result, IntPoint(x - childPoint.x(), y - childPoint.y()));
+            if (floatingObject->m_renderer->hitTest(request, result, pointInContainer, childPoint.x(), childPoint.y())) {
+                updateHitTestResult(result, pointInContainer - toSize(childPoint));
                 return true;
             }
         }
@@ -3984,7 +3984,7 @@
     return false;
 }
 
-bool RenderBlock::hitTestColumns(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction hitTestAction)
+bool RenderBlock::hitTestColumns(const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty, HitTestAction hitTestAction)
 {
     // We need to do multiple passes, breaking up our hit testing into strips.
     ColumnInfo* colInfo = columnInfo();
@@ -4014,28 +4014,28 @@
             currLogicalTopOffset += blockDelta;
         colRect.move(tx, ty);
         
-        if (colRect.intersects(result.rectForPoint(IntPoint(x, y)))) {
+        if (colRect.intersects(result.rectForPoint(pointInContainer))) {
             // The point is inside this column.
             // Adjust tx and ty to change where we hit test.
         
             IntSize offset = isHorizontal ? IntSize(currLogicalLeftOffset, currLogicalTopOffset) : IntSize(currLogicalTopOffset, currLogicalLeftOffset);
             int finalX = tx + offset.width();
             int finalY = ty + offset.height();
-            if (result.isRectBasedTest() && !colRect.contains(result.rectForPoint(IntPoint(x, y))))
-                hitTestContents(request, result, x, y, finalX, finalY, hitTestAction);
+            if (result.isRectBasedTest() && !colRect.contains(result.rectForPoint(pointInContainer)))
+                hitTestContents(request, result, pointInContainer, finalX, finalY, hitTestAction);
             else
-                return hitTestContents(request, result, x, y, finalX, finalY, hitTestAction) || (hitTestAction == HitTestFloat && hitTestFloats(request, result, x, y, finalX, finalY));
+                return hitTestContents(request, result, pointInContainer, finalX, finalY, hitTestAction) || (hitTestAction == HitTestFloat && hitTestFloats(request, result, pointInContainer, finalX, finalY));
         }
     }
 
     return false;
 }
 
-bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction hitTestAction)
+bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty, HitTestAction hitTestAction)
 {
     if (childrenInline() && !isTable()) {
         // We have to hit-test our line boxes.
-        if (m_lineBoxes.hitTest(this, request, result, IntPoint(x, y), tx, ty, hitTestAction))
+        if (m_lineBoxes.hitTest(this, request, result, pointInContainer, tx, ty, hitTestAction))
             return true;
     } else {
         // Hit test our children.
@@ -4044,7 +4044,7 @@
             childHitTest = HitTestChildBlockBackground;
         for (RenderBox* child = lastChildBox(); child; child = child->previousSiblingBox()) {
             IntPoint childPoint = flipForWritingMode(child, IntPoint(tx, ty), ParentToChildFlippingAdjustment);
-            if (!child->hasSelfPaintingLayer() && !child->isFloating() && child->nodeAtPoint(request, result, IntPoint(x, y), childPoint.x(), childPoint.y(), childHitTest))
+            if (!child->hasSelfPaintingLayer() && !child->isFloating() && child->nodeAtPoint(request, result, pointInContainer, childPoint.x(), childPoint.y(), childHitTest))
                 return true;
         }
     }

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (87100 => 87101)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2011-05-23 22:11:15 UTC (rev 87100)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2011-05-23 22:15:19 UTC (rev 87101)
@@ -584,11 +584,11 @@
     int lowestFloatLogicalBottom(FloatingObject::Type = FloatingObject::FloatBoth) const;
     int nextFloatLogicalBottomBelow(int) const;
     
-    virtual bool hitTestColumns(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
-    virtual bool hitTestContents(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
-    bool hitTestFloats(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty);
+    virtual bool hitTestColumns(const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, int tx, int ty, HitTestAction);
+    virtual bool hitTestContents(const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, int tx, int ty, HitTestAction);
+    bool hitTestFloats(const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, int tx, int ty);
 
-    virtual bool isPointInOverflowControl(HitTestResult&, int x, int y, int tx, int ty);
+    virtual bool isPointInOverflowControl(HitTestResult&, const IntPoint& pointInContainer, int tx, int ty);
 
     void computeInlinePreferredLogicalWidths();
     void computeBlockPreferredLogicalWidths();

Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (87100 => 87101)


--- trunk/Source/WebCore/rendering/RenderListBox.cpp	2011-05-23 22:11:15 UTC (rev 87100)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp	2011-05-23 22:15:19 UTC (rev 87101)
@@ -434,17 +434,17 @@
     }
 }
 
-bool RenderListBox::isPointInOverflowControl(HitTestResult& result, int _x, int _y, int _tx, int _ty)
+bool RenderListBox::isPointInOverflowControl(HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty)
 {
     if (!m_vBar)
         return false;
 
-    IntRect vertRect(_tx + width() - borderRight() - m_vBar->width(),
-                     _ty + borderTop(),
+    IntRect vertRect(tx + width() - borderRight() - m_vBar->width(),
+                     ty + borderTop(),
                      m_vBar->width(),
                      height() - borderTop() - borderBottom());
 
-    if (vertRect.contains(_x, _y)) {
+    if (vertRect.contains(pointInContainer)) {
         result.setScrollbar(m_vBar.get());
         return true;
     }

Modified: trunk/Source/WebCore/rendering/RenderListBox.h (87100 => 87101)


--- trunk/Source/WebCore/rendering/RenderListBox.h	2011-05-23 22:11:15 UTC (rev 87100)
+++ trunk/Source/WebCore/rendering/RenderListBox.h	2011-05-23 22:15:19 UTC (rev 87101)
@@ -68,7 +68,7 @@
     virtual void paintObject(PaintInfo&, int tx, int ty);
     virtual IntRect controlClipRect(int tx, int ty) const;
 
-    virtual bool isPointInOverflowControl(HitTestResult&, int x, int y, int tx, int ty);
+    virtual bool isPointInOverflowControl(HitTestResult&, const IntPoint& pointInContainer, int tx, int ty);
 
     virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
     virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to