Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: Source/core/rendering/RenderBlockFlow.cpp

Issue 261383004: [New Multicolumn] Improve balancing for border/padding and empty block content. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address code review issues raised together with lgtm Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/multicol/border-padding-pagination.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 683
684 // Our guess was wrong. Make the child lay itself out again. 684 // Our guess was wrong. Make the child lay itself out again.
685 child->layoutIfNeeded(); 685 child->layoutIfNeeded();
686 } 686 }
687 687
688 LayoutUnit oldTop = logicalTopAfterClear; 688 LayoutUnit oldTop = logicalTopAfterClear;
689 689
690 // If the object has a page or column break value of "before", then we shoul d shift to the top of the next page. 690 // If the object has a page or column break value of "before", then we shoul d shift to the top of the next page.
691 LayoutUnit result = applyBeforeBreak(child, logicalTopAfterClear); 691 LayoutUnit result = applyBeforeBreak(child, logicalTopAfterClear);
692 692
693 if (pageLogicalHeightForOffset(result)) {
694 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset( result, ExcludePageBoundary);
695 LayoutUnit spaceShortage = child->logicalHeight() - remainingLogicalHeig ht;
696 if (spaceShortage > 0) {
697 // If the child crosses a column boundary, report a break, in case n othing inside it has already
698 // done so. The column balancer needs to know how much it has to str etch the columns to make more
699 // content fit. If no breaks are reported (but do occur), the balanc er will have no clue. FIXME:
700 // This should be improved, though, because here we just pretend tha t the child is
701 // unsplittable. A splittable child, on the other hand, has break op portunities at every position
702 // where there's no child content, border or padding. In other words , we risk stretching more
703 // than necessary.
704 setPageBreak(result, spaceShortage);
705 }
706 }
707
708 // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one. 693 // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one.
709 LayoutUnit logicalTopBeforeUnsplittableAdjustment = result; 694 LayoutUnit logicalTopBeforeUnsplittableAdjustment = result;
710 LayoutUnit logicalTopAfterUnsplittableAdjustment = adjustForUnsplittableChil d(child, result); 695 LayoutUnit logicalTopAfterUnsplittableAdjustment = adjustForUnsplittableChil d(child, result);
711 696
712 LayoutUnit paginationStrut = 0; 697 LayoutUnit paginationStrut = 0;
713 LayoutUnit unsplittableAdjustmentDelta = logicalTopAfterUnsplittableAdjustme nt - logicalTopBeforeUnsplittableAdjustment; 698 LayoutUnit unsplittableAdjustmentDelta = logicalTopAfterUnsplittableAdjustme nt - logicalTopBeforeUnsplittableAdjustment;
714 if (unsplittableAdjustmentDelta) 699 LayoutUnit childLogicalHeight = child->logicalHeight();
700 if (unsplittableAdjustmentDelta) {
701 setPageBreak(result, childLogicalHeight - unsplittableAdjustmentDelta);
715 paginationStrut = unsplittableAdjustmentDelta; 702 paginationStrut = unsplittableAdjustmentDelta;
716 else if (childRenderBlock && childRenderBlock->paginationStrut()) 703 } else if (childRenderBlock && childRenderBlock->paginationStrut()) {
717 paginationStrut = childRenderBlock->paginationStrut(); 704 paginationStrut = childRenderBlock->paginationStrut();
705 }
718 706
719 if (paginationStrut) { 707 if (paginationStrut) {
720 // We are willing to propagate out to our parent block as long as we wer e at the top of the block prior 708 // We are willing to propagate out to our parent block as long as we wer e at the top of the block prior
721 // to collapsing our margins, and as long as we didn't clear or move as a result of other pagination. 709 // to collapsing our margins, and as long as we didn't clear or move as a result of other pagination.
722 if (atBeforeSideOfBlock && oldTop == result && !isOutOfFlowPositioned() && !isTableCell()) { 710 if (atBeforeSideOfBlock && oldTop == result && !isOutOfFlowPositioned() && !isTableCell()) {
723 // FIXME: Should really check if we're exceeding the page height bef ore propagating the strut, but we don't 711 // FIXME: Should really check if we're exceeding the page height bef ore propagating the strut, but we don't
724 // have all the information to do so (the strut only has the remaini ng amount to push). Gecko gets this wrong too 712 // have all the information to do so (the strut only has the remaini ng amount to push). Gecko gets this wrong too
725 // and pushes to the next page anyway, so not too concerned about it . 713 // and pushes to the next page anyway, so not too concerned about it .
726 setPaginationStrut(result + paginationStrut); 714 setPaginationStrut(result + paginationStrut);
727 if (childRenderBlock) 715 if (childRenderBlock)
728 childRenderBlock->setPaginationStrut(0); 716 childRenderBlock->setPaginationStrut(0);
729 } else { 717 } else {
730 result += paginationStrut; 718 result += paginationStrut;
731 } 719 }
732 } 720 }
733 721
722 if (!unsplittableAdjustmentDelta) {
723 if (LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(result)) {
724 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOff set(result, ExcludePageBoundary);
725 LayoutUnit spaceShortage = childLogicalHeight - remainingLogicalHeig ht;
726 if (spaceShortage > 0) {
727 // If the child crosses a column boundary, report a break, in ca se nothing inside it
728 // has already done so. The column balancer needs to know how mu ch it has to stretch
729 // the columns to make more content fit. If no breaks are report ed (but do occur),
730 // the balancer will have no clue. Only measure the space after the last column
731 // boundary, in case it crosses more than one.
732 LayoutUnit spaceShortageInLastColumn = intMod(spaceShortage, pag eLogicalHeight);
733 setPageBreak(result, spaceShortageInLastColumn ? spaceShortageIn LastColumn : spaceShortage);
734 } else if (remainingLogicalHeight == pageLogicalHeight && offsetFrom LogicalTopOfFirstPage() + child->logicalTop()) {
735 // We're at the very top of a page or column, and it's not the f irst one. This child
736 // may turn out to be the smallest piece of content that causes a page break, so we
737 // need to report it.
738 setPageBreak(result, childLogicalHeight);
739 }
740 }
741 }
742
734 // Similar to how we apply clearance. Go ahead and boost height() to be the place where we're going to position the child. 743 // Similar to how we apply clearance. Go ahead and boost height() to be the place where we're going to position the child.
735 setLogicalHeight(logicalHeight() + (result - oldTop)); 744 setLogicalHeight(logicalHeight() + (result - oldTop));
736 745
737 // Return the final adjusted logical top. 746 // Return the final adjusted logical top.
738 return result; 747 return result;
739 } 748 }
740 749
741 void RenderBlockFlow::rebuildFloatsFromIntruding() 750 void RenderBlockFlow::rebuildFloatsFromIntruding()
742 { 751 {
743 if (m_floatingObjects) 752 if (m_floatingObjects)
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() 2802 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData()
2794 { 2803 {
2795 if (m_rareData) 2804 if (m_rareData)
2796 return *m_rareData; 2805 return *m_rareData;
2797 2806
2798 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); 2807 m_rareData = adoptPtr(new RenderBlockFlowRareData(this));
2799 return *m_rareData; 2808 return *m_rareData;
2800 } 2809 }
2801 2810
2802 } // namespace WebCore 2811 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/multicol/border-padding-pagination.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698