aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-03-29 16:04:01 +0530
committerbors-servo <lbergstrom+bors@mozilla.com>2016-03-29 16:04:01 +0530
commit3f733217109a98f559904ebf9935e43e553bd076 (patch)
treed3de5c9528124161e7098fe6b6b1ccdb41822642 /components
parent159be44193ef7d60a5c35629d791323e5357e7db (diff)
parent6eb58e2c549411b43550e26ebff7d11acf300002 (diff)
downloadservo-3f733217109a98f559904ebf9935e43e553bd076.tar.gz
servo-3f733217109a98f559904ebf9935e43e553bd076.zip
Auto merge of #10248 - pcwalton:float-speculation-with-negative-margins, r=mbrubeck
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. r? @mbrubeck <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10248) <!-- Reviewable:end -->
Diffstat (limited to 'components')
-rw-r--r--components/layout/floats.rs32
1 files changed, 18 insertions, 14 deletions
diff --git a/components/layout/floats.rs b/components/layout/floats.rs
index e3ae4716e53..a31d7461db0 100644
--- a/components/layout/floats.rs
+++ b/components/layout/floats.rs
@@ -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
}