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 226215 0458d8e6291e3f2c4039fa02f874fba357f1637b
parent 226214 a80685d0ff6f1766090a9dc3aa995b4f0cc7847f
child 226216 f341e1c47a1a1e2f3883f0effdfdde717ae1ef31
push id28187
push usercbook@mozilla.com
push dateWed, 28 Jan 2015 13:20:48 +0000
treeherdermozilla-central@fc21937ca612 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs917322
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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;
   }