diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-08-20 05:17:47 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-08-20 05:17:47 -0600 |
commit | 8f05447a7b1977f91fab753166fa428164a9307b (patch) | |
tree | 5a2bbed7d206d363d42a938fab45b6ae94820196 | |
parent | 14b921ee29b1b5e46e8773836b5a31e85faabfd5 (diff) | |
parent | a516042edbe22b4bdf270e51285cd344339002d7 (diff) | |
download | servo-8f05447a7b1977f91fab753166fa428164a9307b.tar.gz servo-8f05447a7b1977f91fab753166fa428164a9307b.zip |
Auto merge of #7294 - servo:tick-animations-with-no-layout-root, r=glennw+Ms2ger
layout: Don't panic if `requestAnimationFrame()` is called before first layout.
Closes #7115.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7294)
<!-- Reviewable:end -->
-rw-r--r-- | components/layout/layout_task.rs | 25 | ||||
-rw-r--r-- | tests/wpt/mozilla/meta/MANIFEST.json | 8 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/mozilla/window_requestAnimationFrame.html | 16 |
3 files changed, 40 insertions, 9 deletions
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 4c982ec9661..010bbdd578f 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -1276,14 +1276,23 @@ impl LayoutTask { &self.url, reflow_info.goal); - { - // Perform an abbreviated style recalc that operates without access to the DOM. - let mut root_flow = (*rw_data.root_flow.as_ref().unwrap()).clone(); - let animations = &*rw_data.running_animations; - profile(time::ProfilerCategory::LayoutStyleRecalc, - self.profiler_metadata(), - self.time_profiler_chan.clone(), - || animation::recalc_style_for_animations(root_flow.deref_mut(), animations)); + match rw_data.root_flow.as_ref() { + None => { + // We haven't performed a single layout yet! Do nothing. + return + } + Some(ref root_flow) => { + // Perform an abbreviated style recalc that operates without access to the DOM. + let mut root_flow = (*root_flow).clone(); + let animations = &*rw_data.running_animations; + profile(time::ProfilerCategory::LayoutStyleRecalc, + self.profiler_metadata(), + self.time_profiler_chan.clone(), + || { + animation::recalc_style_for_animations(root_flow.deref_mut(), + animations) + }); + } } self.perform_post_style_recalc_layout_passes(&reflow_info, diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 5a1537df1f6..9308a6c527a 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -767,6 +767,12 @@ "url": "/_mozilla/mozilla/window_performance.html" } ], + "mozilla/window_requestAnimationFrame.html": [ + { + "path": "mozilla/window_requestAnimationFrame.html", + "url": "/_mozilla/mozilla/window_requestAnimationFrame.html" + } + ], "mozilla/window_setInterval.html": [ { "path": "mozilla/window_setInterval.html", @@ -1040,4 +1046,4 @@ "rev": null, "url_base": "/_mozilla/", "version": 2 -}
\ No newline at end of file +} diff --git a/tests/wpt/mozilla/tests/mozilla/window_requestAnimationFrame.html b/tests/wpt/mozilla/tests/mozilla/window_requestAnimationFrame.html new file mode 100644 index 00000000000..e9c9e5789b0 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/window_requestAnimationFrame.html @@ -0,0 +1,16 @@ +<html> + <head> + <title>Test throwing an error inside requestAnimationFrame callback</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <script> + async_test(function() { + window.requestAnimationFrame(this.step_func_done()); + // FIXME(#7296) + setTimeout(this.step_func_done(), 500); + }); + </script> + </body> +</html> |