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

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

Issue 2750533006: Initial skeleton of Accessibility Object Model Phase 1 (Closed)
Patch Set: Created 3 years, 9 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 /* 1 /*
2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 23 matching lines...) Expand all
34 #include "core/editing/EditingUtilities.h" 34 #include "core/editing/EditingUtilities.h"
35 #include "core/editing/VisibleUnits.h" 35 #include "core/editing/VisibleUnits.h"
36 #include "core/frame/FrameView.h" 36 #include "core/frame/FrameView.h"
37 #include "core/frame/LocalFrame.h" 37 #include "core/frame/LocalFrame.h"
38 #include "core/frame/Settings.h" 38 #include "core/frame/Settings.h"
39 #include "core/html/HTMLDialogElement.h" 39 #include "core/html/HTMLDialogElement.h"
40 #include "core/html/HTMLFrameOwnerElement.h" 40 #include "core/html/HTMLFrameOwnerElement.h"
41 #include "core/html/parser/HTMLParserIdioms.h" 41 #include "core/html/parser/HTMLParserIdioms.h"
42 #include "core/layout/LayoutBoxModelObject.h" 42 #include "core/layout/LayoutBoxModelObject.h"
43 #include "modules/accessibility/AXObjectCacheImpl.h" 43 #include "modules/accessibility/AXObjectCacheImpl.h"
44 #include "modules/accessibility/AccessibleNode.h"
44 #include "platform/UserGestureIndicator.h" 45 #include "platform/UserGestureIndicator.h"
45 #include "platform/text/PlatformLocale.h" 46 #include "platform/text/PlatformLocale.h"
46 #include "wtf/HashSet.h" 47 #include "wtf/HashSet.h"
47 #include "wtf/StdLibExtras.h" 48 #include "wtf/StdLibExtras.h"
48 #include "wtf/text/WTFString.h" 49 #include "wtf/text/WTFString.h"
49 50
50 using blink::WebLocalizedString; 51 using blink::WebLocalizedString;
51 52
52 namespace blink { 53 namespace blink {
53 54
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 342
342 unsigned AXObject::s_numberOfLiveAXObjects = 0; 343 unsigned AXObject::s_numberOfLiveAXObjects = 0;
343 344
344 AXObject::AXObject(AXObjectCacheImpl& axObjectCache) 345 AXObject::AXObject(AXObjectCacheImpl& axObjectCache)
345 : m_id(0), 346 : m_id(0),
346 m_haveChildren(false), 347 m_haveChildren(false),
347 m_role(UnknownRole), 348 m_role(UnknownRole),
348 m_lastKnownIsIgnoredValue(DefaultBehavior), 349 m_lastKnownIsIgnoredValue(DefaultBehavior),
349 m_explicitContainerID(0), 350 m_explicitContainerID(0),
350 m_parent(nullptr), 351 m_parent(nullptr),
352 m_accessibleNode(nullptr),
351 m_lastModificationCount(-1), 353 m_lastModificationCount(-1),
352 m_cachedIsIgnored(false), 354 m_cachedIsIgnored(false),
353 m_cachedIsInertOrAriaHidden(false), 355 m_cachedIsInertOrAriaHidden(false),
354 m_cachedIsDescendantOfLeafNode(false), 356 m_cachedIsDescendantOfLeafNode(false),
355 m_cachedIsDescendantOfDisabledNode(false), 357 m_cachedIsDescendantOfDisabledNode(false),
356 m_cachedHasInheritedPresentationalRole(false), 358 m_cachedHasInheritedPresentationalRole(false),
357 m_cachedIsPresentationalChild(false), 359 m_cachedIsPresentationalChild(false),
358 m_cachedAncestorExposesActiveDescendant(false), 360 m_cachedAncestorExposesActiveDescendant(false),
359 m_cachedLiveRegionRoot(nullptr), 361 m_cachedLiveRegionRoot(nullptr),
360 m_axObjectCache(&axObjectCache) { 362 m_axObjectCache(&axObjectCache) {
(...skipping 10 matching lines...) Expand all
371 // no children are left with dangling pointers to their parent. 373 // no children are left with dangling pointers to their parent.
372 clearChildren(); 374 clearChildren();
373 375
374 m_axObjectCache = nullptr; 376 m_axObjectCache = nullptr;
375 } 377 }
376 378
377 bool AXObject::isDetached() const { 379 bool AXObject::isDetached() const {
378 return !m_axObjectCache; 380 return !m_axObjectCache;
379 } 381 }
380 382
383 using AomStringPropertyToAriaMap = HashMap<AomStringProperty,
384 QualifiedName,
385 WTF::IntHash<AomStringProperty>,
386 AomStringPropertyHashTraits>;
387
388 static AomStringPropertyToAriaMap& getAomStringPropertyToAriaMap() {
389 DEFINE_STATIC_LOCAL(AomStringPropertyToAriaMap, map, ());
390 if (map.isEmpty()) {
391 map.set(AomStringProperty::Role, roleAttr);
392 map.set(AomStringProperty::Label, aria_labelAttr);
393 }
394 return map;
395 }
396
397 const AtomicString& AXObject::getAomPropertyOrAriaAttribute(
aboxhall 2017/03/16 05:49:34 maybe just getAuthorDefinedProperty?
dmazzoni 2017/03/16 20:43:14 Hmmm, I wouldn't intuitively know how to interpret
398 AomStringProperty property) const {
399 AccessibleNode* aomNode = getAccessibleNode();
400 if (aomNode) {
aboxhall 2017/03/16 05:49:34 As discussed, swap this and the following block.
dmazzoni 2017/03/16 20:43:15 Done.
401 const AtomicString& result = aomNode->getProperty(property);
402 if (!result.isNull())
403 return result;
404 }
405
406 AomStringPropertyToAriaMap& ariaMap = getAomStringPropertyToAriaMap();
407 QualifiedName attrName = ariaMap.at(property);
408 if (attrName != QualifiedName::null())
409 return getAttribute(attrName);
410
411 return nullAtom;
412 }
413
381 bool AXObject::isARIATextControl() const { 414 bool AXObject::isARIATextControl() const {
382 return ariaRoleAttribute() == TextFieldRole || 415 return ariaRoleAttribute() == TextFieldRole ||
383 ariaRoleAttribute() == SearchBoxRole || 416 ariaRoleAttribute() == SearchBoxRole ||
384 ariaRoleAttribute() == ComboBoxRole; 417 ariaRoleAttribute() == ComboBoxRole;
385 } 418 }
386 419
387 bool AXObject::isButton() const { 420 bool AXObject::isButton() const {
388 AccessibilityRole role = roleValue(); 421 AccessibilityRole role = roleValue();
389 422
390 return role == ButtonRole || role == PopUpButtonRole || 423 return role == ButtonRole || role == PopUpButtonRole ||
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 } 829 }
797 } 830 }
798 831
799 // Step 2C from: http://www.w3.org/TR/accname-aam-1.1 832 // Step 2C from: http://www.w3.org/TR/accname-aam-1.1
800 // If you change this logic, update AXNodeObject::nameFromLabelElement, too. 833 // If you change this logic, update AXNodeObject::nameFromLabelElement, too.
801 nameFrom = AXNameFromAttribute; 834 nameFrom = AXNameFromAttribute;
802 if (nameSources) { 835 if (nameSources) {
803 nameSources->push_back(NameSource(*foundTextAlternative, aria_labelAttr)); 836 nameSources->push_back(NameSource(*foundTextAlternative, aria_labelAttr));
804 nameSources->back().type = nameFrom; 837 nameSources->back().type = nameFrom;
805 } 838 }
806 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); 839 const AtomicString& ariaLabel =
840 getAomPropertyOrAriaAttribute(AomStringProperty::Label);
807 if (!ariaLabel.isEmpty()) { 841 if (!ariaLabel.isEmpty()) {
808 textAlternative = ariaLabel; 842 textAlternative = ariaLabel;
809 843
810 if (nameSources) { 844 if (nameSources) {
811 NameSource& source = nameSources->back(); 845 NameSource& source = nameSources->back();
812 source.text = textAlternative; 846 source.text = textAlternative;
813 source.attributeValue = ariaLabel; 847 source.attributeValue = ariaLabel;
814 *foundTextAlternative = true; 848 *foundTextAlternative = true;
815 } else { 849 } else {
816 *foundTextAlternative = true; 850 *foundTextAlternative = true;
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 createInternalRoleNameVector(); 1793 createInternalRoleNameVector();
1760 1794
1761 return internalRoleNameVector->at(role); 1795 return internalRoleNameVector->at(role);
1762 } 1796 }
1763 1797
1764 DEFINE_TRACE(AXObject) { 1798 DEFINE_TRACE(AXObject) {
1765 visitor->trace(m_children); 1799 visitor->trace(m_children);
1766 visitor->trace(m_parent); 1800 visitor->trace(m_parent);
1767 visitor->trace(m_cachedLiveRegionRoot); 1801 visitor->trace(m_cachedLiveRegionRoot);
1768 visitor->trace(m_axObjectCache); 1802 visitor->trace(m_axObjectCache);
1803 visitor->trace(m_accessibleNode);
1769 } 1804 }
1770 1805
1771 } // namespace blink 1806 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698