| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/accessibility/InspectorAccessibilityAgent.h" | 5 #include "modules/accessibility/InspectorAccessibilityAgent.h" |
| 6 | 6 |
| 7 #include <memory> |
| 7 #include "core/HTMLNames.h" | 8 #include "core/HTMLNames.h" |
| 8 #include "core/dom/AXObjectCache.h" | 9 #include "core/dom/AXObjectCache.h" |
| 9 #include "core/dom/DOMNodeIds.h" | 10 #include "core/dom/DOMNodeIds.h" |
| 10 #include "core/dom/Element.h" | 11 #include "core/dom/Element.h" |
| 11 #include "core/dom/Node.h" | 12 #include "core/dom/Node.h" |
| 12 #include "core/dom/NodeList.h" | 13 #include "core/dom/NodeList.h" |
| 13 #include "core/dom/shadow/ElementShadow.h" | 14 #include "core/dom/shadow/ElementShadow.h" |
| 14 #include "core/inspector/IdentifiersFactory.h" | 15 #include "core/inspector/IdentifiersFactory.h" |
| 15 #include "core/inspector/InspectorDOMAgent.h" | 16 #include "core/inspector/InspectorDOMAgent.h" |
| 16 #include "core/inspector/InspectorStyleSheet.h" | 17 #include "core/inspector/InspectorStyleSheet.h" |
| 17 #include "core/page/Page.h" | 18 #include "core/page/Page.h" |
| 18 #include "modules/accessibility/AXObject.h" | |
| 19 #include "modules/accessibility/AXObjectCacheImpl.h" | 19 #include "modules/accessibility/AXObjectCacheImpl.h" |
| 20 #include "modules/accessibility/AXObjectImpl.h" |
| 20 #include "modules/accessibility/InspectorTypeBuilderHelper.h" | 21 #include "modules/accessibility/InspectorTypeBuilderHelper.h" |
| 21 #include <memory> | |
| 22 | 22 |
| 23 namespace blink { | 23 namespace blink { |
| 24 | 24 |
| 25 using protocol::Accessibility::AXGlobalStates; | 25 using protocol::Accessibility::AXGlobalStates; |
| 26 using protocol::Accessibility::AXLiveRegionAttributes; | 26 using protocol::Accessibility::AXLiveRegionAttributes; |
| 27 using protocol::Accessibility::AXNode; | 27 using protocol::Accessibility::AXNode; |
| 28 using protocol::Accessibility::AXNodeId; | 28 using protocol::Accessibility::AXNodeId; |
| 29 using protocol::Accessibility::AXProperty; | 29 using protocol::Accessibility::AXProperty; |
| 30 using protocol::Accessibility::AXValueSource; | 30 using protocol::Accessibility::AXValueSource; |
| 31 using protocol::Accessibility::AXValueType; | 31 using protocol::Accessibility::AXValueType; |
| 32 using protocol::Accessibility::AXRelatedNode; | 32 using protocol::Accessibility::AXRelatedNode; |
| 33 using protocol::Accessibility::AXRelationshipAttributes; | 33 using protocol::Accessibility::AXRelationshipAttributes; |
| 34 using protocol::Accessibility::AXValue; | 34 using protocol::Accessibility::AXValue; |
| 35 using protocol::Accessibility::AXWidgetAttributes; | 35 using protocol::Accessibility::AXWidgetAttributes; |
| 36 using protocol::Accessibility::AXWidgetStates; | 36 using protocol::Accessibility::AXWidgetStates; |
| 37 using protocol::Maybe; | 37 using protocol::Maybe; |
| 38 using protocol::Response; | 38 using protocol::Response; |
| 39 | 39 |
| 40 using namespace HTMLNames; | 40 using namespace HTMLNames; |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 static const AXID kIDForInspectedNodeWithNoAXNode = 0; | 44 static const AXID kIDForInspectedNodeWithNoAXNode = 0; |
| 45 | 45 |
| 46 void FillLiveRegionProperties(AXObject& ax_object, | 46 void FillLiveRegionProperties(AXObjectImpl& ax_object, |
| 47 protocol::Array<AXProperty>& properties) { | 47 protocol::Array<AXProperty>& properties) { |
| 48 if (!ax_object.LiveRegionRoot()) | 48 if (!ax_object.LiveRegionRoot()) |
| 49 return; | 49 return; |
| 50 | 50 |
| 51 properties.addItem( | 51 properties.addItem( |
| 52 CreateProperty(AXLiveRegionAttributesEnum::Live, | 52 CreateProperty(AXLiveRegionAttributesEnum::Live, |
| 53 CreateValue(ax_object.ContainerLiveRegionStatus(), | 53 CreateValue(ax_object.ContainerLiveRegionStatus(), |
| 54 AXValueTypeEnum::Token))); | 54 AXValueTypeEnum::Token))); |
| 55 properties.addItem(CreateProperty( | 55 properties.addItem(CreateProperty( |
| 56 AXLiveRegionAttributesEnum::Atomic, | 56 AXLiveRegionAttributesEnum::Atomic, |
| 57 CreateBooleanValue(ax_object.ContainerLiveRegionAtomic()))); | 57 CreateBooleanValue(ax_object.ContainerLiveRegionAtomic()))); |
| 58 properties.addItem( | 58 properties.addItem( |
| 59 CreateProperty(AXLiveRegionAttributesEnum::Relevant, | 59 CreateProperty(AXLiveRegionAttributesEnum::Relevant, |
| 60 CreateValue(ax_object.ContainerLiveRegionRelevant(), | 60 CreateValue(ax_object.ContainerLiveRegionRelevant(), |
| 61 AXValueTypeEnum::TokenList))); | 61 AXValueTypeEnum::TokenList))); |
| 62 properties.addItem( | 62 properties.addItem( |
| 63 CreateProperty(AXLiveRegionAttributesEnum::Busy, | 63 CreateProperty(AXLiveRegionAttributesEnum::Busy, |
| 64 CreateBooleanValue(ax_object.ContainerLiveRegionBusy()))); | 64 CreateBooleanValue(ax_object.ContainerLiveRegionBusy()))); |
| 65 | 65 |
| 66 if (!ax_object.IsLiveRegion()) { | 66 if (!ax_object.IsLiveRegion()) { |
| 67 properties.addItem(CreateProperty( | 67 properties.addItem(CreateProperty( |
| 68 AXLiveRegionAttributesEnum::Root, | 68 AXLiveRegionAttributesEnum::Root, |
| 69 CreateRelatedNodeListValue(*(ax_object.LiveRegionRoot())))); | 69 CreateRelatedNodeListValue(*(ax_object.LiveRegionRoot())))); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 void FillGlobalStates(AXObject& ax_object, | 73 void FillGlobalStates(AXObjectImpl& ax_object, |
| 74 protocol::Array<AXProperty>& properties) { | 74 protocol::Array<AXProperty>& properties) { |
| 75 if (!ax_object.IsEnabled()) | 75 if (!ax_object.IsEnabled()) |
| 76 properties.addItem( | 76 properties.addItem( |
| 77 CreateProperty(AXGlobalStatesEnum::Disabled, CreateBooleanValue(true))); | 77 CreateProperty(AXGlobalStatesEnum::Disabled, CreateBooleanValue(true))); |
| 78 | 78 |
| 79 if (const AXObject* hidden_root = ax_object.AriaHiddenRoot()) { | 79 if (const AXObjectImpl* hidden_root = ax_object.AriaHiddenRoot()) { |
| 80 properties.addItem( | 80 properties.addItem( |
| 81 CreateProperty(AXGlobalStatesEnum::Hidden, CreateBooleanValue(true))); | 81 CreateProperty(AXGlobalStatesEnum::Hidden, CreateBooleanValue(true))); |
| 82 properties.addItem( | 82 properties.addItem( |
| 83 CreateProperty(AXGlobalStatesEnum::HiddenRoot, | 83 CreateProperty(AXGlobalStatesEnum::HiddenRoot, |
| 84 CreateRelatedNodeListValue(*hidden_root))); | 84 CreateRelatedNodeListValue(*hidden_root))); |
| 85 } | 85 } |
| 86 | 86 |
| 87 InvalidState invalid_state = ax_object.GetInvalidState(); | 87 InvalidState invalid_state = ax_object.GetInvalidState(); |
| 88 switch (invalid_state) { | 88 switch (invalid_state) { |
| 89 case kInvalidStateUndefined: | 89 case kInvalidStateUndefined: |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 role == kSwitchRole; | 156 role == kSwitchRole; |
| 157 } | 157 } |
| 158 | 158 |
| 159 bool RoleAllowsSelected(AccessibilityRole role) { | 159 bool RoleAllowsSelected(AccessibilityRole role) { |
| 160 return role == kCellRole || role == kListBoxOptionRole || role == kRowRole || | 160 return role == kCellRole || role == kListBoxOptionRole || role == kRowRole || |
| 161 role == kTabRole || role == kColumnHeaderRole || | 161 role == kTabRole || role == kColumnHeaderRole || |
| 162 role == kMenuItemRadioRole || role == kRadioButtonRole || | 162 role == kMenuItemRadioRole || role == kRadioButtonRole || |
| 163 role == kRowHeaderRole || role == kTreeItemRole; | 163 role == kRowHeaderRole || role == kTreeItemRole; |
| 164 } | 164 } |
| 165 | 165 |
| 166 void FillWidgetProperties(AXObject& ax_object, | 166 void FillWidgetProperties(AXObjectImpl& ax_object, |
| 167 protocol::Array<AXProperty>& properties) { | 167 protocol::Array<AXProperty>& properties) { |
| 168 AccessibilityRole role = ax_object.RoleValue(); | 168 AccessibilityRole role = ax_object.RoleValue(); |
| 169 String autocomplete = ax_object.AriaAutoComplete(); | 169 String autocomplete = ax_object.AriaAutoComplete(); |
| 170 if (!autocomplete.IsEmpty()) | 170 if (!autocomplete.IsEmpty()) |
| 171 properties.addItem( | 171 properties.addItem( |
| 172 CreateProperty(AXWidgetAttributesEnum::Autocomplete, | 172 CreateProperty(AXWidgetAttributesEnum::Autocomplete, |
| 173 CreateValue(autocomplete, AXValueTypeEnum::Token))); | 173 CreateValue(autocomplete, AXValueTypeEnum::Token))); |
| 174 | 174 |
| 175 if (ax_object.HasAttribute(HTMLNames::aria_haspopupAttr)) { | 175 if (ax_object.HasAttribute(HTMLNames::aria_haspopupAttr)) { |
| 176 bool has_popup = ax_object.AriaHasPopup(); | 176 bool has_popup = ax_object.AriaHasPopup(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 CreateValue(ax_object.MinValueForRange()))); | 242 CreateValue(ax_object.MinValueForRange()))); |
| 243 properties.addItem( | 243 properties.addItem( |
| 244 CreateProperty(AXWidgetAttributesEnum::Valuemax, | 244 CreateProperty(AXWidgetAttributesEnum::Valuemax, |
| 245 CreateValue(ax_object.MaxValueForRange()))); | 245 CreateValue(ax_object.MaxValueForRange()))); |
| 246 properties.addItem( | 246 properties.addItem( |
| 247 CreateProperty(AXWidgetAttributesEnum::Valuetext, | 247 CreateProperty(AXWidgetAttributesEnum::Valuetext, |
| 248 CreateValue(ax_object.ValueDescription()))); | 248 CreateValue(ax_object.ValueDescription()))); |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 void FillWidgetStates(AXObject& ax_object, | 252 void FillWidgetStates(AXObjectImpl& ax_object, |
| 253 protocol::Array<AXProperty>& properties) { | 253 protocol::Array<AXProperty>& properties) { |
| 254 AccessibilityRole role = ax_object.RoleValue(); | 254 AccessibilityRole role = ax_object.RoleValue(); |
| 255 if (RoleAllowsChecked(role)) { | 255 if (RoleAllowsChecked(role)) { |
| 256 AccessibilityButtonState checked = ax_object.CheckedState(); | 256 AccessibilityButtonState checked = ax_object.CheckedState(); |
| 257 switch (checked) { | 257 switch (checked) { |
| 258 case kButtonStateOff: | 258 case kButtonStateOff: |
| 259 properties.addItem( | 259 properties.addItem( |
| 260 CreateProperty(AXWidgetStatesEnum::Checked, | 260 CreateProperty(AXWidgetStatesEnum::Checked, |
| 261 CreateValue("false", AXValueTypeEnum::Tristate))); | 261 CreateValue("false", AXValueTypeEnum::Tristate))); |
| 262 break; | 262 break; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 std::unique_ptr<AXProperty> CreateRelatedNodeListProperty( | 323 std::unique_ptr<AXProperty> CreateRelatedNodeListProperty( |
| 324 const String& key, | 324 const String& key, |
| 325 AXRelatedObjectVector& nodes) { | 325 AXRelatedObjectVector& nodes) { |
| 326 std::unique_ptr<AXValue> node_list_value = | 326 std::unique_ptr<AXValue> node_list_value = |
| 327 CreateRelatedNodeListValue(nodes, AXValueTypeEnum::NodeList); | 327 CreateRelatedNodeListValue(nodes, AXValueTypeEnum::NodeList); |
| 328 return CreateProperty(key, std::move(node_list_value)); | 328 return CreateProperty(key, std::move(node_list_value)); |
| 329 } | 329 } |
| 330 | 330 |
| 331 std::unique_ptr<AXProperty> CreateRelatedNodeListProperty( | 331 std::unique_ptr<AXProperty> CreateRelatedNodeListProperty( |
| 332 const String& key, | 332 const String& key, |
| 333 AXObject::AXObjectVector& nodes, | 333 AXObjectImpl::AXObjectVector& nodes, |
| 334 const QualifiedName& attr, | 334 const QualifiedName& attr, |
| 335 AXObject& ax_object) { | 335 AXObjectImpl& ax_object) { |
| 336 std::unique_ptr<AXValue> node_list_value = CreateRelatedNodeListValue(nodes); | 336 std::unique_ptr<AXValue> node_list_value = CreateRelatedNodeListValue(nodes); |
| 337 const AtomicString& attr_value = ax_object.GetAttribute(attr); | 337 const AtomicString& attr_value = ax_object.GetAttribute(attr); |
| 338 node_list_value->setValue(protocol::StringValue::create(attr_value)); | 338 node_list_value->setValue(protocol::StringValue::create(attr_value)); |
| 339 return CreateProperty(key, std::move(node_list_value)); | 339 return CreateProperty(key, std::move(node_list_value)); |
| 340 } | 340 } |
| 341 | 341 |
| 342 class SparseAttributeAXPropertyAdapter | 342 class SparseAttributeAXPropertyAdapter |
| 343 : public GarbageCollected<SparseAttributeAXPropertyAdapter>, | 343 : public GarbageCollected<SparseAttributeAXPropertyAdapter>, |
| 344 public AXSparseAttributeClient { | 344 public AXSparseAttributeClient { |
| 345 public: | 345 public: |
| 346 SparseAttributeAXPropertyAdapter(AXObject& ax_object, | 346 SparseAttributeAXPropertyAdapter(AXObjectImpl& ax_object, |
| 347 protocol::Array<AXProperty>& properties) | 347 protocol::Array<AXProperty>& properties) |
| 348 : ax_object_(&ax_object), properties_(properties) {} | 348 : ax_object_(&ax_object), properties_(properties) {} |
| 349 | 349 |
| 350 DEFINE_INLINE_TRACE() { visitor->Trace(ax_object_); } | 350 DEFINE_INLINE_TRACE() { visitor->Trace(ax_object_); } |
| 351 | 351 |
| 352 private: | 352 private: |
| 353 Member<AXObject> ax_object_; | 353 Member<AXObjectImpl> ax_object_; |
| 354 protocol::Array<AXProperty>& properties_; | 354 protocol::Array<AXProperty>& properties_; |
| 355 | 355 |
| 356 void AddBoolAttribute(AXBoolAttribute attribute, bool value) { | 356 void AddBoolAttribute(AXBoolAttribute attribute, bool value) { |
| 357 // Implement this when we add the first sparse bool attribute. | 357 // Implement this when we add the first sparse bool attribute. |
| 358 } | 358 } |
| 359 | 359 |
| 360 void AddStringAttribute(AXStringAttribute attribute, const String& value) { | 360 void AddStringAttribute(AXStringAttribute attribute, const String& value) { |
| 361 switch (attribute) { | 361 switch (attribute) { |
| 362 case AXStringAttribute::kAriaKeyShortcuts: | 362 case AXStringAttribute::kAriaKeyShortcuts: |
| 363 properties_.addItem( | 363 properties_.addItem( |
| 364 CreateProperty(AXGlobalStatesEnum::Keyshortcuts, | 364 CreateProperty(AXGlobalStatesEnum::Keyshortcuts, |
| 365 CreateValue(value, AXValueTypeEnum::String))); | 365 CreateValue(value, AXValueTypeEnum::String))); |
| 366 break; | 366 break; |
| 367 case AXStringAttribute::kAriaRoleDescription: | 367 case AXStringAttribute::kAriaRoleDescription: |
| 368 properties_.addItem( | 368 properties_.addItem( |
| 369 CreateProperty(AXGlobalStatesEnum::Roledescription, | 369 CreateProperty(AXGlobalStatesEnum::Roledescription, |
| 370 CreateValue(value, AXValueTypeEnum::String))); | 370 CreateValue(value, AXValueTypeEnum::String))); |
| 371 break; | 371 break; |
| 372 } | 372 } |
| 373 } | 373 } |
| 374 | 374 |
| 375 void AddObjectAttribute(AXObjectAttribute attribute, AXObject& object) { | 375 void AddObjectAttribute(AXObjectAttribute attribute, AXObjectImpl& object) { |
| 376 switch (attribute) { | 376 switch (attribute) { |
| 377 case AXObjectAttribute::kAriaActiveDescendant: | 377 case AXObjectAttribute::kAriaActiveDescendant: |
| 378 properties_.addItem( | 378 properties_.addItem( |
| 379 CreateProperty(AXRelationshipAttributesEnum::Activedescendant, | 379 CreateProperty(AXRelationshipAttributesEnum::Activedescendant, |
| 380 CreateRelatedNodeListValue(object))); | 380 CreateRelatedNodeListValue(object))); |
| 381 break; | 381 break; |
| 382 case AXObjectAttribute::kAriaErrorMessage: | 382 case AXObjectAttribute::kAriaErrorMessage: |
| 383 properties_.addItem( | 383 properties_.addItem( |
| 384 CreateProperty(AXRelationshipAttributesEnum::Errormessage, | 384 CreateProperty(AXRelationshipAttributesEnum::Errormessage, |
| 385 CreateRelatedNodeListValue(object))); | 385 CreateRelatedNodeListValue(object))); |
| 386 break; | 386 break; |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| 390 void AddObjectVectorAttribute(AXObjectVectorAttribute attribute, | 390 void AddObjectVectorAttribute(AXObjectVectorAttribute attribute, |
| 391 HeapVector<Member<AXObject>>& objects) { | 391 HeapVector<Member<AXObjectImpl>>& objects) { |
| 392 switch (attribute) { | 392 switch (attribute) { |
| 393 case AXObjectVectorAttribute::kAriaControls: | 393 case AXObjectVectorAttribute::kAriaControls: |
| 394 properties_.addItem(CreateRelatedNodeListProperty( | 394 properties_.addItem(CreateRelatedNodeListProperty( |
| 395 AXRelationshipAttributesEnum::Controls, objects, aria_controlsAttr, | 395 AXRelationshipAttributesEnum::Controls, objects, aria_controlsAttr, |
| 396 *ax_object_)); | 396 *ax_object_)); |
| 397 break; | 397 break; |
| 398 case AXObjectVectorAttribute::kAriaDetails: | 398 case AXObjectVectorAttribute::kAriaDetails: |
| 399 properties_.addItem(CreateRelatedNodeListProperty( | 399 properties_.addItem(CreateRelatedNodeListProperty( |
| 400 AXRelationshipAttributesEnum::Details, objects, aria_controlsAttr, | 400 AXRelationshipAttributesEnum::Details, objects, aria_controlsAttr, |
| 401 *ax_object_)); | 401 *ax_object_)); |
| 402 break; | 402 break; |
| 403 case AXObjectVectorAttribute::kAriaFlowTo: | 403 case AXObjectVectorAttribute::kAriaFlowTo: |
| 404 properties_.addItem(CreateRelatedNodeListProperty( | 404 properties_.addItem(CreateRelatedNodeListProperty( |
| 405 AXRelationshipAttributesEnum::Flowto, objects, aria_flowtoAttr, | 405 AXRelationshipAttributesEnum::Flowto, objects, aria_flowtoAttr, |
| 406 *ax_object_)); | 406 *ax_object_)); |
| 407 break; | 407 break; |
| 408 } | 408 } |
| 409 } | 409 } |
| 410 }; | 410 }; |
| 411 | 411 |
| 412 void FillRelationships(AXObject& ax_object, | 412 void FillRelationships(AXObjectImpl& ax_object, |
| 413 protocol::Array<AXProperty>& properties) { | 413 protocol::Array<AXProperty>& properties) { |
| 414 AXObject::AXObjectVector results; | 414 AXObjectImpl::AXObjectVector results; |
| 415 ax_object.AriaDescribedbyElements(results); | 415 ax_object.AriaDescribedbyElements(results); |
| 416 if (!results.IsEmpty()) | 416 if (!results.IsEmpty()) |
| 417 properties.addItem(CreateRelatedNodeListProperty( | 417 properties.addItem(CreateRelatedNodeListProperty( |
| 418 AXRelationshipAttributesEnum::Describedby, results, | 418 AXRelationshipAttributesEnum::Describedby, results, |
| 419 aria_describedbyAttr, ax_object)); | 419 aria_describedbyAttr, ax_object)); |
| 420 results.clear(); | 420 results.clear(); |
| 421 | 421 |
| 422 ax_object.AriaOwnsElements(results); | 422 ax_object.AriaOwnsElements(results); |
| 423 if (!results.IsEmpty()) | 423 if (!results.IsEmpty()) |
| 424 properties.addItem(CreateRelatedNodeListProperty( | 424 properties.addItem(CreateRelatedNodeListProperty( |
| 425 AXRelationshipAttributesEnum::Owns, results, aria_ownsAttr, ax_object)); | 425 AXRelationshipAttributesEnum::Owns, results, aria_ownsAttr, ax_object)); |
| 426 results.clear(); | 426 results.clear(); |
| 427 } | 427 } |
| 428 | 428 |
| 429 std::unique_ptr<AXValue> CreateRoleNameValue(AccessibilityRole role) { | 429 std::unique_ptr<AXValue> CreateRoleNameValue(AccessibilityRole role) { |
| 430 AtomicString role_name = AXObject::RoleName(role); | 430 AtomicString role_name = AXObjectImpl::RoleName(role); |
| 431 std::unique_ptr<AXValue> role_name_value; | 431 std::unique_ptr<AXValue> role_name_value; |
| 432 if (!role_name.IsNull()) { | 432 if (!role_name.IsNull()) { |
| 433 role_name_value = CreateValue(role_name, AXValueTypeEnum::Role); | 433 role_name_value = CreateValue(role_name, AXValueTypeEnum::Role); |
| 434 } else { | 434 } else { |
| 435 role_name_value = CreateValue(AXObject::InternalRoleName(role), | 435 role_name_value = CreateValue(AXObjectImpl::InternalRoleName(role), |
| 436 AXValueTypeEnum::InternalRole); | 436 AXValueTypeEnum::InternalRole); |
| 437 } | 437 } |
| 438 return role_name_value; | 438 return role_name_value; |
| 439 } | 439 } |
| 440 | 440 |
| 441 } // namespace | 441 } // namespace |
| 442 | 442 |
| 443 InspectorAccessibilityAgent::InspectorAccessibilityAgent( | 443 InspectorAccessibilityAgent::InspectorAccessibilityAgent( |
| 444 Page* page, | 444 Page* page, |
| 445 InspectorDOMAgent* dom_agent) | 445 InspectorDOMAgent* dom_agent) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 460 document.UpdateStyleAndLayoutIgnorePendingStylesheets(); | 460 document.UpdateStyleAndLayoutIgnorePendingStylesheets(); |
| 461 DocumentLifecycle::DisallowTransitionScope disallow_transition( | 461 DocumentLifecycle::DisallowTransitionScope disallow_transition( |
| 462 document.Lifecycle()); | 462 document.Lifecycle()); |
| 463 LocalFrame* local_frame = document.GetFrame(); | 463 LocalFrame* local_frame = document.GetFrame(); |
| 464 if (!local_frame) | 464 if (!local_frame) |
| 465 return Response::Error("Frame is detached."); | 465 return Response::Error("Frame is detached."); |
| 466 std::unique_ptr<ScopedAXObjectCache> scoped_cache = | 466 std::unique_ptr<ScopedAXObjectCache> scoped_cache = |
| 467 ScopedAXObjectCache::Create(document); | 467 ScopedAXObjectCache::Create(document); |
| 468 AXObjectCacheImpl* cache = ToAXObjectCacheImpl(scoped_cache->Get()); | 468 AXObjectCacheImpl* cache = ToAXObjectCacheImpl(scoped_cache->Get()); |
| 469 | 469 |
| 470 AXObject* inspected_ax_object = cache->GetOrCreate(dom_node); | 470 AXObjectImpl* inspected_ax_object = cache->GetOrCreate(dom_node); |
| 471 *nodes = protocol::Array<protocol::Accessibility::AXNode>::create(); | 471 *nodes = protocol::Array<protocol::Accessibility::AXNode>::create(); |
| 472 if (!inspected_ax_object || inspected_ax_object->AccessibilityIsIgnored()) { | 472 if (!inspected_ax_object || inspected_ax_object->AccessibilityIsIgnored()) { |
| 473 (*nodes)->addItem(BuildObjectForIgnoredNode(dom_node, inspected_ax_object, | 473 (*nodes)->addItem(BuildObjectForIgnoredNode(dom_node, inspected_ax_object, |
| 474 fetch_relatives.fromMaybe(true), | 474 fetch_relatives.fromMaybe(true), |
| 475 *nodes, *cache)); | 475 *nodes, *cache)); |
| 476 return Response::OK(); | 476 return Response::OK(); |
| 477 } else { | 477 } else { |
| 478 (*nodes)->addItem( | 478 (*nodes)->addItem( |
| 479 BuildProtocolAXObject(*inspected_ax_object, inspected_ax_object, | 479 BuildProtocolAXObject(*inspected_ax_object, inspected_ax_object, |
| 480 fetch_relatives.fromMaybe(true), *nodes, *cache)); | 480 fetch_relatives.fromMaybe(true), *nodes, *cache)); |
| 481 } | 481 } |
| 482 | 482 |
| 483 if (!inspected_ax_object) | 483 if (!inspected_ax_object) |
| 484 return Response::OK(); | 484 return Response::OK(); |
| 485 | 485 |
| 486 AXObject* parent = inspected_ax_object->ParentObjectUnignored(); | 486 AXObjectImpl* parent = inspected_ax_object->ParentObjectUnignored(); |
| 487 if (!parent) | 487 if (!parent) |
| 488 return Response::OK(); | 488 return Response::OK(); |
| 489 | 489 |
| 490 if (fetch_relatives.fromMaybe(true)) | 490 if (fetch_relatives.fromMaybe(true)) |
| 491 AddAncestors(*parent, inspected_ax_object, *nodes, *cache); | 491 AddAncestors(*parent, inspected_ax_object, *nodes, *cache); |
| 492 | 492 |
| 493 return Response::OK(); | 493 return Response::OK(); |
| 494 } | 494 } |
| 495 | 495 |
| 496 void InspectorAccessibilityAgent::AddAncestors( | 496 void InspectorAccessibilityAgent::AddAncestors( |
| 497 AXObject& first_ancestor, | 497 AXObjectImpl& first_ancestor, |
| 498 AXObject* inspected_ax_object, | 498 AXObjectImpl* inspected_ax_object, |
| 499 std::unique_ptr<protocol::Array<AXNode>>& nodes, | 499 std::unique_ptr<protocol::Array<AXNode>>& nodes, |
| 500 AXObjectCacheImpl& cache) const { | 500 AXObjectCacheImpl& cache) const { |
| 501 AXObject* ancestor = &first_ancestor; | 501 AXObjectImpl* ancestor = &first_ancestor; |
| 502 while (ancestor) { | 502 while (ancestor) { |
| 503 nodes->addItem(BuildProtocolAXObject(*ancestor, inspected_ax_object, true, | 503 nodes->addItem(BuildProtocolAXObject(*ancestor, inspected_ax_object, true, |
| 504 nodes, cache)); | 504 nodes, cache)); |
| 505 ancestor = ancestor->ParentObjectUnignored(); | 505 ancestor = ancestor->ParentObjectUnignored(); |
| 506 } | 506 } |
| 507 } | 507 } |
| 508 | 508 |
| 509 std::unique_ptr<AXNode> InspectorAccessibilityAgent::BuildObjectForIgnoredNode( | 509 std::unique_ptr<AXNode> InspectorAccessibilityAgent::BuildObjectForIgnoredNode( |
| 510 Node* dom_node, | 510 Node* dom_node, |
| 511 AXObject* ax_object, | 511 AXObjectImpl* ax_object, |
| 512 bool fetch_relatives, | 512 bool fetch_relatives, |
| 513 std::unique_ptr<protocol::Array<AXNode>>& nodes, | 513 std::unique_ptr<protocol::Array<AXNode>>& nodes, |
| 514 AXObjectCacheImpl& cache) const { | 514 AXObjectCacheImpl& cache) const { |
| 515 AXObject::IgnoredReasons ignored_reasons; | 515 AXObjectImpl::IgnoredReasons ignored_reasons; |
| 516 AXID ax_id = kIDForInspectedNodeWithNoAXNode; | 516 AXID ax_id = kIDForInspectedNodeWithNoAXNode; |
| 517 if (ax_object && ax_object->IsAXLayoutObject()) | 517 if (ax_object && ax_object->IsAXLayoutObject()) |
| 518 ax_id = ax_object->AxObjectID(); | 518 ax_id = ax_object->AxObjectID(); |
| 519 std::unique_ptr<AXNode> ignored_node_object = | 519 std::unique_ptr<AXNode> ignored_node_object = |
| 520 AXNode::create() | 520 AXNode::create() |
| 521 .setNodeId(String::Number(ax_id)) | 521 .setNodeId(String::Number(ax_id)) |
| 522 .setIgnored(true) | 522 .setIgnored(true) |
| 523 .build(); | 523 .build(); |
| 524 AccessibilityRole role = AccessibilityRole::kIgnoredRole; | 524 AccessibilityRole role = AccessibilityRole::kIgnoredRole; |
| 525 ignored_node_object->setRole(CreateRoleNameValue(role)); | 525 ignored_node_object->setRole(CreateRoleNameValue(role)); |
| 526 | 526 |
| 527 if (ax_object && ax_object->IsAXLayoutObject()) { | 527 if (ax_object && ax_object->IsAXLayoutObject()) { |
| 528 ax_object->ComputeAccessibilityIsIgnored(&ignored_reasons); | 528 ax_object->ComputeAccessibilityIsIgnored(&ignored_reasons); |
| 529 | 529 |
| 530 AXObject* parent_object = ax_object->ParentObjectUnignored(); | 530 AXObjectImpl* parent_object = ax_object->ParentObjectUnignored(); |
| 531 if (parent_object && fetch_relatives) | 531 if (parent_object && fetch_relatives) |
| 532 AddAncestors(*parent_object, ax_object, nodes, cache); | 532 AddAncestors(*parent_object, ax_object, nodes, cache); |
| 533 } else if (dom_node && !dom_node->GetLayoutObject()) { | 533 } else if (dom_node && !dom_node->GetLayoutObject()) { |
| 534 if (fetch_relatives) { | 534 if (fetch_relatives) { |
| 535 PopulateDOMNodeAncestors(*dom_node, *(ignored_node_object.get()), nodes, | 535 PopulateDOMNodeAncestors(*dom_node, *(ignored_node_object.get()), nodes, |
| 536 cache); | 536 cache); |
| 537 } | 537 } |
| 538 ignored_reasons.push_back(IgnoredReason(kAXNotRendered)); | 538 ignored_reasons.push_back(IgnoredReason(kAXNotRendered)); |
| 539 } | 539 } |
| 540 | 540 |
| 541 if (dom_node) | 541 if (dom_node) |
| 542 ignored_node_object->setBackendDOMNodeId(DOMNodeIds::IdForNode(dom_node)); | 542 ignored_node_object->setBackendDOMNodeId(DOMNodeIds::IdForNode(dom_node)); |
| 543 | 543 |
| 544 std::unique_ptr<protocol::Array<AXProperty>> ignored_reason_properties = | 544 std::unique_ptr<protocol::Array<AXProperty>> ignored_reason_properties = |
| 545 protocol::Array<AXProperty>::create(); | 545 protocol::Array<AXProperty>::create(); |
| 546 for (size_t i = 0; i < ignored_reasons.size(); i++) | 546 for (size_t i = 0; i < ignored_reasons.size(); i++) |
| 547 ignored_reason_properties->addItem(CreateProperty(ignored_reasons[i])); | 547 ignored_reason_properties->addItem(CreateProperty(ignored_reasons[i])); |
| 548 ignored_node_object->setIgnoredReasons(std::move(ignored_reason_properties)); | 548 ignored_node_object->setIgnoredReasons(std::move(ignored_reason_properties)); |
| 549 | 549 |
| 550 return ignored_node_object; | 550 return ignored_node_object; |
| 551 } | 551 } |
| 552 | 552 |
| 553 void InspectorAccessibilityAgent::PopulateDOMNodeAncestors( | 553 void InspectorAccessibilityAgent::PopulateDOMNodeAncestors( |
| 554 Node& inspected_dom_node, | 554 Node& inspected_dom_node, |
| 555 AXNode& node_object, | 555 AXNode& node_object, |
| 556 std::unique_ptr<protocol::Array<AXNode>>& nodes, | 556 std::unique_ptr<protocol::Array<AXNode>>& nodes, |
| 557 AXObjectCacheImpl& cache) const { | 557 AXObjectCacheImpl& cache) const { |
| 558 // Walk up parents until an AXObject can be found. | 558 // Walk up parents until an AXObjectImpl can be found. |
| 559 Node* parent_node = inspected_dom_node.IsShadowRoot() | 559 Node* parent_node = inspected_dom_node.IsShadowRoot() |
| 560 ? &ToShadowRoot(inspected_dom_node).host() | 560 ? &ToShadowRoot(inspected_dom_node).host() |
| 561 : FlatTreeTraversal::Parent(inspected_dom_node); | 561 : FlatTreeTraversal::Parent(inspected_dom_node); |
| 562 AXObject* parent_ax_object = cache.GetOrCreate(parent_node); | 562 AXObjectImpl* parent_ax_object = cache.GetOrCreate(parent_node); |
| 563 while (parent_node && !parent_ax_object) { | 563 while (parent_node && !parent_ax_object) { |
| 564 parent_node = parent_node->IsShadowRoot() | 564 parent_node = parent_node->IsShadowRoot() |
| 565 ? &ToShadowRoot(parent_node)->host() | 565 ? &ToShadowRoot(parent_node)->host() |
| 566 : FlatTreeTraversal::Parent(*parent_node); | 566 : FlatTreeTraversal::Parent(*parent_node); |
| 567 parent_ax_object = cache.GetOrCreate(parent_node); | 567 parent_ax_object = cache.GetOrCreate(parent_node); |
| 568 } | 568 } |
| 569 | 569 |
| 570 if (!parent_ax_object) | 570 if (!parent_ax_object) |
| 571 return; | 571 return; |
| 572 | 572 |
| 573 if (parent_ax_object->AccessibilityIsIgnored()) | 573 if (parent_ax_object->AccessibilityIsIgnored()) |
| 574 parent_ax_object = parent_ax_object->ParentObjectUnignored(); | 574 parent_ax_object = parent_ax_object->ParentObjectUnignored(); |
| 575 if (!parent_ax_object) | 575 if (!parent_ax_object) |
| 576 return; | 576 return; |
| 577 | 577 |
| 578 // Populate parent and ancestors. | 578 // Populate parent and ancestors. |
| 579 std::unique_ptr<AXNode> parent_node_object = | 579 std::unique_ptr<AXNode> parent_node_object = |
| 580 BuildProtocolAXObject(*parent_ax_object, nullptr, true, nodes, cache); | 580 BuildProtocolAXObject(*parent_ax_object, nullptr, true, nodes, cache); |
| 581 std::unique_ptr<protocol::Array<AXNodeId>> child_ids = | 581 std::unique_ptr<protocol::Array<AXNodeId>> child_ids = |
| 582 protocol::Array<AXNodeId>::create(); | 582 protocol::Array<AXNodeId>::create(); |
| 583 child_ids->addItem(String::Number(kIDForInspectedNodeWithNoAXNode)); | 583 child_ids->addItem(String::Number(kIDForInspectedNodeWithNoAXNode)); |
| 584 parent_node_object->setChildIds(std::move(child_ids)); | 584 parent_node_object->setChildIds(std::move(child_ids)); |
| 585 nodes->addItem(std::move(parent_node_object)); | 585 nodes->addItem(std::move(parent_node_object)); |
| 586 | 586 |
| 587 AXObject* grandparent_ax_object = parent_ax_object->ParentObjectUnignored(); | 587 AXObjectImpl* grandparent_ax_object = |
| 588 parent_ax_object->ParentObjectUnignored(); |
| 588 if (grandparent_ax_object) | 589 if (grandparent_ax_object) |
| 589 AddAncestors(*grandparent_ax_object, nullptr, nodes, cache); | 590 AddAncestors(*grandparent_ax_object, nullptr, nodes, cache); |
| 590 } | 591 } |
| 591 | 592 |
| 592 std::unique_ptr<AXNode> InspectorAccessibilityAgent::BuildProtocolAXObject( | 593 std::unique_ptr<AXNode> InspectorAccessibilityAgent::BuildProtocolAXObject( |
| 593 AXObject& ax_object, | 594 AXObjectImpl& ax_object, |
| 594 AXObject* inspected_ax_object, | 595 AXObjectImpl* inspected_ax_object, |
| 595 bool fetch_relatives, | 596 bool fetch_relatives, |
| 596 std::unique_ptr<protocol::Array<AXNode>>& nodes, | 597 std::unique_ptr<protocol::Array<AXNode>>& nodes, |
| 597 AXObjectCacheImpl& cache) const { | 598 AXObjectCacheImpl& cache) const { |
| 598 AccessibilityRole role = ax_object.RoleValue(); | 599 AccessibilityRole role = ax_object.RoleValue(); |
| 599 std::unique_ptr<AXNode> node_object = | 600 std::unique_ptr<AXNode> node_object = |
| 600 AXNode::create() | 601 AXNode::create() |
| 601 .setNodeId(String::Number(ax_object.AxObjectID())) | 602 .setNodeId(String::Number(ax_object.AxObjectID())) |
| 602 .setIgnored(false) | 603 .setIgnored(false) |
| 603 .build(); | 604 .build(); |
| 604 node_object->setRole(CreateRoleNameValue(role)); | 605 node_object->setRole(CreateRoleNameValue(role)); |
| 605 | 606 |
| 606 std::unique_ptr<protocol::Array<AXProperty>> properties = | 607 std::unique_ptr<protocol::Array<AXProperty>> properties = |
| 607 protocol::Array<AXProperty>::create(); | 608 protocol::Array<AXProperty>::create(); |
| 608 FillLiveRegionProperties(ax_object, *(properties.get())); | 609 FillLiveRegionProperties(ax_object, *(properties.get())); |
| 609 FillGlobalStates(ax_object, *(properties.get())); | 610 FillGlobalStates(ax_object, *(properties.get())); |
| 610 FillWidgetProperties(ax_object, *(properties.get())); | 611 FillWidgetProperties(ax_object, *(properties.get())); |
| 611 FillWidgetStates(ax_object, *(properties.get())); | 612 FillWidgetStates(ax_object, *(properties.get())); |
| 612 FillRelationships(ax_object, *(properties.get())); | 613 FillRelationships(ax_object, *(properties.get())); |
| 613 | 614 |
| 614 SparseAttributeAXPropertyAdapter adapter(ax_object, *properties); | 615 SparseAttributeAXPropertyAdapter adapter(ax_object, *properties); |
| 615 ax_object.GetSparseAXAttributes(adapter); | 616 ax_object.GetSparseAXAttributes(adapter); |
| 616 | 617 |
| 617 AXObject::NameSources name_sources; | 618 AXObjectImpl::NameSources name_sources; |
| 618 String computed_name = ax_object.GetName(&name_sources); | 619 String computed_name = ax_object.GetName(&name_sources); |
| 619 if (!name_sources.IsEmpty()) { | 620 if (!name_sources.IsEmpty()) { |
| 620 std::unique_ptr<AXValue> name = | 621 std::unique_ptr<AXValue> name = |
| 621 CreateValue(computed_name, AXValueTypeEnum::ComputedString); | 622 CreateValue(computed_name, AXValueTypeEnum::ComputedString); |
| 622 if (!name_sources.IsEmpty()) { | 623 if (!name_sources.IsEmpty()) { |
| 623 std::unique_ptr<protocol::Array<AXValueSource>> name_source_properties = | 624 std::unique_ptr<protocol::Array<AXValueSource>> name_source_properties = |
| 624 protocol::Array<AXValueSource>::create(); | 625 protocol::Array<AXValueSource>::create(); |
| 625 for (size_t i = 0; i < name_sources.size(); ++i) { | 626 for (size_t i = 0; i < name_sources.size(); ++i) { |
| 626 NameSource& name_source = name_sources[i]; | 627 NameSource& name_source = name_sources[i]; |
| 627 name_source_properties->addItem(CreateValueSource(name_source)); | 628 name_source_properties->addItem(CreateValueSource(name_source)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 640 } else { | 641 } else { |
| 641 node_object->setProperties(std::move(properties)); | 642 node_object->setProperties(std::move(properties)); |
| 642 } | 643 } |
| 643 | 644 |
| 644 FillCoreProperties(ax_object, inspected_ax_object, fetch_relatives, | 645 FillCoreProperties(ax_object, inspected_ax_object, fetch_relatives, |
| 645 *(node_object.get()), nodes, cache); | 646 *(node_object.get()), nodes, cache); |
| 646 return node_object; | 647 return node_object; |
| 647 } | 648 } |
| 648 | 649 |
| 649 void InspectorAccessibilityAgent::FillCoreProperties( | 650 void InspectorAccessibilityAgent::FillCoreProperties( |
| 650 AXObject& ax_object, | 651 AXObjectImpl& ax_object, |
| 651 AXObject* inspected_ax_object, | 652 AXObjectImpl* inspected_ax_object, |
| 652 bool fetch_relatives, | 653 bool fetch_relatives, |
| 653 AXNode& node_object, | 654 AXNode& node_object, |
| 654 std::unique_ptr<protocol::Array<AXNode>>& nodes, | 655 std::unique_ptr<protocol::Array<AXNode>>& nodes, |
| 655 AXObjectCacheImpl& cache) const { | 656 AXObjectCacheImpl& cache) const { |
| 656 AXNameFrom name_from; | 657 AXNameFrom name_from; |
| 657 AXObject::AXObjectVector name_objects; | 658 AXObjectImpl::AXObjectVector name_objects; |
| 658 ax_object.GetName(name_from, &name_objects); | 659 ax_object.GetName(name_from, &name_objects); |
| 659 | 660 |
| 660 AXDescriptionFrom description_from; | 661 AXDescriptionFrom description_from; |
| 661 AXObject::AXObjectVector description_objects; | 662 AXObjectImpl::AXObjectVector description_objects; |
| 662 String description = | 663 String description = |
| 663 ax_object.Description(name_from, description_from, &description_objects); | 664 ax_object.Description(name_from, description_from, &description_objects); |
| 664 if (!description.IsEmpty()) { | 665 if (!description.IsEmpty()) { |
| 665 node_object.setDescription( | 666 node_object.setDescription( |
| 666 CreateValue(description, AXValueTypeEnum::ComputedString)); | 667 CreateValue(description, AXValueTypeEnum::ComputedString)); |
| 667 } | 668 } |
| 668 // Value. | 669 // Value. |
| 669 if (ax_object.SupportsRangeValue()) { | 670 if (ax_object.SupportsRangeValue()) { |
| 670 node_object.setValue(CreateValue(ax_object.ValueForRange())); | 671 node_object.setValue(CreateValue(ax_object.ValueForRange())); |
| 671 } else { | 672 } else { |
| 672 String string_value = ax_object.StringValue(); | 673 String string_value = ax_object.StringValue(); |
| 673 if (!string_value.IsEmpty()) | 674 if (!string_value.IsEmpty()) |
| 674 node_object.setValue(CreateValue(string_value)); | 675 node_object.setValue(CreateValue(string_value)); |
| 675 } | 676 } |
| 676 | 677 |
| 677 if (fetch_relatives) | 678 if (fetch_relatives) |
| 678 PopulateRelatives(ax_object, inspected_ax_object, node_object, nodes, | 679 PopulateRelatives(ax_object, inspected_ax_object, node_object, nodes, |
| 679 cache); | 680 cache); |
| 680 | 681 |
| 681 Node* node = ax_object.GetNode(); | 682 Node* node = ax_object.GetNode(); |
| 682 if (node) | 683 if (node) |
| 683 node_object.setBackendDOMNodeId(DOMNodeIds::IdForNode(node)); | 684 node_object.setBackendDOMNodeId(DOMNodeIds::IdForNode(node)); |
| 684 } | 685 } |
| 685 | 686 |
| 686 void InspectorAccessibilityAgent::PopulateRelatives( | 687 void InspectorAccessibilityAgent::PopulateRelatives( |
| 687 AXObject& ax_object, | 688 AXObjectImpl& ax_object, |
| 688 AXObject* inspected_ax_object, | 689 AXObjectImpl* inspected_ax_object, |
| 689 AXNode& node_object, | 690 AXNode& node_object, |
| 690 std::unique_ptr<protocol::Array<AXNode>>& nodes, | 691 std::unique_ptr<protocol::Array<AXNode>>& nodes, |
| 691 AXObjectCacheImpl& cache) const { | 692 AXObjectCacheImpl& cache) const { |
| 692 AXObject* parent_object = ax_object.ParentObject(); | 693 AXObjectImpl* parent_object = ax_object.ParentObject(); |
| 693 if (parent_object && parent_object != inspected_ax_object) { | 694 if (parent_object && parent_object != inspected_ax_object) { |
| 694 // Use unignored parent unless parent is inspected ignored object. | 695 // Use unignored parent unless parent is inspected ignored object. |
| 695 parent_object = ax_object.ParentObjectUnignored(); | 696 parent_object = ax_object.ParentObjectUnignored(); |
| 696 } | 697 } |
| 697 | 698 |
| 698 std::unique_ptr<protocol::Array<AXNodeId>> child_ids = | 699 std::unique_ptr<protocol::Array<AXNodeId>> child_ids = |
| 699 protocol::Array<AXNodeId>::create(); | 700 protocol::Array<AXNodeId>::create(); |
| 700 | 701 |
| 701 if (&ax_object != inspected_ax_object || | 702 if (&ax_object != inspected_ax_object || |
| 702 (inspected_ax_object && !inspected_ax_object->AccessibilityIsIgnored())) { | 703 (inspected_ax_object && !inspected_ax_object->AccessibilityIsIgnored())) { |
| 703 AddChildren(ax_object, inspected_ax_object, child_ids, nodes, cache); | 704 AddChildren(ax_object, inspected_ax_object, child_ids, nodes, cache); |
| 704 } | 705 } |
| 705 node_object.setChildIds(std::move(child_ids)); | 706 node_object.setChildIds(std::move(child_ids)); |
| 706 } | 707 } |
| 707 | 708 |
| 708 void InspectorAccessibilityAgent::AddChildren( | 709 void InspectorAccessibilityAgent::AddChildren( |
| 709 AXObject& ax_object, | 710 AXObjectImpl& ax_object, |
| 710 AXObject* inspected_ax_object, | 711 AXObjectImpl* inspected_ax_object, |
| 711 std::unique_ptr<protocol::Array<AXNodeId>>& child_ids, | 712 std::unique_ptr<protocol::Array<AXNodeId>>& child_ids, |
| 712 std::unique_ptr<protocol::Array<AXNode>>& nodes, | 713 std::unique_ptr<protocol::Array<AXNode>>& nodes, |
| 713 AXObjectCacheImpl& cache) const { | 714 AXObjectCacheImpl& cache) const { |
| 714 if (inspected_ax_object && inspected_ax_object->AccessibilityIsIgnored() && | 715 if (inspected_ax_object && inspected_ax_object->AccessibilityIsIgnored() && |
| 715 &ax_object == inspected_ax_object->ParentObjectUnignored()) { | 716 &ax_object == inspected_ax_object->ParentObjectUnignored()) { |
| 716 child_ids->addItem(String::Number(inspected_ax_object->AxObjectID())); | 717 child_ids->addItem(String::Number(inspected_ax_object->AxObjectID())); |
| 717 return; | 718 return; |
| 718 } | 719 } |
| 719 | 720 |
| 720 const AXObject::AXObjectVector& children = ax_object.Children(); | 721 const AXObjectImpl::AXObjectVector& children = ax_object.Children(); |
| 721 for (unsigned i = 0; i < children.size(); i++) { | 722 for (unsigned i = 0; i < children.size(); i++) { |
| 722 AXObject& child_ax_object = *children[i].Get(); | 723 AXObjectImpl& child_ax_object = *children[i].Get(); |
| 723 child_ids->addItem(String::Number(child_ax_object.AxObjectID())); | 724 child_ids->addItem(String::Number(child_ax_object.AxObjectID())); |
| 724 if (&child_ax_object == inspected_ax_object) | 725 if (&child_ax_object == inspected_ax_object) |
| 725 continue; | 726 continue; |
| 726 if (&ax_object != inspected_ax_object && | 727 if (&ax_object != inspected_ax_object && |
| 727 (ax_object.GetNode() || | 728 (ax_object.GetNode() || |
| 728 ax_object.ParentObjectUnignored() != inspected_ax_object)) { | 729 ax_object.ParentObjectUnignored() != inspected_ax_object)) { |
| 729 continue; | 730 continue; |
| 730 } | 731 } |
| 731 | 732 |
| 732 // Only add children of inspected node (or un-inspectable children of | 733 // Only add children of inspected node (or un-inspectable children of |
| 733 // inspected node) to returned nodes. | 734 // inspected node) to returned nodes. |
| 734 std::unique_ptr<AXNode> child_node = BuildProtocolAXObject( | 735 std::unique_ptr<AXNode> child_node = BuildProtocolAXObject( |
| 735 child_ax_object, inspected_ax_object, true, nodes, cache); | 736 child_ax_object, inspected_ax_object, true, nodes, cache); |
| 736 nodes->addItem(std::move(child_node)); | 737 nodes->addItem(std::move(child_node)); |
| 737 } | 738 } |
| 738 } | 739 } |
| 739 | 740 |
| 740 DEFINE_TRACE(InspectorAccessibilityAgent) { | 741 DEFINE_TRACE(InspectorAccessibilityAgent) { |
| 741 visitor->Trace(page_); | 742 visitor->Trace(page_); |
| 742 visitor->Trace(dom_agent_); | 743 visitor->Trace(dom_agent_); |
| 743 InspectorBaseAgent::Trace(visitor); | 744 InspectorBaseAgent::Trace(visitor); |
| 744 } | 745 } |
| 745 | 746 |
| 746 } // namespace blink | 747 } // namespace blink |
| OLD | NEW |