mirror of
https://github.com/servo/servo.git
synced 2025-06-15 03:44:30 +00:00
Simplify processing of pending parsing-blocking scripts
This is done outside of finish_load in a more straightforward way now.
This commit is contained in:
parent
1bf0db5537
commit
abdb390da8
1 changed files with 22 additions and 24 deletions
|
@ -1549,26 +1549,7 @@ impl Document {
|
||||||
|
|
||||||
if let LoadType::Stylesheet(_) = load {
|
if let LoadType::Stylesheet(_) = load {
|
||||||
self.process_deferred_scripts();
|
self.process_deferred_scripts();
|
||||||
}
|
self.process_pending_parsing_blocking_script();
|
||||||
|
|
||||||
if let Some(parser) = self.get_current_parser() {
|
|
||||||
let ready_to_be_executed = match self.pending_parsing_blocking_script.borrow_mut().as_mut() {
|
|
||||||
Some(pending) => {
|
|
||||||
if self.script_blocking_stylesheets_count.get() > 0 {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if let Some(pair) = pending.take_result() {
|
|
||||||
Some(pair)
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
if let Some((element, result)) = ready_to_be_executed {
|
|
||||||
*self.pending_parsing_blocking_script.borrow_mut() = None;
|
|
||||||
parser.resume_with_pending_parsing_blocking_script(&element, result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.loader.borrow().is_blocked() && !self.loader.borrow().events_inhibited() {
|
if !self.loader.borrow().is_blocked() && !self.loader.borrow().events_inhibited() {
|
||||||
|
@ -1593,10 +1574,27 @@ impl Document {
|
||||||
|
|
||||||
/// 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 entry = blocking_script.as_mut().unwrap();
|
let mut blocking_script = self.pending_parsing_blocking_script.borrow_mut();
|
||||||
assert!(&*entry.element == element);
|
let entry = blocking_script.as_mut().unwrap();
|
||||||
entry.loaded(result);
|
assert!(&*entry.element == element);
|
||||||
|
entry.loaded(result);
|
||||||
|
}
|
||||||
|
self.process_pending_parsing_blocking_script();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn process_pending_parsing_blocking_script(&self) {
|
||||||
|
if self.script_blocking_stylesheets_count.get() > 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let pair = self.pending_parsing_blocking_script
|
||||||
|
.borrow_mut()
|
||||||
|
.as_mut()
|
||||||
|
.and_then(PendingScript::take_result);
|
||||||
|
if let Some((element, result)) = pair {
|
||||||
|
*self.pending_parsing_blocking_script.borrow_mut() = None;
|
||||||
|
self.get_current_parser().unwrap().resume_with_pending_parsing_blocking_script(&element, result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_asap_script(&self, script: &HTMLScriptElement) {
|
pub fn add_asap_script(&self, script: &HTMLScriptElement) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue