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

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

Issue 1076453004: Show reasons why nodes are ignored in accessibility sidebar (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 8 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: Source/modules/accessibility/InspectorAccessibilityAgent.cpp
diff --git a/Source/modules/accessibility/InspectorAccessibilityAgent.cpp b/Source/modules/accessibility/InspectorAccessibilityAgent.cpp
index fe1664975ef649c729a11bc6d63cb6b452e2ebc6..26b4c3af679cb2f6f0f2f0dc37c734224c0dc6ec 100644
--- a/Source/modules/accessibility/InspectorAccessibilityAgent.cpp
+++ b/Source/modules/accessibility/InspectorAccessibilityAgent.cpp
@@ -6,19 +6,31 @@
#include "modules/accessibility/InspectorAccessibilityAgent.h"
+#include "core/HTMLNames.h"
#include "core/dom/AXObjectCache.h"
#include "core/dom/DOMNodeIds.h"
#include "core/dom/Element.h"
+#include "core/dom/ElementTraversal.h"
+#include "core/html/HTMLDialogElement.h"
+#include "core/html/HTMLFrameOwnerElement.h"
+#include "core/html/HTMLLabelElement.h"
#include "core/inspector/InspectorDOMAgent.h"
#include "core/inspector/InspectorState.h"
#include "core/inspector/InspectorStyleSheet.h"
+#include "core/layout/LayoutBlockFlow.h"
+#include "core/layout/LayoutBoxModelObject.h"
#include "core/page/Page.h"
#include "modules/accessibility/AXObject.h"
#include "modules/accessibility/AXObjectCacheImpl.h"
+#include "modules/accessibility/InspectorTypeBuilderHelper.h"
#include "platform/JSONValues.h"
namespace blink {
+using HTMLNames::altAttr;
+using HTMLNames::aria_describedbyAttr;
+using HTMLNames::aria_helpAttr;
+using HTMLNames::titleAttr;
using TypeBuilder::Accessibility::AXGlobalStates;
using TypeBuilder::Accessibility::AXLiveRegionAttributes;
using TypeBuilder::Accessibility::AXNode;
@@ -33,107 +45,6 @@ using TypeBuilder::Accessibility::AXWidgetStates;
namespace {
-PassRefPtr<AXProperty> createProperty(String name, PassRefPtr<AXValue> value)
-{
- RefPtr<AXProperty> property = AXProperty::create().setName(name).setValue(value);
- return property;
-}
-
-PassRefPtr<AXProperty> createProperty(AXGlobalStates::Enum name, PassRefPtr<AXValue> value)
-{
- return createProperty(TypeBuilder::getEnumConstantValue(name), value);
-}
-
-PassRefPtr<AXProperty> createProperty(AXLiveRegionAttributes::Enum name, PassRefPtr<AXValue> value)
-{
- return createProperty(TypeBuilder::getEnumConstantValue(name), value);
-}
-
-
-PassRefPtr<AXProperty> createProperty(AXRelationshipAttributes::Enum name, PassRefPtr<AXValue> value)
-{
- return createProperty(TypeBuilder::getEnumConstantValue(name), value);
-}
-
-PassRefPtr<AXProperty> createProperty(AXWidgetAttributes::Enum name, PassRefPtr<AXValue> value)
-{
- return createProperty(TypeBuilder::getEnumConstantValue(name), value);
-}
-
-PassRefPtr<AXProperty> createProperty(AXWidgetStates::Enum name, PassRefPtr<AXValue> value)
-{
- return createProperty(TypeBuilder::getEnumConstantValue(name), value);
-}
-
-
-PassRefPtr<AXValue> createValue(String value, AXValueType::Enum type = AXValueType::String)
-{
- RefPtr<AXValue> axValue = AXValue::create().setType(type);
- axValue->setValue(JSONString::create(value));
- return axValue;
-}
-
-PassRefPtr<AXValue> createValue(int value, AXValueType::Enum type = AXValueType::Integer)
-{
- RefPtr<AXValue> axValue = AXValue::create().setType(type);
- axValue->setValue(JSONBasicValue::create(value));
- return axValue;
-}
-
-PassRefPtr<AXValue> createValue(float value, AXValueType::Enum type = AXValueType::Number)
-{
- RefPtr<AXValue> axValue = AXValue::create().setType(type);
- axValue->setValue(JSONBasicValue::create(value));
- return axValue;
-}
-
-PassRefPtr<AXValue> createBooleanValue(bool value, AXValueType::Enum type = AXValueType::Boolean)
-{
- RefPtr<AXValue> axValue = AXValue::create().setType(type);
- axValue->setValue(JSONBasicValue::create(value));
- return axValue;
-}
-
-PassRefPtr<AXRelatedNode> relatedNodeForAXObject(const AXObject* axObject)
-{
- Node* node = axObject->node();
- if (!node)
- return PassRefPtr<AXRelatedNode>();
- int backendNodeId = DOMNodeIds::idForNode(node);
- if (!backendNodeId)
- return PassRefPtr<AXRelatedNode>();
- RefPtr<AXRelatedNode> relatedNode = AXRelatedNode::create().setBackendNodeId(backendNodeId);
- if (!node->isElementNode())
- return relatedNode;
-
- Element* element = toElement(node);
- const AtomicString& idref = element->getIdAttribute();
- if (!idref.isEmpty())
- relatedNode->setIdref(idref);
- return relatedNode;
-}
-
-
-PassRefPtr<AXValue> createRelatedNodeValue(const AXObject* axObject)
-{
- RefPtr<AXValue> axValue = AXValue::create().setType(AXValueType::Idref);
- RefPtr<AXRelatedNode> relatedNode = relatedNodeForAXObject(axObject);
- axValue->setRelatedNodeValue(relatedNode);
- return axValue;
-}
-
-PassRefPtr<AXValue> createRelatedNodeListValue(AXObject::AccessibilityChildrenVector axObjects)
-{
- RefPtr<TypeBuilder::Array<AXRelatedNode>> relatedNodes = TypeBuilder::Array<AXRelatedNode>::create();
- for (unsigned i = 0; i < axObjects.size(); i++) {
- if (RefPtr<AXRelatedNode> relatedNode = relatedNodeForAXObject(axObjects[i].get()))
- relatedNodes->addItem(relatedNode);
- }
- RefPtr<AXValue> axValue = AXValue::create().setType(AXValueType::IdrefList);
- axValue->setRelatedNodeArrayValue(relatedNodes);
- return axValue;
-}
-
void fillCoreProperties(AXObject* axObject, PassRefPtr<AXNode> nodeObject)
{
// core properties
@@ -381,9 +292,8 @@ void fillRelationships(AXObject* axObject, PassRefPtr<TypeBuilder::Array<AXPrope
results.clear();
}
-PassRefPtr<AXNode> buildObjectForNode(Node* node, AXObject* axObject, AXObjectCacheImpl* cacheImpl, PassRefPtr<TypeBuilder::Array<AXProperty>> properties)
+PassRefPtr<AXValue> createRoleNameValue(AccessibilityRole role)
{
- AccessibilityRole role = axObject->roleValue();
AtomicString roleName = AXObject::roleName(role);
RefPtr<AXValue> roleNameValue;
if (!roleName.isNull()) {
@@ -391,7 +301,25 @@ PassRefPtr<AXNode> buildObjectForNode(Node* node, AXObject* axObject, AXObjectCa
} else {
roleNameValue = createValue(AXObject::internalRoleName(role), AXValueType::InternalRole);
}
- RefPtr<AXNode> nodeObject = AXNode::create().setNodeId(String::number(axObject->axObjectID())).setRole(roleNameValue).setProperties(properties);
+ return roleNameValue;
+}
+
+PassRefPtr<AXNode> buildObjectForIgnoredNode(Node* node, AXObject* axObject, AXObjectCacheImpl* cacheImpl)
+{
+ RefPtr<TypeBuilder::Array<AXProperty>> ignoredReasons = TypeBuilder::Array<AXProperty>::create();
+ axObject->computeAccessibilityIsIgnored(ignoredReasons);
+
+ RefPtr<AXNode> ignoredNodeObject = AXNode::create().setNodeId(String::number(axObject->axObjectID())).setIgnored(true);
+ ignoredNodeObject->setIgnoredReasons(ignoredReasons);
+ return ignoredNodeObject;
+}
+
+PassRefPtr<AXNode> buildObjectForNode(Node* node, AXObject* axObject, AXObjectCacheImpl* cacheImpl, PassRefPtr<TypeBuilder::Array<AXProperty>> properties)
+{
+ AccessibilityRole role = axObject->roleValue();
+ RefPtr<AXNode> nodeObject = AXNode::create().setNodeId(String::number(axObject->axObjectID())).setIgnored(false);
+ nodeObject->setRole(createRoleNameValue(role));
+ nodeObject->setProperties(properties);
String computedName = cacheImpl->computedNameForNode(node);
if (!computedName.isEmpty())
nodeObject->setName(createValue(computedName));
@@ -431,6 +359,11 @@ void InspectorAccessibilityAgent::getAXNode(ErrorString* errorString, int nodeId
if (!axObject)
return;
+ if (axObject->accessibilityIsIgnored()) {
+ accessibilityNode = buildObjectForIgnoredNode(node, axObject, cacheImpl);
+ return;
+ }
+
RefPtr<TypeBuilder::Array<AXProperty>> properties = TypeBuilder::Array<AXProperty>::create();
fillLiveRegionProperties(axObject, properties);
fillGlobalStates(axObject, properties);

Powered by Google App Engine
This is Rietveld 408576698