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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 } else { | 351 } else { |
352 nodeObject->setProperties(properties); | 352 nodeObject->setProperties(properties); |
353 } | 353 } |
354 | 354 |
355 fillCoreProperties(axObject, nodeObject.get()); | 355 fillCoreProperties(axObject, nodeObject.get()); |
356 return nodeObject.release(); | 356 return nodeObject.release(); |
357 } | 357 } |
358 | 358 |
359 } // namespace | 359 } // namespace |
360 | 360 |
361 InspectorAccessibilityAgent::InspectorAccessibilityAgent(Page* page) | 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 { | 365 { |
365 } | 366 } |
366 | 367 |
367 void InspectorAccessibilityAgent::getAXNode(ErrorString* errorString, int nodeId
, Maybe<AXNode>* accessibilityNode) | 368 void InspectorAccessibilityAgent::getAXNode(ErrorString* errorString, int nodeId
, Maybe<AXNode>* accessibilityNode) |
368 { | 369 { |
369 Frame* mainFrame = m_page->mainFrame(); | 370 Frame* mainFrame = m_page->mainFrame(); |
370 if (!mainFrame->isLocalFrame()) { | 371 if (!mainFrame->isLocalFrame()) { |
371 *errorString = "Can't inspect out of process frames yet"; | 372 *errorString = "Can't inspect out of process frames yet"; |
372 return; | 373 return; |
373 } | 374 } |
374 | 375 |
375 InspectorDOMAgent* domAgent = toLocalFrame(mainFrame)->instrumentingAgents()
->inspectorDOMAgent(); | 376 if (!m_domAgent->enabled()) { |
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 = m_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 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, 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 visitor->trace(m_domAgent); |
406 InspectorBaseAgent::trace(visitor); | 407 InspectorBaseAgent::trace(visitor); |
407 } | 408 } |
408 | 409 |
409 } // namespace blink | 410 } // namespace blink |
OLD | NEW |