| 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 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 | 1714 |
| 1715 if (marginInfo.quirkContainer() && marginInfo.atBeforeSideOfBlock() && | 1715 if (marginInfo.quirkContainer() && marginInfo.atBeforeSideOfBlock() && |
| 1716 (posTop - negTop)) | 1716 (posTop - negTop)) |
| 1717 marginInfo.setHasMarginBeforeQuirk(topQuirk); | 1717 marginInfo.setHasMarginBeforeQuirk(topQuirk); |
| 1718 | 1718 |
| 1719 LayoutUnit beforeCollapseLogicalTop = logicalHeight(); | 1719 LayoutUnit beforeCollapseLogicalTop = logicalHeight(); |
| 1720 LayoutUnit logicalTop = beforeCollapseLogicalTop; | 1720 LayoutUnit logicalTop = beforeCollapseLogicalTop; |
| 1721 | 1721 |
| 1722 LayoutObject* prev = child.previousSibling(); | 1722 LayoutObject* prev = child.previousSibling(); |
| 1723 LayoutBlockFlow* previousBlockFlow = | 1723 LayoutBlockFlow* previousBlockFlow = |
| 1724 prev && prev->isLayoutBlockFlow() && | 1724 prev && prev->isLayoutBlockFlow() ? toLayoutBlockFlow(prev) : nullptr; |
| 1725 !prev->isFloatingOrOutOfFlowPositioned() | 1725 bool previousBlockFlowCanSelfCollapse = |
| 1726 ? toLayoutBlockFlow(prev) | 1726 previousBlockFlow && |
| 1727 : 0; | 1727 !previousBlockFlow->isFloatingOrOutOfFlowPositioned(); |
| 1728 // If the child's previous sibling is a self-collapsing block that cleared a | 1728 // If the child's previous sibling is a self-collapsing block that cleared a |
| 1729 // float then its top border edge has been set at the bottom border edge of | 1729 // float then its top border edge has been set at the bottom border edge of |
| 1730 // the float. Since we want to collapse the child's top margin with the self- | 1730 // the float. Since we want to collapse the child's top margin with the self- |
| 1731 // collapsing block's top and bottom margins we need to adjust our parent's | 1731 // collapsing block's top and bottom margins we need to adjust our parent's |
| 1732 // height to match the margin top of the self-collapsing block. If the | 1732 // height to match the margin top of the self-collapsing block. If the |
| 1733 // resulting collapsed margin leaves the child still intruding into the float | 1733 // resulting collapsed margin leaves the child still intruding into the float |
| 1734 // then we will want to clear it. | 1734 // then we will want to clear it. |
| 1735 if (!marginInfo.canCollapseWithMarginBefore() && previousBlockFlow && | 1735 if (!marginInfo.canCollapseWithMarginBefore() && |
| 1736 previousBlockFlowCanSelfCollapse && |
| 1736 marginInfo.lastChildIsSelfCollapsingBlockWithClearance()) | 1737 marginInfo.lastChildIsSelfCollapsingBlockWithClearance()) |
| 1737 setLogicalHeight( | 1738 setLogicalHeight( |
| 1738 logicalHeight() - | 1739 logicalHeight() - |
| 1739 marginValuesForChild(*previousBlockFlow).positiveMarginBefore()); | 1740 marginValuesForChild(*previousBlockFlow).positiveMarginBefore()); |
| 1740 | 1741 |
| 1741 if (childIsSelfCollapsing) { | 1742 if (childIsSelfCollapsing) { |
| 1742 // For a self collapsing block both the before and after margins get | 1743 // For a self collapsing block both the before and after margins get |
| 1743 // discarded. The block doesn't contribute anything to the height of the | 1744 // discarded. The block doesn't contribute anything to the height of the |
| 1744 // block. Also, the child's top position equals the logical height of the | 1745 // block. Also, the child's top position equals the logical height of the |
| 1745 // container. | 1746 // container. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1809 // pull back and pretend like the margins collapsed into the page edge. | 1810 // pull back and pretend like the margins collapsed into the page edge. |
| 1810 LayoutState* layoutState = view()->layoutState(); | 1811 LayoutState* layoutState = view()->layoutState(); |
| 1811 if (layoutState->isPaginated() && isPageLogicalHeightKnown() && | 1812 if (layoutState->isPaginated() && isPageLogicalHeightKnown() && |
| 1812 logicalTop > beforeCollapseLogicalTop) { | 1813 logicalTop > beforeCollapseLogicalTop) { |
| 1813 LayoutUnit oldLogicalTop = logicalTop; | 1814 LayoutUnit oldLogicalTop = logicalTop; |
| 1814 logicalTop = | 1815 logicalTop = |
| 1815 std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogicalTop)); | 1816 std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogicalTop)); |
| 1816 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); | 1817 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); |
| 1817 } | 1818 } |
| 1818 | 1819 |
| 1819 if (previousBlockFlow) { | 1820 // If |child| has moved up into previous siblings it needs to avoid or clear |
| 1820 // If |child| is a self-collapsing block it may have collapsed into a | 1821 // any floats they contain. |
| 1821 // previous sibling and although it hasn't reduced the height of the parent | 1822 LayoutUnit oldLogicalHeight = logicalHeight(); |
| 1822 // yet any floats from the parent will now overhang. | 1823 setLogicalHeight(logicalTop); |
| 1823 LayoutUnit oldLogicalHeight = logicalHeight(); | 1824 while (previousBlockFlow) { |
| 1824 setLogicalHeight(logicalTop); | 1825 auto lowestFloat = previousBlockFlow->logicalTop() + |
| 1825 if (!previousBlockFlow->avoidsFloats() && | 1826 previousBlockFlow->lowestFloatLogicalBottom(); |
| 1826 (previousBlockFlow->logicalTop() + | 1827 if (lowestFloat > logicalTop) |
| 1827 previousBlockFlow->lowestFloatLogicalBottom()) > logicalTop) | |
| 1828 addOverhangingFloats(previousBlockFlow, false); | 1828 addOverhangingFloats(previousBlockFlow, false); |
| 1829 setLogicalHeight(oldLogicalHeight); | 1829 LayoutObject* prev = previousBlockFlow->previousSibling(); |
| 1830 if (prev && prev->isLayoutBlockFlow()) |
| 1831 previousBlockFlow = toLayoutBlockFlow(prev); |
| 1832 else |
| 1833 previousBlockFlow = nullptr; |
| 1834 } |
| 1835 setLogicalHeight(oldLogicalHeight); |
| 1830 | 1836 |
| 1837 if (previousBlockFlowCanSelfCollapse) { |
| 1831 // If |child|'s previous sibling is or contains a self-collapsing block that | 1838 // If |child|'s previous sibling is or contains a self-collapsing block that |
| 1832 // cleared a float and margin collapsing resulted in |child| moving up | 1839 // cleared a float and margin collapsing resulted in |child| moving up |
| 1833 // into the margin area of the self-collapsing block then the float it | 1840 // into the margin area of the self-collapsing block then the float it |
| 1834 // clears is now intruding into |child|. Layout again so that we can look | 1841 // clears is now intruding into |child|. Layout again so that we can look |
| 1835 // for floats in the parent that overhang |child|'s new logical top. | 1842 // for floats in the parent that overhang |child|'s new logical top. |
| 1836 bool logicalTopIntrudesIntoFloat = logicalTop < beforeCollapseLogicalTop; | 1843 bool logicalTopIntrudesIntoFloat = logicalTop < beforeCollapseLogicalTop; |
| 1837 if (logicalTopIntrudesIntoFloat && containsFloats() && | 1844 if (logicalTopIntrudesIntoFloat && containsFloats() && |
| 1838 !child.avoidsFloats() && lowestFloatLogicalBottom() > logicalTop) | 1845 !child.avoidsFloats() && lowestFloatLogicalBottom() > logicalTop) |
| 1839 child.setNeedsLayoutAndFullPaintInvalidation( | 1846 child.setNeedsLayoutAndFullPaintInvalidation( |
| 1840 LayoutInvalidationReason::AncestorMarginCollapsing); | 1847 LayoutInvalidationReason::AncestorMarginCollapsing); |
| (...skipping 2697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4538 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); | 4545 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); |
| 4539 } | 4546 } |
| 4540 | 4547 |
| 4541 void LayoutBlockFlow::invalidateDisplayItemClients( | 4548 void LayoutBlockFlow::invalidateDisplayItemClients( |
| 4542 PaintInvalidationReason invalidationReason) const { | 4549 PaintInvalidationReason invalidationReason) const { |
| 4543 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( | 4550 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( |
| 4544 invalidationReason); | 4551 invalidationReason); |
| 4545 } | 4552 } |
| 4546 | 4553 |
| 4547 } // namespace blink | 4554 } // namespace blink |
| OLD | NEW |