aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/window.rs
diff options
context:
space:
mode:
authorDelan Azabani <dazabani@igalia.com>2024-03-22 14:06:28 +0800
committerGitHub <noreply@github.com>2024-03-22 06:06:28 +0000
commit8882507ad06b598fb43d8542c67ad76daeda739c (patch)
tree5d78c92d40aab37a71f87c6f5a1df0c5218e81c5 /components/script/dom/window.rs
parent9b26dca141159ddc75266de9ef5a54f537450921 (diff)
downloadservo-8882507ad06b598fb43d8542c67ad76daeda739c.tar.gz
servo-8882507ad06b598fb43d8542c67ad76daeda739c.zip
Rework “visible” to “throttled” in constellation + script + compositor (#31816)
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r--components/script/dom/window.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index c58700b1a37..9a92955a007 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -349,7 +349,7 @@ pub struct Window {
#[no_trace]
player_context: WindowGLContext,
- visible: Cell<bool>,
+ throttled: Cell<bool>,
/// A shared marker for the validity of any cached layout values. A value of true
/// indicates that any such values remain valid; any new layout that invalidates
@@ -2454,18 +2454,18 @@ impl Window {
self.Document().react_to_environment_changes();
}
- /// Slow down/speed up timers based on visibility.
- pub fn alter_resource_utilization(&self, visible: bool) {
- self.visible.set(visible);
- if visible {
- self.upcast::<GlobalScope>().speed_up_timers();
- } else {
+ /// Set whether to use less resources by running timers at a heavily limited rate.
+ pub fn set_throttled(&self, throttled: bool) {
+ self.throttled.set(throttled);
+ if throttled {
self.upcast::<GlobalScope>().slow_down_timers();
+ } else {
+ self.upcast::<GlobalScope>().speed_up_timers();
}
}
- pub fn visible(&self) -> bool {
- self.visible.get()
+ pub fn throttled(&self) -> bool {
+ self.throttled.get()
}
pub fn unminified_js_dir(&self) -> Option<String> {
@@ -2621,7 +2621,7 @@ impl Window {
userscripts_path,
replace_surrogates,
player_context,
- visible: Cell::new(true),
+ throttled: Cell::new(false),
layout_marker: DomRefCell::new(Rc::new(Cell::new(true))),
current_event: DomRefCell::new(None),
});