diff options
author | Maciej Skrzypkowski <m.skrzypkows@samsung.com> | 2015-07-22 22:31:29 +0200 |
---|---|---|
committer | Maciej Skrzypkowski <m.skrzypkows@samsung.com> | 2015-08-10 21:23:09 +0200 |
commit | 07c0cd8a18dd7421a1670829106d40e2037c1b8c (patch) | |
tree | c5a8ffff626c74a04e2746b284e30d9a144f91eb /components/script/dom/document.rs | |
parent | 8edf1a5ecdecc9f6de8210fc875cff3679fda09e (diff) | |
download | servo-07c0cd8a18dd7421a1670829106d40e2037c1b8c.tar.gz servo-07c0cd8a18dd7421a1670829106d40e2037c1b8c.zip |
Implementing document.hasFocus method. #6475
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r-- | components/script/dom/document.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index d074dca0d4e..37043adb4ae 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -1183,6 +1183,27 @@ impl<'a> DocumentMethods for &'a Document { } } + // https://html.spec.whatwg.org/#dom-document-hasfocus + fn HasFocus(self) -> bool { + let target = self; // Step 1. + let window = self.window.root(); + let window = window.r(); + let browsing_context = window.browsing_context(); + let browsing_context = browsing_context.as_ref(); + + match browsing_context { + Some(browsing_context) => { + let condidate = browsing_context.active_document(); // Step 2. + if condidate.node.get_unique_id() == target.node.get_unique_id() { // Step 3. + true + } else { + false //TODO Step 4. + } + } + None => false + } + } + // https://dom.spec.whatwg.org/#dom-document-documenturi fn DocumentURI(self) -> DOMString { self.URL() |