aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorDavide Giovannini <giovannini.davide90@gmail.com>2016-06-10 11:36:08 +0200
committerDavide Giovannini <giovannini.davide90@gmail.com>2016-06-10 11:36:08 +0200
commit01c3640e5fd957fc946c25708cdd8c364f5a59ad (patch)
tree0f735ddf9518227063e160b86daefd8159f836f9 /components/script
parent35aa24eb4c4bbb9ee8b6e7bd2c083d4584321f07 (diff)
downloadservo-01c3640e5fd957fc946c25708cdd8c364f5a59ad.tar.gz
servo-01c3640e5fd957fc946c25708cdd8c364f5a59ad.zip
fixup! Fixed issue #11651 (Do not fire a blur event when calling .focus() on a focused element)
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/document.rs43
-rw-r--r--components/script/dom/htmlelement.rs3
2 files changed, 22 insertions, 24 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index bb3d59307b3..6de4ee8ecb5 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -598,27 +598,28 @@ 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 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();
- }
+ if self.focused == self.possibly_focused.get().r() {
+ return
+ }
+ 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();
}
}
}
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index e016f7076d9..086eb6ff687 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -251,9 +251,6 @@ impl HTMLElementMethods for HTMLElement {
fn Focus(&self) {
// TODO: Mark the element as locked for focus and run the focusing steps.
// https://html.spec.whatwg.org/multipage/#focusing-steps
- if self.upcast::<Element>().focus_state() {
- return;
- }
let document = document_from_node(self);
document.begin_focus_transaction();
document.request_focus(self.upcast());