Bug 1275528 part.3 Support selection relative WidgetQueryContentEvent in e10s mode r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 14 Jun 2016 20:54:54 +0900
changeset 380002 05228f50107c2030ab6c442e57a8a8bd851524a1
parent 380001 48e9de3ea7f2336b63fdf5d19736277abe90a55c
child 380003 28e01a70279ca2619a3d04efe978733d90e8235f
push id21107
push usermasayuki@d-toybox.com
push dateMon, 20 Jun 2016 10:09:39 +0000
reviewersm_kato
bugs1275528
milestone50.0a1
Bug 1275528 part.3 Support selection relative WidgetQueryContentEvent in e10s mode r?m_kato In e10s mode and during focus is in a remote process, ContentCache handles WidgetQueryContentEvent instead of ContentEventHandler. Therefore, for supporting selection relative WidgetQueryContentEvent in e10s mode, we need to support it in ContentCache too. MozReview-Commit-ID: L5d5ilmpetG
widget/ContentCache.cpp
--- a/widget/ContentCache.cpp
+++ b/widget/ContentCache.cpp
@@ -478,16 +478,44 @@ bool
 ContentCacheInParent::HandleQueryContentEvent(WidgetQueryContentEvent& aEvent,
                                               nsIWidget* aWidget) const
 {
   MOZ_ASSERT(aWidget);
 
   aEvent.mSucceeded = false;
   aEvent.mReply.mFocusedWidget = aWidget;
 
+  // ContentCache doesn't store offset of its start with XP linebreaks.
+  // So, we don't support to query contents relative to composition start
+  // offset with XP linebreaks.
+  if (NS_WARN_IF(!aEvent.mUseNativeLineBreak)) {
+    return false;
+  }
+
+  if (NS_WARN_IF(!aEvent.mInput.IsValidOffset()) ||
+      NS_WARN_IF(!aEvent.mInput.IsValidEventMessage(aEvent.mMessage))) {
+    return false;
+  }
+
+  if (aEvent.mInput.mRelativeToInsertionPoint) {
+    if (aWidget->PluginHasFocus()) {
+      if (NS_WARN_IF(!aEvent.mInput.MakeOffsetAbsolute(0))) {
+        return false;
+      }
+    } else if (mIsComposing) {
+      if (NS_WARN_IF(!aEvent.mInput.MakeOffsetAbsolute(mCompositionStart))) {
+        return false;
+      }
+    } else if (NS_WARN_IF(!mSelection.IsValid()) ||
+               NS_WARN_IF(!aEvent.mInput.MakeOffsetAbsolute(
+                                           mSelection.StartOffset()))) {
+      return false;
+    }
+  }
+
   switch (aEvent.mMessage) {
     case eQuerySelectedText:
       MOZ_LOG(sContentCacheLog, LogLevel::Info,
         ("ContentCacheInParent: 0x%p HandleQueryContentEvent("
          "aEvent={ mMessage=eQuerySelectedText }, aWidget=0x%p)",
          this, aWidget));
       if (aWidget->PluginHasFocus()) {
         MOZ_LOG(sContentCacheLog, LogLevel::Info,