summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qnsviewaccessibility.mm
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/cocoa/qnsviewaccessibility.mm
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/cocoa/qnsviewaccessibility.mm')
-rw-r--r--src/plugins/platforms/cocoa/qnsviewaccessibility.mm31
1 files changed, 8 insertions, 23 deletions
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];
}