aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/document.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-09-19 15:34:06 -0400
committerGitHub <noreply@github.com>2019-09-19 15:34:06 -0400
commit9047ae97dd07f34f6325fc8b7071340f6dd6a28f (patch)
tree1c642608c7a1206d170095cc87ae60019f9af32f /components/script/dom/document.rs
parent7b653cad7b0d891e06e4847ad738f38a9510dd92 (diff)
parentd7bebce53787c535bbd3511855a8633a12986daa (diff)
downloadservo-9047ae97dd07f34f6325fc8b7071340f6dd6a28f.tar.gz
servo-9047ae97dd07f34f6325fc8b7071340f6dd6a28f.zip
Auto merge of #24223 - ferjm:suspend.media.playback, r=jdm,gterzian
Suspend media after navigation - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #21989 and fix #22763 - [ ] I am not sure how to test this This depends on https://github.com/servo/media/pull/310 <!-- 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/24223) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r--components/script/dom/document.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index fcacb4cedad..91f5e19dc7c 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -145,6 +145,7 @@ use script_traits::{
use servo_arc::Arc;
use servo_atoms::Atom;
use servo_config::pref;
+use servo_media::{ClientContextId, ServoMedia};
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
use std::borrow::ToOwned;
use std::cell::{Cell, Ref, RefMut};
@@ -499,12 +500,17 @@ impl Document {
// Set the document's activity level, reflow if necessary, and suspend or resume timers.
if activity != self.activity.get() {
self.activity.set(activity);
+ let media = ServoMedia::get().unwrap();
+ let pipeline_id = self.window().pipeline_id().expect("doc with no pipeline");
+ let client_context_id =
+ ClientContextId::build(pipeline_id.namespace_id.0, pipeline_id.index.0.get());
if activity == DocumentActivity::FullyActive {
self.title_changed();
self.dirty_all_nodes();
self.window()
.reflow(ReflowGoal::Full, ReflowReason::CachedPageNeededReflow);
self.window().resume();
+ media.resume(&client_context_id);
// html.spec.whatwg.org/multipage/#history-traversal
// Step 4.6
if self.ready_state.get() == DocumentReadyState::Complete {
@@ -544,6 +550,7 @@ impl Document {
}
} else {
self.window().suspend();
+ media.suspend(&client_context_id);
}
}
}