summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-09-17 17:37:50 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-09-25 15:55:54 +0000
commit32b67aea15fdf47d6b86e1e5303d25ec6e8ded37 (patch)
treebf43f9840d1313349de4ca6cdc8ff96f5dfa2202
parent57fa7e51c52d8f4608846818eb312ac1c445fa64 (diff)
Add accessibility_tree_formatter_qt
Needed by chrome://accessibility Updates chromium to related change: 224fc0748a Do not assert on --disable-gpu 0ba5e6626a FIXUP: Add ifdefs to exclude ATL and accessibility from the build Change-Id: Ida0b03048ab6aa04686251d16ccfbf4855a37690 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
m---------src/3rdparty0
-rw-r--r--src/core/accessibility_tree_formatter_qt.cpp206
-rw-r--r--src/core/browser_accessibility_manager_qt.cpp9
-rw-r--r--src/core/browser_accessibility_manager_qt.h8
-rw-r--r--src/core/browser_accessibility_qt.cpp14
-rw-r--r--src/core/browser_accessibility_qt.h4
-rw-r--r--src/core/core_chromium.pri1
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp2
8 files changed, 228 insertions, 16 deletions
diff --git a/src/3rdparty b/src/3rdparty
-Subproject 193f502642c85afa8acebe600d94b3956b29b7a
+Subproject 0ba5e6626ae4aff6f32140b810e7650a1018107
diff --git a/src/core/accessibility_tree_formatter_qt.cpp b/src/core/accessibility_tree_formatter_qt.cpp
new file mode 100644
index 000000000..6d3129275
--- /dev/null
+++ b/src/core/accessibility_tree_formatter_qt.cpp
@@ -0,0 +1,206 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 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$
+**
+****************************************************************************/
+
+#include "content/browser/accessibility/accessibility_tree_formatter_browser.h"
+
+#include <utility>
+
+#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
+#include "base/values.h"
+
+#include "browser_accessibility_qt.h"
+
+namespace content {
+
+class AccessibilityTreeFormatterQt : public AccessibilityTreeFormatterBrowser {
+public:
+ explicit AccessibilityTreeFormatterQt();
+ ~AccessibilityTreeFormatterQt() override;
+
+private:
+ const base::FilePath::StringType GetExpectedFileSuffix() override;
+ const std::string GetAllowEmptyString() override;
+ const std::string GetAllowString() override;
+ const std::string GetDenyString() override;
+ void AddProperties(const BrowserAccessibility &node, base::DictionaryValue* dict) override;
+ base::string16 ProcessTreeForOutput(const base::DictionaryValue &node, base::DictionaryValue * = nullptr) override;
+};
+
+// static
+AccessibilityTreeFormatter* AccessibilityTreeFormatter::Create()
+{
+ return new AccessibilityTreeFormatterQt();
+}
+
+AccessibilityTreeFormatterQt::AccessibilityTreeFormatterQt()
+{
+}
+
+AccessibilityTreeFormatterQt::~AccessibilityTreeFormatterQt()
+{
+}
+
+void AccessibilityTreeFormatterQt::AddProperties(const BrowserAccessibility &node, base::DictionaryValue *dict)
+{
+ dict->SetInteger("id", node.GetId());
+ const BrowserAccessibilityQt *acc_node = ToBrowserAccessibilityQt(&node);
+
+ dict->SetString("role", qAccessibleRoleString(acc_node->role()));
+
+ QAccessible::State state = acc_node->state();
+
+ std::vector<base::Value> states;
+ if (state.busy)
+ states.push_back(base::Value("busy"));
+ if (state.checkable)
+ states.push_back(base::Value("checkable"));
+ if (state.checked)
+ states.push_back(base::Value("checked"));
+ if (acc_node->IsClickable())
+ states.push_back(base::Value("clickable"));
+ if (state.collapsed)
+ states.push_back(base::Value("collapsed"));
+ if (state.disabled)
+ states.push_back(base::Value("disabled"));
+ if (state.editable)
+ states.push_back(base::Value("editable"));
+ if (state.expandable)
+ states.push_back(base::Value("expandable"));
+ if (state.expanded)
+ states.push_back(base::Value("expanded"));
+ if (state.focusable)
+ states.push_back(base::Value("focusable"));
+ if (state.focused)
+ states.push_back(base::Value("focused"));
+ if (state.hasPopup)
+ states.push_back(base::Value("hasPopup"));
+ if (state.hotTracked)
+ states.push_back(base::Value("hotTracked"));
+ if (state.invisible)
+ states.push_back(base::Value("invisible"));
+ if (state.linked)
+ states.push_back(base::Value("linked"));
+ if (state.multiLine)
+ states.push_back(base::Value("multiLine"));
+ if (state.multiSelectable)
+ states.push_back(base::Value("multiSelectable"));
+ if (state.modal)
+ states.push_back(base::Value("modal"));
+ if (state.offscreen)
+ states.push_back(base::Value("offscreen"));
+ if (state.passwordEdit)
+ states.push_back(base::Value("password"));
+ if (state.pressed)
+ states.push_back(base::Value("pressed"));
+ if (state.readOnly)
+ states.push_back(base::Value("readOnly"));
+ if (state.selectable)
+ states.push_back(base::Value("selectable"));
+ if (state.selected)
+ states.push_back(base::Value("selected"));
+ if (state.traversed)
+ states.push_back(base::Value("traversed"));
+ dict->SetKey("states", base::Value(states));
+
+ dict->SetString("name", acc_node->text(QAccessible::Name).toStdString());
+ dict->SetString("description", acc_node->text(QAccessible::Description).toStdString());
+}
+
+base::string16 AccessibilityTreeFormatterQt::ProcessTreeForOutput(const base::DictionaryValue &node, base::DictionaryValue *)
+{
+ base::string16 error_value;
+ if (node.GetString("error", &error_value))
+ return error_value;
+
+ base::string16 line;
+ std::string role_value;
+ node.GetString("role", &role_value);
+ if (!role_value.empty())
+ WriteAttribute(true, base::StringPrintf("%s", role_value.c_str()), &line);
+
+ const base::ListValue *states_value = nullptr;
+ node.GetList("states", &states_value);
+ if (states_value) {
+ for (const auto &state : *states_value) {
+ std::string state_value;
+ if (state.GetAsString(&state_value))
+ WriteAttribute(true, state_value, &line);
+ }
+ }
+
+ std::string name_value;
+ if (node.GetString("name", &name_value))
+ WriteAttribute(true, base::StringPrintf("name='%s'", name_value.c_str()), &line);
+
+ std::string description_value;
+ if (node.GetString("description", &description_value))
+ WriteAttribute(false, base::StringPrintf("description='%s'", description_value.c_str()), &line);
+
+ int id_value;
+ node.GetInteger("id", &id_value);
+ WriteAttribute(false, base::StringPrintf("id=%d", id_value), &line);
+
+ return line + base::ASCIIToUTF16("\n");
+}
+
+const base::FilePath::StringType AccessibilityTreeFormatterQt::GetExpectedFileSuffix()
+{
+ return FILE_PATH_LITERAL("-expected-qt.txt");
+}
+
+const std::string AccessibilityTreeFormatterQt::GetAllowEmptyString()
+{
+ return "@QT-ALLOW-EMPTY:";
+}
+
+const std::string AccessibilityTreeFormatterQt::GetAllowString()
+{
+ return "@QT-ALLOW:";
+}
+
+const std::string AccessibilityTreeFormatterQt::GetDenyString()
+{
+ return "@QT-DENY:";
+}
+
+}
diff --git a/src/core/browser_accessibility_manager_qt.cpp b/src/core/browser_accessibility_manager_qt.cpp
index 33ef385c7..644a0a9f0 100644
--- a/src/core/browser_accessibility_manager_qt.cpp
+++ b/src/core/browser_accessibility_manager_qt.cpp
@@ -52,18 +52,19 @@ BrowserAccessibilityManager* BrowserAccessibilityManager::Create(
BrowserAccessibilityFactory* factory)
{
#ifndef QT_NO_ACCESSIBILITY
- return new BrowserAccessibilityManagerQt(0, initialTree, delegate);
+ return new BrowserAccessibilityManagerQt(nullptr, initialTree, delegate, factory);
#else
- return 0;
+ delete factory;
+ return nullptr;
#endif // QT_NO_ACCESSIBILITY
}
-BrowserAccessibility *BrowserAccessibilityFactoryQt::Create()
+BrowserAccessibility *BrowserAccessibility::Create()
{
#ifndef QT_NO_ACCESSIBILITY
return new BrowserAccessibilityQt();
#else
- return 0;
+ return nullptr;
#endif // QT_NO_ACCESSIBILITY
}
diff --git a/src/core/browser_accessibility_manager_qt.h b/src/core/browser_accessibility_manager_qt.h
index ef204faa5..a2d6db458 100644
--- a/src/core/browser_accessibility_manager_qt.h
+++ b/src/core/browser_accessibility_manager_qt.h
@@ -50,19 +50,13 @@ QT_END_NAMESPACE
namespace content {
-class BrowserAccessibilityFactoryQt : public BrowserAccessibilityFactory
-{
-public:
- BrowserAccessibility* Create() override;
-};
-
class BrowserAccessibilityManagerQt : public BrowserAccessibilityManager
{
public:
BrowserAccessibilityManagerQt(QObject* parentObject,
const ui::AXTreeUpdate& initialTree,
BrowserAccessibilityDelegate* delegate,
- BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactoryQt());
+ BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory());
void FireBlinkEvent(ax::mojom::Event event_type,
BrowserAccessibility* node) override;
diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp
index a19eff618..a672ccc06 100644
--- a/src/core/browser_accessibility_qt.cpp
+++ b/src/core/browser_accessibility_qt.cpp
@@ -56,6 +56,11 @@ using QtWebEngineCore::toQt;
namespace content {
+const BrowserAccessibilityQt *ToBrowserAccessibilityQt(const BrowserAccessibility *obj)
+{
+ return static_cast<const BrowserAccessibilityQt *>(obj);
+}
+
BrowserAccessibilityQt::BrowserAccessibilityQt()
{
QAccessible::registerAccessibleInterface(this);
@@ -518,11 +523,11 @@ QAccessible::State BrowserAccessibilityQt::state() const
if (HasState(ax::mojom::State::kLinked))
state.linked = true;
if (HasState(ax::mojom::State::kMultiline))
- {} // FIXME: state.multiLine = true;
+ state.multiLine = true;
if (HasState(ax::mojom::State::kMultiselectable))
state.multiSelectable = true;
if (HasState(ax::mojom::State::kProtected))
- {} // FIXME
+ state.passwordEdit = true;
if (HasState(ax::mojom::State::kRequired))
{} // FIXME
if (HasState(ax::mojom::State::kRichlyEditable))
@@ -530,7 +535,7 @@ QAccessible::State BrowserAccessibilityQt::state() const
if (HasState(ax::mojom::State::kVertical))
{} // FIXME
if (HasState(ax::mojom::State::kVisited))
- {} // FIXME
+ state.traversed = true;
if (IsOffscreen())
state.offscreen = true;
@@ -538,11 +543,14 @@ QAccessible::State BrowserAccessibilityQt::state() const
state.focused = true;
if (GetBoolAttribute(ax::mojom::BoolAttribute::kBusy))
state.busy = true;
+ if (GetBoolAttribute(ax::mojom::BoolAttribute::kModal))
+ state.modal = true;
if (HasBoolAttribute(ax::mojom::BoolAttribute::kSelected)) {
state.selectable = true;
state.selected = GetBoolAttribute(ax::mojom::BoolAttribute::kSelected);
}
if (HasIntAttribute(ax::mojom::IntAttribute::kCheckedState)) {
+ state.checkable = true;
const ax::mojom::CheckedState checkedState =
static_cast<ax::mojom::CheckedState>(GetIntAttribute(ax::mojom::IntAttribute::kCheckedState));
switch (checkedState) {
diff --git a/src/core/browser_accessibility_qt.h b/src/core/browser_accessibility_qt.h
index 167165ac0..edb1f1ed7 100644
--- a/src/core/browser_accessibility_qt.h
+++ b/src/core/browser_accessibility_qt.h
@@ -144,7 +144,9 @@ public:
void modelChange(QAccessibleTableModelChangeEvent *event) override;
};
-}
+const BrowserAccessibilityQt *ToBrowserAccessibilityQt(const BrowserAccessibility *obj);
+
+} // namespace content
#endif // QT_NO_ACCESSIBILITY
#endif
diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri
index 92ab80c6c..92fefe533 100644
--- a/src/core/core_chromium.pri
+++ b/src/core/core_chromium.pri
@@ -38,6 +38,7 @@ qtConfig(egl): CONFIG += egl
INCLUDEPATH += $$PWD $$PWD/api
SOURCES = \
+ accessibility_tree_formatter_qt.cpp \
authentication_dialog_controller.cpp \
browser_accessibility_manager_qt.cpp \
browser_accessibility_qt.cpp \
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index 71ef5573b..57f5f6def 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -2674,7 +2674,7 @@ void tst_QWebEngineView::webUIURLs_data()
QTest::addColumn<QUrl>("url");
QTest::addColumn<bool>("supported");
QTest::newRow("about") << QUrl("chrome://about") << false;
- QTest::newRow("accessibility") << QUrl("chrome://accessibility") << false;
+ QTest::newRow("accessibility") << QUrl("chrome://accessibility") << true;
QTest::newRow("appcache-internals") << QUrl("chrome://appcache-internals") << true;
QTest::newRow("apps") << QUrl("chrome://apps") << false;
QTest::newRow("blob-internals") << QUrl("chrome://blob-internals") << true;