mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #9714 - servo:browsingcontext, r=nox
Improvements to Documents' browsing contexts. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9714) <!-- Reviewable:end -->
This commit is contained in:
commit
f5193ebd82
3 changed files with 13 additions and 10 deletions
|
@ -314,8 +314,10 @@ impl Document {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#fully-active
|
// https://html.spec.whatwg.org/multipage/#fully-active
|
||||||
pub fn is_fully_active(&self) -> bool {
|
pub fn is_fully_active(&self) -> bool {
|
||||||
let browsing_context = self.window.browsing_context();
|
let browsing_context = match self.browsing_context() {
|
||||||
let browsing_context = browsing_context.as_ref().unwrap();
|
Some(browsing_context) => browsing_context,
|
||||||
|
None => return false,
|
||||||
|
};
|
||||||
let active_document = browsing_context.active_document();
|
let active_document = browsing_context.active_document();
|
||||||
|
|
||||||
if self != &*active_document {
|
if self != &*active_document {
|
||||||
|
@ -1766,17 +1768,12 @@ impl DocumentMethods for Document {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-document-hasfocus
|
// https://html.spec.whatwg.org/multipage/#dom-document-hasfocus
|
||||||
fn HasFocus(&self) -> bool {
|
fn HasFocus(&self) -> bool {
|
||||||
// Step 1.
|
match self.browsing_context() {
|
||||||
let target = self;
|
|
||||||
let browsing_context = self.window.browsing_context();
|
|
||||||
let browsing_context = browsing_context.as_ref();
|
|
||||||
|
|
||||||
match browsing_context {
|
|
||||||
Some(browsing_context) => {
|
Some(browsing_context) => {
|
||||||
// Step 2.
|
// Step 2.
|
||||||
let candidate = browsing_context.active_document();
|
let candidate = browsing_context.active_document();
|
||||||
// Step 3.
|
// Step 3.
|
||||||
if &*candidate == target {
|
if &*candidate == self {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false //TODO Step 4.
|
false //TODO Step 4.
|
||||||
|
|
|
@ -71,6 +71,7 @@ impl DOMImplementationMethods for DOMImplementation {
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let doc = XMLDocument::new(win,
|
let doc = XMLDocument::new(win,
|
||||||
|
None,
|
||||||
None,
|
None,
|
||||||
IsHTMLDocument::NonHTMLDocument,
|
IsHTMLDocument::NonHTMLDocument,
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -11,6 +11,7 @@ use dom::bindings::global::GlobalRef;
|
||||||
use dom::bindings::inheritance::Castable;
|
use dom::bindings::inheritance::Castable;
|
||||||
use dom::bindings::js::{Root, RootedReference};
|
use dom::bindings::js::{Root, RootedReference};
|
||||||
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
|
use dom::bindings::reflector::{Reflectable, reflect_dom_object};
|
||||||
|
use dom::browsingcontext::BrowsingContext;
|
||||||
use dom::document::{Document, DocumentSource, IsHTMLDocument};
|
use dom::document::{Document, DocumentSource, IsHTMLDocument};
|
||||||
use dom::location::Location;
|
use dom::location::Location;
|
||||||
use dom::node::Node;
|
use dom::node::Node;
|
||||||
|
@ -27,6 +28,7 @@ pub struct XMLDocument {
|
||||||
|
|
||||||
impl XMLDocument {
|
impl XMLDocument {
|
||||||
fn new_inherited(window: &Window,
|
fn new_inherited(window: &Window,
|
||||||
|
browsing_context: Option<&BrowsingContext>,
|
||||||
url: Option<Url>,
|
url: Option<Url>,
|
||||||
is_html_document: IsHTMLDocument,
|
is_html_document: IsHTMLDocument,
|
||||||
content_type: Option<DOMString>,
|
content_type: Option<DOMString>,
|
||||||
|
@ -35,7 +37,7 @@ impl XMLDocument {
|
||||||
doc_loader: DocumentLoader) -> XMLDocument {
|
doc_loader: DocumentLoader) -> XMLDocument {
|
||||||
XMLDocument {
|
XMLDocument {
|
||||||
document: Document::new_inherited(window,
|
document: Document::new_inherited(window,
|
||||||
None,
|
browsing_context,
|
||||||
url,
|
url,
|
||||||
is_html_document,
|
is_html_document,
|
||||||
content_type,
|
content_type,
|
||||||
|
@ -46,6 +48,7 @@ impl XMLDocument {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(window: &Window,
|
pub fn new(window: &Window,
|
||||||
|
browsing_context: Option<&BrowsingContext>,
|
||||||
url: Option<Url>,
|
url: Option<Url>,
|
||||||
doctype: IsHTMLDocument,
|
doctype: IsHTMLDocument,
|
||||||
content_type: Option<DOMString>,
|
content_type: Option<DOMString>,
|
||||||
|
@ -55,6 +58,7 @@ impl XMLDocument {
|
||||||
-> Root<XMLDocument> {
|
-> Root<XMLDocument> {
|
||||||
let doc = reflect_dom_object(
|
let doc = reflect_dom_object(
|
||||||
box XMLDocument::new_inherited(window,
|
box XMLDocument::new_inherited(window,
|
||||||
|
browsing_context,
|
||||||
url,
|
url,
|
||||||
doctype,
|
doctype,
|
||||||
content_type,
|
content_type,
|
||||||
|
@ -77,6 +81,7 @@ impl XMLDocument {
|
||||||
let docloader = DocumentLoader::new(&*doc.loader());
|
let docloader = DocumentLoader::new(&*doc.loader());
|
||||||
|
|
||||||
Ok(XMLDocument::new(win,
|
Ok(XMLDocument::new(win,
|
||||||
|
None,
|
||||||
None,
|
None,
|
||||||
IsHTMLDocument::NonHTMLDocument,
|
IsHTMLDocument::NonHTMLDocument,
|
||||||
None,
|
None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue