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 -->
This commit is contained in:
bors-servo 2017-01-26 08:30:56 -08:00 committed by GitHub
commit 88cd8a3cf0
2 changed files with 21 additions and 24 deletions

View file

@ -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 {