aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/document.rs
diff options
context:
space:
mode:
authorDavide Giovannini <giovannini.davide90@gmail.com>2016-06-07 20:36:29 +0200
committerDavide Giovannini <giovannini.davide90@gmail.com>2016-06-07 20:36:29 +0200
commit35aa24eb4c4bbb9ee8b6e7bd2c083d4584321f07 (patch)
treeaa89bc00a0e6ec0d6eef0d9a58dab291cd95437c /components/script/dom/document.rs
parentf56848a0e8a9137f128088d1dd0f86e11fad841a (diff)
downloadservo-35aa24eb4c4bbb9ee8b6e7bd2c083d4584321f07.tar.gz
servo-35aa24eb4c4bbb9ee8b6e7bd2c083d4584321f07.zip
Fixed issue #11651 (Do not fire a blur event when calling .focus() on a focused element)
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r--components/script/dom/document.rs40
1 files changed, 21 insertions, 19 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 0897ccc24ae..bb3d59307b3 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -598,25 +598,27 @@ impl Document {
/// Reassign the focus context to the element that last requested focus during this
/// transaction, or none if no elements requested it.
pub fn commit_focus_transaction(&self, focus_type: FocusType) {
- if let Some(ref elem) = self.focused.get() {
- let node = elem.upcast::<Node>();
- elem.set_focus_state(false);
- // FIXME: pass appropriate relatedTarget
- self.fire_focus_event(FocusEventType::Blur, node, None);
- }
-
- self.focused.set(self.possibly_focused.get().r());
-
- if let Some(ref elem) = self.focused.get() {
- elem.set_focus_state(true);
- let node = elem.upcast::<Node>();
- // FIXME: pass appropriate relatedTarget
- self.fire_focus_event(FocusEventType::Focus, node, None);
- // Update the focus state for all elements in the focus chain.
- // https://html.spec.whatwg.org/multipage/#focus-chain
- if focus_type == FocusType::Element {
- let event = ConstellationMsg::Focus(self.window.pipeline());
- self.window.constellation_chan().send(event).unwrap();
+ if self.focused != self.possibly_focused.get().r() {
+ if let Some(ref elem) = self.focused.get() {
+ let node = elem.upcast::<Node>();
+ elem.set_focus_state(false);
+ // FIXME: pass appropriate relatedTarget
+ self.fire_focus_event(FocusEventType::Blur, node, None);
+ }
+
+ self.focused.set(self.possibly_focused.get().r());
+
+ if let Some(ref elem) = self.focused.get() {
+ elem.set_focus_state(true);
+ let node = elem.upcast::<Node>();
+ // FIXME: pass appropriate relatedTarget
+ self.fire_focus_event(FocusEventType::Focus, node, None);
+ // Update the focus state for all elements in the focus chain.
+ // https://html.spec.whatwg.org/multipage/#focus-chain
+ if focus_type == FocusType::Element {
+ let event = ConstellationMsg::Focus(self.window.pipeline());
+ self.window.constellation_chan().send(event).unwrap();
+ }
}
}
}