diff options
| author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-09-13 12:51:20 +0200 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 20:50:05 +0200 |
| commit | d441d6f39bb846989d95bcf5caf387b42414718d (patch) | |
| tree | e367e64a75991c554930278175d403c072de6bb8 /Source/WebCore/rendering/RenderMultiColumnSet.h | |
| parent | 0060b2994c07842f4c59de64b5e3e430525c4b90 (diff) | |
| download | qtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz | |
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit.
Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebCore/rendering/RenderMultiColumnSet.h')
| -rw-r--r-- | Source/WebCore/rendering/RenderMultiColumnSet.h | 70 |
1 files changed, 55 insertions, 15 deletions
diff --git a/Source/WebCore/rendering/RenderMultiColumnSet.h b/Source/WebCore/rendering/RenderMultiColumnSet.h index 88653035c..5f597f7ee 100644 --- a/Source/WebCore/rendering/RenderMultiColumnSet.h +++ b/Source/WebCore/rendering/RenderMultiColumnSet.h @@ -43,8 +43,8 @@ namespace WebCore { // come before and after the span. class RenderMultiColumnSet : public RenderRegionSet { public: - RenderMultiColumnSet(Node*, RenderFlowThread*); - + static RenderMultiColumnSet* createAnonymous(RenderFlowThread*); + virtual bool isRenderMultiColumnSet() const OVERRIDE { return true; } unsigned computedColumnCount() const { return m_computedColumnCount; } @@ -56,10 +56,8 @@ public: m_computedColumnWidth = width; m_computedColumnCount = count; } - void setComputedColumnHeight(LayoutUnit height) - { - m_computedColumnHeight = height; - } + + LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const; void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); } LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; } @@ -84,13 +82,27 @@ public: m_forcedBreakOffset = offsetFromFirstPage; } -private: + // Calculate the column height when contents are supposed to be balanced. If 'initial' is set, + // guess an initial column height; otherwise, stretch the column height a tad. Return true if + // column height changed and another layout pass is required. + bool calculateBalancedHeight(bool initial); + + // 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 + // shortage we find is the amount with which we will stretch the column height, if it turns out + // after layout that the columns weren't tall enough. + void recordSpaceShortage(LayoutUnit spaceShortage); + virtual void updateLogicalWidth() OVERRIDE; - virtual void updateLogicalHeight() OVERRIDE; + + void prepareForLayout(); + +private: + RenderMultiColumnSet(RenderFlowThread*); + virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const OVERRIDE; - virtual void paintReplaced(PaintInfo&, const LayoutPoint& paintOffset) OVERRIDE; - virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE; + virtual void paintObject(PaintInfo&, const LayoutPoint& paintOffset) OVERRIDE; virtual LayoutUnit pageLogicalWidth() const OVERRIDE { return m_computedColumnWidth; } virtual LayoutUnit pageLogicalHeight() const OVERRIDE { return m_computedColumnHeight; } @@ -99,34 +111,62 @@ private: // FIXME: This will change once we have column sets constrained by enclosing pages, etc. virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const OVERRIDE { return m_computedColumnHeight; } + + // FIXME: For now we return false, but it's likely we will leverage the auto height region code to do column + // balancing. That's why we have an override of this function that is distinct from RenderRegionSet's override. + virtual bool shouldHaveAutoLogicalHeight() const OVERRIDE { return false; } virtual void repaintFlowThreadContent(const LayoutRect& repaintRect, bool immediate) const OVERRIDE; + virtual void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect) OVERRIDE; + virtual const char* renderName() const; void paintColumnRules(PaintInfo&, const LayoutPoint& paintOffset); - void paintColumnContents(PaintInfo&, const LayoutPoint& paintOffset); LayoutUnit columnGap() const; LayoutRect columnRectAt(unsigned index) const; unsigned columnCount() const; LayoutRect flowThreadPortionRectAt(unsigned index) const; - LayoutRect flowThreadPortionOverflowRect(const LayoutRect& flowThreadPortion, unsigned index, unsigned colCount, int colGap) const; - - unsigned columnIndexAtOffset(LayoutUnit) const; - + LayoutRect flowThreadPortionOverflowRect(const LayoutRect& flowThreadPortion, unsigned index, unsigned colCount, LayoutUnit colGap) 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, ColumnIndexCalculationMode = ClampToExistingColumns) const; + + void setAndConstrainColumnHeight(LayoutUnit); + unsigned m_computedColumnCount; LayoutUnit m_computedColumnWidth; LayoutUnit m_computedColumnHeight; // 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; unsigned m_forcedBreaksCount; // FIXME: We will ultimately need to cache more information to balance around forced breaks properly. LayoutUnit m_maximumDistanceBetweenForcedBreaks; LayoutUnit m_forcedBreakOffset; }; +inline RenderMultiColumnSet* toRenderMultiColumnSet(RenderObject* object) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderMultiColumnSet()); + return static_cast<RenderMultiColumnSet*>(object); +} + +inline const RenderMultiColumnSet* toRenderMultiColumnSet(const RenderObject* object) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderMultiColumnSet()); + return static_cast<const RenderMultiColumnSet*>(object); +} + +// This will catch anyone doing an unnecessary cast. +void toRenderMultiColumnSet(const RenderMultiColumnSet*); + } // namespace WebCore #endif // RenderMultiColumnSet_h |
