Use FetchCanceller for document loads

This commit is contained in:
Manish Goregaokar 2017-11-21 16:43:50 -08:00
parent 78c8b4232f
commit 3900f5e616
No known key found for this signature in database
GPG key ID: 3BBF4D3E2EF79F98
11 changed files with 51 additions and 24 deletions

View file

@ -91,6 +91,7 @@ use dom::windowproxy::WindowProxy;
use dom_struct::dom_struct;
use encoding_rs::{Encoding, UTF_8};
use euclid::Point2D;
use fetch::FetchCanceller;
use html5ever::{LocalName, Namespace, QualName};
use hyper::header::{Header, SetCookie};
use hyper_serde::Serde;
@ -360,6 +361,8 @@ pub struct Document {
form_id_listener_map: DomRefCell<HashMap<Atom, HashSet<Dom<Element>>>>,
interactive_time: DomRefCell<InteractiveMetrics>,
tti_window: DomRefCell<InteractiveWindow>,
/// RAII canceller for Fetch
canceller: FetchCanceller,
}
#[derive(JSTraceable, MallocSizeOf)]
@ -2165,7 +2168,8 @@ impl Document {
source: DocumentSource,
doc_loader: DocumentLoader,
referrer: Option<String>,
referrer_policy: Option<ReferrerPolicy>)
referrer_policy: Option<ReferrerPolicy>,
canceller: FetchCanceller)
-> Document {
let url = url.unwrap_or_else(|| ServoUrl::parse("about:blank").unwrap());
@ -2270,6 +2274,7 @@ impl Document {
form_id_listener_map: Default::default(),
interactive_time: DomRefCell::new(interactive_time),
tti_window: DomRefCell::new(InteractiveWindow::new()),
canceller: canceller,
}
}
@ -2288,7 +2293,8 @@ impl Document {
DocumentSource::NotFromParser,
docloader,
None,
None))
None,
Default::default()))
}
pub fn new(window: &Window,
@ -2302,7 +2308,8 @@ impl Document {
source: DocumentSource,
doc_loader: DocumentLoader,
referrer: Option<String>,
referrer_policy: Option<ReferrerPolicy>)
referrer_policy: Option<ReferrerPolicy>,
canceller: FetchCanceller)
-> DomRoot<Document> {
let document = reflect_dom_object(
Box::new(Document::new_inherited(
@ -2317,7 +2324,8 @@ impl Document {
source,
doc_loader,
referrer,
referrer_policy
referrer_policy,
canceller
)),
window,
DocumentBinding::Wrap
@ -2474,7 +2482,8 @@ impl Document {
DocumentSource::NotFromParser,
DocumentLoader::new(&self.loader()),
None,
None);
None,
Default::default());
new_doc.appropriate_template_contents_owner_document.set(Some(&new_doc));
new_doc
})

View file

@ -137,7 +137,8 @@ impl DOMImplementationMethods for DOMImplementation {
DocumentSource::NotFromParser,
loader,
None,
None);
None,
Default::default());
{
// Step 3.

View file

@ -70,7 +70,8 @@ impl DOMParserMethods for DOMParser {
DocumentSource::FromParser,
loader,
None,
None);
None,
Default::default());
ServoParser::parse_html_document(&document, s, url);
document.set_ready_state(DocumentReadyState::Complete);
Ok(document)
@ -88,7 +89,8 @@ impl DOMParserMethods for DOMParser {
DocumentSource::NotFromParser,
loader,
None,
None);
None,
Default::default());
ServoParser::parse_xml_document(&document, s, url);
Ok(document)
}

View file

@ -1814,7 +1814,7 @@ impl Node {
is_html_doc, None,
None, DocumentActivity::Inactive,
DocumentSource::NotFromParser, loader,
None, None);
None, None, Default::default());
DomRoot::upcast::<Node>(document)
},
NodeTypeId::Element(..) => {

View file

@ -138,7 +138,8 @@ impl ServoParser {
DocumentSource::FromParser,
loader,
None,
None);
None,
Default::default());
// Step 2.
document.set_quirks_mode(context_document.quirks_mode());

View file

@ -48,7 +48,8 @@ impl XMLDocument {
source,
doc_loader,
None,
None),
None,
Default::default()),
}
}

View file

@ -1261,7 +1261,8 @@ impl XMLHttpRequest {
DocumentSource::FromParser,
docloader,
None,
None)
None,
Default::default())
}
fn filter_response_headers(&self) -> Headers {