Commit 5050aa20 authored by Robert Hogan's avatar Robert Hogan Committed by Commit Bot

Look past formatting context objects for overhanging floats

Bug: 797185
Change-Id: I2521e1cf552be56abba6513eada51cad571d2cca
Reviewed-on: https://chromium-review.googlesource.com/844074Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Robert Hogan <robhogan@gmail.com>
Cr-Commit-Position: refs/heads/master@{#526477}
parent eadeea9d
<!DOCTYPE html>
<style>
::-webkit-scrollbar { display: none; }
body { margin: 0px; }
.float { float: left; width: 50px; height: 100px; background: green; }
#content { overflow: hidden; margin-top: -100px; width: 50px; height: 100px; background: green; }
.container { width: 100px; background: red; }
</style>
<div class="container">
<div>
<div class="float"></div>
<br clear=all>
</div>
<div style="position:absolute"></div>
<div id="content" data-offset-x=50></div>
</div>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script>
test(() => {
var hr = document.getElementById("content");
assert_equals(hr.offsetLeft, 50);
}, "crbug.com/666487: There should be a green square.");
</script>
<!DOCTYPE html>
<style>
::-webkit-scrollbar { display: none; }
body { margin: 0px; }
.float { float: left; width: 50px; height: 100px; background: green; }
#content { overflow: hidden; margin-top: -100px; width: 50px; height: 100px; background: green; }
.container { width: 100px; background: red; }
</style>
<div class="container">
<div>
<div class="float"></div>
<br clear=all>
</div>
<div style="display:table;"></div>
<div id="content" data-offset-x=50></div>
</div>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script>
test(() => {
var hr = document.getElementById("content");
assert_equals(hr.offsetLeft, 50);
}, "crbug.com/666487: There should be a green square.");
</script>
...@@ -1709,6 +1709,18 @@ LayoutUnit LayoutBlockFlow::AdjustedMarginBeforeForPagination( ...@@ -1709,6 +1709,18 @@ LayoutUnit LayoutBlockFlow::AdjustedMarginBeforeForPagination(
return std::min(effective_margin, remaining_space); return std::min(effective_margin, remaining_space);
} }
static LayoutBlockFlow* PreviousBlockFlowInFormattingContext(
const LayoutBox& child) {
LayoutObject* prev = child.PreviousSibling();
while (prev && (!prev->IsLayoutBlockFlow() ||
ToLayoutBlockFlow(prev)->CreatesNewFormattingContext())) {
prev = prev->PreviousSibling();
}
if (prev)
return ToLayoutBlockFlow(prev);
return nullptr;
}
LayoutUnit LayoutBlockFlow::CollapseMargins( LayoutUnit LayoutBlockFlow::CollapseMargins(
LayoutBox& child, LayoutBox& child,
BlockChildrenLayoutInfo& layout_info, BlockChildrenLayoutInfo& layout_info,
...@@ -1896,18 +1908,16 @@ LayoutUnit LayoutBlockFlow::CollapseMargins( ...@@ -1896,18 +1908,16 @@ LayoutUnit LayoutBlockFlow::CollapseMargins(
if (logical_top < before_collapse_logical_top) { if (logical_top < before_collapse_logical_top) {
LayoutUnit old_logical_height = LogicalHeight(); LayoutUnit old_logical_height = LogicalHeight();
SetLogicalHeight(logical_top); SetLogicalHeight(logical_top);
LayoutBlockFlow* previous_block_flow =
PreviousBlockFlowInFormattingContext(child);
while (previous_block_flow) { while (previous_block_flow) {
auto lowest_float = previous_block_flow->LogicalTop() + auto lowest_float = previous_block_flow->LogicalTop() +
previous_block_flow->LowestFloatLogicalBottom(); previous_block_flow->LowestFloatLogicalBottom();
if (lowest_float > logical_top) if (lowest_float <= logical_top)
AddOverhangingFloats(previous_block_flow, false);
else
break; break;
LayoutObject* prev = previous_block_flow->PreviousSibling(); AddOverhangingFloats(previous_block_flow, false);
if (prev && prev->IsLayoutBlockFlow()) previous_block_flow =
previous_block_flow = ToLayoutBlockFlow(prev); PreviousBlockFlowInFormattingContext(*previous_block_flow);
else
previous_block_flow = nullptr;
} }
SetLogicalHeight(old_logical_height); SetLogicalHeight(old_logical_height);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment