| 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 return columnSet; | 479 return columnSet; |
| 480 } | 480 } |
| 481 | 481 |
| 482 void LayoutMultiColumnFlowThread::layoutColumns( | 482 void LayoutMultiColumnFlowThread::layoutColumns( |
| 483 SubtreeLayoutScope& layoutScope) { | 483 SubtreeLayoutScope& layoutScope) { |
| 484 // Since we ended up here, it means that the multicol container (our parent) | 484 // Since we ended up here, it means that the multicol container (our parent) |
| 485 // needed layout. Since contents of the multicol container are diverted to the | 485 // needed layout. Since contents of the multicol container are diverted to the |
| 486 // flow thread, the flow thread needs layout as well. | 486 // flow thread, the flow thread needs layout as well. |
| 487 layoutScope.setChildNeedsLayout(this); | 487 layoutScope.setChildNeedsLayout(this); |
| 488 | 488 |
| 489 calculateColumnHeightAvailable(); |
| 490 |
| 489 if (FragmentationContext* enclosingFragmentationContext = | 491 if (FragmentationContext* enclosingFragmentationContext = |
| 490 this->enclosingFragmentationContext()) { | 492 this->enclosingFragmentationContext()) { |
| 491 m_blockOffsetInEnclosingFragmentationContext = | 493 m_blockOffsetInEnclosingFragmentationContext = |
| 492 multiColumnBlockFlow()->offsetFromLogicalTopOfFirstPage(); | 494 multiColumnBlockFlow()->offsetFromLogicalTopOfFirstPage(); |
| 493 m_blockOffsetInEnclosingFragmentationContext += | 495 m_blockOffsetInEnclosingFragmentationContext += |
| 494 multiColumnBlockFlow()->borderAndPaddingBefore(); | 496 multiColumnBlockFlow()->borderAndPaddingBefore(); |
| 495 | 497 |
| 496 if (LayoutMultiColumnFlowThread* enclosingFlowThread = | 498 if (LayoutMultiColumnFlowThread* enclosingFlowThread = |
| 497 enclosingFragmentationContext->associatedFlowThread()) { | 499 enclosingFragmentationContext->associatedFlowThread()) { |
| 498 if (LayoutMultiColumnSet* firstSet = firstMultiColumnSet()) { | 500 if (LayoutMultiColumnSet* firstSet = firstMultiColumnSet()) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 LayoutUnit blockOffset) { | 651 LayoutUnit blockOffset) { |
| 650 return pageLogicalHeightForOffset(blockOffset); | 652 return pageLogicalHeightForOffset(blockOffset); |
| 651 } | 653 } |
| 652 | 654 |
| 653 LayoutUnit LayoutMultiColumnFlowThread::remainingLogicalHeightAt( | 655 LayoutUnit LayoutMultiColumnFlowThread::remainingLogicalHeightAt( |
| 654 LayoutUnit blockOffset) { | 656 LayoutUnit blockOffset) { |
| 655 return pageRemainingLogicalHeightForOffset(blockOffset, | 657 return pageRemainingLogicalHeightForOffset(blockOffset, |
| 656 AssociateWithLatterPage); | 658 AssociateWithLatterPage); |
| 657 } | 659 } |
| 658 | 660 |
| 661 void LayoutMultiColumnFlowThread::calculateColumnHeightAvailable() { |
| 662 // Calculate the non-auto content box height, or set it to 0 if it's auto. We |
| 663 // need to know this before layout, so that we can figure out where to insert |
| 664 // column breaks. We also treat LayoutView (which may be paginated, which uses |
| 665 // the multicol implementation) as having a fixed height, since its height is |
| 666 // deduced from the viewport height. We use computeLogicalHeight() to |
| 667 // calculate the content box height. That method will clamp against max-height |
| 668 // and min-height. Since we're now at the beginning of layout, and we don't |
| 669 // know the actual height of the content yet, only call that method when |
| 670 // height is definite, or we might fool ourselves into believing that columns |
| 671 // have a definite height when they in fact don't. |
| 672 LayoutBlockFlow* container = multiColumnBlockFlow(); |
| 673 LayoutUnit columnHeight; |
| 674 if (container->hasDefiniteLogicalHeight() || container->isLayoutView()) { |
| 675 LogicalExtentComputedValues computedValues; |
| 676 container->computeLogicalHeight(LayoutUnit(), container->logicalTop(), |
| 677 computedValues); |
| 678 columnHeight = computedValues.m_extent - |
| 679 container->borderAndPaddingLogicalHeight() - |
| 680 container->scrollbarLogicalHeight(); |
| 681 } |
| 682 setColumnHeightAvailable(std::max(columnHeight, LayoutUnit())); |
| 683 } |
| 684 |
| 659 void LayoutMultiColumnFlowThread::calculateColumnCountAndWidth( | 685 void LayoutMultiColumnFlowThread::calculateColumnCountAndWidth( |
| 660 LayoutUnit& width, | 686 LayoutUnit& width, |
| 661 unsigned& count) const { | 687 unsigned& count) const { |
| 662 LayoutBlock* columnBlock = multiColumnBlockFlow(); | 688 LayoutBlock* columnBlock = multiColumnBlockFlow(); |
| 663 const ComputedStyle* columnStyle = columnBlock->style(); | 689 const ComputedStyle* columnStyle = columnBlock->style(); |
| 664 LayoutUnit availableWidth = columnBlock->contentLogicalWidth(); | 690 LayoutUnit availableWidth = columnBlock->contentLogicalWidth(); |
| 665 LayoutUnit columnGap = LayoutUnit(columnBlock->columnGap()); | 691 LayoutUnit columnGap = LayoutUnit(columnBlock->columnGap()); |
| 666 LayoutUnit computedColumnWidth = | 692 LayoutUnit computedColumnWidth = |
| 667 max(LayoutUnit(1), LayoutUnit(columnStyle->columnWidth())); | 693 max(LayoutUnit(1), LayoutUnit(columnStyle->columnWidth())); |
| 668 unsigned computedColumnCount = max<int>(1, columnStyle->columnCount()); | 694 unsigned computedColumnCount = max<int>(1, columnStyle->columnCount()); |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 const { | 1346 const { |
| 1321 return MultiColumnLayoutState(m_lastSetWorkedOn); | 1347 return MultiColumnLayoutState(m_lastSetWorkedOn); |
| 1322 } | 1348 } |
| 1323 | 1349 |
| 1324 void LayoutMultiColumnFlowThread::restoreMultiColumnLayoutState( | 1350 void LayoutMultiColumnFlowThread::restoreMultiColumnLayoutState( |
| 1325 const MultiColumnLayoutState& state) { | 1351 const MultiColumnLayoutState& state) { |
| 1326 m_lastSetWorkedOn = state.columnSet(); | 1352 m_lastSetWorkedOn = state.columnSet(); |
| 1327 } | 1353 } |
| 1328 | 1354 |
| 1329 } // namespace blink | 1355 } // namespace blink |
| OLD | NEW |