a11y: Don't add scrollbar container as a11y child if scroll bar is re-parented

If someone has, for unknown reasons, re-parented the scroll bar of a
scroll area to outside the scroll area, we should not blindly add the
parent widget of the scroll bar as an a11y child of the scroll area.

We don't need to explicitly add the scroll bar itself as a child either,
as that will be handled by whoever is the new parent widget, as a normal
scroll bar would.

Fixes: QTBUG-93768
Change-Id: Ib26f31674602e2221311e864ad31bbf141cad8f6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit e51ff5c4935330b00d8039e435ec6cac60cfb875)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2023-05-05 12:09:47 +02:00 committed by Qt Cherry-pick Bot
parent 5bd9d9521e
commit 7782eeeefe

View File

@ -476,13 +476,19 @@ QWidgetList QAccessibleAbstractScrollArea::accessibleChildren() const
// Horizontal scrollBar container.
QScrollBar *horizontalScrollBar = abstractScrollArea()->horizontalScrollBar();
if (horizontalScrollBar && horizontalScrollBar->isVisible()) {
children.append(horizontalScrollBar->parentWidget());
QWidget *scrollBarParent = horizontalScrollBar->parentWidget();
// Add container only if scroll bar is in the container
if (elementType(scrollBarParent) == HorizontalContainer)
children.append(scrollBarParent);
}
// Vertical scrollBar container.
QScrollBar *verticalScrollBar = abstractScrollArea()->verticalScrollBar();
if (verticalScrollBar && verticalScrollBar->isVisible()) {
children.append(verticalScrollBar->parentWidget());
QWidget *scrollBarParent = verticalScrollBar->parentWidget();
// Add container only if scroll bar is in the container
if (elementType(scrollBarParent) == VerticalContainer)
children.append(scrollBarParent);
}
// CornerWidget.