From 9ec19c1ccc78f05b6fd79621d5173929e72c1de5 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Wed, 19 Dec 2012 11:49:23 -0800 Subject: [PATCH] Bug 766066 - Part 2: Handle element focus and IME state separately. r=djf --HG-- extra : rebase_source : 337546eaa5a10386bd05cc52e3af65ccdaf422fa --- b2g/chrome/content/forms.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/b2g/chrome/content/forms.js b/b2g/chrome/content/forms.js index 294f14e5eff..e5b237bc097 100644 --- a/b2g/chrome/content/forms.js +++ b/b2g/chrome/content/forms.js @@ -64,6 +64,9 @@ let FormAssistant = { }, setFocusedElement: function fa_setFocusedElement(element) { + if (element instanceof HTMLOptionElement) + element = element.parentNode; + if (element === this.focusedElement) return; @@ -92,13 +95,16 @@ let FormAssistant = { if (this.isTextInputElement(target) && this.isIMEDisabled()) return; - if (target && this.isFocusableElement(target)) + if (target && this.isFocusableElement(target)) { + this.setFocusedElement(target); this.showKeyboard(target); + } break; case "blur": if (this.focusedElement) this.hideKeyboard(); + this.setFocusedElement(null); break; case 'mousedown': @@ -211,24 +217,19 @@ let FormAssistant = { return disabled; }, - showKeyboard: function fa_showKeyboard(target) { + showKeyboard: function fa_showKeyboard() { if (this.isKeyboardOpened) return; - if (target instanceof HTMLOptionElement) - target = target.parentNode; - + let target = this.focusedElement; let kbOpened = this.sendKeyboardState(target); if (this.isTextInputElement(target)) this.isKeyboardOpened = kbOpened; - - this.setFocusedElement(target); }, hideKeyboard: function fa_hideKeyboard() { sendAsyncMessage("Forms:Input", { "type": "blur" }); this.isKeyboardOpened = false; - this.setFocusedElement(null); }, isFocusableElement: function fa_isFocusableElement(element) {