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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp

Issue 1908643003: Prioritize first-lines over orphans when deciding whether to propagate a strut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « third_party/WebKit/LayoutTests/fragmentation/block-with-float-and-1-orphaned-line-expected.txt ('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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 791
792 // Similar to how we apply clearance. Go ahead and boost height() to be the place where we're going to position the child. 792 // Similar to how we apply clearance. Go ahead and boost height() to be the place where we're going to position the child.
793 setLogicalHeight(logicalHeight() + (newLogicalTop - logicalTop)); 793 setLogicalHeight(logicalHeight() + (newLogicalTop - logicalTop));
794 794
795 // Return the final adjusted logical top. 795 // Return the final adjusted logical top.
796 return newLogicalTop; 796 return newLogicalTop;
797 } 797 }
798 798
799 static bool shouldSetStrutOnBlock(const LayoutBlockFlow& block, const RootInline Box& lineBox, LayoutUnit lineLogicalOffset, int lineIndex, LayoutUnit pageLogica lHeight) 799 static bool shouldSetStrutOnBlock(const LayoutBlockFlow& block, const RootInline Box& lineBox, LayoutUnit lineLogicalOffset, int lineIndex, LayoutUnit pageLogica lHeight)
800 { 800 {
801 bool wantsStrutOnBlock = false; 801 if (lineBox == block.firstRootBox()) {
802 if (!block.style()->hasAutoOrphans() && block.style()->orphans() >= lineInde x) {
803 // Not enough orphans here. Push the entire block to the next column / p age as an
804 // attempt to better satisfy the orphans requirement.
805 wantsStrutOnBlock = true;
806 } else if (lineBox == block.firstRootBox() && lineLogicalOffset == block.bor derAndPaddingBefore()) {
807 // This is the first line in the block. We can take the whole block with us to the next page 802 // This is the first line in the block. We can take the whole block with us to the next page
808 // or column, rather than keeping a content-less portion of it in the pr evious one. Only do 803 // or column, rather than keeping a content-less portion of it in the pr evious one. Only do
809 // this if the line is flush with the content edge of the block, though. If it isn't, it 804 // this if the line is flush with the content edge of the block, though. If it isn't, it
810 // means that the line was pushed downwards by preceding floats that did n't fit beside the 805 // means that the line was pushed downwards by preceding floats that did n't fit beside the
811 // line, and we don't want to move all that, since it has already been e stablished that it 806 // line, and we don't want to move all that, since it has already been e stablished that it
812 // fits nicely where it is. 807 // fits nicely where it is. In this case we have a class "C" break point [1] in front of
808 // this line.
809 //
810 // [1] https://drafts.csswg.org/css-break/#possible-breaks
811 if (lineLogicalOffset > block.borderAndPaddingBefore())
812 return false;
813
813 LayoutUnit lineHeight = lineBox.lineBottomWithLeading() - lineBox.lineTo pWithLeading(); 814 LayoutUnit lineHeight = lineBox.lineBottomWithLeading() - lineBox.lineTo pWithLeading();
814 LayoutUnit totalLogicalHeight = lineHeight + lineLogicalOffset.clampNega tiveToZero(); 815 LayoutUnit totalLogicalHeight = lineHeight + lineLogicalOffset.clampNega tiveToZero();
815 // It's rather pointless to break before the block if the current line i sn't going to 816 // It's rather pointless to break before the block if the current line i sn't going to
816 // fit in the same column or page, so check that as well. 817 // fit in the same column or page, so check that as well.
817 if (totalLogicalHeight <= pageLogicalHeight) 818 if (totalLogicalHeight > pageLogicalHeight)
818 wantsStrutOnBlock = true; 819 return false;
820 } else {
821 if (block.style()->hasAutoOrphans() || lineIndex > block.style()->orphan s())
822 return false;
823
824 // Not enough orphans here. Push the entire block to the next column / p age as an attempt to
825 // better satisfy the orphans requirement.
826 //
827 // Note that we should ideally check if the first line in the block is f lush with the
828 // content edge of the block here, because if it isn't, we should break at the class "C"
829 // break point in front of the first line, rather than before the entire block.
819 } 830 }
820 return wantsStrutOnBlock && block.allowsPaginationStrut(); 831 return block.allowsPaginationStrut();
821 } 832 }
822 833
823 void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, La youtUnit& delta) 834 void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, La youtUnit& delta)
824 { 835 {
825 // TODO(mstensho): Pay attention to line overflow. It should be painted in t he same column as 836 // TODO(mstensho): Pay attention to line overflow. It should be painted in t he same column as
826 // the rest of the line, possibly overflowing the column. We currently only allow overflow above 837 // the rest of the line, possibly overflowing the column. We currently only allow overflow above
827 // the first column. We clip at all other column boundaries, and that's how it has to be for 838 // the first column. We clip at all other column boundaries, and that's how it has to be for
828 // now. The paint we have to do when a column has overflow has to be special . We need to exclude 839 // now. The paint we have to do when a column has overflow has to be special . We need to exclude
829 // content that paints in a previous column (and content that paints in the following column). 840 // content that paints in a previous column (and content that paints in the following column).
830 // 841 //
(...skipping 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after
3029 // FIXME: Glyph overflow will get lost in this case, but not really a big de al. 3040 // FIXME: Glyph overflow will get lost in this case, but not really a big de al.
3030 GlyphOverflowAndFallbackFontsMap textBoxDataMap; 3041 GlyphOverflowAndFallbackFontsMap textBoxDataMap;
3031 for (ListHashSet<RootInlineBox*>::const_iterator it = lineBoxes.begin(); it != lineBoxes.end(); ++it) { 3042 for (ListHashSet<RootInlineBox*>::const_iterator it = lineBoxes.begin(); it != lineBoxes.end(); ++it) {
3032 RootInlineBox* box = *it; 3043 RootInlineBox* box = *it;
3033 box->computeOverflow(box->lineTop(), box->lineBottom(), textBoxDataMap); 3044 box->computeOverflow(box->lineTop(), box->lineBottom(), textBoxDataMap);
3034 } 3045 }
3035 return childrenOverflowChanged; 3046 return childrenOverflowChanged;
3036 } 3047 }
3037 3048
3038 } // namespace blink 3049 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fragmentation/block-with-float-and-1-orphaned-line-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698