| 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 "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
| 8 #include "core/dom/AXObjectCache.h" | 8 #include "core/dom/AXObjectCache.h" |
| 9 #include "core/dom/DOMNodeIds.h" | 9 #include "core/dom/DOMNodeIds.h" |
| 10 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 role == SwitchRole; | 149 role == SwitchRole; |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool roleAllowsSelected(AccessibilityRole role) { | 152 bool roleAllowsSelected(AccessibilityRole role) { |
| 153 return role == CellRole || role == ListBoxOptionRole || role == RowRole || | 153 return role == CellRole || role == ListBoxOptionRole || role == RowRole || |
| 154 role == TabRole || role == ColumnHeaderRole || | 154 role == TabRole || role == ColumnHeaderRole || |
| 155 role == MenuItemRadioRole || role == RadioButtonRole || | 155 role == MenuItemRadioRole || role == RadioButtonRole || |
| 156 role == RowHeaderRole || role == TreeItemRole; | 156 role == RowHeaderRole || role == TreeItemRole; |
| 157 } | 157 } |
| 158 | 158 |
| 159 bool roleAllowsModal(AccessibilityRole role) { |
| 160 return role == DialogRole || role == AlertDialogRole; |
| 161 } |
| 162 |
| 159 void fillWidgetProperties(AXObject& axObject, | 163 void fillWidgetProperties(AXObject& axObject, |
| 160 protocol::Array<AXProperty>& properties) { | 164 protocol::Array<AXProperty>& properties) { |
| 161 AccessibilityRole role = axObject.roleValue(); | 165 AccessibilityRole role = axObject.roleValue(); |
| 162 String autocomplete = axObject.ariaAutoComplete(); | 166 String autocomplete = axObject.ariaAutoComplete(); |
| 163 if (!autocomplete.isEmpty()) | 167 if (!autocomplete.isEmpty()) |
| 164 properties.addItem( | 168 properties.addItem( |
| 165 createProperty(AXWidgetAttributesEnum::Autocomplete, | 169 createProperty(AXWidgetAttributesEnum::Autocomplete, |
| 166 createValue(autocomplete, AXValueTypeEnum::Token))); | 170 createValue(autocomplete, AXValueTypeEnum::Token))); |
| 167 | 171 |
| 168 if (axObject.hasAttribute(HTMLNames::aria_haspopupAttr)) { | 172 if (axObject.hasAttribute(HTMLNames::aria_haspopupAttr)) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 341 |
| 338 DEFINE_INLINE_TRACE() { visitor->trace(m_axObject); } | 342 DEFINE_INLINE_TRACE() { visitor->trace(m_axObject); } |
| 339 | 343 |
| 340 private: | 344 private: |
| 341 Member<AXObject> m_axObject; | 345 Member<AXObject> m_axObject; |
| 342 protocol::Array<AXProperty>& m_properties; | 346 protocol::Array<AXProperty>& m_properties; |
| 343 | 347 |
| 344 void addBoolAttribute(AXBoolAttribute attribute, bool value) { | 348 void addBoolAttribute(AXBoolAttribute attribute, bool value) { |
| 345 switch (attribute) { | 349 switch (attribute) { |
| 346 case AXBoolAttribute::AriaModal: | 350 case AXBoolAttribute::AriaModal: |
| 347 // TODO | 351 if (roleAllowsModal(m_axObject->roleValue())) { |
| 352 m_properties.addItem(createProperty(AXWidgetStatesEnum::Modal, |
| 353 createBooleanValue(value))); |
| 354 } |
| 348 break; | 355 break; |
| 349 } | 356 } |
| 350 } | 357 } |
| 351 | 358 |
| 352 void addStringAttribute(AXStringAttribute attribute, const String& value) { | 359 void addStringAttribute(AXStringAttribute attribute, const String& value) { |
| 353 switch (attribute) { | 360 switch (attribute) { |
| 354 case AXStringAttribute::AriaKeyShortcuts: | 361 case AXStringAttribute::AriaKeyShortcuts: |
| 355 // TODO | 362 m_properties.addItem(createProperty( |
| 363 AXWidgetAttributesEnum::Keyshortcuts, createValue(value))); |
| 356 break; | 364 break; |
| 357 case AXStringAttribute::AriaRoleDescription: | 365 case AXStringAttribute::AriaRoleDescription: |
| 358 // TODO | 366 m_properties.addItem(createProperty( |
| 367 AXWidgetAttributesEnum::Roledescription, createValue(value))); |
| 359 break; | 368 break; |
| 360 } | 369 } |
| 361 } | 370 } |
| 362 | 371 |
| 363 void addObjectAttribute(AXObjectAttribute attribute, AXObject* object) { | 372 void addObjectAttribute(AXObjectAttribute attribute, AXObject* object) { |
| 364 switch (attribute) { | 373 switch (attribute) { |
| 365 case AXObjectAttribute::AriaActiveDescendant: | 374 case AXObjectAttribute::AriaActiveDescendant: |
| 366 m_properties.addItem( | 375 m_properties.addItem( |
| 367 createProperty(AXRelationshipAttributesEnum::Activedescendant, | 376 createProperty(AXRelationshipAttributesEnum::Activedescendant, |
| 368 createRelatedNodeListValue(*object))); | 377 createRelatedNodeListValue(*object))); |
| 369 break; | 378 break; |
| 370 case AXObjectAttribute::AriaErrorMessage: | 379 case AXObjectAttribute::AriaErrorMessage: |
| 371 // TODO | 380 m_properties.addItem( |
| 381 createProperty(AXRelationshipAttributesEnum::Errormessage, |
| 382 createRelatedNodeListValue(*object))); |
| 372 break; | 383 break; |
| 373 } | 384 } |
| 374 } | 385 } |
| 375 | 386 |
| 376 void addObjectVectorAttribute(AXObjectVectorAttribute attribute, | 387 void addObjectVectorAttribute(AXObjectVectorAttribute attribute, |
| 377 HeapVector<Member<AXObject>>& objects) { | 388 HeapVector<Member<AXObject>>& objects) { |
| 378 switch (attribute) { | 389 switch (attribute) { |
| 379 case AXObjectVectorAttribute::AriaControls: | 390 case AXObjectVectorAttribute::AriaControls: |
| 380 m_properties.addItem(createRelatedNodeListProperty( | 391 m_properties.addItem(createRelatedNodeListProperty( |
| 381 AXRelationshipAttributesEnum::Controls, objects, aria_controlsAttr, | 392 AXRelationshipAttributesEnum::Controls, objects, aria_controlsAttr, |
| 382 *m_axObject)); | 393 *m_axObject)); |
| 383 break; | 394 break; |
| 384 case AXObjectVectorAttribute::AriaDetails: | 395 case AXObjectVectorAttribute::AriaDetails: |
| 385 // TODO | 396 m_properties.addItem(createRelatedNodeListProperty( |
| 397 AXRelationshipAttributesEnum::Details, objects, aria_controlsAttr, |
| 398 *m_axObject)); |
| 386 break; | 399 break; |
| 387 case AXObjectVectorAttribute::AriaFlowTo: | 400 case AXObjectVectorAttribute::AriaFlowTo: |
| 388 m_properties.addItem(createRelatedNodeListProperty( | 401 m_properties.addItem(createRelatedNodeListProperty( |
| 389 AXRelationshipAttributesEnum::Flowto, objects, aria_flowtoAttr, | 402 AXRelationshipAttributesEnum::Flowto, objects, aria_flowtoAttr, |
| 390 *m_axObject)); | 403 *m_axObject)); |
| 391 break; | 404 break; |
| 392 } | 405 } |
| 393 } | 406 } |
| 394 }; | 407 }; |
| 395 | 408 |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 } | 847 } |
| 835 } | 848 } |
| 836 | 849 |
| 837 DEFINE_TRACE(InspectorAccessibilityAgent) { | 850 DEFINE_TRACE(InspectorAccessibilityAgent) { |
| 838 visitor->trace(m_page); | 851 visitor->trace(m_page); |
| 839 visitor->trace(m_domAgent); | 852 visitor->trace(m_domAgent); |
| 840 InspectorBaseAgent::trace(visitor); | 853 InspectorBaseAgent::trace(visitor); |
| 841 } | 854 } |
| 842 | 855 |
| 843 } // namespace blink | 856 } // namespace blink |
| OLD | NEW |