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 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
767 // Too tall to fit in one page / column. Give up. Don't push to the next page / column. | 767 // Too tall to fit in one page / column. Give up. Don't push to the next page / column. |
768 // TODO(mstensho): Get rid of this. This is just utter weirdness, but th e other browsers | 768 // TODO(mstensho): Get rid of this. This is just utter weirdness, but th e other browsers |
769 // also do something slightly similar, although in much more specific ca ses than we do here, | 769 // also do something slightly similar, although in much more specific ca ses than we do here, |
770 // and printing Google Docs depends on it. | 770 // and printing Google Docs depends on it. |
771 return; | 771 return; |
772 } | 772 } |
773 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary); | 773 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary); |
774 | 774 |
775 int lineIndex = lineCount(&lineBox); | 775 int lineIndex = lineCount(&lineBox); |
776 if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIndex)) { | 776 if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIndex)) { |
777 // We need to insert a break now, either because there's no room for the line in the | |
778 // current column / page, or because we have determined that we need a b reak to satisfy | |
779 // widow requirements. | |
777 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn dex) { | 780 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn dex) { |
778 clearShouldBreakAtLineToAvoidWidow(); | 781 clearShouldBreakAtLineToAvoidWidow(); |
779 setDidBreakAtLineToAvoidWidow(); | 782 setDidBreakAtLineToAvoidWidow(); |
780 } | 783 } |
781 LayoutUnit totalLogicalHeight = lineHeight + std::max<LayoutUnit>(0, log icalOffset); | |
782 LayoutUnit pageLogicalHeightAtNewOffset = pageLogicalHeightForOffset(log icalOffset + remainingLogicalHeight); | |
783 setPageBreak(logicalOffset, lineHeight - remainingLogicalHeight); | 784 setPageBreak(logicalOffset, lineHeight - remainingLogicalHeight); |
784 if (((lineBox == firstRootBox() && totalLogicalHeight < pageLogicalHeigh tAtNewOffset) || (!style()->hasAutoOrphans() && style()->orphans() >= lineIndex) ) | 785 // Decide whether to insert the break before the current line, or before the entire block. |
785 && !isOutOfFlowPositioned() && !isTableCell()) { | 786 bool wantsStrutOnBlock = false; |
787 if (!style()->hasAutoOrphans() && style()->orphans() >= lineIndex) { | |
leviw_travelin_and_unemployed
2015/08/10 19:46:19
It may be worth extracting this if/else block (det
mstensho (USE GERRIT)
2015/08/10 20:14:45
Done.
That helper function got some papayawhip-co
| |
788 // Not enough orphans here. Push the entire block to the next column / page as an | |
789 // attempt to better satisfy the orphans requirement. | |
790 wantsStrutOnBlock = true; | |
791 } else if (lineBox == firstRootBox() && logicalOffset == borderAndPaddin gBefore()) { | |
792 // This is the first line in the block. We can take the whole block with us to the next | |
793 // page or column, rather than keeping a content-less portion of it in the previous | |
794 // one. Only do this if the line is flush with the content edge of t he block, | |
795 // though. If it isn't, it means that the line was pushed downwards by preceding floats | |
796 // that didn't fit beside the line, and we don't want to move all th at, since it has | |
797 // already been established that it fits nicely where it is. | |
798 LayoutUnit totalLogicalHeight = lineHeight + std::max<LayoutUnit>(0, logicalOffset); | |
799 LayoutUnit pageLogicalHeightAtNewOffset = pageLogicalHeightForOffset (logicalOffset + remainingLogicalHeight); | |
800 // It's rather pointless to break before the block if the current li ne isn't going to | |
801 // fit in the same column or page, so check that as well. | |
802 if (totalLogicalHeight < pageLogicalHeightAtNewOffset) | |
803 wantsStrutOnBlock = true; | |
804 } | |
805 // If we want to break before the block, one final check is needed, sinc e some block object | |
806 // types cannot handle struts. | |
807 if (wantsStrutOnBlock && !isOutOfFlowPositioned() && !isTableCell()) { | |
808 // Note that when setting the strut on a block, it may be propagated to parent blocks | |
809 // later on, if a block's logical top is flush with that of its pare nt. We don't want | |
810 // content-less portions (struts) at the beginning of a block before a break, if it can | |
811 // be avoided. After all, that's the reason for setting struts on bl ocks and not lines | |
812 // in the first place. | |
786 setPaginationStrut(remainingLogicalHeight + std::max<LayoutUnit>(0, logicalOffset)); | 813 setPaginationStrut(remainingLogicalHeight + std::max<LayoutUnit>(0, logicalOffset)); |
787 } else { | 814 } else { |
788 delta += remainingLogicalHeight; | 815 delta += remainingLogicalHeight; |
789 lineBox.setPaginationStrut(remainingLogicalHeight); | 816 lineBox.setPaginationStrut(remainingLogicalHeight); |
790 lineBox.setIsFirstAfterPageBreak(true); | 817 lineBox.setIsFirstAfterPageBreak(true); |
791 } | 818 } |
792 } else if (remainingLogicalHeight == pageLogicalHeight) { | 819 } else if (remainingLogicalHeight == pageLogicalHeight) { |
793 // We're at the very top of a page or column. | 820 // We're at the very top of a page or column. |
794 if (lineBox != firstRootBox()) | 821 if (lineBox != firstRootBox()) |
795 lineBox.setIsFirstAfterPageBreak(true); | 822 lineBox.setIsFirstAfterPageBreak(true); |
(...skipping 2227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3023 FrameView* frameView = document().view(); | 3050 FrameView* frameView = document().view(); |
3024 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); | 3051 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); |
3025 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); | 3052 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); |
3026 if (size().height() < visibleHeight) | 3053 if (size().height() < visibleHeight) |
3027 top += (visibleHeight - size().height()) / 2; | 3054 top += (visibleHeight - size().height()) / 2; |
3028 setY(top); | 3055 setY(top); |
3029 dialog->setCentered(top); | 3056 dialog->setCentered(top); |
3030 } | 3057 } |
3031 | 3058 |
3032 } // namespace blink | 3059 } // namespace blink |
OLD | NEW |