Diff
Modified: trunk/Source/WebCore/ChangeLog (88194 => 88195)
--- trunk/Source/WebCore/ChangeLog 2011-06-06 22:03:35 UTC (rev 88194)
+++ trunk/Source/WebCore/ChangeLog 2011-06-06 22:13:08 UTC (rev 88195)
@@ -1,3 +1,32 @@
+2011-06-06 Emil A Eklund <[email protected]>
+
+ Reviewed by Eric Seidel.
+
+ Convert hitTest to IntPoint
+ https://bugs.webkit.org/show_bug.cgi?id=62144
+
+ Covered by existing tests.
+
+ * rendering/InlineBox.cpp:
+ (WebCore::InlineBox::nodeAtPoint):
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::hitTestFloats):
+ (WebCore::RenderBlock::hitTestContents):
+ * rendering/RenderInline.cpp:
+ (WebCore::RenderInline::nodeAtPoint):
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::hitTestContents):
+ * rendering/RenderLayer.h:
+ (WebCore::RenderLayer::renderBoxLocation):
+ (WebCore::RenderLayer::renderBoxX):
+ (WebCore::RenderLayer::renderBoxY):
+ * rendering/RenderLineBoxList.cpp:
+ (WebCore::RenderLineBoxList::hitTest):
+ * rendering/RenderLineBoxList.h:
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::hitTest):
+ * rendering/RenderObject.h:
+
2011-06-06 Levi Weintraub <[email protected]>
Reviewed by Eric Seidel.
Modified: trunk/Source/WebCore/rendering/InlineBox.cpp (88194 => 88195)
--- trunk/Source/WebCore/rendering/InlineBox.cpp 2011-06-06 22:03:35 UTC (rev 88194)
+++ trunk/Source/WebCore/rendering/InlineBox.cpp 2011-06-06 22:13:08 UTC (rev 88195)
@@ -225,7 +225,7 @@
// Hit test all phases of replaced elements atomically, as though the replaced element established its
// own stacking context. (See Appendix E.2, section 6.4 on inline block/table elements in the CSS2.1
// specification.)
- return renderer()->hitTest(request, result, pointInContainer, tx, ty);
+ return renderer()->hitTest(request, result, pointInContainer, IntPoint(tx, ty));
}
const RootInlineBox* InlineBox::root() const
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (88194 => 88195)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2011-06-06 22:03:35 UTC (rev 88194)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2011-06-06 22:13:08 UTC (rev 88195)
@@ -3973,7 +3973,7 @@
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, pointInContainer, childPoint.x(), childPoint.y())) {
+ if (floatingObject->m_renderer->hitTest(request, result, pointInContainer, childPoint)) {
updateHitTestResult(result, pointInContainer - toSize(childPoint));
return true;
}
@@ -4034,7 +4034,7 @@
{
if (childrenInline() && !isTable()) {
// We have to hit-test our line boxes.
- if (m_lineBoxes.hitTest(this, request, result, pointInContainer, tx, ty, hitTestAction))
+ if (m_lineBoxes.hitTest(this, request, result, pointInContainer, IntPoint(tx, ty), hitTestAction))
return true;
} else {
// Hit test our children.
Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (88194 => 88195)
--- trunk/Source/WebCore/rendering/RenderInline.cpp 2011-06-06 22:03:35 UTC (rev 88194)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp 2011-06-06 22:13:08 UTC (rev 88195)
@@ -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, tx, ty, hitTestAction);
+ return m_lineBoxes.hitTest(this, request, result, pointInContainer, IntPoint(tx, ty), hitTestAction);
}
VisiblePosition RenderInline::positionForPoint(const IntPoint& point)
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (88194 => 88195)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2011-06-06 22:03:35 UTC (rev 88194)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2011-06-06 22:13:08 UTC (rev 88195)
@@ -3137,8 +3137,7 @@
bool RenderLayer::hitTestContents(const HitTestRequest& request, HitTestResult& result, const IntRect& layerBounds, const IntPoint& hitTestPoint, HitTestFilter hitTestFilter) const
{
if (!renderer()->hitTest(request, result, hitTestPoint,
- layerBounds.x() - renderBoxX(),
- layerBounds.y() - renderBoxY(),
+ toPoint(layerBounds.location() - renderBoxLocation()),
hitTestFilter)) {
// It's wrong to set innerNode, but then claim that you didn't hit anything, unless it is
// a rect-based test.
Modified: trunk/Source/WebCore/rendering/RenderLayer.h (88194 => 88195)
--- trunk/Source/WebCore/rendering/RenderLayer.h 2011-06-06 22:03:35 UTC (rev 88194)
+++ trunk/Source/WebCore/rendering/RenderLayer.h 2011-06-06 22:13:08 UTC (rev 88195)
@@ -459,8 +459,9 @@
void setFirstChild(RenderLayer* first) { m_first = first; }
void setLastChild(RenderLayer* last) { m_last = last; }
- int renderBoxX() const { return renderer()->isBox() ? toRenderBox(renderer())->x() : 0; }
- int renderBoxY() const { return renderer()->isBox() ? toRenderBox(renderer())->y() : 0; }
+ IntPoint renderBoxLocation() const { return renderer()->isBox() ? toRenderBox(renderer())->location() : IntPoint(); }
+ int renderBoxX() const { return renderBoxLocation().x(); }
+ int renderBoxY() const { return renderBoxLocation().y(); }
void collectLayers(Vector<RenderLayer*>*&, Vector<RenderLayer*>*&);
Modified: trunk/Source/WebCore/rendering/RenderLineBoxList.cpp (88194 => 88195)
--- trunk/Source/WebCore/rendering/RenderLineBoxList.cpp 2011-06-06 22:03:35 UTC (rev 88194)
+++ trunk/Source/WebCore/rendering/RenderLineBoxList.cpp 2011-06-06 22:13:08 UTC (rev 88195)
@@ -274,7 +274,7 @@
}
-bool RenderLineBoxList::hitTest(RenderBoxModelObject* renderer, const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty, HitTestAction hitTestAction) const
+bool RenderLineBoxList::hitTest(RenderBoxModelObject* renderer, const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, const IntPoint& accumulatedOffset, HitTestAction hitTestAction) const
{
if (hitTestAction != HitTestForeground)
return false;
@@ -289,7 +289,7 @@
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, IntPoint(tx, ty)))
+ if (!anyLineIntersectsRect(renderer, rect, accumulatedOffset))
return false;
// See if our root lines contain the point. If so, then we hit test
@@ -297,10 +297,10 @@
// based off positions of our first line box or our last line box.
for (InlineFlowBox* curr = lastLineBox(); curr; curr = curr->prevLineBox()) {
RootInlineBox* root = curr->root();
- if (rangeIntersectsRect(renderer, curr->logicalTopVisualOverflow(root->lineTop()), curr->logicalBottomVisualOverflow(root->lineBottom()), rect, IntPoint(tx, ty))) {
- bool inside = curr->nodeAtPoint(request, result, pointInContainer, tx, ty, root->lineTop(), root->lineBottom());
+ if (rangeIntersectsRect(renderer, curr->logicalTopVisualOverflow(root->lineTop()), curr->logicalBottomVisualOverflow(root->lineBottom()), rect, accumulatedOffset)) {
+ bool inside = curr->nodeAtPoint(request, result, pointInContainer, accumulatedOffset.x(), accumulatedOffset.y(), root->lineTop(), root->lineBottom());
if (inside) {
- renderer->updateHitTestResult(result, pointInContainer - IntSize(tx, ty));
+ renderer->updateHitTestResult(result, toPoint(pointInContainer - accumulatedOffset));
return true;
}
}
Modified: trunk/Source/WebCore/rendering/RenderLineBoxList.h (88194 => 88195)
--- trunk/Source/WebCore/rendering/RenderLineBoxList.h 2011-06-06 22:03:35 UTC (rev 88194)
+++ trunk/Source/WebCore/rendering/RenderLineBoxList.h 2011-06-06 22:13:08 UTC (rev 88195)
@@ -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&, const IntPoint& pointInContainer, int tx, int ty, HitTestAction) const;
+ bool hitTest(RenderBoxModelObject*, const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, const IntPoint& accumulatedOffset, HitTestAction) const;
private:
bool anyLineIntersectsRect(RenderBoxModelObject*, const IntRect&, const IntPoint&, bool usePrintRect = false, int outlineSize = 0) const;
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (88194 => 88195)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2011-06-06 22:03:35 UTC (rev 88194)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2011-06-06 22:13:08 UTC (rev 88195)
@@ -2142,25 +2142,25 @@
curr->updateDragState(dragOn);
}
-bool RenderObject::hitTest(const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty, HitTestFilter hitTestFilter)
+bool RenderObject::hitTest(const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, const IntPoint& accumulatedOffset, HitTestFilter hitTestFilter)
{
bool inside = false;
if (hitTestFilter != HitTestSelf) {
// First test the foreground layer (lines and inlines).
- inside = nodeAtPoint(request, result, pointInContainer, tx, ty, HitTestForeground);
+ inside = nodeAtPoint(request, result, pointInContainer, accumulatedOffset.x(), accumulatedOffset.y(), HitTestForeground);
// Test floats next.
if (!inside)
- inside = nodeAtPoint(request, result, pointInContainer, tx, ty, HitTestFloat);
+ inside = nodeAtPoint(request, result, pointInContainer, accumulatedOffset.x(), accumulatedOffset.y(), HitTestFloat);
// Finally test to see if the mouse is in the background (within a child block's background).
if (!inside)
- inside = nodeAtPoint(request, result, pointInContainer, tx, ty, HitTestChildBlockBackgrounds);
+ inside = nodeAtPoint(request, result, pointInContainer, accumulatedOffset.x(), accumulatedOffset.y(), HitTestChildBlockBackgrounds);
}
// See if the mouse is inside us but not any of our descendants
if (hitTestFilter != HitTestDescendants && !inside)
- inside = nodeAtPoint(request, result, pointInContainer, tx, ty, HitTestBlockBackground);
+ inside = nodeAtPoint(request, result, pointInContainer, accumulatedOffset.x(), accumulatedOffset.y(), HitTestBlockBackground);
return inside;
}
Modified: trunk/Source/WebCore/rendering/RenderObject.h (88194 => 88195)
--- trunk/Source/WebCore/rendering/RenderObject.h 2011-06-06 22:03:35 UTC (rev 88194)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2011-06-06 22:13:08 UTC (rev 88195)
@@ -545,7 +545,7 @@
void collectDashboardRegions(Vector<DashboardRegionValue>&);
#endif
- bool hitTest(const HitTestRequest&, HitTestResult&, const IntPoint&, int tx, int ty, HitTestFilter = HitTestAll);
+ bool hitTest(const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, const IntPoint& accumulatedOffset, HitTestFilter = HitTestAll);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const IntPoint& pointInContainer, int tx, int ty, HitTestAction);
virtual void updateHitTestResult(HitTestResult&, const IntPoint&);