Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(895)

Unified Diff: Source/core/layout/MultiColumnFragmentainerGroup.cpp

Issue 978603003: [New Multicolumn] Make positionForPoint() work. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More tests Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/layout/MultiColumnFragmentainerGroup.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/MultiColumnFragmentainerGroup.cpp
diff --git a/Source/core/layout/MultiColumnFragmentainerGroup.cpp b/Source/core/layout/MultiColumnFragmentainerGroup.cpp
index 8c8423a58448278aed95ec5d47c58bb94582e8fa..7823341661f0401f61193bfbb541bbd6aa082a4d 100644
--- a/Source/core/layout/MultiColumnFragmentainerGroup.cpp
+++ b/Source/core/layout/MultiColumnFragmentainerGroup.cpp
@@ -146,6 +146,33 @@ LayoutUnit MultiColumnFragmentainerGroup::columnLogicalTopForOffset(LayoutUnit o
return m_logicalTopInFlowThread + columnIndex * m_columnHeight;
}
+LayoutPoint MultiColumnFragmentainerGroup::visualPointToFlowThreadPoint(const LayoutPoint& visualPoint) const
+{
+ unsigned columnIndex = columnIndexAtVisualPoint(visualPoint);
+ LayoutRect columnRect = columnRectAt(columnIndex);
+ LayoutPoint localPoint(visualPoint);
+ localPoint.moveBy(-columnRect.location());
+ // Before converting to a flow thread position, if the block direction coordinate is outside the
+ // column, snap to the bounds of the column, and reset the inline direction coordinate to the
+ // start position in the column. The effect of this is that if the block position is before the
+ // column rectangle, we'll get to the beginning of this column, while if the block position is
+ // after the column rectangle, we'll get to the beginning of the next column.
+ if (!m_columnSet.isHorizontalWritingMode()) {
+ LayoutUnit columnStart = m_columnSet.style()->isLeftToRightDirection() ? LayoutUnit() : columnRect.height();
+ if (localPoint.x() < 0)
+ localPoint = LayoutPoint(LayoutUnit(), columnStart);
+ else if (localPoint.x() > logicalHeight())
+ localPoint = LayoutPoint(logicalHeight(), columnStart);
+ return LayoutPoint(localPoint.x() + logicalTopInFlowThreadAt(columnIndex), localPoint.y());
+ }
+ LayoutUnit columnStart = m_columnSet.style()->isLeftToRightDirection() ? LayoutUnit() : columnRect.width();
+ if (localPoint.y() < 0)
+ localPoint = LayoutPoint(columnStart, LayoutUnit());
+ else if (localPoint.y() > logicalHeight())
+ localPoint = LayoutPoint(columnStart, logicalHeight());
+ return LayoutPoint(localPoint.x(), localPoint.y() + logicalTopInFlowThreadAt(columnIndex));
+}
+
void MultiColumnFragmentainerGroup::collectLayerFragments(LayerFragments& fragments, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect) const
{
// |layerBoundingBox| is in the flow thread coordinate space, relative to the top/left edge of
@@ -490,6 +517,24 @@ unsigned MultiColumnFragmentainerGroup::columnIndexAtOffset(LayoutUnit offsetInF
return 0;
}
+unsigned MultiColumnFragmentainerGroup::columnIndexAtVisualPoint(const LayoutPoint& visualPoint) const
+{
+ bool isColumnProgressionInline = m_columnSet.multiColumnFlowThread()->progressionIsInline();
+ bool isHorizontalWritingMode = m_columnSet.isHorizontalWritingMode();
+ LayoutUnit columnLengthInColumnProgressionDirection = isColumnProgressionInline ? m_columnSet.pageLogicalWidth() : m_columnSet.pageLogicalHeight();
+ LayoutUnit offsetInColumnProgressionDirection = isHorizontalWritingMode == isColumnProgressionInline ? visualPoint.x() : visualPoint.y();
+ if (!m_columnSet.style()->isLeftToRightDirection() && isColumnProgressionInline)
+ offsetInColumnProgressionDirection = m_columnSet.logicalWidth() - offsetInColumnProgressionDirection;
+ LayoutUnit columnGap = m_columnSet.columnGap();
+ if (columnLengthInColumnProgressionDirection + columnGap <= 0)
+ return 0;
+ // Column boundaries are in the middle of the column gap.
+ int index = (offsetInColumnProgressionDirection + columnGap / 2) / (columnLengthInColumnProgressionDirection + columnGap);
+ if (index < 0)
+ return 0;
+ return std::min(unsigned(index), actualColumnCount() - 1);
+}
+
MultiColumnFragmentainerGroupList::MultiColumnFragmentainerGroupList(LayoutMultiColumnSet& columnSet)
: m_columnSet(columnSet)
{
« no previous file with comments | « Source/core/layout/MultiColumnFragmentainerGroup.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698