Bug 779091 - Make Accessible::Init() infallible; r=surkov

This commit is contained in:
Aryeh Gregor 2012-07-27 16:53:02 +03:00
parent abda96b8c6
commit 7a0712368b
14 changed files with 20 additions and 42 deletions

View File

@ -572,7 +572,7 @@ toplevel_event_watcher(GSignalInvocationHint* ihint,
return TRUE;
}
bool
void
ApplicationAccessibleWrap::Init()
{
if (ShouldA11yBeEnabled()) {
@ -615,7 +615,7 @@ ApplicationAccessibleWrap::Init()
}
}
return ApplicationAccessible::Init();
ApplicationAccessible::Init();
}
void

View File

@ -23,7 +23,7 @@ public:
virtual ~ApplicationAccessibleWrap();
// nsAccessNode
virtual bool Init();
virtual void Init();
// Accessible
virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);

View File

@ -388,10 +388,7 @@ nsAccDocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
mDocAccessibleCache.Put(aDocument, docAcc);
// Initialize the document accessible.
if (!docAcc->Init()) {
docAcc->Shutdown();
return nullptr;
}
docAcc->Init();
docAcc->SetRoleMapEntry(aria::GetRoleMap(aDocument));
// Bind the document to the tree.

View File

@ -96,12 +96,7 @@ nsAccessNode::GetApplicationAccessible()
// Addref on create. Will Release in ShutdownXPAccessibility()
NS_ADDREF(gApplicationAccessible);
nsresult rv = gApplicationAccessible->Init();
if (NS_FAILED(rv)) {
gApplicationAccessible->Shutdown();
NS_RELEASE(gApplicationAccessible);
return nullptr;
}
gApplicationAccessible->Init();
}
return gApplicationAccessible;

View File

@ -195,10 +195,9 @@ Accessible::SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry)
mRoleMapEntry = aRoleMapEntry;
}
bool
void
Accessible::Init()
{
return true;
}
NS_IMETHODIMP

View File

@ -129,7 +129,7 @@ public:
/**
* Initialize the accessible.
*/
virtual bool Init();
virtual void Init();
/**
* Get the description of this accessible.

View File

@ -268,11 +268,10 @@ ApplicationAccessible::GetPlatformVersion(nsAString& aVersion)
////////////////////////////////////////////////////////////////////////////////
// nsAccessNode public methods
bool
void
ApplicationAccessible::Init()
{
mAppInfo = do_GetService("@mozilla.org/xre/app-info;1");
return true;
}
void

View File

@ -61,7 +61,7 @@ public:
NS_DECL_NSIACCESSIBLEAPPLICATION
// nsAccessNode
virtual bool Init();
virtual void Init();
virtual void Shutdown();
virtual bool IsPrimaryForNode() const;

View File

@ -604,7 +604,7 @@ DocAccessible::GetAccessible(nsINode* aNode) const
////////////////////////////////////////////////////////////////////////////////
// nsAccessNode
bool
void
DocAccessible::Init()
{
#ifdef DEBUG
@ -614,8 +614,6 @@ DocAccessible::Init()
// Initialize notification controller.
mNotificationController = new NotificationController(this, mPresShell);
if (!mNotificationController)
return false;
// Mark the document accessible as loaded if its DOM document was loaded at
// this point (this can happen because a11y is started late or DOM document
@ -624,7 +622,6 @@ DocAccessible::Init()
mLoadState |= eDOMLoaded;
AddEventListeners();
return true;
}
void
@ -1397,12 +1394,7 @@ DocAccessible::BindToDocument(Accessible* aAccessible,
mAccessibleCache.Put(aAccessible->UniqueID(), aAccessible);
// Initialize the accessible.
if (!aAccessible->Init()) {
NS_ERROR("Failed to initialize an accessible!");
UnbindFromDocument(aAccessible);
return false;
}
aAccessible->Init();
aAccessible->SetRoleMapEntry(aRoleMapEntry);
if (aAccessible->IsElement())

View File

@ -71,7 +71,7 @@ public:
NS_DECL_NSIDOCUMENTOBSERVER
// nsAccessNode
virtual bool Init();
virtual void Init();
virtual void Shutdown();
virtual nsIFrame* GetFrame() const;
virtual nsINode* GetNode() const { return mDocument; }

View File

@ -1150,14 +1150,11 @@ XULTreeItemAccessible::Name(nsString& aName)
////////////////////////////////////////////////////////////////////////////////
// XULTreeItemAccessible: nsAccessNode implementation
bool
void
XULTreeItemAccessible::Init()
{
if (!XULTreeItemAccessibleBase::Init())
return false;
XULTreeItemAccessibleBase::Init();
Name(mCachedName);
return true;
}
void

View File

@ -235,7 +235,7 @@ public:
XULTreeItemAccessibleBase)
// nsAccessNode
virtual bool Init();
virtual void Init();
virtual void Shutdown();
// Accessible

View File

@ -779,11 +779,12 @@ XULTreeGridCellAccessible::IsSelected(bool* aIsSelected)
////////////////////////////////////////////////////////////////////////////////
// XULTreeGridCellAccessible: nsAccessNode implementation
bool
void
XULTreeGridCellAccessible::Init()
{
if (!LeafAccessible::Init() || !mTreeView)
return false;
LeafAccessible::Init();
NS_ASSERTION(mTreeView, "mTreeView is null");
PRInt16 type;
mColumn->GetType(&type);
@ -791,8 +792,6 @@ XULTreeGridCellAccessible::Init()
mTreeView->GetCellValue(mRow, mColumn, mCachedTextEquiv);
else
mTreeView->GetCellText(mRow, mColumn, mCachedTextEquiv);
return true;
}
bool

View File

@ -150,7 +150,7 @@ public:
NS_DECL_OR_FORWARD_NSIACCESSIBLETABLECELL_WITH_XPCACCESSIBLETABLECELL
// nsAccessNode
virtual bool Init();
virtual void Init();
virtual bool IsPrimaryForNode() const;
// Accessible