If the attached property is not found, ignore the item, unless
it is part of the tree. We still create a valid hierarchy this
way, but filter out all irrelevant items. The same goes for
hit-testing.
On the other hand this patch enables the root item to be found
by setting isAccessible on it when updating the flags. Otherwise
the hierarchy is not valid again.
Change-Id: Ied422fd0506d13458757c87a5dad7cdb9d3079bf
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
#include <QtQuick/QQuickView>
#include <QtQuick/QQuickItem>
#include <QtQuick/QQuickView>
#include <QtQuick/QQuickItem>
+#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquickaccessibleattached_p.h>
#include <qaccessibleplugin.h>
#include <QtQuick/private/qquickaccessibleattached_p.h>
#include <qaccessibleplugin.h>
if (classname == QLatin1String("QQuickView")) {
return new QAccessibleQuickView(qobject_cast<QQuickView *>(object)); // FIXME
} else if (classname == QLatin1String("QQuickItem")) {
if (classname == QLatin1String("QQuickView")) {
return new QAccessibleQuickView(qobject_cast<QQuickView *>(object)); // FIXME
} else if (classname == QLatin1String("QQuickItem")) {
- QQuickItem * item = qobject_cast<QQuickItem *>(object);
+ QQuickItem *item = qobject_cast<QQuickItem *>(object);
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ if (!itemPrivate->isAccessible)
+ return 0;
QVariant v = QQuickAccessibleAttached::property(item, "role");
bool ok;
QVariant v = QQuickAccessibleAttached::property(item, "role");
bool ok;
}
QScopedPointer<QAccessibleInterface> accessibleInterface(QAccessible::queryAccessibleInterface(item));
}
QScopedPointer<QAccessibleInterface> accessibleInterface(QAccessible::queryAccessibleInterface(item));
- if (accessibleInterface && accessibleInterface->childCount() == 0) {
+ // this item has no Accessible attached property
+ if (!accessibleInterface)
+ return 0;
+
+ if (accessibleInterface->childCount() == 0) {
return (itemScreenRect(item).contains(x, y)) ? item : 0;
}
return (itemScreenRect(item).contains(x, y)) ? item : 0;
}
if (root) {
if (QQuickItem *item = childAt_helper(root, x, y))
return QAccessible::queryAccessibleInterface(item);
if (root) {
if (QQuickItem *item = childAt_helper(root, x, y))
return QAccessible::queryAccessibleInterface(item);
+ return QAccessible::queryAccessibleInterface(root);
if (item->d_func()->isAccessible)
break; // already set - grandparents should have the flag set as well.
if (item->d_func()->isAccessible)
break; // already set - grandparents should have the flag set as well.
- if (item->canvas() && item->canvas()->rootItem() == item)
- break; // don't add a listener to the canvas root item
-
item->d_func()->isAccessible = true;
item = item->d_func()->parentItem;
}
item->d_func()->isAccessible = true;
item = item->d_func()->parentItem;
}
QAI rootItem = QAI(canvasIface->child(0));
QRect rootRect = rootItem->rect();
QAI rootItem = QAI(canvasIface->child(0));
QRect rootRect = rootItem->rect();
- // hit the root item
- QAI rootItemIface(canvasIface->childAt(rootRect.x() + 200, rootRect.y() + 50));
- QVERIFY(rootItemIface);
- QCOMPARE(rootRect, rootItemIface->rect());
+ // check the root item from app
+ QAI appIface = QAI(QAccessible::queryAccessibleInterface(qApp));
+ QVERIFY(appIface);
+ QAI itemHit(appIface->childAt(rootRect.x() + 200, rootRect.y() + 50));
+ QVERIFY(itemHit);
+ QCOMPARE(rootRect, itemHit->rect());
// hit rect1
QAI rect1(rootItem->child(0));
QRect rect1Rect = rect1->rect();
// hit rect1
QAI rect1(rootItem->child(0));
QRect rect1Rect = rect1->rect();
- rootItemIface = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10));
+ QAI rootItemIface = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10));
QVERIFY(rootItemIface);
QCOMPARE(rect1Rect, rootItemIface->rect());
QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect1"));
QVERIFY(rootItemIface);
QCOMPARE(rect1Rect, rootItemIface->rect());
QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect1"));