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

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

Issue 1983783002: Remove OwnPtr::release() calls in modules/ (part 1). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/accessibility/InspectorTypeBuilderHelper.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 } 242 }
243 243
244 if (roleAllowsSelected(role)) { 244 if (roleAllowsSelected(role)) {
245 properties->addItem(createProperty(AXWidgetStatesEnum::Selected, createB ooleanValue(axObject->isSelected()))); 245 properties->addItem(createProperty(AXWidgetStatesEnum::Selected, createB ooleanValue(axObject->isSelected())));
246 } 246 }
247 } 247 }
248 248
249 PassOwnPtr<AXProperty> createRelatedNodeListProperty(const String& key, AXRelate dObjectVector& nodes) 249 PassOwnPtr<AXProperty> createRelatedNodeListProperty(const String& key, AXRelate dObjectVector& nodes)
250 { 250 {
251 OwnPtr<AXValue> nodeListValue = createRelatedNodeListValue(nodes, AXValueTyp eEnum::NodeList); 251 OwnPtr<AXValue> nodeListValue = createRelatedNodeListValue(nodes, AXValueTyp eEnum::NodeList);
252 return createProperty(key, nodeListValue.release()); 252 return createProperty(key, std::move(nodeListValue));
253 } 253 }
254 254
255 PassOwnPtr<AXProperty> createRelatedNodeListProperty(const String& key, AXObject ::AXObjectVector& nodes, const QualifiedName& attr, AXObject* axObject) 255 PassOwnPtr<AXProperty> createRelatedNodeListProperty(const String& key, AXObject ::AXObjectVector& nodes, const QualifiedName& attr, AXObject* axObject)
256 { 256 {
257 OwnPtr<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(protocol::StringValue::create(attrValue)); 259 nodeListValue->setValue(protocol::StringValue::create(attrValue));
260 return createProperty(key, nodeListValue.release()); 260 return createProperty(key, std::move(nodeListValue));
261 } 261 }
262 262
263 void fillRelationships(AXObject* axObject, protocol::Array<AXProperty>* properti es) 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(AXRelationshipAttributesEnum::Actived escendant, 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);
(...skipping 19 matching lines...) Expand all
290 290
291 PassOwnPtr<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 OwnPtr<AXValue> roleNameValue; 294 OwnPtr<AXValue> roleNameValue;
295 if (!roleName.isNull()) { 295 if (!roleName.isNull()) {
296 roleNameValue = createValue(roleName, AXValueTypeEnum::Role); 296 roleNameValue = createValue(roleName, AXValueTypeEnum::Role);
297 } else { 297 } else {
298 roleNameValue = createValue(AXObject::internalRoleName(role), AXValueTyp eEnum::InternalRole); 298 roleNameValue = createValue(AXObject::internalRoleName(role), AXValueTyp eEnum::InternalRole);
299 } 299 }
300 return roleNameValue.release(); 300 return roleNameValue;
301 } 301 }
302 302
303 PassOwnPtr<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 OwnPtr<AXNode> ignoredNodeObject = AXNode::create().setNodeId(String::number (axID)).setIgnored(true).build(); 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 OwnPtr<protocol::Array<AXProperty>> ignoredReasonProperties = protocol::Arra y<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.release()); 321 ignoredNodeObject->setIgnoredReasons(std::move(ignoredReasonProperties));
322 322
323 return ignoredNodeObject.release(); 323 return ignoredNodeObject;
324 } 324 }
325 325
326 PassOwnPtr<AXNode> buildObjectForNode(Node* node, AXObject* axObject, AXObjectCa cheImpl* cacheImpl, PassOwnPtr<protocol::Array<AXProperty>> properties) 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 OwnPtr<AXNode> nodeObject = AXNode::create().setNodeId(String::number(axObje ct->axObjectID())).setIgnored(false).build(); 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 OwnPtr<AXValue> name = createValue(computedName, AXValueTypeEnum::Comput edString); 335 OwnPtr<AXValue> name = createValue(computedName, AXValueTypeEnum::Comput edString);
336 if (!nameSources.isEmpty()) { 336 if (!nameSources.isEmpty()) {
337 OwnPtr<protocol::Array<AXValueSource>> nameSourceProperties = protoc ol::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 shipAttributesEnum::Labelledby, nameSource.relatedObjects)); 344 properties->addItem(createRelatedNodeListProperty(AXRelation shipAttributesEnum::Labelledby, nameSource.relatedObjects));
345 } 345 }
346 } 346 }
347 name->setSources(nameSourceProperties.release()); 347 name->setSources(std::move(nameSourceProperties));
348 } 348 }
349 nodeObject->setProperties(std::move(properties)); 349 nodeObject->setProperties(std::move(properties));
350 nodeObject->setName(name.release()); 350 nodeObject->setName(std::move(name));
351 } else { 351 } else {
352 nodeObject->setProperties(std::move(properties)); 352 nodeObject->setProperties(std::move(properties));
353 } 353 }
354 354
355 fillCoreProperties(axObject, nodeObject.get()); 355 fillCoreProperties(axObject, nodeObject.get());
356 return nodeObject.release(); 356 return nodeObject;
357 } 357 }
358 358
359 } // namespace 359 } // namespace
360 360
361 InspectorAccessibilityAgent::InspectorAccessibilityAgent(Page* page, InspectorDO MAgent* domAgent) 361 InspectorAccessibilityAgent::InspectorAccessibilityAgent(Page* page, InspectorDO MAgent* domAgent)
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 , m_domAgent(domAgent) 364 , m_domAgent(domAgent)
365 { 365 {
366 } 366 }
(...skipping 23 matching lines...) Expand all
390 return; 390 return;
391 } 391 }
392 392
393 OwnPtr<protocol::Array<AXProperty>> properties = protocol::Array<AXProperty> ::create(); 393 OwnPtr<protocol::Array<AXProperty>> properties = protocol::Array<AXProperty> ::create();
394 fillLiveRegionProperties(axObject, properties.get()); 394 fillLiveRegionProperties(axObject, properties.get());
395 fillGlobalStates(axObject, properties.get()); 395 fillGlobalStates(axObject, properties.get());
396 fillWidgetProperties(axObject, properties.get()); 396 fillWidgetProperties(axObject, properties.get());
397 fillWidgetStates(axObject, properties.get()); 397 fillWidgetStates(axObject, properties.get());
398 fillRelationships(axObject, properties.get()); 398 fillRelationships(axObject, properties.get());
399 399
400 *accessibilityNode = buildObjectForNode(node, axObject, cacheImpl, propertie s.release()); 400 *accessibilityNode = buildObjectForNode(node, axObject, cacheImpl, std::move (properties));
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 visitor->trace(m_domAgent); 406 visitor->trace(m_domAgent);
407 InspectorBaseAgent::trace(visitor); 407 InspectorBaseAgent::trace(visitor);
408 } 408 }
409 409
410 } // namespace blink 410 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/accessibility/InspectorTypeBuilderHelper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698