| 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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 } | 620 } |
| 621 | 621 |
| 622 void LayoutMultiColumnFlowThread::appendNewFragmentainerGroupIfNeeded( | 622 void LayoutMultiColumnFlowThread::appendNewFragmentainerGroupIfNeeded( |
| 623 LayoutUnit offsetInFlowThread, | 623 LayoutUnit offsetInFlowThread, |
| 624 PageBoundaryRule pageBoundaryRule) { | 624 PageBoundaryRule pageBoundaryRule) { |
| 625 LayoutMultiColumnSet* columnSet = | 625 LayoutMultiColumnSet* columnSet = |
| 626 columnSetAtBlockOffset(offsetInFlowThread, pageBoundaryRule); | 626 columnSetAtBlockOffset(offsetInFlowThread, pageBoundaryRule); |
| 627 if (!columnSet->newFragmentainerGroupsAllowed()) | 627 if (!columnSet->newFragmentainerGroupsAllowed()) |
| 628 return; | 628 return; |
| 629 | 629 |
| 630 if (!columnSet->hasFragmentainerGroupForColumnAt(offsetInFlowThread, | 630 if (columnSet->needsNewFragmentainerGroupAt(offsetInFlowThread, |
| 631 pageBoundaryRule)) { | 631 pageBoundaryRule)) { |
| 632 FragmentationContext* enclosingFragmentationContext = | 632 // We should never create additional fragmentainer groups unless we're in a |
| 633 this->enclosingFragmentationContext(); | 633 // nested fragmentation context. |
| 634 // Not nested. We'll never need more rows than the one we already have then. | 634 DCHECK(enclosingFragmentationContext()); |
| 635 if (!enclosingFragmentationContext) | 635 |
| 636 return; | 636 DCHECK(!isLayoutPagedFlowThread()); |
| 637 ASSERT(!isLayoutPagedFlowThread()); | |
| 638 | 637 |
| 639 // We have run out of columns here, so we need to add at least one more row | 638 // We have run out of columns here, so we need to add at least one more row |
| 640 // to hold more columns. | 639 // to hold more columns. |
| 641 LayoutMultiColumnFlowThread* enclosingFlowThread = | 640 LayoutMultiColumnFlowThread* enclosingFlowThread = |
| 642 enclosingFragmentationContext->associatedFlowThread(); | 641 enclosingFragmentationContext()->associatedFlowThread(); |
| 643 do { | 642 do { |
| 644 if (enclosingFlowThread) { | 643 if (enclosingFlowThread) { |
| 645 // When we add a new row here, it implicitly means that we're inserting | 644 // When we add a new row here, it implicitly means that we're inserting |
| 646 // another column in our enclosing multicol container. That in turn may | 645 // another column in our enclosing multicol container. That in turn may |
| 647 // mean that we've run out of columns there too. Need to insert | 646 // mean that we've run out of columns there too. Need to insert |
| 648 // additional rows in ancestral multicol containers before doing it in | 647 // additional rows in ancestral multicol containers before doing it in |
| 649 // the descendants, in order to get the height constraints right down | 648 // the descendants, in order to get the height constraints right down |
| 650 // there. | 649 // there. |
| 651 const MultiColumnFragmentainerGroup& lastRow = | 650 const MultiColumnFragmentainerGroup& lastRow = |
| 652 columnSet->lastFragmentainerGroup(); | 651 columnSet->lastFragmentainerGroup(); |
| 653 // The top offset where where the new fragmentainer group will start in | 652 // The top offset where where the new fragmentainer group will start in |
| 654 // this column set, converted to the coordinate space of the enclosing | 653 // this column set, converted to the coordinate space of the enclosing |
| 655 // multicol container. | 654 // multicol container. |
| 656 LayoutUnit logicalOffsetInOuter = | 655 LayoutUnit logicalOffsetInOuter = |
| 657 lastRow.blockOffsetInEnclosingFragmentationContext() + | 656 lastRow.blockOffsetInEnclosingFragmentationContext() + |
| 658 lastRow.logicalHeight(); | 657 lastRow.logicalHeight(); |
| 659 enclosingFlowThread->appendNewFragmentainerGroupIfNeeded( | 658 enclosingFlowThread->appendNewFragmentainerGroupIfNeeded( |
| 660 logicalOffsetInOuter, AssociateWithLatterPage); | 659 logicalOffsetInOuter, AssociateWithLatterPage); |
| 661 } | 660 } |
| 662 | 661 |
| 663 const MultiColumnFragmentainerGroup& newRow = | 662 const MultiColumnFragmentainerGroup& newRow = |
| 664 columnSet->appendNewFragmentainerGroup(); | 663 columnSet->appendNewFragmentainerGroup(); |
| 665 // Zero-height rows should really not occur here, but if it does anyway, | 664 // Zero-height rows should really not occur here, but if it does anyway, |
| 666 // break, so that we don't get stuck in an infinite loop. | 665 // break, so that we don't get stuck in an infinite loop. |
| 667 ASSERT(newRow.logicalHeight() > 0); | 666 ASSERT(newRow.logicalHeight() > 0); |
| 668 if (newRow.logicalHeight() <= 0) | 667 if (newRow.logicalHeight() <= 0) |
| 669 break; | 668 break; |
| 670 } while (!columnSet->hasFragmentainerGroupForColumnAt(offsetInFlowThread, | 669 } while (columnSet->needsNewFragmentainerGroupAt(offsetInFlowThread, |
| 671 pageBoundaryRule)); | 670 pageBoundaryRule)); |
| 672 } | 671 } |
| 673 } | 672 } |
| 674 | 673 |
| 675 bool LayoutMultiColumnFlowThread::isFragmentainerLogicalHeightKnown() { | 674 bool LayoutMultiColumnFlowThread::isFragmentainerLogicalHeightKnown() { |
| 676 return isPageLogicalHeightKnown(); | 675 return isPageLogicalHeightKnown(); |
| 677 } | 676 } |
| 678 | 677 |
| 679 LayoutUnit LayoutMultiColumnFlowThread::fragmentainerLogicalHeightAt( | 678 LayoutUnit LayoutMultiColumnFlowThread::fragmentainerLogicalHeightAt( |
| 680 LayoutUnit blockOffset) { | 679 LayoutUnit blockOffset) { |
| 681 return pageLogicalHeightForOffset(blockOffset); | 680 return pageLogicalHeightForOffset(blockOffset); |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 const { | 1369 const { |
| 1371 return MultiColumnLayoutState(m_lastSetWorkedOn); | 1370 return MultiColumnLayoutState(m_lastSetWorkedOn); |
| 1372 } | 1371 } |
| 1373 | 1372 |
| 1374 void LayoutMultiColumnFlowThread::restoreMultiColumnLayoutState( | 1373 void LayoutMultiColumnFlowThread::restoreMultiColumnLayoutState( |
| 1375 const MultiColumnLayoutState& state) { | 1374 const MultiColumnLayoutState& state) { |
| 1376 m_lastSetWorkedOn = state.columnSet(); | 1375 m_lastSetWorkedOn = state.columnSet(); |
| 1377 } | 1376 } |
| 1378 | 1377 |
| 1379 } // namespace blink | 1378 } // namespace blink |
| OLD | NEW |