OLD | NEW |
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 Loading... |
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 Loading... |
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 // Why this is here instead of AXNodeObject: |
| 410 // Because an AXMenuListOption (<option>) can |
| 411 // have an ARIA role of menuitemcheckbox/menuitemradio |
| 412 // yet does not inherit from AXNodeObject |
| 413 AccessibilityButtonState AXObject::checkedState() const { |
| 414 if (isCheckable() && hasAttribute(aria_checkedAttr)) { |
| 415 const AtomicString& checkedAttribute = getAttribute(aria_checkedAttr); |
| 416 if (equalIgnoringCase(checkedAttribute, "true")) |
| 417 return ButtonStateOn; |
| 418 |
| 419 if (equalIgnoringCase(checkedAttribute, "mixed")) { |
| 420 // Only checkboxes and radios should support the mixed state. |
| 421 const AccessibilityRole role = roleValue(); |
| 422 if (role == CheckBoxRole || role == MenuItemCheckBoxRole || |
| 423 role == RadioButtonRole || role == MenuItemRadioRole) |
| 424 return ButtonStateMixed; |
| 425 } |
| 426 |
| 427 return ButtonStateOff; |
| 428 } |
| 429 |
| 430 const Node* node = this->getNode(); |
| 431 if (!node) |
| 432 return ButtonStateOff; |
| 433 |
| 434 if (isNativeInputInMixedState(node)) |
| 435 return ButtonStateMixed; |
| 436 |
| 437 if (isHTMLInputElement(*node) && |
| 438 toHTMLInputElement(*node).shouldAppearChecked()) { |
| 439 return ButtonStateOn; |
| 440 } |
| 441 |
| 442 return ButtonStateOff; |
| 443 } |
| 444 |
| 445 bool AXObject::isNativeInputInMixedState(const Node* node) { |
| 446 if (!isHTMLInputElement(node)) |
| 447 return false; |
| 448 |
| 449 const HTMLInputElement* input = toHTMLInputElement(node); |
| 450 const auto inputType = input->type(); |
| 451 if (inputType != InputTypeNames::checkbox && |
| 452 inputType != InputTypeNames::radio) |
| 453 return false; |
| 454 return input->shouldAppearIndeterminate(); |
| 455 } |
| 456 |
394 bool AXObject::isLandmarkRelated() const { | 457 bool AXObject::isLandmarkRelated() const { |
395 switch (roleValue()) { | 458 switch (roleValue()) { |
396 case ApplicationRole: | 459 case ApplicationRole: |
397 case ArticleRole: | 460 case ArticleRole: |
398 case BannerRole: | 461 case BannerRole: |
399 case ComplementaryRole: | 462 case ComplementaryRole: |
400 case ContentInfoRole: | 463 case ContentInfoRole: |
401 case FooterRole: | 464 case FooterRole: |
402 case FormRole: | 465 case FormRole: |
403 case MainRole: | 466 case MainRole: |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 switch (roleValue()) { | 985 switch (roleValue()) { |
923 case ButtonRole: | 986 case ButtonRole: |
924 case ToggleButtonRole: | 987 case ToggleButtonRole: |
925 return AXSupportedAction::Press; | 988 return AXSupportedAction::Press; |
926 case TextFieldRole: | 989 case TextFieldRole: |
927 return AXSupportedAction::Activate; | 990 return AXSupportedAction::Activate; |
928 case RadioButtonRole: | 991 case RadioButtonRole: |
929 return AXSupportedAction::Select; | 992 return AXSupportedAction::Select; |
930 case CheckBoxRole: | 993 case CheckBoxRole: |
931 case SwitchRole: | 994 case SwitchRole: |
932 return isChecked() ? AXSupportedAction::Check | 995 return checkedState() == ButtonStateOff |
933 : AXSupportedAction::Uncheck; | 996 ? AXSupportedAction::Check |
| 997 : AXSupportedAction::Uncheck; |
934 case LinkRole: | 998 case LinkRole: |
935 return AXSupportedAction::Jump; | 999 return AXSupportedAction::Jump; |
936 case PopUpButtonRole: | 1000 case PopUpButtonRole: |
937 return AXSupportedAction::Open; | 1001 return AXSupportedAction::Open; |
938 default: | 1002 default: |
939 return AXSupportedAction::Click; | 1003 return AXSupportedAction::Click; |
940 } | 1004 } |
941 } | 1005 } |
942 | 1006 |
943 AccessibilityButtonState AXObject::checkboxOrRadioValue() const { | |
944 const AtomicString& checkedAttribute = getAttribute(aria_checkedAttr); | |
945 if (equalIgnoringCase(checkedAttribute, "true")) | |
946 return ButtonStateOn; | |
947 | |
948 if (equalIgnoringCase(checkedAttribute, "mixed")) { | |
949 // Only checkboxes should support the mixed state. | |
950 AccessibilityRole role = ariaRoleAttribute(); | |
951 if (role == CheckBoxRole || role == MenuItemCheckBoxRole) | |
952 return ButtonStateMixed; | |
953 } | |
954 | |
955 return ButtonStateOff; | |
956 } | |
957 | |
958 bool AXObject::isMultiline() const { | 1007 bool AXObject::isMultiline() const { |
959 Node* node = this->getNode(); | 1008 Node* node = this->getNode(); |
960 if (!node) | 1009 if (!node) |
961 return false; | 1010 return false; |
962 | 1011 |
963 if (isHTMLTextAreaElement(*node)) | 1012 if (isHTMLTextAreaElement(*node)) |
964 return true; | 1013 return true; |
965 | 1014 |
966 if (hasEditableStyle(*node)) | 1015 if (hasEditableStyle(*node)) |
967 return true; | 1016 return true; |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1762 } | 1811 } |
1763 | 1812 |
1764 DEFINE_TRACE(AXObject) { | 1813 DEFINE_TRACE(AXObject) { |
1765 visitor->trace(m_children); | 1814 visitor->trace(m_children); |
1766 visitor->trace(m_parent); | 1815 visitor->trace(m_parent); |
1767 visitor->trace(m_cachedLiveRegionRoot); | 1816 visitor->trace(m_cachedLiveRegionRoot); |
1768 visitor->trace(m_axObjectCache); | 1817 visitor->trace(m_axObjectCache); |
1769 } | 1818 } |
1770 | 1819 |
1771 } // namespace blink | 1820 } // namespace blink |
OLD | NEW |