Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp

Issue 2556373002: Revert: Detect floats to avoid or clear due to negative margin top (and followup) (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/block/float/avoid-floats-when-negative-margin-top-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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() ? toLayoutBlockFlow(prev) : nullptr; 1712 prev && prev->isLayoutBlockFlow() &&
1713 bool previousBlockFlowCanSelfCollapse = 1713 !prev->isFloatingOrOutOfFlowPositioned()
1714 previousBlockFlow && 1714 ? toLayoutBlockFlow(prev)
1715 !previousBlockFlow->isFloatingOrOutOfFlowPositioned(); 1715 : 0;
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() && 1723 if (!marginInfo.canCollapseWithMarginBefore() && previousBlockFlow &&
1724 previousBlockFlowCanSelfCollapse &&
1725 marginInfo.lastChildIsSelfCollapsingBlockWithClearance()) 1724 marginInfo.lastChildIsSelfCollapsingBlockWithClearance())
1726 setLogicalHeight( 1725 setLogicalHeight(
1727 logicalHeight() - 1726 logicalHeight() -
1728 marginValuesForChild(*previousBlockFlow).positiveMarginBefore()); 1727 marginValuesForChild(*previousBlockFlow).positiveMarginBefore());
1729 1728
1730 if (childIsSelfCollapsing) { 1729 if (childIsSelfCollapsing) {
1731 // For a self collapsing block both the before and after margins get 1730 // For a self collapsing block both the before and after margins get
1732 // discarded. The block doesn't contribute anything to the height of the 1731 // discarded. The block doesn't contribute anything to the height of the
1733 // block. Also, the child's top position equals the logical height of the 1732 // block. Also, the child's top position equals the logical height of the
1734 // container. 1733 // container.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 } 1794 }
1796 1795
1797 if (view()->layoutState()->isPaginated() && isPageLogicalHeightKnown()) { 1796 if (view()->layoutState()->isPaginated() && isPageLogicalHeightKnown()) {
1798 LayoutUnit oldLogicalTop = logicalTop; 1797 LayoutUnit oldLogicalTop = logicalTop;
1799 LayoutUnit margin = adjustedMarginBeforeForPagination( 1798 LayoutUnit margin = adjustedMarginBeforeForPagination(
1800 child, beforeCollapseLogicalTop, logicalTop, layoutInfo); 1799 child, beforeCollapseLogicalTop, logicalTop, layoutInfo);
1801 logicalTop = beforeCollapseLogicalTop + margin; 1800 logicalTop = beforeCollapseLogicalTop + margin;
1802 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); 1801 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop));
1803 } 1802 }
1804 1803
1805 // If |child| has moved up into previous siblings it needs to avoid or clear 1804 if (previousBlockFlow) {
1806 // any floats they contain. 1805 // If |child| is a self-collapsing block it may have collapsed into a
1807 LayoutUnit oldLogicalHeight = logicalHeight(); 1806 // previous sibling and although it hasn't reduced the height of the parent
1808 setLogicalHeight(logicalTop); 1807 // yet any floats from the parent will now overhang.
1809 while (previousBlockFlow) { 1808 LayoutUnit oldLogicalHeight = logicalHeight();
1810 auto lowestFloat = previousBlockFlow->logicalTop() + 1809 setLogicalHeight(logicalTop);
1811 previousBlockFlow->lowestFloatLogicalBottom(); 1810 if (!previousBlockFlow->avoidsFloats() &&
1812 if (lowestFloat > logicalTop) 1811 (previousBlockFlow->logicalTop() +
1812 previousBlockFlow->lowestFloatLogicalBottom()) > logicalTop)
1813 addOverhangingFloats(previousBlockFlow, false); 1813 addOverhangingFloats(previousBlockFlow, false);
1814 else 1814 setLogicalHeight(oldLogicalHeight);
1815 break;
1816 LayoutObject* prev = previousBlockFlow->previousSibling();
1817 if (prev && prev->isLayoutBlockFlow())
1818 previousBlockFlow = toLayoutBlockFlow(prev);
1819 else
1820 previousBlockFlow = nullptr;
1821 }
1822 setLogicalHeight(oldLogicalHeight);
1823 1815
1824 if (previousBlockFlowCanSelfCollapse) {
1825 // If |child|'s previous sibling is or contains a self-collapsing block that 1816 // If |child|'s previous sibling is or contains a self-collapsing block that
1826 // cleared a float and margin collapsing resulted in |child| moving up 1817 // cleared a float and margin collapsing resulted in |child| moving up
1827 // into the margin area of the self-collapsing block then the float it 1818 // into the margin area of the self-collapsing block then the float it
1828 // clears is now intruding into |child|. Layout again so that we can look 1819 // clears is now intruding into |child|. Layout again so that we can look
1829 // for floats in the parent that overhang |child|'s new logical top. 1820 // for floats in the parent that overhang |child|'s new logical top.
1830 bool logicalTopIntrudesIntoFloat = logicalTop < beforeCollapseLogicalTop; 1821 bool logicalTopIntrudesIntoFloat = logicalTop < beforeCollapseLogicalTop;
1831 if (logicalTopIntrudesIntoFloat && containsFloats() && 1822 if (logicalTopIntrudesIntoFloat && containsFloats() &&
1832 !child.avoidsFloats() && lowestFloatLogicalBottom() > logicalTop) 1823 !child.avoidsFloats() && lowestFloatLogicalBottom() > logicalTop)
1833 child.setNeedsLayoutAndFullPaintInvalidation( 1824 child.setNeedsLayoutAndFullPaintInvalidation(
1834 LayoutInvalidationReason::AncestorMarginCollapsing); 1825 LayoutInvalidationReason::AncestorMarginCollapsing);
(...skipping 2744 matching lines...) Expand 10 before | Expand all | Expand 10 after
4579 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); 4570 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState);
4580 } 4571 }
4581 4572
4582 void LayoutBlockFlow::invalidateDisplayItemClients( 4573 void LayoutBlockFlow::invalidateDisplayItemClients(
4583 PaintInvalidationReason invalidationReason) const { 4574 PaintInvalidationReason invalidationReason) const {
4584 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( 4575 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients(
4585 invalidationReason); 4576 invalidationReason);
4586 } 4577 }
4587 4578
4588 } // namespace blink 4579 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/block/float/avoid-floats-when-negative-margin-top-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698