Index: Source/core/rendering/MultiColumnRow.h |
diff --git a/Source/core/rendering/MultiColumnRow.h b/Source/core/rendering/MultiColumnRow.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0f66dcc4d67a7ea6accc4951ffb518c9e7db8565 |
--- /dev/null |
+++ b/Source/core/rendering/MultiColumnRow.h |
@@ -0,0 +1,126 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MultiColumnRow_h |
+#define MultiColumnRow_h |
+ |
+#include "core/rendering/RenderMultiColumnFlowThread.h" |
+ |
+namespace blink { |
+ |
+class MultiColumnRow { |
Julien - ping for review
2015/01/29 17:37:47
We would need a class comment about this. I still
mstensho (USE GERRIT)
2015/02/02 17:57:23
Done.
|
+public: |
+ MultiColumnRow(RenderMultiColumnSet&); |
+ |
+ // FIXME: implement these. For now we only support one row. |
+ MultiColumnRow* previousRow() { return 0; } |
+ MultiColumnRow* nextRow() { return 0; } |
+ const MultiColumnRow* previousRow() const { return 0; } |
+ const MultiColumnRow* nextRow() const { return 0; } |
+ |
+ // Position within the RenderMultiColumnSet. |
+ LayoutUnit logicalTop() const { return m_logicalTop; } |
+ |
+ LayoutUnit logicalHeight() const { return m_columnHeight; } |
+ |
+ LayoutSize offsetFromColumnSet() const; |
+ |
+ // The top of our flow thread portion |
+ LayoutUnit logicalTopInFlowThread() const { return m_logicalTopInFlowThread; } |
+ void setLogicalTopInFlowThread(LayoutUnit logicalTopInFlowThread) { m_logicalTopInFlowThread = logicalTopInFlowThread; } |
+ |
+ // The bottom of our flow thread portion |
+ LayoutUnit logicalBottomInFlowThread() const { return m_logicalBottomInFlowThread; } |
+ void setLogicalBottomInFlowThread(LayoutUnit logicalBottomInFlowThread) { m_logicalBottomInFlowThread = logicalBottomInFlowThread; } |
+ |
+ // The height of our flow thread portion |
+ LayoutUnit logicalHeightInFlowThread() const { return m_logicalBottomInFlowThread - m_logicalTopInFlowThread; } |
+ |
+ bool heightIsAuto() const; |
+ void resetColumnHeight(); |
+ void addContentRun(LayoutUnit endOffsetInFlowThread); |
+ void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); } |
+ void recordSpaceShortage(LayoutUnit); |
+ bool recalculateColumnHeight(BalancedColumnHeightCalculation calculationMode); |
+ |
+ void expandToEncompassFlowThreadOverflow(); |
+ |
+ LayoutSize flowThreadTranslationAtOffset(LayoutUnit offsetInFlowThread) const; |
+ LayoutUnit columnLogicalTopForOffset(LayoutUnit offsetInFlowThread) const; |
+ void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect); |
+ LayoutRect calculateOverflow() const; |
+ |
+ // The "CSS actual" value of column-count. This includes overflowing columns, if any. |
+ unsigned actualColumnCount() const; |
+ |
+private: |
+ LayoutUnit heightAdjustedForRowOffset(LayoutUnit height) const; |
+ LayoutUnit calculateMaxColumnHeight() const; |
+ void setAndConstrainColumnHeight(LayoutUnit); |
+ |
+ // Return the index of the content run with the currently tallest columns, taking all implicit |
+ // breaks assumed so far into account. |
+ unsigned findRunWithTallestColumns() const; |
+ |
+ // Given the current list of content runs, make assumptions about where we need to insert |
+ // implicit breaks (if there's room for any at all; depending on the number of explicit breaks), |
+ // and store the results. This is needed in order to balance the columns. |
+ void distributeImplicitBreaks(); |
+ |
+ LayoutUnit calculateColumnHeight(BalancedColumnHeightCalculation) const; |
+ |
+ LayoutRect columnRectAt(unsigned columnIndex) const; |
+ LayoutRect flowThreadPortionRectAt(unsigned columnIndex) const; |
+ LayoutRect flowThreadPortionOverflowRect(const LayoutRect& flowThreadPortion, unsigned columnIndex, unsigned columnCount, LayoutUnit columnGap) const; |
+ |
+ enum ColumnIndexCalculationMode { |
+ ClampToExistingColumns, // Stay within the range of already existing columns. |
+ AssumeNewColumns // Allow column indices outside the range of already existing columns. |
+ }; |
+ unsigned columnIndexAtOffset(LayoutUnit offsetInFlowThread, ColumnIndexCalculationMode = ClampToExistingColumns) const; |
+ |
+ RenderMultiColumnSet& m_columnSet; |
+ |
+ LayoutUnit m_logicalTop; |
+ LayoutUnit m_logicalTopInFlowThread; |
+ LayoutUnit m_logicalBottomInFlowThread; |
+ |
+ LayoutUnit m_columnHeight; |
+ |
+ // The following variables are used when balancing the column set. |
+ LayoutUnit m_maxColumnHeight; // Maximum column height allowed. |
+ LayoutUnit m_minSpaceShortage; // The smallest amout of space shortage that caused a column break. |
+ LayoutUnit m_minimumColumnHeight; |
+ |
+ // A run of content without explicit (forced) breaks; i.e. a flow thread portion between two |
+ // explicit breaks, between flow thread start and an explicit break, between an explicit break |
+ // and flow thread end, or, in cases when there are no explicit breaks at all: between flow |
+ // thread portion start and flow thread portion end. We need to know where the explicit breaks |
+ // are, in order to figure out where the implicit breaks will end up, so that we get the columns |
+ // properly balanced. A content run starts out as representing one single column, and will |
+ // represent one additional column for each implicit break "inserted" there. |
+ class ContentRun { |
+ public: |
+ ContentRun(LayoutUnit breakOffset) |
+ : m_breakOffset(breakOffset) |
+ , m_assumedImplicitBreaks(0) { } |
+ |
+ unsigned assumedImplicitBreaks() const { return m_assumedImplicitBreaks; } |
+ void assumeAnotherImplicitBreak() { m_assumedImplicitBreaks++; } |
+ LayoutUnit breakOffset() const { return m_breakOffset; } |
+ |
+ // Return the column height that this content run would require, considering the implicit |
+ // breaks assumed so far. |
+ LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ceilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1)); } |
+ |
+ private: |
+ LayoutUnit m_breakOffset; // Flow thread offset where this run ends. |
+ unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this run assumed so far. |
+ }; |
+ Vector<ContentRun, 1> m_contentRuns; |
+}; |
+ |
+} // namespace blink |
+ |
+#endif // MultiColumnRow_h |