Bug 1055004 - Fix failure of GetAccessibleOrContainer() to return a parent past a shadow root. r=davidb

This commit is contained in:
Eitan Isaacson 2014-08-22 13:10:57 -07:00
parent 1032aeef55
commit 9e49c14b6c

View File

@ -1309,8 +1309,22 @@ DocAccessible::GetAccessibleOrContainer(nsINode* aNode) const
nsINode* currNode = aNode;
Accessible* accessible = nullptr;
while (!(accessible = GetAccessible(currNode)) &&
(currNode = currNode->GetParentNode()));
while (!(accessible = GetAccessible(currNode))) {
nsINode* parent = nullptr;
// If this is a content node, try to get a flattened parent content node.
// This will smartly skip from the shadow root to the host element,
// over parentless document fragment
if (currNode->IsContent())
parent = currNode->AsContent()->GetFlattenedTreeParent();
// Fallback to just get parent node, in case there is no parent content
// node. Or current node is not a content node.
if (!parent)
parent = currNode->GetParentNode();
if (!(currNode = parent)) break;
}
return accessible;
}