OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
686 | 686 |
687 // Our guess was wrong. Make the child lay itself out again. | 687 // Our guess was wrong. Make the child lay itself out again. |
688 child->layoutIfNeeded(); | 688 child->layoutIfNeeded(); |
689 } | 689 } |
690 | 690 |
691 LayoutUnit oldTop = logicalTopAfterClear; | 691 LayoutUnit oldTop = logicalTopAfterClear; |
692 | 692 |
693 // If the object has a page or column break value of "before", then we shoul d shift to the top of the next page. | 693 // If the object has a page or column break value of "before", then we shoul d shift to the top of the next page. |
694 LayoutUnit result = applyBeforeBreak(child, logicalTopAfterClear); | 694 LayoutUnit result = applyBeforeBreak(child, logicalTopAfterClear); |
695 | 695 |
696 if (pageLogicalHeightForOffset(result)) { | |
697 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset( result, ExcludePageBoundary); | |
698 LayoutUnit spaceShortage = child->logicalHeight() - remainingLogicalHeig ht; | |
699 if (spaceShortage > 0) { | |
700 // If the child crosses a column boundary, report a break, in case n othing inside it has already | |
701 // done so. The column balancer needs to know how much it has to str etch the columns to make more | |
702 // content fit. If no breaks are reported (but do occur), the balanc er will have no clue. FIXME: | |
703 // This should be improved, though, because here we just pretend tha t the child is | |
704 // unsplittable. A splittable child, on the other hand, has break op portunities at every position | |
705 // where there's no child content, border or padding. In other words , we risk stretching more | |
706 // than necessary. | |
707 setPageBreak(result, spaceShortage); | |
708 } | |
709 } | |
710 | |
711 // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one. | 696 // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one. |
712 LayoutUnit logicalTopBeforeUnsplittableAdjustment = result; | 697 LayoutUnit logicalTopBeforeUnsplittableAdjustment = result; |
713 LayoutUnit logicalTopAfterUnsplittableAdjustment = adjustForUnsplittableChil d(child, result); | 698 LayoutUnit logicalTopAfterUnsplittableAdjustment = adjustForUnsplittableChil d(child, result); |
714 | 699 |
715 LayoutUnit paginationStrut = 0; | 700 LayoutUnit paginationStrut = 0; |
716 LayoutUnit unsplittableAdjustmentDelta = logicalTopAfterUnsplittableAdjustme nt - logicalTopBeforeUnsplittableAdjustment; | 701 LayoutUnit unsplittableAdjustmentDelta = logicalTopAfterUnsplittableAdjustme nt - logicalTopBeforeUnsplittableAdjustment; |
717 if (unsplittableAdjustmentDelta) | 702 LayoutUnit childLogicalHeight = child->logicalHeight(); |
703 if (unsplittableAdjustmentDelta) { | |
704 setPageBreak(result, childLogicalHeight - unsplittableAdjustmentDelta); | |
Julien - ping for review
2014/05/08 15:10:48
Wouldn't that report a page break even if we have
mstensho (USE GERRIT)
2014/05/08 15:32:55
unsplittableAdjustmentDelta is only set if the chi
| |
718 paginationStrut = unsplittableAdjustmentDelta; | 705 paginationStrut = unsplittableAdjustmentDelta; |
719 else if (childRenderBlock && childRenderBlock->paginationStrut()) | 706 } else if (childRenderBlock && childRenderBlock->paginationStrut()) { |
720 paginationStrut = childRenderBlock->paginationStrut(); | 707 paginationStrut = childRenderBlock->paginationStrut(); |
708 } | |
721 | 709 |
722 if (paginationStrut) { | 710 if (paginationStrut) { |
723 // We are willing to propagate out to our parent block as long as we wer e at the top of the block prior | 711 // We are willing to propagate out to our parent block as long as we wer e at the top of the block prior |
724 // to collapsing our margins, and as long as we didn't clear or move as a result of other pagination. | 712 // to collapsing our margins, and as long as we didn't clear or move as a result of other pagination. |
725 if (atBeforeSideOfBlock && oldTop == result && !isOutOfFlowPositioned() && !isTableCell()) { | 713 if (atBeforeSideOfBlock && oldTop == result && !isOutOfFlowPositioned() && !isTableCell()) { |
726 // FIXME: Should really check if we're exceeding the page height bef ore propagating the strut, but we don't | 714 // FIXME: Should really check if we're exceeding the page height bef ore propagating the strut, but we don't |
727 // have all the information to do so (the strut only has the remaini ng amount to push). Gecko gets this wrong too | 715 // have all the information to do so (the strut only has the remaini ng amount to push). Gecko gets this wrong too |
728 // and pushes to the next page anyway, so not too concerned about it . | 716 // and pushes to the next page anyway, so not too concerned about it . |
729 setPaginationStrut(result + paginationStrut); | 717 setPaginationStrut(result + paginationStrut); |
730 if (childRenderBlock) | 718 if (childRenderBlock) |
731 childRenderBlock->setPaginationStrut(0); | 719 childRenderBlock->setPaginationStrut(0); |
732 } else { | 720 } else { |
733 result += paginationStrut; | 721 result += paginationStrut; |
734 } | 722 } |
735 } | 723 } |
736 | 724 |
725 if (!unsplittableAdjustmentDelta) { | |
726 if (LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(result)) { | |
727 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOff set(result, ExcludePageBoundary); | |
728 LayoutUnit spaceShortage = childLogicalHeight - remainingLogicalHeig ht; | |
729 if (spaceShortage > 0) { | |
730 // If the child crosses a column boundary, report a break, in ca se nothing inside it | |
731 // has already done so. The column balancer needs to know how mu ch it has to stretch | |
732 // the columns to make more content fit. If no breaks are report ed (but do occur), | |
733 // the balancer will have no clue. | |
734 setPageBreak(result, spaceShortage); | |
735 } else if (remainingLogicalHeight == pageLogicalHeight && offsetFrom LogicalTopOfFirstPage() + child->logicalTop()) { | |
736 // We're at the very top of a page or column, and it's not the f irst one. This child | |
737 // may turn out to be the smallest piece of content that causes a page break, so we | |
738 // need to report it. | |
739 setPageBreak(result, childLogicalHeight); | |
740 } | |
741 } | |
742 } | |
743 | |
737 // Similar to how we apply clearance. Go ahead and boost height() to be the place where we're going to position the child. | 744 // Similar to how we apply clearance. Go ahead and boost height() to be the place where we're going to position the child. |
738 setLogicalHeight(logicalHeight() + (result - oldTop)); | 745 setLogicalHeight(logicalHeight() + (result - oldTop)); |
739 | 746 |
740 // Return the final adjusted logical top. | 747 // Return the final adjusted logical top. |
741 return result; | 748 return result; |
742 } | 749 } |
743 | 750 |
744 void RenderBlockFlow::rebuildFloatsFromIntruding() | 751 void RenderBlockFlow::rebuildFloatsFromIntruding() |
745 { | 752 { |
746 if (m_floatingObjects) | 753 if (m_floatingObjects) |
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2793 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() | 2800 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() |
2794 { | 2801 { |
2795 if (m_rareData) | 2802 if (m_rareData) |
2796 return *m_rareData; | 2803 return *m_rareData; |
2797 | 2804 |
2798 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); | 2805 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); |
2799 return *m_rareData; | 2806 return *m_rareData; |
2800 } | 2807 } |
2801 | 2808 |
2802 } // namespace WebCore | 2809 } // namespace WebCore |
OLD | NEW |