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
--- 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);