RenderMultiColumnSet.h [plain text]
#pragma once
#include "LayerFragment.h"
#include "RenderMultiColumnFlowThread.h"
#include "RenderRegionSet.h"
#include <wtf/Vector.h>
namespace WebCore {
class RenderMultiColumnSet final : public RenderRegionSet {
public:
RenderMultiColumnSet(RenderFlowThread&, RenderStyle&&);
RenderBlockFlow* multiColumnBlockFlow() const { return downcast<RenderBlockFlow>(parent()); }
RenderMultiColumnFlowThread* multiColumnFlowThread() const { return static_cast<RenderMultiColumnFlowThread*>(flowThread()); }
RenderMultiColumnSet* nextSiblingMultiColumnSet() const;
RenderMultiColumnSet* previousSiblingMultiColumnSet() const;
RenderObject* firstRendererInFlowThread() const;
RenderObject* lastRendererInFlowThread() const;
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)
{
m_computedColumnWidth = width;
m_computedColumnCount = count;
}
LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const;
void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); }
LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; }
unsigned forcedBreaksCount() const { return m_contentRuns.size(); }
void clearForcedBreaks();
void addForcedBreak(LayoutUnit offsetFromFirstPage);
bool recalculateColumnHeight(bool initial);
void recordSpaceShortage(LayoutUnit spaceShortage);
void updateLogicalWidth() override;
void prepareForLayout(bool initial);
void beginFlow(RenderBlock* container);
void endFlow(RenderBlock* container, LayoutUnit bottomInContainer);
bool hasBeenFlowed() const { return logicalBottomInFlowThread() != RenderFlowThread::maxLogicalHeight(); }
bool requiresBalancing() const;
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:
bool isRenderMultiColumnSet() const override { return true; }
void layout() override;
LogicalExtentComputedValues computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop) const override;
void paintObject(PaintInfo&, const LayoutPoint&) override { }
LayoutUnit pageLogicalWidth() const override { return m_computedColumnWidth; }
LayoutUnit pageLogicalHeight() const override { return m_computedColumnHeight; }
LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const override;
LayoutUnit logicalHeightOfAllFlowThreadContent() const override { return logicalHeightInFlowThread(); }
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;
LayoutUnit columnLogicalLeft(unsigned) const;
LayoutUnit columnLogicalTop(unsigned) const;
LayoutRect flowThreadPortionRectAt(unsigned index) const;
LayoutRect flowThreadPortionOverflowRect(const LayoutRect& flowThreadPortion, unsigned index, unsigned colCount, LayoutUnit colGap);
LayoutUnit initialBlockOffsetForPainting() const;
enum ColumnIndexCalculationMode {
ClampToExistingColumns, AssumeNewColumns };
unsigned columnIndexAtOffset(LayoutUnit, ColumnIndexCalculationMode = ClampToExistingColumns) const;
void setAndConstrainColumnHeight(LayoutUnit);
unsigned findRunWithTallestColumns() const;
void distributeImplicitBreaks();
LayoutUnit calculateBalancedHeight(bool initial) const;
unsigned m_computedColumnCount; LayoutUnit m_computedColumnWidth; LayoutUnit m_computedColumnHeight;
LayoutUnit m_availableColumnHeight;
bool m_columnHeightComputed;
LayoutUnit m_maxColumnHeight; LayoutUnit m_minSpaceShortage; LayoutUnit m_minimumColumnHeight;
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; }
LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ceilf(float(m_breakOffset - startOffset) / float(m_assumedImplicitBreaks + 1)); }
private:
LayoutUnit m_breakOffset; unsigned m_assumedImplicitBreaks; };
Vector<ContentRun, 1> m_contentRuns;
};
}
SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMultiColumnSet, isRenderMultiColumnSet())