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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
index 3b7f040121bcfbc793b479e13c7ffeba7ea8c472..79350deba644fb961050bdfb60a16d23818ca9e7 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
@@ -1709,10 +1709,10 @@ LayoutUnit LayoutBlockFlow::collapseMargins(LayoutBox& child,
LayoutObject* prev = child.previousSibling();
LayoutBlockFlow* previousBlockFlow =
- prev && prev->isLayoutBlockFlow() ? toLayoutBlockFlow(prev) : nullptr;
- bool previousBlockFlowCanSelfCollapse =
- previousBlockFlow &&
- !previousBlockFlow->isFloatingOrOutOfFlowPositioned();
+ prev && prev->isLayoutBlockFlow() &&
+ !prev->isFloatingOrOutOfFlowPositioned()
+ ? toLayoutBlockFlow(prev)
+ : 0;
// If the child's previous sibling is a self-collapsing block that cleared a
// float then its top border edge has been set at the bottom border edge of
// the float. Since we want to collapse the child's top margin with the self-
@@ -1720,8 +1720,7 @@ LayoutUnit LayoutBlockFlow::collapseMargins(LayoutBox& child,
// height to match the margin top of the self-collapsing block. If the
// resulting collapsed margin leaves the child still intruding into the float
// then we will want to clear it.
- if (!marginInfo.canCollapseWithMarginBefore() &&
- previousBlockFlowCanSelfCollapse &&
+ if (!marginInfo.canCollapseWithMarginBefore() && previousBlockFlow &&
marginInfo.lastChildIsSelfCollapsingBlockWithClearance())
setLogicalHeight(
logicalHeight() -
@@ -1802,26 +1801,18 @@ LayoutUnit LayoutBlockFlow::collapseMargins(LayoutBox& child,
setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop));
}
- // If |child| has moved up into previous siblings it needs to avoid or clear
- // any floats they contain.
- LayoutUnit oldLogicalHeight = logicalHeight();
- setLogicalHeight(logicalTop);
- while (previousBlockFlow) {
- auto lowestFloat = previousBlockFlow->logicalTop() +
- previousBlockFlow->lowestFloatLogicalBottom();
- if (lowestFloat > logicalTop)
+ if (previousBlockFlow) {
+ // If |child| is a self-collapsing block it may have collapsed into a
+ // previous sibling and although it hasn't reduced the height of the parent
+ // yet any floats from the parent will now overhang.
+ LayoutUnit oldLogicalHeight = logicalHeight();
+ setLogicalHeight(logicalTop);
+ if (!previousBlockFlow->avoidsFloats() &&
+ (previousBlockFlow->logicalTop() +
+ previousBlockFlow->lowestFloatLogicalBottom()) > logicalTop)
addOverhangingFloats(previousBlockFlow, false);
- else
- break;
- LayoutObject* prev = previousBlockFlow->previousSibling();
- if (prev && prev->isLayoutBlockFlow())
- previousBlockFlow = toLayoutBlockFlow(prev);
- else
- previousBlockFlow = nullptr;
- }
- setLogicalHeight(oldLogicalHeight);
+ setLogicalHeight(oldLogicalHeight);
- if (previousBlockFlowCanSelfCollapse) {
// If |child|'s previous sibling is or contains a self-collapsing block that
// cleared a float and margin collapsing resulted in |child| moving up
// into the margin area of the self-collapsing block then the float it
« 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