Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

layout: Only take nonnegative margins into account when estimating inline placement of floats. #10248

Merged
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

layout: Only take nonnegative margins into account when estimating

inline placement of floats.

Otherwise, the heuristics can pass even when there are no floats,
causing block formatting contexts to be speculated to be flowing around
floats that don't exist!

Closes #10237.
  • Loading branch information
pcwalton committed Mar 29, 2016
commit 6eb58e2c549411b43550e26ebff7d11acf300002
@@ -459,8 +459,8 @@ impl SpeculatedFloatPlacement {
}
}

/// Given the speculated inline size of the floats in for this flow, computes the speculated
/// inline size of the floats out for this flow.
/// Given the speculated inline size of the floats out for this flow's last child, computes the
/// speculated inline size of the floats out for this flow.
pub fn compute_floats_out(&mut self, flow: &mut Flow) {
if flow.is_block_like() {
let block_flow = flow.as_block();
@@ -470,10 +470,10 @@ impl SpeculatedFloatPlacement {
if self.left > Au(0) || self.right > Au(0) {
let speculated_inline_content_edge_offsets =
block_flow.fragment.guess_inline_content_edge_offsets();
if self.left > Au(0) {
if self.left > Au(0) && speculated_inline_content_edge_offsets.start > Au(0) {
self.left = self.left + speculated_inline_content_edge_offsets.start
}
if self.right > Au(0) {
if self.right > Au(0) && speculated_inline_content_edge_offsets.end > Au(0) {
self.right = self.right + speculated_inline_content_edge_offsets.end
}
}
@@ -507,16 +507,20 @@ impl SpeculatedFloatPlacement {
let speculated_inline_content_edge_offsets =
parent_block_flow.fragment.guess_inline_content_edge_offsets();

if placement.left > speculated_inline_content_edge_offsets.start {
placement.left = placement.left - speculated_inline_content_edge_offsets.start
} else {
placement.left = Au(0)
};
if placement.right > speculated_inline_content_edge_offsets.end {
placement.right = placement.right - speculated_inline_content_edge_offsets.end
} else {
placement.right = Au(0)
};
if speculated_inline_content_edge_offsets.start > Au(0) {
placement.left = if placement.left > speculated_inline_content_edge_offsets.start {
placement.left - speculated_inline_content_edge_offsets.start
} else {
Au(0)
}
}
if speculated_inline_content_edge_offsets.end > Au(0) {
placement.right = if placement.right > speculated_inline_content_edge_offsets.end {
placement.right - speculated_inline_content_edge_offsets.end
} else {
Au(0)
}
}

placement
}
@@ -1484,6 +1484,18 @@
"url": "/_mozilla/css/float_right_intrinsic_width_a.html"
}
],
"css/float_speculation_negative_inline_margins_a.html": [
{
"path": "css/float_speculation_negative_inline_margins_a.html",
"references": [
[
"/_mozilla/css/float_speculation_negative_inline_margins_ref.html",
"=="
]
],
"url": "/_mozilla/css/float_speculation_negative_inline_margins_a.html"
}
],
"css/float_table_a.html": [
{
"path": "css/float_table_a.html",
@@ -7822,6 +7834,18 @@
"url": "/_mozilla/css/float_right_intrinsic_width_a.html"
}
],
"css/float_speculation_negative_inline_margins_a.html": [
{
"path": "css/float_speculation_negative_inline_margins_a.html",
"references": [
[
"/_mozilla/css/float_speculation_negative_inline_margins_ref.html",
"=="
]
],
"url": "/_mozilla/css/float_speculation_negative_inline_margins_a.html"
}
],
"css/float_table_a.html": [
{
"path": "css/float_table_a.html",
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title></title>
<link rel="match" href="float_speculation_negative_inline_margins_ref.html">
<style>
* {
margin: 0;
padding: 0;
font-size: 0;
}
.red {
left: 50%;
position: absolute;
top: 40px;
width: 480px;
margin-left: -240px;
background: red;
}
.green {
display: block;
width: 410px;
height: 34px;
line-height: 34px;
background: green;
border: none
}
</style>

<div class="red"><input class="green"></div>

@@ -0,0 +1,29 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title></title>
<style>
* {
margin: 0;
padding: 0;
font-size: 0;
}
.red {
left: 50%;
position: absolute;
top: 40px;
width: 480px;
margin-left: -240px;
background: red;
}
.green {
display: block;
width: 410px;
height: 34px;
line-height: 34px;
background: green;
border: none
}
</style>

<div class="red"><div class="green"></div>

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.