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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // | 110 // |
111 // For each layout iteration done for column balancing, the flow thread will nee
d a deep layout if | 111 // For each layout iteration done for column balancing, the flow thread will nee
d a deep layout if |
112 // column heights changed in the previous pass, since column height changes may
affect break points | 112 // column heights changed in the previous pass, since column height changes may
affect break points |
113 // and pagination struts anywhere in the tree, and currently no way exists to do
this in a more | 113 // and pagination struts anywhere in the tree, and currently no way exists to do
this in a more |
114 // optimized manner. | 114 // optimized manner. |
115 // | 115 // |
116 // There's also some documentation online: | 116 // There's also some documentation online: |
117 // https://sites.google.com/a/chromium.org/dev/developers/design-documents/multi
-column-layout | 117 // https://sites.google.com/a/chromium.org/dev/developers/design-documents/multi
-column-layout |
118 class CORE_EXPORT LayoutMultiColumnFlowThread : public LayoutFlowThread { | 118 class CORE_EXPORT LayoutMultiColumnFlowThread : public LayoutFlowThread { |
119 public: | 119 public: |
120 virtual ~LayoutMultiColumnFlowThread(); | 120 ~LayoutMultiColumnFlowThread() override; |
121 | 121 |
122 static LayoutMultiColumnFlowThread* createAnonymous(Document&, const Compute
dStyle& parentStyle); | 122 static LayoutMultiColumnFlowThread* createAnonymous(Document&, const Compute
dStyle& parentStyle); |
123 | 123 |
124 virtual bool isLayoutMultiColumnFlowThread() const override final { return t
rue; } | 124 bool isLayoutMultiColumnFlowThread() const final { return true; } |
125 | 125 |
126 LayoutBlockFlow* multiColumnBlockFlow() const { return toLayoutBlockFlow(par
ent()); } | 126 LayoutBlockFlow* multiColumnBlockFlow() const { return toLayoutBlockFlow(par
ent()); } |
127 | 127 |
128 LayoutMultiColumnSet* firstMultiColumnSet() const; | 128 LayoutMultiColumnSet* firstMultiColumnSet() const; |
129 LayoutMultiColumnSet* lastMultiColumnSet() const; | 129 LayoutMultiColumnSet* lastMultiColumnSet() const; |
130 | 130 |
131 // Return the first column set or spanner placeholder. | 131 // Return the first column set or spanner placeholder. |
132 LayoutBox* firstMultiColumnBox() const | 132 LayoutBox* firstMultiColumnBox() const |
133 { | 133 { |
134 return nextSiblingBox(); | 134 return nextSiblingBox(); |
(...skipping 21 matching lines...) Expand all Loading... |
156 // Empty the flow thread by moving everything to the parent. Remove all mult
icol specific | 156 // Empty the flow thread by moving everything to the parent. Remove all mult
icol specific |
157 // layoutObjects. Then destroy the flow thread. Called when a multicol conta
iner becomes a regular | 157 // layoutObjects. Then destroy the flow thread. Called when a multicol conta
iner becomes a regular |
158 // block. | 158 // block. |
159 void evacuateAndDestroy(); | 159 void evacuateAndDestroy(); |
160 | 160 |
161 unsigned columnCount() const { return m_columnCount; } | 161 unsigned columnCount() const { return m_columnCount; } |
162 LayoutUnit columnHeightAvailable() const { return m_columnHeightAvailable; } | 162 LayoutUnit columnHeightAvailable() const { return m_columnHeightAvailable; } |
163 void setColumnHeightAvailable(LayoutUnit available) { m_columnHeightAvailabl
e = available; } | 163 void setColumnHeightAvailable(LayoutUnit available) { m_columnHeightAvailabl
e = available; } |
164 bool progressionIsInline() const { return m_progressionIsInline; } | 164 bool progressionIsInline() const { return m_progressionIsInline; } |
165 | 165 |
166 virtual LayoutSize columnOffset(const LayoutPoint&) const override final; | 166 LayoutSize columnOffset(const LayoutPoint&) const final; |
167 | 167 |
168 // Do we need to set a new width and lay out? | 168 // Do we need to set a new width and lay out? |
169 virtual bool needsNewWidth() const; | 169 virtual bool needsNewWidth() const; |
170 | 170 |
171 virtual LayoutPoint visualPointToFlowThreadPoint(const LayoutPoint& visualPo
int) const override; | 171 LayoutPoint visualPointToFlowThreadPoint(const LayoutPoint& visualPoint) con
st override; |
172 | 172 |
173 virtual LayoutMultiColumnSet* columnSetAtBlockOffset(LayoutUnit) const overr
ide final; | 173 LayoutMultiColumnSet* columnSetAtBlockOffset(LayoutUnit) const final; |
174 | 174 |
175 void layoutColumns(bool relayoutChildren, SubtreeLayoutScope&); | 175 void layoutColumns(bool relayoutChildren, SubtreeLayoutScope&); |
176 | 176 |
177 bool recalculateColumnHeights(); | 177 bool recalculateColumnHeights(); |
178 | 178 |
179 void columnRuleStyleDidChange(); | 179 void columnRuleStyleDidChange(); |
180 | 180 |
181 // Remove the spanner placeholder and return true if the specified object is
no longer a valid spanner. | 181 // Remove the spanner placeholder and return true if the specified object is
no longer a valid spanner. |
182 bool removeSpannerPlaceholderIfNoLongerValid(LayoutBox* spannerObjectInFlowT
hread); | 182 bool removeSpannerPlaceholderIfNoLongerValid(LayoutBox* spannerObjectInFlowT
hread); |
183 | 183 |
184 virtual const char* name() const override { return "LayoutMultiColumnFlowThr
ead"; } | 184 const char* name() const override { return "LayoutMultiColumnFlowThread"; } |
185 | 185 |
186 protected: | 186 protected: |
187 LayoutMultiColumnFlowThread(); | 187 LayoutMultiColumnFlowThread(); |
188 void setProgressionIsInline(bool isInline) { m_progressionIsInline = isInlin
e; } | 188 void setProgressionIsInline(bool isInline) { m_progressionIsInline = isInlin
e; } |
189 | 189 |
190 virtual void layout() override; | 190 void layout() override; |
191 | 191 |
192 private: | 192 private: |
193 void calculateColumnCountAndWidth(LayoutUnit& width, unsigned& count) const; | 193 void calculateColumnCountAndWidth(LayoutUnit& width, unsigned& count) const; |
194 void createAndInsertMultiColumnSet(LayoutBox* insertBefore = nullptr); | 194 void createAndInsertMultiColumnSet(LayoutBox* insertBefore = nullptr); |
195 void createAndInsertSpannerPlaceholder(LayoutBox* spannerObjectInFlowThread,
LayoutObject* insertedBeforeInFlowThread); | 195 void createAndInsertSpannerPlaceholder(LayoutBox* spannerObjectInFlowThread,
LayoutObject* insertedBeforeInFlowThread); |
196 void destroySpannerPlaceholder(LayoutMultiColumnSpannerPlaceholder*); | 196 void destroySpannerPlaceholder(LayoutMultiColumnSpannerPlaceholder*); |
197 virtual bool descendantIsValidColumnSpanner(LayoutObject* descendant) const; | 197 virtual bool descendantIsValidColumnSpanner(LayoutObject* descendant) const; |
198 | 198 |
199 virtual void addColumnSetToThread(LayoutMultiColumnSet*) override; | 199 void addColumnSetToThread(LayoutMultiColumnSet*) override; |
200 virtual void willBeRemovedFromTree() override; | 200 void willBeRemovedFromTree() override; |
201 virtual void skipColumnSpanner(LayoutBox*, LayoutUnit logicalTopInFlowThread
) override; | 201 void skipColumnSpanner(LayoutBox*, LayoutUnit logicalTopInFlowThread) overri
de; |
202 virtual void flowThreadDescendantWasInserted(LayoutObject*) final; | 202 void flowThreadDescendantWasInserted(LayoutObject*) final; |
203 virtual void flowThreadDescendantWillBeRemoved(LayoutObject*) final; | 203 void flowThreadDescendantWillBeRemoved(LayoutObject*) final; |
204 virtual void flowThreadDescendantStyleWillChange(LayoutObject*, StyleDiffere
nce, const ComputedStyle& newStyle) override; | 204 void flowThreadDescendantStyleWillChange(LayoutObject*, StyleDifference, con
st ComputedStyle& newStyle) override; |
205 virtual void flowThreadDescendantStyleDidChange(LayoutObject*, StyleDifferen
ce, const ComputedStyle& oldStyle) override; | 205 void flowThreadDescendantStyleDidChange(LayoutObject*, StyleDifference, cons
t ComputedStyle& oldStyle) override; |
206 virtual void computePreferredLogicalWidths() override; | 206 void computePreferredLogicalWidths() override; |
207 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const override; | 207 void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, L
ogicalExtentComputedValues&) const override; |
208 virtual void updateLogicalWidth() override; | 208 void updateLogicalWidth() override; |
209 virtual void setPageBreak(LayoutUnit offset, LayoutUnit spaceShortage) overr
ide; | 209 void setPageBreak(LayoutUnit offset, LayoutUnit spaceShortage) override; |
210 virtual void updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeight
) override; | 210 void updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeight) overri
de; |
211 virtual bool addForcedColumnBreak(LayoutUnit, LayoutObject* breakChild, bool
isBefore, LayoutUnit* offsetBreakAdjustment = nullptr) override; | 211 bool addForcedColumnBreak(LayoutUnit, LayoutObject* breakChild, bool isBefor
e, LayoutUnit* offsetBreakAdjustment = nullptr) override; |
212 virtual bool isPageLogicalHeightKnown() const override; | 212 bool isPageLogicalHeightKnown() const override; |
213 | 213 |
214 // The last set we worked on. It's not to be used as the "current set". The
concept of a | 214 // The last set we worked on. It's not to be used as the "current set". The
concept of a |
215 // "current set" is difficult, since layout may jump back and forth in the t
ree, due to wrong | 215 // "current set" is difficult, since layout may jump back and forth in the t
ree, due to wrong |
216 // top location estimates (due to e.g. margin collapsing), and possibly for
other reasons. | 216 // top location estimates (due to e.g. margin collapsing), and possibly for
other reasons. |
217 LayoutMultiColumnSet* m_lastSetWorkedOn; | 217 LayoutMultiColumnSet* m_lastSetWorkedOn; |
218 | 218 |
219 unsigned m_columnCount; // The used value of column-count | 219 unsigned m_columnCount; // The used value of column-count |
220 LayoutUnit m_columnHeightAvailable; // Total height available to columns, or
0 if auto. | 220 LayoutUnit m_columnHeightAvailable; // Total height available to columns, or
0 if auto. |
221 bool m_inBalancingPass; // Set when relayouting for column balancing. | 221 bool m_inBalancingPass; // Set when relayouting for column balancing. |
222 bool m_needsColumnHeightsRecalculation; // Set when we need to recalculate t
he column set heights after layout. | 222 bool m_needsColumnHeightsRecalculation; // Set when we need to recalculate t
he column set heights after layout. |
223 bool m_progressionIsInline; // Always true for regular multicol. False for p
aged-y overflow. | 223 bool m_progressionIsInline; // Always true for regular multicol. False for p
aged-y overflow. |
224 bool m_isBeingEvacuated; | 224 bool m_isBeingEvacuated; |
225 }; | 225 }; |
226 | 226 |
227 } // namespace blink | 227 } // namespace blink |
228 | 228 |
229 #endif // LayoutMultiColumnFlowThread_h | 229 #endif // LayoutMultiColumnFlowThread_h |
OLD | NEW |