mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Return a Url from HTMLIFrameElement::get_url.
Since Url::origin() always returns an opaque origin for about: urls, I don't believe this changes behaviour.
This commit is contained in:
parent
5358df5a16
commit
68076fbd7b
1 changed files with 8 additions and 13 deletions
|
@ -76,7 +76,9 @@ impl HTMLIFrameElement {
|
||||||
self.sandbox.get().is_some()
|
self.sandbox.get().is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_url(&self) -> Option<Url> {
|
/// <https://html.spec.whatwg.org/multipage/#otherwise-steps-for-iframe-or-frame-elements>,
|
||||||
|
/// step 1.
|
||||||
|
fn get_url(&self) -> Url {
|
||||||
let element = self.upcast::<Element>();
|
let element = self.upcast::<Element>();
|
||||||
element.get_attribute(&ns!(), &atom!("src")).and_then(|src| {
|
element.get_attribute(&ns!(), &atom!("src")).and_then(|src| {
|
||||||
let url = src.value();
|
let url = src.value();
|
||||||
|
@ -85,7 +87,7 @@ impl HTMLIFrameElement {
|
||||||
} else {
|
} else {
|
||||||
document_from_node(self).base_url().join(&url).ok()
|
document_from_node(self).base_url().join(&url).ok()
|
||||||
}
|
}
|
||||||
})
|
}).unwrap_or_else(|| Url::parse("about:blank").unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate_new_subpage_id(&self) -> (SubpageId, Option<SubpageId>) {
|
pub fn generate_new_subpage_id(&self) -> (SubpageId, Option<SubpageId>) {
|
||||||
|
@ -144,10 +146,7 @@ impl HTMLIFrameElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_the_iframe_attributes(&self) {
|
pub fn process_the_iframe_attributes(&self) {
|
||||||
let url = match self.get_url() {
|
let url = self.get_url();
|
||||||
Some(url) => url,
|
|
||||||
None => Url::parse("about:blank").unwrap(),
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO - loaddata here should have referrer info (not None, None)
|
// TODO - loaddata here should have referrer info (not None, None)
|
||||||
self.navigate_or_reload_child_browsing_context(Some(LoadData::new(url, None, None)));
|
self.navigate_or_reload_child_browsing_context(Some(LoadData::new(url, None, None)));
|
||||||
|
@ -430,10 +429,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument
|
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument
|
||||||
fn GetContentDocument(&self) -> Option<Root<Document>> {
|
fn GetContentDocument(&self) -> Option<Root<Document>> {
|
||||||
self.GetContentWindow().and_then(|window| {
|
self.GetContentWindow().and_then(|window| {
|
||||||
let self_url = match self.get_url() {
|
let self_url = self.get_url();
|
||||||
Some(self_url) => self_url,
|
|
||||||
None => return None,
|
|
||||||
};
|
|
||||||
let win_url = window_from_node(self).get_url();
|
let win_url = window_from_node(self).get_url();
|
||||||
|
|
||||||
if UrlHelper::SameOrigin(&self_url, &win_url) {
|
if UrlHelper::SameOrigin(&self_url, &win_url) {
|
||||||
|
@ -585,11 +581,10 @@ impl VirtualMethods for HTMLIFrameElement {
|
||||||
// Since most of this cleanup doesn't happen on same-origin
|
// Since most of this cleanup doesn't happen on same-origin
|
||||||
// iframes, and since that would cause a deadlock, don't do it.
|
// iframes, and since that would cause a deadlock, don't do it.
|
||||||
let ConstellationChan(ref chan) = *window.constellation_chan();
|
let ConstellationChan(ref chan) = *window.constellation_chan();
|
||||||
let same_origin = if let Some(self_url) = self.get_url() {
|
let same_origin = {
|
||||||
|
let self_url = self.get_url();
|
||||||
let win_url = window_from_node(self).get_url();
|
let win_url = window_from_node(self).get_url();
|
||||||
UrlHelper::SameOrigin(&self_url, &win_url)
|
UrlHelper::SameOrigin(&self_url, &win_url)
|
||||||
} else {
|
|
||||||
false
|
|
||||||
};
|
};
|
||||||
let (sender, receiver) = if same_origin {
|
let (sender, receiver) = if same_origin {
|
||||||
(None, None)
|
(None, None)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue