Skip to content

Commit

Permalink
Auto merge of #17581 - mbrubeck:incremental, r=pcwalton
Browse files Browse the repository at this point in the history
Fix incremental layout bugs for absolute and cleared elements

Fixes #17307.  <del>There were two underlying bugs:</del>

* <del>Nodes were not marked dirty when their style attribute changed.</del>

* BaseFlow flags set during flow construction could get out of sync with the element's style if repair_style was called.

---

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #17307
- [x] There are tests for these changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17581)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Jul 1, 2017
2 parents 90cf191 + 2aef2af commit ece35f9
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/layout/Cargo.toml
Expand Up @@ -12,7 +12,7 @@ path = "lib.rs"
[dependencies]
app_units = "0.5"
atomic_refcell = "0.1"
bitflags = "0.7"
bitflags = "0.8"
canvas_traits = {path = "../canvas_traits"}
euclid = "0.15"
fnv = "1.0"
Expand Down
23 changes: 23 additions & 0 deletions components/layout/flow.rs
Expand Up @@ -1115,6 +1115,28 @@ impl BaseFlow {
}
}

/// Update the 'flags' field when computed styles have changed.
///
/// These flags are initially set during flow construction. They only need to be updated here
/// if they are based on properties that can change without triggering `RECONSTRUCT_FLOW`.
pub fn update_flags_if_needed(&mut self, style: &ServoComputedValues) {
// For absolutely-positioned flows, changes to top/bottom/left/right can cause these flags
// to get out of date:
if self.restyle_damage.contains(REFLOW_OUT_OF_FLOW) {
// Note: We don't need to check whether IS_ABSOLUTELY_POSITIONED has changed, because
// changes to the 'position' property trigger flow reconstruction.
if self.flags.contains(IS_ABSOLUTELY_POSITIONED) {
let logical_position = style.logical_position();
self.flags.set(INLINE_POSITION_IS_STATIC,
logical_position.inline_start == LengthOrPercentageOrAuto::Auto &&
logical_position.inline_end == LengthOrPercentageOrAuto::Auto);
self.flags.set(BLOCK_POSITION_IS_STATIC,
logical_position.block_start == LengthOrPercentageOrAuto::Auto &&
logical_position.block_end == LengthOrPercentageOrAuto::Auto);
}
}
}

/// Return a new BaseFlow like this one but with the given children list
pub fn clone_with_children(&self, children: FlowList) -> BaseFlow {
BaseFlow {
Expand Down Expand Up @@ -1361,6 +1383,7 @@ impl<'a> MutableFlowUtils for &'a mut Flow {
/// calling them individually, since there is no reason not to perform both operations.
fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ServoComputedValues>) {
self.repair_style(style);
mut_base(self).update_flags_if_needed(style);
self.bubble_inline_sizes();
}

Expand Down
2 changes: 1 addition & 1 deletion components/style/servo/restyle_damage.rs
Expand Up @@ -202,7 +202,7 @@ fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> Servo
add_if_not_equal!(old, new, damage,
[REPAINT, REPOSITION, STORE_OVERFLOW, BUBBLE_ISIZES, REFLOW_OUT_OF_FLOW,
REFLOW, RECONSTRUCT_FLOW], [
get_box.float, get_box.display, get_box.position, get_counters.content,
get_box.clear, get_box.float, get_box.display, get_box.position, get_counters.content,
get_counters.counter_reset, get_counters.counter_increment,
get_inheritedbox._servo_under_display_none,
get_list.quotes, get_list.list_style_type,
Expand Down

This file was deleted.

25 changes: 25 additions & 0 deletions tests/wpt/mozilla/meta/MANIFEST.json
Expand Up @@ -2435,6 +2435,18 @@
{}
]
],
"css/incremental_position.html": [
[
"/_mozilla/css/incremental_position.html",
[
[
"/_mozilla/css/incremental_position_ref.html",
"=="
]
],
{}
]
],
"css/incremental_text_color_a.html": [
[
"/_mozilla/css/incremental_text_color_a.html",
Expand Down Expand Up @@ -7911,6 +7923,11 @@
{}
]
],
"css/incremental_position_ref.html": [
[
{}
]
],
"css/incremental_text_color_ref.html": [
[
{}
Expand Down Expand Up @@ -22808,6 +22825,14 @@
"3235e9662e37dc723364a1dd39e07157868dd290",
"support"
],
"css/incremental_position.html": [
"849f3f5ae1df8ecf3bcf3f1723b5a755afeb3316",
"reftest"
],
"css/incremental_position_ref.html": [
"67ab51b29fb015b82bf98942e2e886b3de5ea2cd",
"support"
],
"css/incremental_text_color_a.html": [
"1846e2691b150cd2eb0b126c6d8f68f47d683fab",
"reftest"
Expand Down
27 changes: 27 additions & 0 deletions tests/wpt/mozilla/tests/css/incremental_position.html
@@ -0,0 +1,27 @@
<!doctype html>
<html class="reftest-wait">
<head>
<meta charset="utf-8">
<title>Incremental absolute position test</title>
<link rel="match" href="incremental_position_ref.html">
<style>
#rect {
position: absolute;
border: 1px solid red;
width: 40px;
height: 40px;
}
</style>
</head>
<body>
<div id="rect"></div>
<script>
window.onload = function() {
document.body.offsetWidth; // force layout
var e = document.getElementById("rect");
e.style.left = "100px";
document.documentElement.classList.remove('reftest-wait');
};
</script>
</body>
</html>
19 changes: 19 additions & 0 deletions tests/wpt/mozilla/tests/css/incremental_position_ref.html
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Incremental absolute position reference</title>
<style>
#rect {
position: absolute;
border: 1px solid red;
width: 40px;
height: 40px;
left: 100px;
}
</style>
</head>
<body>
<div id="rect"></div>
</body>
</html>

0 comments on commit ece35f9

Please sign in to comment.