Bug 417315 Cannot use IME menus during IME transaction #2 r=peterv+enndeakin, sr=peterv, a1.9=beltzner
authormasayuki@d-toybox.com
Tue, 19 Feb 2008 23:18:53 -0800
changeset 11912 0b329d9345ac3040f8bf1c984c13f25be6f69650
parent 11911 50defedcb2ae56516cdc77a7ada0b651ef8a8ebd
child 11913 3f626d2077d474219f6fb37df57389c95fa128eb
push idunknown
push userunknown
push dateunknown
reviewerspeterv, peterv
bugs417315
milestone1.9b4pre
Bug 417315 Cannot use IME menus during IME transaction #2 r=peterv+enndeakin, sr=peterv, a1.9=beltzner
editor/idl/nsIEditorIMESupport.idl
editor/libeditor/base/nsEditor.cpp
toolkit/content/widgets/textbox.xml
--- a/editor/idl/nsIEditorIMESupport.idl
+++ b/editor/idl/nsIEditorIMESupport.idl
@@ -47,17 +47,17 @@ struct nsQueryCaretRectEventReply;
 %}
 
 [ptr] native nsIPrivateTextRangeListPtr(nsIPrivateTextRangeList);
 [ptr] native nsTextEventReplyPtr(nsTextEventReply);
 [ptr] native nsReconversionEventReplyPtr(nsReconversionEventReply);
 [ptr] native nsQueryCaretRectEventReplyPtr(nsQueryCaretRectEventReply);
 
 
-[scriptable, uuid(228a76d3-5462-4322-a63c-5f94f7f5d4ed)]
+[scriptable, uuid(ce1c0424-c3c0-44b0-97d6-df12deb19d45)]
 
 interface nsIEditorIMESupport : nsISupports
 {
 
 
   /**
    * beginComposition(nsTextEventReply* aReply) Handles the start of inline input composition.
    */
@@ -113,10 +113,15 @@ interface nsIEditorIMESupport : nsISuppo
 
   [noscript] void getQueryCaretRect(in nsQueryCaretRectEventReplyPtr aReply);
 
   /**
    * Get preferred IME status of current widget.
    */
 
   [noscript] void getPreferredIMEState(out unsigned long aState);
+
+  /**
+   * whether this editor has active IME transaction
+   */
+  readonly attribute boolean composing;
 };
 
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -2241,16 +2241,24 @@ nsEditor::GetPreferredIMEState(PRUint32 
       *aState |= nsIContent::IME_STATUS_CLOSE;
       break;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsEditor::GetComposing(PRBool* aResult)
+{
+  NS_ENSURE_ARG_POINTER(aResult);
+  *aResult = IsIMEComposing();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsEditor::GetReconversionString(nsReconversionEventReply* aReply)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsEditor::GetQueryCaretRect(nsQueryCaretRectEventReply* aReply)
 {
--- a/toolkit/content/widgets/textbox.xml
+++ b/toolkit/content/widgets/textbox.xml
@@ -227,18 +227,25 @@
 
           if (!this.hasAttribute("focused")) {
             if (event.originalTarget == this)
               this.inputField.focus(); // Forward focus to actual HTML input
             else if (event.originalTarget != this.inputField)
               return; // Allow other children (e.g. URL bar buttons) to get focus
             else if (this.mIgnoreFocus)
               this.mIgnoreFocus = false;
-            else if (this.clickSelectsAll)
-              this.editor.selectAll();
+            else if (this.clickSelectsAll) {
+              try {
+                const nsIEditorIMESupport =
+                        Components.interfaces.nsIEditorIMESupport;
+                var imeEditor = this.editor.QueryInterface(nsIEditorIMESupport);
+                if (!imeEditor || !imeEditor.composing)
+                  this.editor.selectAll();
+              } catch (e) {}
+            }
 
             this.setAttribute("focused", "true");
           }
         ]]>
       </handler>
 
       <handler event="blur" phase="capturing">
         <![CDATA[