Bug 1260860 - stop illicit accessible stealing, r=yzen

This commit is contained in:
Alexander Surkov 2016-04-01 11:07:57 -04:00
Родитель 946aff842c
Коммит c9b15d3087
6 изменённых файлов: 25 добавлений и 31 удалений

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

@ -1963,28 +1963,17 @@ Accessible::NativeName(nsString& aName)
void
Accessible::BindToParent(Accessible* aParent, uint32_t aIndexInParent)
{
NS_PRECONDITION(aParent, "This method isn't used to set null parent!");
MOZ_ASSERT(aParent, "This method isn't used to set null parent");
MOZ_ASSERT(!mParent, "The child was expected to be moved");
if (mParent) {
if (mParent != aParent) {
#ifdef A11Y_LOG
if (mParent) {
logging::TreeInfo("BindToParent: stealing accessible", 0,
"old parent", mParent.get(),
"new parent", aParent,
"child", this, nullptr);
}
#endif
// XXX: legalize adoption. As long as we don't invalidate the children,
// the accessibles start to steal them.
AutoTreeMutation mt(mParent);
mt.BeforeRemoval(this);
mParent->RemoveChild(this);
mt.Done();
} else {
NS_ERROR("Binding to the same parent!");
return;
}
}
mParent = aParent;
mIndexInParent = aIndexInParent;

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

@ -2262,19 +2262,22 @@ DocAccessible::CacheChildrenInSubtree(Accessible* aRoot,
FocusMgr()->HasDOMFocus(aRoot->GetContent()))
*aFocusedAcc = aRoot;
aRoot->EnsureChildren();
Accessible* root = aRoot->IsHTMLCombobox() ? aRoot->FirstChild() : aRoot;
if (root->KidsFromDOM()) {
AutoTreeMutation mt(root);
TreeWalker walker(root);
while (Accessible* child = walker.Next()) {
if (child->IsBoundToParent()) {
MoveChild(child, root, root->ChildCount());
continue;
}
root->AppendChild(child);
mt.AfterInsertion(child);
// Make sure we create accessible tree defined in DOM only, i.e. if accessible
// provides specific tree (like XUL trees) then tree creation is handled by
// this accessible.
uint32_t count = aRoot->ContentChildCount();
for (uint32_t idx = 0; idx < count; idx++) {
Accessible* child = aRoot->ContentChildAt(idx);
NS_ASSERTION(child, "Illicit tree change while tree is created!");
// Don't cross document boundaries.
if (child && child->IsContent()) {
CacheChildrenInSubtree(child, aFocusedAcc);
}
mt.Done();
}
// Fire document load complete on ARIA documents.

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

@ -51,6 +51,7 @@ HTMLLIAccessible::
if (blockFrame && blockFrame->HasBullet()) {
mBullet = new HTMLListBulletAccessible(mContent, mDoc);
Document()->BindToDocument(mBullet, nullptr);
AppendChild(mBullet);
}
}

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

@ -361,7 +361,7 @@
function showHiddenParentOfVisibleChild()
{
this.eventSeq = [
new todo_invokerChecker(EVENT_HIDE, getNode("c4_child")),
new invokerChecker(EVENT_HIDE, getNode("c4_child")),
new invokerChecker(EVENT_SHOW, getNode("c4_middle")),
new invokerChecker(EVENT_REORDER, getNode("c4"))
];

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

@ -144,11 +144,11 @@
<div id="t2_3" aria-owns="t2_1" role="heading"></div>
<!-- loop #2 -->
<div id="t3_3" aria-owns="t3_1"></div>
<div id="t3_1" aria-owns="t3_2" role="group"></div>
<div id="t3_2" role="note">
<div aria-owns="t3_3" role="heading"></div>
</div>
<div id="t3_3" aria-owns="t3_1"></div>
<!-- self loop -->
<div id="t4_1"><div aria-owns="t4_1" role="group"></div></div>

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

@ -50,6 +50,7 @@ XULLabelAccessible::
nsAutoString text;
textBoxFrame->GetCroppedTitle(text);
mValueTextLeaf->SetText(text);
AppendChild(mValueTextLeaf);
}
}