Bug 1170242 - On accessibility SetSelectionRange, scroll the selection into view. r=surkov
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Wed, 11 Oct 2017 10:43:53 +0200
changeset 428213 9cbc9faa5c9973e09fa90045f6d4fdcc93eb449e
parent 428212 50368fa3e040a806a0b86c0c6471055f4cb41ae1
child 428214 96dca2eb7f27c6ac854d148d637ea2d651c677d9
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewerssurkov
bugs1170242
milestone58.0a1
Bug 1170242 - On accessibility SetSelectionRange, scroll the selection into view. r=surkov
accessible/generic/HyperTextAccessible.cpp
--- a/accessible/generic/HyperTextAccessible.cpp
+++ b/accessible/generic/HyperTextAccessible.cpp
@@ -1331,16 +1331,23 @@ HyperTextAccessible::SetSelectionRange(i
   dom::Selection* domSel = DOMSelection();
   NS_ENSURE_STATE(domSel);
 
   // Set up the selection.
   for (int32_t idx = domSel->RangeCount() - 1; idx > 0; idx--)
     domSel->RemoveRange(domSel->GetRangeAt(idx));
   SetSelectionBoundsAt(0, aStartPos, aEndPos);
 
+  // Make sure it is visible
+  domSel->ScrollIntoView(nsISelectionController::SELECTION_FOCUS_REGION,
+                         nsIPresShell::ScrollAxis(),
+                         nsIPresShell::ScrollAxis(),
+                         dom::Selection::SCROLL_FOR_CARET_MOVE |
+                             dom::Selection::SCROLL_OVERFLOW_HIDDEN);
+
   // When selection is done, move the focus to the selection if accessible is
   // not focusable. That happens when selection is set within hypertext
   // accessible.
   if (isFocusable)
     return NS_OK;
 
   nsFocusManager* DOMFocusManager = nsFocusManager::GetFocusManager();
   if (DOMFocusManager) {