Bug 1520779 Part 5: Expose both text and list bullet when requesting the paragraph from a list item, r=Jamie

Tagging onto what we already do for getting line offsets, also doing the same when the paragraph selection is requested.

Differential Revision: https://phabricator.services.mozilla.com/D90238
This commit is contained in:
Marco Zehe 2020-09-17 00:02:22 +00:00
Родитель ba3763885d
Коммит 2209e8f5b2
2 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -490,6 +490,7 @@ uint32_t HyperTextAccessible::FindOffset(uint32_t aOffset,
switch (aAmount) {
case eSelectLine:
case eSelectEndLine:
case eSelectParagraph:
// Ask a text leaf next (if not empty) to the bullet for an offset
// since list item may be multiline.
return nextOffset < CharacterCount()
@ -565,7 +566,8 @@ uint32_t HyperTextAccessible::FindOffset(uint32_t aOffset,
if (hyperTextOffset == CharacterCount()) return 0;
// PeekOffset stops right before bullet so return 0 to workaround it.
if (IsHTMLListItem() && aAmount == eSelectBeginLine &&
if (IsHTMLListItem() &&
(aAmount == eSelectBeginLine || aAmount == eSelectParagraph) &&
hyperTextOffset > 0) {
Accessible* prevOffsetChild = GetChildAtOffset(hyperTextOffset - 1);
if (prevOffsetChild == AsHTMLListItem()->Bullet()) return 0;

Просмотреть файл

@ -34,6 +34,13 @@
testTextAtOffset("link", BOUNDARY_PARAGRAPH,
[[0, 2, "bc", 0, 2]]);
// Test a list and list item
testTextAtOffset("ul", BOUNDARY_PARAGRAPH,
[[0, 0, kEmbedChar, 0, 1],
[1, 2, kEmbedChar, 1, 2]]);
testTextAtOffset("li1", BOUNDARY_PARAGRAPH,
[[0, 3, "• a", 0, 3]]);
SimpleTest.finish();
}
@ -60,5 +67,6 @@
</div>
<p id="forced_wrap" style="width: 1px; word-break: break-all;">ab</p>
<p id="pWithLink">a<a id="link" href="https://example.com/">bc</a>d</p>
<ul id="ul"><li id="li1">a</li><li>b</li></ul>
</body>
</html>