Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: third_party/WebKit/Source/modules/accessibility/ElementAccessibleNode.cpp

Issue 2750533006: Initial skeleton of Accessibility Object Model Phase 1 (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/accessibility/ElementAccessibleNode.cpp
diff --git a/third_party/WebKit/Source/modules/accessibility/ElementAccessibleNode.cpp b/third_party/WebKit/Source/modules/accessibility/ElementAccessibleNode.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fdd2f455a0e0a04b723903040a7a56ea68ac880a
--- /dev/null
+++ b/third_party/WebKit/Source/modules/accessibility/ElementAccessibleNode.cpp
@@ -0,0 +1,40 @@
+// Copyright 2017 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 "modules/accessibility/ElementAccessibleNode.h"
+
+#include "core/dom/Document.h"
+#include "core/frame/Settings.h"
+#include "modules/accessibility/AXObject.h"
+#include "modules/accessibility/AXObjectCacheImpl.h"
+#include "modules/accessibility/AccessibleNode.h"
+#include "platform/RuntimeEnabledFeatures.h"
+
+namespace blink {
+
+AccessibleNode* ElementAccessibleNode::accessibleNode(Element& node) {
+ if (!RuntimeEnabledFeatures::accessibilityObjectModelEnabled())
+ return nullptr;
+
+ Settings* settings = node.document().settings();
+ if (settings && !settings->getAccessibilityEnabled())
aboxhall 2017/03/16 05:49:34 Wait, why do we need to do this? Can we decouple c
dmazzoni 2017/03/16 20:43:16 Hmmm, good point. Right now the AXObject for the
+ settings->setAccessibilityEnabled(true);
+
+ // Creates an AXObjectCache if needed.
+ AXObjectCacheImpl* cache =
+ static_cast<AXObjectCacheImpl*>(node.document().axObjectCache());
+ if (!cache)
+ return nullptr;
+
+ DCHECK(cache);
+ AXObject* obj = cache->getOrCreate(&node);
+ if (!obj)
+ return nullptr;
+
+ if (!obj->getAccessibleNode())
+ obj->setAccessibleNode(new AccessibleNode(obj));
+ return obj->getAccessibleNode();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698