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 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 setPaginationStrut(result + paginationStrut); | 699 setPaginationStrut(result + paginationStrut); |
700 if (childBlockFlow) | 700 if (childBlockFlow) |
701 childBlockFlow->setPaginationStrut(0); | 701 childBlockFlow->setPaginationStrut(0); |
702 } else { | 702 } else { |
703 result += paginationStrut; | 703 result += paginationStrut; |
704 } | 704 } |
705 } | 705 } |
706 | 706 |
707 if (!unsplittableAdjustmentDelta) { | 707 if (!unsplittableAdjustmentDelta) { |
708 if (LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(result)) { | 708 if (LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(result)) { |
709 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOff
set(result, ExcludePageBoundary); | 709 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOff
set(result, AssociateWithLatterPage); |
710 LayoutUnit spaceShortage = childLogicalHeight - remainingLogicalHeig
ht; | 710 LayoutUnit spaceShortage = childLogicalHeight - remainingLogicalHeig
ht; |
711 if (spaceShortage > 0) { | 711 if (spaceShortage > 0) { |
712 // If the child crosses a column boundary, report a break, in ca
se nothing inside it | 712 // If the child crosses a column boundary, report a break, in ca
se nothing inside it |
713 // has already done so. The column balancer needs to know how mu
ch it has to stretch | 713 // has already done so. The column balancer needs to know how mu
ch it has to stretch |
714 // the columns to make more content fit. If no breaks are report
ed (but do occur), | 714 // the columns to make more content fit. If no breaks are report
ed (but do occur), |
715 // the balancer will have no clue. Only measure the space after
the last column | 715 // the balancer will have no clue. Only measure the space after
the last column |
716 // boundary, in case it crosses more than one. | 716 // boundary, in case it crosses more than one. |
717 LayoutUnit spaceShortageInLastColumn = intMod(spaceShortage, pag
eLogicalHeight); | 717 LayoutUnit spaceShortageInLastColumn = intMod(spaceShortage, pag
eLogicalHeight); |
718 setPageBreak(result, spaceShortageInLastColumn ? spaceShortageIn
LastColumn : spaceShortage); | 718 setPageBreak(result, spaceShortageInLastColumn ? spaceShortageIn
LastColumn : spaceShortage); |
719 } else if (remainingLogicalHeight == pageLogicalHeight && offsetFrom
LogicalTopOfFirstPage() + child.logicalTop()) { | 719 } else if (remainingLogicalHeight == pageLogicalHeight && offsetFrom
LogicalTopOfFirstPage() + child.logicalTop()) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); | 790 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); |
791 if (!pageLogicalHeight) | 791 if (!pageLogicalHeight) |
792 return; | 792 return; |
793 if (lineHeight > pageLogicalHeight) { | 793 if (lineHeight > pageLogicalHeight) { |
794 // Too tall to fit in one page / column. Give up. Don't push to the next
page / column. | 794 // Too tall to fit in one page / column. Give up. Don't push to the next
page / column. |
795 // TODO(mstensho): Get rid of this. This is just utter weirdness, but th
e other browsers | 795 // TODO(mstensho): Get rid of this. This is just utter weirdness, but th
e other browsers |
796 // also do something slightly similar, although in much more specific ca
ses than we do here, | 796 // also do something slightly similar, although in much more specific ca
ses than we do here, |
797 // and printing Google Docs depends on it. | 797 // and printing Google Docs depends on it. |
798 return; | 798 return; |
799 } | 799 } |
800 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, ExcludePageBoundary); | 800 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, AssociateWithLatterPage); |
801 | 801 |
802 int lineIndex = lineCount(&lineBox); | 802 int lineIndex = lineCount(&lineBox); |
803 if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow()
&& lineBreakToAvoidWidow() == lineIndex)) { | 803 if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow()
&& lineBreakToAvoidWidow() == lineIndex)) { |
804 // We need to insert a break now, either because there's no room for the
line in the | 804 // We need to insert a break now, either because there's no room for the
line in the |
805 // current column / page, or because we have determined that we need a b
reak to satisfy | 805 // current column / page, or because we have determined that we need a b
reak to satisfy |
806 // widow requirements. | 806 // widow requirements. |
807 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn
dex) { | 807 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn
dex) { |
808 clearShouldBreakAtLineToAvoidWidow(); | 808 clearShouldBreakAtLineToAvoidWidow(); |
809 setDidBreakAtLineToAvoidWidow(); | 809 setDidBreakAtLineToAvoidWidow(); |
810 } | 810 } |
(...skipping 25 matching lines...) Expand all Loading... |
836 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); | 836 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); |
837 bool isUnsplittable = child.isUnsplittableForPagination() || (checkColumnBre
aks && child.style()->columnBreakInside() == PBAVOID) | 837 bool isUnsplittable = child.isUnsplittableForPagination() || (checkColumnBre
aks && child.style()->columnBreakInside() == PBAVOID) |
838 || (checkPageBreaks && child.style()->pageBreakInside() == PBAVOID); | 838 || (checkPageBreaks && child.style()->pageBreakInside() == PBAVOID); |
839 if (!isUnsplittable) | 839 if (!isUnsplittable) |
840 return logicalOffset; | 840 return logicalOffset; |
841 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi
ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit()); | 841 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi
ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit()); |
842 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); | 842 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); |
843 updateMinimumPageHeight(logicalOffset, childLogicalHeight); | 843 updateMinimumPageHeight(logicalOffset, childLogicalHeight); |
844 if (!pageLogicalHeight) | 844 if (!pageLogicalHeight) |
845 return logicalOffset; | 845 return logicalOffset; |
846 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, ExcludePageBoundary); | 846 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, AssociateWithLatterPage); |
847 if (remainingLogicalHeight < childLogicalHeight) | 847 if (remainingLogicalHeight < childLogicalHeight) |
848 return logicalOffset + remainingLogicalHeight; | 848 return logicalOffset + remainingLogicalHeight; |
849 return logicalOffset; | 849 return logicalOffset; |
850 } | 850 } |
851 | 851 |
852 void LayoutBlockFlow::rebuildFloatsFromIntruding() | 852 void LayoutBlockFlow::rebuildFloatsFromIntruding() |
853 { | 853 { |
854 if (m_floatingObjects) | 854 if (m_floatingObjects) |
855 m_floatingObjects->setHorizontalWritingMode(isHorizontalWritingMode()); | 855 m_floatingObjects->setHorizontalWritingMode(isHorizontalWritingMode()); |
856 | 856 |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 | 1267 |
1268 if (marginInfo.margin()) | 1268 if (marginInfo.margin()) |
1269 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(&child)); | 1269 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(&child)); |
1270 } | 1270 } |
1271 | 1271 |
1272 // If margins would pull us past the top of the next page, then we need to p
ull back and pretend like the margins | 1272 // If margins would pull us past the top of the next page, then we need to p
ull back and pretend like the margins |
1273 // collapsed into the page edge. | 1273 // collapsed into the page edge. |
1274 LayoutState* layoutState = view()->layoutState(); | 1274 LayoutState* layoutState = view()->layoutState(); |
1275 if (layoutState->isPaginated() && isPageLogicalHeightKnown(beforeCollapseLog
icalTop) && logicalTop > beforeCollapseLogicalTop) { | 1275 if (layoutState->isPaginated() && isPageLogicalHeightKnown(beforeCollapseLog
icalTop) && logicalTop > beforeCollapseLogicalTop) { |
1276 LayoutUnit oldLogicalTop = logicalTop; | 1276 LayoutUnit oldLogicalTop = logicalTop; |
1277 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic
alTop)); | 1277 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic
alTop, AssociateWithLatterPage)); |
1278 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); | 1278 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); |
1279 } | 1279 } |
1280 | 1280 |
1281 if (previousBlockFlow) { | 1281 if (previousBlockFlow) { |
1282 // If |child| is a self-collapsing block it may have collapsed into a pr
evious sibling and although it hasn't reduced the height of the parent yet | 1282 // If |child| is a self-collapsing block it may have collapsed into a pr
evious sibling and although it hasn't reduced the height of the parent yet |
1283 // any floats from the parent will now overhang. | 1283 // any floats from the parent will now overhang. |
1284 LayoutUnit oldLogicalHeight = logicalHeight(); | 1284 LayoutUnit oldLogicalHeight = logicalHeight(); |
1285 setLogicalHeight(logicalTop); | 1285 setLogicalHeight(logicalTop); |
1286 if (!previousBlockFlow->avoidsFloats() && (previousBlockFlow->logicalTop
() + previousBlockFlow->lowestFloatLogicalBottom()) > logicalTop) | 1286 if (!previousBlockFlow->avoidsFloats() && (previousBlockFlow->logicalTop
() + previousBlockFlow->lowestFloatLogicalBottom()) > logicalTop) |
1287 addOverhangingFloats(previousBlockFlow, false); | 1287 addOverhangingFloats(previousBlockFlow, false); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 | 1483 |
1484 // Collapse the result with our current margins. | 1484 // Collapse the result with our current margins. |
1485 if (!discardMarginBefore) | 1485 if (!discardMarginBefore) |
1486 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive
MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); | 1486 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive
MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); |
1487 } | 1487 } |
1488 | 1488 |
1489 // Adjust logicalTopEstimate down to the next page if the margins are so lar
ge that we don't fit on the current | 1489 // Adjust logicalTopEstimate down to the next page if the margins are so lar
ge that we don't fit on the current |
1490 // page. | 1490 // page. |
1491 LayoutState* layoutState = view()->layoutState(); | 1491 LayoutState* layoutState = view()->layoutState(); |
1492 if (layoutState->isPaginated() && isPageLogicalHeightKnown(logicalHeight())
&& logicalTopEstimate > logicalHeight()) | 1492 if (layoutState->isPaginated() && isPageLogicalHeightKnown(logicalHeight())
&& logicalTopEstimate > logicalHeight()) |
1493 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log
icalHeight())); | 1493 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log
icalHeight(), AssociateWithLatterPage)); |
1494 | 1494 |
1495 logicalTopEstimate += getClearDelta(&child, logicalTopEstimate); | 1495 logicalTopEstimate += getClearDelta(&child, logicalTopEstimate); |
1496 | 1496 |
1497 estimateWithoutPagination = logicalTopEstimate; | 1497 estimateWithoutPagination = logicalTopEstimate; |
1498 | 1498 |
1499 if (layoutState->isPaginated()) { | 1499 if (layoutState->isPaginated()) { |
1500 // If the object has a page or column break value of "before", then we s
hould shift to the top of the next page. | 1500 // If the object has a page or column break value of "before", then we s
hould shift to the top of the next page. |
1501 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate); | 1501 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate); |
1502 | 1502 |
1503 // For replaced elements and scrolled elements, we want to shift them to
the next page if they don't fit on the current one. | 1503 // For replaced elements and scrolled elements, we want to shift them to
the next page if they don't fit on the current one. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 bool checkColumnBreaks = flowThread; | 1684 bool checkColumnBreaks = flowThread; |
1685 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); // FIXME: Once columns can print we have to check this. | 1685 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); // FIXME: Once columns can print we have to check this. |
1686 bool checkBeforeAlways = (checkColumnBreaks && child.style()->columnBreakBef
ore() == PBALWAYS) | 1686 bool checkBeforeAlways = (checkColumnBreaks && child.style()->columnBreakBef
ore() == PBALWAYS) |
1687 || (checkPageBreaks && child.style()->pageBreakBefore() == PBALWAYS); | 1687 || (checkPageBreaks && child.style()->pageBreakBefore() == PBALWAYS); |
1688 if (checkBeforeAlways && inNormalFlow(&child)) { | 1688 if (checkBeforeAlways && inNormalFlow(&child)) { |
1689 if (checkColumnBreaks) { | 1689 if (checkColumnBreaks) { |
1690 LayoutUnit offsetBreakAdjustment = 0; | 1690 LayoutUnit offsetBreakAdjustment = 0; |
1691 if (flowThread->addForcedColumnBreak(offsetFromLogicalTopOfFirstPage
() + logicalOffset, &child, true, &offsetBreakAdjustment)) | 1691 if (flowThread->addForcedColumnBreak(offsetFromLogicalTopOfFirstPage
() + logicalOffset, &child, true, &offsetBreakAdjustment)) |
1692 return logicalOffset + offsetBreakAdjustment; | 1692 return logicalOffset + offsetBreakAdjustment; |
1693 } | 1693 } |
1694 return nextPageLogicalTop(logicalOffset, IncludePageBoundary); | 1694 return nextPageLogicalTop(logicalOffset, AssociateWithFormerPage); |
1695 } | 1695 } |
1696 return logicalOffset; | 1696 return logicalOffset; |
1697 } | 1697 } |
1698 | 1698 |
1699 LayoutUnit LayoutBlockFlow::applyAfterBreak(LayoutBox& child, LayoutUnit logical
Offset, MarginInfo& marginInfo) | 1699 LayoutUnit LayoutBlockFlow::applyAfterBreak(LayoutBox& child, LayoutUnit logical
Offset, MarginInfo& marginInfo) |
1700 { | 1700 { |
1701 // FIXME: Add page break checking here when we support printing. | 1701 // FIXME: Add page break checking here when we support printing. |
1702 LayoutFlowThread* flowThread = flowThreadContainingBlock(); | 1702 LayoutFlowThread* flowThread = flowThreadContainingBlock(); |
1703 bool checkColumnBreaks = flowThread; | 1703 bool checkColumnBreaks = flowThread; |
1704 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); // FIXME: Once columns can print we have to check this. | 1704 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); // FIXME: Once columns can print we have to check this. |
1705 bool checkAfterAlways = (checkColumnBreaks && child.style()->columnBreakAfte
r() == PBALWAYS) | 1705 bool checkAfterAlways = (checkColumnBreaks && child.style()->columnBreakAfte
r() == PBALWAYS) |
1706 || (checkPageBreaks && child.style()->pageBreakAfter() == PBALWAYS); | 1706 || (checkPageBreaks && child.style()->pageBreakAfter() == PBALWAYS); |
1707 if (checkAfterAlways && inNormalFlow(&child)) { | 1707 if (checkAfterAlways && inNormalFlow(&child)) { |
1708 // So our margin doesn't participate in the next collapsing steps. | 1708 // So our margin doesn't participate in the next collapsing steps. |
1709 marginInfo.clearMargin(); | 1709 marginInfo.clearMargin(); |
1710 | 1710 |
1711 if (checkColumnBreaks) { | 1711 if (checkColumnBreaks) { |
1712 LayoutUnit offsetBreakAdjustment = 0; | 1712 LayoutUnit offsetBreakAdjustment = 0; |
1713 if (flowThread->addForcedColumnBreak(offsetFromLogicalTopOfFirstPage
() + logicalOffset, &child, false, &offsetBreakAdjustment)) | 1713 if (flowThread->addForcedColumnBreak(offsetFromLogicalTopOfFirstPage
() + logicalOffset, &child, false, &offsetBreakAdjustment)) |
1714 return logicalOffset + offsetBreakAdjustment; | 1714 return logicalOffset + offsetBreakAdjustment; |
1715 } | 1715 } |
1716 return nextPageLogicalTop(logicalOffset, IncludePageBoundary); | 1716 return nextPageLogicalTop(logicalOffset, AssociateWithFormerPage); |
1717 } | 1717 } |
1718 return logicalOffset; | 1718 return logicalOffset; |
1719 } | 1719 } |
1720 | 1720 |
1721 void LayoutBlockFlow::addOverflowFromFloats() | 1721 void LayoutBlockFlow::addOverflowFromFloats() |
1722 { | 1722 { |
1723 if (!m_floatingObjects) | 1723 if (!m_floatingObjects) |
1724 return; | 1724 return; |
1725 | 1725 |
1726 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 1726 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3055 FrameView* frameView = document().view(); | 3055 FrameView* frameView = document().view(); |
3056 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 3056 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
3057 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 3057 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
3058 if (size().height() < visibleHeight) | 3058 if (size().height() < visibleHeight) |
3059 top += (visibleHeight - size().height()) / 2; | 3059 top += (visibleHeight - size().height()) / 2; |
3060 setY(top); | 3060 setY(top); |
3061 dialog->setCentered(top); | 3061 dialog->setCentered(top); |
3062 } | 3062 } |
3063 | 3063 |
3064 } // namespace blink | 3064 } // namespace blink |
OLD | NEW |