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

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

Issue 2322413003: Show ancestor hierarchy in accessibility panel (Closed)
Patch Set: Add new test for ancestors Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp
diff --git a/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp b/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp
index c1762d60d37ab82fa0aad7b88924a6452b53e707..0fd6451ccd12e5bc8d57ce992e545a28275817f7 100644
--- a/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp
+++ b/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp
@@ -8,6 +8,7 @@
#include "core/dom/AXObjectCache.h"
#include "core/dom/DOMNodeIds.h"
#include "core/dom/Element.h"
+#include "core/inspector/IdentifiersFactory.h"
#include "core/inspector/InspectorDOMAgent.h"
#include "core/inspector/InspectorStyleSheet.h"
#include "core/page/Page.h"
@@ -300,7 +301,7 @@ std::unique_ptr<AXValue> createRoleNameValue(AccessibilityRole role)
return roleNameValue;
}
-std::unique_ptr<AXNode> buildObjectForIgnoredNode(Node* node, AXObject* axObject, AXObjectCacheImpl* cacheImpl)
+std::unique_ptr<AXNode> buildObjectForIgnoredNode(Node* node, const AXObject* axObject)
{
AXObject::IgnoredReasons ignoredReasons;
@@ -311,7 +312,7 @@ std::unique_ptr<AXNode> buildObjectForIgnoredNode(Node* node, AXObject* axObject
axID = axObject->axObjectID();
AccessibilityRole role = axObject->roleValue();
ignoredNodeObject->setRole(createRoleNameValue(role));
- } else if (!node->layoutObject()) {
+ } else if (node && !node->layoutObject()) {
ignoredReasons.append(IgnoredReason(AXNotRendered));
}
@@ -323,12 +324,19 @@ std::unique_ptr<AXNode> buildObjectForIgnoredNode(Node* node, AXObject* axObject
return ignoredNodeObject;
}
-std::unique_ptr<AXNode> buildObjectForNode(Node* node, AXObject* axObject, AXObjectCacheImpl* cacheImpl, std::unique_ptr<protocol::Array<AXProperty>> properties)
+std::unique_ptr<AXNode> buildProtocolAXObject(AXObject* axObject)
{
AccessibilityRole role = axObject->roleValue();
std::unique_ptr<AXNode> nodeObject = AXNode::create().setNodeId(String::number(axObject->axObjectID())).setIgnored(false).build();
nodeObject->setRole(createRoleNameValue(role));
+ std::unique_ptr<protocol::Array<AXProperty>> properties = protocol::Array<AXProperty>::create();
+ fillLiveRegionProperties(axObject, properties.get());
+ fillGlobalStates(axObject, properties.get());
+ fillWidgetProperties(axObject, properties.get());
+ fillWidgetStates(axObject, properties.get());
+ fillRelationships(axObject, properties.get());
+
AXObject::NameSources nameSources;
String computedName = axObject->name(&nameSources);
if (!nameSources.isEmpty()) {
@@ -364,41 +372,41 @@ InspectorAccessibilityAgent::InspectorAccessibilityAgent(Page* page, InspectorDO
{
}
-void InspectorAccessibilityAgent::getAXNode(ErrorString* errorString, int nodeId, Maybe<AXNode>* accessibilityNode)
+void InspectorAccessibilityAgent::getAXNodeChain(ErrorString* errorString, int domNodeId, bool fetchAncestors, std::unique_ptr<protocol::Array<protocol::Accessibility::AXNode>>* nodes)
{
- Frame* mainFrame = m_page->mainFrame();
- if (!mainFrame->isLocalFrame()) {
- *errorString = "Can't inspect out of process frames yet";
- return;
- }
-
if (!m_domAgent->enabled()) {
*errorString = "DOM agent must be enabled";
return;
}
- Node* node = m_domAgent->assertNode(errorString, nodeId);
+ Node* node = m_domAgent->assertNode(errorString, domNodeId);
if (!node)
return;
Document& document = node->document();
document.updateStyleAndLayoutIgnorePendingStylesheets();
DocumentLifecycle::DisallowTransitionScope disallowTransition(document.lifecycle());
- std::unique_ptr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document);
- AXObjectCacheImpl* cacheImpl = toAXObjectCacheImpl(cache->get());
- AXObject* axObject = cacheImpl->getOrCreate(node);
- if (!axObject || axObject->accessibilityIsIgnored()) {
- *accessibilityNode = buildObjectForIgnoredNode(node, axObject, cacheImpl);
+ LocalFrame* localFrame = document.frame();
+ if (!localFrame) {
+ *errorString = "Frame is detached.";
return;
}
+ std::unique_ptr<ScopedAXObjectCache> scopedCache = ScopedAXObjectCache::create(document);
+ AXObjectCacheImpl* cache = toAXObjectCacheImpl(scopedCache->get());
+ AXObject* axObject = cache->getOrCreate(node);
+ *nodes = protocol::Array<protocol::Accessibility::AXNode>::create();
+ if (!axObject || axObject->accessibilityIsIgnored()) {
+ (*nodes)->addItem(buildObjectForIgnoredNode(node, axObject));
+ } else {
+ (*nodes)->addItem(buildProtocolAXObject(axObject));
+ }
- std::unique_ptr<protocol::Array<AXProperty>> properties = protocol::Array<AXProperty>::create();
- fillLiveRegionProperties(axObject, properties.get());
- fillGlobalStates(axObject, properties.get());
- fillWidgetProperties(axObject, properties.get());
- fillWidgetStates(axObject, properties.get());
- fillRelationships(axObject, properties.get());
-
- *accessibilityNode = buildObjectForNode(node, axObject, cacheImpl, std::move(properties));
+ if (fetchAncestors && axObject) {
+ AXObject* parent = axObject->parentObjectUnignored();
+ while (parent) {
+ (*nodes)->addItem(buildProtocolAXObject(parent));
+ parent = parent->parentObjectUnignored();
+ }
+ }
}
DEFINE_TRACE(InspectorAccessibilityAgent)
« no previous file with comments | « third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698