Skip to content

Commit

Permalink
Bug 1314254 - Add mozilla::ipc::IPCResult type and convert IPDL handl…
Browse files Browse the repository at this point in the history
…ers to use new return type. r=billm

We will use the new type for the generated IPDL message handler
prototype to make sure correct error handling method is called.

MozReview-Commit-ID: AzVbApxFGZ0
  • Loading branch information
kanru committed Nov 15, 2016
1 parent 76b9f04 commit 1c46520
Show file tree
Hide file tree
Showing 404 changed files with 7,202 additions and 6,673 deletions.
95 changes: 50 additions & 45 deletions accessible/ipc/DocAccessibleParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
namespace mozilla {
namespace a11y {

bool
mozilla::ipc::IPCResult
DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
const bool& aFromUser)
{
if (mShutdown)
return true;
return IPC_OK();

MOZ_DIAGNOSTIC_ASSERT(CheckDocTree());

if (aData.NewTree().IsEmpty()) {
NS_ERROR("no children being added");
return false;
return IPC_FAIL_NO_REASON(this);
}

ProxyAccessible* parent = GetAccessible(aData.ID());
Expand All @@ -35,13 +35,13 @@ DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
// required show events.
if (!parent) {
NS_ERROR("adding child to unknown accessible");
return true;
return IPC_OK();
}

uint32_t newChildIdx = aData.Idx();
if (newChildIdx > parent->ChildrenCount()) {
NS_ERROR("invalid index to add child at");
return true;
return IPC_OK();
}

uint32_t consumed = AddSubtree(parent, aData.NewTree(), 0, newChildIdx);
Expand All @@ -50,7 +50,7 @@ DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
// XXX This shouldn't happen, but if we failed to add children then the below
// is pointless and can crash.
if (!consumed) {
return true;
return IPC_OK();
}

#ifdef DEBUG
Expand All @@ -66,7 +66,7 @@ DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
ProxyShowHideEvent(target, parent, true, aFromUser);

if (!nsCoreUtils::AccEventObserversExist()) {
return true;
return IPC_OK();
}

uint32_t type = nsIAccessibleEvent::EVENT_SHOW;
Expand All @@ -77,7 +77,7 @@ DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
aFromUser);
nsCoreUtils::DispatchAccEvent(Move(event));

return true;
return IPC_OK();
}

uint32_t
Expand Down Expand Up @@ -130,32 +130,32 @@ DocAccessibleParent::AddSubtree(ProxyAccessible* aParent,
return accessibles;
}

bool
mozilla::ipc::IPCResult
DocAccessibleParent::RecvHideEvent(const uint64_t& aRootID,
const bool& aFromUser)
{
if (mShutdown)
return true;
return IPC_OK();

MOZ_DIAGNOSTIC_ASSERT(CheckDocTree());

// We shouldn't actually need this because mAccessibles shouldn't have an
// entry for the document itself, but it doesn't hurt to be explicit.
if (!aRootID) {
NS_ERROR("trying to hide entire document?");
return false;
return IPC_FAIL_NO_REASON(this);
}

ProxyEntry* rootEntry = mAccessibles.GetEntry(aRootID);
if (!rootEntry) {
NS_ERROR("invalid root being removed!");
return true;
return IPC_OK();
}

ProxyAccessible* root = rootEntry->mProxy;
if (!root) {
NS_ERROR("invalid root being removed!");
return true;
return IPC_OK();
}

ProxyAccessible* parent = root->Parent();
Expand Down Expand Up @@ -185,22 +185,22 @@ DocAccessibleParent::RecvHideEvent(const uint64_t& aRootID,
nsCoreUtils::DispatchAccEvent(Move(event));
}

return true;
return IPC_OK();
}

bool
mozilla::ipc::IPCResult
DocAccessibleParent::RecvEvent(const uint64_t& aID, const uint32_t& aEventType)
{
ProxyAccessible* proxy = GetAccessible(aID);
if (!proxy) {
NS_ERROR("no proxy for event!");
return true;
return IPC_OK();
}

ProxyEvent(proxy, aEventType);

if (!nsCoreUtils::AccEventObserversExist()) {
return true;
return IPC_OK();
}

xpcAccessibleGeneric* xpcAcc = GetXPCAccessible(proxy);
Expand All @@ -211,24 +211,24 @@ DocAccessibleParent::RecvEvent(const uint64_t& aID, const uint32_t& aEventType)
fromUser);
nsCoreUtils::DispatchAccEvent(Move(event));

return true;
return IPC_OK();
}

bool
mozilla::ipc::IPCResult
DocAccessibleParent::RecvStateChangeEvent(const uint64_t& aID,
const uint64_t& aState,
const bool& aEnabled)
{
ProxyAccessible* target = GetAccessible(aID);
if (!target) {
NS_ERROR("we don't know about the target of a state change event!");
return true;
return IPC_OK();
}

ProxyStateChangeEvent(target, aState, aEnabled);

if (!nsCoreUtils::AccEventObserversExist()) {
return true;
return IPC_OK();
}

xpcAccessibleGeneric* xpcAcc = GetXPCAccessible(target);
Expand All @@ -243,22 +243,22 @@ DocAccessibleParent::RecvStateChangeEvent(const uint64_t& aID,
aEnabled);
nsCoreUtils::DispatchAccEvent(Move(event));

return true;
return IPC_OK();
}

bool
mozilla::ipc::IPCResult
DocAccessibleParent::RecvCaretMoveEvent(const uint64_t& aID, const int32_t& aOffset)
{
ProxyAccessible* proxy = GetAccessible(aID);
if (!proxy) {
NS_ERROR("unknown caret move event target!");
return true;
return IPC_OK();
}

ProxyCaretMoveEvent(proxy, aOffset);

if (!nsCoreUtils::AccEventObserversExist()) {
return true;
return IPC_OK();
}

xpcAccessibleGeneric* xpcAcc = GetXPCAccessible(proxy);
Expand All @@ -270,10 +270,10 @@ DocAccessibleParent::RecvCaretMoveEvent(const uint64_t& aID, const int32_t& aOff
new xpcAccCaretMoveEvent(type, xpcAcc, doc, node, fromUser, aOffset);
nsCoreUtils::DispatchAccEvent(Move(event));

return true;
return IPC_OK();
}

bool
mozilla::ipc::IPCResult
DocAccessibleParent::RecvTextChangeEvent(const uint64_t& aID,
const nsString& aStr,
const int32_t& aStart,
Expand All @@ -284,13 +284,13 @@ DocAccessibleParent::RecvTextChangeEvent(const uint64_t& aID,
ProxyAccessible* target = GetAccessible(aID);
if (!target) {
NS_ERROR("text change event target is unknown!");
return true;
return IPC_OK();
}

ProxyTextChangeEvent(target, aStr, aStart, aLen, aIsInsert, aFromUser);

if (!nsCoreUtils::AccEventObserversExist()) {
return true;
return IPC_OK();
}

xpcAccessibleGeneric* xpcAcc = GetXPCAccessible(target);
Expand All @@ -303,10 +303,10 @@ DocAccessibleParent::RecvTextChangeEvent(const uint64_t& aID,
aIsInsert, aStr);
nsCoreUtils::DispatchAccEvent(Move(event));

return true;
return IPC_OK();
}

bool
mozilla::ipc::IPCResult
DocAccessibleParent::RecvSelectionEvent(const uint64_t& aID,
const uint64_t& aWidgetID,
const uint32_t& aType)
Expand All @@ -315,42 +315,42 @@ DocAccessibleParent::RecvSelectionEvent(const uint64_t& aID,
ProxyAccessible* widget = GetAccessible(aWidgetID);
if (!target || !widget) {
NS_ERROR("invalid id in selection event");
return true;
return IPC_OK();
}

ProxySelectionEvent(target, widget, aType);
if (!nsCoreUtils::AccEventObserversExist()) {
return true;
return IPC_OK();
}
xpcAccessibleGeneric* xpcTarget = GetXPCAccessible(target);
xpcAccessibleDocument* xpcDoc = GetAccService()->GetXPCDocument(this);
RefPtr<xpcAccEvent> event = new xpcAccEvent(aType, xpcTarget, xpcDoc,
nullptr, false);
nsCoreUtils::DispatchAccEvent(Move(event));

return true;
return IPC_OK();
}

bool
mozilla::ipc::IPCResult
DocAccessibleParent::RecvRoleChangedEvent(const uint32_t& aRole)
{
if (aRole >= roles::LAST_ROLE) {
NS_ERROR("child sent bad role in RoleChangedEvent");
return false;
return IPC_FAIL_NO_REASON(this);
}

mRole = static_cast<a11y::role>(aRole);
return true;
return IPC_OK();
}

bool
mozilla::ipc::IPCResult
DocAccessibleParent::RecvBindChildDoc(PDocAccessibleParent* aChildDoc, const uint64_t& aID)
{
// One document should never directly be the child of another.
// We should always have at least an outer doc accessible in between.
MOZ_ASSERT(aID);
if (!aID)
return false;
return IPC_FAIL_NO_REASON(this);

MOZ_DIAGNOSTIC_ASSERT(CheckDocTree());

Expand All @@ -359,7 +359,10 @@ DocAccessibleParent::RecvBindChildDoc(PDocAccessibleParent* aChildDoc, const uin
bool result = AddChildDoc(childDoc, aID, false);
MOZ_ASSERT(result);
MOZ_DIAGNOSTIC_ASSERT(CheckDocTree());
return result;
if (!result) {
return IPC_FAIL_NO_REASON(this);
}
return IPC_OK();
}

bool
Expand Down Expand Up @@ -395,16 +398,18 @@ DocAccessibleParent::AddChildDoc(DocAccessibleParent* aChildDoc,
return true;
}

bool
mozilla::ipc::IPCResult
DocAccessibleParent::RecvShutdown()
{
Destroy();

if (!static_cast<dom::TabParent*>(Manager())->IsDestroyed()) {
return PDocAccessibleParent::Send__delete__(this);
if (!PDocAccessibleParent::Send__delete__(this)) {
return IPC_FAIL_NO_REASON(this);
}
}

return true;
return IPC_OK();
}

void
Expand Down Expand Up @@ -465,7 +470,7 @@ DocAccessibleParent::GetXPCAccessible(ProxyAccessible* aProxy)
* the parent of the document. The content process will use this
* proxy when traversing up across the content/chrome boundary.
*/
bool
mozilla::ipc::IPCResult
DocAccessibleParent::RecvCOMProxy(const IAccessibleHolder& aCOMProxy,
IAccessibleHolder* aParentCOMProxy)
{
Expand All @@ -479,7 +484,7 @@ DocAccessibleParent::RecvCOMProxy(const IAccessibleHolder& aCOMProxy,
}

aParentCOMProxy->Set(IAccessibleHolder::COMPtrType(rawNative));
return true;
return IPC_OK();
}
#endif // defined(XP_WIN)

Expand Down
38 changes: 19 additions & 19 deletions accessible/ipc/DocAccessibleParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,32 @@ class DocAccessibleParent : public ProxyAccessible,
* Called when a message from a document in a child process notifies the main
* process it is firing an event.
*/
virtual bool RecvEvent(const uint64_t& aID, const uint32_t& aType)
virtual mozilla::ipc::IPCResult RecvEvent(const uint64_t& aID, const uint32_t& aType)
override;

virtual bool RecvShowEvent(const ShowEventData& aData, const bool& aFromUser)
virtual mozilla::ipc::IPCResult RecvShowEvent(const ShowEventData& aData, const bool& aFromUser)
override;
virtual bool RecvHideEvent(const uint64_t& aRootID, const bool& aFromUser)
virtual mozilla::ipc::IPCResult RecvHideEvent(const uint64_t& aRootID, const bool& aFromUser)
override;
virtual bool RecvStateChangeEvent(const uint64_t& aID,
const uint64_t& aState,
const bool& aEnabled) override final;
virtual mozilla::ipc::IPCResult RecvStateChangeEvent(const uint64_t& aID,
const uint64_t& aState,
const bool& aEnabled) override final;

virtual bool RecvCaretMoveEvent(const uint64_t& aID, const int32_t& aOffset)
virtual mozilla::ipc::IPCResult RecvCaretMoveEvent(const uint64_t& aID, const int32_t& aOffset)
override final;

virtual bool RecvTextChangeEvent(const uint64_t& aID, const nsString& aStr,
const int32_t& aStart, const uint32_t& aLen,
const bool& aIsInsert,
const bool& aFromUser) override;
virtual mozilla::ipc::IPCResult RecvTextChangeEvent(const uint64_t& aID, const nsString& aStr,
const int32_t& aStart, const uint32_t& aLen,
const bool& aIsInsert,
const bool& aFromUser) override;

virtual bool RecvSelectionEvent(const uint64_t& aID,
const uint64_t& aWidgetID,
const uint32_t& aType) override;
virtual mozilla::ipc::IPCResult RecvSelectionEvent(const uint64_t& aID,
const uint64_t& aWidgetID,
const uint32_t& aType) override;

virtual bool RecvRoleChangedEvent(const uint32_t& aRole) override final;
virtual mozilla::ipc::IPCResult RecvRoleChangedEvent(const uint32_t& aRole) override final;

virtual bool RecvBindChildDoc(PDocAccessibleParent* aChildDoc, const uint64_t& aID) override;
virtual mozilla::ipc::IPCResult RecvBindChildDoc(PDocAccessibleParent* aChildDoc, const uint64_t& aID) override;

void Unbind()
{
Expand All @@ -84,7 +84,7 @@ class DocAccessibleParent : public ProxyAccessible,
mParentDoc = nullptr;
}

virtual bool RecvShutdown() override;
virtual mozilla::ipc::IPCResult RecvShutdown() override;
void Destroy();
virtual void ActorDestroy(ActorDestroyReason aWhy) override
{
Expand Down Expand Up @@ -144,8 +144,8 @@ class DocAccessibleParent : public ProxyAccessible,
{ return mChildDocs[aIdx]; }

#if defined(XP_WIN)
virtual bool RecvCOMProxy(const IAccessibleHolder& aCOMProxy,
IAccessibleHolder* aParentCOMProxy) override;
virtual mozilla::ipc::IPCResult RecvCOMProxy(const IAccessibleHolder& aCOMProxy,
IAccessibleHolder* aParentCOMProxy) override;
#endif

private:
Expand Down
Loading

0 comments on commit 1c46520

Please sign in to comment.