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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 | 730 |
731 paginatedContentWasLaidOut(newLogicalTop); | 731 paginatedContentWasLaidOut(newLogicalTop); |
732 | 732 |
733 // Similar to how we apply clearance. Go ahead and boost height() to be the
place where we're going to position the child. | 733 // Similar to how we apply clearance. Go ahead and boost height() to be the
place where we're going to position the child. |
734 setLogicalHeight(logicalHeight() + (newLogicalTop - logicalTop)); | 734 setLogicalHeight(logicalHeight() + (newLogicalTop - logicalTop)); |
735 | 735 |
736 // Return the final adjusted logical top. | 736 // Return the final adjusted logical top. |
737 return newLogicalTop; | 737 return newLogicalTop; |
738 } | 738 } |
739 | 739 |
740 static inline LayoutUnit calculateMinimumPageHeight(const ComputedStyle& style,
const RootInlineBox& lastLine) | |
741 { | |
742 // We may require a certain minimum number of lines per page in order to sat
isfy | |
743 // orphans and widows, and that may affect the minimum page height. | |
744 unsigned lineCount = std::max<unsigned>(style.hasAutoOrphans() ? 1 : style.o
rphans(), style.widows()); | |
745 const RootInlineBox* firstLine = &lastLine; | |
746 for (unsigned i = 1; i < lineCount && firstLine->prevRootBox(); i++) | |
747 firstLine = firstLine->prevRootBox(); | |
748 return lastLine.lineBottomWithLeading() - firstLine->lineTopWithLeading(); | |
749 } | |
750 | |
751 static inline bool shouldSetStrutOnBlock(const LayoutBlockFlow& block, const Roo
tInlineBox& lineBox, LayoutUnit lineLogicalOffset, int lineIndex, LayoutUnit rem
ainingLogicalHeight) | 740 static inline bool shouldSetStrutOnBlock(const LayoutBlockFlow& block, const Roo
tInlineBox& lineBox, LayoutUnit lineLogicalOffset, int lineIndex, LayoutUnit rem
ainingLogicalHeight) |
752 { | 741 { |
753 bool wantsStrutOnBlock = false; | 742 bool wantsStrutOnBlock = false; |
754 if (!block.style()->hasAutoOrphans() && block.style()->orphans() >= lineInde
x) { | 743 if (!block.style()->hasAutoOrphans() && block.style()->orphans() >= lineInde
x) { |
755 // Not enough orphans here. Push the entire block to the next column / p
age as an | 744 // Not enough orphans here. Push the entire block to the next column / p
age as an |
756 // attempt to better satisfy the orphans requirement. | 745 // attempt to better satisfy the orphans requirement. |
757 wantsStrutOnBlock = true; | 746 wantsStrutOnBlock = true; |
758 } else if (lineBox == block.firstRootBox() && lineLogicalOffset == block.bor
derAndPaddingBefore()) { | 747 } else if (lineBox == block.firstRootBox() && lineLogicalOffset == block.bor
derAndPaddingBefore()) { |
759 // This is the first line in the block. We can take the whole block with
us to the next page | 748 // This is the first line in the block. We can take the whole block with
us to the next page |
760 // or column, rather than keeping a content-less portion of it in the pr
evious one. Only do | 749 // or column, rather than keeping a content-less portion of it in the pr
evious one. Only do |
(...skipping 18 matching lines...) Expand all Loading... |
779 // the rest of the line, possibly overflowing the column. We currently only
allow overflow above | 768 // the rest of the line, possibly overflowing the column. We currently only
allow overflow above |
780 // the first column. We clip at all other column boundaries, and that's how
it has to be for | 769 // the first column. We clip at all other column boundaries, and that's how
it has to be for |
781 // now. The paint we have to do when a column has overflow has to be special
. We need to exclude | 770 // now. The paint we have to do when a column has overflow has to be special
. We need to exclude |
782 // content that paints in a previous column (and content that paints in the
following column). | 771 // content that paints in a previous column (and content that paints in the
following column). |
783 // | 772 // |
784 // FIXME: Another problem with simply moving lines is that the available lin
e width may change (because of floats). | 773 // FIXME: Another problem with simply moving lines is that the available lin
e width may change (because of floats). |
785 // Technically if the location we move the line to has a different line widt
h than our old position, then we need to dirty the | 774 // Technically if the location we move the line to has a different line widt
h than our old position, then we need to dirty the |
786 // line and all following lines. | 775 // line and all following lines. |
787 LayoutUnit logicalOffset = lineBox.lineTopWithLeading(); | 776 LayoutUnit logicalOffset = lineBox.lineTopWithLeading(); |
788 LayoutUnit lineHeight = lineBox.lineBottomWithLeading() - logicalOffset; | 777 LayoutUnit lineHeight = lineBox.lineBottomWithLeading() - logicalOffset; |
789 updateMinimumPageHeight(logicalOffset, calculateMinimumPageHeight(styleRef()
, lineBox)); | |
790 logicalOffset += delta; | 778 logicalOffset += delta; |
791 lineBox.setPaginationStrut(LayoutUnit()); | 779 lineBox.setPaginationStrut(LayoutUnit()); |
792 lineBox.setIsFirstAfterPageBreak(false); | 780 lineBox.setIsFirstAfterPageBreak(false); |
793 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); | 781 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); |
794 if (!pageLogicalHeight) | 782 if (!pageLogicalHeight) |
795 return; | 783 return; |
796 if (lineHeight > pageLogicalHeight) { | 784 if (lineHeight > pageLogicalHeight) { |
797 // Too tall to fit in one page / column. Give up. Don't push to the next
page / column. | 785 // Too tall to fit in one page / column. Give up. Don't push to the next
page / column. |
798 // TODO(mstensho): Get rid of this. This is just utter weirdness, but th
e other browsers | 786 // TODO(mstensho): Get rid of this. This is just utter weirdness, but th
e other browsers |
799 // also do something slightly similar, although in much more specific ca
ses than we do here, | 787 // also do something slightly similar, although in much more specific ca
ses than we do here, |
(...skipping 29 matching lines...) Expand all Loading... |
829 } | 817 } |
830 } else if (remainingLogicalHeight == pageLogicalHeight) { | 818 } else if (remainingLogicalHeight == pageLogicalHeight) { |
831 // We're at the very top of a page or column. | 819 // We're at the very top of a page or column. |
832 if (lineBox != firstRootBox()) | 820 if (lineBox != firstRootBox()) |
833 lineBox.setIsFirstAfterPageBreak(true); | 821 lineBox.setIsFirstAfterPageBreak(true); |
834 } | 822 } |
835 | 823 |
836 paginatedContentWasLaidOut(logicalOffset); | 824 paginatedContentWasLaidOut(logicalOffset); |
837 } | 825 } |
838 | 826 |
839 LayoutUnit LayoutBlockFlow::adjustForUnsplittableChild(LayoutBox& child, LayoutU
nit logicalOffset) | 827 LayoutUnit LayoutBlockFlow::adjustForUnsplittableChild(LayoutBox& child, LayoutU
nit logicalOffset) const |
840 { | 828 { |
841 if (child.paginationBreakability() == AllowAnyBreaks) | 829 if (child.paginationBreakability() == AllowAnyBreaks) |
842 return logicalOffset; | 830 return logicalOffset; |
843 LayoutUnit childLogicalHeight = logicalHeightForChild(child); | 831 LayoutUnit childLogicalHeight = logicalHeightForChild(child); |
844 // Floats' margins do not collapse with page or column boundaries. | 832 // Floats' margins do not collapse with page or column boundaries. |
845 if (child.isFloating()) | 833 if (child.isFloating()) |
846 childLogicalHeight += marginBeforeForChild(child) + marginAfterForChild(
child); | 834 childLogicalHeight += marginBeforeForChild(child) + marginAfterForChild(
child); |
847 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); | 835 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); |
848 updateMinimumPageHeight(logicalOffset, childLogicalHeight); | |
849 if (!pageLogicalHeight) | 836 if (!pageLogicalHeight) |
850 return logicalOffset; | 837 return logicalOffset; |
851 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, AssociateWithLatterPage); | 838 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, AssociateWithLatterPage); |
852 // Break if there's not enough space left for us, but only as long as we're
not already at the | 839 // Break if there's not enough space left for us, but only as long as we're
not already at the |
853 // top of a page. No point in leaving a page completely blank. | 840 // top of a page. No point in leaving a page completely blank. |
854 if (remainingLogicalHeight < childLogicalHeight && remainingLogicalHeight <
pageLogicalHeight) | 841 if (remainingLogicalHeight < childLogicalHeight && remainingLogicalHeight <
pageLogicalHeight) |
855 return logicalOffset + remainingLogicalHeight; | 842 return logicalOffset + remainingLogicalHeight; |
856 return logicalOffset; | 843 return logicalOffset; |
857 } | 844 } |
858 | 845 |
(...skipping 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3066 FrameView* frameView = document().view(); | 3053 FrameView* frameView = document().view(); |
3067 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 3054 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
3068 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 3055 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
3069 if (size().height() < visibleHeight) | 3056 if (size().height() < visibleHeight) |
3070 top += (visibleHeight - size().height()) / 2; | 3057 top += (visibleHeight - size().height()) / 2; |
3071 setY(top); | 3058 setY(top); |
3072 dialog->setCentered(top); | 3059 dialog->setCentered(top); |
3073 } | 3060 } |
3074 | 3061 |
3075 } // namespace blink | 3062 } // namespace blink |
OLD | NEW |