From b8dee3b91412289470ed6bd62d5d3a3b27157f92 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 16 Jul 2014 15:41:20 +0200 Subject: Implement QAccessibleActionInterface For now only setting the focus via accessibility APIs is supported. Being able to do that is important since screen readers allow exploring the application in different ways and expect to be able to set the focus according to what they present to the user. Change-Id: I4ce17039307844a77c0274d743f5afbe049e3c66 Reviewed-by: Michael Bruning --- src/core/browser_accessibility_qt.cpp | 24 ++++++++++++++++++++++++ src/core/browser_accessibility_qt.h | 6 ++++++ 2 files changed, 30 insertions(+) (limited to 'src/core') diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp index 106a71d4c..f71a50610 100644 --- a/src/core/browser_accessibility_qt.cpp +++ b/src/core/browser_accessibility_qt.cpp @@ -80,6 +80,10 @@ QAccessibleInterface *BrowserAccessibilityQt::childAt(int x, int y) const void *BrowserAccessibilityQt::interface_cast(QAccessible::InterfaceType type) { switch (type) { + case QAccessible::ActionInterface: + if (!actionNames().isEmpty()) + return static_cast(this); + break; case QAccessible::TextInterface: if (IsEditableText()) return static_cast(this); @@ -436,6 +440,26 @@ void BrowserAccessibilityQt::NativeReleaseReference() QAccessible::deleteAccessibleInterface(interfaceId); } +QStringList BrowserAccessibilityQt::actionNames() const +{ + QStringList actions; + if (HasState(blink::WebAXStateFocusable)) + actions << QAccessibleActionInterface::setFocusAction(); + return actions; +} + +void BrowserAccessibilityQt::doAction(const QString &actionName) +{ + if (actionName == QAccessibleActionInterface::setFocusAction()) + manager()->SetFocus(this, true); +} + +QStringList BrowserAccessibilityQt::keyBindingsForAction(const QString &actionName) const +{ + QT_NOT_YET_IMPLEMENTED + return QStringList(); +} + void BrowserAccessibilityQt::addSelection(int startOffset, int endOffset) { manager()->SetTextSelection(*this, startOffset, endOffset); diff --git a/src/core/browser_accessibility_qt.h b/src/core/browser_accessibility_qt.h index 2c85b3349..5a0e4f026 100644 --- a/src/core/browser_accessibility_qt.h +++ b/src/core/browser_accessibility_qt.h @@ -50,6 +50,7 @@ namespace content { class BrowserAccessibilityQt : public BrowserAccessibility , public QAccessibleInterface + , public QAccessibleActionInterface , public QAccessibleTextInterface , public QAccessibleValueInterface { @@ -80,6 +81,11 @@ public: void NativeReleaseReference() Q_DECL_OVERRIDE; bool IsNative() const Q_DECL_OVERRIDE { return true; } + // QAccessibleActionInterface + QStringList actionNames() const Q_DECL_OVERRIDE; + void doAction(const QString &actionName) Q_DECL_OVERRIDE; + QStringList keyBindingsForAction(const QString &actionName) const Q_DECL_OVERRIDE; + // QAccessibleTextInterface void addSelection(int startOffset, int endOffset) Q_DECL_OVERRIDE; QString attributes(int offset, int *startOffset, int *endOffset) const Q_DECL_OVERRIDE; -- cgit v1.2.3