Make Document::DefaultView return a null value when there's no browsing context

This commit is contained in:
Kosov Eugene 2016-06-04 23:42:43 +03:00
parent a80767993b
commit 3bb093cc16
7 changed files with 66 additions and 28 deletions

View file

@ -2551,8 +2551,12 @@ impl DocumentMethods for Document {
}
// https://html.spec.whatwg.org/multipage/#dom-document-defaultview
fn DefaultView(&self) -> Root<Window> {
Root::from_ref(&*self.window)
fn GetDefaultView(&self) -> Option<Root<Window>> {
if self.browsing_context.is_none() {
None
} else {
Some(Root::from_ref(&*self.window))
}
}
// https://html.spec.whatwg.org/multipage/#dom-document-cookie

View file

@ -1297,7 +1297,10 @@ impl Element {
}
// Step 5
let win = doc.DefaultView();
let win = match doc.GetDefaultView() {
None => return,
Some(win) => win,
};
// Step 7
if *self.root_element() == *self {
@ -1635,7 +1638,10 @@ impl ElementMethods for Element {
}
// Step 3
let win = doc.DefaultView();
let win = match doc.GetDefaultView() {
None => return 0.0,
Some(win) => win,
};
// Step 5
if *self.root_element() == *self {
@ -1683,7 +1689,10 @@ impl ElementMethods for Element {
}
// Step 5
let win = doc.DefaultView();
let win = match doc.GetDefaultView() {
None => return,
Some(win) => win,
};
// Step 7
if *self.root_element() == *self {
@ -1721,7 +1730,10 @@ impl ElementMethods for Element {
}
// Step 3
let win = doc.DefaultView();
let win = match doc.GetDefaultView() {
None => return 0.0,
Some(win) => win,
};
// Step 5
if *self.root_element() == *self {
@ -1769,7 +1781,10 @@ impl ElementMethods for Element {
}
// Step 5
let win = doc.DefaultView();
let win = match doc.GetDefaultView() {
None => return,
Some(win) => win,
};
// Step 7
if *self.root_element() == *self {

View file

@ -118,7 +118,7 @@ partial /*sealed*/ interface Document {
// void writeln(DOMString... text);
// user interaction
readonly attribute Window/*Proxy?*/ defaultView;
readonly attribute Window?/*Proxy?*/ defaultView;
readonly attribute Element? activeElement;
boolean hasFocus();
// attribute DOMString designMode;