Bug 917322 part.9 TextEventDispatcher::CommitComposition() should return error if caller tries to commit composition non-existing composition with the last data or empty string r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 28 Jan 2015 15:27:32 +0900
changeset 239580 0458d8e6291e3f2c4039fa02f874fba357f1637b
parent 239579 a80685d0ff6f1766090a9dc3aa995b4f0cc7847f
child 239581 f341e1c47a1a1e2f3883f0effdfdde717ae1ef31
push id500
push userjoshua.m.grant@gmail.com
push dateThu, 29 Jan 2015 01:48:36 +0000
reviewerssmaug
bugs917322
milestone38.0a1
Bug 917322 part.9 TextEventDispatcher::CommitComposition() should return error if caller tries to commit composition non-existing composition with the last data or empty string r=smaug
widget/TextEventDispatcher.cpp
--- a/widget/TextEventDispatcher.cpp
+++ b/widget/TextEventDispatcher.cpp
@@ -146,16 +146,24 @@ TextEventDispatcher::CommitComposition(n
 {
   aStatus = nsEventStatus_eIgnore;
 
   nsresult rv = GetState();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
+  // When there is no composition, caller shouldn't try to commit composition
+  // with non-existing composition string nor commit composition with empty
+  // string.
+  if (NS_WARN_IF(!IsComposing() &&
+                 (!aCommitString || aCommitString->IsEmpty()))) {
+    return NS_ERROR_FAILURE;
+  }
+
   nsCOMPtr<nsIWidget> widget(mWidget);
   rv = StartCompositionAutomaticallyIfNecessary(aStatus);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   if (aStatus == nsEventStatus_eConsumeNoDefault) {
     return NS_OK;
   }