summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@nokia.com>2011-11-22 18:08:05 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-19 12:27:45 +0100
commit74c9f9d83f9f5cb934d0b62b468c74df5a3b9a0d (patch)
treeea5e783b8d025ce2d525dab5c524aaee298dd6b9 /src/plugins/platforms
parent7e12d2d30f74b5fe1f80fac7192416cf6eb22d4d (diff)
Accessibility: childAt returns interface
childAt used to return an integer. Return an interface instead. Not requiring a direct child to be returned allows optimizing by bypassing iterating through the hierarchy of accessibles. For QtQuick this is the only sensible way of implementing this. The bridges are still responsible for finding the top-most element. The default implementation in QAccessibleObject is sufficient to return direct children. The implementation in QAccessibleApplication is therfore no longer needed. Change-Id: Id7100dd5bcc3a98de516a7f4a12eaaa41cb46d26 Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm16
-rw-r--r--src/plugins/platforms/cocoa/qnsviewaccessibility.mm31
-rw-r--r--src/plugins/platforms/windows/qwindowsaccessibility.cpp24
3 files changed, 28 insertions, 43 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
index 332577d6e9..5ad9e57c31 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
@@ -197,21 +197,19 @@ static QAccessibleInterface *acast(void *ptr)
}
- (id)accessibilityHitTest:(NSPoint)point {
- int index = acast(accessibleInterface)->childAt(point.x, qt_mac_flipYCoordinate(point.y));
- // hit outside
- if (index == -1) {
- return 0;
- }
+ if (!accessibleInterface)
+ return NSAccessibilityUnignoredAncestor(self);
+ QAccessibleInterface *childInterface = acast(accessibleInterface)->childAt(point.x, qt_mac_flipYCoordinate(point.y));
- // hit this element
- if (index == 0) {
+ // No child found, meaning we hit this element.
+ if (!childInterface) {
return NSAccessibilityUnignoredAncestor(self);
}
// hit a child, forward to child accessible interface.
- QAccessibleInterface *childInterface = acast(accessibleInterface)->child(index - 1);
- QCocoaAccessibleElement *accessibleElement = [QCocoaAccessibleElement elementWithIndex:index - 1 parent:self accessibleInterface: childInterface];
+ int childIndex = acast(accessibleInterface)->indexOfChild(childInterface);
+ QCocoaAccessibleElement *accessibleElement = [QCocoaAccessibleElement elementWithIndex:childIndex -1 parent:self accessibleInterface: childInterface];
return [accessibleElement accessibilityHitTest:point];
}
diff --git a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm
index 327bace123..562ad4264a 100644
--- a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm
@@ -83,34 +83,19 @@
}
- (id)accessibilityHitTest:(NSPoint)point {
+ if (!m_accessibleRoot)
+ return [super accessibilityHitTest:point];
NSPoint windowPoint = [[self window] convertScreenToBase:point];
- NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
-
- int index = -1;
- if (m_accessibleRoot) {
- index = m_accessibleRoot->childAt(point.x, qt_mac_flipYCoordinate(point.y));
-
- // qDebug() << "root rect" << m_accessibleRoot->rect();
- // qDebug() << "hit screen" << point.x << qt_mac_flipYCoordinate(point.y) << index;
- // if (index > 0) {
- // qDebug() << "child name" << m_accessibleRoot->child(index - 1)->text(QAccessible::Name);
- // qDebug() << "child rect" << m_accessibleRoot->child(index - 1)->rect();
- // }
- }
- // hit outside
- if (index == -1) {
+ QAccessibleInterface *childInterface = m_accessibleRoot->childAt(point.x, qt_mac_flipYCoordinate(point.y));
+ // No child found, meaning we hit the NSView
+ if (!childInterface) {
return [super accessibilityHitTest:point];
}
- // hit the NSView / top-level window
- if (index == 0) {
- QCocoaAccessibleElement *accessibleElement = [QCocoaAccessibleElement elementWithIndex:index parent:self accessibleInterface:(void*)m_accessibleRoot];
- return [accessibleElement accessibilityHitTest:point];
- }
-
- // hit a child, forward to child accessible interface.
- QCocoaAccessibleElement *accessibleElement = [QCocoaAccessibleElement elementWithIndex:index - 1 parent:self accessibleInterface:(void*)m_accessibleRoot->child(index -1)];
+ // Hit a child, forward to child accessible interface.
+ int childIndex = m_accessibleRoot->indexOfChild(childInterface);
+ QCocoaAccessibleElement *accessibleElement = [QCocoaAccessibleElement elementWithIndex:childIndex -1 parent:self accessibleInterface: childInterface];
return [accessibleElement accessibilityHitTest:point];
}
diff --git a/src/plugins/platforms/windows/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/qwindowsaccessibility.cpp
index aa4507484d..53d7b33769 100644
--- a/src/plugins/platforms/windows/qwindowsaccessibility.cpp
+++ b/src/plugins/platforms/windows/qwindowsaccessibility.cpp
@@ -753,21 +753,23 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::accHitTest(long xLeft, long yTop,
if (!accessible->isValid())
return E_FAIL;
- int control = accessible->childAt(xLeft, yTop);
- if (control == -1) {
+ QAccessibleInterface *child = accessible->childAt(xLeft, yTop);
+ if (child == 0) {
+ // no child found, return this item if it contains the coordinates
+ if (accessible->rect().contains(xLeft, yTop)) {
+ IDispatch *iface = 0;
+ QueryInterface(IID_IDispatch, (void**)&iface);
+ if (iface) {
+ (*pvarID).vt = VT_DISPATCH;
+ (*pvarID).pdispVal = iface;
+ return S_OK;
+ }
+ }
(*pvarID).vt = VT_EMPTY;
return S_FALSE;
}
- QAccessibleInterface *acc = 0;
- if (control)
- accessible->navigate(QAccessible::Child, control, &acc);
- if (!acc) {
- (*pvarID).vt = VT_I4;
- (*pvarID).lVal = control;
- return S_OK;
- }
- QWindowsAccessible* wacc = new QWindowsAccessible(acc);
+ QWindowsAccessible* wacc = new QWindowsAccessible(child);
IDispatch *iface = 0;
wacc->QueryInterface(IID_IDispatch, (void**)&iface);
if (iface) {