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 19 matching lines...) Expand all Loading... |
30 #include "core/layout/LayoutView.h" | 30 #include "core/layout/LayoutView.h" |
31 #include "core/layout/MultiColumnFragmentainerGroup.h" | 31 #include "core/layout/MultiColumnFragmentainerGroup.h" |
32 #include "core/layout/ViewFragmentationContext.h" | 32 #include "core/layout/ViewFragmentationContext.h" |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
36 LayoutMultiColumnFlowThread::LayoutMultiColumnFlowThread() | 36 LayoutMultiColumnFlowThread::LayoutMultiColumnFlowThread() |
37 : m_lastSetWorkedOn(nullptr) | 37 : m_lastSetWorkedOn(nullptr) |
38 , m_columnCount(1) | 38 , m_columnCount(1) |
39 , m_columnHeightAvailable(0) | 39 , m_columnHeightAvailable(0) |
40 , m_inBalancingPass(false) | 40 , m_columnHeightsChanged(false) |
41 , m_needsColumnHeightsRecalculation(false) | |
42 , m_progressionIsInline(true) | 41 , m_progressionIsInline(true) |
43 , m_isBeingEvacuated(false) | 42 , m_isBeingEvacuated(false) |
44 { | 43 { |
45 setIsInsideFlowThread(true); | 44 setIsInsideFlowThread(true); |
46 } | 45 } |
47 | 46 |
48 LayoutMultiColumnFlowThread::~LayoutMultiColumnFlowThread() | 47 LayoutMultiColumnFlowThread::~LayoutMultiColumnFlowThread() |
49 { | 48 { |
50 } | 49 } |
51 | 50 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 return adapter.result(); | 346 return adapter.result(); |
348 } | 347 } |
349 | 348 |
350 void LayoutMultiColumnFlowThread::layoutColumns(SubtreeLayoutScope& layoutScope) | 349 void LayoutMultiColumnFlowThread::layoutColumns(SubtreeLayoutScope& layoutScope) |
351 { | 350 { |
352 // Since we ended up here, it means that the multicol container (our parent)
needed | 351 // Since we ended up here, it means that the multicol container (our parent)
needed |
353 // layout. Since contents of the multicol container are diverted to the flow
thread, the flow | 352 // layout. Since contents of the multicol container are diverted to the flow
thread, the flow |
354 // thread needs layout as well. | 353 // thread needs layout as well. |
355 layoutScope.setChildNeedsLayout(this); | 354 layoutScope.setChildNeedsLayout(this); |
356 | 355 |
357 m_needsColumnHeightsRecalculation = false; | |
358 | |
359 m_blockOffsetInEnclosingFragmentationContext = enclosingFragmentationContext
() ? multiColumnBlockFlow()->offsetFromLogicalTopOfFirstPage() : LayoutUnit(); | 356 m_blockOffsetInEnclosingFragmentationContext = enclosingFragmentationContext
() ? multiColumnBlockFlow()->offsetFromLogicalTopOfFirstPage() : LayoutUnit(); |
360 | 357 |
361 for (LayoutBox* columnBox = firstMultiColumnBox(); columnBox; columnBox = co
lumnBox->nextSiblingMultiColumnBox()) { | 358 for (LayoutBox* columnBox = firstMultiColumnBox(); columnBox; columnBox = co
lumnBox->nextSiblingMultiColumnBox()) { |
362 if (!columnBox->isLayoutMultiColumnSet()) { | 359 if (!columnBox->isLayoutMultiColumnSet()) { |
363 ASSERT(columnBox->isLayoutMultiColumnSpannerPlaceholder()); // no ot
her type is expected. | 360 ASSERT(columnBox->isLayoutMultiColumnSpannerPlaceholder()); // no ot
her type is expected. |
364 m_needsColumnHeightsRecalculation = true; | |
365 continue; | 361 continue; |
366 } | 362 } |
367 LayoutMultiColumnSet* columnSet = toLayoutMultiColumnSet(columnBox); | 363 LayoutMultiColumnSet* columnSet = toLayoutMultiColumnSet(columnBox); |
368 layoutScope.setChildNeedsLayout(columnSet); | 364 layoutScope.setChildNeedsLayout(columnSet); |
369 if (!m_inBalancingPass) { | 365 if (!m_columnHeightsChanged) { |
370 // This is the initial layout pass. We need to reset the column heig
ht, because contents | 366 // This is the initial layout pass. We need to reset the column heig
ht, because contents |
371 // typically have changed. | 367 // typically have changed. |
372 columnSet->resetColumnHeight(); | 368 columnSet->resetColumnHeight(); |
373 } | 369 } |
374 if (!m_needsColumnHeightsRecalculation) | |
375 m_needsColumnHeightsRecalculation = columnSet->heightIsAuto(); | |
376 // Since column sets are regular block flow objects, and their position
is changed in | 370 // Since column sets are regular block flow objects, and their position
is changed in |
377 // regular block layout code (with no means for the multicol code to not
ice unless we add | 371 // regular block layout code (with no means for the multicol code to not
ice unless we add |
378 // hooks there), store the previous position now. If it changes in the i
mminent layout | 372 // hooks there), store the previous position now. If it changes in the i
mminent layout |
379 // pass, we may have to rebalance its columns. | 373 // pass, we may have to rebalance its columns. |
380 columnSet->storeOldPosition(); | 374 columnSet->storeOldPosition(); |
381 } | 375 } |
382 | 376 |
| 377 m_columnHeightsChanged = false; |
383 invalidateColumnSets(); | 378 invalidateColumnSets(); |
384 layout(); | 379 layout(); |
385 } | |
386 | |
387 bool LayoutMultiColumnFlowThread::recalculateColumnHeights() | |
388 { | |
389 // All column sets that needed layout have now been laid out, so we can fina
lly validate them. | |
390 validateColumnSets(); | 380 validateColumnSets(); |
391 | |
392 if (!m_needsColumnHeightsRecalculation) | |
393 return false; | |
394 | |
395 // Column heights may change here because of balancing. We may have to do mu
ltiple layout | |
396 // passes, depending on how the contents is fitted to the changed column hei
ghts. In most | |
397 // cases, laying out again twice or even just once will suffice. Sometimes w
e need more | |
398 // passes than that, though, but the number of retries should not exceed the
number of | |
399 // columns, unless we have a bug. | |
400 bool needsRelayout = false; | |
401 for (LayoutMultiColumnSet* multicolSet = firstMultiColumnSet(); multicolSet;
multicolSet = multicolSet->nextSiblingMultiColumnSet()) | |
402 needsRelayout |= multicolSet->recalculateColumnHeight(); | |
403 | |
404 if (needsRelayout) | |
405 setChildNeedsLayout(MarkOnlyThis); | |
406 | |
407 m_inBalancingPass = needsRelayout; | |
408 return needsRelayout; | |
409 } | 381 } |
410 | 382 |
411 void LayoutMultiColumnFlowThread::columnRuleStyleDidChange() | 383 void LayoutMultiColumnFlowThread::columnRuleStyleDidChange() |
412 { | 384 { |
413 for (LayoutMultiColumnSet* columnSet = firstMultiColumnSet(); columnSet; col
umnSet = columnSet->nextSiblingMultiColumnSet()) | 385 for (LayoutMultiColumnSet* columnSet = firstMultiColumnSet(); columnSet; col
umnSet = columnSet->nextSiblingMultiColumnSet()) |
414 columnSet->setShouldDoFullPaintInvalidation(PaintInvalidationStyleChange
); | 386 columnSet->setShouldDoFullPaintInvalidation(PaintInvalidationStyleChange
); |
415 } | 387 } |
416 | 388 |
417 bool LayoutMultiColumnFlowThread::removeSpannerPlaceholderIfNoLongerValid(Layout
Box* spannerObjectInFlowThread) | 389 bool LayoutMultiColumnFlowThread::removeSpannerPlaceholderIfNoLongerValid(Layout
Box* spannerObjectInFlowThread) |
418 { | 390 { |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 // the "mayBe"), if we're in an out-of-flow subtree and have an outer multic
ol container that | 921 // the "mayBe"), if we're in an out-of-flow subtree and have an outer multic
ol container that |
950 // doesn't affect us, but that's okay. We'll discover that further down the
road when trying to | 922 // doesn't affect us, but that's okay. We'll discover that further down the
road when trying to |
951 // locate our enclosing flow thread for real. | 923 // locate our enclosing flow thread for real. |
952 bool mayBeNested = multiColumnBlockFlow()->isInsideFlowThread() || view()->f
ragmentationContext(); | 924 bool mayBeNested = multiColumnBlockFlow()->isInsideFlowThread() || view()->f
ragmentationContext(); |
953 if (!mayBeNested) | 925 if (!mayBeNested) |
954 return; | 926 return; |
955 appendNewFragmentainerGroupIfNeeded(logicalTopInFlowThreadAfterPagination); | 927 appendNewFragmentainerGroupIfNeeded(logicalTopInFlowThreadAfterPagination); |
956 } | 928 } |
957 | 929 |
958 } | 930 } |
OLD | NEW |