mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
iframe: use value of name attr to set nested bc name
This commit is contained in:
parent
e27ba16c3f
commit
a0082c57c8
1 changed files with 14 additions and 1 deletions
|
@ -76,6 +76,7 @@ pub struct HTMLIFrameElement {
|
|||
sandbox_allowance: Cell<Option<SandboxAllowance>>,
|
||||
load_blocker: DomRefCell<Option<LoadBlocker>>,
|
||||
visibility: Cell<bool>,
|
||||
name: DomRefCell<DOMString>,
|
||||
}
|
||||
|
||||
impl HTMLIFrameElement {
|
||||
|
@ -223,6 +224,16 @@ impl HTMLIFrameElement {
|
|||
return;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#attr-iframe-name
|
||||
// Note: the spec says to set the name 'when the nested browsing context is created'.
|
||||
// The current implementation sets the name on the window,
|
||||
// when the iframe attributes are first processed.
|
||||
if mode == ProcessingMode::FirstTime {
|
||||
if let Some(window) = self.GetContentWindow() {
|
||||
window.set_name(self.name.borrow().clone())
|
||||
}
|
||||
}
|
||||
|
||||
let url = self.get_url();
|
||||
|
||||
// TODO: check ancestor browsing contexts for same URL
|
||||
|
@ -299,6 +310,7 @@ impl HTMLIFrameElement {
|
|||
sandbox_allowance: Cell::new(None),
|
||||
load_blocker: DomRefCell::new(None),
|
||||
visibility: Cell::new(true),
|
||||
name: DomRefCell::new(DOMString::new())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -471,6 +483,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-name
|
||||
fn SetName(&self, name: DOMString) {
|
||||
*self.name.borrow_mut() = name.clone();
|
||||
if let Some(window) = self.GetContentWindow() {
|
||||
window.set_name(name)
|
||||
}
|
||||
|
@ -481,7 +494,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
|
|||
if let Some(window) = self.GetContentWindow() {
|
||||
window.get_name()
|
||||
} else {
|
||||
DOMString::new()
|
||||
self.name.borrow().clone()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue