mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
script: Stop copying the document URL.
This commit is contained in:
parent
4d1be2f56c
commit
5dce5f0c97
8 changed files with 19 additions and 16 deletions
|
@ -226,7 +226,6 @@ impl CollectionFilter for AppletsFilter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Document {
|
impl Document {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn loader(&self) -> Ref<DocumentLoader> {
|
pub fn loader(&self) -> Ref<DocumentLoader> {
|
||||||
|
@ -269,16 +268,16 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#concept-document-url
|
// https://dom.spec.whatwg.org/#concept-document-url
|
||||||
pub fn url(&self) -> Url {
|
pub fn url<'a>(&'a self) -> &'a Url {
|
||||||
self.url.clone()
|
&self.url
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#fallback-base-url
|
// https://html.spec.whatwg.org/multipage/#fallback-base-url
|
||||||
pub fn fallback_base_url(&self) -> Url {
|
pub fn fallback_base_url<'a>(&'a self) -> Url {
|
||||||
// Step 1: iframe srcdoc (#4767).
|
// Step 1: iframe srcdoc (#4767).
|
||||||
// Step 2: about:blank with a creator browsing context.
|
// Step 2: about:blank with a creator browsing context.
|
||||||
// Step 3.
|
// Step 3.
|
||||||
self.url()
|
self.url().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#document-base-url
|
// https://html.spec.whatwg.org/multipage/#document-base-url
|
||||||
|
@ -1735,7 +1734,7 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let (tx, rx) = ipc::channel().unwrap();
|
let (tx, rx) = ipc::channel().unwrap();
|
||||||
let _ = window.r().resource_task().send(GetCookiesForUrl(url, tx, NonHTTP));
|
let _ = window.r().resource_task().send(GetCookiesForUrl((*url).clone(), tx, NonHTTP));
|
||||||
let cookies = rx.recv().unwrap();
|
let cookies = rx.recv().unwrap();
|
||||||
Ok(cookies.unwrap_or("".to_owned()))
|
Ok(cookies.unwrap_or("".to_owned()))
|
||||||
}
|
}
|
||||||
|
@ -1744,11 +1743,11 @@ impl DocumentMethods for Document {
|
||||||
fn SetCookie(&self, cookie: DOMString) -> ErrorResult {
|
fn SetCookie(&self, cookie: DOMString) -> ErrorResult {
|
||||||
//TODO: ignore for cookie-averse Document
|
//TODO: ignore for cookie-averse Document
|
||||||
let url = self.url();
|
let url = self.url();
|
||||||
if !is_scheme_host_port_tuple(&url) {
|
if !is_scheme_host_port_tuple(url) {
|
||||||
return Err(Security);
|
return Err(Security);
|
||||||
}
|
}
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
let _ = window.r().resource_task().send(SetCookiesForUrl(url, cookie, NonHTTP));
|
let _ = window.r().resource_task().send(SetCookiesForUrl((*url).clone(), cookie, NonHTTP));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,8 @@ impl HTMLBaseElement {
|
||||||
let href = ElementCast::from_ref(self).get_attribute(&ns!(""), &atom!("href"))
|
let href = ElementCast::from_ref(self).get_attribute(&ns!(""), &atom!("href"))
|
||||||
.expect("The frozen base url is only defined for base elements \
|
.expect("The frozen base url is only defined for base elements \
|
||||||
that have a base url.");
|
that have a base url.");
|
||||||
let base = document_from_node(self).fallback_base_url();
|
let document = document_from_node(self);
|
||||||
|
let base = document.fallback_base_url();
|
||||||
let parsed = UrlParser::new().base_url(&base).parse(&href.value());
|
let parsed = UrlParser::new().base_url(&base).parse(&href.value());
|
||||||
parsed.unwrap_or(base)
|
parsed.unwrap_or(base)
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,8 @@ impl VirtualMethods for HTMLBodyElement {
|
||||||
},
|
},
|
||||||
(&atom!(background), _) => {
|
(&atom!(background), _) => {
|
||||||
*self.background.borrow_mut() = mutation.new_value(attr).and_then(|value| {
|
*self.background.borrow_mut() = mutation.new_value(attr).and_then(|value| {
|
||||||
let base = document_from_node(self).url();
|
let document = document_from_node(self);
|
||||||
|
let base = document.url();
|
||||||
UrlParser::new().base_url(&base).parse(&value).ok()
|
UrlParser::new().base_url(&base).parse(&value).ok()
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -187,7 +187,8 @@ impl HTMLFormElement {
|
||||||
}
|
}
|
||||||
// TODO: Resolve the url relative to the submitter element
|
// TODO: Resolve the url relative to the submitter element
|
||||||
// Step 10-15
|
// Step 10-15
|
||||||
let action_components = UrlParser::new().base_url(&base).parse(&action).unwrap_or(base);
|
let action_components =
|
||||||
|
UrlParser::new().base_url(base).parse(&action).unwrap_or((*base).clone());
|
||||||
let _action = action_components.serialize();
|
let _action = action_components.serialize();
|
||||||
let scheme = action_components.scheme.clone();
|
let scheme = action_components.scheme.clone();
|
||||||
let enctype = submitter.enctype();
|
let enctype = submitter.enctype();
|
||||||
|
|
|
@ -1715,7 +1715,7 @@ impl Node {
|
||||||
};
|
};
|
||||||
let window = document.window();
|
let window = document.window();
|
||||||
let loader = DocumentLoader::new(&*document.loader());
|
let loader = DocumentLoader::new(&*document.loader());
|
||||||
let document = Document::new(window.r(), Some(document.url()),
|
let document = Document::new(window.r(), Some((*document.url()).clone()),
|
||||||
is_html_doc, None,
|
is_html_doc, None,
|
||||||
None, DocumentSource::NotFromParser, loader);
|
None, DocumentSource::NotFromParser, loader);
|
||||||
NodeCast::from_root(document)
|
NodeCast::from_root(document)
|
||||||
|
|
|
@ -1098,7 +1098,7 @@ impl Window {
|
||||||
|
|
||||||
pub fn get_url(&self) -> Url {
|
pub fn get_url(&self) -> Url {
|
||||||
let doc = self.Document();
|
let doc = self.Document();
|
||||||
doc.r().url()
|
(*doc.r().url()).clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resource_task(&self) -> ResourceTask {
|
pub fn resource_task(&self) -> ResourceTask {
|
||||||
|
|
|
@ -1909,7 +1909,7 @@ impl ScriptTask {
|
||||||
window.r().set_fragment_name(final_url.fragment.clone());
|
window.r().set_fragment_name(final_url.fragment.clone());
|
||||||
|
|
||||||
// Notify devtools that a new script global exists.
|
// Notify devtools that a new script global exists.
|
||||||
self.notify_devtools(document.r().Title(), final_url, (id, None));
|
self.notify_devtools(document.r().Title(), (*final_url).clone(), (id, None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,6 +182,7 @@ pub fn handle_get_name(page: &Rc<Page>,
|
||||||
pub fn handle_get_url(page: &Rc<Page>,
|
pub fn handle_get_url(page: &Rc<Page>,
|
||||||
_pipeline: PipelineId,
|
_pipeline: PipelineId,
|
||||||
reply: IpcSender<Url>) {
|
reply: IpcSender<Url>) {
|
||||||
let url = page.document().r().url();
|
let document = page.document();
|
||||||
reply.send(url).unwrap();
|
let url = document.r().url();
|
||||||
|
reply.send((*url).clone()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue