Bug 1286464 part.7 ContentEventHandler::OnQueryTextRect() should redirect the query event to OnQueryCaretRect() if its query range is empty r=smaug draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 25 Jul 2016 23:19:53 +0900
changeset 399836 34cd75d05cc15c1b960eda0c3fe16387729ce14f
parent 399835 8767a8ffa18393cb5ad7fba0e9c636897fa5867f
child 399837 a42f468b44eee3956324de6ec4a8b0acbbd5165d
push id26007
push usermasayuki@d-toybox.com
push dateFri, 12 Aug 2016 06:30:02 +0000
reviewerssmaug
bugs1286464
milestone51.0a1
Bug 1286464 part.7 ContentEventHandler::OnQueryTextRect() should redirect the query event to OnQueryCaretRect() if its query range is empty r=smaug When eQueryTextRect's query range length is 0 (this may be caused by native IME's bug), it should return caret rect. Therefore, it should redirect such query events to OnQueryCaretRect(). Such IME must want caret rect in such case. MozReview-Commit-ID: JaUwhw1Cn5G
dom/events/ContentEventHandler.cpp
--- a/dom/events/ContentEventHandler.cpp
+++ b/dom/events/ContentEventHandler.cpp
@@ -1535,16 +1535,22 @@ ContentEventHandler::OnQueryTextRectArra
 nsresult
 ContentEventHandler::OnQueryTextRect(WidgetQueryContentEvent* aEvent)
 {
   nsresult rv = Init(aEvent);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
+  // If mLength is 0 (this may be caused by bug of native IME), we should
+  // redirect this event to OnQueryCaretRect().
+  if (!aEvent->mInput.mLength) {
+    return OnQueryCaretRect(aEvent);
+  }
+
   LineBreakType lineBreakType = GetLineBreakType(aEvent);
   RefPtr<nsRange> range = new nsRange(mRootContent);
   rv = SetRangeFromFlatTextOffset(range, aEvent->mInput.mOffset,
                                   aEvent->mInput.mLength, lineBreakType, true,
                                   &aEvent->mReply.mOffset);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = GenerateFlatTextContent(range, aEvent->mReply.mString, lineBreakType);
   NS_ENSURE_SUCCESS(rv, rv);