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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 } | 365 } |
366 LayoutMultiColumnSet* columnSet = toLayoutMultiColumnSet(columnBox); | 366 LayoutMultiColumnSet* columnSet = toLayoutMultiColumnSet(columnBox); |
367 layoutScope.setChildNeedsLayout(columnSet); | 367 layoutScope.setChildNeedsLayout(columnSet); |
368 if (!m_inBalancingPass) { | 368 if (!m_inBalancingPass) { |
369 // This is the initial layout pass. We need to reset the column heig
ht, because contents | 369 // This is the initial layout pass. We need to reset the column heig
ht, because contents |
370 // typically have changed. | 370 // typically have changed. |
371 columnSet->resetColumnHeight(); | 371 columnSet->resetColumnHeight(); |
372 } | 372 } |
373 if (!m_needsColumnHeightsRecalculation) | 373 if (!m_needsColumnHeightsRecalculation) |
374 m_needsColumnHeightsRecalculation = columnSet->heightIsAuto(); | 374 m_needsColumnHeightsRecalculation = columnSet->heightIsAuto(); |
| 375 // Since column sets are regular block flow objects, and their position
is changed in |
| 376 // regular block layout code (with no means for the multicol code to not
ice unless we add |
| 377 // hooks there), store the previous position now. If it changes in the i
mminent layout |
| 378 // pass, we may have to rebalance its columns. |
| 379 columnSet->storeOldPosition(); |
375 } | 380 } |
376 | 381 |
377 invalidateColumnSets(); | 382 invalidateColumnSets(); |
378 layout(); | 383 layout(); |
379 } | 384 } |
380 | 385 |
381 bool LayoutMultiColumnFlowThread::recalculateColumnHeights() | 386 bool LayoutMultiColumnFlowThread::recalculateColumnHeights() |
382 { | 387 { |
383 // All column sets that needed layout have now been laid out, so we can fina
lly validate them. | 388 // All column sets that needed layout have now been laid out, so we can fina
lly validate them. |
384 validateColumnSets(); | 389 validateColumnSets(); |
385 | 390 |
386 if (!m_needsColumnHeightsRecalculation) | 391 if (!m_needsColumnHeightsRecalculation) |
387 return false; | 392 return false; |
388 | 393 |
389 // Column heights may change here because of balancing. We may have to do mu
ltiple layout | 394 // Column heights may change here because of balancing. We may have to do mu
ltiple layout |
390 // passes, depending on how the contents is fitted to the changed column hei
ghts. In most | 395 // passes, depending on how the contents is fitted to the changed column hei
ghts. In most |
391 // cases, laying out again twice or even just once will suffice. Sometimes w
e need more | 396 // cases, laying out again twice or even just once will suffice. Sometimes w
e need more |
392 // passes than that, though, but the number of retries should not exceed the
number of | 397 // passes than that, though, but the number of retries should not exceed the
number of |
393 // columns, unless we have a bug. | 398 // columns, unless we have a bug. |
394 bool needsRelayout = false; | 399 bool needsRelayout = false; |
395 for (LayoutMultiColumnSet* multicolSet = firstMultiColumnSet(); multicolSet;
multicolSet = multicolSet->nextSiblingMultiColumnSet()) | 400 for (LayoutMultiColumnSet* multicolSet = firstMultiColumnSet(); multicolSet;
multicolSet = multicolSet->nextSiblingMultiColumnSet()) |
396 needsRelayout |= multicolSet->recalculateColumnHeight(m_inBalancingPass
? StretchBySpaceShortage : GuessFromFlowThreadPortion); | 401 needsRelayout |= multicolSet->recalculateColumnHeight(); |
397 | 402 |
398 if (needsRelayout) | 403 if (needsRelayout) |
399 setChildNeedsLayout(MarkOnlyThis); | 404 setChildNeedsLayout(MarkOnlyThis); |
400 | 405 |
401 m_inBalancingPass = needsRelayout; | 406 m_inBalancingPass = needsRelayout; |
402 return needsRelayout; | 407 return needsRelayout; |
403 } | 408 } |
404 | 409 |
405 void LayoutMultiColumnFlowThread::columnRuleStyleDidChange() | 410 void LayoutMultiColumnFlowThread::columnRuleStyleDidChange() |
406 { | 411 { |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 // First figure out if there's any chance that we're nested at all. If we ca
n be sure that | 927 // First figure out if there's any chance that we're nested at all. If we ca
n be sure that |
923 // we're not, bail early. This code is run very often, and since locating a
containing flow | 928 // we're not, bail early. This code is run very often, and since locating a
containing flow |
924 // thread has some cost (depending on tree depth), avoid calling enclosingFl
owThread() right | 929 // thread has some cost (depending on tree depth), avoid calling enclosingFl
owThread() right |
925 // away. This test may give some false positives (hence the "mayBe"), if we'
re in an | 930 // away. This test may give some false positives (hence the "mayBe"), if we'
re in an |
926 // out-of-flow subtree and have an outer multicol container that doesn't aff
ect us, but that's | 931 // out-of-flow subtree and have an outer multicol container that doesn't aff
ect us, but that's |
927 // okay. We'll discover that further down the road when trying to locate our
enclosing flow | 932 // okay. We'll discover that further down the road when trying to locate our
enclosing flow |
928 // thread for real. | 933 // thread for real. |
929 bool mayBeNested = multiColumnBlockFlow()->isInsideFlowThread(); | 934 bool mayBeNested = multiColumnBlockFlow()->isInsideFlowThread(); |
930 if (!mayBeNested) | 935 if (!mayBeNested) |
931 return; | 936 return; |
932 if (!isInInitialLayoutPass()) { | 937 LayoutMultiColumnSet* columnSet = columnSetAtBlockOffset(logicalTopInFlowThr
eadAfterPagination); |
| 938 if (!columnSet) |
| 939 return; |
| 940 if (columnSet->isInitialHeightCalculated()) { |
933 // We only insert additional fragmentainer groups in the initial layout
pass. We only want | 941 // We only insert additional fragmentainer groups in the initial layout
pass. We only want |
934 // to balance columns in the last fragmentainer group (if we need to bal
ance at all), so we | 942 // to balance columns in the last fragmentainer group (if we need to bal
ance at all), so we |
935 // want that last fragmentainer group to be the same one in all layout p
asses that follow. | 943 // want that last fragmentainer group to be the same one in all layout p
asses that follow. |
936 return; | 944 return; |
937 } | 945 } |
938 LayoutMultiColumnSet* columnSet = columnSetAtBlockOffset(logicalTopInFlowThr
eadAfterPagination); | |
939 if (!columnSet) | |
940 return; | |
941 MultiColumnFragmentainerGroup& row = columnSet->fragmentainerGroupAtFlowThre
adOffset(logicalTopInFlowThreadAfterPagination); | 946 MultiColumnFragmentainerGroup& row = columnSet->fragmentainerGroupAtFlowThre
adOffset(logicalTopInFlowThreadAfterPagination); |
942 if (!row.isLastGroup()) | 947 if (!row.isLastGroup()) |
943 return; | 948 return; |
944 appendNewFragmentainerGroupIfNeeded(logicalTopInFlowThreadAfterPagination); | 949 appendNewFragmentainerGroupIfNeeded(logicalTopInFlowThreadAfterPagination); |
945 } | 950 } |
946 | 951 |
947 } | 952 } |
OLD | NEW |