Changeset 239986 in webkit
- Timestamp:
- Jan 15, 2019, 8:28:37 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/audit/run-accessibility-expected.txt (added)
-
LayoutTests/inspector/audit/run-accessibility.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/inspector/InspectorAuditAccessibilityObject.cpp (modified) (1 diff)
-
Source/WebCore/inspector/InspectorAuditAccessibilityObject.h (modified) (2 diffs)
-
Source/WebCore/inspector/InspectorAuditAccessibilityObject.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r239983 r239986 1 2019-01-15 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Audit: provide a way to query for all nodes with a given computed Accessibility role 4 https://bugs.webkit.org/show_bug.cgi?id=193228 5 <rdar://problem/46787787> 6 7 Reviewed by Joseph Pecoraro. 8 9 * inspector/audit/run-accessibility.html: Added. 10 * inspector/audit/run-accessibility-expected.txt: Added. 11 1 12 2019-01-15 Zalan Bujtas <zalan@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r239985 r239986 1 2019-01-15 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Audit: provide a way to query for all nodes with a given computed Accessibility role 4 https://bugs.webkit.org/show_bug.cgi?id=193228 5 <rdar://problem/46787787> 6 7 Reviewed by Joseph Pecoraro. 8 9 Test: inspector/audit/run-accessibility.html 10 11 * inspector/InspectorAuditAccessibilityObject.idl: 12 * inspector/InspectorAuditAccessibilityObject.h: 13 * inspector/InspectorAuditAccessibilityObject.cpp: 14 (WebCore::accessiblityObjectForNode): Added. 15 (WebCore::InspectorAuditAccessibilityObject::getElementsByComputedRole): Added. 16 1 17 2019-01-15 Simon Fraser <simon.fraser@apple.com> 2 18 -
trunk/Source/WebCore/inspector/InspectorAuditAccessibilityObject.cpp
r239976 r239986 28 28 #include "InspectorAuditAccessibilityObject.h" 29 29 30 #include "AXObjectCache.h" 31 #include "AccessibilityObject.h" 32 #include "ContainerNode.h" 33 #include "Document.h" 34 #include "ElementDescendantIterator.h" 35 #include "Node.h" 36 #include <wtf/Vector.h> 37 30 38 namespace WebCore { 31 39 32 40 using namespace Inspector; 33 41 34 InspectorAuditAccessibilityObject::InspectorAuditAccessibilityObject() 42 #define ERROR_IF_NO_ACTIVE_AUDIT() \ 43 if (!m_auditAgent.hasActiveAudit()) \ 44 return Exception { NotAllowedError, "Cannot be called outside of a Web Inspector Audit"_s }; 45 46 InspectorAuditAccessibilityObject::InspectorAuditAccessibilityObject(InspectorAuditAgent& auditAgent) 47 : m_auditAgent(auditAgent) 35 48 { 36 49 } 37 50 51 static AccessibilityObject* accessiblityObjectForNode(Node& node) 52 { 53 if (!AXObjectCache::accessibilityEnabled()) 54 AXObjectCache::enableAccessibility(); 55 56 if (AXObjectCache* axObjectCache = node.document().axObjectCache()) 57 return axObjectCache->getOrCreate(&node); 58 59 return nullptr; 60 } 61 62 ExceptionOr<Vector<Ref<Node>>> InspectorAuditAccessibilityObject::getElementsByComputedRole(Document& document, const String& role, Node* container) 63 { 64 ERROR_IF_NO_ACTIVE_AUDIT(); 65 66 Vector<Ref<Node>> nodes; 67 68 for (Element& element : elementDescendants(is<ContainerNode>(container) ? downcast<ContainerNode>(*container) : document)) { 69 if (AccessibilityObject* axObject = accessiblityObjectForNode(element)) { 70 if (axObject->computedRoleString() == role) 71 nodes.append(element); 72 } 73 } 74 75 return nodes; 76 } 77 38 78 } // namespace WebCore -
trunk/Source/WebCore/inspector/InspectorAuditAccessibilityObject.h
r239976 r239986 26 26 #pragma once 27 27 28 #include "ExceptionOr.h" 28 29 #include <JavaScriptCore/InspectorAuditAgent.h> 30 #include <wtf/Forward.h> 29 31 #include <wtf/Ref.h> 30 32 #include <wtf/RefCounted.h> … … 32 34 namespace WebCore { 33 35 36 class Document; 37 class Node; 38 34 39 class InspectorAuditAccessibilityObject : public RefCounted<InspectorAuditAccessibilityObject> { 35 40 public: 36 static Ref<InspectorAuditAccessibilityObject> create(Inspector::InspectorAuditAgent& )41 static Ref<InspectorAuditAccessibilityObject> create(Inspector::InspectorAuditAgent& auditAgent) 37 42 { 38 return adoptRef(*new InspectorAuditAccessibilityObject( ));43 return adoptRef(*new InspectorAuditAccessibilityObject(auditAgent)); 39 44 } 40 45 46 ExceptionOr<Vector<Ref<Node>>> getElementsByComputedRole(Document&, const String& role, Node* container); 47 41 48 private: 42 explicit InspectorAuditAccessibilityObject(); 49 explicit InspectorAuditAccessibilityObject(Inspector::InspectorAuditAgent&); 50 51 Inspector::InspectorAuditAgent& m_auditAgent; 43 52 }; 44 53 -
trunk/Source/WebCore/inspector/InspectorAuditAccessibilityObject.idl
r239976 r239986 29 29 NoInterfaceObject, 30 30 ] interface InspectorAuditAccessibilityObject { 31 [CallWith=Document, MayThrowException] sequence<Node> getElementsByComputedRole(DOMString role, optional Node? container); 31 32 };
Note:
See TracChangeset
for help on using the changeset viewer.