diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index fc3025615a71..ae0cf9a0e273 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -1450,29 +1450,6 @@ impl Document { changed } - pub fn set_pending_parsing_blocking_script(&self, - script: &HTMLScriptElement, - load: Option) { - assert!(!self.has_pending_parsing_blocking_script()); - *self.pending_parsing_blocking_script.borrow_mut() = Some(PendingScript::new_with_load(script, load)); - } - - pub fn has_pending_parsing_blocking_script(&self) -> bool { - self.pending_parsing_blocking_script.borrow().is_some() - } - - pub fn add_deferred_script(&self, script: &HTMLScriptElement) { - self.deferred_scripts.push(script); - } - - pub fn add_asap_script(&self, script: &HTMLScriptElement) { - self.asap_scripts_set.borrow_mut().push_back(PendingScript::new(script)); - } - - pub fn push_asap_in_order_script(&self, script: &HTMLScriptElement) { - self.asap_in_order_scripts_list.push(script); - } - pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) { if PREFS.is_mozbrowser_enabled() { if let Some((parent_pipeline_id, _)) = self.window.parent_info() { @@ -1613,6 +1590,17 @@ impl Document { } } + pub fn set_pending_parsing_blocking_script(&self, + script: &HTMLScriptElement, + load: Option) { + assert!(!self.has_pending_parsing_blocking_script()); + *self.pending_parsing_blocking_script.borrow_mut() = Some(PendingScript::new_with_load(script, load)); + } + + pub fn has_pending_parsing_blocking_script(&self) -> bool { + self.pending_parsing_blocking_script.borrow().is_some() + } + /// https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.d. pub fn pending_parsing_blocking_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) { let mut blocking_script = self.pending_parsing_blocking_script.borrow_mut(); @@ -1621,31 +1609,8 @@ impl Document { entry.loaded(result); } - /// https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.d. - pub fn deferred_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) { - self.deferred_scripts.loaded(element, result); - } - - /// https://html.spec.whatwg.org/multipage/#the-end step 3. - pub fn process_deferred_scripts(&self) { - if self.ready_state.get() != DocumentReadyState::Interactive { - return; - } - // Part of substep 1. - loop { - if self.script_blocking_stylesheets_count.get() > 0 { - return; - } - if let Some((element, result)) = self.deferred_scripts.take_next_ready_to_be_executed() { - element.execute(result); - } else { - break; - } - } - if self.deferred_scripts.is_empty() { - // https://html.spec.whatwg.org/multipage/#the-end step 4. - self.maybe_dispatch_dom_content_loaded(); - } + pub fn add_asap_script(&self, script: &HTMLScriptElement) { + self.asap_scripts_set.borrow_mut().push_back(PendingScript::new(script)); } /// https://html.spec.whatwg.org/multipage/#the-end step 3. @@ -1657,6 +1622,10 @@ impl Document { scripts[0].loaded(result); } + pub fn push_asap_in_order_script(&self, script: &HTMLScriptElement) { + self.asap_in_order_scripts_list.push(script); + } + /// https://html.spec.whatwg.org/multipage/#the-end step 3. /// https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.c. pub fn asap_in_order_script_loaded(&self, @@ -1676,6 +1645,37 @@ impl Document { } } + pub fn add_deferred_script(&self, script: &HTMLScriptElement) { + self.deferred_scripts.push(script); + } + + /// https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.d. + pub fn deferred_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) { + self.deferred_scripts.loaded(element, result); + } + + /// https://html.spec.whatwg.org/multipage/#the-end step 3. + pub fn process_deferred_scripts(&self) { + if self.ready_state.get() != DocumentReadyState::Interactive { + return; + } + // Part of substep 1. + loop { + if self.script_blocking_stylesheets_count.get() > 0 { + return; + } + if let Some((element, result)) = self.deferred_scripts.take_next_ready_to_be_executed() { + element.execute(result); + } else { + break; + } + } + if self.deferred_scripts.is_empty() { + // https://html.spec.whatwg.org/multipage/#the-end step 4. + self.maybe_dispatch_dom_content_loaded(); + } + } + pub fn maybe_dispatch_dom_content_loaded(&self) { if self.domcontentloaded_dispatched.get() { return;