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
--- 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,