Bug 1166436 part.17 ContentCache::HandleQueryContentEvent() should return caret rect if mInput.mLength of NS_QUERY_TEXT_RECT event is 0 r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 05 Jun 2015 18:28:21 +0900
changeset 278140 8feaf4e01d6a6b2f5d51046ded6704a8ce3d510e
parent 278139 d5462260041476cf3079d4855074ce51aed12ebb
child 278141 6fe725dba239a5eeb30805e26a9362dd6d938a4b
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1166436
milestone41.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 1166436 part.17 ContentCache::HandleQueryContentEvent() should return caret rect if mInput.mLength of NS_QUERY_TEXT_RECT event is 0 r=m_kato
widget/ContentCache.cpp
--- a/widget/ContentCache.cpp
+++ b/widget/ContentCache.cpp
@@ -253,25 +253,37 @@ ContentCache::HandleQueryContentEvent(Wi
     }
     case NS_QUERY_TEXT_RECT:
       MOZ_LOG(sContentCacheLog, LogLevel::Info,
         ("ContentCache: 0x%p (mIsChrome=%s) HandleQueryContentEvent("
          "aEvent={ message=NS_QUERY_TEXT_RECT, mInput={ mOffset=%u, "
          "mLength=%u } }, aWidget=0x%p), mText.Length()=%u",
          this, GetBoolName(mIsChrome), aEvent.mInput.mOffset,
          aEvent.mInput.mLength, aWidget, mText.Length()));
-      if (NS_WARN_IF(!GetUnionTextRects(aEvent.mInput.mOffset,
-                                        aEvent.mInput.mLength,
-                                        aEvent.mReply.mRect))) {
-        // XXX We don't have cache for this request.
-        MOZ_LOG(sContentCacheLog, LogLevel::Error,
-          ("ContentCache: 0x%p (mIsChrome=%s) HandleQueryContentEvent(), "
-           "FAILED to get union rect",
-           this, GetBoolName(mIsChrome)));
-        return false;
+      if (aEvent.mInput.mLength) {
+        if (NS_WARN_IF(!GetUnionTextRects(aEvent.mInput.mOffset,
+                                          aEvent.mInput.mLength,
+                                          aEvent.mReply.mRect))) {
+          // XXX We don't have cache for this request.
+          MOZ_LOG(sContentCacheLog, LogLevel::Error,
+            ("ContentCache: 0x%p (mIsChrome=%s) HandleQueryContentEvent(), "
+             "FAILED to get union rect",
+             this, GetBoolName(mIsChrome)));
+          return false;
+        }
+      } else {
+        // If the length is 0, we should return caret rect instead.
+        if (NS_WARN_IF(!GetCaretRect(aEvent.mInput.mOffset,
+                                     aEvent.mReply.mRect))) {
+          MOZ_LOG(sContentCacheLog, LogLevel::Error,
+            ("ContentCache: 0x%p (mIsChrome=%s) HandleQueryContentEvent(), "
+             "FAILED to get caret rect",
+             this, GetBoolName(mIsChrome)));
+          return false;
+        }
       }
       if (aEvent.mInput.mOffset < mText.Length()) {
         aEvent.mReply.mString =
           Substring(mText, aEvent.mInput.mOffset,
                     mText.Length() >= aEvent.mInput.EndOffset() ?
                       aEvent.mInput.mLength : UINT32_MAX);
       } else {
         aEvent.mReply.mString.Truncate(0);