bug 1339128 - reference parent proxy by id r=eeejay

This commit is contained in:
Trevor Saunders 2017-02-13 11:56:53 -05:00
Родитель cbdcae43c2
Коммит 570037515c
4 изменённых файлов: 50 добавлений и 6 удалений

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

@ -425,7 +425,7 @@ DocAccessibleParent::AddChildDoc(DocAccessibleParent* aChildDoc,
return IPC_FAIL(this, "binding to proxy that can't be a outerDoc!");
}
aChildDoc->mParent = outerDoc;
aChildDoc->SetParent(outerDoc);
outerDoc->SetChildDoc(aChildDoc);
mChildDocs.AppendElement(aChildDoc);
aChildDoc->mParentDoc = this;

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

@ -95,7 +95,7 @@ public:
parent->RemoveChildDoc(this);
}
mParent = nullptr;
SetParent(nullptr);
}
virtual mozilla::ipc::IPCResult RecvShutdown() override;

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

@ -167,6 +167,47 @@ ProxyAccessibleBase<Derived>::OuterDocOfRemoteBrowser() const
return chromeDoc ? chromeDoc->GetAccessible(frame) : nullptr;
}
template<class Derived>
void
ProxyAccessibleBase<Derived>::SetParent(Derived* aParent)
{
MOZ_ASSERT(IsDoc(), "we should only reparent documents");
if (!aParent) {
mParent = kNoParent;
} else {
MOZ_ASSERT(!aParent->IsDoc());
mParent = aParent->ID();
}
}
template<class Derived>
Derived*
ProxyAccessibleBase<Derived>::Parent() const
{
if (mParent == kNoParent) {
return nullptr;
}
// if we are not a document then are parent is another proxy in the same
// document. That means we can just ask our document for the proxy with our
// parent id.
if (!IsDoc()) {
return Document()->GetAccessible(mParent);
}
// If we are a top level document then our parent is not a proxy.
if (AsDoc()->IsTopLevel()) {
return nullptr;
}
// Finally if we are a non top level document then our parent id is for a
// proxy in our parent document so get the proxy from there.
DocAccessibleParent* parentDoc = AsDoc()->ParentDoc();
MOZ_ASSERT(parentDoc);
MOZ_ASSERT(mParent);
return parentDoc->GetAccessible(mParent);
}
template class ProxyAccessibleBase<ProxyAccessible>;
} // namespace a11y

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

@ -90,7 +90,7 @@ public:
/**
* Return the proxy for the parent of the wrapped accessible.
*/
Derived* Parent() const { return mParent; }
Derived* Parent() const;
Accessible* OuterDocOfRemoteBrowser() const;
@ -158,7 +158,7 @@ protected:
ProxyAccessibleBase(uint64_t aID, Derived* aParent,
DocAccessibleParent* aDoc, role aRole,
uint32_t aInterfaces)
: mParent(aParent)
: mParent(aParent->ID())
, mDoc(aDoc)
, mWrapper(0)
, mID(aID)
@ -172,15 +172,18 @@ protected:
}
explicit ProxyAccessibleBase(DocAccessibleParent* aThisAsDoc) :
mParent(nullptr), mDoc(aThisAsDoc), mWrapper(0), mID(0),
mParent(kNoParent), mDoc(aThisAsDoc), mWrapper(0), mID(0),
mRole(roles::DOCUMENT), mOuterDoc(false), mIsDoc(true), mHasValue(false),
mIsHyperLink(false), mIsHyperText(false)
{}
protected:
Derived* mParent;
void SetParent(Derived* aParent);
private:
uintptr_t mParent;
static const uintptr_t kNoParent = UINTPTR_MAX;
friend Derived;
nsTArray<Derived*> mChildren;