aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-01-26 08:30:56 -0800
committerGitHub <noreply@github.com>2017-01-26 08:30:56 -0800
commit88cd8a3cf0d299a4dc066059d454fdbc395dbfeb (patch)
treef12539962f03b669fb2c441319185a27735bb6d5 /components/script/dom
parent58f4804ef5ae8d1aca1790a1567214b6443d23b2 (diff)
parenta689cf1d34067bbeb127bf32520ef3b027d01e49 (diff)
downloadservo-88cd8a3cf0d299a4dc066059d454fdbc395dbfeb.tar.gz
servo-88cd8a3cf0d299a4dc066059d454fdbc395dbfeb.zip
Auto merge of #15179 - servo:alter_resource_utilization, r=nox
Refactor away ScriptThread::alter_resource_utilization(). It's used in two places, one of which already has access to the Window. <!-- 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/15179) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/window.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index c8e4ccc832d..cb9d5abdf07 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -1583,6 +1583,15 @@ impl Window {
pub fn evaluate_media_queries_and_report_changes(&self) {
self.media_query_lists.evaluate_and_report_changes();
}
+
+ /// Slow down/speed up timers based on visibility.
+ pub fn alter_resource_utilization(&self, visible: bool) {
+ if visible {
+ self.upcast::<GlobalScope>().speed_up_timers();
+ } else {
+ self.upcast::<GlobalScope>().slow_down_timers();
+ }
+ }
}
impl Window {