diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-04-04 18:21:48 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-04-04 18:21:48 -0600 |
commit | b63fb0c0a7e9cd9208d66319c910750aaaac844c (patch) | |
tree | 730bee60cc0d1a43e248f5a60d2c8616e22fdf48 /components/script/dom/document.rs | |
parent | 8758d7d11abd3a0e84e2af5c41911b767723513e (diff) | |
parent | 791fa3757dd11b53c9ef7ef112f460675eddea17 (diff) | |
download | servo-b63fb0c0a7e9cd9208d66319c910750aaaac844c.tar.gz servo-b63fb0c0a7e9cd9208d66319c910750aaaac844c.zip |
auto merge of #5461 : mbrubeck/servo/focus, r=jdm
Fixes #5460. This supports for simple focusable elements that are their own DOM anchors, like text `input` fields.
Requires servo/rust-selectors#20. r? @SimonSapin
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r-- | components/script/dom/document.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 5cb13ac18e9..49eaef294d5 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -454,7 +454,20 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> { /// transaction, or none if no elements requested it. fn commit_focus_transaction(self) { //TODO: dispatch blur, focus, focusout, and focusin events + + if let Some(ref elem) = self.focused.get().root() { + let node: JSRef<Node> = NodeCast::from_ref(elem.r()); + node.set_focus_state(false); + } + self.focused.assign(self.possibly_focused.get()); + + if let Some(ref elem) = self.focused.get().root() { + let node: JSRef<Node> = NodeCast::from_ref(elem.r()); + node.set_focus_state(true); + } + // TODO: Update the focus state for all elements in the focus chain. + // https://html.spec.whatwg.org/multipage/interaction.html#focus-chain } /// Handles any updates when the document's title has changed. |