Bug 1680277 - 2/3: Use use previous offset for calculating element at marker. r=morgan

This is consistent with how WebKit does it: if offset is between two accessibles,
return the previous one.

Depends on D99311

Differential Revision: https://phabricator.services.mozilla.com/D99312
This commit is contained in:
Eitan Isaacson 2020-12-10 18:24:58 +00:00
parent 2020ec8b53
commit d19edae3f4
2 changed files with 19 additions and 15 deletions

View File

@ -536,7 +536,9 @@ void HyperTextAccessibleWrap::RangeOfChild(Accessible* aChild,
Accessible* HyperTextAccessibleWrap::LeafAtOffset(int32_t aOffset) {
HyperTextAccessible* text = this;
Accessible* child = nullptr;
int32_t innerOffset = aOffset;
// The offset needed should "attach" the previous accessible if
// in between two accessibles.
int32_t innerOffset = aOffset > 0 ? aOffset - 1 : aOffset;
do {
int32_t childIdx = text->GetChildIndexAtOffset(innerOffset);
if (childIdx == -1) {

View File

@ -356,13 +356,13 @@
"I love all of my children equally"],
words: ["my", " "],
element: ["AXStaticText", "I love all of my ", "I love all of my "] },
{ style: "children",
{ style: "I love all of my ",
paragraph: "I love all of my children equally",
lines: ["I love all of my children equally",
"I love all of my children equally",
"I love all of my children equally"],
words: [" ", "children"],
element: ["AXStaticText", "children", "children"] },
element: ["AXStaticText", "I love all of my ", "I love all of my "] },
{ style: "children",
paragraph: "I love all of my children equally",
lines: ["I love all of my children equally",
@ -552,13 +552,13 @@
"This is the best free scrapbooking class I have ever taken"],
words: ["the", " "],
element: ["AXStaticText", "This is the ", "This is the "] },
{ style: "best",
{ style: "This is the ",
paragraph: "This is the best free scrapbooking class I have ever taken",
lines: ["This is the best free scrapbooking class I have ever taken",
"This is the best free scrapbooking class I have ever taken",
"This is the best free scrapbooking class I have ever taken"],
words: [" ", "best"],
element: ["AXStaticText", "best", "best"] },
element: ["AXStaticText", "This is the ", "This is the "] },
{ style: "best",
paragraph: "This is the best free scrapbooking class I have ever taken",
lines: ["This is the best free scrapbooking class I have ever taken",
@ -580,13 +580,13 @@
"This is the best free scrapbooking class I have ever taken"],
words: ["best", "best"],
element: ["AXStaticText", "best", "best"] },
{ style: " free scr",
{ style: "best",
paragraph: "This is the best free scrapbooking class I have ever taken",
lines: ["This is the best free scrapbooking class I have ever taken",
"This is the best free scrapbooking class I have ever taken",
"This is the best free scrapbooking class I have ever taken"],
words: ["best", " "],
element: ["AXStaticText", " free scr", " free scr"] },
element: ["AXStaticText", "best", "best"] },
{ style: " free scr",
paragraph: "This is the best free scrapbooking class I have ever taken",
lines: ["This is the best free scrapbooking class I have ever taken",
@ -643,13 +643,13 @@
"This is the best free scrapbooking class I have ever taken"],
words: ["scrapbooking", "scrapbooking"],
element: ["AXStaticText", " free scr", " free scr"] },
{ style: "apbook",
{ style: " free scr",
paragraph: "This is the best free scrapbooking class I have ever taken",
lines: ["This is the best free scrapbooking class I have ever taken",
"This is the best free scrapbooking class I have ever taken",
"This is the best free scrapbooking class I have ever taken"],
words: ["scrapbooking", "scrapbooking"],
element: ["AXStaticText", "apbook", "apbook"] },
element: ["AXStaticText", " free scr", " free scr"] },
{ style: "apbook",
paragraph: "This is the best free scrapbooking class I have ever taken",
lines: ["This is the best free scrapbooking class I have ever taken",
@ -1637,13 +1637,15 @@
element: ["AXStaticText",
"Chicken fingers with ",
"\u2022 Chicken fingers with "] },
{ style: "spicy",
{ style: "\u2022 Chicken fingers with ",
paragraph: "\u2022 Chicken fingers with spicy club sauce",
lines: ["\u2022 Chicken fingers with spicy club sauce",
"\u2022 Chicken fingers with spicy club sauce",
"\u2022 Chicken fingers with spicy club sauce"],
words: [" ", "spicy"],
element: ["AXStaticText", "spicy", "spicy"] },
element: ["AXStaticText",
"Chicken fingers with ",
"\u2022 Chicken fingers with "] },
{ style: "spicy",
paragraph: "\u2022 Chicken fingers with spicy club sauce",
lines: ["\u2022 Chicken fingers with spicy club sauce",
@ -1672,13 +1674,13 @@
"\u2022 Chicken fingers with spicy club sauce"],
words: ["spicy", "spicy"],
element: ["AXStaticText", "spicy", "spicy"] },
{ style: " club sauce",
{ style: "spicy",
paragraph: "\u2022 Chicken fingers with spicy club sauce",
lines: ["\u2022 Chicken fingers with spicy club sauce",
"\u2022 Chicken fingers with spicy club sauce",
"\u2022 Chicken fingers with spicy club sauce"],
words: ["spicy", " "],
element: ["AXStaticText", " club sauce", " club sauce"] },
element: ["AXStaticText", "spicy", "spicy"] },
{ style: " club sauce",
paragraph: "\u2022 Chicken fingers with spicy club sauce",
lines: ["\u2022 Chicken fingers with spicy club sauce",
@ -2322,11 +2324,11 @@
lines: ["I deceived you, mom.", "I deceived you, mom.", "I deceived you, mom."],
words: ["I", " "],
element: ["AXStaticText", "I ", "I "] },
{ style: "deceived you",
{ style: "I ",
paragraph: "deceived you",
lines: ["deceived you", "deceived you", "deceived you"],
words: [" ", "deceived"],
element: ["AXTextField", "deceived you", "deceived you"] },
element: ["AXStaticText", "I ", "I "] },
{ style: "deceived you",
paragraph: "deceived you",
lines: ["deceived you", "deceived you", "deceived you"],