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

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

Issue 2360253002: Content that starts before the first fragmentainer should stay where it is. (Closed)
Patch Set: Created 4 years, 2 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/content-preceding-first-fragmentainer.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 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 setPaginationStrutPropagatedFromChild(strut); 973 setPaginationStrutPropagatedFromChild(strut);
974 } else { 974 } else {
975 delta += paginationStrut; 975 delta += paginationStrut;
976 lineBox.setPaginationStrut(paginationStrut); 976 lineBox.setPaginationStrut(paginationStrut);
977 lineBox.setIsFirstAfterPageBreak(true); 977 lineBox.setIsFirstAfterPageBreak(true);
978 } 978 }
979 paginatedContentWasLaidOut(newLogicalOffset + lineHeight); 979 paginatedContentWasLaidOut(newLogicalOffset + lineHeight);
980 return; 980 return;
981 } 981 }
982 982
983 LayoutUnit strutToPropagate;
983 if (remainingLogicalHeight == pageLogicalHeight) { 984 if (remainingLogicalHeight == pageLogicalHeight) {
984 // We're at the very top of a page or column. 985 // We're at the very top of a page or column.
985 if (lineBox != firstRootBox()) 986 if (lineBox != firstRootBox())
986 lineBox.setIsFirstAfterPageBreak(true); 987 lineBox.setIsFirstAfterPageBreak(true);
987 // If this is the first line in the block, and the block has a top borde r, padding, or (in 988 // If this is the first line in the block, and the block has a top borde r, padding, or (in
988 // case it's a float) margin, we may want to set a strut on the block, s o that everything 989 // case it's a float) margin, we may want to set a strut on the block, s o that everything
989 // ends up in the next column or page. Setting a strut on the block is a lso important when 990 // ends up in the next column or page. Setting a strut on the block is a lso important when
990 // it comes to satisfying orphan requirements. 991 // it comes to satisfying orphan requirements.
991 if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, page LogicalHeight)) { 992 if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, page LogicalHeight))
992 LayoutUnit strut = logicalOffset + marginBeforeIfFloating(); 993 strutToPropagate = logicalOffset + marginBeforeIfFloating();
993 setPaginationStrutPropagatedFromChild(strut);
994 }
995 } else if (lineBox == firstRootBox() && allowsPaginationStrut()) { 994 } else if (lineBox == firstRootBox() && allowsPaginationStrut()) {
996 // This is the first line in the block. The block may still start in the previous column or 995 // This is the first line in the block. The block may still start in the previous column or
997 // page, and if that's the case, attempt to pull it over to where this l ine is, so that we 996 // page, and if that's the case, attempt to pull it over to where this l ine is, so that we
998 // don't split the top border, padding, or (in case it's a float) margin . 997 // don't split the top border, padding, or (in case it's a float) margin .
999 LayoutUnit totalLogicalOffset = logicalOffset + marginBeforeIfFloating() ; 998 LayoutUnit totalLogicalOffset = logicalOffset + marginBeforeIfFloating() ;
1000 LayoutUnit strut = remainingLogicalHeight + totalLogicalOffset - pageLog icalHeight; 999 LayoutUnit strut = remainingLogicalHeight + totalLogicalOffset - pageLog icalHeight;
1001 if (strut > 0) { 1000 if (strut > 0) {
1002 // The block starts in a previous column or page. Set a strut on the block if there's 1001 // The block starts in a previous column or page. Set a strut on the block if there's
1003 // room for the top border, padding and (if it's a float) margin and the line in one 1002 // room for the top border, padding and (if it's a float) margin and the line in one
1004 // column or page. 1003 // column or page.
1005 if (totalLogicalOffset + lineHeight <= pageLogicalHeight) 1004 if (totalLogicalOffset + lineHeight <= pageLogicalHeight)
1006 setPaginationStrutPropagatedFromChild(strut); 1005 strutToPropagate = strut;
1007 } 1006 }
1008 } 1007 }
1009 1008
1009 // If we found that some preceding content (lines, border and padding) belon gs together with
1010 // this line, we should pull the entire block with us to the fragmentainer w e're currently
1011 // in. We need to avoid this when the block precedes the first fragmentainer , though. We
1012 // shouldn't fragment content there, but rather let it appear in the overflo w area before the
1013 // first fragmentainer.
1014 if (strutToPropagate && offsetFromLogicalTopOfFirstPage() > LayoutUnit())
1015 setPaginationStrutPropagatedFromChild(strutToPropagate);
1016
1010 paginatedContentWasLaidOut(logicalOffset + lineHeight); 1017 paginatedContentWasLaidOut(logicalOffset + lineHeight);
1011 } 1018 }
1012 1019
1013 LayoutUnit LayoutBlockFlow::adjustForUnsplittableChild(LayoutBox& child, LayoutU nit logicalOffset) const 1020 LayoutUnit LayoutBlockFlow::adjustForUnsplittableChild(LayoutBox& child, LayoutU nit logicalOffset) const
1014 { 1021 {
1015 if (child.getPaginationBreakability() == AllowAnyBreaks) 1022 if (child.getPaginationBreakability() == AllowAnyBreaks)
1016 return logicalOffset; 1023 return logicalOffset;
1017 LayoutUnit childLogicalHeight = logicalHeightForChild(child); 1024 LayoutUnit childLogicalHeight = logicalHeightForChild(child);
1018 // Floats' margins do not collapse with page or column boundaries. 1025 // Floats' margins do not collapse with page or column boundaries.
1019 if (child.isFloating()) 1026 if (child.isFloating())
(...skipping 2753 matching lines...) Expand 10 before | Expand all | Expand 10 after
3773 3780
3774 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); 3781 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState);
3775 } 3782 }
3776 3783
3777 void LayoutBlockFlow::invalidateDisplayItemClients(PaintInvalidationReason inval idationReason) const 3784 void LayoutBlockFlow::invalidateDisplayItemClients(PaintInvalidationReason inval idationReason) const
3778 { 3785 {
3779 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients(invalidationRe ason); 3786 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients(invalidationRe ason);
3780 } 3787 }
3781 3788
3782 } // namespace blink 3789 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fragmentation/content-preceding-first-fragmentainer.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698