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

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp

Issue 1702673002: DevTools: migrate remote debugging protocol generators to jinja2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
OLDNEW
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"
11 #include "core/inspector/InspectorDOMAgent.h" 11 #include "core/inspector/InspectorDOMAgent.h"
12 #include "core/inspector/InspectorStyleSheet.h" 12 #include "core/inspector/InspectorStyleSheet.h"
13 #include "core/page/Page.h" 13 #include "core/page/Page.h"
14 #include "modules/accessibility/AXObject.h" 14 #include "modules/accessibility/AXObject.h"
15 #include "modules/accessibility/AXObjectCacheImpl.h" 15 #include "modules/accessibility/AXObjectCacheImpl.h"
16 #include "modules/accessibility/InspectorTypeBuilderHelper.h" 16 #include "modules/accessibility/InspectorTypeBuilderHelper.h"
17 #include "platform/JSONValues.h" 17 #include "platform/JSONValues.h"
18 18
19 namespace blink { 19 namespace blink {
20 20
21 using protocol::TypeBuilder::Accessibility::AXGlobalStates; 21 using protocol::Accessibility::AXGlobalStates;
22 using protocol::TypeBuilder::Accessibility::AXLiveRegionAttributes; 22 using protocol::Accessibility::AXLiveRegionAttributes;
23 using protocol::TypeBuilder::Accessibility::AXNode; 23 using protocol::Accessibility::AXNode;
24 using protocol::TypeBuilder::Accessibility::AXNodeId; 24 using protocol::Accessibility::AXNodeId;
25 using protocol::TypeBuilder::Accessibility::AXProperty; 25 using protocol::Accessibility::AXProperty;
26 using protocol::TypeBuilder::Accessibility::AXValueSource; 26 using protocol::Accessibility::AXValueSource;
27 using protocol::TypeBuilder::Accessibility::AXValueType; 27 using protocol::Accessibility::AXValueType;
28 using protocol::TypeBuilder::Accessibility::AXRelatedNode; 28 using protocol::Accessibility::AXRelatedNode;
29 using protocol::TypeBuilder::Accessibility::AXRelationshipAttributes; 29 using protocol::Accessibility::AXRelationshipAttributes;
30 using protocol::TypeBuilder::Accessibility::AXValue; 30 using protocol::Accessibility::AXValue;
31 using protocol::TypeBuilder::Accessibility::AXWidgetAttributes; 31 using protocol::Accessibility::AXWidgetAttributes;
32 using protocol::TypeBuilder::Accessibility::AXWidgetStates; 32 using protocol::Accessibility::AXWidgetStates;
33 33
34 using namespace HTMLNames; 34 using namespace HTMLNames;
35 35
36 namespace { 36 namespace {
37 37
38 void fillCoreProperties(AXObject* axObject, PassRefPtr<AXNode> nodeObject) 38 void fillCoreProperties(AXObject* axObject, AXNode* nodeObject)
39 { 39 {
40 // Description (secondary to the accessible name). 40 // Description (secondary to the accessible name).
41 AXNameFrom nameFrom; 41 AXNameFrom nameFrom;
42 AXObject::AXObjectVector nameObjects; 42 AXObject::AXObjectVector nameObjects;
43 axObject->name(nameFrom, &nameObjects); 43 axObject->name(nameFrom, &nameObjects);
44 AXDescriptionFrom descriptionFrom; 44 AXDescriptionFrom descriptionFrom;
45 AXObject::AXObjectVector descriptionObjects; 45 AXObject::AXObjectVector descriptionObjects;
46 String description = axObject->description(nameFrom, descriptionFrom, &descr iptionObjects); 46 String description = axObject->description(nameFrom, descriptionFrom, &descr iptionObjects);
47 if (!description.isEmpty()) 47 if (!description.isEmpty())
48 nodeObject->setDescription(createValue(description, AXValueType::Compute dString)); 48 nodeObject->setDescription(createValue(description, AXValueTypeEnum::Com putedString));
49 49
50 // Value. 50 // Value.
51 if (axObject->supportsRangeValue()) { 51 if (axObject->supportsRangeValue()) {
52 nodeObject->setValue(createValue(axObject->valueForRange())); 52 nodeObject->setValue(createValue(axObject->valueForRange()));
53 } else { 53 } else {
54 String stringValue = axObject->stringValue(); 54 String stringValue = axObject->stringValue();
55 if (!stringValue.isEmpty()) 55 if (!stringValue.isEmpty())
56 nodeObject->setValue(createValue(stringValue)); 56 nodeObject->setValue(createValue(stringValue));
57 } 57 }
58 } 58 }
59 59
60 void fillLiveRegionProperties(AXObject* axObject, PassRefPtr<protocol::TypeBuild er::Array<AXProperty>> properties) 60 void fillLiveRegionProperties(AXObject* axObject, protocol::Array<AXProperty>* p roperties)
61 { 61 {
62 if (!axObject->liveRegionRoot()) 62 if (!axObject->liveRegionRoot())
63 return; 63 return;
64 64
65 properties->addItem(createProperty(AXLiveRegionAttributes::Live, createValue (axObject->containerLiveRegionStatus(), AXValueType::Token))); 65 properties->addItem(createProperty(AXLiveRegionAttributesEnum::Live, createV alue(axObject->containerLiveRegionStatus(), AXValueTypeEnum::Token)));
66 properties->addItem(createProperty(AXLiveRegionAttributes::Atomic, createBoo leanValue(axObject->containerLiveRegionAtomic()))); 66 properties->addItem(createProperty(AXLiveRegionAttributesEnum::Atomic, creat eBooleanValue(axObject->containerLiveRegionAtomic())));
67 properties->addItem(createProperty(AXLiveRegionAttributes::Relevant, createV alue(axObject->containerLiveRegionRelevant(), AXValueType::TokenList))); 67 properties->addItem(createProperty(AXLiveRegionAttributesEnum::Relevant, cre ateValue(axObject->containerLiveRegionRelevant(), AXValueTypeEnum::TokenList)));
68 properties->addItem(createProperty(AXLiveRegionAttributes::Busy, createBoole anValue(axObject->containerLiveRegionBusy()))); 68 properties->addItem(createProperty(AXLiveRegionAttributesEnum::Busy, createB ooleanValue(axObject->containerLiveRegionBusy())));
69 69
70 if (!axObject->isLiveRegion()) 70 if (!axObject->isLiveRegion())
71 properties->addItem(createProperty(AXLiveRegionAttributes::Root, createR elatedNodeListValue(axObject->liveRegionRoot()))); 71 properties->addItem(createProperty(AXLiveRegionAttributesEnum::Root, cre ateRelatedNodeListValue(axObject->liveRegionRoot())));
72 } 72 }
73 73
74 void fillGlobalStates(AXObject* axObject, PassRefPtr<protocol::TypeBuilder::Arra y<AXProperty>> properties) 74 void fillGlobalStates(AXObject* axObject, protocol::Array<AXProperty>* propertie s)
75 { 75 {
76 if (!axObject->isEnabled()) 76 if (!axObject->isEnabled())
77 properties->addItem(createProperty(AXGlobalStates::Disabled, createBoole anValue(true))); 77 properties->addItem(createProperty(AXGlobalStatesEnum::Disabled, createB ooleanValue(true)));
78 78
79 if (const AXObject* hiddenRoot = axObject->ariaHiddenRoot()) { 79 if (const AXObject* hiddenRoot = axObject->ariaHiddenRoot()) {
80 properties->addItem(createProperty(AXGlobalStates::Hidden, createBoolean Value(true))); 80 properties->addItem(createProperty(AXGlobalStatesEnum::Hidden, createBoo leanValue(true)));
81 properties->addItem(createProperty(AXGlobalStates::HiddenRoot, createRel atedNodeListValue(hiddenRoot))); 81 properties->addItem(createProperty(AXGlobalStatesEnum::HiddenRoot, creat eRelatedNodeListValue(hiddenRoot)));
82 } 82 }
83 83
84 InvalidState invalidState = axObject->invalidState(); 84 InvalidState invalidState = axObject->invalidState();
85 switch (invalidState) { 85 switch (invalidState) {
86 case InvalidStateUndefined: 86 case InvalidStateUndefined:
87 break; 87 break;
88 case InvalidStateFalse: 88 case InvalidStateFalse:
89 properties->addItem(createProperty(AXGlobalStates::Invalid, createValue( "false", AXValueType::Token))); 89 properties->addItem(createProperty(AXGlobalStatesEnum::Invalid, createVa lue("false", AXValueTypeEnum::Token)));
90 break; 90 break;
91 case InvalidStateTrue: 91 case InvalidStateTrue:
92 properties->addItem(createProperty(AXGlobalStates::Invalid, createValue( "true", AXValueType::Token))); 92 properties->addItem(createProperty(AXGlobalStatesEnum::Invalid, createVa lue("true", AXValueTypeEnum::Token)));
93 break; 93 break;
94 case InvalidStateSpelling: 94 case InvalidStateSpelling:
95 properties->addItem(createProperty(AXGlobalStates::Invalid, createValue( "spelling", AXValueType::Token))); 95 properties->addItem(createProperty(AXGlobalStatesEnum::Invalid, createVa lue("spelling", AXValueTypeEnum::Token)));
96 break; 96 break;
97 case InvalidStateGrammar: 97 case InvalidStateGrammar:
98 properties->addItem(createProperty(AXGlobalStates::Invalid, createValue( "grammar", AXValueType::Token))); 98 properties->addItem(createProperty(AXGlobalStatesEnum::Invalid, createVa lue("grammar", AXValueTypeEnum::Token)));
99 break; 99 break;
100 default: 100 default:
101 // TODO(aboxhall): expose invalid: <nothing> and source: aria-invalid as invalid value 101 // TODO(aboxhall): expose invalid: <nothing> and source: aria-invalid as invalid value
102 properties->addItem(createProperty(AXGlobalStates::Invalid, createValue( axObject->ariaInvalidValue(), AXValueType::String))); 102 properties->addItem(createProperty(AXGlobalStatesEnum::Invalid, createVa lue(axObject->ariaInvalidValue(), AXValueTypeEnum::String)));
103 break; 103 break;
104 } 104 }
105 } 105 }
106 106
107 bool roleAllowsMultiselectable(AccessibilityRole role) 107 bool roleAllowsMultiselectable(AccessibilityRole role)
108 { 108 {
109 return role == GridRole || role == ListBoxRole || role == TabListRole || rol e == TreeGridRole || role == TreeRole; 109 return role == GridRole || role == ListBoxRole || role == TabListRole || rol e == TreeGridRole || role == TreeRole;
110 } 110 }
111 111
112 bool roleAllowsOrientation(AccessibilityRole role) 112 bool roleAllowsOrientation(AccessibilityRole role)
(...skipping 19 matching lines...) Expand all
132 bool roleAllowsChecked(AccessibilityRole role) 132 bool roleAllowsChecked(AccessibilityRole role)
133 { 133 {
134 return role == MenuItemCheckBoxRole || role == MenuItemRadioRole || role == RadioButtonRole || role == CheckBoxRole || role == TreeItemRole || role == ListB oxOptionRole || role == SwitchRole; 134 return role == MenuItemCheckBoxRole || role == MenuItemRadioRole || role == RadioButtonRole || role == CheckBoxRole || role == TreeItemRole || role == ListB oxOptionRole || role == SwitchRole;
135 } 135 }
136 136
137 bool roleAllowsSelected(AccessibilityRole role) 137 bool roleAllowsSelected(AccessibilityRole role)
138 { 138 {
139 return role == CellRole || role == ListBoxOptionRole || role == RowRole || r ole == TabRole || role == ColumnHeaderRole || role == MenuItemRadioRole || role == RadioButtonRole || role == RowHeaderRole || role == TreeItemRole; 139 return role == CellRole || role == ListBoxOptionRole || role == RowRole || r ole == TabRole || role == ColumnHeaderRole || role == MenuItemRadioRole || role == RadioButtonRole || role == RowHeaderRole || role == TreeItemRole;
140 } 140 }
141 141
142 void fillWidgetProperties(AXObject* axObject, PassRefPtr<protocol::TypeBuilder:: Array<AXProperty>> properties) 142 void fillWidgetProperties(AXObject* axObject, protocol::Array<AXProperty>* prope rties)
143 { 143 {
144 AccessibilityRole role = axObject->roleValue(); 144 AccessibilityRole role = axObject->roleValue();
145 String autocomplete = axObject->ariaAutoComplete(); 145 String autocomplete = axObject->ariaAutoComplete();
146 if (!autocomplete.isEmpty()) 146 if (!autocomplete.isEmpty())
147 properties->addItem(createProperty(AXWidgetAttributes::Autocomplete, cre ateValue(autocomplete, AXValueType::Token))); 147 properties->addItem(createProperty(AXWidgetAttributesEnum::Autocomplete, createValue(autocomplete, AXValueTypeEnum::Token)));
148 148
149 if (axObject->hasAttribute(HTMLNames::aria_haspopupAttr)) { 149 if (axObject->hasAttribute(HTMLNames::aria_haspopupAttr)) {
150 bool hasPopup = axObject->ariaHasPopup(); 150 bool hasPopup = axObject->ariaHasPopup();
151 properties->addItem(createProperty(AXWidgetAttributes::Haspopup, createB ooleanValue(hasPopup))); 151 properties->addItem(createProperty(AXWidgetAttributesEnum::Haspopup, cre ateBooleanValue(hasPopup)));
152 } 152 }
153 153
154 int headingLevel = axObject->headingLevel(); 154 int headingLevel = axObject->headingLevel();
155 if (headingLevel > 0) 155 if (headingLevel > 0)
156 properties->addItem(createProperty(AXWidgetAttributes::Level, createValu e(headingLevel))); 156 properties->addItem(createProperty(AXWidgetAttributesEnum::Level, create Value(headingLevel)));
157 int hierarchicalLevel = axObject->hierarchicalLevel(); 157 int hierarchicalLevel = axObject->hierarchicalLevel();
158 if (hierarchicalLevel > 0 || axObject->hasAttribute(HTMLNames::aria_levelAtt r)) 158 if (hierarchicalLevel > 0 || axObject->hasAttribute(HTMLNames::aria_levelAtt r))
159 properties->addItem(createProperty(AXWidgetAttributes::Level, createValu e(hierarchicalLevel))); 159 properties->addItem(createProperty(AXWidgetAttributesEnum::Level, create Value(hierarchicalLevel)));
160 160
161 if (roleAllowsMultiselectable(role)) { 161 if (roleAllowsMultiselectable(role)) {
162 bool multiselectable = axObject->isMultiSelectable(); 162 bool multiselectable = axObject->isMultiSelectable();
163 properties->addItem(createProperty(AXWidgetAttributes::Multiselectable, createBooleanValue(multiselectable))); 163 properties->addItem(createProperty(AXWidgetAttributesEnum::Multiselectab le, createBooleanValue(multiselectable)));
164 } 164 }
165 165
166 if (roleAllowsOrientation(role)) { 166 if (roleAllowsOrientation(role)) {
167 AccessibilityOrientation orientation = axObject->orientation(); 167 AccessibilityOrientation orientation = axObject->orientation();
168 switch (orientation) { 168 switch (orientation) {
169 case AccessibilityOrientationVertical: 169 case AccessibilityOrientationVertical:
170 properties->addItem(createProperty(AXWidgetAttributes::Orientation, createValue("vertical", AXValueType::Token))); 170 properties->addItem(createProperty(AXWidgetAttributesEnum::Orientati on, createValue("vertical", AXValueTypeEnum::Token)));
171 break; 171 break;
172 case AccessibilityOrientationHorizontal: 172 case AccessibilityOrientationHorizontal:
173 properties->addItem(createProperty(AXWidgetAttributes::Orientation, createValue("horizontal", AXValueType::Token))); 173 properties->addItem(createProperty(AXWidgetAttributesEnum::Orientati on, createValue("horizontal", AXValueTypeEnum::Token)));
174 break; 174 break;
175 case AccessibilityOrientationUndefined: 175 case AccessibilityOrientationUndefined:
176 break; 176 break;
177 } 177 }
178 } 178 }
179 179
180 if (role == TextFieldRole) 180 if (role == TextFieldRole)
181 properties->addItem(createProperty(AXWidgetAttributes::Multiline, create BooleanValue(axObject->isMultiline()))); 181 properties->addItem(createProperty(AXWidgetAttributesEnum::Multiline, cr eateBooleanValue(axObject->isMultiline())));
182 182
183 if (roleAllowsReadonly(role)) { 183 if (roleAllowsReadonly(role)) {
184 properties->addItem(createProperty(AXWidgetAttributes::Readonly, createB ooleanValue(axObject->isReadOnly()))); 184 properties->addItem(createProperty(AXWidgetAttributesEnum::Readonly, cre ateBooleanValue(axObject->isReadOnly())));
185 } 185 }
186 186
187 if (roleAllowsRequired(role)) { 187 if (roleAllowsRequired(role)) {
188 properties->addItem(createProperty(AXWidgetAttributes::Required, createB ooleanValue(axObject->isRequired()))); 188 properties->addItem(createProperty(AXWidgetAttributesEnum::Required, cre ateBooleanValue(axObject->isRequired())));
189 } 189 }
190 190
191 if (roleAllowsSort(role)) { 191 if (roleAllowsSort(role)) {
192 // TODO(aboxhall): sort 192 // TODO(aboxhall): sort
193 } 193 }
194 194
195 if (axObject->isRange()) { 195 if (axObject->isRange()) {
196 properties->addItem(createProperty(AXWidgetAttributes::Valuemin, createV alue(axObject->minValueForRange()))); 196 properties->addItem(createProperty(AXWidgetAttributesEnum::Valuemin, cre ateValue(axObject->minValueForRange())));
197 properties->addItem(createProperty(AXWidgetAttributes::Valuemax, createV alue(axObject->maxValueForRange()))); 197 properties->addItem(createProperty(AXWidgetAttributesEnum::Valuemax, cre ateValue(axObject->maxValueForRange())));
198 properties->addItem(createProperty(AXWidgetAttributes::Valuetext, create Value(axObject->valueDescription()))); 198 properties->addItem(createProperty(AXWidgetAttributesEnum::Valuetext, cr eateValue(axObject->valueDescription())));
199 } 199 }
200 } 200 }
201 201
202 void fillWidgetStates(AXObject* axObject, PassRefPtr<protocol::TypeBuilder::Arra y<AXProperty>> properties) 202 void fillWidgetStates(AXObject* axObject, protocol::Array<AXProperty>* propertie s)
203 { 203 {
204 AccessibilityRole role = axObject->roleValue(); 204 AccessibilityRole role = axObject->roleValue();
205 if (roleAllowsChecked(role)) { 205 if (roleAllowsChecked(role)) {
206 AccessibilityButtonState checked = axObject->checkboxOrRadioValue(); 206 AccessibilityButtonState checked = axObject->checkboxOrRadioValue();
207 switch (checked) { 207 switch (checked) {
208 case ButtonStateOff: 208 case ButtonStateOff:
209 properties->addItem(createProperty(AXWidgetStates::Checked, createVa lue("false", AXValueType::Tristate))); 209 properties->addItem(createProperty(AXWidgetStatesEnum::Checked, crea teValue("false", AXValueTypeEnum::Tristate)));
210 break; 210 break;
211 case ButtonStateOn: 211 case ButtonStateOn:
212 properties->addItem(createProperty(AXWidgetStates::Checked, createVa lue("true", AXValueType::Tristate))); 212 properties->addItem(createProperty(AXWidgetStatesEnum::Checked, crea teValue("true", AXValueTypeEnum::Tristate)));
213 break; 213 break;
214 case ButtonStateMixed: 214 case ButtonStateMixed:
215 properties->addItem(createProperty(AXWidgetStates::Checked, createVa lue("mixed", AXValueType::Tristate))); 215 properties->addItem(createProperty(AXWidgetStatesEnum::Checked, crea teValue("mixed", AXValueTypeEnum::Tristate)));
216 break; 216 break;
217 } 217 }
218 } 218 }
219 219
220 AccessibilityExpanded expanded = axObject->isExpanded(); 220 AccessibilityExpanded expanded = axObject->isExpanded();
221 switch (expanded) { 221 switch (expanded) {
222 case ExpandedUndefined: 222 case ExpandedUndefined:
223 break; 223 break;
224 case ExpandedCollapsed: 224 case ExpandedCollapsed:
225 properties->addItem(createProperty(AXWidgetStates::Expanded, createBoole anValue(false, AXValueType::BooleanOrUndefined))); 225 properties->addItem(createProperty(AXWidgetStatesEnum::Expanded, createB ooleanValue(false, AXValueTypeEnum::BooleanOrUndefined)));
226 break; 226 break;
227 case ExpandedExpanded: 227 case ExpandedExpanded:
228 properties->addItem(createProperty(AXWidgetStates::Expanded, createBoole anValue(true, AXValueType::BooleanOrUndefined))); 228 properties->addItem(createProperty(AXWidgetStatesEnum::Expanded, createB ooleanValue(true, AXValueTypeEnum::BooleanOrUndefined)));
229 break; 229 break;
230 } 230 }
231 231
232 if (role == ToggleButtonRole) { 232 if (role == ToggleButtonRole) {
233 if (!axObject->isPressed()) { 233 if (!axObject->isPressed()) {
234 properties->addItem(createProperty(AXWidgetStates::Pressed, createVa lue("false", AXValueType::Tristate))); 234 properties->addItem(createProperty(AXWidgetStatesEnum::Pressed, crea teValue("false", AXValueTypeEnum::Tristate)));
235 } else { 235 } else {
236 const AtomicString& pressedAttr = axObject->getAttribute(HTMLNames:: aria_pressedAttr); 236 const AtomicString& pressedAttr = axObject->getAttribute(HTMLNames:: aria_pressedAttr);
237 if (equalIgnoringCase(pressedAttr, "mixed")) 237 if (equalIgnoringCase(pressedAttr, "mixed"))
238 properties->addItem(createProperty(AXWidgetStates::Pressed, crea teValue("mixed", AXValueType::Tristate))); 238 properties->addItem(createProperty(AXWidgetStatesEnum::Pressed, createValue("mixed", AXValueTypeEnum::Tristate)));
239 else 239 else
240 properties->addItem(createProperty(AXWidgetStates::Pressed, crea teValue("true", AXValueType::Tristate))); 240 properties->addItem(createProperty(AXWidgetStatesEnum::Pressed, createValue("true", AXValueTypeEnum::Tristate)));
241 } 241 }
242 } 242 }
243 243
244 if (roleAllowsSelected(role)) { 244 if (roleAllowsSelected(role)) {
245 properties->addItem(createProperty(AXWidgetStates::Selected, createBoole anValue(axObject->isSelected()))); 245 properties->addItem(createProperty(AXWidgetStatesEnum::Selected, createB ooleanValue(axObject->isSelected())));
246 } 246 }
247 } 247 }
248 248
249 PassRefPtr<AXProperty> createRelatedNodeListProperty(AXRelationshipAttributes::E num key, AXRelatedObjectVector& nodes) 249 PassOwnPtr<AXProperty> createRelatedNodeListProperty(const String& key, AXRelate dObjectVector& nodes)
250 { 250 {
251 RefPtr<AXValue> nodeListValue = createRelatedNodeListValue(nodes, AXValueTyp e::NodeList); 251 OwnPtr<AXValue> nodeListValue = createRelatedNodeListValue(nodes, AXValueTyp eEnum::NodeList);
252 return createProperty(key, nodeListValue); 252 return createProperty(key, nodeListValue.release());
253 } 253 }
254 254
255 PassRefPtr<AXProperty> createRelatedNodeListProperty(AXRelationshipAttributes::E num key, AXObject::AXObjectVector& nodes, const QualifiedName& attr, AXObject* a xObject) 255 PassOwnPtr<AXProperty> createRelatedNodeListProperty(const String& key, AXObject ::AXObjectVector& nodes, const QualifiedName& attr, AXObject* axObject)
256 { 256 {
257 RefPtr<AXValue> nodeListValue = createRelatedNodeListValue(nodes); 257 OwnPtr<AXValue> nodeListValue = createRelatedNodeListValue(nodes);
258 const AtomicString& attrValue = axObject->getAttribute(attr); 258 const AtomicString& attrValue = axObject->getAttribute(attr);
259 nodeListValue->setValue(JSONString::create(attrValue)); 259 nodeListValue->setValue(JSONString::create(attrValue));
260 return createProperty(key, nodeListValue); 260 return createProperty(key, nodeListValue.release());
261 } 261 }
262 262
263 void fillRelationships(AXObject* axObject, PassRefPtr<protocol::TypeBuilder::Arr ay<AXProperty>> properties) 263 void fillRelationships(AXObject* axObject, protocol::Array<AXProperty>* properti es)
264 { 264 {
265 if (AXObject* activeDescendant = axObject->activeDescendant()) { 265 if (AXObject* activeDescendant = axObject->activeDescendant()) {
266 properties->addItem(createProperty(AXRelationshipAttributes::Activedesce ndant, createRelatedNodeListValue(activeDescendant))); 266 properties->addItem(createProperty(AXRelationshipAttributesEnum::Actived escendant, createRelatedNodeListValue(activeDescendant)));
267 } 267 }
268 268
269 AXObject::AXObjectVector results; 269 AXObject::AXObjectVector results;
270 axObject->ariaFlowToElements(results); 270 axObject->ariaFlowToElements(results);
271 if (!results.isEmpty()) 271 if (!results.isEmpty())
272 properties->addItem(createRelatedNodeListProperty(AXRelationshipAttribut es::Flowto, results, aria_flowtoAttr, axObject)); 272 properties->addItem(createRelatedNodeListProperty(AXRelationshipAttribut esEnum::Flowto, results, aria_flowtoAttr, axObject));
273 results.clear(); 273 results.clear();
274 274
275 axObject->ariaControlsElements(results); 275 axObject->ariaControlsElements(results);
276 if (!results.isEmpty()) 276 if (!results.isEmpty())
277 properties->addItem(createRelatedNodeListProperty(AXRelationshipAttribut es::Controls, results, aria_controlsAttr, axObject)); 277 properties->addItem(createRelatedNodeListProperty(AXRelationshipAttribut esEnum::Controls, results, aria_controlsAttr, axObject));
278 results.clear(); 278 results.clear();
279 279
280 axObject->ariaDescribedbyElements(results); 280 axObject->ariaDescribedbyElements(results);
281 if (!results.isEmpty()) 281 if (!results.isEmpty())
282 properties->addItem(createRelatedNodeListProperty(AXRelationshipAttribut es::Describedby, results, aria_describedbyAttr, axObject)); 282 properties->addItem(createRelatedNodeListProperty(AXRelationshipAttribut esEnum::Describedby, results, aria_describedbyAttr, axObject));
283 results.clear(); 283 results.clear();
284 284
285 axObject->ariaOwnsElements(results); 285 axObject->ariaOwnsElements(results);
286 if (!results.isEmpty()) 286 if (!results.isEmpty())
287 properties->addItem(createRelatedNodeListProperty(AXRelationshipAttribut es::Owns, results, aria_ownsAttr, axObject)); 287 properties->addItem(createRelatedNodeListProperty(AXRelationshipAttribut esEnum::Owns, results, aria_ownsAttr, axObject));
288 results.clear(); 288 results.clear();
289 } 289 }
290 290
291 PassRefPtr<AXValue> createRoleNameValue(AccessibilityRole role) 291 PassOwnPtr<AXValue> createRoleNameValue(AccessibilityRole role)
292 { 292 {
293 AtomicString roleName = AXObject::roleName(role); 293 AtomicString roleName = AXObject::roleName(role);
294 RefPtr<AXValue> roleNameValue; 294 OwnPtr<AXValue> roleNameValue;
295 if (!roleName.isNull()) { 295 if (!roleName.isNull()) {
296 roleNameValue = createValue(roleName, AXValueType::Role); 296 roleNameValue = createValue(roleName, AXValueTypeEnum::Role);
297 } else { 297 } else {
298 roleNameValue = createValue(AXObject::internalRoleName(role), AXValueTyp e::InternalRole); 298 roleNameValue = createValue(AXObject::internalRoleName(role), AXValueTyp eEnum::InternalRole);
299 } 299 }
300 return roleNameValue; 300 return roleNameValue.release();
301 } 301 }
302 302
303 PassRefPtr<AXNode> buildObjectForIgnoredNode(Node* node, AXObject* axObject, AXO bjectCacheImpl* cacheImpl) 303 PassOwnPtr<AXNode> buildObjectForIgnoredNode(Node* node, AXObject* axObject, AXO bjectCacheImpl* cacheImpl)
304 { 304 {
305 AXObject::IgnoredReasons ignoredReasons; 305 AXObject::IgnoredReasons ignoredReasons;
306 306
307 AXID axID = 0; 307 AXID axID = 0;
308 RefPtr<AXNode> ignoredNodeObject = AXNode::create().setNodeId(String::number (axID)).setIgnored(true); 308 OwnPtr<AXNode> ignoredNodeObject = AXNode::create().setNodeId(String::number (axID)).setIgnored(true).build();
309 if (axObject) { 309 if (axObject) {
310 axObject->computeAccessibilityIsIgnored(&ignoredReasons); 310 axObject->computeAccessibilityIsIgnored(&ignoredReasons);
311 axID = axObject->axObjectID(); 311 axID = axObject->axObjectID();
312 AccessibilityRole role = axObject->roleValue(); 312 AccessibilityRole role = axObject->roleValue();
313 ignoredNodeObject->setRole(createRoleNameValue(role)); 313 ignoredNodeObject->setRole(createRoleNameValue(role));
314 } else if (!node->layoutObject()) { 314 } else if (!node->layoutObject()) {
315 ignoredReasons.append(IgnoredReason(AXNotRendered)); 315 ignoredReasons.append(IgnoredReason(AXNotRendered));
316 } 316 }
317 317
318 RefPtr<protocol::TypeBuilder::Array<AXProperty>> ignoredReasonProperties = p rotocol::TypeBuilder::Array<AXProperty>::create(); 318 OwnPtr<protocol::Array<AXProperty>> ignoredReasonProperties = protocol::Arra y<AXProperty>::create();
319 for (size_t i = 0; i < ignoredReasons.size(); i++) 319 for (size_t i = 0; i < ignoredReasons.size(); i++)
320 ignoredReasonProperties->addItem(createProperty(ignoredReasons[i])); 320 ignoredReasonProperties->addItem(createProperty(ignoredReasons[i]));
321 ignoredNodeObject->setIgnoredReasons(ignoredReasonProperties); 321 ignoredNodeObject->setIgnoredReasons(ignoredReasonProperties.release());
322 322
323 return ignoredNodeObject; 323 return ignoredNodeObject.release();
324 } 324 }
325 325
326 PassRefPtr<AXNode> buildObjectForNode(Node* node, AXObject* axObject, AXObjectCa cheImpl* cacheImpl, PassRefPtr<protocol::TypeBuilder::Array<AXProperty>> propert ies) 326 PassOwnPtr<AXNode> buildObjectForNode(Node* node, AXObject* axObject, AXObjectCa cheImpl* cacheImpl, PassOwnPtr<protocol::Array<AXProperty>> properties)
327 { 327 {
328 AccessibilityRole role = axObject->roleValue(); 328 AccessibilityRole role = axObject->roleValue();
329 RefPtr<AXNode> nodeObject = AXNode::create().setNodeId(String::number(axObje ct->axObjectID())).setIgnored(false); 329 OwnPtr<AXNode> nodeObject = AXNode::create().setNodeId(String::number(axObje ct->axObjectID())).setIgnored(false).build();
330 nodeObject->setRole(createRoleNameValue(role)); 330 nodeObject->setRole(createRoleNameValue(role));
331 331
332 AXObject::NameSources nameSources; 332 AXObject::NameSources nameSources;
333 String computedName = axObject->name(&nameSources); 333 String computedName = axObject->name(&nameSources);
334 if (!nameSources.isEmpty()) { 334 if (!nameSources.isEmpty()) {
335 RefPtr<AXValue> name = createValue(computedName, AXValueType::ComputedSt ring); 335 OwnPtr<AXValue> name = createValue(computedName, AXValueTypeEnum::Comput edString);
336 if (!nameSources.isEmpty()) { 336 if (!nameSources.isEmpty()) {
337 RefPtr<protocol::TypeBuilder::Array<AXValueSource>> nameSourceProper ties = protocol::TypeBuilder::Array<AXValueSource>::create(); 337 OwnPtr<protocol::Array<AXValueSource>> nameSourceProperties = protoc ol::Array<AXValueSource>::create();
338 for (size_t i = 0; i < nameSources.size(); ++i) { 338 for (size_t i = 0; i < nameSources.size(); ++i) {
339 NameSource& nameSource = nameSources[i]; 339 NameSource& nameSource = nameSources[i];
340 nameSourceProperties->addItem(createValueSource(nameSource)); 340 nameSourceProperties->addItem(createValueSource(nameSource));
341 if (nameSource.text.isNull() || nameSource.superseded) 341 if (nameSource.text.isNull() || nameSource.superseded)
342 continue; 342 continue;
343 if (!nameSource.relatedObjects.isEmpty()) { 343 if (!nameSource.relatedObjects.isEmpty()) {
344 properties->addItem(createRelatedNodeListProperty(AXRelation shipAttributes::Labelledby, nameSource.relatedObjects)); 344 properties->addItem(createRelatedNodeListProperty(AXRelation shipAttributesEnum::Labelledby, nameSource.relatedObjects));
345 } 345 }
346 } 346 }
347 name->setSources(nameSourceProperties); 347 name->setSources(nameSourceProperties.release());
348 } 348 }
349 nodeObject->setProperties(properties); 349 nodeObject->setProperties(properties);
350 nodeObject->setName(name); 350 nodeObject->setName(name.release());
351 } else { 351 } else {
352 nodeObject->setProperties(properties); 352 nodeObject->setProperties(properties);
353 } 353 }
354 354
355 fillCoreProperties(axObject, nodeObject); 355 fillCoreProperties(axObject, nodeObject.get());
356 return nodeObject; 356 return nodeObject.release();
357 } 357 }
358 358
359 } // namespace 359 } // namespace
360 360
361 InspectorAccessibilityAgent::InspectorAccessibilityAgent(Page* page) 361 InspectorAccessibilityAgent::InspectorAccessibilityAgent(Page* page)
362 : InspectorBaseAgent<InspectorAccessibilityAgent, protocol::Frontend::Access ibility>("Accessibility") 362 : InspectorBaseAgent<InspectorAccessibilityAgent, protocol::Frontend::Access ibility>("Accessibility")
363 , m_page(page) 363 , m_page(page)
364 { 364 {
365 } 365 }
366 366
367 void InspectorAccessibilityAgent::getAXNode(ErrorString* errorString, int nodeId , RefPtr<AXNode>& accessibilityNode) 367 void InspectorAccessibilityAgent::getAXNode(ErrorString* errorString, int nodeId , OwnPtr<AXNode>* accessibilityNode)
368 { 368 {
369 Frame* mainFrame = m_page->mainFrame(); 369 Frame* mainFrame = m_page->mainFrame();
370 if (!mainFrame->isLocalFrame()) { 370 if (!mainFrame->isLocalFrame()) {
371 *errorString = "Can't inspect out of process frames yet"; 371 *errorString = "Can't inspect out of process frames yet";
372 return; 372 return;
373 } 373 }
374 374
375 InspectorDOMAgent* domAgent = toLocalFrame(mainFrame)->instrumentingAgents() ->inspectorDOMAgent(); 375 InspectorDOMAgent* domAgent = toLocalFrame(mainFrame)->instrumentingAgents() ->inspectorDOMAgent();
376 if (!domAgent) { 376 if (!domAgent) {
377 *errorString = "DOM agent must be enabled"; 377 *errorString = "DOM agent must be enabled";
378 return; 378 return;
379 } 379 }
380 Node* node = domAgent->assertNode(errorString, nodeId); 380 Node* node = domAgent->assertNode(errorString, nodeId);
381 if (!node) 381 if (!node)
382 return; 382 return;
383 383
384 Document& document = node->document(); 384 Document& document = node->document();
385 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document); 385 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document);
386 AXObjectCacheImpl* cacheImpl = toAXObjectCacheImpl(cache->get()); 386 AXObjectCacheImpl* cacheImpl = toAXObjectCacheImpl(cache->get());
387 AXObject* axObject = cacheImpl->getOrCreate(node); 387 AXObject* axObject = cacheImpl->getOrCreate(node);
388 if (!axObject || axObject->accessibilityIsIgnored()) { 388 if (!axObject || axObject->accessibilityIsIgnored()) {
389 accessibilityNode = buildObjectForIgnoredNode(node, axObject, cacheImpl) ; 389 *accessibilityNode = buildObjectForIgnoredNode(node, axObject, cacheImpl );
390 return; 390 return;
391 } 391 }
392 392
393 RefPtr<protocol::TypeBuilder::Array<AXProperty>> properties = protocol::Type Builder::Array<AXProperty>::create(); 393 OwnPtr<protocol::Array<AXProperty>> properties = protocol::Array<AXProperty> ::create();
394 fillLiveRegionProperties(axObject, properties); 394 fillLiveRegionProperties(axObject, properties.get());
395 fillGlobalStates(axObject, properties); 395 fillGlobalStates(axObject, properties.get());
396 fillWidgetProperties(axObject, properties); 396 fillWidgetProperties(axObject, properties.get());
397 fillWidgetStates(axObject, properties); 397 fillWidgetStates(axObject, properties.get());
398 fillRelationships(axObject, properties); 398 fillRelationships(axObject, properties.get());
399 399
400 accessibilityNode = buildObjectForNode(node, axObject, cacheImpl, properties ); 400 *accessibilityNode = buildObjectForNode(node, axObject, cacheImpl, propertie s.release());
401 } 401 }
402 402
403 DEFINE_TRACE(InspectorAccessibilityAgent) 403 DEFINE_TRACE(InspectorAccessibilityAgent)
404 { 404 {
405 visitor->trace(m_page); 405 visitor->trace(m_page);
406 InspectorBaseAgent::trace(visitor); 406 InspectorBaseAgent::trace(visitor);
407 } 407 }
408 408
409 } // namespace blink 409 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698