Bug 766066 - Part 0: Rename some B2G keyboard functions. r=djf
authorChris Peterson <cpeterson@mozilla.com>
Tue, 18 Dec 2012 15:10:18 -0800
changeset 116583 c2b6362784c219a350863e460c5950e0e288c8c2
parent 116582 42213ca59024f89cdd34a7081c184ac60e2d3600
child 116584 69b6541efafcb30fc34979167903b9c7c84f6a90
push idunknown
push userunknown
push dateunknown
reviewersdjf
bugs766066
milestone20.0a1
Bug 766066 - Part 0: Rename some B2G keyboard functions. r=djf
b2g/chrome/content/forms.js
--- a/b2g/chrome/content/forms.js
+++ b/b2g/chrome/content/forms.js
@@ -89,39 +89,39 @@ let FormAssistant = {
     let target = evt.target;
 
     switch (evt.type) {
       case "focus":
         if (this.isTextInputElement(target) && this.isIMEDisabled())
           return;
 
         if (target && this.isFocusableElement(target))
-          this.handleIMEStateEnabled(target);
+          this.showKeyboard(target);
         break;
 
       case "blur":
         if (this.focusedElement)
-          this.handleIMEStateDisabled();
+          this.hideKeyboard();
         break;
 
       case 'mousedown':
         // We only listen for this event on the currently focused element.
         // When the mouse goes down, note the cursor/selection position
         this.selectionStart = this.focusedElement.selectionStart;
         this.selectionEnd = this.focusedElement.selectionEnd;
         break;
 
       case 'mouseup':
         // We only listen for this event on the currently focused element.
         // When the mouse goes up, see if the cursor has moved (or the
         // selection changed) since the mouse went down. If it has, we
         // need to tell the keyboard about it
         if (this.focusedElement.selectionStart !== this.selectionStart ||
             this.focusedElement.selectionEnd !== this.selectionEnd) {
-          this.tryShowIme(this.focusedElement);
+          this.sendKeyboardState(this.focusedElement);
         }
         break;
 
       case "resize":
         if (!this.isKeyboardOpened)
           return;
 
         if (this.scrollIntoViewTimeout) {
@@ -198,19 +198,19 @@ let FormAssistant = {
       case "ime-enabled-state-changed":
         let shouldOpen = parseInt(data);
         let target = Services.fm.focusedElement;
         if (!target || !this.isTextInputElement(target))
           return;
 
         if (shouldOpen) {
           if (!this.focusedElement && this.isFocusableElement(target))
-            this.handleIMEStateEnabled(target);
+            this.showKeyboard(target);
         } else if (this._focusedElement == target) {
-          this.handleIMEStateDisabled();
+          this.hideKeyboard();
         }
         break;
 
       case "xpcom-shutdown":
         Services.obs.removeObserver(this, "ime-enabled-state-changed", false);
         Services.obs.removeObserver(this, "xpcom-shutdown");
         removeMessageListener("Forms:Select:Choice", this);
         removeMessageListener("Forms:Input:Value", this);
@@ -222,31 +222,31 @@ let FormAssistant = {
     let disabled = false;
     try {
       disabled = domWindowUtils.IMEStatus == domWindowUtils.IME_STATUS_DISABLED;
     } catch (e) {}
 
     return disabled;
   },
 
-  handleIMEStateEnabled: function fa_handleIMEStateEnabled(target) {
+  showKeyboard: function fa_showKeyboard(target) {
     if (this.isKeyboardOpened)
       return;
 
     if (target instanceof HTMLOptionElement)
       target = target.parentNode;
 
-    let kbOpened = this.tryShowIme(target);
+    let kbOpened = this.sendKeyboardState(target);
     if (this.isTextInputElement(target))
       this.isKeyboardOpened = kbOpened;
 
     this.setFocusedElement(target);
   },
 
-  handleIMEStateDisabled: function fa_handleIMEStateDisabled() {
+  hideKeyboard: function fa_hideKeyboard() {
     sendAsyncMessage("Forms:Input", { "type": "blur" });
     this.isKeyboardOpened = false;
     this.setFocusedElement(null);
   },
 
   isFocusableElement: function fa_isFocusableElement(element) {
     if (element.contentEditable && element.contentEditable == "true") {
       return true;
@@ -265,17 +265,17 @@ let FormAssistant = {
   },
 
   isTextInputElement: function fa_isTextInputElement(element) {
     return element instanceof HTMLInputElement ||
            element instanceof HTMLTextAreaElement ||
            (element.contentEditable && element.contentEditable == "true");
   },
 
-  tryShowIme: function(element) {
+  sendKeyboardState: function(element) {
     // FIXME/bug 729623: work around apparent bug in the IME manager
     // in gecko.
     let readonly = element.getAttribute("readonly");
     if (readonly) {
       return false;
     }
 
     sendAsyncMessage("Forms:Input", getJSON(element));