| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 #ifndef ColumnInfo_h | |
| 27 #define ColumnInfo_h | |
| 28 | |
| 29 #include "platform/LayoutUnit.h" | |
| 30 #include "wtf/Vector.h" | |
| 31 | |
| 32 namespace WebCore { | |
| 33 | |
| 34 class ColumnInfo { | |
| 35 WTF_MAKE_NONCOPYABLE(ColumnInfo); WTF_MAKE_FAST_ALLOCATED; | |
| 36 public: | |
| 37 ColumnInfo() | |
| 38 : m_desiredColumnWidth(0) | |
| 39 , m_desiredColumnCount(1) | |
| 40 , m_progressionAxis(InlineAxis) | |
| 41 , m_progressionIsReversed(false) | |
| 42 , m_columnCount(1) | |
| 43 , m_columnHeight(0) | |
| 44 , m_minimumColumnHeight(0) | |
| 45 , m_forcedBreaks(0) | |
| 46 , m_maximumDistanceBetweenForcedBreaks(0) | |
| 47 , m_forcedBreakOffset(0) | |
| 48 , m_paginationUnit(Column) | |
| 49 { | |
| 50 } | |
| 51 | |
| 52 LayoutUnit desiredColumnWidth() const { return m_desiredColumnWidth; } | |
| 53 void setDesiredColumnWidth(LayoutUnit width) { m_desiredColumnWidth = width;
} | |
| 54 | |
| 55 unsigned desiredColumnCount() const { return m_desiredColumnCount; } | |
| 56 void setDesiredColumnCount(unsigned count) { m_desiredColumnCount = count; } | |
| 57 | |
| 58 enum Axis { InlineAxis, BlockAxis }; | |
| 59 | |
| 60 Axis progressionAxis() const { return m_progressionAxis; } | |
| 61 void setProgressionAxis(Axis progressionAxis) { m_progressionAxis = progress
ionAxis; } | |
| 62 | |
| 63 bool progressionIsReversed() const { return m_progressionIsReversed; } | |
| 64 void setProgressionIsReversed(bool reversed) { m_progressionIsReversed = rev
ersed; } | |
| 65 | |
| 66 unsigned columnCount() const { return m_columnCount; } | |
| 67 LayoutUnit columnHeight() const { return m_columnHeight; } | |
| 68 | |
| 69 // Set our count and height. This is enough info for a RenderBlock to compu
te page rects | |
| 70 // dynamically. | |
| 71 void setColumnCountAndHeight(int count, LayoutUnit height) | |
| 72 { | |
| 73 m_columnCount = count; | |
| 74 m_columnHeight = height; | |
| 75 } | |
| 76 void setColumnHeight(LayoutUnit height) { m_columnHeight = height; } | |
| 77 | |
| 78 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight =
std::max(height, m_minimumColumnHeight); } | |
| 79 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; } | |
| 80 | |
| 81 int forcedBreaks() const { return m_forcedBreaks; } | |
| 82 LayoutUnit forcedBreakOffset() const { return m_forcedBreakOffset; } | |
| 83 LayoutUnit maximumDistanceBetweenForcedBreaks() const { return m_maximumDist
anceBetweenForcedBreaks; } | |
| 84 void clearForcedBreaks() | |
| 85 { | |
| 86 m_forcedBreaks = 0; | |
| 87 m_maximumDistanceBetweenForcedBreaks = 0; | |
| 88 m_forcedBreakOffset = 0; | |
| 89 } | |
| 90 void addForcedBreak(LayoutUnit offsetFromFirstPage) | |
| 91 { | |
| 92 ASSERT(!m_columnHeight); | |
| 93 LayoutUnit distanceFromLastBreak = offsetFromFirstPage - m_forcedBreakOf
fset; | |
| 94 if (!distanceFromLastBreak) | |
| 95 return; | |
| 96 m_forcedBreaks++; | |
| 97 m_maximumDistanceBetweenForcedBreaks = std::max(m_maximumDistanceBetween
ForcedBreaks, distanceFromLastBreak); | |
| 98 m_forcedBreakOffset = offsetFromFirstPage; | |
| 99 } | |
| 100 | |
| 101 enum PaginationUnit { Column, Page }; | |
| 102 PaginationUnit paginationUnit() const { return m_paginationUnit; } | |
| 103 void setPaginationUnit(PaginationUnit paginationUnit) { m_paginationUnit = p
aginationUnit; } | |
| 104 | |
| 105 private: | |
| 106 LayoutUnit m_desiredColumnWidth; | |
| 107 unsigned m_desiredColumnCount; | |
| 108 Axis m_progressionAxis; | |
| 109 bool m_progressionIsReversed; | |
| 110 | |
| 111 unsigned m_columnCount; | |
| 112 LayoutUnit m_columnHeight; | |
| 113 LayoutUnit m_minimumColumnHeight; | |
| 114 int m_forcedBreaks; // FIXME: We will ultimately need to cache more informat
ion to balance around forced breaks properly. | |
| 115 LayoutUnit m_maximumDistanceBetweenForcedBreaks; | |
| 116 LayoutUnit m_forcedBreakOffset; | |
| 117 PaginationUnit m_paginationUnit; | |
| 118 }; | |
| 119 | |
| 120 } | |
| 121 | |
| 122 #endif | |
| OLD | NEW |