| 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 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 | 1445 |
| 1446 if (marginInfo.margin()) | 1446 if (marginInfo.margin()) |
| 1447 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(&child)); | 1447 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(&child)); |
| 1448 } | 1448 } |
| 1449 | 1449 |
| 1450 // If margins would pull us past the top of the next page, then we need to p
ull back and pretend like the margins | 1450 // If margins would pull us past the top of the next page, then we need to p
ull back and pretend like the margins |
| 1451 // collapsed into the page edge. | 1451 // collapsed into the page edge. |
| 1452 LayoutState* layoutState = view()->layoutState(); | 1452 LayoutState* layoutState = view()->layoutState(); |
| 1453 if (layoutState->isPaginated() && isPageLogicalHeightKnown(beforeCollapseLog
icalTop) && logicalTop > beforeCollapseLogicalTop) { | 1453 if (layoutState->isPaginated() && isPageLogicalHeightKnown(beforeCollapseLog
icalTop) && logicalTop > beforeCollapseLogicalTop) { |
| 1454 LayoutUnit oldLogicalTop = logicalTop; | 1454 LayoutUnit oldLogicalTop = logicalTop; |
| 1455 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic
alTop, AssociateWithLatterPage)); | 1455 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic
alTop)); |
| 1456 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); | 1456 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); |
| 1457 } | 1457 } |
| 1458 | 1458 |
| 1459 if (previousBlockFlow) { | 1459 if (previousBlockFlow) { |
| 1460 // 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 | 1460 // 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 |
| 1461 // any floats from the parent will now overhang. | 1461 // any floats from the parent will now overhang. |
| 1462 LayoutUnit oldLogicalHeight = logicalHeight(); | 1462 LayoutUnit oldLogicalHeight = logicalHeight(); |
| 1463 setLogicalHeight(logicalTop); | 1463 setLogicalHeight(logicalTop); |
| 1464 if (!previousBlockFlow->avoidsFloats() && (previousBlockFlow->logicalTop
() + previousBlockFlow->lowestFloatLogicalBottom()) > logicalTop) | 1464 if (!previousBlockFlow->avoidsFloats() && (previousBlockFlow->logicalTop
() + previousBlockFlow->lowestFloatLogicalBottom()) > logicalTop) |
| 1465 addOverhangingFloats(previousBlockFlow, false); | 1465 addOverhangingFloats(previousBlockFlow, false); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1670 | 1670 |
| 1671 // Collapse the result with our current margins. | 1671 // Collapse the result with our current margins. |
| 1672 if (!discardMarginBefore) | 1672 if (!discardMarginBefore) |
| 1673 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive
MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); | 1673 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive
MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); |
| 1674 } | 1674 } |
| 1675 | 1675 |
| 1676 // Adjust logicalTopEstimate down to the next page if the margins are so lar
ge that we don't fit on the current | 1676 // Adjust logicalTopEstimate down to the next page if the margins are so lar
ge that we don't fit on the current |
| 1677 // page. | 1677 // page. |
| 1678 LayoutState* layoutState = view()->layoutState(); | 1678 LayoutState* layoutState = view()->layoutState(); |
| 1679 if (layoutState->isPaginated() && isPageLogicalHeightKnown(logicalHeight())
&& logicalTopEstimate > logicalHeight()) | 1679 if (layoutState->isPaginated() && isPageLogicalHeightKnown(logicalHeight())
&& logicalTopEstimate > logicalHeight()) |
| 1680 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log
icalHeight(), AssociateWithLatterPage)); | 1680 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log
icalHeight())); |
| 1681 | 1681 |
| 1682 logicalTopEstimate += getClearDelta(&child, logicalTopEstimate); | 1682 logicalTopEstimate += getClearDelta(&child, logicalTopEstimate); |
| 1683 | 1683 |
| 1684 estimateWithoutPagination = logicalTopEstimate; | 1684 estimateWithoutPagination = logicalTopEstimate; |
| 1685 | 1685 |
| 1686 if (layoutState->isPaginated()) { | 1686 if (layoutState->isPaginated()) { |
| 1687 if (!layoutInfo.isAtFirstInFlowChild()) { | 1687 if (!layoutInfo.isAtFirstInFlowChild()) { |
| 1688 // Estimate the need for a forced break in front of this child. The
final break policy | 1688 // Estimate the need for a forced break in front of this child. The
final break policy |
| 1689 // at this class A break point isn't known until we have laid out th
e children of | 1689 // at this class A break point isn't known until we have laid out th
e children of |
| 1690 // |child|. There may be forced break-before values set on first-chi
ldren inside that | 1690 // |child|. There may be forced break-before values set on first-chi
ldren inside that |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1880 return childStyle.marginAfterCollapse() == MarginCollapseSeparate; | 1880 return childStyle.marginAfterCollapse() == MarginCollapseSeparate; |
| 1881 if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) | 1881 if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) |
| 1882 return childStyle.marginBeforeCollapse() == MarginCollapseSeparate; | 1882 return childStyle.marginBeforeCollapse() == MarginCollapseSeparate; |
| 1883 | 1883 |
| 1884 // FIXME: See |mustDiscardMarginBeforeForChild| above. | 1884 // FIXME: See |mustDiscardMarginBeforeForChild| above. |
| 1885 return false; | 1885 return false; |
| 1886 } | 1886 } |
| 1887 | 1887 |
| 1888 LayoutUnit LayoutBlockFlow::applyForcedBreak(LayoutUnit logicalOffset, EBreak br
eakValue) | 1888 LayoutUnit LayoutBlockFlow::applyForcedBreak(LayoutUnit logicalOffset, EBreak br
eakValue) |
| 1889 { | 1889 { |
| 1890 if (!isForcedFragmentainerBreakValue(breakValue)) |
| 1891 return logicalOffset; |
| 1890 // TODO(mstensho): honor breakValue. There are different types of forced bre
aks. We currently | 1892 // TODO(mstensho): honor breakValue. There are different types of forced bre
aks. We currently |
| 1891 // just assume that we want to break to the top of the next fragmentainer of
the fragmentation | 1893 // just assume that we want to break to the top of the next fragmentainer of
the fragmentation |
| 1892 // context we're in. However, we may want to find the next left or right pag
e - even if we're | 1894 // context we're in. However, we may want to find the next left or right pag
e - even if we're |
| 1893 // inside a multicol container when printing. | 1895 // inside a multicol container when printing. |
| 1894 if (isForcedFragmentainerBreakValue(breakValue)) | 1896 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); |
| 1895 return nextPageLogicalTop(logicalOffset, AssociateWithFormerPage); | 1897 if (!pageLogicalHeight) |
| 1896 return logicalOffset; | 1898 return logicalOffset; // Page height is still unknown, so we cannot inse
rt forced breaks. |
| 1899 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, AssociateWithLatterPage); |
| 1900 if (remainingLogicalHeight == pageLogicalHeight) |
| 1901 return logicalOffset; // Don't break if we're already at the block start
of a fragmentainer. |
| 1902 return logicalOffset + remainingLogicalHeight; |
| 1897 } | 1903 } |
| 1898 | 1904 |
| 1899 void LayoutBlockFlow::setBreakBefore(EBreak breakValue) | 1905 void LayoutBlockFlow::setBreakBefore(EBreak breakValue) |
| 1900 { | 1906 { |
| 1901 if (breakValue != BreakAuto && !isBreakBetweenControllable(breakValue)) | 1907 if (breakValue != BreakAuto && !isBreakBetweenControllable(breakValue)) |
| 1902 breakValue = BreakAuto; | 1908 breakValue = BreakAuto; |
| 1903 if (breakValue == BreakAuto && !m_rareData) | 1909 if (breakValue == BreakAuto && !m_rareData) |
| 1904 return; | 1910 return; |
| 1905 ensureRareData().m_breakBefore = breakValue; | 1911 ensureRareData().m_breakBefore = breakValue; |
| 1906 } | 1912 } |
| (...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3760 | 3766 |
| 3761 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); | 3767 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); |
| 3762 } | 3768 } |
| 3763 | 3769 |
| 3764 void LayoutBlockFlow::invalidateDisplayItemClients(PaintInvalidationReason inval
idationReason) const | 3770 void LayoutBlockFlow::invalidateDisplayItemClients(PaintInvalidationReason inval
idationReason) const |
| 3765 { | 3771 { |
| 3766 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients(invalidationRe
ason); | 3772 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients(invalidationRe
ason); |
| 3767 } | 3773 } |
| 3768 | 3774 |
| 3769 } // namespace blink | 3775 } // namespace blink |
| OLD | NEW |