Index: Source/core/rendering/RenderMultiColumnSet.h |
diff --git a/Source/core/rendering/RenderMultiColumnSet.h b/Source/core/rendering/RenderMultiColumnSet.h |
index c09e482d166a8f0c834eb36c2c0a78627c40c0c9..ac223b6ae6292501a15c4db3679560ca35589ae9 100644 |
--- a/Source/core/rendering/RenderMultiColumnSet.h |
+++ b/Source/core/rendering/RenderMultiColumnSet.h |
@@ -50,7 +50,7 @@ namespace blink { |
// |
// Column spans result in the creation of new column sets, since a spanning renderer has to be |
// placed in between the column sets that come before and after the span. |
-class RenderMultiColumnSet FINAL : public RenderRegion { |
+class RenderMultiColumnSet : public RenderRegion { |
public: |
enum BalancedHeightCalculation { GuessFromFlowThreadPortion, StretchBySpaceShortage }; |
@@ -59,7 +59,7 @@ public: |
virtual bool isRenderMultiColumnSet() const OVERRIDE { return true; } |
virtual LayoutUnit pageLogicalWidth() const OVERRIDE FINAL { return flowThread()->logicalWidth(); } |
- virtual LayoutUnit pageLogicalHeight() const OVERRIDE FINAL { return m_columnHeight; } |
+ virtual LayoutUnit pageLogicalHeight() const OVERRIDE { return m_columnHeight; } |
RenderBlockFlow* multiColumnBlockFlow() const { return toRenderBlockFlow(parent()); } |
RenderMultiColumnFlowThread* multiColumnFlowThread() const |
@@ -71,14 +71,19 @@ public: |
RenderMultiColumnSet* nextSiblingMultiColumnSet() const; |
RenderMultiColumnSet* previousSiblingMultiColumnSet() const; |
+ void setLogicalTopInFlowThread(LayoutUnit); |
LayoutUnit logicalTopInFlowThread() const { return isHorizontalWritingMode() ? flowThreadPortionRect().y() : flowThreadPortionRect().x(); } |
- LayoutUnit logicalBottomInFlowThread() const { return isHorizontalWritingMode() ? flowThreadPortionRect().maxY() : flowThreadPortionRect().maxX(); } |
- |
LayoutUnit logicalHeightInFlowThread() const { return isHorizontalWritingMode() ? flowThreadPortionRect().height() : flowThreadPortionRect().width(); } |
+ void setLogicalBottomInFlowThread(LayoutUnit); |
+ LayoutUnit logicalBottomInFlowThread() const { return isHorizontalWritingMode() ? flowThreadPortionRect().maxY() : flowThreadPortionRect().maxX(); } |
// The used CSS value of column-count, i.e. how many columns there are room for without overflowing. |
unsigned usedColumnCount() const { return multiColumnFlowThread()->columnCount(); } |
+ bool heightIsAuto() const; |
+ |
+ bool requiresBalancing() const { return !isRenderMultiColumnSpannerSet() && heightIsAuto(); } |
+ |
// Find the column that contains the given block offset, and return the translation needed to |
// get from flow thread coordinates to visual coordinates. |
LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const; |
@@ -94,8 +99,10 @@ public: |
// height. |
void addContentRun(LayoutUnit endOffsetFromFirstPage); |
- // (Re-)calculate the column height if it's auto. |
- bool recalculateColumnHeight(BalancedHeightCalculation); |
+ // (Re-)calculate the column height if it's auto. This is first and foremost needed by sets that |
+ // are to balance the column height, but even when it isn't to be balanced, this is necessary if |
+ // the multicol container's height is constrained. |
+ virtual bool recalculateColumnHeight(BalancedHeightCalculation); |
// Record space shortage (the amount of space that would have been enough to prevent some |
// element from being moved to the next column) at a column break. The smallest amount of space |
@@ -106,6 +113,17 @@ public: |
// Reset previously calculated column height. Will mark for layout if needed. |
void resetColumnHeight(); |
+ // Prepare this set for flow thread layout. |
+ void resetFlow(); |
+ // Layout of flow thread content that's to be rendered inside this column set begins. This |
+ // happens at the beginning of flow thread layout, and when advancing from a previous column set |
+ // or spanner to this one. |
+ void beginFlow(LayoutUnit offsetInFlowThread); |
+ // Layout of flow thread content that was to be rendered inside this column set has |
+ // finished. This happens at end of flow thread layout, and when advancing to the next column |
+ // set or spanner. |
+ void endFlow(LayoutUnit offsetInFlowThread); |
+ |
// Expand this set's flow thread portion rectangle to contain all trailing flow thread |
// overflow. Only to be called on the last set. |
void expandToEncompassFlowThreadContentsIfNeeded(); |
@@ -127,9 +145,10 @@ public: |
void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect); |
-private: |
+protected: |
RenderMultiColumnSet(RenderFlowThread*); |
+private: |
virtual void insertedIntoTree() OVERRIDE FINAL; |
virtual void willBeRemovedFromTree() OVERRIDE FINAL; |
@@ -207,6 +226,28 @@ private: |
Vector<ContentRun, 1> m_contentRuns; |
}; |
+inline void RenderMultiColumnSet::resetFlow() |
+{ |
+ // Start with "infinite" flow thread portion height until height is known. |
+ setLogicalBottomInFlowThread(RenderFlowThread::maxLogicalHeight()); |
+} |
+ |
+inline void RenderMultiColumnSet::beginFlow(LayoutUnit offsetInFlowThread) |
+{ |
+ // At this point layout is exactly at the beginning of this set. Store block offset from flow |
+ // thread start. |
+ setLogicalTopInFlowThread(offsetInFlowThread); |
+} |
+ |
+inline void RenderMultiColumnSet::endFlow(LayoutUnit offsetInFlowThread) |
+{ |
+ // At this point layout is exactly at the end of this set. Store block offset from flow thread |
+ // start. This set is now considered "flowed", although we may have to revisit it later (with |
+ // beginFlow()), e.g. if a subtree in the flow thread has to be laid out over again because the |
+ // initial margin collapsing estimates were wrong. |
+ setLogicalBottomInFlowThread(offsetInFlowThread); |
+} |
+ |
DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet()); |
} // namespace blink |