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 20 matching lines...) Expand all Loading... |
31 #include "core/layout/MultiColumnFragmentainerGroup.h" | 31 #include "core/layout/MultiColumnFragmentainerGroup.h" |
32 #include "core/paint/MultiColumnSetPainter.h" | 32 #include "core/paint/MultiColumnSetPainter.h" |
33 #include "platform/RuntimeEnabledFeatures.h" | 33 #include "platform/RuntimeEnabledFeatures.h" |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
37 LayoutMultiColumnSet::LayoutMultiColumnSet(LayoutFlowThread* flowThread) | 37 LayoutMultiColumnSet::LayoutMultiColumnSet(LayoutFlowThread* flowThread) |
38 : LayoutBlockFlow(nullptr) | 38 : LayoutBlockFlow(nullptr) |
39 , m_fragmentainerGroups(*this) | 39 , m_fragmentainerGroups(*this) |
40 , m_flowThread(flowThread) | 40 , m_flowThread(flowThread) |
| 41 , m_initialHeightCalculated(false) |
41 { | 42 { |
42 } | 43 } |
43 | 44 |
44 LayoutMultiColumnSet* LayoutMultiColumnSet::createAnonymous(LayoutFlowThread& fl
owThread, const ComputedStyle& parentStyle) | 45 LayoutMultiColumnSet* LayoutMultiColumnSet::createAnonymous(LayoutFlowThread& fl
owThread, const ComputedStyle& parentStyle) |
45 { | 46 { |
46 Document& document = flowThread.document(); | 47 Document& document = flowThread.document(); |
47 LayoutMultiColumnSet* layoutObject = new LayoutMultiColumnSet(&flowThread); | 48 LayoutMultiColumnSet* layoutObject = new LayoutMultiColumnSet(&flowThread); |
48 layoutObject->setDocumentForAnonymous(&document); | 49 layoutObject->setDocumentForAnonymous(&document); |
49 layoutObject->setStyle(ComputedStyle::createAnonymousStyleWithDisplay(parent
Style, BLOCK)); | 50 layoutObject->setStyle(ComputedStyle::createAnonymousStyleWithDisplay(parent
Style, BLOCK)); |
50 return layoutObject; | 51 return layoutObject; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 { | 238 { |
238 const MultiColumnFragmentainerGroup& row = fragmentainerGroupAtVisualPoint(v
isualPoint); | 239 const MultiColumnFragmentainerGroup& row = fragmentainerGroupAtVisualPoint(v
isualPoint); |
239 return row.visualPointToFlowThreadPoint(visualPoint - row.offsetFromColumnSe
t()); | 240 return row.visualPointToFlowThreadPoint(visualPoint - row.offsetFromColumnSe
t()); |
240 } | 241 } |
241 | 242 |
242 LayoutUnit LayoutMultiColumnSet::pageLogicalTopForOffset(LayoutUnit offset) cons
t | 243 LayoutUnit LayoutMultiColumnSet::pageLogicalTopForOffset(LayoutUnit offset) cons
t |
243 { | 244 { |
244 return fragmentainerGroupAtFlowThreadOffset(offset).columnLogicalTopForOffse
t(offset); | 245 return fragmentainerGroupAtFlowThreadOffset(offset).columnLogicalTopForOffse
t(offset); |
245 } | 246 } |
246 | 247 |
247 bool LayoutMultiColumnSet::recalculateColumnHeight(BalancedColumnHeightCalculati
on calculationMode) | 248 bool LayoutMultiColumnSet::recalculateColumnHeight() |
248 { | 249 { |
249 if (calculationMode == GuessFromFlowThreadPortion) | 250 if (m_oldLogicalTop != logicalTop() && multiColumnFlowThread()->enclosingFlo
wThread()) { |
250 m_tallestUnbreakableLogicalHeight = LayoutUnit(); | 251 // Preceding spanners or column sets have been moved or resized. This me
ans that the |
| 252 // fragmentainer groups that we have inserted need to be re-inserted. Re
start column |
| 253 // balancing. |
| 254 resetColumnHeight(); |
| 255 return true; |
| 256 } |
| 257 |
251 bool changed = false; | 258 bool changed = false; |
252 for (auto& group : m_fragmentainerGroups) | 259 for (auto& group : m_fragmentainerGroups) |
253 changed = group.recalculateColumnHeight(calculationMode) || changed; | 260 changed = group.recalculateColumnHeight() || changed; |
| 261 m_initialHeightCalculated = true; |
254 return changed; | 262 return changed; |
255 } | 263 } |
256 | 264 |
257 void LayoutMultiColumnSet::resetColumnHeight() | 265 void LayoutMultiColumnSet::resetColumnHeight() |
258 { | 266 { |
259 m_fragmentainerGroups.deleteExtraGroups(); | 267 m_fragmentainerGroups.deleteExtraGroups(); |
260 m_fragmentainerGroups.first().resetColumnHeight(); | 268 m_fragmentainerGroups.first().resetColumnHeight(); |
| 269 m_tallestUnbreakableLogicalHeight = LayoutUnit(); |
| 270 m_initialHeightCalculated = false; |
261 } | 271 } |
262 | 272 |
263 void LayoutMultiColumnSet::beginFlow(LayoutUnit offsetInFlowThread) | 273 void LayoutMultiColumnSet::beginFlow(LayoutUnit offsetInFlowThread) |
264 { | 274 { |
265 // At this point layout is exactly at the beginning of this set. Store block
offset from flow | 275 // At this point layout is exactly at the beginning of this set. Store block
offset from flow |
266 // thread start. | 276 // thread start. |
267 m_fragmentainerGroups.first().setLogicalTopInFlowThread(offsetInFlowThread); | 277 m_fragmentainerGroups.first().setLogicalTopInFlowThread(offsetInFlowThread); |
268 } | 278 } |
269 | 279 |
270 void LayoutMultiColumnSet::endFlow(LayoutUnit offsetInFlowThread) | 280 void LayoutMultiColumnSet::endFlow(LayoutUnit offsetInFlowThread) |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 | 390 |
381 LayoutRect LayoutMultiColumnSet::flowThreadPortionRect() const | 391 LayoutRect LayoutMultiColumnSet::flowThreadPortionRect() const |
382 { | 392 { |
383 LayoutRect portionRect(LayoutUnit(), logicalTopInFlowThread(), pageLogicalWi
dth(), logicalHeightInFlowThread()); | 393 LayoutRect portionRect(LayoutUnit(), logicalTopInFlowThread(), pageLogicalWi
dth(), logicalHeightInFlowThread()); |
384 if (!isHorizontalWritingMode()) | 394 if (!isHorizontalWritingMode()) |
385 return portionRect.transposedRect(); | 395 return portionRect.transposedRect(); |
386 return portionRect; | 396 return portionRect; |
387 } | 397 } |
388 | 398 |
389 } | 399 } |
OLD | NEW |