diff options
author | Gregory Terzian <gterzian@users.noreply.github.com> | 2018-07-01 20:22:19 +0800 |
---|---|---|
committer | Gregory Terzian <gterzian@users.noreply.github.com> | 2018-07-29 16:42:54 +0800 |
commit | ff62ca7c018eb3e6d50b516dc653e5090dbe7e37 (patch) | |
tree | 381aa67cf0290ce571e1d4737c3ff268c2b8c882 /components/script/dom/document.rs | |
parent | aab335e543f52211b2c44f6ed2ebf0cba98ddf97 (diff) | |
download | servo-ff62ca7c018eb3e6d50b516dc653e5090dbe7e37.tar.gz servo-ff62ca7c018eb3e6d50b516dc653e5090dbe7e37.zip |
implement window.stop, improve aborting document load
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r-- | components/script/dom/document.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 26c59bdb8ec..1ff29786491 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -141,7 +141,7 @@ use style::shared_lock::{SharedRwLock as StyleSharedRwLock, SharedRwLockReadGuar use style::str::{split_html_space_chars, str_join}; use style::stylesheet_set::DocumentStylesheetSet; use style::stylesheets::{CssRule, Stylesheet, Origin, OriginSet}; -use task_source::TaskSource; +use task_source::{TaskSource, TaskSourceName}; use time; use timers::OneshotTimerCallback; use url::Host; @@ -2010,7 +2010,7 @@ impl Document { } // https://html.spec.whatwg.org/multipage/#abort-a-document - fn abort(&self) { + pub fn abort(&self) { // We need to inhibit the loader before anything else. self.loader.borrow_mut().inhibit_events(); @@ -2029,14 +2029,21 @@ impl Document { *self.asap_scripts_set.borrow_mut() = vec![]; self.asap_in_order_scripts_list.clear(); self.deferred_scripts.clear(); + if self.loader.borrow_mut().cancel_all_loads() { + // If any loads were canceled. + self.salvageable.set(false); + }; - // TODO: https://github.com/servo/servo/issues/15236 - self.window.cancel_all_tasks(); + // Also Step 2. + // Note: the spec says to discard any tasks queued for fetch. + // This cancels all tasks on the networking task source, which might be too broad. + // See https://github.com/whatwg/html/issues/3837 + self.window.cancel_all_tasks_from_source(TaskSourceName::Networking); // Step 3. if let Some(parser) = self.get_current_parser() { parser.abort(); - // TODO: salvageable flag. + self.salvageable.set(false); } } |