mirror of
https://github.com/servo/servo.git
synced 2025-07-28 17:50:37 +01:00
Implementing document.hasFocus method. #6475
This commit is contained in:
parent
8edf1a5ecd
commit
07c0cd8a18
3 changed files with 22 additions and 7 deletions
|
@ -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()
|
||||
|
|
|
@ -114,7 +114,7 @@ partial /*sealed*/ interface Document {
|
|||
// user interaction
|
||||
readonly attribute Window/*Proxy?*/ defaultView;
|
||||
// readonly attribute Element? activeElement;
|
||||
// boolean hasFocus();
|
||||
boolean hasFocus();
|
||||
// attribute DOMString designMode;
|
||||
// boolean execCommand(DOMString commandId, optional boolean showUI = false, optional DOMString value = "");
|
||||
// boolean queryCommandEnabled(DOMString commandId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue