From c6c1da2f4c71e523213aa8ee961d8fec779f62e2 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 21 Jul 2014 15:11:35 +0200 Subject: Try harder to return accessible names Always check if there is another accessible set as title for the one queried. For text fields also return the placeholder property if nothing else is set. Change-Id: I3f10ff04338a405ad8de00e75e15dded4aaeed3b Reviewed-by: Jocelyn Turcotte --- src/core/browser_accessibility_qt.cpp | 82 +++++++++++++++++++++- src/core/browser_accessibility_qt.h | 3 + .../tst_qwebengineaccessibility.cpp | 70 +++++++++++++----- 3 files changed, 136 insertions(+), 19 deletions(-) diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp index d2710b0ea..405bafb94 100644 --- a/src/core/browser_accessibility_qt.cpp +++ b/src/core/browser_accessibility_qt.cpp @@ -34,6 +34,10 @@ ** ****************************************************************************/ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + #include "browser_accessibility_qt.h" #include "third_party/WebKit/public/web/WebAXEnums.h" @@ -52,6 +56,82 @@ BrowserAccessibilityQt::BrowserAccessibilityQt() QAccessible::registerAccessibleInterface(this); } +// This function is taken from chromium/content/browser/accessibility/browser_accessibility_win.cc +// see also http://www.w3.org/TR/html-aapi +void BrowserAccessibilityQt::OnDataChanged() +{ + BrowserAccessibility::OnDataChanged(); + + // The calculation of the accessible name of an element has been + // standardized in the HTML to Platform Accessibility APIs Implementation + // Guide (http://www.w3.org/TR/html-aapi/). In order to return the + // appropriate accessible name on Windows, we need to apply some logic + // to the fields we get from WebKit. + // + // TODO(dmazzoni): move most of this logic into WebKit. + // + // WebKit gives us: + // + // name: the default name, e.g. inner text + // title ui element: a reference to a