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 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 lineBox.setPaginationStrut(LayoutUnit()); | 761 lineBox.setPaginationStrut(LayoutUnit()); |
762 lineBox.setIsFirstAfterPageBreak(false); | 762 lineBox.setIsFirstAfterPageBreak(false); |
763 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); | 763 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); |
764 if (!pageLogicalHeight) | 764 if (!pageLogicalHeight) |
765 return; | 765 return; |
766 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, AssociateWithLatterPage); | 766 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, AssociateWithLatterPage); |
767 int lineIndex = lineCount(&lineBox); | 767 int lineIndex = lineCount(&lineBox); |
768 if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow()
&& lineBreakToAvoidWidow() == lineIndex)) { | 768 if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow()
&& lineBreakToAvoidWidow() == lineIndex)) { |
769 LayoutUnit paginationStrut = calculatePaginationStrutToFitContent(logica
lOffset, remainingLogicalHeight, lineHeight); | 769 LayoutUnit paginationStrut = calculatePaginationStrutToFitContent(logica
lOffset, remainingLogicalHeight, lineHeight); |
770 LayoutUnit newLogicalOffset = logicalOffset + paginationStrut; | 770 LayoutUnit newLogicalOffset = logicalOffset + paginationStrut; |
771 // The new offset may require us to insert a new row for columns (fragme
ntainer group). | |
772 // Give the multicol machinery an opportunity to do so (before checking
the height of a | |
773 // column that wouldn't have existed yet otherwise). | |
774 paginatedContentWasLaidOut(newLogicalOffset + lineHeight); | |
775 // Moving to a different page or column may mean that its height is diff
erent. | 771 // Moving to a different page or column may mean that its height is diff
erent. |
776 pageLogicalHeight = pageLogicalHeightForOffset(newLogicalOffset); | 772 pageLogicalHeight = pageLogicalHeightForOffset(newLogicalOffset); |
777 if (lineHeight > pageLogicalHeight) { | 773 if (lineHeight > pageLogicalHeight) { |
778 // Too tall to fit in one page / column. Give up. Don't push to the
next page / column. | 774 // Too tall to fit in one page / column. Give up. Don't push to the
next page / column. |
779 // TODO(mstensho): Get rid of this. This is just utter weirdness, bu
t the other browsers | 775 // TODO(mstensho): Get rid of this. This is just utter weirdness, bu
t the other browsers |
780 // also do something slightly similar, although in much more specifi
c cases than we do here, | 776 // also do something slightly similar, although in much more specifi
c cases than we do here, |
781 // and printing Google Docs depends on it. | 777 // and printing Google Docs depends on it. |
| 778 paginatedContentWasLaidOut(logicalOffset + lineHeight); |
782 return; | 779 return; |
783 } | 780 } |
784 | 781 |
785 // We need to insert a break now, either because there's no room for the
line in the | 782 // We need to insert a break now, either because there's no room for the
line in the |
786 // current column / page, or because we have determined that we need a b
reak to satisfy | 783 // current column / page, or because we have determined that we need a b
reak to satisfy |
787 // widow requirements. | 784 // widow requirements. |
788 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn
dex) { | 785 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn
dex) { |
789 clearShouldBreakAtLineToAvoidWidow(); | 786 clearShouldBreakAtLineToAvoidWidow(); |
790 setDidBreakAtLineToAvoidWidow(); | 787 setDidBreakAtLineToAvoidWidow(); |
791 } | 788 } |
792 if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, page
LogicalHeight)) { | 789 if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, page
LogicalHeight)) { |
793 // Note that when setting the strut on a block, it may be propagated
to parent blocks | 790 // Note that when setting the strut on a block, it may be propagated
to parent blocks |
794 // later on, if a block's logical top is flush with that of its pare
nt. We don't want | 791 // later on, if a block's logical top is flush with that of its pare
nt. We don't want |
795 // content-less portions (struts) at the beginning of a block before
a break, if it can | 792 // content-less portions (struts) at the beginning of a block before
a break, if it can |
796 // be avoided. After all, that's the reason for setting struts on bl
ocks and not lines | 793 // be avoided. After all, that's the reason for setting struts on bl
ocks and not lines |
797 // in the first place. | 794 // in the first place. |
798 LayoutUnit strut = paginationStrut + logicalOffset + marginBeforeIfF
loating(); | 795 LayoutUnit strut = paginationStrut + logicalOffset + marginBeforeIfF
loating(); |
799 setPaginationStrutPropagatedFromChild(strut); | 796 setPaginationStrutPropagatedFromChild(strut); |
800 } else { | 797 } else { |
801 delta += paginationStrut; | 798 delta += paginationStrut; |
802 lineBox.setPaginationStrut(paginationStrut); | 799 lineBox.setPaginationStrut(paginationStrut); |
803 lineBox.setIsFirstAfterPageBreak(true); | 800 lineBox.setIsFirstAfterPageBreak(true); |
804 } | 801 } |
| 802 paginatedContentWasLaidOut(newLogicalOffset + lineHeight); |
805 return; | 803 return; |
806 } | 804 } |
807 | 805 |
808 if (remainingLogicalHeight == pageLogicalHeight) { | 806 if (remainingLogicalHeight == pageLogicalHeight) { |
809 // We're at the very top of a page or column. | 807 // We're at the very top of a page or column. |
810 if (lineBox != firstRootBox()) | 808 if (lineBox != firstRootBox()) |
811 lineBox.setIsFirstAfterPageBreak(true); | 809 lineBox.setIsFirstAfterPageBreak(true); |
812 // If this is the first line in the block, and the block has a top borde
r, padding, or (in | 810 // If this is the first line in the block, and the block has a top borde
r, padding, or (in |
813 // case it's a float) margin, we may want to set a strut on the block, s
o that everything | 811 // case it's a float) margin, we may want to set a strut on the block, s
o that everything |
814 // ends up in the next column or page. Setting a strut on the block is a
lso important when | 812 // ends up in the next column or page. Setting a strut on the block is a
lso important when |
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2858 FrameView* frameView = document().view(); | 2856 FrameView* frameView = document().view(); |
2859 LayoutUnit top = LayoutUnit((style()->position() == FixedPosition) ? 0 : fra
meView->scrollOffset().height()); | 2857 LayoutUnit top = LayoutUnit((style()->position() == FixedPosition) ? 0 : fra
meView->scrollOffset().height()); |
2860 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 2858 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
2861 if (size().height() < visibleHeight) | 2859 if (size().height() < visibleHeight) |
2862 top += (visibleHeight - size().height()) / 2; | 2860 top += (visibleHeight - size().height()) / 2; |
2863 setY(top); | 2861 setY(top); |
2864 dialog->setCentered(top); | 2862 dialog->setCentered(top); |
2865 } | 2863 } |
2866 | 2864 |
2867 } // namespace blink | 2865 } // namespace blink |
OLD | NEW |