Bug 911951 part.4 Clear the wrong clause information and the caret information at failing to dispatch event r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 13 Sep 2013 00:19:00 +0900
changeset 159764 11cc413aad1c3b7ac09e170fb49690b878273b89
parent 159763 cbaab4e2562d69958b1fd22d168c9d211194fc1d
child 159765 67a98b765933163049203aab43cefb5b722eb93a
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs911951
milestone26.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 911951 part.4 Clear the wrong clause information and the caret information at failing to dispatch event r=smaug
dom/base/CompositionStringSynthesizer.cpp
--- a/dom/base/CompositionStringSynthesizer.cpp
+++ b/dom/base/CompositionStringSynthesizer.cpp
@@ -112,23 +112,29 @@ CompositionStringSynthesizer::DispatchEv
   NS_ENSURE_ARG_POINTER(aDefaultPrevented);
   nsCOMPtr<nsIWidget> widget = GetWidget();
   NS_ENSURE_TRUE(widget && !widget->Destroyed(), NS_ERROR_NOT_AVAILABLE);
 
   if (!nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
-  if (!mClauses.IsEmpty()) {
-    NS_ENSURE_TRUE(mClauses[mClauses.Length()-1].mEndOffset == mString.Length(),
-                   NS_ERROR_ILLEGAL_VALUE);
+  if (!mClauses.IsEmpty() &&
+      mClauses[mClauses.Length()-1].mEndOffset != mString.Length()) {
+    NS_WARNING("Sum of length of the all clauses must be same as the string "
+               "length");
+    ClearInternal();
+    return NS_ERROR_ILLEGAL_VALUE;
   }
   if (mCaret.mRangeType == NS_TEXTRANGE_CARETPOSITION) {
-    NS_ENSURE_TRUE(mCaret.mEndOffset <= mString.Length(),
-                   NS_ERROR_ILLEGAL_VALUE);
+    if (mCaret.mEndOffset > mString.Length()) {
+      NS_WARNING("Caret position is out of the composition string");
+      ClearInternal();
+      return NS_ERROR_ILLEGAL_VALUE;
+    }
     mClauses.AppendElement(mCaret);
   }
 
   nsTextEvent textEvent(true, NS_TEXT_TEXT, widget);
   textEvent.time = PR_IntervalNow();
   textEvent.theText = mString;
   textEvent.rangeCount = mClauses.Length();
   textEvent.rangeArray = mClauses.Elements();