summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderMultiColumnSet.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/RenderMultiColumnSet.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/RenderMultiColumnSet.h')
-rw-r--r--Source/WebCore/rendering/RenderMultiColumnSet.h117
1 files changed, 83 insertions, 34 deletions
diff --git a/Source/WebCore/rendering/RenderMultiColumnSet.h b/Source/WebCore/rendering/RenderMultiColumnSet.h
index 0a95c403e..b1ae20eca 100644
--- a/Source/WebCore/rendering/RenderMultiColumnSet.h
+++ b/Source/WebCore/rendering/RenderMultiColumnSet.h
@@ -13,7 +13,7 @@
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -23,10 +23,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#pragma once
-#ifndef RenderMultiColumnSet_h
-#define RenderMultiColumnSet_h
-
+#include "LayerFragment.h"
+#include "RenderMultiColumnFlowThread.h"
#include "RenderRegionSet.h"
#include <wtf/Vector.h>
@@ -44,13 +44,32 @@ namespace WebCore {
// come before and after the span.
class RenderMultiColumnSet final : public RenderRegionSet {
public:
- RenderMultiColumnSet(RenderFlowThread&, PassRef<RenderStyle>);
+ RenderMultiColumnSet(RenderFlowThread&, RenderStyle&&);
+
+ RenderBlockFlow* multiColumnBlockFlow() const { return downcast<RenderBlockFlow>(parent()); }
+ RenderMultiColumnFlowThread* multiColumnFlowThread() const { return static_cast<RenderMultiColumnFlowThread*>(flowThread()); }
+
+ RenderMultiColumnSet* nextSiblingMultiColumnSet() const;
+ RenderMultiColumnSet* previousSiblingMultiColumnSet() const;
+
+ // Return the first object in the flow thread that's rendered inside this set.
+ RenderObject* firstRendererInFlowThread() const;
+ // Return the last object in the flow thread that's rendered inside this set.
+ RenderObject* lastRendererInFlowThread() const;
- virtual bool isRenderMultiColumnSet() const override { return true; }
+ // Return true if the specified renderer (descendant of the flow thread) is inside this column set.
+ bool containsRendererInFlowThread(const RenderObject&) const;
+
+ void setLogicalTopInFlowThread(LayoutUnit);
+ LayoutUnit logicalTopInFlowThread() const { return isHorizontalWritingMode() ? flowThreadPortionRect().y() : flowThreadPortionRect().x(); }
+ void setLogicalBottomInFlowThread(LayoutUnit);
+ LayoutUnit logicalBottomInFlowThread() const { return isHorizontalWritingMode() ? flowThreadPortionRect().maxY() : flowThreadPortionRect().maxX(); }
+ LayoutUnit logicalHeightInFlowThread() const { return isHorizontalWritingMode() ? flowThreadPortionRect().height() : flowThreadPortionRect().width(); }
unsigned computedColumnCount() const { return m_computedColumnCount; }
LayoutUnit computedColumnWidth() const { return m_computedColumnWidth; }
LayoutUnit computedColumnHeight() const { return m_computedColumnHeight; }
+ bool columnHeightComputed() const { return m_columnHeightComputed; }
void setComputedColumnWidthAndCount(LayoutUnit width, unsigned count)
{
@@ -67,10 +86,12 @@ public:
void clearForcedBreaks();
void addForcedBreak(LayoutUnit offsetFromFirstPage);
- // (Re-)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 recalculateBalancedHeight(bool initial);
+ // (Re-)calculate the column height. 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. If |initial| is set, and we are to balance, 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 recalculateColumnHeight(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
@@ -78,39 +99,68 @@ public:
// after layout that the columns weren't tall enough.
void recordSpaceShortage(LayoutUnit spaceShortage);
- virtual void updateLogicalWidth() override;
+ void updateLogicalWidth() override;
+
+ void prepareForLayout(bool initial);
+ // Begin laying out content for this column set. This happens at the beginning of flow thread
+ // layout, and when advancing from a previous column set or spanner to this one.
+ void beginFlow(RenderBlock* container);
+ // Finish laying out content for this column set. This happens at end of flow thread layout, and
+ // when advancing to the next column set or spanner.
+ void endFlow(RenderBlock* container, LayoutUnit bottomInContainer);
+ // Has this set been flowed in this layout pass?
+ bool hasBeenFlowed() const { return logicalBottomInFlowThread() != RenderFlowThread::maxLogicalHeight(); }
+
+ bool requiresBalancing() const;
- void prepareForLayout();
+ LayoutPoint columnTranslationForOffset(const LayoutUnit&) const;
+
+ void paintColumnRules(PaintInfo&, const LayoutPoint& paintOffset) override;
+
+ enum ColumnHitTestTranslationMode {
+ ClampHitTestTranslationToColumns,
+ DoNotClampHitTestTranslationToColumns
+ };
+ LayoutPoint translateRegionPointToFlowThread(const LayoutPoint & logicalPoint, ColumnHitTestTranslationMode = DoNotClampHitTestTranslationToColumns) const;
+
+ void updateHitTestResult(HitTestResult&, const LayoutPoint&) override;
+
+ LayoutRect columnRectAt(unsigned index) const;
+ unsigned columnCount() const;
protected:
void addOverflowFromChildren() override;
private:
- virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const override;
+ bool isRenderMultiColumnSet() const override { return true; }
+ void layout() override;
- virtual void paintObject(PaintInfo&, const LayoutPoint& paintOffset) override;
+ LogicalExtentComputedValues computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop) const override;
- virtual LayoutUnit pageLogicalWidth() const override { return m_computedColumnWidth; }
- virtual LayoutUnit pageLogicalHeight() const override { return m_computedColumnHeight; }
+ void paintObject(PaintInfo&, const LayoutPoint&) override { }
- virtual LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const override;
-
- // FIXME: This will change once we have column sets constrained by enclosing pages, etc.
- virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const override { return m_computedColumnHeight; }
-
- virtual void repaintFlowThreadContent(const LayoutRect& repaintRect, bool immediate) override;
+ LayoutUnit pageLogicalWidth() const override { return m_computedColumnWidth; }
+ LayoutUnit pageLogicalHeight() const override { return m_computedColumnHeight; }
- virtual void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect) override;
+ LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const override;
- virtual void adjustRegionBoundsFromFlowThreadPortionRect(const IntPoint& layerOffset, IntRect& regionBounds) override;
+ LayoutUnit logicalHeightOfAllFlowThreadContent() const override { return logicalHeightInFlowThread(); }
- virtual const char* renderName() const;
-
- void paintColumnRules(PaintInfo&, const LayoutPoint& paintOffset);
+ void repaintFlowThreadContent(const LayoutRect& repaintRect) override;
+
+ void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect) override;
+
+ void adjustRegionBoundsFromFlowThreadPortionRect(LayoutRect& regionBounds) const override;
+
+ VisiblePosition positionForPoint(const LayoutPoint&, const RenderRegion*) override;
+
+ const char* renderName() const override;
+ LayoutUnit calculateMaxColumnHeight() const;
LayoutUnit columnGap() const;
- LayoutRect columnRectAt(unsigned index) const;
- unsigned columnCount() const;
+
+ LayoutUnit columnLogicalLeft(unsigned) const;
+ LayoutUnit columnLogicalTop(unsigned) const;
LayoutRect flowThreadPortionRectAt(unsigned index) const;
LayoutRect flowThreadPortionOverflowRect(const LayoutRect& flowThreadPortion, unsigned index, unsigned colCount, LayoutUnit colGap);
@@ -139,7 +189,9 @@ private:
unsigned m_computedColumnCount; // Used column count (the resulting 'N' from the pseudo-algorithm in the multicol spec)
LayoutUnit m_computedColumnWidth; // Used column width (the resulting 'W' from the pseudo-algorithm in the multicol spec)
LayoutUnit m_computedColumnHeight;
-
+ LayoutUnit m_availableColumnHeight;
+ bool m_columnHeightComputed;
+
// 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.
@@ -173,9 +225,6 @@ private:
Vector<ContentRun, 1> m_contentRuns;
};
-RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet())
-
} // namespace WebCore
-#endif // RenderMultiColumnSet_h
-
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMultiColumnSet, isRenderMultiColumnSet())