Pass the Document's origin to its constructor.

CC #10963.
This commit is contained in:
Ms2ger 2016-11-28 18:27:23 +01:00
parent 01e336f691
commit ec5d08c887
9 changed files with 34 additions and 17 deletions

View file

@ -1822,6 +1822,7 @@ impl Document {
pub fn new_inherited(window: &Window,
browsing_context: Option<&BrowsingContext>,
url: Option<ServoUrl>,
origin: Origin,
is_html_document: IsHTMLDocument,
content_type: Option<DOMString>,
last_modified: Option<String>,
@ -1838,15 +1839,6 @@ impl Document {
(DocumentReadyState::Complete, true)
};
// Incomplete implementation of Document origin specification at
// https://html.spec.whatwg.org/multipage/#origin:document
let origin = if url_has_network_scheme(&url) {
Origin::new(&url)
} else {
// Default to DOM standard behaviour
Origin::opaque_identifier()
};
Document {
node: Node::new_document_node(),
window: JS::from_ref(window),
@ -1932,6 +1924,7 @@ impl Document {
Ok(Document::new(window,
None,
None,
doc.origin().alias(),
IsHTMLDocument::NonHTMLDocument,
None,
None,
@ -1944,6 +1937,7 @@ impl Document {
pub fn new(window: &Window,
browsing_context: Option<&BrowsingContext>,
url: Option<ServoUrl>,
origin: Origin,
doctype: IsHTMLDocument,
content_type: Option<DOMString>,
last_modified: Option<String>,
@ -1955,6 +1949,7 @@ impl Document {
let document = reflect_dom_object(box Document::new_inherited(window,
browsing_context,
url,
origin,
doctype,
content_type,
last_modified,
@ -2026,6 +2021,8 @@ impl Document {
let new_doc = Document::new(self.window(),
None,
None,
// https://github.com/whatwg/html/issues/2109
Origin::opaque_identifier(),
doctype,
None,
None,

View file

@ -79,6 +79,7 @@ impl DOMImplementationMethods for DOMImplementation {
let doc = XMLDocument::new(win,
None,
None,
self.document.origin().alias(),
IsHTMLDocument::NonHTMLDocument,
Some(DOMString::from(content_type)),
None,
@ -124,6 +125,7 @@ impl DOMImplementationMethods for DOMImplementation {
let doc = Document::new(win,
None,
None,
self.document.origin().alias(),
IsHTMLDocument::HTMLDocument,
None,
None,

View file

@ -61,6 +61,7 @@ impl DOMParserMethods for DOMParser {
let document = Document::new(&self.window,
None,
Some(url.clone()),
doc.origin().alias(),
IsHTMLDocument::HTMLDocument,
Some(content_type),
None,
@ -77,6 +78,7 @@ impl DOMParserMethods for DOMParser {
let document = Document::new(&self.window,
None,
Some(url.clone()),
doc.origin().alias(),
IsHTMLDocument::NonHTMLDocument,
Some(content_type),
None,

View file

@ -168,7 +168,7 @@ impl HTMLIFrameElement {
layout_threads: PREFS.get("layout.threads").as_u64().expect("count") as usize,
};
ScriptThread::process_attach_layout(new_layout_info);
ScriptThread::process_attach_layout(new_layout_info, document.origin().alias());
} else {
let load_info = IFrameLoadInfoWithData {
info: load_info,

View file

@ -1720,6 +1720,8 @@ impl Node {
let loader = DocumentLoader::new(&*document.loader());
let document = Document::new(window, None,
Some(document.url()),
// https://github.com/whatwg/dom/issues/378
document.origin().alias(),
is_html_doc, None,
None, DocumentSource::NotFromParser, loader,
None, None);

View file

@ -106,6 +106,7 @@ impl ServoParser {
// Step 1.
let loader = DocumentLoader::new(&*context_document.loader());
let document = Document::new(window, None, Some(url.clone()),
context_document.origin().alias(),
IsHTMLDocument::HTMLDocument,
None, None,
DocumentSource::FromParser,

View file

@ -16,6 +16,7 @@ use dom::location::Location;
use dom::node::Node;
use dom::window::Window;
use js::jsapi::{JSContext, JSObject};
use origin::Origin;
use servo_url::ServoUrl;
// https://dom.spec.whatwg.org/#xmldocument
@ -28,6 +29,7 @@ impl XMLDocument {
fn new_inherited(window: &Window,
browsing_context: Option<&BrowsingContext>,
url: Option<ServoUrl>,
origin: Origin,
is_html_document: IsHTMLDocument,
content_type: Option<DOMString>,
last_modified: Option<String>,
@ -37,6 +39,7 @@ impl XMLDocument {
document: Document::new_inherited(window,
browsing_context,
url,
origin,
is_html_document,
content_type,
last_modified,
@ -50,6 +53,7 @@ impl XMLDocument {
pub fn new(window: &Window,
browsing_context: Option<&BrowsingContext>,
url: Option<ServoUrl>,
origin: Origin,
doctype: IsHTMLDocument,
content_type: Option<DOMString>,
last_modified: Option<String>,
@ -60,6 +64,7 @@ impl XMLDocument {
box XMLDocument::new_inherited(window,
browsing_context,
url,
origin,
doctype,
content_type,
last_modified,

View file

@ -1204,6 +1204,7 @@ impl XMLHttpRequest {
Document::new(win,
None,
parsed_url,
doc.origin().alias(),
is_html_document,
content_type,
None,