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

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

Issue 2694903010: AX checked state changes (Closed)
Patch Set: Remove whitespace change Created 3 years, 10 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 20 matching lines...) Expand all
31 #include "SkMatrix44.h" 31 #include "SkMatrix44.h"
32 #include "core/css/resolver/StyleResolver.h" 32 #include "core/css/resolver/StyleResolver.h"
33 #include "core/dom/DocumentUserGestureToken.h" 33 #include "core/dom/DocumentUserGestureToken.h"
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/HTMLInputElement.h"
41 #include "core/html/parser/HTMLParserIdioms.h" 42 #include "core/html/parser/HTMLParserIdioms.h"
43 #include "core/InputTypeNames.h"
42 #include "core/layout/LayoutBoxModelObject.h" 44 #include "core/layout/LayoutBoxModelObject.h"
43 #include "modules/accessibility/AXObjectCacheImpl.h" 45 #include "modules/accessibility/AXObjectCacheImpl.h"
44 #include "platform/UserGestureIndicator.h" 46 #include "platform/UserGestureIndicator.h"
45 #include "platform/text/PlatformLocale.h" 47 #include "platform/text/PlatformLocale.h"
46 #include "wtf/HashSet.h" 48 #include "wtf/HashSet.h"
47 #include "wtf/StdLibExtras.h" 49 #include "wtf/StdLibExtras.h"
48 #include "wtf/text/WTFString.h" 50 #include "wtf/text/WTFString.h"
49 51
50 using blink::WebLocalizedString; 52 using blink::WebLocalizedString;
51 53
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 ariaRoleAttribute() == ComboBoxRole; 386 ariaRoleAttribute() == ComboBoxRole;
385 } 387 }
386 388
387 bool AXObject::isButton() const { 389 bool AXObject::isButton() const {
388 AccessibilityRole role = roleValue(); 390 AccessibilityRole role = roleValue();
389 391
390 return role == ButtonRole || role == PopUpButtonRole || 392 return role == ButtonRole || role == PopUpButtonRole ||
391 role == ToggleButtonRole; 393 role == ToggleButtonRole;
392 } 394 }
393 395
396 bool AXObject::isCheckable() const {
397 switch (roleValue()) {
398 case CheckBoxRole:
399 case MenuItemCheckBoxRole:
400 case MenuItemRadioRole:
401 case RadioButtonRole:
402 case SwitchRole:
403 return true;
404 default:
405 return false;
406 }
407 }
408
409 bool AXObject::isChecked() const {
410 return checkboxOrRadioState() == ButtonStateOn;
411 }
412
413 // Why this is here instead of AXNodeObject:
414 // Because an AXMenuListOption (<option>) can
415 // have an ARIA role of menuitemcheckbox/menuitemradio
416 // yet does not inherit from AXNodeObject
417 AccessibilityButtonState AXObject::checkboxOrRadioState() const {
418 if (isCheckable() && hasAttribute(aria_checkedAttr)) {
419 const AtomicString& checkedAttribute = getAttribute(aria_checkedAttr);
420 if (equalIgnoringCase(checkedAttribute, "true"))
421 return ButtonStateOn;
422
423 if (equalIgnoringCase(checkedAttribute, "mixed")) {
424 // Only checkboxes should support the mixed state.
dmazzoni 2017/02/16 20:56:04 This comment disagrees with the code below
aleventhal 2017/02/24 21:44:02 Done.
425 const AccessibilityRole role = roleValue();
426 if (role == CheckBoxRole || role == MenuItemCheckBoxRole ||
dmazzoni 2017/02/16 20:56:04 Is the set of roles checked here different than th
aleventhal 2017/02/24 21:44:02 Yes, it doesn't include the Switch role.
427 role == RadioButtonRole || role == MenuItemRadioRole)
428 return ButtonStateMixed;
429 }
430
431 return ButtonStateOff;
432 }
433
434 const Node* node = this->getNode();
435 if (!node)
436 return ButtonStateOff;
437
438 if (isNativeInputInMixedState(node))
439 return ButtonStateMixed;
440
441 if (isHTMLInputElement(*node) &&
442 toHTMLInputElement(*node).shouldAppearChecked()) {
443 return ButtonStateOn;
444 }
445
446 return ButtonStateOff;
447 }
448
449 bool AXObject::isNativeInputInMixedState(const Node* node) {
450 if (!isHTMLInputElement(node))
451 return false;
452
453 const HTMLInputElement* input = toHTMLInputElement(node);
454 const auto inputType = input->type();
455 if (inputType != InputTypeNames::checkbox &&
456 inputType != InputTypeNames::radio)
457 return false;
458 return input->shouldAppearIndeterminate();
dmazzoni 2017/02/16 20:56:04 Is it necessary to check the type? I wonder if sho
aleventhal 2017/02/24 21:44:01 It doesn't right now. What do you think about keep
459 }
460
394 bool AXObject::isLandmarkRelated() const { 461 bool AXObject::isLandmarkRelated() const {
395 switch (roleValue()) { 462 switch (roleValue()) {
396 case ApplicationRole: 463 case ApplicationRole:
397 case ArticleRole: 464 case ArticleRole:
398 case BannerRole: 465 case BannerRole:
399 case ComplementaryRole: 466 case ComplementaryRole:
400 case ContentInfoRole: 467 case ContentInfoRole:
401 case FooterRole: 468 case FooterRole:
402 case FormRole: 469 case FormRole:
403 case MainRole: 470 case MainRole:
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 : AXSupportedAction::Uncheck; 997 : AXSupportedAction::Uncheck;
931 case LinkRole: 998 case LinkRole:
932 return AXSupportedAction::Jump; 999 return AXSupportedAction::Jump;
933 case PopUpButtonRole: 1000 case PopUpButtonRole:
934 return AXSupportedAction::Open; 1001 return AXSupportedAction::Open;
935 default: 1002 default:
936 return AXSupportedAction::Click; 1003 return AXSupportedAction::Click;
937 } 1004 }
938 } 1005 }
939 1006
940 AccessibilityButtonState AXObject::checkboxOrRadioValue() const {
941 const AtomicString& checkedAttribute = getAttribute(aria_checkedAttr);
942 if (equalIgnoringCase(checkedAttribute, "true"))
943 return ButtonStateOn;
944
945 if (equalIgnoringCase(checkedAttribute, "mixed")) {
946 // Only checkboxes should support the mixed state.
947 AccessibilityRole role = ariaRoleAttribute();
948 if (role == CheckBoxRole || role == MenuItemCheckBoxRole)
949 return ButtonStateMixed;
950 }
951
952 return ButtonStateOff;
953 }
954
955 bool AXObject::isMultiline() const { 1007 bool AXObject::isMultiline() const {
956 Node* node = this->getNode(); 1008 Node* node = this->getNode();
957 if (!node) 1009 if (!node)
958 return false; 1010 return false;
959 1011
960 if (isHTMLTextAreaElement(*node)) 1012 if (isHTMLTextAreaElement(*node))
961 return true; 1013 return true;
962 1014
963 if (hasEditableStyle(*node)) 1015 if (hasEditableStyle(*node))
964 return true; 1016 return true;
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 } 1811 }
1760 1812
1761 DEFINE_TRACE(AXObject) { 1813 DEFINE_TRACE(AXObject) {
1762 visitor->trace(m_children); 1814 visitor->trace(m_children);
1763 visitor->trace(m_parent); 1815 visitor->trace(m_parent);
1764 visitor->trace(m_cachedLiveRegionRoot); 1816 visitor->trace(m_cachedLiveRegionRoot);
1765 visitor->trace(m_axObjectCache); 1817 visitor->trace(m_axObjectCache);
1766 } 1818 }
1767 1819
1768 } // namespace blink 1820 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698