summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordglazkov@chromium.org <dglazkov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-04 20:06:15 +0000
committerdglazkov@chromium.org <dglazkov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-04 20:06:15 +0000
commitc7287a9c5154d8ce9f213d5e741021b13dfcbe66 (patch)
tree9c67ea76a88047ac74632df01b1bec7557a2a3a7 /webkit
parentb8ce79bbe5104243715968ab112e6b19102effee (diff)
downloadchromium_src-c7287a9c5154d8ce9f213d5e741021b13dfcbe66.zip
chromium_src-c7287a9c5154d8ce9f213d5e741021b13dfcbe66.tar.gz
chromium_src-c7287a9c5154d8ce9f213d5e741021b13dfcbe66.tar.bz2
Introduce WebAccessibilityControllerImpl.
Removes accessibility-related WebCore dependencies from glue. R=darin TEST=none BUG=24616 Review URL: http://codereview.chromium.org/348063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30986 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/api/WebKit.gyp6
-rwxr-xr-xwebkit/api/public/WebAccessibilityCache.h (renamed from webkit/api/public/WebAccessibilityController.h)24
-rw-r--r--webkit/api/public/WebAccessibilityObject.h33
-rwxr-xr-xwebkit/api/src/WebAccessibilityCache.cpp (renamed from webkit/api/src/WebAccessibilityController.cpp)4
-rw-r--r--webkit/api/src/WebAccessibilityCacheImpl.cpp167
-rw-r--r--webkit/api/src/WebAccessibilityCacheImpl.h95
-rwxr-xr-xwebkit/api/src/WebAccessibilityObject.cpp276
-rw-r--r--webkit/glue/glue_accessibility_object.cc482
-rw-r--r--webkit/glue/glue_accessibility_object.h119
-rw-r--r--webkit/glue/webaccessibility.cc340
-rw-r--r--webkit/glue/webaccessibility.h7
-rw-r--r--webkit/glue/webaccessibilitymanager_impl.cc289
-rw-r--r--webkit/glue/webaccessibilitymanager_impl.h76
-rw-r--r--webkit/tools/test_shell/accessibility_controller.cc6
-rw-r--r--webkit/webkit.gyp13
15 files changed, 943 insertions, 994 deletions
diff --git a/webkit/api/WebKit.gyp b/webkit/api/WebKit.gyp
index 9551e7f..49c8966 100644
--- a/webkit/api/WebKit.gyp
+++ b/webkit/api/WebKit.gyp
@@ -64,7 +64,7 @@
'public/x11/WebScreenInfoFactory.h',
'public/mac/WebInputEventFactory.h',
'public/mac/WebScreenInfoFactory.h',
- 'public/WebAccessibilityController.h',
+ 'public/WebAccessibilityCache.h',
'public/WebAccessibilityObject.h',
'public/WebAccessibilityRole.h',
'public/WebApplicationCacheHost.h',
@@ -210,7 +210,9 @@
'src/StorageNamespaceProxy.cpp',
'src/StorageNamespaceProxy.h',
'src/TemporaryGlue.h',
- 'src/WebAccessibilityController.cpp',
+ 'src/WebAccessibilityCache.cpp',
+ 'src/WebAccessibilityCacheImpl.cpp',
+ 'src/WebAccessibilityCacheImpl.h',
'src/WebAccessibilityObject.cpp',
'src/WebBindings.cpp',
'src/WebCache.cpp',
diff --git a/webkit/api/public/WebAccessibilityController.h b/webkit/api/public/WebAccessibilityCache.h
index 00dbd13..91992c5 100755
--- a/webkit/api/public/WebAccessibilityController.h
+++ b/webkit/api/public/WebAccessibilityCache.h
@@ -28,20 +28,32 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebAccessibilityController_h
-#define WebAccessibilityController_h
+#ifndef WebAccessibilityCache_h
+#define WebAccessibilityCache_h
#include "WebCommon.h"
namespace WebKit {
+ class WebView;
+ class WebAccessibilityObject;
- // FIXME: Move all methods of WebAcessibilityManager here.
- class WebAccessibilityController {
+ class WebAccessibilityCache {
public:
- WebAccessibilityController() {}
- virtual ~WebAccessibilityController() {}
+ WebAccessibilityCache() {}
+ virtual ~WebAccessibilityCache() {}
+ static WebAccessibilityCache* create();
static void enableAccessibility();
+
+ virtual void initialize(WebView* view) = 0;
+ virtual bool isInitialized() const = 0;
+
+ virtual WebAccessibilityObject getObjectById(int) = 0;
+ virtual bool isValidId(int) const = 0;
+ virtual int addOrGetId(const WebAccessibilityObject& object) = 0;
+
+ virtual void remove(int) = 0;
+ virtual void clear() = 0;
};
} // namespace WebKit
diff --git a/webkit/api/public/WebAccessibilityObject.h b/webkit/api/public/WebAccessibilityObject.h
index 5bfbdc1..eba5c64 100644
--- a/webkit/api/public/WebAccessibilityObject.h
+++ b/webkit/api/public/WebAccessibilityObject.h
@@ -42,6 +42,8 @@ namespace WTF { template <typename T> class PassRefPtr; }
namespace WebKit {
class WebAccessibilityObjectPrivate;
class WebString;
+ struct WebPoint;
+ struct WebRect;
// A container for passing around a reference to AccessibilityObject.
class WebAccessibilityObject {
@@ -58,10 +60,39 @@ namespace WebKit {
bool isNull() const { return m_private == 0; }
WebString accessibilityDescription() const;
- WebAccessibilityObject childAt(unsigned) const;
+ WebString actionVerb() const;
+ bool canSetFocusAttribute() const;
+
unsigned childCount() const;
+
+ WebAccessibilityObject childAt(unsigned) const;
+ WebAccessibilityObject firstChild() const;
+ WebAccessibilityObject focusedChild() const;
+ WebAccessibilityObject lastChild() const;
+ WebAccessibilityObject nextSibling() const;
+ WebAccessibilityObject parentObject() const;
+ WebAccessibilityObject previousSibling() const;
+
+ bool isAnchor() const;
+ bool isChecked() const;
+ bool isFocused() const;
bool isEnabled() const;
+ bool isHovered() const;
+ bool isIndeterminate() const;
+ bool isMultiSelect() const;
+ bool isOffScreen() const;
+ bool isPasswordField() const;
+ bool isPressed() const;
+ bool isReadOnly() const;
+ bool isVisited() const;
+
+ WebRect boundingBoxRect() const;
+ WebString helpText() const;
+ WebAccessibilityObject hitTest(const WebPoint&) const;
+ WebString keyboardShortcut() const;
+ bool performDefaultAction() const;
WebAccessibilityRole roleValue() const;
+ WebString stringValue() const;
WebString title() const;
#if WEBKIT_IMPLEMENTATION
diff --git a/webkit/api/src/WebAccessibilityController.cpp b/webkit/api/src/WebAccessibilityCache.cpp
index d2df500..8a3f697 100755
--- a/webkit/api/src/WebAccessibilityController.cpp
+++ b/webkit/api/src/WebAccessibilityCache.cpp
@@ -29,7 +29,7 @@
*/
#include "config.h"
-#include "WebAccessibilityController.h"
+#include "WebAccessibilityCache.h"
#include "AXObjectCache.h"
@@ -37,7 +37,7 @@ using namespace WebCore;
namespace WebKit {
-void WebAccessibilityController::enableAccessibility()
+void WebAccessibilityCache::enableAccessibility()
{
AXObjectCache::enableAccessibility();
}
diff --git a/webkit/api/src/WebAccessibilityCacheImpl.cpp b/webkit/api/src/WebAccessibilityCacheImpl.cpp
new file mode 100644
index 0000000..232a765
--- /dev/null
+++ b/webkit/api/src/WebAccessibilityCacheImpl.cpp
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebAccessibilityCacheImpl.h"
+
+#include "AccessibilityObject.h"
+#include "AXObjectCache.h"
+#include "Document.h"
+#include "Frame.h"
+#include "WebAccessibilityObject.h"
+#include "WebFrameImpl.h"
+#include "WebViewImpl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+const int invalidObjectId = -1;
+const int firstObjectId = 1000;
+
+static PassRefPtr<AccessibilityObject> toAccessibilityObject(const WebAccessibilityObject& object)
+{
+ return object;
+}
+
+// WebView ----------------------------------------------------------------
+
+WebAccessibilityCache* WebAccessibilityCache::create()
+{
+ return new WebAccessibilityCacheImpl();
+}
+
+// WeakHandle -------------------------------------------------------------
+
+PassRefPtr<WebAccessibilityCacheImpl::WeakHandle> WebAccessibilityCacheImpl::WeakHandle::create(AccessibilityObject* object)
+{
+ // FIXME: Remove resetting ref-count from AccessibilityObjectWrapper
+ // and convert to use adoptRef.
+ return new WebAccessibilityCacheImpl::WeakHandle(object);
+}
+
+WebAccessibilityCacheImpl::WeakHandle::WeakHandle(AccessibilityObject* object)
+ : AccessibilityObjectWrapper(object)
+{
+ m_object->setWrapper(this);
+}
+
+// WebAccessibilityCacheImpl ----------------------------------------
+
+void WebAccessibilityCacheImpl::WeakHandle::detach()
+{
+ if (m_object)
+ m_object = 0;
+}
+
+WebAccessibilityCacheImpl::WebAccessibilityCacheImpl()
+ : m_nextNewId(firstObjectId)
+ , m_initialized(false)
+{
+}
+
+WebAccessibilityCacheImpl::~WebAccessibilityCacheImpl()
+{
+}
+
+void WebAccessibilityCacheImpl::initialize(WebView* view)
+{
+ AXObjectCache::enableAccessibility();
+ WebAccessibilityObject root = view->accessibilityObject();
+ if (root.isNull())
+ return;
+
+ RefPtr<AccessibilityObject> rootObject = toAccessibilityObject(root);
+
+ // Insert root in hashmaps.
+ m_objectMap.set(m_nextNewId, WeakHandle::create(rootObject.get()));
+ m_idMap.set(rootObject.get(), m_nextNewId++);
+
+ m_initialized = true;
+}
+
+WebAccessibilityObject WebAccessibilityCacheImpl::getObjectById(int id)
+{
+ ObjectMap::iterator it = m_objectMap.find(id);
+
+ if (it == m_objectMap.end() || !it->second)
+ return WebAccessibilityObject();
+
+ return WebAccessibilityObject(it->second->accessibilityObject());
+}
+
+bool WebAccessibilityCacheImpl::isValidId(int id) const
+{
+ return id >= firstObjectId;
+}
+
+void WebAccessibilityCacheImpl::remove(int id)
+{
+ ObjectMap::iterator it = m_objectMap.find(id);
+
+ if (it == m_objectMap.end())
+ return;
+
+ if (it->second) {
+ // Erase element from reverse hashmap.
+ IdMap::iterator it2 = m_idMap.find(it->second->accessibilityObject());
+ if (it2 != m_idMap.end())
+ m_idMap.remove(it2);
+ }
+
+ m_objectMap.remove(it);
+}
+
+void WebAccessibilityCacheImpl::clear()
+{
+ m_objectMap.clear();
+ m_idMap.clear();
+}
+
+int WebAccessibilityCacheImpl::addOrGetId(const WebAccessibilityObject& object) {
+ if (object.isNull())
+ return invalidObjectId;
+
+ RefPtr<AccessibilityObject> o = toAccessibilityObject(object);
+
+ IdMap::iterator it = m_idMap.find(o.get());
+
+ if (it != m_idMap.end())
+ return it->second;
+
+ // Insert new accessibility object in hashmaps and return its newly
+ // assigned accessibility object id.
+ m_objectMap.set(m_nextNewId, WeakHandle::create(o.get()));
+ m_idMap.set(o.get(), m_nextNewId);
+
+ return m_nextNewId++;
+}
+
+}
diff --git a/webkit/api/src/WebAccessibilityCacheImpl.h b/webkit/api/src/WebAccessibilityCacheImpl.h
new file mode 100644
index 0000000..1173a41
--- /dev/null
+++ b/webkit/api/src/WebAccessibilityCacheImpl.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebAccessibilityCacheImpl_h
+#define WebAccessibilityCacheImpl_h
+
+// FIXME: Move wtf/RefCounted.h include to AccessibilityObjectWrapper.h
+// once this file is upstream.
+#include <wtf/RefCounted.h>
+#include "AccessibilityObjectWrapper.h"
+#include "WebAccessibilityCache.h"
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+// FIXME: Should be eliminated to use AXObjectCache instead.
+class WebAccessibilityCacheImpl : public WebKit::WebAccessibilityCache {
+public:
+ virtual void initialize(WebView* view);
+ virtual bool isInitialized() const { return m_initialized; }
+
+ virtual WebAccessibilityObject getObjectById(int);
+ virtual bool isValidId(int) const;
+ virtual int addOrGetId(const WebKit::WebAccessibilityObject&);
+
+ virtual void remove(int);
+ virtual void clear();
+
+protected:
+ friend class WebKit::WebAccessibilityCache;
+
+ WebAccessibilityCacheImpl();
+ ~WebAccessibilityCacheImpl();
+
+private:
+ // FIXME: This can be just part of Chromium's AccessibilityObjectWrapper.
+ class WeakHandle : public WebCore::AccessibilityObjectWrapper {
+ public:
+ static PassRefPtr<WeakHandle> create(WebCore::AccessibilityObject*);
+ virtual void detach();
+ private:
+ WeakHandle(WebCore::AccessibilityObject*);
+ };
+
+ typedef HashMap<int, RefPtr<WeakHandle> > ObjectMap;
+ typedef HashMap<WebCore::AccessibilityObject*, int> IdMap;
+
+ // Hashmap for caching of elements in use by the AT, mapping id (int) to
+ // WebAccessibilityObject.
+ ObjectMap m_objectMap;
+ // Hashmap for caching of elements in use by the AT, mapping a
+ // AccessibilityObject pointer to its id (int). Needed for reverse lookup,
+ // to ensure unnecessary duplicate entries are not created in the
+ // ObjectMap and for focus changes in WebKit.
+ IdMap m_idMap;
+
+ // Unique identifier for retrieving an accessibility object from the page's
+ // hashmaps. Id is always 0 for the root of the accessibility object
+ // hierarchy (on a per-renderer process basis).
+ int m_nextNewId;
+
+ bool m_initialized;
+};
+
+}
+
+#endif
diff --git a/webkit/api/src/WebAccessibilityObject.cpp b/webkit/api/src/WebAccessibilityObject.cpp
index f1da633..49fed03 100755
--- a/webkit/api/src/WebAccessibilityObject.cpp
+++ b/webkit/api/src/WebAccessibilityObject.cpp
@@ -29,8 +29,14 @@
*/
#include "config.h"
-#include "AccessibilityObject.h"
#include "WebAccessibilityObject.h"
+
+#include "AccessibilityObject.h"
+#include "EventHandler.h"
+#include "FrameView.h"
+#include "PlatformKeyboardEvent.h"
+#include "WebPoint.h"
+#include "WebRect.h"
#include "WebString.h"
using namespace WebCore;
@@ -62,6 +68,33 @@ WebString WebAccessibilityObject::accessibilityDescription() const
return m_private->accessibilityDescription();
}
+WebString WebAccessibilityObject::actionVerb() const
+{
+ if (!m_private)
+ return WebString();
+
+ m_private->updateBackingStore();
+ return m_private->actionVerb();
+}
+
+bool WebAccessibilityObject::canSetFocusAttribute() const
+{
+ if (!m_private)
+ return false;
+
+ m_private->updateBackingStore();
+ return m_private->canSetFocusAttribute();
+}
+
+unsigned WebAccessibilityObject::childCount() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->children().size();
+}
+
WebAccessibilityObject WebAccessibilityObject::childAt(unsigned index) const
{
if (!m_private)
@@ -74,13 +107,92 @@ WebAccessibilityObject WebAccessibilityObject::childAt(unsigned index) const
return WebAccessibilityObject(m_private->children()[index]);
}
-unsigned WebAccessibilityObject::childCount() const
+WebAccessibilityObject WebAccessibilityObject::firstChild() const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ return WebAccessibilityObject(m_private->firstChild());
+}
+
+WebAccessibilityObject WebAccessibilityObject::focusedChild() const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ RefPtr<AccessibilityObject> focused = m_private->focusedUIElement();
+ if (m_private == focused.get() || focused->parentObject() == m_private)
+ return WebAccessibilityObject(focused);
+
+ return WebAccessibilityObject();
+}
+
+WebAccessibilityObject WebAccessibilityObject::lastChild() const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ return WebAccessibilityObject(m_private->lastChild());
+}
+
+
+WebAccessibilityObject WebAccessibilityObject::nextSibling() const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ return WebAccessibilityObject(m_private->nextSibling());
+}
+
+WebAccessibilityObject WebAccessibilityObject::parentObject() const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ return WebAccessibilityObject(m_private->parentObject());
+}
+
+
+WebAccessibilityObject WebAccessibilityObject::previousSibling() const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ return WebAccessibilityObject(m_private->previousSibling());
+}
+
+bool WebAccessibilityObject::isAnchor() const
{
if (!m_private)
return 0;
m_private->updateBackingStore();
- return m_private->children().size();
+ return m_private->isAnchor();
+}
+
+bool WebAccessibilityObject::isChecked() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isChecked();
+}
+
+
+bool WebAccessibilityObject::isFocused() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isFocused();
}
bool WebAccessibilityObject::isEnabled() const
@@ -92,12 +204,170 @@ bool WebAccessibilityObject::isEnabled() const
return m_private->isEnabled();
}
+bool WebAccessibilityObject::isHovered() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isHovered();
+}
+
+bool WebAccessibilityObject::isIndeterminate() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isIndeterminate();
+}
+
+bool WebAccessibilityObject::isMultiSelect() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isMultiSelect();
+}
+
+bool WebAccessibilityObject::isOffScreen() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isOffScreen();
+}
+
+bool WebAccessibilityObject::isPasswordField() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isPasswordField();
+}
+
+bool WebAccessibilityObject::isPressed() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isPressed();
+}
+
+bool WebAccessibilityObject::isReadOnly() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isReadOnly();
+}
+
+bool WebAccessibilityObject::isVisited() const
+{
+ if (!m_private)
+ return 0;
+
+ m_private->updateBackingStore();
+ return m_private->isVisited();
+}
+
+WebRect WebAccessibilityObject::boundingBoxRect() const
+{
+ if (!m_private)
+ return WebRect();
+
+ m_private->updateBackingStore();
+ return m_private->documentFrameView()->contentsToWindow(m_private->boundingBoxRect());
+}
+
+WebString WebAccessibilityObject::helpText() const
+{
+ if (!m_private)
+ return WebString();
+
+ m_private->updateBackingStore();
+ return m_private->helpText();
+}
+
+WebAccessibilityObject WebAccessibilityObject::hitTest(const WebPoint& point) const
+{
+ if (!m_private)
+ return WebAccessibilityObject();
+
+ m_private->updateBackingStore();
+ IntPoint contentsPoint = m_private->documentFrameView()->windowToContents(point);
+ RefPtr<AccessibilityObject> hit = m_private->doAccessibilityHitTest(contentsPoint);
+
+ if (hit.get())
+ return WebAccessibilityObject(hit);
+
+ if (m_private->boundingBoxRect().contains(contentsPoint))
+ return *this;
+
+ return WebAccessibilityObject();
+}
+
+WebString WebAccessibilityObject::keyboardShortcut() const
+{
+ if (!m_private)
+ return WebString();
+
+ m_private->updateBackingStore();
+ String accessKey = m_private->accessKey();
+ if (accessKey.isNull())
+ return WebString();
+
+ static String modifierString;
+ if (modifierString.isNull()) {
+ unsigned modifiers = EventHandler::accessKeyModifiers();
+ // Follow the same order as Mozilla MSAA implementation:
+ // Ctrl+Alt+Shift+Meta+key. MSDN states that keyboard shortcut strings
+ // should not be localized and defines the separator as "+".
+ if (modifiers & PlatformKeyboardEvent::CtrlKey)
+ modifierString += "Ctrl+";
+ if (modifiers & PlatformKeyboardEvent::AltKey)
+ modifierString += "Alt+";
+ if (modifiers & PlatformKeyboardEvent::ShiftKey)
+ modifierString += "Shift+";
+ if (modifiers & PlatformKeyboardEvent::MetaKey)
+ modifierString += "Win+";
+ }
+
+ return modifierString + accessKey;
+}
+
+bool WebAccessibilityObject::performDefaultAction() const
+{
+ if (!m_private)
+ return false;
+
+ m_private->updateBackingStore();
+ return m_private->performDefaultAction();
+}
+
WebAccessibilityRole WebAccessibilityObject::roleValue() const
{
+ if (!m_private)
+ return WebKit::WebAccessibilityRoleUnknown;
+
m_private->updateBackingStore();
return static_cast<WebAccessibilityRole>(m_private->roleValue());
}
+WebString WebAccessibilityObject::stringValue() const
+{
+ if (!m_private)
+ return WebString();
+
+ m_private->updateBackingStore();
+ return m_private->stringValue();
+}
+
WebString WebAccessibilityObject::title() const
{
if (!m_private)
diff --git a/webkit/glue/glue_accessibility_object.cc b/webkit/glue/glue_accessibility_object.cc
deleted file mode 100644
index 94a0b63..0000000
--- a/webkit/glue/glue_accessibility_object.cc
+++ /dev/null
@@ -1,482 +0,0 @@
-// Copyright (c) 2006-2009 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 "config.h"
-
-#include "AccessibilityObject.h"
-#include "EventHandler.h"
-#include "FrameView.h"
-#include "PlatformKeyboardEvent.h"
-
-#include "webkit/glue/glue_accessibility_object.h"
-
-using WebCore::AccessibilityObject;
-using WebCore::String;
-using webkit_glue::WebAccessibility;
-
-GlueAccessibilityObject::GlueAccessibilityObject(AccessibilityObject* obj)
- : AccessibilityObjectWrapper(obj) {
- m_object->setWrapper(this);
-}
-
-GlueAccessibilityObject* GlueAccessibilityObject::CreateInstance(
- AccessibilityObject* obj) {
- if (!obj)
- return NULL;
-
- return new GlueAccessibilityObject(obj);
-}
-
-bool GlueAccessibilityObject::DoDefaultAction(int child_id) {
- AccessibilityObject* child_obj;
-
- if (!GetAccessibilityObjectForChild(child_id, child_obj) ||
- !child_obj->performDefaultAction()) {
- return false;
- }
- return true;
-}
-
-GlueAccessibilityObject* GlueAccessibilityObject::HitTest(long x, long y) {
- if (!m_object)
- return NULL;
-
- // x, y - coordinates are passed in as window coordinates, to maintain
- // sandbox functionality.
- WebCore::IntPoint point =
- m_object->documentFrameView()->windowToContents(WebCore::IntPoint(x, y));
- AccessibilityObject* child_obj = m_object->doAccessibilityHitTest(point);
-
- if (!child_obj) {
- // If we did not hit any child objects, test whether the point hit us, and
- // report that.
- if (!m_object->boundingBoxRect().contains(point))
- return NULL;
- child_obj = m_object;
- }
- // TODO(klink): simple object child?
- ToWrapper(child_obj)->ref();
- return ToWrapper(child_obj);
-}
-
-bool GlueAccessibilityObject::Location(long* left, long* top, long* width,
- long* height, int child_id) {
- if (!left || !top || !width || !height)
- return false;
-
- *left = *top = *width = *height = 0;
-
- AccessibilityObject* child_obj;
- if (!GetAccessibilityObjectForChild(child_id, child_obj))
- return false;
-
- // Returning window coordinates, to be handled and converted appropriately by
- // the client.
- WebCore::IntRect window_rect(child_obj->documentFrameView()->contentsToWindow(
- child_obj->boundingBoxRect()));
- *left = window_rect.x();
- *top = window_rect.y();
- *width = window_rect.width();
- *height = window_rect.height();
- return true;
-}
-
-GlueAccessibilityObject* GlueAccessibilityObject::Navigate(
- WebAccessibility::Direction dir, int start_child_id) {
- AccessibilityObject* child_obj = 0;
-
- switch (dir) {
- case WebAccessibility::DIRECTION_DOWN:
- case WebAccessibility::DIRECTION_UP:
- case WebAccessibility::DIRECTION_LEFT:
- case WebAccessibility::DIRECTION_RIGHT:
- // These directions are not implemented, matching Mozilla and IE.
- return NULL;
- case WebAccessibility::DIRECTION_LASTCHILD:
- case WebAccessibility::DIRECTION_FIRSTCHILD:
- // MSDN states that navigating to first/last child can only be from self.
- if (start_child_id != 0 || !m_object)
- return NULL;
-
- if (dir == WebAccessibility::DIRECTION_FIRSTCHILD) {
- child_obj = m_object->firstChild();
- } else {
- child_obj = m_object->lastChild();
- }
- break;
- case WebAccessibility::DIRECTION_NEXT:
- case WebAccessibility::DIRECTION_PREVIOUS: {
- // Navigating to next and previous is allowed from self or any of our
- // children.
- if (!GetAccessibilityObjectForChild(start_child_id, child_obj))
- return NULL;
-
- if (dir == WebAccessibility::DIRECTION_NEXT) {
- child_obj = child_obj->nextSibling();
- } else {
- child_obj = child_obj->previousSibling();
- }
- break;
- }
- default:
- return NULL;
- }
-
- if (!child_obj)
- return NULL;
-
- // TODO(klink): simple object child?
- ToWrapper(child_obj)->ref();
- return ToWrapper(child_obj);
-}
-
-GlueAccessibilityObject* GlueAccessibilityObject::GetChild(int child_id) {
- AccessibilityObject* child_obj;
- if (!GetAccessibilityObjectForChild(child_id, child_obj))
- return NULL;
-
- // TODO(klink): simple object child?
- ToWrapper(child_obj)->ref();
- return ToWrapper(child_obj);
-}
-
-bool GlueAccessibilityObject::ChildCount(long* count) {
- if (!m_object || !count)
- return false;
-
- *count = static_cast<long>(m_object->children().size());
- return true;
-}
-
-bool GlueAccessibilityObject::DefaultAction(int child_id, String* action) {
- if (!action)
- return false;
-
- AccessibilityObject* child_obj;
- if (!GetAccessibilityObjectForChild(child_id, child_obj))
- return false;
-
- *action = child_obj->actionVerb();
- return !action->isEmpty();
-}
-
-bool GlueAccessibilityObject::Description(int child_id, String* description) {
- if (!description)
- return false;
-
- AccessibilityObject* child_obj;
- if (!GetAccessibilityObjectForChild(child_id, child_obj))
- return false;
-
- // TODO(klink): Description, for SELECT subitems, should be a string
- // describing the position of the item in its group and of the group in the
- // list (see Firefox).
- *description = ToWrapper(child_obj)->description();
- return !description->isEmpty();
-}
-
-GlueAccessibilityObject* GlueAccessibilityObject::GetFocusedChild() {
- if (!m_object)
- return NULL;
-
- AccessibilityObject* focused_obj = m_object->focusedUIElement();
- if (!focused_obj)
- return NULL;
-
- // Only return the focused child if it's us or a child of us.
- if (focused_obj == m_object || focused_obj->parentObject() == m_object) {
- ToWrapper(focused_obj)->ref();
- return ToWrapper(focused_obj);
- }
- return NULL;
-}
-
-bool GlueAccessibilityObject::HelpText(int child_id, String* help) {
- if (!help)
- return false;
-
- AccessibilityObject* child_obj;
- if (!GetAccessibilityObjectForChild(child_id, child_obj))
- return false;
-
- *help = child_obj->helpText();
- return !help->isEmpty();
-}
-
-bool GlueAccessibilityObject::KeyboardShortcut(int child_id, String* shortcut) {
- if (!shortcut)
- return false;
-
- AccessibilityObject* child_obj;
- if (!GetAccessibilityObjectForChild(child_id, child_obj))
- return false;
-
- String access_key = child_obj->accessKey();
- if (access_key.isNull())
- return false;
-
- static String access_key_modifiers;
- if (access_key_modifiers.isNull()) {
- unsigned modifiers = WebCore::EventHandler::accessKeyModifiers();
- // Follow the same order as Mozilla MSAA implementation:
- // Ctrl+Alt+Shift+Meta+key. MSDN states that keyboard shortcut strings
- // should not be localized and defines the separator as "+".
- if (modifiers & WebCore::PlatformKeyboardEvent::CtrlKey)
- access_key_modifiers += "Ctrl+";
- if (modifiers & WebCore::PlatformKeyboardEvent::AltKey)
- access_key_modifiers += "Alt+";
- if (modifiers & WebCore::PlatformKeyboardEvent::ShiftKey)
- access_key_modifiers += "Shift+";
- if (modifiers & WebCore::PlatformKeyboardEvent::MetaKey)
- access_key_modifiers += "Win+";
- }
- *shortcut = access_key_modifiers + access_key;
- return !shortcut->isEmpty();
-}
-
-bool GlueAccessibilityObject::Name(int child_id, String* name) {
- if (!name)
- return false;
-
- AccessibilityObject* child_obj;
- if (!GetAccessibilityObjectForChild(child_id, child_obj))
- return false;
-
- *name = ToWrapper(child_obj)->name();
- return !name->isEmpty();
-}
-
-GlueAccessibilityObject* GlueAccessibilityObject::GetParent() {
- if (!m_object)
- return NULL;
-
- AccessibilityObject* parent_obj = m_object->parentObject();
-
- if (parent_obj) {
- ToWrapper(parent_obj)->ref();
- return ToWrapper(parent_obj);
- }
- // No valid parent, or parent is the containing window.
- return NULL;
-}
-
-bool GlueAccessibilityObject::Role(int child_id, long* role) {
- if (!role)
- return false;
-
- AccessibilityObject* child_obj;
- if (!GetAccessibilityObjectForChild(child_id, child_obj))
- return false;
-
- *role = ToWrapper(child_obj)->role();
- return true;
-}
-
-bool GlueAccessibilityObject::Value(int child_id, String* value) {
- if (!value)
- return false;
-
- AccessibilityObject* child_obj;
- if (!GetAccessibilityObjectForChild(child_id, child_obj))
- return false;
-
- *value = ToWrapper(child_obj)->value();
- return !value->isEmpty();
-}
-
-bool GlueAccessibilityObject::State(int child_id, long* state) {
- if (!state)
- return false;
-
- *state = 0;
- AccessibilityObject* child_obj;
- if (!GetAccessibilityObjectForChild(child_id, child_obj))
- return false;
-
- if (child_obj->isChecked())
- *state |= static_cast<long>(1 << WebAccessibility::STATE_CHECKED);
-
- if (child_obj->canSetFocusAttribute())
- *state |= static_cast<long>(1 << WebAccessibility::STATE_FOCUSABLE);
-
- if (child_obj->isFocused())
- *state |= static_cast<long>(1 << WebAccessibility::STATE_FOCUSED);
-
- if (child_obj->isHovered())
- *state |= static_cast<long>(1 << WebAccessibility::STATE_HOTTRACKED);
-
- if (child_obj->isIndeterminate())
- *state |= static_cast<long>(1 << WebAccessibility::STATE_INDETERMINATE);
-
- if (child_obj->isAnchor())
- *state |= static_cast<long>(1 << WebAccessibility::STATE_LINKED);
-
- if (child_obj->isMultiSelect())
- *state |= static_cast<long>(1 << WebAccessibility::STATE_MULTISELECTABLE);
-
- if (child_obj->isOffScreen())
- *state |= static_cast<long>(1 << WebAccessibility::STATE_OFFSCREEN);
-
- if (child_obj->isPressed())
- *state |= static_cast<long>(1 << WebAccessibility::STATE_PRESSED);
-
- if (child_obj->isPasswordField())
- *state |= static_cast<long>(1 << WebAccessibility::STATE_PROTECTED);
-
- if (child_obj->isReadOnly())
- *state |= static_cast<long>(1 << WebAccessibility::STATE_READONLY);
-
- if (child_obj->isVisited())
- *state |= static_cast<long>(1 << WebAccessibility::STATE_TRAVERSED);
-
- if (!child_obj->isEnabled())
- *state |= static_cast<long>(1 << WebAccessibility::STATE_UNAVAILABLE);
-
- // TODO(klink): Add selected and selectable states.
-
- return true;
-}
-
-// Helper functions
-String GlueAccessibilityObject::name() const {
- return m_object->title();
-}
-
-String GlueAccessibilityObject::value() const {
- return m_object->stringValue();
-}
-
-String GlueAccessibilityObject::description() const {
- String desc = m_object->accessibilityDescription();
- if (desc.isNull())
- return desc;
-
- // From the Mozilla MSAA implementation:
- // "Signal to screen readers that this description is speakable and is not
- // a formatted positional information description. Don't localize the
- // 'Description: ' part of this string, it will be parsed out by assistive
- // technologies."
- return "Description: " + desc;
-}
-
-// Provides a conversion between the WebCore::AccessibilityRole and a
-// role supported on the Browser side. Listed alphabetically by the
-// WebAccessibility role (except for default role). Static function.
-static WebAccessibility::Role SupportedRole(WebCore::AccessibilityRole role) {
- switch (role) {
- case WebCore::LandmarkApplicationRole:
- return WebAccessibility::ROLE_APPLICATION;
- case WebCore::CellRole:
- return WebAccessibility::ROLE_CELL;
- case WebCore::CheckBoxRole:
- return WebAccessibility::ROLE_CHECKBUTTON;
- case WebCore::ColumnRole:
- return WebAccessibility::ROLE_COLUMN;
- case WebCore::ColumnHeaderRole:
- return WebAccessibility::ROLE_COLUMNHEADER;
- case WebCore::DocumentArticleRole:
- case WebCore::WebAreaRole:
- return WebAccessibility::ROLE_DOCUMENT;
- case WebCore::ImageMapRole:
- case WebCore::ImageRole:
- return WebAccessibility::ROLE_GRAPHIC;
- case WebCore::DocumentRegionRole:
- case WebCore::RadioGroupRole:
- case WebCore::GroupRole:
- return WebAccessibility::ROLE_GROUPING;
- case WebCore::LinkRole:
- case WebCore::WebCoreLinkRole:
- return WebAccessibility::ROLE_LINK;
- case WebCore::ListRole:
- return WebAccessibility::ROLE_LIST;
- case WebCore::ListBoxRole:
- return WebAccessibility::ROLE_LISTBOX;
- case WebCore::ListBoxOptionRole:
- return WebAccessibility::ROLE_LISTITEM;
- case WebCore::MenuBarRole:
- return WebAccessibility::ROLE_MENUBAR;
- case WebCore::MenuButtonRole:
- case WebCore::MenuItemRole:
- return WebAccessibility::ROLE_MENUITEM;
- case WebCore::MenuRole:
- return WebAccessibility::ROLE_MENUPOPUP;
- case WebCore::OutlineRole:
- return WebAccessibility::ROLE_OUTLINE;
- case WebCore::TabGroupRole:
- return WebAccessibility::ROLE_PAGETABLIST;
- case WebCore::ProgressIndicatorRole:
- return WebAccessibility::ROLE_PROGRESSBAR;
- case WebCore::ButtonRole:
- return WebAccessibility::ROLE_PUSHBUTTON;
- case WebCore::RadioButtonRole:
- return WebAccessibility::ROLE_RADIOBUTTON;
- case WebCore::RowRole:
- return WebAccessibility::ROLE_ROW;
- case WebCore::RowHeaderRole:
- return WebAccessibility::ROLE_ROWHEADER;
- case WebCore::SplitterRole:
- return WebAccessibility::ROLE_SEPARATOR;
- case WebCore::SliderRole:
- return WebAccessibility::ROLE_SLIDER;
- case WebCore::StaticTextRole:
- return WebAccessibility::ROLE_STATICTEXT;
- case WebCore::ApplicationStatusRole:
- return WebAccessibility::ROLE_STATUSBAR;
- case WebCore::TableRole:
- return WebAccessibility::ROLE_TABLE;
- case WebCore::ListMarkerRole:
- case WebCore::TextFieldRole:
- case WebCore::TextAreaRole:
- return WebAccessibility::ROLE_TEXT;
- case WebCore::ToolbarRole:
- return WebAccessibility::ROLE_TOOLBAR;
- case WebCore::UserInterfaceTooltipRole:
- return WebAccessibility::ROLE_TOOLTIP;
- case WebCore::DocumentRole:
- case WebCore::UnknownRole:
- default:
- // This is the default role.
- return WebAccessibility::ROLE_CLIENT;
- }
-}
-
-WebAccessibility::Role GlueAccessibilityObject::role() const {
- return SupportedRole(m_object->roleValue());
-}
-
-bool GlueAccessibilityObject::GetAccessibilityObjectForChild(int child_id,
- AccessibilityObject*& child_obj) const {
- child_obj = 0;
-
- if (!m_object || child_id < 0)
- return false;
-
- if (child_id == 0) {
- child_obj = m_object;
- } else {
- size_t child_index = static_cast<size_t>(child_id - 1);
-
- if (child_index >= m_object->children().size())
- return false;
- child_obj = m_object->children().at(child_index).get();
- }
-
- if (!child_obj)
- return false;
-
- return true;
-}
-
-GlueAccessibilityObject* GlueAccessibilityObject::ToWrapper(
- AccessibilityObject* obj) {
- if (!obj)
- return NULL;
-
- GlueAccessibilityObject* result =
- static_cast<GlueAccessibilityObject*>(obj->wrapper());
- if (!result)
- result = CreateInstance(obj);
-
- return result;
-}
diff --git a/webkit/glue/glue_accessibility_object.h b/webkit/glue/glue_accessibility_object.h
deleted file mode 100644
index f94f9a1..0000000
--- a/webkit/glue/glue_accessibility_object.h
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright (c) 2006-2008 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.
-
-#ifndef WEBKIT_GLUE_GLUE_ACCESSIBILITY_OBJECT_H_
-#define WEBKIT_GLUE_GLUE_ACCESSIBILITY_OBJECT_H_
-
-#include "AccessibilityObjectWrapper.h"
-
-#include "base/basictypes.h"
-#include "webkit/glue/webaccessibility.h"
-
-namespace WebCore {
-class AccessibilityObject;
-enum AccessibilityRole;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// GlueAccessibilityObject
-//
-// Operations that access the underlying WebKit DOM directly, exposing
-// accessibility information to the GlueAccessibilityManager. Also provides a
-// platform-independent wrapper to WebKit's AccessibilityObject.
-////////////////////////////////////////////////////////////////////////////////
-class GlueAccessibilityObject : public WebCore::AccessibilityObjectWrapper {
- public:
- static GlueAccessibilityObject* CreateInstance(WebCore::AccessibilityObject*);
-
- virtual ~GlueAccessibilityObject() {}
-
- // Performs the default action on a given object.
- bool DoDefaultAction(int child_id);
-
- // Retrieves the child element or child object at a given point on the screen.
- GlueAccessibilityObject* HitTest(long x, long y);
-
- // Retrieves the specified object's current screen location.
- bool Location(long* left,
- long* top,
- long* width,
- long* height,
- int child_id);
-
- // Traverses to another UI element and retrieves the object.
- GlueAccessibilityObject* Navigate(
- webkit_glue::WebAccessibility::Direction dir,
- int start_child_id);
-
- // Retrieves an GlueAccessibilityObject pointer for the specified [child_id].
- GlueAccessibilityObject* GetChild(int child_id);
-
- // Retrieves the number of accessible children.
- bool ChildCount(long* count);
-
- // Retrieves a string that describes the object's default action.
- bool DefaultAction(int child_id, WebCore::String* action);
-
- // Retrieves the object's description.
- bool Description(int child_id, WebCore::String* description);
-
- // Retrieves the object that has the keyboard focus.
- GlueAccessibilityObject* GetFocusedChild();
-
- // Retrieves the help information associated with the object.
- bool HelpText(int child_id, WebCore::String* help);
-
- // Retrieves the specified object's shortcut.
- bool KeyboardShortcut(int child_id, WebCore::String* shortcut);
-
- // Retrieves the name of the specified object.
- bool Name(int child_id, WebCore::String* name);
-
- // Retrieves the GlueAccessibilityObject of the object's parent. In the case
- // of the root object (where the parent is the containing window), it is up
- // to the browser side to handle this.
- GlueAccessibilityObject* GetParent();
-
- // Retrieves information describing the role of the specified object.
- bool Role(int child_id, long* role);
-
- // Retrieves the current state of the specified object.
- bool State(int child_id, long* state);
-
- // Returns the value associated with the object.
- bool Value(int child_id, WebCore::String* value);
-
- // WebCore::AccessiblityObjectWrapper.
- virtual void detach() {
- if (m_object)
- m_object = 0;
- }
-
- protected:
- explicit GlueAccessibilityObject(WebCore::AccessibilityObject*);
-
- // Helper functions.
- WebCore::String name() const;
- WebCore::String value() const;
- WebCore::String description() const;
- webkit_glue::WebAccessibility::Role role() const;
-
- // Retrieves the AccessibilityObject for a given [child_id]. Returns false if
- // [child_id] is less than 0, or if no valid AccessibilityObject is found.
- // A [child_id] of 0 is treated as referring to the current object itself.
- bool GetAccessibilityObjectForChild(int child_id,
- WebCore::AccessibilityObject*&) const;
-
- // Wraps the given AccessibilityObject in a GlueAccessibilityObject and
- // returns it. If the AccessibilityObject already has a wrapper assigned, that
- // one is returned. Otherwise, a new instance of GlueAccessibilityObject is
- // created and assigned as the wrapper.
- static GlueAccessibilityObject* ToWrapper(WebCore::AccessibilityObject*);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(GlueAccessibilityObject);
-};
-
-#endif // WEBKIT_GLUE_GLUE_ACCESSIBILITY_OBJECT_H_
diff --git a/webkit/glue/webaccessibility.cc b/webkit/glue/webaccessibility.cc
new file mode 100644
index 0000000..6553eeb
--- /dev/null
+++ b/webkit/glue/webaccessibility.cc
@@ -0,0 +1,340 @@
+// Copyright (c) 2006-2008 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 "webkit/glue/webaccessibility.h"
+
+#include "webkit/api/public/WebAccessibilityCache.h"
+#include "webkit/api/public/WebAccessibilityObject.h"
+#include "webkit/api/public/WebAccessibilityRole.h"
+#include "webkit/api/public/WebPoint.h"
+#include "webkit/api/public/WebRect.h"
+#include "webkit/api/public/WebString.h"
+
+using WebKit::WebAccessibilityCache;
+using WebKit::WebAccessibilityRole;
+using WebKit::WebAccessibilityObject;
+using WebKit::WebPoint;
+using WebKit::WebRect;
+using WebKit::WebString;
+
+namespace webkit_glue {
+
+// Provides a conversion between the WebKit::WebAccessibilityRole and a role
+// supported on the Browser side. Listed alphabetically by the
+// WebAccessibilityRole (except for default role).
+WebAccessibility::Role ConvertRole(WebKit::WebAccessibilityRole role) {
+ switch (role) {
+ case WebKit::WebAccessibilityRoleLandmarkApplication:
+ return WebAccessibility::ROLE_APPLICATION;
+ case WebKit::WebAccessibilityRoleCell:
+ return WebAccessibility::ROLE_CELL;
+ case WebKit::WebAccessibilityRoleCheckBox:
+ return WebAccessibility::ROLE_CHECKBUTTON;
+ case WebKit::WebAccessibilityRoleColumn:
+ return WebAccessibility::ROLE_COLUMN;
+ case WebKit::WebAccessibilityRoleColumnHeader:
+ return WebAccessibility::ROLE_COLUMNHEADER;
+ case WebKit::WebAccessibilityRoleDocumentArticle:
+ case WebKit::WebAccessibilityRoleWebArea:
+ return WebAccessibility::ROLE_DOCUMENT;
+ case WebKit::WebAccessibilityRoleImageMap:
+ case WebKit::WebAccessibilityRoleImage:
+ return WebAccessibility::ROLE_GRAPHIC;
+ case WebKit::WebAccessibilityRoleDocumentRegion:
+ case WebKit::WebAccessibilityRoleRadioGroup:
+ case WebKit::WebAccessibilityRoleGroup:
+ return WebAccessibility::ROLE_GROUPING;
+ case WebKit::WebAccessibilityRoleLink:
+ case WebKit::WebAccessibilityRoleWebCoreLink:
+ return WebAccessibility::ROLE_LINK;
+ case WebKit::WebAccessibilityRoleList:
+ return WebAccessibility::ROLE_LIST;
+ case WebKit::WebAccessibilityRoleListBox:
+ return WebAccessibility::ROLE_LISTBOX;
+ case WebKit::WebAccessibilityRoleListBoxOption:
+ return WebAccessibility::ROLE_LISTITEM;
+ case WebKit::WebAccessibilityRoleMenuBar:
+ return WebAccessibility::ROLE_MENUBAR;
+ case WebKit::WebAccessibilityRoleMenuButton:
+ case WebKit::WebAccessibilityRoleMenuItem:
+ return WebAccessibility::ROLE_MENUITEM;
+ case WebKit::WebAccessibilityRoleMenu:
+ return WebAccessibility::ROLE_MENUPOPUP;
+ case WebKit::WebAccessibilityRoleOutline:
+ return WebAccessibility::ROLE_OUTLINE;
+ case WebKit::WebAccessibilityRoleTabGroup:
+ return WebAccessibility::ROLE_PAGETABLIST;
+ case WebKit::WebAccessibilityRoleProgressIndicator:
+ return WebAccessibility::ROLE_PROGRESSBAR;
+ case WebKit::WebAccessibilityRoleButton:
+ return WebAccessibility::ROLE_PUSHBUTTON;
+ case WebKit::WebAccessibilityRoleRadioButton:
+ return WebAccessibility::ROLE_RADIOBUTTON;
+ case WebKit::WebAccessibilityRoleRow:
+ return WebAccessibility::ROLE_ROW;
+ case WebKit::WebAccessibilityRoleRowHeader:
+ return WebAccessibility::ROLE_ROWHEADER;
+ case WebKit::WebAccessibilityRoleSplitter:
+ return WebAccessibility::ROLE_SEPARATOR;
+ case WebKit::WebAccessibilityRoleSlider:
+ return WebAccessibility::ROLE_SLIDER;
+ case WebKit::WebAccessibilityRoleStaticText:
+ return WebAccessibility::ROLE_STATICTEXT;
+ case WebKit::WebAccessibilityRoleApplicationStatus:
+ return WebAccessibility::ROLE_STATUSBAR;
+ case WebKit::WebAccessibilityRoleTable:
+ return WebAccessibility::ROLE_TABLE;
+ case WebKit::WebAccessibilityRoleListMarker:
+ case WebKit::WebAccessibilityRoleTextField:
+ case WebKit::WebAccessibilityRoleTextArea:
+ return WebAccessibility::ROLE_TEXT;
+ case WebKit::WebAccessibilityRoleToolbar:
+ return WebAccessibility::ROLE_TOOLBAR;
+ case WebKit::WebAccessibilityRoleUserInterfaceTooltip:
+ return WebAccessibility::ROLE_TOOLTIP;
+ case WebKit::WebAccessibilityRoleDocument:
+ case WebKit::WebAccessibilityRoleUnknown:
+ default:
+ // This is the default role.
+ return WebAccessibility::ROLE_CLIENT;
+ }
+}
+
+long ConvertState(const WebAccessibilityObject& o) {
+ long state = 0;
+ if (o.isChecked())
+ state |= static_cast<long>(1 << WebAccessibility::STATE_CHECKED);
+
+ if (o.canSetFocusAttribute())
+ state |= static_cast<long>(1 << WebAccessibility::STATE_FOCUSABLE);
+
+ if (o.isFocused())
+ state |= static_cast<long>(1 << WebAccessibility::STATE_FOCUSED);
+
+ if (o.isHovered())
+ state |= static_cast<long>(1 << WebAccessibility::STATE_HOTTRACKED);
+
+ if (o.isIndeterminate())
+ state |= static_cast<long>(1 << WebAccessibility::STATE_INDETERMINATE);
+
+ if (o.isAnchor())
+ state |= static_cast<long>(1 << WebAccessibility::STATE_LINKED);
+
+ if (o.isMultiSelect())
+ state |= static_cast<long>(1 << WebAccessibility::STATE_MULTISELECTABLE);
+
+ if (o.isOffScreen())
+ state |= static_cast<long>(1 << WebAccessibility::STATE_OFFSCREEN);
+
+ if (o.isPressed())
+ state |= static_cast<long>(1 << WebAccessibility::STATE_PRESSED);
+
+ if (o.isPasswordField())
+ state |= static_cast<long>(1 << WebAccessibility::STATE_PROTECTED);
+
+ if (o.isReadOnly())
+ state |= static_cast<long>(1 << WebAccessibility::STATE_READONLY);
+
+ if (o.isVisited())
+ state |= static_cast<long>(1 << WebAccessibility::STATE_TRAVERSED);
+
+ if (!o.isEnabled())
+ state |= static_cast<long>(1 << WebAccessibility::STATE_UNAVAILABLE);
+
+ return state;
+}
+
+
+bool WebAccessibility::GetAccObjInfo(WebAccessibilityCache* cache,
+ const WebAccessibility::InParams& in_params,
+ WebAccessibility::OutParams* out_params) {
+
+ // Find object requested by |object_id|.
+ WebAccessibilityObject active_acc_obj;
+
+ // Since ids assigned by Chrome starts at 1000, whereas platform-specific ids
+ // used to reference a child will be in a wholly different range, we know
+ // that any id that high should be treated as a non-direct descendant.
+ bool local_child = false;
+ if (cache->isValidId(in_params.child_id)) {
+ // Object is not a direct child, re-map the input parameters accordingly.
+ // The object to be retrieved is referred to by the |in_params.child_id|, as
+ // a result of e.g. a focus event.
+ active_acc_obj = cache->getObjectById(in_params.child_id);
+ } else {
+ local_child = true;
+
+ active_acc_obj = cache->getObjectById(in_params.object_id);
+ if (active_acc_obj.isNull())
+ return false;
+
+ // child_id == 0 means self. Otherwise, it's a local child - 1.
+ if (in_params.child_id > 0) {
+ unsigned index = in_params.child_id - 1;
+ if (index >= active_acc_obj.childCount())
+ return false;
+
+ active_acc_obj = active_acc_obj.childAt(index);
+ }
+ }
+
+ if (active_acc_obj.isNull())
+ return false;
+
+ // Temp paramters for holding output information.
+ WebAccessibilityObject out_acc_obj;
+ string16 out_string;
+
+ switch (in_params.function_id) {
+ case WebAccessibility::FUNCTION_DODEFAULTACTION: {
+ if (!active_acc_obj.performDefaultAction())
+ return false;
+ break;
+ }
+ case WebAccessibility::FUNCTION_HITTEST: {
+ WebPoint point(in_params.input_long1, in_params.input_long2);
+ out_acc_obj = active_acc_obj.hitTest(point);
+ if (out_acc_obj.isNull())
+ return false;
+ break;
+ }
+ case WebAccessibility::FUNCTION_LOCATION: {
+ WebRect rect = active_acc_obj.boundingBoxRect();
+ out_params->output_long1 = rect.x;
+ out_params->output_long2 = rect.y;
+ out_params->output_long3 = rect.width;
+ out_params->output_long4 = rect.height;
+ break;
+ }
+ case WebAccessibility::FUNCTION_NAVIGATE: {
+ WebAccessibility::Direction dir =
+ static_cast<WebAccessibility::Direction>(in_params.input_long1);
+ switch (dir) {
+ case WebAccessibility::DIRECTION_DOWN:
+ case WebAccessibility::DIRECTION_UP:
+ case WebAccessibility::DIRECTION_LEFT:
+ case WebAccessibility::DIRECTION_RIGHT:
+ // These directions are not implemented, matching Mozilla and IE.
+ return false;
+ case WebAccessibility::DIRECTION_LASTCHILD:
+ case WebAccessibility::DIRECTION_FIRSTCHILD:
+ // MSDN states that navigating to first/last child can only be from
+ // self.
+ if (!local_child)
+ return false;
+
+ if (dir == WebAccessibility::DIRECTION_FIRSTCHILD) {
+ out_acc_obj = active_acc_obj.firstChild();
+ } else {
+ out_acc_obj = active_acc_obj.lastChild();
+ }
+ break;
+ case WebAccessibility::DIRECTION_NEXT:
+ case WebAccessibility::DIRECTION_PREVIOUS: {
+ if (dir == WebAccessibility::DIRECTION_NEXT) {
+ out_acc_obj = active_acc_obj.nextSibling();
+ } else {
+ out_acc_obj = active_acc_obj.previousSibling();
+ }
+ break;
+ }
+ default:
+ return false;
+ }
+ if (out_acc_obj.isNull())
+ return false;
+ break;
+ }
+ case WebAccessibility::FUNCTION_GETCHILD: {
+ out_params->object_id = in_params.object_id;
+ out_acc_obj = active_acc_obj;
+ break;
+ }
+ case WebAccessibility::FUNCTION_CHILDCOUNT: {
+ out_params->output_long1 = active_acc_obj.childCount();
+ break;
+ }
+ case WebAccessibility::FUNCTION_DEFAULTACTION: {
+ out_string = active_acc_obj.actionVerb();
+ if (out_string.empty())
+ return false;
+ break;
+ }
+ case WebAccessibility::FUNCTION_DESCRIPTION: {
+ out_string = active_acc_obj.accessibilityDescription();
+ if (out_string.empty())
+ return false;
+ // From the Mozilla MSAA implementation:
+ // "Signal to screen readers that this description is speakable and is not
+ // a formatted positional information description. Don't localize the
+ // 'Description: ' part of this string, it will be parsed out by assistive
+ // technologies."
+ out_string = L"Description: " + out_string;
+ break;
+ }
+ case WebAccessibility::FUNCTION_GETFOCUSEDCHILD: {
+ out_acc_obj = active_acc_obj.focusedChild();
+ if (out_acc_obj.isNull())
+ return false;
+ break;
+ }
+ case WebAccessibility::FUNCTION_HELPTEXT: {
+ out_string = active_acc_obj.helpText();
+ if (out_string.empty())
+ return false;
+ break;
+ }
+ case WebAccessibility::FUNCTION_KEYBOARDSHORTCUT: {
+ out_string = active_acc_obj.keyboardShortcut();
+ if (out_string.empty())
+ return false;
+ break;
+ }
+ case WebAccessibility::FUNCTION_NAME: {
+ out_string = active_acc_obj.title();
+ if (out_string.empty())
+ return false;
+ break;
+ }
+ case WebAccessibility::FUNCTION_GETPARENT: {
+ out_acc_obj = active_acc_obj.parentObject();
+ if (out_acc_obj.isNull())
+ return false;
+ break;
+ }
+ case WebAccessibility::FUNCTION_ROLE: {
+ out_params->output_long1 = ConvertRole(active_acc_obj.roleValue());
+ break;
+ }
+ case WebAccessibility::FUNCTION_STATE: {
+ out_params->output_long1 = ConvertState(active_acc_obj);
+ break;
+ }
+ case WebAccessibility::FUNCTION_VALUE: {
+ out_string = active_acc_obj.stringValue();
+ if (out_string.empty())
+ return false;
+ break;
+ }
+ default:
+ // Non-supported function id.
+ return false;
+ }
+
+ // Output and hashmap assignments, as appropriate.
+ if (!out_string.empty())
+ out_params->output_string = out_string;
+
+ if (out_acc_obj.isNull())
+ return true;
+
+ int id = cache->addOrGetId(out_acc_obj);
+ out_params->object_id = id;
+ out_params->output_long1 = -1;
+
+ // TODO(klink): Handle simple objects returned.
+ return true;
+}
+
+} // namespace webkit_glue
diff --git a/webkit/glue/webaccessibility.h b/webkit/glue/webaccessibility.h
index f57c06c..b1be0d1 100644
--- a/webkit/glue/webaccessibility.h
+++ b/webkit/glue/webaccessibility.h
@@ -7,6 +7,10 @@
#include "base/string16.h"
+namespace WebKit {
+class WebAccessibilityCache;
+}
+
namespace webkit_glue {
class WebAccessibility {
@@ -165,6 +169,9 @@ class WebAccessibility {
// input validation.
bool return_code;
};
+
+ static bool GetAccObjInfo(WebKit::WebAccessibilityCache* cache,
+ const InParams& in_params, OutParams* out_params);
};
} // namespace webkit_glue
diff --git a/webkit/glue/webaccessibilitymanager_impl.cc b/webkit/glue/webaccessibilitymanager_impl.cc
deleted file mode 100644
index f512a37..0000000
--- a/webkit/glue/webaccessibilitymanager_impl.cc
+++ /dev/null
@@ -1,289 +0,0 @@
-// Copyright (c) 2006-2008 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 "config.h"
-
-#include "AXObjectCache.h"
-#include "Document.h"
-#include "Frame.h"
-#include "RefPtr.h"
-#undef LOG
-
-#include "webkit/glue/webaccessibilitymanager_impl.h"
-
-#include "webkit/api/public/WebAccessibilityObject.h"
-#include "webkit/api/src/WebFrameImpl.h"
-#include "webkit/api/src/WebViewImpl.h"
-#include "webkit/glue/glue_accessibility_object.h"
-#include "webkit/glue/glue_util.h"
-
-using WebKit::WebAccessibilityObject;
-using WebKit::WebFrameImpl;
-using WebKit::WebView;
-
-namespace webkit_glue {
-
-// struct WebAccessibilityManagerImpl::GlueAccessibilityObjectRoot
-struct WebAccessibilityManagerImpl::GlueAccessibilityObjectRoot {
- GlueAccessibilityObjectRoot() {}
-
- // Root of the WebKit AccessibilityObject tree.
- RefPtr<GlueAccessibilityObject> acc_obj_root_;
-};
-
-/*static*/
-WebAccessibilityManager* WebAccessibilityManager::Create() {
- return new WebAccessibilityManagerImpl();
-}
-
-// class WebAccessibilityManagerImpl
-WebAccessibilityManagerImpl::WebAccessibilityManagerImpl()
- : root_(new GlueAccessibilityObjectRoot),
- acc_obj_id_(1000) {
-}
-
-WebAccessibilityManagerImpl::~WebAccessibilityManagerImpl() {
- int_to_glue_acc_obj_map_.clear();
- acc_obj_to_int_map_.clear();
-}
-
-bool WebAccessibilityManagerImpl::GetAccObjInfo(WebView* view,
- const WebAccessibility::InParams& in_params,
- WebAccessibility::OutParams* out_params) {
- if (!root_->acc_obj_root_ && !InitAccObjRoot(view)) {
- // Failure in retrieving or initializing the root.
- return false;
- }
-
- // Function input parameters.
- int object_id = in_params.object_id;
- int child_id = in_params.child_id;
-
- // Since ids assigned by Chrome starts at 1000, whereas platform-specific ids
- // used to reference a child will be in a wholly different range, we know
- // that any id that high should be treated as a non-direct descendant.
- if (in_params.child_id >= 1000) {
- // Object is not a direct child, re-map the input parameters accordingly.
- // The object to be retrieved is referred to by the |in_params.child_id|, as
- // a result of e.g. a focus event. The local |child_id| is set to 0, to
- // indicate that any function call should refer to the object itself.
- object_id = in_params.child_id;
- child_id = 0;
- }
-
- // Find GlueAccessibilityObject requested by |object_id|.
- IntToGlueAccObjMap::iterator it =
- int_to_glue_acc_obj_map_.find(object_id);
- if (it == int_to_glue_acc_obj_map_.end() || !it->second) {
- // Map did not contain a valid instance of the data requested.
- return false;
- }
- RefPtr<GlueAccessibilityObject> active_acc_obj = it->second;
-
- // Temp paramters for holding output information.
- RefPtr<GlueAccessibilityObject> out_acc_obj = NULL;
- WebCore::String out_string;
-
- switch (in_params.function_id) {
- case WebAccessibility::FUNCTION_DODEFAULTACTION :
- if (!active_acc_obj->DoDefaultAction(child_id))
- return false;
- break;
- case WebAccessibility::FUNCTION_HITTEST :
- out_acc_obj = active_acc_obj->HitTest(in_params.input_long1,
- in_params.input_long2);
- if (!out_acc_obj.get())
- return false;
- break;
- case WebAccessibility::FUNCTION_LOCATION :
- if (!active_acc_obj->Location(&out_params->output_long1,
- &out_params->output_long2,
- &out_params->output_long3,
- &out_params->output_long4,
- child_id)) {
- return false;
- }
- break;
- case WebAccessibility::FUNCTION_NAVIGATE :
- out_acc_obj = active_acc_obj->Navigate(
- static_cast<WebAccessibility::Direction>(in_params.input_long1),
- child_id);
- if (!out_acc_obj.get())
- return false;
- break;
- case WebAccessibility::FUNCTION_GETCHILD :
- if (child_id == 0) {
- // If child requested is self, stay with the same accessibility object.
- out_params->object_id = in_params.object_id;
- out_acc_obj = active_acc_obj.get();
- } else {
- out_acc_obj = active_acc_obj->GetChild(child_id);
- }
-
- if (!out_acc_obj.get())
- return false;
- break;
- case WebAccessibility::FUNCTION_CHILDCOUNT :
- if (!active_acc_obj->ChildCount(&out_params->output_long1))
- return false;
- break;
- case WebAccessibility::FUNCTION_DEFAULTACTION :
- if (!active_acc_obj->DefaultAction(child_id, &out_string))
- return false;
- break;
- case WebAccessibility::FUNCTION_DESCRIPTION :
- if (!active_acc_obj->Description(child_id, &out_string))
- return false;
- break;
- case WebAccessibility::FUNCTION_GETFOCUSEDCHILD :
- out_acc_obj = active_acc_obj->GetFocusedChild();
- if (!out_acc_obj.get())
- return false;
- break;
- case WebAccessibility::FUNCTION_HELPTEXT :
- if (!active_acc_obj->HelpText(child_id, &out_string))
- return false;
- break;
- case WebAccessibility::FUNCTION_KEYBOARDSHORTCUT :
- if (!active_acc_obj->KeyboardShortcut(child_id, &out_string))
- return false;
- break;
- case WebAccessibility::FUNCTION_NAME :
- if (!active_acc_obj->Name(child_id, &out_string))
- return false;
- break;
- case WebAccessibility::FUNCTION_GETPARENT :
- out_acc_obj = active_acc_obj->GetParent();
- if (!out_acc_obj.get())
- return false;
- break;
- case WebAccessibility::FUNCTION_ROLE :
- if (!active_acc_obj->Role(child_id, &out_params->output_long1))
- return false;
- break;
- case WebAccessibility::FUNCTION_STATE :
- if (!active_acc_obj->State(child_id, &out_params->output_long1))
- return false;
- break;
- case WebAccessibility::FUNCTION_VALUE :
- if (!active_acc_obj->Value(child_id, &out_string))
- return false;
- break;
- default:
- // Non-supported function id.
- return false;
- }
-
- // Output and hashmap assignments, as appropriate.
- if (!out_string.isEmpty())
- out_params->output_string = StringToString16(out_string);
-
- if (out_acc_obj) {
- AccObjToIntMap::iterator it =
- acc_obj_to_int_map_.find(out_acc_obj->accessibilityObject());
-
- if (it != acc_obj_to_int_map_.end()) {
- // Data already present in map, return previously assigned id.
- out_params->object_id = it->second;
- out_params->output_long1 = -1;
- } else {
- // Insert new GlueAccessibilityObject in hashmaps.
- int_to_glue_acc_obj_map_[acc_obj_id_] = out_acc_obj.get();
- acc_obj_to_int_map_[out_acc_obj->accessibilityObject()] = acc_obj_id_;
- out_params->object_id = acc_obj_id_++;
- out_params->output_long1 = -1;
- }
- }
- // TODO(klink): Handle simple objects returned.
- return true;
-}
-
-bool WebAccessibilityManagerImpl::InitAccObjRoot(WebView* view) {
- // Enable accessibility and retrieve Document.
- WebCore::AXObjectCache::enableAccessibility();
- WebFrameImpl* main_frame_impl =
- static_cast<WebFrameImpl*>(view->mainFrame());
- if (!main_frame_impl || !main_frame_impl->frame())
- return false;
-
- WebCore::Document* doc = main_frame_impl->frame()->document();
-
- if (!doc || !doc->renderer())
- return false;
-
- if (!root_->acc_obj_root_) {
- // Either we've never had a wrapper for this frame's top-level Document,
- // the Document renderer was destroyed and its wrapper was detached, or
- // the previous Document is in the page cache, and the current document
- // needs to be wrapped.
- root_->acc_obj_root_ = GlueAccessibilityObject::CreateInstance(doc->
- axObjectCache()->getOrCreate(doc->renderer()));
- }
- // Insert root in hashmaps.
- int_to_glue_acc_obj_map_[acc_obj_id_] = root_->acc_obj_root_.get();
- acc_obj_to_int_map_[root_->acc_obj_root_->accessibilityObject()] =
- acc_obj_id_++;
-
- return true;
-}
-
-bool WebAccessibilityManagerImpl::ClearAccObjMap(int acc_obj_id,
- bool clear_all) {
- if (clear_all) {
- // Clear maps and invalidate root.
- int_to_glue_acc_obj_map_.clear();
- acc_obj_to_int_map_.clear();
- root_->acc_obj_root_ = 0;
- return true;
- }
-
- IntToGlueAccObjMap::iterator it = int_to_glue_acc_obj_map_.find(acc_obj_id);
-
- if (it == int_to_glue_acc_obj_map_.end()) {
- // Element not found.
- return false;
- }
-
- if (it->second) {
- // Erase element from reverse hashmap.
- AccObjToIntMap::iterator it2 =
- acc_obj_to_int_map_.find(it->second->accessibilityObject());
-
- if (it2 != acc_obj_to_int_map_.end())
- acc_obj_to_int_map_.erase(it2);
- }
- int_to_glue_acc_obj_map_.erase(it);
-
- if (acc_obj_id == 1000) {
- // Invalidate root.
- root_->acc_obj_root_ = 0;
- }
- return true;
-}
-
-int WebAccessibilityManagerImpl::FocusAccObj(
- const WebAccessibilityObject& object) {
- if (object.isNull()) {
- // Return with failure.
- return -1;
- }
-
- RefPtr<WebCore::AccessibilityObject> acc_obj =
- WebAccessibilityObjectToAccessibilityObject(object);
-
- AccObjToIntMap::iterator it = acc_obj_to_int_map_.find(acc_obj.get());
-
- if (it != acc_obj_to_int_map_.end())
- return it->second;
-
- // Insert new accessibility object in hashmaps and return its newly
- // assigned accessibility object id.
- int_to_glue_acc_obj_map_[acc_obj_id_] =
- GlueAccessibilityObject::CreateInstance(acc_obj.get());
- acc_obj_to_int_map_[acc_obj.get()] = acc_obj_id_;
-
- return acc_obj_id_++;
-}
-
-} // namespace webkit_glue
diff --git a/webkit/glue/webaccessibilitymanager_impl.h b/webkit/glue/webaccessibilitymanager_impl.h
deleted file mode 100644
index c95ec5f..0000000
--- a/webkit/glue/webaccessibilitymanager_impl.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2006-2008 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.
-
-#ifndef WEBKIT_GLUE_WEBACCESSIBILITYMANAGER_IMPL_H_
-#define WEBKIT_GLUE_WEBACCESSIBILITYMANAGER_IMPL_H_
-
-#include "base/hash_tables.h"
-#include "webkit/glue/webaccessibilitymanager.h"
-
-class GlueAccessibilityObject;
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// WebAccessibilityManagerImpl
-//
-//
-// Implements WebAccessibilityManager.
-// Responds to incoming accessibility requests from the browser side. Retrieves
-// the requested information from the active AccessibilityObject, through the
-// GlueAccessibilityObject.
-////////////////////////////////////////////////////////////////////////////////
-
-namespace webkit_glue {
-
-class WebAccessibilityManagerImpl : public WebAccessibilityManager {
- public:
- // From WebAccessibilityManager.
- bool GetAccObjInfo(WebKit::WebView* view,
- const WebAccessibility::InParams& in_params,
- WebAccessibility::OutParams* out_params);
- bool ClearAccObjMap(int acc_obj_id, bool clear_all);
- int FocusAccObj(const WebKit::WebAccessibilityObject& object);
-
- protected:
- // Needed so WebAccessibilityManager::Create can call our constructor.
- friend class WebAccessibilityManager;
-
- // Constructor creates a new GlueAccessibilityObjectRoot, and initializes
- // the root |acc_obj_id_| to 1000, to avoid conflicts with platform-specific
- // child ids.
- WebAccessibilityManagerImpl();
- ~WebAccessibilityManagerImpl();
-
- private:
- // From WebAccessibilityManager.
- bool InitAccObjRoot(WebKit::WebView* view);
-
- // Wrapper around the pointer that holds the root of the AccessibilityObject
- // tree, to allow the use of a scoped_refptr.
- struct GlueAccessibilityObjectRoot;
- GlueAccessibilityObjectRoot* root_;
-
- typedef base::hash_map<int, GlueAccessibilityObject*> IntToGlueAccObjMap;
- typedef base::hash_map<WebCore::AccessibilityObject*, int> AccObjToIntMap;
-
- // Hashmap for cashing of elements in use by the AT, mapping id (int) to a
- // GlueAccessibilityObject pointer.
- IntToGlueAccObjMap int_to_glue_acc_obj_map_;
- // Hashmap for cashing of elements in use by the AT, mapping a
- // AccessibilityObject pointer to its id (int). Needed for reverse lookup,
- // to ensure unnecessary duplicate entries are not created in the
- // IntToGlueAccObjMap (above) and for focus changes in WebKit.
- AccObjToIntMap acc_obj_to_int_map_;
-
- // Unique identifier for retrieving an accessibility object from the page's
- // hashmaps. Id is always 0 for the root of the accessibility object
- // hierarchy (on a per-renderer process basis).
- int acc_obj_id_;
-
- DISALLOW_COPY_AND_ASSIGN(WebAccessibilityManagerImpl);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_GLUE_WEBACCESSIBILITYMANAGER_IMPL_H_
diff --git a/webkit/tools/test_shell/accessibility_controller.cc b/webkit/tools/test_shell/accessibility_controller.cc
index 41d4d3c..5583062 100644
--- a/webkit/tools/test_shell/accessibility_controller.cc
+++ b/webkit/tools/test_shell/accessibility_controller.cc
@@ -7,13 +7,13 @@
#include "webkit/tools/test_shell/accessibility_controller.h"
#include "base/logging.h"
-#include "webkit/api/public/WebAccessibilityController.h"
+#include "webkit/api/public/WebAccessibilityCache.h"
#include "webkit/api/public/WebAccessibilityObject.h"
#include "webkit/api/public/WebFrame.h"
#include "webkit/api/public/WebView.h"
#include "webkit/tools/test_shell/test_shell.h"
-using WebKit::WebAccessibilityController;
+using WebKit::WebAccessibilityCache;
using WebKit::WebAccessibilityObject;
using WebKit::WebFrame;
@@ -35,7 +35,7 @@ AccessibilityController::AccessibilityController(TestShell* shell)
void AccessibilityController::BindToJavascript(
WebFrame* frame, const std::wstring& classname) {
- WebAccessibilityController::enableAccessibility();
+ WebAccessibilityCache::enableAccessibility();
CppBoundClass::BindToJavascript(frame, classname);
}
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index 7304306..1fa755b 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -307,8 +307,6 @@
'glue/form_field_values.h',
'glue/ftp_directory_listing_response_delegate.cc',
'glue/ftp_directory_listing_response_delegate.h',
- 'glue/glue_accessibility_object.cc',
- 'glue/glue_accessibility_object.h',
'glue/glue_serialize.cc',
'glue/glue_serialize.h',
'glue/glue_util.cc',
@@ -334,10 +332,8 @@
'glue/scoped_clipboard_writer_glue.h',
'glue/simple_webmimeregistry_impl.cc',
'glue/simple_webmimeregistry_impl.h',
+ 'glue/webaccessibility.cc',
'glue/webaccessibility.h',
- 'glue/webaccessibilitymanager.h',
- 'glue/webaccessibilitymanager_impl.cc',
- 'glue/webaccessibilitymanager_impl.h',
'glue/webclipboard_impl.cc',
'glue/webclipboard_impl.h',
'glue/webcookie.h',
@@ -430,13 +426,8 @@
'sources!': [
# These files are Windows-only now but may be ported to other
# platforms.
- 'glue/glue_accessibility_object.cc',
- 'glue/glue_accessibility_object.h',
+ 'glue/webaccessibility.cc',
'glue/webaccessibility.h',
- 'glue/webaccessibilitymanager.h',
- 'glue/webaccessibilitymanager_impl.cc',
- 'glue/webaccessibilitymanager_impl.cc',
- 'glue/webaccessibilitymanager_impl.h',
'glue/webthemeengine_impl_win.cc',
],
}, { # else: OS=="win"