WinRT: Fix invisible element being included in the UI Automation tree

When an element is not visible then it should not be shown in the element
tree at all when using tools like Inspect. Also, the IsOffscreen property
was hardcoded to false instead of reflecting the actual object offscreen
state.

Task-number: QTBUG-69537
Change-Id: Ic8f55486685837cf5e21b3499085bb669c1dc6c8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
bb10
Andre de la Rocha 2018-07-24 16:26:28 +02:00
parent f493324066
commit 54e117d27d
3 changed files with 20 additions and 2 deletions

View File

@ -81,6 +81,13 @@ void QWinRTUiaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
case QAccessible::Focus:
QWinRTUiaMainProvider::notifyFocusChange(event);
break;
case QAccessible::ObjectCreated:
case QAccessible::ObjectDestroyed:
case QAccessible::ObjectShow:
case QAccessible::ObjectHide:
case QAccessible::ObjectReorder:
QWinRTUiaMainProvider::notifyVisibilityChange(event);
break;
case QAccessible::StateChanged:
QWinRTUiaMainProvider::notifyStateChange(static_cast<QAccessibleStateChangeEvent *>(event));
break;

View File

@ -230,6 +230,14 @@ void QWinRTUiaMainProvider::notifyFocusChange(QAccessibleEvent *event)
}
}
void QWinRTUiaMainProvider::notifyVisibilityChange(QAccessibleEvent *event)
{
if (QAccessibleInterface *accessible = event->accessibleInterface()) {
QAccessible::Id accid = idForAccessible(accessible);
QWinRTUiaMetadataCache::instance()->load(accid);
}
}
void QWinRTUiaMainProvider::notifyStateChange(QAccessibleStateChangeEvent *event)
{
if (QAccessibleInterface *accessible = event->accessibleInterface()) {
@ -517,7 +525,8 @@ HRESULT STDMETHODCALLTYPE QWinRTUiaMainProvider::GetChildrenCore(IVector<Automat
if (QAccessibleInterface *childAcc = accessible->child(i)) {
QAccessible::Id childId = idForAccessible(childAcc);
QWinRTUiaMetadataCache::instance()->load(childId);
(*ptrChildren)->append(childId);
if (!childAcc->state().invisible)
(*ptrChildren)->append(childId);
}
}
}
@ -683,7 +692,8 @@ HRESULT STDMETHODCALLTYPE QWinRTUiaMainProvider::IsOffscreenCore(boolean *return
if (!returnValue)
return E_INVALIDARG;
*returnValue = false;
QSharedPointer<QWinRTUiaControlMetadata> metadata = QWinRTUiaMetadataCache::instance()->metadataForId(id());
*returnValue = (metadata->state().offscreen != 0);
return S_OK;
}

View File

@ -71,6 +71,7 @@ public:
static HRESULT rawProviderForAccessibleId(QAccessible::Id elementId, ABI::Windows::UI::Xaml::Automation::Provider::IIRawElementProviderSimple **returnValue);
static HRESULT rawProviderArrayForAccessibleIdList(const QList<QAccessible::Id> &elementIds, UINT32 *returnValueSize, ABI::Windows::UI::Xaml::Automation::Provider::IIRawElementProviderSimple ***returnValue);
static void notifyFocusChange(QAccessibleEvent *event);
static void notifyVisibilityChange(QAccessibleEvent *event);
static void notifyStateChange(QAccessibleStateChangeEvent *event);
static void notifyValueChange(QAccessibleValueChangeEvent *event);
static void notifyTextChange(QAccessibleEvent *event);