Bug 1351783 part 9 - Disable a FocusTarget for an editable element. r=smaug
authorRyan Hunt <rhunt@eqrion.net>
Mon, 05 Jun 2017 19:23:45 -0500
changeset 600757 965a72722c0165313b4da4a9063896103645a827
parent 600756 310bd86a94f512df05f52dd84a3576c39a0defe3
child 600758 8d3d222b4761f2c6cfe27c92ba0ae1dcf3c44430
push id65868
push userbmo:rail@mozilla.com
push dateTue, 27 Jun 2017 20:33:55 +0000
reviewerssmaug
bugs1351783
milestone56.0a1
Bug 1351783 part 9 - Disable a FocusTarget for an editable element. r=smaug This commit updates FocusTarget to disable itself if the focused element is editable, or is a part of an editable document. This is needed because we cannot do async scrolling when this is the case. MozReview-Commit-ID: Fl7W3967djG
gfx/layers/apz/src/FocusTarget.cpp
--- a/gfx/layers/apz/src/FocusTarget.cpp
+++ b/gfx/layers/apz/src/FocusTarget.cpp
@@ -55,16 +55,22 @@ HasListenersForKeyEvents(nsIContent* aCo
   for (size_t i = 0; i < targets.Length(); i++) {
     if (targets[i]->HasUntrustedOrNonSystemGroupKeyEventListeners()) {
       return true;
     }
   }
   return false;
 }
 
+static bool
+IsEditableNode(nsINode* aNode)
+{
+  return aNode && aNode->IsEditable();
+}
+
 FocusTarget::FocusTarget()
   : mFocusHasKeyEventListeners(false)
   , mType(FocusTarget::eNone)
 {
 }
 
 FocusTarget::FocusTarget(nsIPresShell* aRootPresShell)
   : mFocusHasKeyEventListeners(false)
@@ -93,16 +99,23 @@ FocusTarget::FocusTarget(nsIPresShell* a
       mData.mRefLayerId = rfp->GetLayersId();
       return;
     }
 
     mType = FocusTarget::eNone;
     return;
   }
 
+  // If the focus isn't on a remote browser then check for scrollable targets
+  if (IsEditableNode(scrollTarget) ||
+      IsEditableNode(presShell->GetDocument())) {
+    mType = FocusTarget::eNone;
+    return;
+  }
+
   // Gather the scrollable frames that would be scrolled in each direction
   // for this scroll target
   nsIScrollableFrame* horizontal =
     presShell->GetScrollableFrameToScrollForContent(scrollTarget.get(),
                                                     nsIPresShell::eHorizontal);
   nsIScrollableFrame* vertical =
     presShell->GetScrollableFrameToScrollForContent(scrollTarget.get(),
                                                     nsIPresShell::eVertical);