mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Reorder some Document methods to put them together
This commit is contained in:
parent
5756f2ff4d
commit
a60bbc81b8
1 changed files with 51 additions and 51 deletions
|
@ -1450,29 +1450,6 @@ impl Document {
|
||||||
changed
|
changed
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_pending_parsing_blocking_script(&self,
|
|
||||||
script: &HTMLScriptElement,
|
|
||||||
load: Option<ScriptResult>) {
|
|
||||||
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) {
|
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
|
||||||
if PREFS.is_mozbrowser_enabled() {
|
if PREFS.is_mozbrowser_enabled() {
|
||||||
if let Some((parent_pipeline_id, _)) = self.window.parent_info() {
|
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<ScriptResult>) {
|
||||||
|
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.
|
/// https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.d.
|
||||||
pub fn pending_parsing_blocking_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) {
|
pub fn pending_parsing_blocking_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) {
|
||||||
let mut blocking_script = self.pending_parsing_blocking_script.borrow_mut();
|
let mut blocking_script = self.pending_parsing_blocking_script.borrow_mut();
|
||||||
|
@ -1621,6 +1609,46 @@ impl Document {
|
||||||
entry.loaded(result);
|
entry.loaded(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.
|
||||||
|
/// https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.d.
|
||||||
|
pub fn asap_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) {
|
||||||
|
let mut scripts = self.asap_scripts_set.borrow_mut();
|
||||||
|
let idx = scripts.iter().position(|entry| &*entry.element == element).unwrap();
|
||||||
|
scripts.swap(0, idx);
|
||||||
|
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,
|
||||||
|
element: &HTMLScriptElement,
|
||||||
|
result: ScriptResult) {
|
||||||
|
self.asap_in_order_scripts_list.loaded(element, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn process_asap_scripts(&self) {
|
||||||
|
let pair = self.asap_scripts_set.borrow_mut().front_mut().and_then(PendingScript::take_result);
|
||||||
|
if let Some((element, result)) = pair {
|
||||||
|
self.asap_scripts_set.borrow_mut().pop_front();
|
||||||
|
element.execute(result);
|
||||||
|
}
|
||||||
|
while let Some((element, result)) = self.asap_in_order_scripts_list.take_next_ready_to_be_executed() {
|
||||||
|
element.execute(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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.
|
/// https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.d.
|
||||||
pub fn deferred_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) {
|
pub fn deferred_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) {
|
||||||
self.deferred_scripts.loaded(element, result);
|
self.deferred_scripts.loaded(element, result);
|
||||||
|
@ -1648,34 +1676,6 @@ impl Document {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#the-end step 3.
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.d.
|
|
||||||
pub fn asap_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) {
|
|
||||||
let mut scripts = self.asap_scripts_set.borrow_mut();
|
|
||||||
let idx = scripts.iter().position(|entry| &*entry.element == element).unwrap();
|
|
||||||
scripts.swap(0, idx);
|
|
||||||
scripts[0].loaded(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 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,
|
|
||||||
element: &HTMLScriptElement,
|
|
||||||
result: ScriptResult) {
|
|
||||||
self.asap_in_order_scripts_list.loaded(element, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn process_asap_scripts(&self) {
|
|
||||||
let pair = self.asap_scripts_set.borrow_mut().front_mut().and_then(PendingScript::take_result);
|
|
||||||
if let Some((element, result)) = pair {
|
|
||||||
self.asap_scripts_set.borrow_mut().pop_front();
|
|
||||||
element.execute(result);
|
|
||||||
}
|
|
||||||
while let Some((element, result)) = self.asap_in_order_scripts_list.take_next_ready_to_be_executed() {
|
|
||||||
element.execute(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn maybe_dispatch_dom_content_loaded(&self) {
|
pub fn maybe_dispatch_dom_content_loaded(&self) {
|
||||||
if self.domcontentloaded_dispatched.get() {
|
if self.domcontentloaded_dispatched.get() {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue