OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // Column spans result in the creation of new column sets, since a spanning rend
erer has to be | 51 // Column spans result in the creation of new column sets, since a spanning rend
erer has to be |
52 // placed in between the column sets that come before and after the span. | 52 // placed in between the column sets that come before and after the span. |
53 class RenderMultiColumnSet FINAL : public RenderRegion { | 53 class RenderMultiColumnSet FINAL : public RenderRegion { |
54 public: | 54 public: |
55 enum BalancedHeightCalculation { GuessFromFlowThreadPortion, StretchBySpaceS
hortage }; | 55 enum BalancedHeightCalculation { GuessFromFlowThreadPortion, StretchBySpaceS
hortage }; |
56 | 56 |
57 static RenderMultiColumnSet* createAnonymous(RenderFlowThread*, RenderStyle*
parentStyle); | 57 static RenderMultiColumnSet* createAnonymous(RenderFlowThread*, RenderStyle*
parentStyle); |
58 | 58 |
59 virtual bool isRenderMultiColumnSet() const OVERRIDE { return true; } | 59 virtual bool isRenderMultiColumnSet() const OVERRIDE { return true; } |
60 | 60 |
| 61 virtual LayoutUnit pageLogicalWidth() const OVERRIDE FINAL { return flowThre
ad()->logicalWidth(); } |
| 62 virtual LayoutUnit pageLogicalHeight() const OVERRIDE FINAL { return m_colum
nHeight; } |
| 63 |
61 RenderBlockFlow* multiColumnBlockFlow() const { return toRenderBlockFlow(par
ent()); } | 64 RenderBlockFlow* multiColumnBlockFlow() const { return toRenderBlockFlow(par
ent()); } |
62 RenderMultiColumnFlowThread* multiColumnFlowThread() const | 65 RenderMultiColumnFlowThread* multiColumnFlowThread() const |
63 { | 66 { |
64 ASSERT_WITH_SECURITY_IMPLICATION(!flowThread() || flowThread()->isRender
MultiColumnFlowThread()); | 67 ASSERT_WITH_SECURITY_IMPLICATION(!flowThread() || flowThread()->isRender
MultiColumnFlowThread()); |
65 return static_cast<RenderMultiColumnFlowThread*>(flowThread()); | 68 return static_cast<RenderMultiColumnFlowThread*>(flowThread()); |
66 } | 69 } |
67 | 70 |
68 RenderMultiColumnSet* nextSiblingMultiColumnSet() const; | 71 RenderMultiColumnSet* nextSiblingMultiColumnSet() const; |
69 RenderMultiColumnSet* previousSiblingMultiColumnSet() const; | 72 RenderMultiColumnSet* previousSiblingMultiColumnSet() const; |
70 | 73 |
71 LayoutUnit logicalTopInFlowThread() const { return isHorizontalWritingMode()
? flowThreadPortionRect().y() : flowThreadPortionRect().x(); } | 74 LayoutUnit logicalTopInFlowThread() const { return isHorizontalWritingMode()
? flowThreadPortionRect().y() : flowThreadPortionRect().x(); } |
72 LayoutUnit logicalBottomInFlowThread() const { return isHorizontalWritingMod
e() ? flowThreadPortionRect().maxY() : flowThreadPortionRect().maxX(); } | 75 LayoutUnit logicalBottomInFlowThread() const { return isHorizontalWritingMod
e() ? flowThreadPortionRect().maxY() : flowThreadPortionRect().maxX(); } |
73 | 76 |
74 LayoutUnit logicalHeightInFlowThread() const { return isHorizontalWritingMod
e() ? flowThreadPortionRect().height() : flowThreadPortionRect().width(); } | 77 LayoutUnit logicalHeightInFlowThread() const { return isHorizontalWritingMod
e() ? flowThreadPortionRect().height() : flowThreadPortionRect().width(); } |
75 | 78 |
76 unsigned computedColumnCount() const { return m_computedColumnCount; } | 79 // The used CSS value of column-count, i.e. how many columns there are room
for without overflowing. |
77 LayoutUnit computedColumnWidth() const { return m_computedColumnWidth; } | 80 unsigned usedColumnCount() const { return multiColumnFlowThread()->columnCou
nt(); } |
78 LayoutUnit computedColumnHeight() const { return m_computedColumnHeight; } | |
79 | |
80 void setComputedColumnWidthAndCount(LayoutUnit width, unsigned count) | |
81 { | |
82 m_computedColumnWidth = width; | |
83 m_computedColumnCount = count; | |
84 } | |
85 | 81 |
86 // Find the column that contains the given block offset, and return the tran
slation needed to | 82 // Find the column that contains the given block offset, and return the tran
slation needed to |
87 // get from flow thread coordinates to visual coordinates. | 83 // get from flow thread coordinates to visual coordinates. |
88 LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const; | 84 LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const; |
89 | 85 |
90 LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const; | 86 LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const; |
91 | 87 |
92 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight =
std::max(height, m_minimumColumnHeight); } | 88 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight =
std::max(height, m_minimumColumnHeight); } |
93 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; } | 89 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; } |
94 | 90 |
(...skipping 19 matching lines...) Expand all Loading... |
114 // overflow. Only to be called on the last set. | 110 // overflow. Only to be called on the last set. |
115 void expandToEncompassFlowThreadContentsIfNeeded(); | 111 void expandToEncompassFlowThreadContentsIfNeeded(); |
116 | 112 |
117 private: | 113 private: |
118 RenderMultiColumnSet(RenderFlowThread*); | 114 RenderMultiColumnSet(RenderFlowThread*); |
119 | 115 |
120 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const OVERRIDE; | 116 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const OVERRIDE; |
121 | 117 |
122 virtual void paintObject(PaintInfo&, const LayoutPoint& paintOffset) OVERRID
E; | 118 virtual void paintObject(PaintInfo&, const LayoutPoint& paintOffset) OVERRID
E; |
123 | 119 |
124 virtual LayoutUnit pageLogicalWidth() const OVERRIDE { return m_computedColu
mnWidth; } | |
125 virtual LayoutUnit pageLogicalHeight() const OVERRIDE { return m_computedCol
umnHeight; } | |
126 | |
127 virtual LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const OVERRIDE
; | 120 virtual LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const OVERRIDE
; |
128 | 121 |
129 virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const OVERRIDE { re
turn logicalHeightInFlowThread(); } | 122 virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const OVERRIDE { re
turn logicalHeightInFlowThread(); } |
130 | 123 |
131 virtual void repaintFlowThreadContent(const LayoutRect& repaintRect) const O
VERRIDE; | 124 virtual void repaintFlowThreadContent(const LayoutRect& repaintRect) const O
VERRIDE; |
132 | 125 |
133 virtual void collectLayerFragments(LayerFragments&, const LayoutRect& layerB
oundingBox, const LayoutRect& dirtyRect) OVERRIDE; | 126 virtual void collectLayerFragments(LayerFragments&, const LayoutRect& layerB
oundingBox, const LayoutRect& dirtyRect) OVERRIDE; |
134 | 127 |
135 virtual void addOverflowFromChildren() OVERRIDE; | 128 virtual void addOverflowFromChildren() OVERRIDE; |
136 | 129 |
137 virtual const char* renderName() const OVERRIDE; | 130 virtual const char* renderName() const OVERRIDE; |
138 | 131 |
139 void paintColumnRules(PaintInfo&, const LayoutPoint& paintOffset); | 132 void paintColumnRules(PaintInfo&, const LayoutPoint& paintOffset); |
140 | 133 |
141 LayoutUnit calculateMaxColumnHeight() const; | 134 LayoutUnit calculateMaxColumnHeight() const; |
142 LayoutUnit columnGap() const; | 135 LayoutUnit columnGap() const; |
143 LayoutRect columnRectAt(unsigned index) const; | 136 LayoutRect columnRectAt(unsigned index) const; |
144 unsigned columnCount() const; | 137 |
| 138 // The "CSS actual" value of column-count. This includes overflowing columns
, if any. |
| 139 unsigned actualColumnCount() const; |
145 | 140 |
146 LayoutRect flowThreadPortionRectAt(unsigned index) const; | 141 LayoutRect flowThreadPortionRectAt(unsigned index) const; |
147 LayoutRect flowThreadPortionOverflowRect(const LayoutRect& flowThreadPortion
, unsigned index, unsigned colCount, LayoutUnit colGap) const; | 142 LayoutRect flowThreadPortionOverflowRect(const LayoutRect& flowThreadPortion
, unsigned index, unsigned colCount, LayoutUnit colGap) const; |
148 | 143 |
149 enum ColumnIndexCalculationMode { | 144 enum ColumnIndexCalculationMode { |
150 ClampToExistingColumns, // Stay within the range of already existing col
umns. | 145 ClampToExistingColumns, // Stay within the range of already existing col
umns. |
151 AssumeNewColumns // Allow column indices outside the range of already ex
isting columns. | 146 AssumeNewColumns // Allow column indices outside the range of already ex
isting columns. |
152 }; | 147 }; |
153 unsigned columnIndexAtOffset(LayoutUnit, ColumnIndexCalculationMode = ClampT
oExistingColumns) const; | 148 unsigned columnIndexAtOffset(LayoutUnit, ColumnIndexCalculationMode = ClampT
oExistingColumns) const; |
154 | 149 |
155 void setAndConstrainColumnHeight(LayoutUnit); | 150 void setAndConstrainColumnHeight(LayoutUnit); |
156 | 151 |
157 // Return the index of the content run with the currently tallest columns, t
aking all implicit | 152 // Return the index of the content run with the currently tallest columns, t
aking all implicit |
158 // breaks assumed so far into account. | 153 // breaks assumed so far into account. |
159 unsigned findRunWithTallestColumns() const; | 154 unsigned findRunWithTallestColumns() const; |
160 | 155 |
161 // Given the current list of content runs, make assumptions about where we n
eed to insert | 156 // Given the current list of content runs, make assumptions about where we n
eed to insert |
162 // implicit breaks (if there's room for any at all; depending on the number
of explicit breaks), | 157 // implicit breaks (if there's room for any at all; depending on the number
of explicit breaks), |
163 // and store the results. This is needed in order to balance the columns. | 158 // and store the results. This is needed in order to balance the columns. |
164 void distributeImplicitBreaks(); | 159 void distributeImplicitBreaks(); |
165 | 160 |
166 LayoutUnit calculateColumnHeight(BalancedHeightCalculation) const; | 161 LayoutUnit calculateColumnHeight(BalancedHeightCalculation) const; |
167 | 162 |
168 unsigned m_computedColumnCount; // Used column count (the resulting 'N' from
the pseudo-algorithm in the multicol spec) | 163 LayoutUnit m_columnHeight; |
169 LayoutUnit m_computedColumnWidth; // Used column width (the resulting 'W' fr
om the pseudo-algorithm in the multicol spec) | |
170 LayoutUnit m_computedColumnHeight; | |
171 | 164 |
172 // The following variables are used when balancing the column set. | 165 // The following variables are used when balancing the column set. |
173 LayoutUnit m_maxColumnHeight; // Maximum column height allowed. | 166 LayoutUnit m_maxColumnHeight; // Maximum column height allowed. |
174 LayoutUnit m_minSpaceShortage; // The smallest amout of space shortage that
caused a column break. | 167 LayoutUnit m_minSpaceShortage; // The smallest amout of space shortage that
caused a column break. |
175 LayoutUnit m_minimumColumnHeight; | 168 LayoutUnit m_minimumColumnHeight; |
176 | 169 |
177 // A run of content without explicit (forced) breaks; i.e. a flow thread por
tion between two | 170 // A run of content without explicit (forced) breaks; i.e. a flow thread por
tion between two |
178 // explicit breaks, between flow thread start and an explicit break, between
an explicit break | 171 // explicit breaks, between flow thread start and an explicit break, between
an explicit break |
179 // and flow thread end, or, in cases when there are no explicit breaks at al
l: between flow | 172 // and flow thread end, or, in cases when there are no explicit breaks at al
l: between flow |
180 // thread portion start and flow thread portion end. We need to know where t
he explicit breaks | 173 // thread portion start and flow thread portion end. We need to know where t
he explicit breaks |
(...skipping 20 matching lines...) Expand all Loading... |
201 }; | 194 }; |
202 Vector<ContentRun, 1> m_contentRuns; | 195 Vector<ContentRun, 1> m_contentRuns; |
203 }; | 196 }; |
204 | 197 |
205 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet()); | 198 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet()); |
206 | 199 |
207 } // namespace WebCore | 200 } // namespace WebCore |
208 | 201 |
209 #endif // RenderMultiColumnSet_h | 202 #endif // RenderMultiColumnSet_h |
210 | 203 |
OLD | NEW |