| 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 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1702 | 1702 |
| 1703 if (marginInfo.quirkContainer() && marginInfo.atBeforeSideOfBlock() && | 1703 if (marginInfo.quirkContainer() && marginInfo.atBeforeSideOfBlock() && |
| 1704 (posTop - negTop)) | 1704 (posTop - negTop)) |
| 1705 marginInfo.setHasMarginBeforeQuirk(topQuirk); | 1705 marginInfo.setHasMarginBeforeQuirk(topQuirk); |
| 1706 | 1706 |
| 1707 LayoutUnit beforeCollapseLogicalTop = logicalHeight(); | 1707 LayoutUnit beforeCollapseLogicalTop = logicalHeight(); |
| 1708 LayoutUnit logicalTop = beforeCollapseLogicalTop; | 1708 LayoutUnit logicalTop = beforeCollapseLogicalTop; |
| 1709 | 1709 |
| 1710 LayoutObject* prev = child.previousSibling(); | 1710 LayoutObject* prev = child.previousSibling(); |
| 1711 LayoutBlockFlow* previousBlockFlow = | 1711 LayoutBlockFlow* previousBlockFlow = |
| 1712 prev && prev->isLayoutBlockFlow() && | 1712 prev && prev->isLayoutBlockFlow() ? toLayoutBlockFlow(prev) : nullptr; |
| 1713 !prev->isFloatingOrOutOfFlowPositioned() | 1713 bool previousBlockFlowCanSelfCollapse = |
| 1714 ? toLayoutBlockFlow(prev) | 1714 previousBlockFlow && |
| 1715 : 0; | 1715 !previousBlockFlow->isFloatingOrOutOfFlowPositioned(); |
| 1716 // If the child's previous sibling is a self-collapsing block that cleared a | 1716 // If the child's previous sibling is a self-collapsing block that cleared a |
| 1717 // float then its top border edge has been set at the bottom border edge of | 1717 // float then its top border edge has been set at the bottom border edge of |
| 1718 // the float. Since we want to collapse the child's top margin with the self- | 1718 // the float. Since we want to collapse the child's top margin with the self- |
| 1719 // collapsing block's top and bottom margins we need to adjust our parent's | 1719 // collapsing block's top and bottom margins we need to adjust our parent's |
| 1720 // height to match the margin top of the self-collapsing block. If the | 1720 // height to match the margin top of the self-collapsing block. If the |
| 1721 // resulting collapsed margin leaves the child still intruding into the float | 1721 // resulting collapsed margin leaves the child still intruding into the float |
| 1722 // then we will want to clear it. | 1722 // then we will want to clear it. |
| 1723 if (!marginInfo.canCollapseWithMarginBefore() && previousBlockFlow && | 1723 if (!marginInfo.canCollapseWithMarginBefore() && |
| 1724 previousBlockFlowCanSelfCollapse && |
| 1724 marginInfo.lastChildIsSelfCollapsingBlockWithClearance()) | 1725 marginInfo.lastChildIsSelfCollapsingBlockWithClearance()) |
| 1725 setLogicalHeight( | 1726 setLogicalHeight( |
| 1726 logicalHeight() - | 1727 logicalHeight() - |
| 1727 marginValuesForChild(*previousBlockFlow).positiveMarginBefore()); | 1728 marginValuesForChild(*previousBlockFlow).positiveMarginBefore()); |
| 1728 | 1729 |
| 1729 if (childIsSelfCollapsing) { | 1730 if (childIsSelfCollapsing) { |
| 1730 // For a self collapsing block both the before and after margins get | 1731 // For a self collapsing block both the before and after margins get |
| 1731 // discarded. The block doesn't contribute anything to the height of the | 1732 // discarded. The block doesn't contribute anything to the height of the |
| 1732 // block. Also, the child's top position equals the logical height of the | 1733 // block. Also, the child's top position equals the logical height of the |
| 1733 // container. | 1734 // container. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 } | 1795 } |
| 1795 | 1796 |
| 1796 if (view()->layoutState()->isPaginated() && isPageLogicalHeightKnown()) { | 1797 if (view()->layoutState()->isPaginated() && isPageLogicalHeightKnown()) { |
| 1797 LayoutUnit oldLogicalTop = logicalTop; | 1798 LayoutUnit oldLogicalTop = logicalTop; |
| 1798 LayoutUnit margin = adjustedMarginBeforeForPagination( | 1799 LayoutUnit margin = adjustedMarginBeforeForPagination( |
| 1799 child, beforeCollapseLogicalTop, logicalTop, layoutInfo); | 1800 child, beforeCollapseLogicalTop, logicalTop, layoutInfo); |
| 1800 logicalTop = beforeCollapseLogicalTop + margin; | 1801 logicalTop = beforeCollapseLogicalTop + margin; |
| 1801 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); | 1802 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); |
| 1802 } | 1803 } |
| 1803 | 1804 |
| 1804 if (previousBlockFlow) { | 1805 // If |child| has moved up into previous siblings it needs to avoid or clear |
| 1805 // If |child| is a self-collapsing block it may have collapsed into a | 1806 // any floats they contain. |
| 1806 // previous sibling and although it hasn't reduced the height of the parent | 1807 if (logicalTop < beforeCollapseLogicalTop) { |
| 1807 // yet any floats from the parent will now overhang. | |
| 1808 LayoutUnit oldLogicalHeight = logicalHeight(); | 1808 LayoutUnit oldLogicalHeight = logicalHeight(); |
| 1809 setLogicalHeight(logicalTop); | 1809 setLogicalHeight(logicalTop); |
| 1810 if (!previousBlockFlow->avoidsFloats() && | 1810 while (previousBlockFlow) { |
| 1811 (previousBlockFlow->logicalTop() + | 1811 auto lowestFloat = previousBlockFlow->logicalTop() + |
| 1812 previousBlockFlow->lowestFloatLogicalBottom()) > logicalTop) | 1812 previousBlockFlow->lowestFloatLogicalBottom(); |
| 1813 addOverhangingFloats(previousBlockFlow, false); | 1813 if (lowestFloat > logicalTop) |
| 1814 addOverhangingFloats(previousBlockFlow, false); |
| 1815 else |
| 1816 break; |
| 1817 LayoutObject* prev = previousBlockFlow->previousSibling(); |
| 1818 if (prev && prev->isLayoutBlockFlow()) |
| 1819 previousBlockFlow = toLayoutBlockFlow(prev); |
| 1820 else |
| 1821 previousBlockFlow = nullptr; |
| 1822 } |
| 1814 setLogicalHeight(oldLogicalHeight); | 1823 setLogicalHeight(oldLogicalHeight); |
| 1824 } |
| 1815 | 1825 |
| 1826 if (previousBlockFlowCanSelfCollapse) { |
| 1816 // If |child|'s previous sibling is or contains a self-collapsing block that | 1827 // If |child|'s previous sibling is or contains a self-collapsing block that |
| 1817 // cleared a float and margin collapsing resulted in |child| moving up | 1828 // cleared a float and margin collapsing resulted in |child| moving up |
| 1818 // into the margin area of the self-collapsing block then the float it | 1829 // into the margin area of the self-collapsing block then the float it |
| 1819 // clears is now intruding into |child|. Layout again so that we can look | 1830 // clears is now intruding into |child|. Layout again so that we can look |
| 1820 // for floats in the parent that overhang |child|'s new logical top. | 1831 // for floats in the parent that overhang |child|'s new logical top. |
| 1821 bool logicalTopIntrudesIntoFloat = logicalTop < beforeCollapseLogicalTop; | 1832 bool logicalTopIntrudesIntoFloat = logicalTop < beforeCollapseLogicalTop; |
| 1822 if (logicalTopIntrudesIntoFloat && containsFloats() && | 1833 if (logicalTopIntrudesIntoFloat && containsFloats() && |
| 1823 !child.avoidsFloats() && lowestFloatLogicalBottom() > logicalTop) | 1834 !child.avoidsFloats() && lowestFloatLogicalBottom() > logicalTop) |
| 1824 child.setNeedsLayoutAndFullPaintInvalidation( | 1835 child.setNeedsLayoutAndFullPaintInvalidation( |
| 1825 LayoutInvalidationReason::AncestorMarginCollapsing); | 1836 LayoutInvalidationReason::AncestorMarginCollapsing); |
| (...skipping 2744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4570 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); | 4581 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); |
| 4571 } | 4582 } |
| 4572 | 4583 |
| 4573 void LayoutBlockFlow::invalidateDisplayItemClients( | 4584 void LayoutBlockFlow::invalidateDisplayItemClients( |
| 4574 PaintInvalidationReason invalidationReason) const { | 4585 PaintInvalidationReason invalidationReason) const { |
| 4575 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( | 4586 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( |
| 4576 invalidationReason); | 4587 invalidationReason); |
| 4577 } | 4588 } |
| 4578 | 4589 |
| 4579 } // namespace blink | 4590 } // namespace blink |
| OLD | NEW |