#ifndef ColumnInfo_h
#define ColumnInfo_h
#include "platform/LayoutUnit.h"
#include "wtf/Vector.h"
namespace WebCore {
class ColumnInfo {
WTF_MAKE_NONCOPYABLE(ColumnInfo); WTF_MAKE_FAST_ALLOCATED;
public:
ColumnInfo()
: m_desiredColumnWidth(0)
, m_desiredColumnCount(1)
, m_progressionAxis(InlineAxis)
, m_columnCount(1)
, m_columnHeight(0)
, m_minimumColumnHeight(0)
, m_forcedBreaks(0)
, m_maximumDistanceBetweenForcedBreaks(0)
, m_forcedBreakOffset(0)
{
}
LayoutUnit desiredColumnWidth() const { return m_desiredColumnWidth; }
void setDesiredColumnWidth(LayoutUnit width) { m_desiredColumnWidth = width; }
unsigned desiredColumnCount() const { return m_desiredColumnCount; }
void setDesiredColumnCount(unsigned count) { m_desiredColumnCount = count; }
enum Axis { InlineAxis, BlockAxis };
Axis progressionAxis() const { return m_progressionAxis; }
void setProgressionAxis(Axis progressionAxis) { m_progressionAxis = progressionAxis; }
unsigned columnCount() const { return m_columnCount; }
LayoutUnit columnHeight() const { return m_columnHeight; }
void setColumnCountAndHeight(int count, LayoutUnit height)
{
m_columnCount = count;
m_columnHeight = height;
}
void setColumnHeight(LayoutUnit height) { m_columnHeight = height; }
void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); }
LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; }
int forcedBreaks() const { return m_forcedBreaks; }
LayoutUnit forcedBreakOffset() const { return m_forcedBreakOffset; }
LayoutUnit maximumDistanceBetweenForcedBreaks() const { return m_maximumDistanceBetweenForcedBreaks; }
void clearForcedBreaks()
{
m_forcedBreaks = 0;
m_maximumDistanceBetweenForcedBreaks = 0;
m_forcedBreakOffset = 0;
}
void addForcedBreak(LayoutUnit offsetFromFirstPage)
{
ASSERT(!m_columnHeight);
LayoutUnit distanceFromLastBreak = offsetFromFirstPage - m_forcedBreakOffset;
if (!distanceFromLastBreak)
return;
m_forcedBreaks++;
m_maximumDistanceBetweenForcedBreaks = std::max(m_maximumDistanceBetweenForcedBreaks, distanceFromLastBreak);
m_forcedBreakOffset = offsetFromFirstPage;
}
private:
LayoutUnit m_desiredColumnWidth;
unsigned m_desiredColumnCount;
Axis m_progressionAxis;
unsigned m_columnCount;
LayoutUnit m_columnHeight;
LayoutUnit m_minimumColumnHeight;
int m_forcedBreaks;
LayoutUnit m_maximumDistanceBetweenForcedBreaks;
LayoutUnit m_forcedBreakOffset;
};
}
#endif