зеркало из https://github.com/mozilla/pjs.git
Bug 358884 Add assertion to ensure accessible object with a text child supports the right interfaces
patch by Evan Yan at sun.com r=aaronleventhal,hwaara
This commit is contained in:
Родитель
e2cb37921f
Коммит
189926e941
|
@ -810,6 +810,12 @@ getRoleCB(AtkObject *aAtkObj)
|
|||
{
|
||||
NS_ENSURE_SUCCESS(CheckMaiAtkObject(aAtkObj), ATK_ROLE_INVALID);
|
||||
|
||||
#ifdef DEBUG_A11Y
|
||||
nsAccessibleWrap *testAccWrap =
|
||||
NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
|
||||
NS_ASSERTION(nsAccessible::IsTextInterfaceSupportCorrect(testAccWrap), "Does not support nsIAccessibleText when it should");
|
||||
#endif
|
||||
|
||||
if (aAtkObj->role == ATK_ROLE_INVALID) {
|
||||
nsAccessibleWrap *accWrap =
|
||||
NS_REINTERPRET_CAST(MaiAtkObject*, aAtkObj)->accWrap;
|
||||
|
|
|
@ -107,6 +107,40 @@
|
|||
NS_IMPL_ADDREF_INHERITED(nsAccessible, nsAccessNode)
|
||||
NS_IMPL_RELEASE_INHERITED(nsAccessible, nsAccessNode)
|
||||
|
||||
#ifdef DEBUG_A11Y
|
||||
/*
|
||||
* static
|
||||
* help method. to detect whether this accessible object implements
|
||||
* nsIAccessibleText, when it is text or has text child node.
|
||||
*/
|
||||
PRBool nsAccessible::IsTextInterfaceSupportCorrect(nsIAccessible *aAccessible)
|
||||
{
|
||||
PRBool foundText = PR_FALSE;
|
||||
|
||||
if (IsText(aAccessible)) {
|
||||
foundText = PR_TRUE;
|
||||
}
|
||||
nsCOMPtr<nsIAccessible> child, nextSibling;
|
||||
aAccessible->GetFirstChild(getter_AddRefs(child));
|
||||
while (child) {
|
||||
if (IsText(child)) {
|
||||
foundText = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
child->GetNextSibling(getter_AddRefs(nextSibling));
|
||||
child.swap(nextSibling);
|
||||
}
|
||||
if (foundText) {
|
||||
// found text child node
|
||||
nsCOMPtr<nsIAccessibleText> text = do_QueryInterface(aAccessible);
|
||||
if (!text) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult nsAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
// Custom-built QueryInterface() knows when we support nsIAccessibleSelectable
|
||||
|
|
|
@ -142,6 +142,10 @@ public:
|
|||
nsIFrame **aFirstTextFrame, const nsIFrame *aTextFrame);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_A11Y
|
||||
static PRBool IsTextInterfaceSupportCorrect(nsIAccessible *aAccessible);
|
||||
#endif
|
||||
|
||||
static PRBool IsCorrectFrameType(nsIFrame* aFrame, nsIAtom* aAtom);
|
||||
static PRUint32 State(nsIAccessible *aAcc) { PRUint32 state; aAcc->GetFinalState(&state); return state; }
|
||||
static PRUint32 Role(nsIAccessible *aAcc) { PRUint32 role; aAcc->GetFinalRole(&role); return role; }
|
||||
|
|
|
@ -366,6 +366,9 @@ ObjectOrUnignoredAncestor(id anObject)
|
|||
|
||||
- (NSString*)role
|
||||
{
|
||||
#ifdef DEBUG_A11Y
|
||||
NS_ASSERTION(nsAccessible::IsTextInterfaceSupportCorrect(mGeckoAccessible), "Does not support nsIAccessibleText when it should");
|
||||
#endif
|
||||
PRUint32 roleInt = 0;
|
||||
mGeckoAccessible->GetFinalRole (&roleInt);
|
||||
return AXRoles[roleInt]; // see nsRoleMap.h
|
||||
|
|
|
@ -434,6 +434,10 @@ STDMETHODIMP nsAccessibleWrap::get_accRole(
|
|||
if (!xpAccessible)
|
||||
return E_FAIL;
|
||||
|
||||
#ifdef DEBUG_A11Y
|
||||
NS_ASSERTION(nsAccessible::IsTextInterfaceSupportCorrect(xpAccessible), "Does not support nsIAccessibleText when it should");
|
||||
#endif
|
||||
|
||||
PRUint32 xpRole = 0, msaaRole = 0;
|
||||
if (NS_FAILED(xpAccessible->GetFinalRole(&xpRole)))
|
||||
return E_FAIL;
|
||||
|
|
Загрузка…
Ссылка в новой задаче