| 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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 paginationStrut = childBlockFlow->paginationStrut(); | 690 paginationStrut = childBlockFlow->paginationStrut(); |
| 691 } | 691 } |
| 692 | 692 |
| 693 if (paginationStrut) { | 693 if (paginationStrut) { |
| 694 // We are willing to propagate out to our parent block as long as we wer
e at the top of the block prior | 694 // We are willing to propagate out to our parent block as long as we wer
e at the top of the block prior |
| 695 // to collapsing our margins, and as long as we didn't clear or move as
a result of other pagination. | 695 // to collapsing our margins, and as long as we didn't clear or move as
a result of other pagination. |
| 696 if (atBeforeSideOfBlock && logicalTop == newLogicalTop && !isOutOfFlowPo
sitioned() && !isTableCell()) { | 696 if (atBeforeSideOfBlock && logicalTop == newLogicalTop && !isOutOfFlowPo
sitioned() && !isTableCell()) { |
| 697 // FIXME: Should really check if we're exceeding the page height bef
ore propagating the strut, but we don't | 697 // FIXME: Should really check if we're exceeding the page height bef
ore propagating the strut, but we don't |
| 698 // have all the information to do so (the strut only has the remaini
ng amount to push). Gecko gets this wrong too | 698 // have all the information to do so (the strut only has the remaini
ng amount to push). Gecko gets this wrong too |
| 699 // and pushes to the next page anyway, so not too concerned about it
. | 699 // and pushes to the next page anyway, so not too concerned about it
. |
| 700 setPaginationStrut(logicalTop + paginationStrut); | 700 paginationStrut += logicalTop; |
| 701 if (isFloating()) |
| 702 paginationStrut += marginBefore(); // Floats' margins do not col
lapse with page or column boundaries. |
| 703 setPaginationStrut(paginationStrut); |
| 701 if (childBlockFlow) | 704 if (childBlockFlow) |
| 702 childBlockFlow->setPaginationStrut(0); | 705 childBlockFlow->setPaginationStrut(0); |
| 703 } else { | 706 } else { |
| 704 newLogicalTop += paginationStrut; | 707 newLogicalTop += paginationStrut; |
| 705 } | 708 } |
| 706 } | 709 } |
| 707 | 710 |
| 708 if (!unsplittableAdjustmentDelta) { | 711 if (!unsplittableAdjustmentDelta) { |
| 709 if (LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(newLogical
Top)) { | 712 if (LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(newLogical
Top)) { |
| 710 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOff
set(newLogicalTop, AssociateWithLatterPage); | 713 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOff
set(newLogicalTop, AssociateWithLatterPage); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 clearShouldBreakAtLineToAvoidWidow(); | 812 clearShouldBreakAtLineToAvoidWidow(); |
| 810 setDidBreakAtLineToAvoidWidow(); | 813 setDidBreakAtLineToAvoidWidow(); |
| 811 } | 814 } |
| 812 setPageBreak(logicalOffset, lineHeight - remainingLogicalHeight); | 815 setPageBreak(logicalOffset, lineHeight - remainingLogicalHeight); |
| 813 if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, rema
iningLogicalHeight)) { | 816 if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, rema
iningLogicalHeight)) { |
| 814 // Note that when setting the strut on a block, it may be propagated
to parent blocks | 817 // Note that when setting the strut on a block, it may be propagated
to parent blocks |
| 815 // later on, if a block's logical top is flush with that of its pare
nt. We don't want | 818 // later on, if a block's logical top is flush with that of its pare
nt. We don't want |
| 816 // content-less portions (struts) at the beginning of a block before
a break, if it can | 819 // content-less portions (struts) at the beginning of a block before
a break, if it can |
| 817 // be avoided. After all, that's the reason for setting struts on bl
ocks and not lines | 820 // be avoided. After all, that's the reason for setting struts on bl
ocks and not lines |
| 818 // in the first place. | 821 // in the first place. |
| 819 setPaginationStrut(remainingLogicalHeight + std::max<LayoutUnit>(0,
logicalOffset)); | 822 LayoutUnit paginationStrut = remainingLogicalHeight + std::max<Layou
tUnit>(0, logicalOffset); |
| 823 if (isFloating()) |
| 824 paginationStrut += marginBefore(); // Floats' margins do not col
lapse with page or column boundaries. |
| 825 setPaginationStrut(paginationStrut); |
| 820 } else { | 826 } else { |
| 821 delta += remainingLogicalHeight; | 827 delta += remainingLogicalHeight; |
| 822 lineBox.setPaginationStrut(remainingLogicalHeight); | 828 lineBox.setPaginationStrut(remainingLogicalHeight); |
| 823 lineBox.setIsFirstAfterPageBreak(true); | 829 lineBox.setIsFirstAfterPageBreak(true); |
| 824 } | 830 } |
| 825 } else if (remainingLogicalHeight == pageLogicalHeight) { | 831 } else if (remainingLogicalHeight == pageLogicalHeight) { |
| 826 // We're at the very top of a page or column. | 832 // We're at the very top of a page or column. |
| 827 if (lineBox != firstRootBox()) | 833 if (lineBox != firstRootBox()) |
| 828 lineBox.setIsFirstAfterPageBreak(true); | 834 lineBox.setIsFirstAfterPageBreak(true); |
| 829 if (lineBox != firstRootBox() || offsetFromLogicalTopOfFirstPage()) | 835 if (lineBox != firstRootBox() || offsetFromLogicalTopOfFirstPage()) |
| 830 setPageBreak(logicalOffset, lineHeight); | 836 setPageBreak(logicalOffset, lineHeight); |
| 831 } | 837 } |
| 832 } | 838 } |
| 833 | 839 |
| 834 LayoutUnit LayoutBlockFlow::adjustForUnsplittableChild(LayoutBox& child, LayoutU
nit logicalOffset, bool includeMargins) | 840 LayoutUnit LayoutBlockFlow::adjustForUnsplittableChild(LayoutBox& child, LayoutU
nit logicalOffset) |
| 835 { | 841 { |
| 836 bool checkColumnBreaks = flowThreadContainingBlock(); | 842 bool checkColumnBreaks = flowThreadContainingBlock(); |
| 837 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); | 843 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); |
| 838 bool isUnsplittable = child.isUnsplittableForPagination() || (checkColumnBre
aks && child.style()->columnBreakInside() == PBAVOID) | 844 bool isUnsplittable = child.isUnsplittableForPagination() || (checkColumnBre
aks && child.style()->columnBreakInside() == PBAVOID) |
| 839 || (checkPageBreaks && child.style()->pageBreakInside() == PBAVOID); | 845 || (checkPageBreaks && child.style()->pageBreakInside() == PBAVOID); |
| 840 if (!isUnsplittable) | 846 if (!isUnsplittable) |
| 841 return logicalOffset; | 847 return logicalOffset; |
| 842 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi
ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit()); | 848 LayoutUnit childLogicalHeight = logicalHeightForChild(child); |
| 849 // Floats' margins do not collapse with page or column boundaries. |
| 850 if (child.isFloating()) |
| 851 childLogicalHeight += marginBeforeForChild(child) + marginAfterForChild(
child); |
| 843 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); | 852 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); |
| 844 updateMinimumPageHeight(logicalOffset, childLogicalHeight); | 853 updateMinimumPageHeight(logicalOffset, childLogicalHeight); |
| 845 if (!pageLogicalHeight) | 854 if (!pageLogicalHeight) |
| 846 return logicalOffset; | 855 return logicalOffset; |
| 847 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, AssociateWithLatterPage); | 856 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, AssociateWithLatterPage); |
| 848 // Break if there's not enough space left for us, but only as long as we're
not already at the | 857 // Break if there's not enough space left for us, but only as long as we're
not already at the |
| 849 // top of a page. No point in leaving a page completely blank. | 858 // top of a page. No point in leaving a page completely blank. |
| 850 if (remainingLogicalHeight < childLogicalHeight && remainingLogicalHeight <
pageLogicalHeight) | 859 if (remainingLogicalHeight < childLogicalHeight && remainingLogicalHeight <
pageLogicalHeight) |
| 851 return logicalOffset + remainingLogicalHeight; | 860 return logicalOffset + remainingLogicalHeight; |
| 852 return logicalOffset; | 861 return logicalOffset; |
| (...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2392 | 2401 |
| 2393 SubtreeLayoutScope layoutScope(*childBox); | 2402 SubtreeLayoutScope layoutScope(*childBox); |
| 2394 LayoutState* layoutState = view()->layoutState(); | 2403 LayoutState* layoutState = view()->layoutState(); |
| 2395 bool isPaginated = layoutState->isPaginated(); | 2404 bool isPaginated = layoutState->isPaginated(); |
| 2396 if (isPaginated && !childBox->needsLayout()) | 2405 if (isPaginated && !childBox->needsLayout()) |
| 2397 childBox->markForPaginationRelayoutIfNeeded(layoutScope); | 2406 childBox->markForPaginationRelayoutIfNeeded(layoutScope); |
| 2398 | 2407 |
| 2399 childBox->layoutIfNeeded(); | 2408 childBox->layoutIfNeeded(); |
| 2400 | 2409 |
| 2401 if (isPaginated) { | 2410 if (isPaginated) { |
| 2402 // If we are unsplittable and don't fit, then we need to move down. | 2411 LayoutUnit newLogicalTop = floatLogicalLocation.y(); |
| 2403 // We include our margins as part of the unsplittable area. | |
| 2404 LayoutUnit newLogicalTop = adjustForUnsplittableChild(*childBox, flo
atLogicalLocation.y(), true); | |
| 2405 | 2412 |
| 2406 // See if we have a pagination strut that is making us move down fur
ther. | |
| 2407 // Note that an unsplittable child can't also have a pagination stru
t, so this is | |
| 2408 // exclusive with the case above. | |
| 2409 LayoutBlockFlow* childBlockFlow = childBox->isLayoutBlockFlow() ? to
LayoutBlockFlow(childBox) : 0; | 2413 LayoutBlockFlow* childBlockFlow = childBox->isLayoutBlockFlow() ? to
LayoutBlockFlow(childBox) : 0; |
| 2410 if (childBlockFlow && childBlockFlow->paginationStrut()) { | 2414 if (childBlockFlow && childBlockFlow->paginationStrut()) { |
| 2415 // Some content inside this float has determined that we need to
move to the next |
| 2416 // page or column. |
| 2411 newLogicalTop += childBlockFlow->paginationStrut(); | 2417 newLogicalTop += childBlockFlow->paginationStrut(); |
| 2412 childBlockFlow->setPaginationStrut(0); | 2418 childBlockFlow->setPaginationStrut(LayoutUnit()); |
| 2419 } else { |
| 2420 // Now that we know the final height, check if we are unsplittab
le, and if we don't |
| 2421 // fit at the current position, but would fit at the top of the
next page or |
| 2422 // column, move there. |
| 2423 newLogicalTop = adjustForUnsplittableChild(*childBox, newLogical
Top); |
| 2413 } | 2424 } |
| 2414 | 2425 |
| 2415 if (newLogicalTop != floatLogicalLocation.y()) { | 2426 if (newLogicalTop != floatLogicalLocation.y()) { |
| 2416 floatingObject.setPaginationStrut(newLogicalTop - floatLogicalLo
cation.y()); | 2427 floatingObject.setPaginationStrut(newLogicalTop - floatLogicalLo
cation.y()); |
| 2417 | 2428 |
| 2418 floatLogicalLocation = computeLogicalLocationForFloat(floatingOb
ject, newLogicalTop); | 2429 floatLogicalLocation = computeLogicalLocationForFloat(floatingOb
ject, newLogicalTop); |
| 2419 setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x())
; | 2430 setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x())
; |
| 2420 | 2431 |
| 2421 setLogicalLeftForChild(*childBox, floatLogicalLocation.x() + chi
ldLogicalLeftMargin); | 2432 setLogicalLeftForChild(*childBox, floatLogicalLocation.x() + chi
ldLogicalLeftMargin); |
| 2422 setLogicalTopForChild(*childBox, floatLogicalLocation.y() + marg
inBeforeForChild(*childBox)); | 2433 setLogicalTopForChild(*childBox, floatLogicalLocation.y() + marg
inBeforeForChild(*childBox)); |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3060 FrameView* frameView = document().view(); | 3071 FrameView* frameView = document().view(); |
| 3061 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 3072 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
| 3062 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 3073 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
| 3063 if (size().height() < visibleHeight) | 3074 if (size().height() < visibleHeight) |
| 3064 top += (visibleHeight - size().height()) / 2; | 3075 top += (visibleHeight - size().height()) / 2; |
| 3065 setY(top); | 3076 setY(top); |
| 3066 dialog->setCentered(top); | 3077 dialog->setCentered(top); |
| 3067 } | 3078 } |
| 3068 | 3079 |
| 3069 } // namespace blink | 3080 } // namespace blink |
| OLD | NEW |