Bug 1203871 - Part 3. Use eQueryTextRectArray on ContentCache for e10s. r=masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 14 Mar 2016 16:03:31 +0900
changeset 380803 6b6cfbba6777d267b0e884444be41079be06dba8
parent 380802 20cd5777d0088a8c5eb22f4f5c74111af05125c2
child 380804 8610d6f66dcc1d83df90274f84e1ec33eced0678
push id21331
push userm_kato@ga2.so-net.ne.jp
push dateThu, 23 Jun 2016 12:36:21 +0000
reviewersmasayuki
bugs1203871
milestone50.0a1
Bug 1203871 - Part 3. Use eQueryTextRectArray on ContentCache for e10s. r=masayuki Use new event to update cotent process's cache. MozReview-Commit-ID: CexTXW4knMQ
widget/ContentCache.cpp
--- a/widget/ContentCache.cpp
+++ b/widget/ContentCache.cpp
@@ -302,30 +302,24 @@ ContentCacheInChild::CacheTextRects(nsIW
   if (textComposition) {
     // mCompositionStart may be updated by some composition event handlers.
     // So, let's update it with the latest information.
     mCompositionStart = textComposition->NativeOffsetOfStartComposition();
     // Note that TextComposition::String() may not be modified here because
     // it's modified after all edit action listeners are performed but this
     // is called while some of them are performed.
     uint32_t length = textComposition->LastData().Length();
-    mTextRectArray.mRects.SetCapacity(length);
     mTextRectArray.mStart = mCompositionStart;
-    uint32_t endOffset = mTextRectArray.mStart + length;
-    for (uint32_t i = mTextRectArray.mStart; i < endOffset; i++) {
-      LayoutDeviceIntRect charRect;
-      if (NS_WARN_IF(!QueryCharRect(aWidget, i, charRect))) {
-        MOZ_LOG(sContentCacheLog, LogLevel::Error,
-          ("ContentCacheInChild: 0x%p CacheTextRects(), FAILED, "
-           "couldn't retrieve text rect at offset=%u", this, i));
-        mTextRectArray.Clear();
-        return false;
-      }
-      mTextRectArray.mRects.AppendElement(charRect);
-    }
+
+    nsEventStatus status = nsEventStatus_eIgnore;
+    WidgetQueryContentEvent textRects(true, eQueryTextRectArray, aWidget);
+    textRects.InitForQueryTextRectArray(mTextRectArray.mStart, length);
+    aWidget->DispatchEvent(&textRects, status);
+
+    mTextRectArray.mRects = textRects.mReply.mRectArray;
   }
 
   if (mTextRectArray.InRange(mSelection.mAnchor)) {
     mSelection.mAnchorCharRect = mTextRectArray.GetRect(mSelection.mAnchor);
   } else {
     LayoutDeviceIntRect charRect;
     if (NS_WARN_IF(!QueryCharRect(aWidget, mSelection.mAnchor, charRect))) {
       MOZ_LOG(sContentCacheLog, LogLevel::Error,