Title: [87019] trunk/Source/WebCore
Revision
87019
Author
[email protected]
Date
2011-05-21 08:30:02 -0700 (Sat, 21 May 2011)

Log Message

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

        Reviewed by Eric Seidel.

        Change RenderLineBoxList::hitTest to use IntPoint
        https://bugs.webkit.org/show_bug.cgi?id=61156

        Change the RenderLineBoxList hit testing to use IntPoint and clean up the rect calculation.

        Covered by existing tests.

        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::hitTestContents):
        * rendering/RenderInline.cpp:
        (WebCore::RenderInline::nodeAtPoint):
        * rendering/RenderLineBoxList.cpp:
        (WebCore::RenderLineBoxList::hitTest):
        * rendering/RenderLineBoxList.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (87018 => 87019)


--- trunk/Source/WebCore/ChangeLog	2011-05-21 13:54:31 UTC (rev 87018)
+++ trunk/Source/WebCore/ChangeLog	2011-05-21 15:30:02 UTC (rev 87019)
@@ -2,6 +2,25 @@
 
         Reviewed by Eric Seidel.
 
+        Change RenderLineBoxList::hitTest to use IntPoint
+        https://bugs.webkit.org/show_bug.cgi?id=61156
+
+        Change the RenderLineBoxList hit testing to use IntPoint and clean up the rect calculation.
+
+        Covered by existing tests.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::hitTestContents):
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::nodeAtPoint):
+        * rendering/RenderLineBoxList.cpp:
+        (WebCore::RenderLineBoxList::hitTest):
+        * rendering/RenderLineBoxList.h:
+
+2011-05-21  Emil A Eklund  <[email protected]>
+
+        Reviewed by Eric Seidel.
+
         Change HitTestResult to use IntPoint
         https://bugs.webkit.org/show_bug.cgi?id=61230
 

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (87018 => 87019)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2011-05-21 13:54:31 UTC (rev 87018)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2011-05-21 15:30:02 UTC (rev 87019)
@@ -4035,7 +4035,7 @@
 {
     if (childrenInline() && !isTable()) {
         // We have to hit-test our line boxes.
-        if (m_lineBoxes.hitTest(this, request, result, x, y, tx, ty, hitTestAction))
+        if (m_lineBoxes.hitTest(this, request, result, IntPoint(x, y), tx, ty, hitTestAction))
             return true;
     } else {
         // Hit test our children.

Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (87018 => 87019)


--- trunk/Source/WebCore/rendering/RenderInline.cpp	2011-05-21 13:54:31 UTC (rev 87018)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp	2011-05-21 15:30:02 UTC (rev 87019)
@@ -714,7 +714,7 @@
 bool RenderInline::nodeAtPoint(const HitTestRequest& request, HitTestResult& result,
                                 const IntPoint& pointInContainer, int tx, int ty, HitTestAction hitTestAction)
 {
-    return m_lineBoxes.hitTest(this, request, result, pointInContainer.x(), pointInContainer.y(), tx, ty, hitTestAction);
+    return m_lineBoxes.hitTest(this, request, result, pointInContainer, tx, ty, hitTestAction);
 }
 
 VisiblePosition RenderInline::positionForPoint(const IntPoint& point)

Modified: trunk/Source/WebCore/rendering/RenderLineBoxList.cpp (87018 => 87019)


--- trunk/Source/WebCore/rendering/RenderLineBoxList.cpp	2011-05-21 13:54:31 UTC (rev 87018)
+++ trunk/Source/WebCore/rendering/RenderLineBoxList.cpp	2011-05-21 15:30:02 UTC (rev 87019)
@@ -274,7 +274,7 @@
 }
 
 
-bool RenderLineBoxList::hitTest(RenderBoxModelObject* renderer, const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction hitTestAction) const
+bool RenderLineBoxList::hitTest(RenderBoxModelObject* renderer, const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty, HitTestAction hitTestAction) const
 {
     if (hitTestAction != HitTestForeground)
         return false;
@@ -285,13 +285,10 @@
     if (!firstLineBox())
         return false;
 
-    bool isHorizontal = firstLineBox()->isHorizontal();
-    
-    int logicalPointStart = isHorizontal ? y - result.topPadding() : x - result.leftPadding();
-    int logicalPointEnd = (isHorizontal ? y + result.bottomPadding() : x + result.rightPadding()) + 1;
-    IntRect rect(isHorizontal ? x : logicalPointStart, isHorizontal ? logicalPointStart : y,
-                 isHorizontal ? 1 : logicalPointEnd - logicalPointStart,
-                 isHorizontal ? logicalPointEnd - logicalPointStart : 1);    
+    IntRect rect = firstLineBox()->isHorizontal() ?
+        IntRect(pointInContainer.x(), pointInContainer.y() - result.topPadding(), 1, result.topPadding() + result.bottomPadding() + 1) :
+        IntRect(pointInContainer.x() - result.leftPadding(), pointInContainer.y(), result.rightPadding() + result.leftPadding() + 1, 1);
+
     if (!anyLineIntersectsRect(renderer, rect, tx, ty))
         return false;
 
@@ -301,9 +298,9 @@
     for (InlineFlowBox* curr = lastLineBox(); curr; curr = curr->prevLineBox()) {
         RootInlineBox* root = curr->root();
         if (rangeIntersectsRect(renderer, curr->logicalTopVisualOverflow(root->lineTop()), curr->logicalBottomVisualOverflow(root->lineBottom()), rect, tx, ty)) {
-            bool inside = curr->nodeAtPoint(request, result, IntPoint(x, y), tx, ty, root->lineTop(), root->lineBottom());
+            bool inside = curr->nodeAtPoint(request, result, pointInContainer, tx, ty, root->lineTop(), root->lineBottom());
             if (inside) {
-                renderer->updateHitTestResult(result, IntPoint(x - tx, y - ty));
+                renderer->updateHitTestResult(result, pointInContainer - IntSize(tx, ty));
                 return true;
             }
         }

Modified: trunk/Source/WebCore/rendering/RenderLineBoxList.h (87018 => 87019)


--- trunk/Source/WebCore/rendering/RenderLineBoxList.h	2011-05-21 13:54:31 UTC (rev 87018)
+++ trunk/Source/WebCore/rendering/RenderLineBoxList.h	2011-05-21 15:30:02 UTC (rev 87019)
@@ -64,7 +64,7 @@
     void dirtyLinesFromChangedChild(RenderObject* parent, RenderObject* child);
 
     void paint(RenderBoxModelObject*, PaintInfo&, int x, int y) const;
-    bool hitTest(RenderBoxModelObject*, const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction) const;
+    bool hitTest(RenderBoxModelObject*, const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, int tx, int ty, HitTestAction) const;
     
 private:
     bool anyLineIntersectsRect(RenderBoxModelObject*, const IntRect&, int tx, int ty, bool usePrintRect = false, int outlineSize = 0) const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to