Accessibility: Clean up usage of navigate.
Prefer to use parent/child functions instead. Change-Id: Ic92165b9439eb750c9d762ddf5dcd2a5ccf0277d Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
This commit is contained in:
parent
6f9fb98886
commit
6e7f08182e
@ -88,8 +88,7 @@ void QPlatformAccessibility::notifyAccessibilityUpdate(QObject *o,
|
||||
|
||||
// updates for List/Table/Tree should send child
|
||||
if (who) {
|
||||
QAccessibleInterface *child;
|
||||
iface->navigate(QAccessible::Child, who, &child);
|
||||
QAccessibleInterface *child = iface->child(who - 1);
|
||||
if (child) {
|
||||
delete iface;
|
||||
iface = child;
|
||||
|
@ -512,12 +512,11 @@ int QAccessibleItemRow::navigate(RelationFlag relation, int index,
|
||||
return index;}
|
||||
case Sibling:
|
||||
if (index) {
|
||||
QAccessibleInterface *ifaceParent = 0;
|
||||
navigate(Ancestor, 1, &ifaceParent);
|
||||
QAccessibleInterface *ifaceParent = parent();
|
||||
if (ifaceParent) {
|
||||
int entry = ifaceParent->navigate(Child, index, iface);
|
||||
*iface = ifaceParent->child(index - 1);
|
||||
delete ifaceParent;
|
||||
return entry;
|
||||
return *iface ? 0 : -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@ -589,11 +588,11 @@ QAccessible::State QAccessibleItemRow::state(int child) const
|
||||
if (!view)
|
||||
return st;
|
||||
|
||||
QAccessibleInterface *parent = 0;
|
||||
QAccessibleInterface *parentIface = parent();
|
||||
QRect globalRect;
|
||||
if (navigate(Ancestor, 1, &parent) == 0) {
|
||||
globalRect = parent->rect(0);
|
||||
delete parent;
|
||||
if (parentIface) {
|
||||
globalRect = parentIface->rect(0);
|
||||
delete parentIface;
|
||||
}
|
||||
if (!globalRect.intersects(rect(child)))
|
||||
st |= Invisible;
|
||||
@ -998,11 +997,11 @@ void QAccessibleItemView::setText(Text t, int child, const QString &text)
|
||||
}
|
||||
}
|
||||
|
||||
QRect QAccessibleItemView::rect(int child) const
|
||||
QRect QAccessibleItemView::rect(int childIndex) const
|
||||
{
|
||||
if (atViewport()) {
|
||||
QRect r;
|
||||
if (!child) {
|
||||
if (!childIndex) {
|
||||
// Make sure that the rect *include* the vertical and horizontal headers, while
|
||||
// not including the potential vertical and horizontal scrollbars.
|
||||
QAbstractItemView *w = itemView();
|
||||
@ -1025,16 +1024,16 @@ QRect QAccessibleItemView::rect(int child) const
|
||||
r.adjust(0, 0, -vscrollWidth, -hscrollHeight);
|
||||
}
|
||||
} else {
|
||||
QAccessibleInterface *iface = 0;
|
||||
if (navigate(Child, child, &iface) == 0) {
|
||||
QAccessibleInterface *iface = child(childIndex - 1);
|
||||
if (iface) {
|
||||
r = iface->rect(0);
|
||||
delete iface;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
} else {
|
||||
QRect r = QAccessibleAbstractScrollArea::rect(child);
|
||||
if (child == 1) {
|
||||
QRect r = QAccessibleAbstractScrollArea::rect(childIndex);
|
||||
if (childIndex == 1) {
|
||||
// include the potential vertical and horizontal headers
|
||||
|
||||
const QHeaderView *header = verticalHeader();
|
||||
|
@ -851,10 +851,9 @@ int QAccessibleTable2Cell::navigate(RelationFlag relation, int index, QAccessibl
|
||||
case Sibling:
|
||||
if (index > 0) {
|
||||
QAccessibleInterface *parent = queryAccessibleInterface(view);
|
||||
int ret = parent->navigate(QAccessible::Child, index, iface);
|
||||
*iface = parent->child(index - 1);
|
||||
delete parent;
|
||||
if (*iface)
|
||||
return ret;
|
||||
return *iface ? 0 : -1;
|
||||
}
|
||||
return -1;
|
||||
|
||||
|
@ -272,50 +272,45 @@ QAccessibleInterface *QAccessibleMenuItem::child(int index) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int QAccessibleMenuItem::navigate(RelationFlag relation, int entry, QAccessibleInterface ** target ) const
|
||||
int QAccessibleMenuItem::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
|
||||
{
|
||||
int ret = -1;
|
||||
if (entry < 0) {
|
||||
*target = 0;
|
||||
return ret;
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (relation) {
|
||||
case Child:
|
||||
*target = child(entry - 1);
|
||||
ret = *target ? 0 : -1;
|
||||
break;
|
||||
case Ancestor:
|
||||
*target = parent();
|
||||
return 0;
|
||||
break;
|
||||
case Up:
|
||||
case Down:{
|
||||
QAccessibleInterface *parent = 0;
|
||||
int ent = navigate(Ancestor, 1, &parent);
|
||||
if (ent == 0) {
|
||||
int index = parent->indexOfChild(this);
|
||||
QAccessibleInterface *parentIface = parent();
|
||||
if (parentIface) {
|
||||
int index = parentIface->indexOfChild(this);
|
||||
if (index != -1) {
|
||||
index += (relation == Down ? +1 : -1);
|
||||
ret = parent->navigate(Child, index, target);
|
||||
*target = parentIface->child(index - 1);
|
||||
}
|
||||
}
|
||||
delete parent;
|
||||
break;}
|
||||
delete parentIface;
|
||||
break;
|
||||
}
|
||||
case Sibling: {
|
||||
QAccessibleInterface *parent = 0;
|
||||
int ent = navigate(Ancestor, 1, &parent);
|
||||
if (ent == 0) {
|
||||
ret = parent->navigate(Child, entry, target);
|
||||
}
|
||||
delete parent;
|
||||
break;}
|
||||
QAccessibleInterface *parentIface = parent();
|
||||
if (parentIface)
|
||||
*target = parentIface->child(entry - 1);
|
||||
delete parentIface;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
if (ret == -1)
|
||||
*target = 0;
|
||||
return ret;
|
||||
return *target ? 0 : -1;
|
||||
}
|
||||
|
||||
QObject *QAccessibleMenuItem::object() const
|
||||
|
@ -1419,9 +1419,6 @@ int QAccessibleTitleBar::navigate(RelationFlag relation, int entry, QAccessibleI
|
||||
case Ancestor:
|
||||
*iface = parent();
|
||||
return iface ? 0 : -1;
|
||||
case Sibling:
|
||||
return navigate(Child, entry, iface);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -824,8 +824,7 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::accNavigate(long navDir, VARIANT v
|
||||
case NAVDIR_NEXT:
|
||||
case NAVDIR_PREVIOUS:
|
||||
if (!varStart.lVal){
|
||||
QAccessibleInterface *parent = 0;
|
||||
accessible->navigate(Ancestor, 1, &parent);
|
||||
QAccessibleInterface *parent = accessible->parent();
|
||||
if (parent) {
|
||||
int index = parent->indexOfChild(accessible);
|
||||
index += (navDir == NAVDIR_NEXT) ? 1 : -1;
|
||||
@ -944,8 +943,7 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accParent(IDispatch** ppdispPa
|
||||
if (!accessible->isValid())
|
||||
return E_FAIL;
|
||||
|
||||
QAccessibleInterface *acc = 0;
|
||||
accessible->navigate(Ancestor, 1, &acc);
|
||||
QAccessibleInterface *acc = accessible->parent();
|
||||
if (acc) {
|
||||
QWindowsAccessible* wacc = new QWindowsAccessible(acc);
|
||||
wacc->QueryInterface(IID_IDispatch, (void**)ppdispParent);
|
||||
|
@ -109,7 +109,7 @@ InterfaceChildPair WidgetNavigator::find(QAccessible::Text textType, const QStri
|
||||
}
|
||||
|
||||
/*
|
||||
Recursiveley navigates the accessible hiearchy looking for an interfafce that
|
||||
Recursiveley navigates the accessible hiearchy looking for an interface that
|
||||
passsed the Test (meaning it returns true).
|
||||
*/
|
||||
InterfaceChildPair WidgetNavigator::recursiveSearch(TestBase *test, QAccessibleInterface *iface, int possibleChild)
|
||||
@ -128,13 +128,10 @@ InterfaceChildPair WidgetNavigator::recursiveSearch(TestBase *test, QAccessibleI
|
||||
|
||||
const int numChildren = testInterface.iface->childCount();
|
||||
for (int i = 0; i < numChildren; ++i) {
|
||||
QAccessibleInterface *childInterface = 0;
|
||||
int newPossibleChild = testInterface.iface->navigate(QAccessible::Child, i + 1, &childInterface);
|
||||
QAccessibleInterface *childInterface = testInterface.iface->child(i);
|
||||
if (childInterface) {
|
||||
todoInterfaces.push(InterfaceChildPair(childInterface, newPossibleChild));
|
||||
todoInterfaces.push(InterfaceChildPair(childInterface, 0));
|
||||
deleteInDestructor(childInterface);
|
||||
} else if (newPossibleChild != -1) {
|
||||
todoInterfaces.push(InterfaceChildPair(testInterface.iface, newPossibleChild));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -172,8 +172,7 @@ static int verifyHierarchy(QAccessibleInterface *iface)
|
||||
if2 = iface->child(i);
|
||||
EXPECT(if2 != 0);
|
||||
// navigate Ancestor...
|
||||
QAccessibleInterface *parent = 0;
|
||||
parent = if2->parent();
|
||||
QAccessibleInterface *parent = if2->parent();
|
||||
EXPECT(iface->object() == parent->object());
|
||||
delete parent;
|
||||
|
||||
@ -1533,8 +1532,8 @@ void tst_QAccessibility::menuTest()
|
||||
QAccessibleInterface *iface2 = 0;
|
||||
|
||||
// traverse siblings with navigate(Sibling, ...)
|
||||
int entry = interface->navigate(QAccessible::Child, 1, &iface);
|
||||
QCOMPARE(entry, 0);
|
||||
int entry;
|
||||
iface = interface->child(0);
|
||||
QVERIFY(iface);
|
||||
QCOMPARE(iface->role(), QAccessible::MenuItem);
|
||||
|
||||
@ -1555,8 +1554,7 @@ void tst_QAccessibility::menuTest()
|
||||
delete iface;
|
||||
|
||||
// traverse menu items with navigate(Down, ...)
|
||||
entry = interface->navigate(QAccessible::Child, 1, &iface);
|
||||
QCOMPARE(entry, 0);
|
||||
iface = interface->child(0);
|
||||
QVERIFY(iface);
|
||||
QCOMPARE(iface->role(), QAccessible::MenuItem);
|
||||
|
||||
@ -1571,8 +1569,7 @@ void tst_QAccessibility::menuTest()
|
||||
delete iface;
|
||||
|
||||
// traverse menu items with navigate(Up, ...)
|
||||
entry = interface->navigate(QAccessible::Child, interface->childCount(), &iface);
|
||||
QCOMPARE(entry, 0);
|
||||
iface = interface->child(interface->childCount() - 1);
|
||||
QVERIFY(iface);
|
||||
QCOMPARE(iface->role(), QAccessible::MenuItem);
|
||||
|
||||
@ -1587,13 +1584,12 @@ void tst_QAccessibility::menuTest()
|
||||
delete iface;
|
||||
|
||||
// "New" item
|
||||
entry = interface->navigate(QAccessible::Child, 1, &iface);
|
||||
QCOMPARE(entry, 0);
|
||||
iface = interface->child(0);
|
||||
QVERIFY(iface);
|
||||
QCOMPARE(iface->role(), QAccessible::MenuItem);
|
||||
|
||||
// "New" menu
|
||||
entry = iface->navigate(QAccessible::Child, 1, &iface2);
|
||||
iface2 = iface->child(0);
|
||||
delete iface;
|
||||
iface = iface2;
|
||||
QCOMPARE(entry, 0);
|
||||
@ -1601,10 +1597,9 @@ void tst_QAccessibility::menuTest()
|
||||
QCOMPARE(iface->role(), QAccessible::PopupMenu);
|
||||
|
||||
// "Text file" menu item
|
||||
entry = iface->navigate(QAccessible::Child, 1, &iface2);
|
||||
iface2 = iface->child(0);
|
||||
delete iface;
|
||||
iface = iface2;
|
||||
QCOMPARE(entry, 0);
|
||||
QVERIFY(iface);
|
||||
QCOMPARE(iface->role(), QAccessible::MenuItem);
|
||||
|
||||
@ -1905,8 +1900,7 @@ void tst_QAccessibility::mdiSubWindowTest()
|
||||
if (isSubWindowsPlacedNextToEachOther) {
|
||||
// This part of the test can only be run if the sub windows are
|
||||
// placed next to each other.
|
||||
QAccessibleInterface *destination = 0;
|
||||
QCOMPARE(interface->navigate(QAccessible::Child, 1, &destination), 0);
|
||||
QAccessibleInterface *destination = interface->child(0);
|
||||
QVERIFY(destination);
|
||||
QCOMPARE(destination->object(), (QObject*)testWindow->widget());
|
||||
delete destination;
|
||||
|
Loading…
Reference in New Issue
Block a user