Modified: trunk/Source/WebCore/ChangeLog (127036 => 127037)
--- trunk/Source/WebCore/ChangeLog 2012-08-29 20:05:54 UTC (rev 127036)
+++ trunk/Source/WebCore/ChangeLog 2012-08-29 20:10:03 UTC (rev 127037)
@@ -1,3 +1,21 @@
+2012-08-29 David Hyatt <[email protected]>
+
+ [New Multicolumn] Implement hit testing for columns.
+ https://bugs.webkit.org/show_bug.cgi?id=95367
+
+ Reviewed by Simon Fraser.
+
+ Add an implementation of nodeAtPoint for RenderMultiColumnSet that works similarly to painting.
+ Multiple calls get made as you walk through the columns to hitTestFlowThreadPortionInRegion.
+
+ * rendering/RenderMultiColumnSet.cpp:
+ (WebCore::RenderMultiColumnSet::nodeAtPoint):
+ (WebCore):
+ * rendering/RenderMultiColumnSet.h:
+ (RenderMultiColumnSet):
+ * rendering/RenderRegion.cpp:
+ (WebCore::RenderRegion::nodeAtPoint):
+
2012-08-29 Anna Cavender <[email protected]>
Create a toggle button for closed captions.
Modified: trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp (127036 => 127037)
--- trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp 2012-08-29 20:05:54 UTC (rev 127036)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp 2012-08-29 20:10:03 UTC (rev 127037)
@@ -24,9 +24,11 @@
*/
#include "config.h"
+#include "RenderMultiColumnSet.h"
+
+#include "HitTestResult.h"
#include "PaintInfo.h"
#include "RenderMultiColumnFlowThread.h"
-#include "RenderMultiColumnSet.h"
#include "RenderMultiColumnBlock.h"
using std::min;
@@ -253,6 +255,49 @@
}
}
+bool RenderMultiColumnSet::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
+{
+ LayoutPoint adjustedLocation = accumulatedOffset + location();
+
+ // Check our bounds next. For this purpose always assume that we can only be hit in the
+ // foreground phase (which is true for replaced elements like images).
+ // FIXME: Once we support overflow, we need to intersect with that and not with the bounds rect.
+ LayoutRect boundsRect = borderBoxRectInRegion(locationInContainer.region());
+ boundsRect.moveBy(adjustedLocation);
+ if (!visibleToHitTesting() || action != HitTestForeground || !locationInContainer.intersects(boundsRect))
+ return false;
+
+ // The point is in one specific column. Since columns can't overlap, we don't ever have to test
+ // multiple columns. Put the
+
+ // FIXME: It would be nice to jump right to the specific column by just doing math on the point. Since columns
+ // can't overlap, we shouldn't have to walk every column like this. The old column code walked all the columns, though,
+ // so this is no worse. We'd have to watch out for rect-based hit testing, though, which actually could overlap
+ // multiple columns.
+ LayoutUnit colGap = columnGap();
+ unsigned colCount = columnCount();
+ for (unsigned i = 0; i < colCount; i++) {
+ // First we get the column rect, which is in our local coordinate space, and we make it physical and apply
+ // the hit test offset to it. That gives us the physical location that we want to paint the column at.
+ LayoutRect colRect = columnRectAt(i);
+ flipForWritingMode(colRect);
+ colRect.moveBy(adjustedLocation);
+
+ // Next we get the portion of the flow thread that corresponds to this column.
+ LayoutRect flowThreadPortion = flowThreadPortionRectAt(i);
+
+ // Now get the overflow rect that corresponds to the column.
+ LayoutRect flowThreadOverflowPortion = flowThreadPortionOverflowRect(flowThreadPortion, i, colCount, colGap);
+
+ // Do the hit test with the computed rects.
+ if (flowThread()->hitTestFlowThreadPortionInRegion(this, flowThreadPortion, flowThreadOverflowPortion, request, result, locationInContainer, colRect.location()))
+ return true;
+ }
+
+ updateHitTestResult(result, locationInContainer.point() - toLayoutSize(adjustedLocation));
+ return !result.addNodeToRectBasedTestResult(node(), locationInContainer, boundsRect);
+}
+
const char* RenderMultiColumnSet::renderName() const
{
return "RenderMultiColumnSet";
Modified: trunk/Source/WebCore/rendering/RenderMultiColumnSet.h (127036 => 127037)
--- trunk/Source/WebCore/rendering/RenderMultiColumnSet.h 2012-08-29 20:05:54 UTC (rev 127036)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnSet.h 2012-08-29 20:10:03 UTC (rev 127037)
@@ -66,6 +66,7 @@
virtual void computeLogicalHeight() OVERRIDE;
virtual void paintReplaced(PaintInfo&, const LayoutPoint& paintOffset) OVERRIDE;
+ virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
virtual LayoutUnit logicalWidthForFlowThreadContent() const OVERRIDE { return m_computedColumnWidth; }
virtual LayoutUnit logicalHeightForFlowThreadContent() const OVERRIDE { return m_computedColumnHeight; } // FIXME: Will be wrong once we have multiple sets.
Modified: trunk/Source/WebCore/rendering/RenderRegion.cpp (127036 => 127037)
--- trunk/Source/WebCore/rendering/RenderRegion.cpp 2012-08-29 20:05:54 UTC (rev 127036)
+++ trunk/Source/WebCore/rendering/RenderRegion.cpp 2012-08-29 20:10:03 UTC (rev 127037)
@@ -132,6 +132,7 @@
// Check our bounds next. For this purpose always assume that we can only be hit in the
// foreground phase (which is true for replaced elements like images).
+ // FIXME: Once we support overflow, we need to intersect with that and not with the bounds rect.
LayoutRect boundsRect = borderBoxRectInRegion(locationInContainer.region());
boundsRect.moveBy(adjustedLocation);
if (visibleToHitTesting() && action == HitTestForeground && locationInContainer.intersects(boundsRect)) {