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 10 matching lines...) Expand all Loading... |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 | 26 |
27 #ifndef LayoutMultiColumnFlowThread_h | 27 #ifndef LayoutMultiColumnFlowThread_h |
28 #define LayoutMultiColumnFlowThread_h | 28 #define LayoutMultiColumnFlowThread_h |
29 | 29 |
30 #include "core/CoreExport.h" | 30 #include "core/CoreExport.h" |
| 31 #include "core/layout/FragmentationContext.h" |
31 #include "core/layout/LayoutFlowThread.h" | 32 #include "core/layout/LayoutFlowThread.h" |
32 | 33 |
33 namespace blink { | 34 namespace blink { |
34 | 35 |
35 class LayoutMultiColumnSet; | 36 class LayoutMultiColumnSet; |
36 class LayoutMultiColumnSpannerPlaceholder; | 37 class LayoutMultiColumnSpannerPlaceholder; |
37 | 38 |
38 // Flow thread implementation for CSS multicol. This will be inserted as an anon
ymous child block of | 39 // Flow thread implementation for CSS multicol. This will be inserted as an anon
ymous child block of |
39 // the actual multicol container (i.e. the LayoutBlockFlow whose style computes
to non-auto | 40 // the actual multicol container (i.e. the LayoutBlockFlow whose style computes
to non-auto |
40 // column-count and/or column-width). LayoutMultiColumnFlowThread is the heart o
f the multicol | 41 // column-count and/or column-width). LayoutMultiColumnFlowThread is the heart o
f the multicol |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // perfectly in the number of columns that we have specified). The rule of thumb
is that we | 106 // perfectly in the number of columns that we have specified). The rule of thumb
is that we |
106 // shouldn't have to perform more of such iterations than the number of columns
that we have. | 107 // shouldn't have to perform more of such iterations than the number of columns
that we have. |
107 // | 108 // |
108 // For each layout iteration done for column balancing, the flow thread will nee
d a deep layout if | 109 // For each layout iteration done for column balancing, the flow thread will nee
d a deep layout if |
109 // column heights changed in the previous pass, since column height changes may
affect break points | 110 // column heights changed in the previous pass, since column height changes may
affect break points |
110 // and pagination struts anywhere in the tree, and currently no way exists to do
this in a more | 111 // and pagination struts anywhere in the tree, and currently no way exists to do
this in a more |
111 // optimized manner. | 112 // optimized manner. |
112 // | 113 // |
113 // There's also some documentation online: | 114 // There's also some documentation online: |
114 // https://sites.google.com/a/chromium.org/dev/developers/design-documents/multi
-column-layout | 115 // https://sites.google.com/a/chromium.org/dev/developers/design-documents/multi
-column-layout |
115 class CORE_EXPORT LayoutMultiColumnFlowThread : public LayoutFlowThread { | 116 class CORE_EXPORT LayoutMultiColumnFlowThread : public LayoutFlowThread, public
FragmentationContext { |
116 public: | 117 public: |
117 ~LayoutMultiColumnFlowThread() override; | 118 ~LayoutMultiColumnFlowThread() override; |
118 | 119 |
119 static LayoutMultiColumnFlowThread* createAnonymous(Document&, const Compute
dStyle& parentStyle); | 120 static LayoutMultiColumnFlowThread* createAnonymous(Document&, const Compute
dStyle& parentStyle); |
120 | 121 |
121 bool isLayoutMultiColumnFlowThread() const final { return true; } | 122 bool isLayoutMultiColumnFlowThread() const final { return true; } |
122 | 123 |
123 LayoutBlockFlow* multiColumnBlockFlow() const { return toLayoutBlockFlow(par
ent()); } | 124 LayoutBlockFlow* multiColumnBlockFlow() const { return toLayoutBlockFlow(par
ent()); } |
124 | 125 |
125 LayoutMultiColumnSet* firstMultiColumnSet() const; | 126 LayoutMultiColumnSet* firstMultiColumnSet() const; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 void skipColumnSpanner(LayoutBox*, LayoutUnit logicalTopInFlowThread); | 184 void skipColumnSpanner(LayoutBox*, LayoutUnit logicalTopInFlowThread); |
184 | 185 |
185 bool recalculateColumnHeights(); | 186 bool recalculateColumnHeights(); |
186 | 187 |
187 void columnRuleStyleDidChange(); | 188 void columnRuleStyleDidChange(); |
188 | 189 |
189 // Remove the spanner placeholder and return true if the specified object is
no longer a valid spanner. | 190 // Remove the spanner placeholder and return true if the specified object is
no longer a valid spanner. |
190 bool removeSpannerPlaceholderIfNoLongerValid(LayoutBox* spannerObjectInFlowT
hread); | 191 bool removeSpannerPlaceholderIfNoLongerValid(LayoutBox* spannerObjectInFlowT
hread); |
191 | 192 |
192 LayoutMultiColumnFlowThread* enclosingFlowThread() const; | 193 LayoutMultiColumnFlowThread* enclosingFlowThread() const; |
193 LayoutUnit blockOffsetInEnclosingFlowThread() const { ASSERT(enclosingFlowTh
read()); return m_blockOffsetInEnclosingFlowThread; } | 194 FragmentationContext* enclosingFragmentationContext() const; |
| 195 LayoutUnit blockOffsetInEnclosingFragmentationContext() const { ASSERT(enclo
singFragmentationContext()); return m_blockOffsetInEnclosingFragmentationContext
; } |
194 | 196 |
195 // If we've run out of columns in the last fragmentainer group (column row),
we have to insert | 197 // If we've run out of columns in the last fragmentainer group (column row),
we have to insert |
196 // another fragmentainer group in order to hold more columns. This means tha
t we're moving to | 198 // another fragmentainer group in order to hold more columns. This means tha
t we're moving to |
197 // the next outer column (in the enclosing fragmentation context). | 199 // the next outer column (in the enclosing fragmentation context). |
198 void appendNewFragmentainerGroupIfNeeded(LayoutUnit offsetInFlowThread); | 200 void appendNewFragmentainerGroupIfNeeded(LayoutUnit offsetInFlowThread); |
199 | 201 |
| 202 // Implementing FragmentationContext: |
| 203 bool isFragmentainerLogicalHeightKnown() final; |
| 204 LayoutUnit fragmentainerLogicalHeightAt(LayoutUnit blockOffset) final; |
| 205 LayoutUnit remainingLogicalHeightAt(LayoutUnit blockOffset) final; |
| 206 LayoutMultiColumnFlowThread* associatedFlowThread() final { return this; } |
| 207 |
200 const char* name() const override { return "LayoutMultiColumnFlowThread"; } | 208 const char* name() const override { return "LayoutMultiColumnFlowThread"; } |
201 | 209 |
202 protected: | 210 protected: |
203 LayoutMultiColumnFlowThread(); | 211 LayoutMultiColumnFlowThread(); |
204 void setProgressionIsInline(bool isInline) { m_progressionIsInline = isInlin
e; } | 212 void setProgressionIsInline(bool isInline) { m_progressionIsInline = isInlin
e; } |
205 | 213 |
206 void layout() override; | 214 void layout() override; |
207 | 215 |
208 private: | 216 private: |
209 void calculateColumnCountAndWidth(LayoutUnit& width, unsigned& count) const; | 217 void calculateColumnCountAndWidth(LayoutUnit& width, unsigned& count) const; |
(...skipping 14 matching lines...) Expand all Loading... |
224 void contentWasLaidOut(LayoutUnit logicalTopInFlowThreadAfterPagination) ove
rride; | 232 void contentWasLaidOut(LayoutUnit logicalTopInFlowThreadAfterPagination) ove
rride; |
225 | 233 |
226 // The last set we worked on. It's not to be used as the "current set". The
concept of a | 234 // The last set we worked on. It's not to be used as the "current set". The
concept of a |
227 // "current set" is difficult, since layout may jump back and forth in the t
ree, due to wrong | 235 // "current set" is difficult, since layout may jump back and forth in the t
ree, due to wrong |
228 // top location estimates (due to e.g. margin collapsing), and possibly for
other reasons. | 236 // top location estimates (due to e.g. margin collapsing), and possibly for
other reasons. |
229 LayoutMultiColumnSet* m_lastSetWorkedOn; | 237 LayoutMultiColumnSet* m_lastSetWorkedOn; |
230 | 238 |
231 unsigned m_columnCount; // The used value of column-count | 239 unsigned m_columnCount; // The used value of column-count |
232 LayoutUnit m_columnHeightAvailable; // Total height available to columns, or
0 if auto. | 240 LayoutUnit m_columnHeightAvailable; // Total height available to columns, or
0 if auto. |
233 | 241 |
234 // Cached block offset from this flow thread to the enclosing flow thread, i
f any. In the | 242 // Cached block offset from this flow thread to the enclosing fragmentation
context, if any. In |
235 // coordinate space of the enclosing flow thread. | 243 // the coordinate space of the enclosing fragmentation context. |
236 LayoutUnit m_blockOffsetInEnclosingFlowThread; | 244 LayoutUnit m_blockOffsetInEnclosingFragmentationContext; |
237 | 245 |
238 bool m_inBalancingPass; // Set when relayouting for column balancing. | 246 bool m_inBalancingPass; // Set when relayouting for column balancing. |
239 bool m_needsColumnHeightsRecalculation; // Set when we need to recalculate t
he column set heights after layout. | 247 bool m_needsColumnHeightsRecalculation; // Set when we need to recalculate t
he column set heights after layout. |
240 bool m_progressionIsInline; // Always true for regular multicol. False for p
aged-y overflow. | 248 bool m_progressionIsInline; // Always true for regular multicol. False for p
aged-y overflow. |
241 bool m_isBeingEvacuated; | 249 bool m_isBeingEvacuated; |
242 }; | 250 }; |
243 | 251 |
244 // Cannot use DEFINE_LAYOUT_OBJECT_TYPE_CASTS here, because isMultiColumnFlowThr
ead() is defined in | 252 // Cannot use DEFINE_LAYOUT_OBJECT_TYPE_CASTS here, because isMultiColumnFlowThr
ead() is defined in |
245 // LayoutFlowThread, not in LayoutObject. | 253 // LayoutFlowThread, not in LayoutObject. |
246 DEFINE_TYPE_CASTS(LayoutMultiColumnFlowThread, LayoutFlowThread, object, object-
>isLayoutMultiColumnFlowThread(), object.isLayoutMultiColumnFlowThread()); | 254 DEFINE_TYPE_CASTS(LayoutMultiColumnFlowThread, LayoutFlowThread, object, object-
>isLayoutMultiColumnFlowThread(), object.isLayoutMultiColumnFlowThread()); |
247 | 255 |
248 } // namespace blink | 256 } // namespace blink |
249 | 257 |
250 #endif // LayoutMultiColumnFlowThread_h | 258 #endif // LayoutMultiColumnFlowThread_h |
OLD | NEW |