diff options
Diffstat (limited to 'src/core/browser_accessibility_manager_qt.cpp')
-rw-r--r-- | src/core/browser_accessibility_manager_qt.cpp | 97 |
1 files changed, 47 insertions, 50 deletions
diff --git a/src/core/browser_accessibility_manager_qt.cpp b/src/core/browser_accessibility_manager_qt.cpp index c35f92d7f..077856266 100644 --- a/src/core/browser_accessibility_manager_qt.cpp +++ b/src/core/browser_accessibility_manager_qt.cpp @@ -1,78 +1,56 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#include "qtwebenginecoreglobal.h" + +#include "content/browser/accessibility/browser_accessibility_manager.h" + +#include <QtGui/qtguiglobal.h> + +#if QT_CONFIG(accessibility) +#include "browser_accessibility_qt.h" #include "browser_accessibility_manager_qt.h" +#include "render_widget_host_view_qt.h" // WebContentsAccessibilityQt #include "content/browser/accessibility/browser_accessibility.h" #include "ui/accessibility/ax_enums.mojom.h" -#include "browser_accessibility_qt.h" -#include "render_widget_host_view_qt.h" - #include <QtGui/qaccessible.h> - -using namespace blink; +#endif // QT_CONFIG(accessibility) namespace content { // static BrowserAccessibilityManager *BrowserAccessibilityManager::Create( const ui::AXTreeUpdate &initialTree, - BrowserAccessibilityDelegate *delegate) + WebAXPlatformTreeManagerDelegate *delegate) { #if QT_CONFIG(accessibility) Q_ASSERT(delegate); QtWebEngineCore::WebContentsAccessibilityQt *access = nullptr; access = static_cast<QtWebEngineCore::WebContentsAccessibilityQt *>(delegate->AccessibilityGetWebContentsAccessibility()); + + // Accessibility is not supported for guest views and child frames. + if (!access) { + return nullptr; + } + return new BrowserAccessibilityManagerQt(access, initialTree, delegate); #else + Q_UNUSED(initialTree); + Q_UNUSED(delegate); return nullptr; #endif // QT_CONFIG(accessibility) } // static BrowserAccessibilityManager *BrowserAccessibilityManager::Create( - BrowserAccessibilityDelegate *delegate) + WebAXPlatformTreeManagerDelegate *delegate) { #if QT_CONFIG(accessibility) return BrowserAccessibilityManager::Create(BrowserAccessibilityManagerQt::GetEmptyDocument(), delegate); #else + Q_UNUSED(delegate); return nullptr; #endif } @@ -81,7 +59,7 @@ BrowserAccessibilityManager *BrowserAccessibilityManager::Create( BrowserAccessibilityManagerQt::BrowserAccessibilityManagerQt( QtWebEngineCore::WebContentsAccessibilityQt *webContentsAccessibility, const ui::AXTreeUpdate &initialTree, - BrowserAccessibilityDelegate* delegate) + WebAXPlatformTreeManagerDelegate* delegate) : BrowserAccessibilityManager(delegate) , m_webContentsAccessibility(webContentsAccessibility) { @@ -96,7 +74,7 @@ BrowserAccessibilityManagerQt::~BrowserAccessibilityManagerQt() QAccessibleInterface *BrowserAccessibilityManagerQt::rootParentAccessible() { - content::BrowserAccessibility *parent_node = GetParentNodeFromParentTree(); + content::BrowserAccessibility *parent_node = GetParentNodeFromParentTreeAsBrowserAccessibility(); if (!parent_node) { Q_ASSERT(m_webContentsAccessibility); return QAccessible::queryAccessibleInterface(m_webContentsAccessibility->accessibilityParentObject()); @@ -108,13 +86,16 @@ QAccessibleInterface *BrowserAccessibilityManagerQt::rootParentAccessible() } void BrowserAccessibilityManagerQt::FireBlinkEvent(ax::mojom::Event event_type, - BrowserAccessibility* node) + BrowserAccessibility *node, + int action_request_id) { auto *iface = toQAccessibleInterface(node); switch (event_type) { case ax::mojom::Event::kFocus: { QAccessibleEvent event(iface, QAccessible::Focus); + if (event.object()) + event.setChild(-1); QAccessible::updateAccessibility(&event); break; } @@ -122,6 +103,8 @@ void BrowserAccessibilityManagerQt::FireBlinkEvent(ax::mojom::Event event_type, QAccessible::State change; change.checked = true; QAccessibleStateChangeEvent event(iface, change); + if (event.object()) + event.setChild(-1); QAccessible::updateAccessibility(&event); break; } @@ -130,6 +113,8 @@ void BrowserAccessibilityManagerQt::FireBlinkEvent(ax::mojom::Event event_type, if (QAccessibleValueInterface *valueIface = iface->valueInterface()) value = valueIface->currentValue(); QAccessibleValueChangeEvent event(iface, value); + if (event.object()) + event.setChild(-1); QAccessible::updateAccessibility(&event); break; } @@ -141,6 +126,8 @@ void BrowserAccessibilityManagerQt::FireBlinkEvent(ax::mojom::Event event_type, break; case ax::mojom::Event::kTextChanged: { QAccessibleTextUpdateEvent event(iface, -1, QString(), QString()); + if (event.object()) + event.setChild(-1); QAccessible::updateAccessibility(&event); break; } @@ -152,9 +139,13 @@ void BrowserAccessibilityManagerQt::FireBlinkEvent(ax::mojom::Event event_type, textIface->selection(0, &start, &end); if (start == end) { QAccessibleTextCursorEvent event(iface, start); + if (event.object()) + event.setChild(-1); QAccessible::updateAccessibility(&event); } else { QAccessibleTextSelectionEvent event(iface, start, end); + if (event.object()) + event.setChild(-1); QAccessible::updateAccessibility(&event); } } @@ -166,14 +157,20 @@ void BrowserAccessibilityManagerQt::FireBlinkEvent(ax::mojom::Event event_type, } void BrowserAccessibilityManagerQt::FireGeneratedEvent(ui::AXEventGenerator::Event event_type, - BrowserAccessibility* node) + const ui::AXNode *node) { - auto *iface = toQAccessibleInterface(node); + BrowserAccessibilityManager::FireGeneratedEvent(event_type, node); + + BrowserAccessibility *wrapper = GetFromAXNode(node); + DCHECK(wrapper); + auto *iface = toQAccessibleInterface(wrapper); switch (event_type) { case ui::AXEventGenerator::Event::VALUE_IN_TEXT_FIELD_CHANGED: if (iface->role() == QAccessible::EditableText) { QAccessibleTextUpdateEvent event(iface, -1, QString(), QString()); + if (event.object()) + event.setChild(-1); QAccessible::updateAccessibility(&event); } break; |