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

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

Issue 2694903010: AX checked state changes (Closed)
Patch Set: git cl try Created 3 years, 8 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 11 matching lines...) Expand all
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "modules/accessibility/AXObject.h" 29 #include "modules/accessibility/AXObject.h"
30 30
31 #include "SkMatrix44.h" 31 #include "SkMatrix44.h"
32 #include "core/InputTypeNames.h"
32 #include "core/css/resolver/StyleResolver.h" 33 #include "core/css/resolver/StyleResolver.h"
33 #include "core/dom/AccessibleNode.h" 34 #include "core/dom/AccessibleNode.h"
34 #include "core/dom/DocumentUserGestureToken.h" 35 #include "core/dom/DocumentUserGestureToken.h"
35 #include "core/editing/EditingUtilities.h" 36 #include "core/editing/EditingUtilities.h"
36 #include "core/editing/VisibleUnits.h" 37 #include "core/editing/VisibleUnits.h"
37 #include "core/frame/FrameView.h" 38 #include "core/frame/FrameView.h"
38 #include "core/frame/LocalFrame.h" 39 #include "core/frame/LocalFrame.h"
39 #include "core/frame/Settings.h" 40 #include "core/frame/Settings.h"
40 #include "core/html/HTMLDialogElement.h" 41 #include "core/html/HTMLDialogElement.h"
41 #include "core/html/HTMLFrameOwnerElement.h" 42 #include "core/html/HTMLFrameOwnerElement.h"
43 #include "core/html/HTMLInputElement.h"
42 #include "core/html/parser/HTMLParserIdioms.h" 44 #include "core/html/parser/HTMLParserIdioms.h"
43 #include "core/layout/LayoutBoxModelObject.h" 45 #include "core/layout/LayoutBoxModelObject.h"
44 #include "modules/accessibility/AXObjectCacheImpl.h" 46 #include "modules/accessibility/AXObjectCacheImpl.h"
45 #include "platform/UserGestureIndicator.h" 47 #include "platform/UserGestureIndicator.h"
46 #include "platform/text/PlatformLocale.h" 48 #include "platform/text/PlatformLocale.h"
47 #include "platform/wtf/HashSet.h" 49 #include "platform/wtf/HashSet.h"
48 #include "platform/wtf/StdLibExtras.h" 50 #include "platform/wtf/StdLibExtras.h"
49 #include "platform/wtf/text/WTFString.h" 51 #include "platform/wtf/text/WTFString.h"
50 52
51 using blink::WebLocalizedString; 53 using blink::WebLocalizedString;
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 AriaRoleAttribute() == kComboBoxRole; 398 AriaRoleAttribute() == kComboBoxRole;
397 } 399 }
398 400
399 bool AXObject::IsButton() const { 401 bool AXObject::IsButton() const {
400 AccessibilityRole role = RoleValue(); 402 AccessibilityRole role = RoleValue();
401 403
402 return role == kButtonRole || role == kPopUpButtonRole || 404 return role == kButtonRole || role == kPopUpButtonRole ||
403 role == kToggleButtonRole; 405 role == kToggleButtonRole;
404 } 406 }
405 407
408 bool AXObject::IsCheckable() const {
409 switch (RoleValue()) {
410 case kCheckBoxRole:
411 case kMenuItemCheckBoxRole:
412 case kMenuItemRadioRole:
413 case kRadioButtonRole:
414 case kSwitchRole:
415 return true;
416 default:
417 return false;
418 }
419 }
420
421 // Why this is here instead of AXNodeObject:
422 // Because an AXMenuListOption (<option>) can
423 // have an ARIA role of menuitemcheckbox/menuitemradio
424 // yet does not inherit from AXNodeObject
425 AccessibilityButtonState AXObject::CheckedState() const {
426 if (!IsCheckable())
427 return kButtonStateOff;
428
429 const AtomicString& checkedAttribute =
430 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kChecked);
431 if (checkedAttribute) {
432 if (EqualIgnoringASCIICase(checkedAttribute, "true"))
433 return kButtonStateOn;
434
435 if (EqualIgnoringASCIICase(checkedAttribute, "mixed")) {
436 // Only checkboxes and radios should support the mixed state.
437 const AccessibilityRole role = RoleValue();
438 if (role == kCheckBoxRole || role == kMenuItemCheckBoxRole ||
439 role == kRadioButtonRole || role == kMenuItemRadioRole)
440 return kButtonStateMixed;
441 }
442
443 return kButtonStateOff;
444 }
445
446 const Node* node = this->GetNode();
447 if (!node)
448 return kButtonStateOff;
449
450 if (IsNativeInputInMixedState(node))
451 return kButtonStateMixed;
452
453 if (isHTMLInputElement(*node) &&
454 toHTMLInputElement(*node).ShouldAppearChecked()) {
455 return kButtonStateOn;
456 }
457
458 return kButtonStateOff;
459 }
460
461 bool AXObject::IsNativeInputInMixedState(const Node* node) {
462 if (!isHTMLInputElement(node))
463 return false;
464
465 const HTMLInputElement* input = toHTMLInputElement(node);
466 const auto inputType = input->type();
467 if (inputType != InputTypeNames::checkbox &&
468 inputType != InputTypeNames::radio)
469 return false;
470 return input->ShouldAppearIndeterminate();
471 }
472
406 bool AXObject::IsLandmarkRelated() const { 473 bool AXObject::IsLandmarkRelated() const {
407 switch (RoleValue()) { 474 switch (RoleValue()) {
408 case kApplicationRole: 475 case kApplicationRole:
409 case kArticleRole: 476 case kArticleRole:
410 case kBannerRole: 477 case kBannerRole:
411 case kComplementaryRole: 478 case kComplementaryRole:
412 case kContentInfoRole: 479 case kContentInfoRole:
413 case kFooterRole: 480 case kFooterRole:
414 case kFormRole: 481 case kFormRole:
415 case kMainRole: 482 case kMainRole:
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 switch (RoleValue()) { 1006 switch (RoleValue()) {
940 case kButtonRole: 1007 case kButtonRole:
941 case kToggleButtonRole: 1008 case kToggleButtonRole:
942 return AXSupportedAction::kPress; 1009 return AXSupportedAction::kPress;
943 case kTextFieldRole: 1010 case kTextFieldRole:
944 return AXSupportedAction::kActivate; 1011 return AXSupportedAction::kActivate;
945 case kRadioButtonRole: 1012 case kRadioButtonRole:
946 return AXSupportedAction::kSelect; 1013 return AXSupportedAction::kSelect;
947 case kCheckBoxRole: 1014 case kCheckBoxRole:
948 case kSwitchRole: 1015 case kSwitchRole:
949 return IsChecked() ? AXSupportedAction::kCheck 1016 return CheckedState() == kButtonStateOff ? AXSupportedAction::kCheck
950 : AXSupportedAction::kUncheck; 1017 : AXSupportedAction::kUncheck;
951 case kLinkRole: 1018 case kLinkRole:
952 return AXSupportedAction::kJump; 1019 return AXSupportedAction::kJump;
953 case kPopUpButtonRole: 1020 case kPopUpButtonRole:
954 return AXSupportedAction::kOpen; 1021 return AXSupportedAction::kOpen;
955 default: 1022 default:
956 return AXSupportedAction::kClick; 1023 return AXSupportedAction::kClick;
957 } 1024 }
958 } 1025 }
959 1026
960 AccessibilityButtonState AXObject::CheckboxOrRadioValue() const {
961 const AtomicString& checked_attribute =
962 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kChecked);
963 if (EqualIgnoringASCIICase(checked_attribute, "true"))
964 return kButtonStateOn;
965
966 if (EqualIgnoringASCIICase(checked_attribute, "mixed")) {
967 // Only checkboxes should support the mixed state.
968 AccessibilityRole role = AriaRoleAttribute();
969 if (role == kCheckBoxRole || role == kMenuItemCheckBoxRole)
970 return kButtonStateMixed;
971 }
972
973 return kButtonStateOff;
974 }
975
976 bool AXObject::IsMultiline() const { 1027 bool AXObject::IsMultiline() const {
977 Node* node = this->GetNode(); 1028 Node* node = this->GetNode();
978 if (!node) 1029 if (!node)
979 return false; 1030 return false;
980 1031
981 if (isHTMLTextAreaElement(*node)) 1032 if (isHTMLTextAreaElement(*node))
982 return true; 1033 return true;
983 1034
984 if (HasEditableStyle(*node)) 1035 if (HasEditableStyle(*node))
985 return true; 1036 return true;
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 } 1862 }
1812 1863
1813 DEFINE_TRACE(AXObject) { 1864 DEFINE_TRACE(AXObject) {
1814 visitor->Trace(children_); 1865 visitor->Trace(children_);
1815 visitor->Trace(parent_); 1866 visitor->Trace(parent_);
1816 visitor->Trace(cached_live_region_root_); 1867 visitor->Trace(cached_live_region_root_);
1817 visitor->Trace(ax_object_cache_); 1868 visitor->Trace(ax_object_cache_);
1818 } 1869 }
1819 1870
1820 } // namespace blink 1871 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698