Bug 1668958 - Don't wrap to first word when getting right word at end of input. r=morgan
authorEitan Isaacson <eitan@monotonous.org>
Tue, 06 Oct 2020 22:19:13 +0000
changeset 551799 36d34ef369cfef2b0a6b8d16851b6f17505a1716
parent 551798 d1f82fb748cf2193a503115ca8dd4d4f524c2a83
child 551800 e2438dd9b47fce310c3ca7f8de5c9f886ce8cdb7
push id128068
push usereisaacson@mozilla.com
push dateWed, 07 Oct 2020 02:19:45 +0000
treeherderautoland@36d34ef369cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmorgan
bugs1668958
milestone83.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1668958 - Don't wrap to first word when getting right word at end of input. r=morgan Differential Revision: https://phabricator.services.mozilla.com/D92310
accessible/mac/HyperTextAccessibleWrap.mm
accessible/tests/browser/mac/doc_textmarker_test.html
--- a/accessible/mac/HyperTextAccessibleWrap.mm
+++ b/accessible/mac/HyperTextAccessibleWrap.mm
@@ -328,29 +328,26 @@ void HyperTextAccessibleWrap::LeftWordAt
 
 void HyperTextAccessibleWrap::RightWordAt(int32_t aOffset,
                                           HyperTextAccessible** aStartContainer,
                                           int32_t* aStartOffset,
                                           HyperTextAccessible** aEndContainer,
                                           int32_t* aEndOffset) {
   TextPoint here(this, aOffset);
   TextPoint end = FindTextPoint(aOffset, eDirNext, eSelectWord, eEndWord);
-  if (!end.mContainer || end < here) {
+  if (!end.mContainer || end < here || here == end) {
     // If we didn't find a word end, or if we wrapped around (bug 1652833),
     // return with no result.
     return;
   }
 
   if ((NativeState() & states::EDITABLE) &&
       !(end.mContainer->NativeState() & states::EDITABLE)) {
-    // The word search crossed an editable boundary. Return the last word of the
-    // editable root.
-    return EditableRoot()->LeftWordAt(
-        nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT, aStartContainer,
-        aStartOffset, aEndContainer, aEndOffset);
+    // The word search crossed an editable boundary. Return with no result.
+    return;
   }
 
   TextPoint start =
       static_cast<HyperTextAccessibleWrap*>(end.mContainer)
           ->FindTextPoint(end.mOffset, eDirPrevious, eSelectWord, eStartWord);
 
   if (here < start) {
     *aStartContainer = here.mContainer;
--- a/accessible/tests/browser/mac/doc_textmarker_test.html
+++ b/accessible/tests/browser/mac/doc_textmarker_test.html
@@ -1978,17 +1978,17 @@
         { style: "deceived you",
           paragraph: "deceived you",
           lines: ["deceived you", "deceived you", "deceived you"],
           words: ["you", "you"],
           element: ["AXTextField", "deceived you"] },
         { style: "deceived you",
           paragraph: "deceived you",
           lines: ["I deceived you, mom.", "I deceived you, mom.", "I deceived you, mom."],
-          words: ["you", "deceived"],
+          words: ["you", ""],
           element: ["AXTextField", "deceived you"] },
         { style: ", mom.",
           paragraph: "I deceived you, mom.",
           lines: ["I deceived you, mom.", "I deceived you, mom.", "I deceived you, mom."],
           words: [",", " "],
           element: ["AXStaticText", ", mom."] },
         { style: ", mom.",
           paragraph: "I deceived you, mom.",