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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 |
OLD | NEW |