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
Pick-to: 6.5 6.2
Change-Id: Ib26f31674602e2221311e864ad31bbf141cad8f6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Tor Arne Vestbø 2023-05-05 12:09:47 +02:00
parent 8f6ec8cea2
commit e51ff5c493

View File

@ -477,13 +477,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.