aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/document.rs
diff options
context:
space:
mode:
authorMaciej Skrzypkowski <m.skrzypkows@samsung.com>2015-07-22 22:31:29 +0200
committerMaciej Skrzypkowski <m.skrzypkows@samsung.com>2015-08-10 21:23:09 +0200
commit07c0cd8a18dd7421a1670829106d40e2037c1b8c (patch)
treec5a8ffff626c74a04e2746b284e30d9a144f91eb /components/script/dom/document.rs
parent8edf1a5ecdecc9f6de8210fc875cff3679fda09e (diff)
downloadservo-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.rs21
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()