Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "active parser was aborted boolean" to Document #25414

Merged
merged 1 commit into from Jan 4, 2020
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Just the code, no metadata for now

  • Loading branch information
pshaughn committed Jan 2, 2020
commit 3bd30afcf370b0b7ec691f630e7344a463248fa6
@@ -370,6 +370,8 @@ pub struct Document {
page_showing: Cell<bool>,
/// Whether the document is salvageable.
salvageable: Cell<bool>,
/// Whether the document was aborted with an active parser
active_parser_was_aborted: Cell<bool>,
/// Whether the unload event has already been fired.
fired_unload: Cell<bool>,
/// List of responsive images
@@ -2264,6 +2266,7 @@ impl Document {

// Step 3.
if let Some(parser) = self.get_current_parser() {
self.active_parser_was_aborted.set(true);
parser.abort();
self.salvageable.set(false);
}
@@ -2812,6 +2815,7 @@ impl Document {
throw_on_dynamic_markup_insertion_counter: Cell::new(0),
page_showing: Cell::new(false),
salvageable: Cell::new(true),
active_parser_was_aborted: Cell::new(false),
fired_unload: Cell::new(false),
responsive_images: Default::default(),
redirect_count: Cell::new(0),
@@ -4458,35 +4462,42 @@ impl DocumentMethods for Document {
return Ok(DomRoot::from_ref(self));
}

// Step 7
if self.active_parser_was_aborted.get() {
return Ok(DomRoot::from_ref(self));
}

// TODO: prompt to unload.
// TODO: set unload_event_start and unload_event_end

window_from_node(self).set_navigation_start();

// Step 7
// Step 8
// TODO: https://github.com/servo/servo/issues/21937
if self.has_browsing_context() {
// spec says "stop document loading",
// which is a process that does more than just abort
self.abort();
}

// Step 8
// Step 9
for node in self
.upcast::<Node>()
.traverse_preorder(ShadowIncluding::Yes)
{
node.upcast::<EventTarget>().remove_all_listeners();
}

// Step 9
// Step 10
if self.window.Document() == DomRoot::from_ref(self) {
self.window.upcast::<EventTarget>().remove_all_listeners();
}

// Step 10
// Step 11
// TODO: https://github.com/servo/servo/issues/21936
Node::replace_all(None, self.upcast::<Node>());

// Step 11
// Step 12
if self.is_fully_active() {
let mut new_url = entry_responsible_document.url();
if entry_responsible_document != DomRoot::from_ref(self) {
@@ -4496,13 +4507,13 @@ impl DocumentMethods for Document {
self.set_url(new_url);
}

// Step 12
// Step 13
// TODO: https://github.com/servo/servo/issues/21938

// Step 13
// Step 14
self.set_quirks_mode(QuirksMode::NoQuirks);

// Step 14
// Step 15
let resource_threads = self
.window
.upcast::<GlobalScope>()
@@ -4512,13 +4523,13 @@ impl DocumentMethods for Document {
DocumentLoader::new_with_threads(resource_threads, Some(self.url()));
ServoParser::parse_html_script_input(self, self.url());

// Step 15
self.ready_state.set(DocumentReadyState::Loading);

// Step 16
// Handled when creating the parser in step 14
self.ready_state.set(DocumentReadyState::Loading);

// Step 17
// Handled when creating the parser in step 15

// Step 18
Ok(DomRoot::from_ref(self))
}

@@ -4550,8 +4561,8 @@ impl DocumentMethods for Document {
return Err(Error::InvalidState);
}

if !self.is_active() {
// Step 3.
// Step 3 - what specifies the is_active() part here?
if !self.is_active() || self.active_parser_was_aborted.get() {
return Ok(());
}

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.