mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1793408: Consistently treat OuterDocAccessibles as a single character in TextLeafPoint. r=morgan
1. When constructing a TextLeafPoint and searching for a leaf, do not descend inside an OuterDoc (iframe/browser). Otherwise, we end up inside another document. Other TextLeafPoint code avoids crossing document boundaries, so the constructor must do this too. 2. When searching for a leaf, include an OuterDoc, but don't walk inside it. Previously, we skipped OuterDocs altogether. This meant that if you started on an OuterDoc, walking backward and then forward by character would never return you to your origin. Also, clients walking the document text shouldn't just skip iframes altogether, so exposing them as a single character makes more sense. This fixes infinite loops in OffsetAtPoint when querying a container with an iframe at the end. Differential Revision: https://phabricator.services.mozilla.com/D158740
This commit is contained in:
parent
633b70954e
commit
c579cdfd2e
@ -103,7 +103,10 @@ class LeafRule : public PivotRule {
|
||||
public:
|
||||
virtual uint16_t Match(Accessible* aAcc) override {
|
||||
if (aAcc->IsOuterDoc()) {
|
||||
return nsIAccessibleTraversalRule::FILTER_IGNORE_SUBTREE;
|
||||
// Treat an embedded doc as a single character in this document, but do
|
||||
// not descend inside it.
|
||||
return nsIAccessibleTraversalRule::FILTER_MATCH |
|
||||
nsIAccessibleTraversalRule::FILTER_IGNORE_SUBTREE;
|
||||
}
|
||||
// We deliberately include Accessibles such as empty input elements and
|
||||
// empty containers, as these can be at the start of a line.
|
||||
@ -468,10 +471,16 @@ static nsTArray<nsRange*> FindDOMSpellingErrors(LocalAccessible* aAcc,
|
||||
/*** TextLeafPoint ***/
|
||||
|
||||
TextLeafPoint::TextLeafPoint(Accessible* aAcc, int32_t aOffset) {
|
||||
if (aOffset != nsIAccessibleText::TEXT_OFFSET_CARET && aAcc->HasChildren()) {
|
||||
// Even though an OuterDoc contains a document, we treat it as a leaf because
|
||||
// we don't want to move into another document.
|
||||
if (aOffset != nsIAccessibleText::TEXT_OFFSET_CARET && !aAcc->IsOuterDoc() &&
|
||||
aAcc->HasChildren()) {
|
||||
// Find a leaf. This might not necessarily be a TextLeafAccessible; it
|
||||
// could be an empty container.
|
||||
auto GetChild = [&aOffset](Accessible* acc) -> Accessible* {
|
||||
if (acc->IsOuterDoc()) {
|
||||
return nullptr;
|
||||
}
|
||||
return aOffset != nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT
|
||||
? acc->FirstChild()
|
||||
: acc->LastChild();
|
||||
|
@ -9,6 +9,10 @@ addAccessibleTask(
|
||||
a
|
||||
<div id="noChars" style="width: 5px; height: 5px;"><p></p></div>
|
||||
<p id="twoText"><span>a</span><span>b</span></p>
|
||||
<div id="iframeAtEnd" style="width: 20px; height: 20px;">
|
||||
a
|
||||
<iframe width="1" height="1"></iframe>
|
||||
</div>
|
||||
`,
|
||||
async function(browser, docAcc) {
|
||||
const dpr = await getContentDPR(browser);
|
||||
@ -28,6 +32,17 @@ a
|
||||
const text2 = twoText.getChildAt(1);
|
||||
[x, y] = Layout.getBounds(text2, dpr);
|
||||
await testOffsetAtPoint(twoText, x, y, COORDTYPE_SCREEN_RELATIVE, 1);
|
||||
|
||||
// Test offsetAtPoint when there is an iframe at the end of the container.
|
||||
const iframeAtEnd = findAccessibleChildByID(docAcc, "iframeAtEnd", [
|
||||
Ci.nsIAccessibleText,
|
||||
]);
|
||||
let width;
|
||||
let height;
|
||||
[x, y, width, height] = Layout.getBounds(iframeAtEnd, dpr);
|
||||
x += width - 1;
|
||||
y += height - 1;
|
||||
await testOffsetAtPoint(iframeAtEnd, x, y, COORDTYPE_SCREEN_RELATIVE, -1);
|
||||
},
|
||||
{
|
||||
topLevel: true,
|
||||
|
Loading…
Reference in New Issue
Block a user