Merge m-c to m-i

This commit is contained in:
Phil Ringnalda 2016-09-18 18:46:58 -07:00
commit fbee0c8359
14 changed files with 29 additions and 190 deletions

View File

@ -82,29 +82,6 @@ DocAccessibleChildBase::SerializeTree(Accessible* aRoot,
}
}
#if defined(XP_WIN)
/* static */ void
DocAccessibleChildBase::SetMsaaIds(Accessible* aRoot,
uint32_t& aMsaaIdIndex,
const nsTArray<MsaaMapping>& aNewMsaaIds)
{
const MsaaMapping& mapping = aNewMsaaIds[aMsaaIdIndex];
#if defined(DEBUG)
uint64_t id = reinterpret_cast<uint64_t>(aRoot->UniqueID());
MOZ_ASSERT(mapping.ID() == id);
#endif // defined(DEBUG)
static_cast<AccessibleWrap*>(aRoot)->SetID(mapping.MsaaID());
++aMsaaIdIndex;
if (aRoot->IsOuterDoc()) {
// This needs to match the tree traversal in SerializeTree
return;
}
for (uint32_t i = 0, n = aRoot->ChildCount(); i < n; ++i) {
SetMsaaIds(aRoot->GetChildAt(i), aMsaaIdIndex, aNewMsaaIds);
}
}
#endif // defined(XP_WIN)
void
DocAccessibleChildBase::ShowEvent(AccShowEvent* aShowEvent)
{
@ -114,22 +91,7 @@ DocAccessibleChildBase::ShowEvent(AccShowEvent* aShowEvent)
nsTArray<AccessibleData> shownTree;
ShowEventData data(parentID, idxInParent, shownTree);
SerializeTree(aShowEvent->GetAccessible(), data.NewTree());
#if defined(XP_WIN)
nsTArray<MsaaMapping> newMsaaIds;
SendShowEventInfo(data, &newMsaaIds);
// newMsaaIds could be empty if something went wrong in SendShowEvent()
if (!newMsaaIds.IsEmpty()) {
uint32_t index = 0;
SetMsaaIds(aShowEvent->GetAccessible(), index, newMsaaIds);
}
// NB: On Windows, SendShowEvent attaches the subtree and generates new IDs,
// but does *NOT* fire the native event. We need to do that after
// we've called SetMsaaIds.
SendEvent(reinterpret_cast<uint64_t>(aShowEvent->GetAccessible()->UniqueID()),
nsIAccessibleEvent::EVENT_SHOW);
#else
SendShowEvent(data, aShowEvent->IsFromUserInput());
#endif // defined(XP_WIN)
}
} // namespace a11y

View File

@ -60,10 +60,6 @@ public:
protected:
static uint32_t InterfacesFor(Accessible* aAcc);
static void SerializeTree(Accessible* aRoot, nsTArray<AccessibleData>& aTree);
#if defined(XP_WIN)
static void SetMsaaIds(Accessible* aRoot, uint32_t& aMsaaIdIndex,
const nsTArray<MsaaMapping>& aNewMsaaIds);
#endif
DocAccessible* mDoc;
};

View File

@ -16,13 +16,8 @@ namespace mozilla {
namespace a11y {
bool
#if defined(XP_WIN)
DocAccessibleParent::RecvShowEventInfo(const ShowEventData& aData,
nsTArray<MsaaMapping>* aNewMsaaIds)
#else
DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
const bool& aFromUser)
#endif // defined(XP_WIN)
{
if (mShutdown)
return true;
@ -49,13 +44,7 @@ DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
return true;
}
#if defined(XP_WIN)
aNewMsaaIds->SetCapacity(aData.NewTree().Length());
uint32_t consumed = AddSubtree(parent, aData.NewTree(), 0, newChildIdx,
aNewMsaaIds);
#else
uint32_t consumed = AddSubtree(parent, aData.NewTree(), 0, newChildIdx);
#endif
MOZ_ASSERT(consumed == aData.NewTree().Length());
// XXX This shouldn't happen, but if we failed to add children then the below
@ -73,9 +62,6 @@ DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
MOZ_DIAGNOSTIC_ASSERT(CheckDocTree());
// NB: On Windows we dispatch the native event via a subsequent call to
// RecvEvent().
#if !defined(XP_WIN)
ProxyAccessible* target = parent->ChildAt(newChildIdx);
ProxyShowHideEvent(target, parent, true, aFromUser);
@ -90,7 +76,6 @@ DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
RefPtr<xpcAccEvent> event = new xpcAccEvent(type, xpcAcc, doc, node,
aFromUser);
nsCoreUtils::DispatchAccEvent(Move(event));
#endif
return true;
}
@ -98,11 +83,7 @@ DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
uint32_t
DocAccessibleParent::AddSubtree(ProxyAccessible* aParent,
const nsTArray<a11y::AccessibleData>& aNewTree,
uint32_t aIdx, uint32_t aIdxInParent
#if defined(XP_WIN)
, nsTArray<MsaaMapping>* aNewMsaaIds
#endif
)
uint32_t aIdx, uint32_t aIdxInParent)
{
if (aNewTree.Length() <= aIdx) {
NS_ERROR("bad index in serialized tree!");
@ -143,22 +124,10 @@ DocAccessibleParent::AddSubtree(ProxyAccessible* aParent,
mAccessibles.PutEntry(newChild.ID())->mProxy = newProxy;
ProxyCreated(newProxy, newChild.Interfaces());
#if defined(XP_WIN)
Accessible* idForAcc = WrapperFor(newProxy);
MOZ_ASSERT(idForAcc);
uint32_t newMsaaId = AccessibleWrap::GetChildIDFor(idForAcc);
MOZ_ASSERT(newMsaaId);
aNewMsaaIds->AppendElement(MsaaMapping(newChild.ID(), newMsaaId));
#endif // defined(XP_WIN)
uint32_t accessibles = 1;
uint32_t kids = newChild.ChildrenCount();
for (uint32_t i = 0; i < kids; i++) {
uint32_t consumed = AddSubtree(newProxy, aNewTree, aIdx + accessibles, i
#if defined(XP_WIN)
, aNewMsaaIds
#endif
);
uint32_t consumed = AddSubtree(newProxy, aNewTree, aIdx + accessibles, i);
if (!consumed)
return 0;
@ -507,8 +476,7 @@ DocAccessibleParent::GetXPCAccessible(ProxyAccessible* aProxy)
*/
bool
DocAccessibleParent::RecvCOMProxy(const IAccessibleHolder& aCOMProxy,
IAccessibleHolder* aParentCOMProxy,
uint32_t* aMsaaID)
IAccessibleHolder* aParentCOMProxy)
{
RefPtr<IAccessible> ptr(aCOMProxy.Get());
SetCOMInterface(ptr);
@ -520,8 +488,6 @@ DocAccessibleParent::RecvCOMProxy(const IAccessibleHolder& aCOMProxy,
}
aParentCOMProxy->Set(IAccessibleHolder::COMPtrType(rawNative));
Accessible* wrapper = WrapperFor(this);
*aMsaaID = AccessibleWrap::GetChildIDFor(wrapper);
return true;
}
#endif // defined(XP_WIN)

View File

@ -50,13 +50,8 @@ public:
virtual bool RecvEvent(const uint64_t& aID, const uint32_t& aType)
override;
#if defined(XP_WIN)
virtual bool RecvShowEventInfo(const ShowEventData& aData,
nsTArray<MsaaMapping>* aNewMsaaIds) override;
#else
virtual bool RecvShowEvent(const ShowEventData& aData, const bool& aFromUser)
override;
#endif // defined(XP_WIN)
virtual bool RecvHideEvent(const uint64_t& aRootID, const bool& aFromUser)
override;
virtual bool RecvStateChangeEvent(const uint64_t& aID,
@ -149,8 +144,7 @@ public:
#if defined(XP_WIN)
virtual bool RecvCOMProxy(const IAccessibleHolder& aCOMProxy,
IAccessibleHolder* aParentCOMProxy,
uint32_t* aMsaaID) override;
IAccessibleHolder* aParentCOMProxy) override;
#endif
private:
@ -180,11 +174,7 @@ private:
uint32_t AddSubtree(ProxyAccessible* aParent,
const nsTArray<AccessibleData>& aNewTree, uint32_t aIdx,
uint32_t aIdxInParent
#if defined(XP_WIN)
, nsTArray<MsaaMapping>* aNewMsaaIds
#endif // defined(XP_WIN)
);
uint32_t aIdxInParent);
MOZ_MUST_USE bool CheckDocTree() const;
xpcAccessibleGeneric* GetXPCAccessible(ProxyAccessible* aProxy);

View File

@ -34,10 +34,8 @@ void
DocAccessibleChild::SendCOMProxy(const IAccessibleHolder& aProxy)
{
IAccessibleHolder parentProxy;
uint32_t msaaID = AccessibleWrap::kNoID;
PDocAccessibleChild::SendCOMProxy(aProxy, &parentProxy, &msaaID);
PDocAccessibleChild::SendCOMProxy(aProxy, &parentProxy);
mParentProxy.reset(parentProxy.Release());
mDoc->SetID(msaaID);
}
} // namespace a11y

View File

@ -27,12 +27,6 @@ struct ShowEventData
AccessibleData[] NewTree;
};
struct MsaaMapping
{
uint64_t ID;
uint32_t MsaaID;
};
struct Attribute
{
nsCString Name;
@ -51,7 +45,7 @@ parent:
* event.
*/
async Event(uint64_t aID, uint32_t type);
sync ShowEventInfo(ShowEventData data) returns (MsaaMapping[] aNewMsaaIds);
async ShowEvent(ShowEventData data, bool aFromuser);
async HideEvent(uint64_t aRootID, bool aFromUser);
async StateChangeEvent(uint64_t aID, uint64_t aState, bool aEnabled);
async CaretMoveEvent(uint64_t aID, int32_t aOffset);
@ -69,7 +63,7 @@ parent:
// For now we'll add the command to send the proxy here. This might move to
// PDocAccessible constructor in PBrowser.
sync COMProxy(IAccessibleHolder aDocCOMProxy)
returns(IAccessibleHolder aParentCOMProxy, uint32_t aMsaaID);
returns(IAccessibleHolder aParentCOMProxy);
child:
async __delete__();

View File

@ -9,8 +9,6 @@
#include "Compatibility.h"
#include "DocAccessible-inl.h"
#include "mozilla/dom/TabChild.h"
#include "mozilla/a11y/DocAccessibleChild.h"
#include "mozilla/a11y/DocAccessibleParent.h"
#include "EnumVariant.h"
#include "nsAccUtils.h"
@ -71,7 +69,9 @@ static const int32_t kIEnumVariantDisconnected = -1;
////////////////////////////////////////////////////////////////////////////////
AccessibleWrap::AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
Accessible(aContent, aDoc)
#ifdef _WIN64
, mID(kNoID)
#endif
{
}
@ -90,6 +90,7 @@ NS_IMPL_ISUPPORTS_INHERITED0(AccessibleWrap, Accessible)
void
AccessibleWrap::Shutdown()
{
#ifdef _WIN64
if (mID != kNoID) {
auto doc = static_cast<DocAccessibleWrap*>(mDoc);
MOZ_ASSERT(doc);
@ -97,6 +98,7 @@ AccessibleWrap::Shutdown()
doc->RemoveID(mID);
}
}
#endif
Accessible::Shutdown();
}
@ -1145,22 +1147,9 @@ AccessibleWrap::GetNativeInterface(void** aOutAccessible)
NS_ADDREF_THIS();
}
void
AccessibleWrap::SetID(uint32_t aID)
{
MOZ_ASSERT(XRE_IsContentProcess());
mID = aID;
DocAccessibleWrap* doc = static_cast<DocAccessibleWrap*>(Document());
DebugOnly<AccessibleWrap*> checkAcc = nullptr;
MOZ_ASSERT(!(checkAcc = doc->GetAccessibleByID(aID)) ||
checkAcc->GetExistingID() == aID);
doc->AddID(aID, this);
}
void
AccessibleWrap::FireWinEvent(Accessible* aTarget, uint32_t aEventType)
{
MOZ_ASSERT(XRE_IsParentProcess());
static_assert(sizeof(gWinEventMap)/sizeof(gWinEventMap[0]) == nsIAccessibleEvent::EVENT_LAST_ENTRY,
"MSAA event map skewed");
@ -1257,13 +1246,6 @@ AccessibleWrap::GetChildIDFor(Accessible* aAccessible)
return 0;
}
// Content should use mID which has been generated by the chrome process.
if (XRE_IsContentProcess() && !aAccessible->IsApplication()) {
const uint32_t id = static_cast<AccessibleWrap*>(aAccessible)->mID;
MOZ_ASSERT(id != kNoID);
return id;
}
#ifdef _WIN64
if (!aAccessible->Document() && !aAccessible->IsProxy())
return 0;
@ -1304,22 +1286,6 @@ AccessibleWrap::GetHWNDFor(Accessible* aAccessible)
return nullptr;
}
if (XRE_IsContentProcess()) {
DocAccessible* doc = aAccessible->Document();
if (!doc) {
return nullptr;
}
DocAccessibleChild* ipcDoc = doc->IPCDoc();
if (!ipcDoc) {
return nullptr;
}
auto tab = static_cast<dom::TabChild*>(ipcDoc->Manager());
MOZ_ASSERT(tab);
return reinterpret_cast<HWND>(tab->GetNativeWindowHandle());
}
// Accessibles in child processes are said to have the HWND of the window
// their tab is within. Popups are always in the parent process, and so
// never proxied, which means this is basically correct.
@ -1379,6 +1345,7 @@ AccessibleWrap::NativeAccessible(Accessible* aAccessible)
return static_cast<IDispatch*>(msaaAccessible);
}
#ifdef _WIN64
static Accessible*
GetAccessibleInSubtree(DocAccessible* aDoc, uint32_t aID)
{
@ -1395,6 +1362,7 @@ GetAccessibleInSubtree(DocAccessible* aDoc, uint32_t aID)
return nullptr;
}
#endif
static AccessibleWrap*
GetProxiedAccessibleInSubtree(const DocAccessibleParent* aDoc, uint32_t aID)
@ -1458,9 +1426,7 @@ AccessibleWrap::GetXPAccessibleFor(const VARIANT& aVarChild)
#ifdef _WIN64
GetAccessibleInSubtree(document, static_cast<uint32_t>(aVarChild.lVal));
#else
XRE_IsContentProcess() ?
GetAccessibleInSubtree(document, static_cast<uint32_t>(aVarChild.lVal)) :
document->GetAccessibleByUniqueIDInSubtree(uniqueID);
document->GetAccessibleByUniqueIDInSubtree(uniqueID);
#endif
// If it is a document then just return an accessible.

View File

@ -179,15 +179,17 @@ public: // construction, destruction
static IDispatch* NativeAccessible(Accessible* aAccessible);
#ifdef _WIN64
uint32_t GetExistingID() const { return mID; }
static const uint32_t kNoID = 0;
// This is only valid to call in content
void SetID(uint32_t aID);
#endif
protected:
virtual ~AccessibleWrap();
#ifdef _WIN64
uint32_t mID;
#endif
/**
* Return the wrapper for the document's proxy.

View File

@ -48,10 +48,15 @@ STDMETHODIMP
DocAccessibleWrap::get_accParent(
/* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *ppdispParent)
{
HRESULT hr = DocAccessible::get_accParent(ppdispParent);
if (*ppdispParent) {
return hr;
}
// We might be a top-level document in a content process.
DocAccessibleChild* ipcDoc = IPCDoc();
if (!ipcDoc) {
return DocAccessible::get_accParent(ppdispParent);
return S_FALSE;
}
IAccessible* dispParent = ipcDoc->GetParentIAccessible();
if (!dispParent) {

View File

@ -40,11 +40,13 @@ public:
/**
* Manage the mapping from id to Accessible.
*/
#ifdef _WIN64
void AddID(uint32_t aID, AccessibleWrap* aAcc)
{ mIDToAccessibleMap.Put(aID, aAcc); }
void RemoveID(uint32_t aID) { mIDToAccessibleMap.Remove(aID); }
AccessibleWrap* GetAccessibleByID(uint32_t aID) const
{ return mIDToAccessibleMap.Get(aID); }
#endif
protected:
// DocAccessible
@ -56,7 +58,9 @@ protected:
/*
* This provides a mapping from 32 bit id to accessible objects.
*/
#ifdef _WIN64
nsDataHashtable<nsUint32HashKey, AccessibleWrap*> mIDToAccessibleMap;
#endif
};
} // namespace a11y

View File

@ -837,14 +837,6 @@ child:
*/
async Print(uint64_t aOuterWindowID, PrintData aPrintData);
/**
* Update the child with the tab's current top-level native window handle.
* This is used by a11y objects who must expose their native window.
*
* @param aNewHandle The native window handle of the tab's top-level window.
*/
async UpdateNativeWindowHandle(uintptr_t aNewHandle);
/*
* FIXME: write protocol!

View File

@ -548,9 +548,6 @@ TabChild::TabChild(nsIContentChild* aManager,
, mDidSetRealShowInfo(false)
, mDidLoadURLInit(false)
, mAPZChild(nullptr)
#if defined(XP_WIN) && defined(ACCESSIBILITY)
, mNativeWindowHandle(0)
#endif
, mLayerObserverEpoch(0)
{
// In the general case having the TabParent tell us if APZ is enabled or not
@ -2537,17 +2534,6 @@ TabChild::RecvPrint(const uint64_t& aOuterWindowID, const PrintData& aPrintData)
return true;
}
bool
TabChild::RecvUpdateNativeWindowHandle(const uintptr_t& aNewHandle)
{
#if defined(XP_WIN) && defined(ACCESSIBILITY)
mNativeWindowHandle = aNewHandle;
return true;
#else
return false;
#endif
}
bool
TabChild::RecvDestroy()
{

View File

@ -590,8 +590,6 @@ public:
virtual bool RecvPrint(const uint64_t& aOuterWindowID,
const PrintData& aPrintData) override;
virtual bool RecvUpdateNativeWindowHandle(const uintptr_t& aNewHandle) override;
/**
* Native widget remoting protocol for use with windowed plugins with e10s.
*/
@ -650,10 +648,6 @@ public:
mAPZChild = aAPZChild;
}
#if defined(XP_WIN) && defined(ACCESSIBILITY)
uintptr_t GetNativeWindowHandle() const { return mNativeWindowHandle; }
#endif
// Request that the docshell be marked as active.
void ForcePaint(uint64_t aLayerObserverEpoch);
@ -792,11 +786,6 @@ private:
// dangling pointer.
layers::APZChild* mAPZChild;
#if defined(XP_WIN) && defined(ACCESSIBILITY)
// The handle associated with the native window that contains this tab
uintptr_t mNativeWindowHandle;
#endif // defined(XP_WIN)
// The most recently seen layer observer epoch in RecvSetDocShellIsActive.
uint64_t mLayerObserverEpoch;

View File

@ -400,17 +400,6 @@ TabParent::SetOwnerElement(Element* aElement)
Unused << SendSetUseGlobalHistory(useGlobalHistory);
}
#if defined(XP_WIN) && defined(ACCESSIBILITY)
if (!mIsDestroyed) {
uintptr_t newWindowHandle = 0;
if (nsCOMPtr<nsIWidget> widget = GetWidget()) {
newWindowHandle =
reinterpret_cast<uintptr_t>(widget->GetNativeData(NS_NATIVE_WINDOW));
}
Unused << SendUpdateNativeWindowHandle(newWindowHandle);
}
#endif
AddWindowListeners();
TryCacheDPIAndScale();
}