OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, Google 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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 // Only aria-labelledby and aria-describedby can target hidden elements. | 785 // Only aria-labelledby and aria-describedby can target hidden elements. |
786 if (child->AccessibilityIsIgnored() && attr != aria_labelledbyAttr && | 786 if (child->AccessibilityIsIgnored() && attr != aria_labelledbyAttr && |
787 attr != aria_labeledbyAttr && attr != aria_describedbyAttr) { | 787 attr != aria_labeledbyAttr && attr != aria_describedbyAttr) { |
788 continue; | 788 continue; |
789 } | 789 } |
790 children.push_back(child); | 790 children.push_back(child); |
791 } | 791 } |
792 } | 792 } |
793 } | 793 } |
794 | 794 |
| 795 bool AXNodeObject::IsMultiline() const { |
| 796 Node* node = this->GetNode(); |
| 797 if (!node) |
| 798 return false; |
| 799 |
| 800 const AccessibilityRole role = RoleValue(); |
| 801 const bool is_edit_box = role == kSearchBoxRole || role == kTextFieldRole; |
| 802 if (!IsEditable() && !is_edit_box) |
| 803 return false; // Doesn't support multiline. |
| 804 |
| 805 // Supports aria-multiline, so check for attribute. |
| 806 bool is_multiline = false; |
| 807 if (HasAOMPropertyOrARIAAttribute(AOMBooleanProperty::kMultiline, |
| 808 is_multiline)) { |
| 809 return is_multiline; |
| 810 } |
| 811 |
| 812 // Default for <textarea> is true. |
| 813 if (isHTMLTextAreaElement(*node)) |
| 814 return true; |
| 815 |
| 816 // Default for other edit boxes is false, including for ARIA, says CORE-AAM. |
| 817 if (is_edit_box) |
| 818 return false; |
| 819 |
| 820 // If root of contenteditable area and no ARIA role of textbox/searchbox used, |
| 821 // default to multiline=true which is what the default behavior is. |
| 822 return HasContentEditableAttributeSet(); |
| 823 } |
| 824 |
795 // This only returns true if this is the element that actually has the | 825 // This only returns true if this is the element that actually has the |
796 // contentEditable attribute set, unlike node->hasEditableStyle() which will | 826 // contentEditable attribute set, unlike node->hasEditableStyle() which will |
797 // also return true if an ancestor is editable. | 827 // also return true if an ancestor is editable. |
798 bool AXNodeObject::HasContentEditableAttributeSet() const { | 828 bool AXNodeObject::HasContentEditableAttributeSet() const { |
799 const AtomicString& content_editable_value = | 829 const AtomicString& content_editable_value = |
800 GetAttribute(contenteditableAttr); | 830 GetAttribute(contenteditableAttr); |
801 if (content_editable_value.IsNull()) | 831 if (content_editable_value.IsNull()) |
802 return false; | 832 return false; |
803 // Both "true" (case-insensitive) and the empty string count as true. | 833 // Both "true" (case-insensitive) and the empty string count as true. |
804 return content_editable_value.IsEmpty() || | 834 return content_editable_value.IsEmpty() || |
805 EqualIgnoringASCIICase(content_editable_value, "true"); | 835 EqualIgnoringASCIICase(content_editable_value, "true"); |
806 } | 836 } |
807 | 837 |
| 838 // TODO(aleventhal) Find a more appropriate name or consider returning false |
| 839 // for everything but a searchbox or textfield, as a combobox and spinbox |
| 840 // can contain a field but should not be considered edit controls themselves. |
808 bool AXNodeObject::IsTextControl() const { | 841 bool AXNodeObject::IsTextControl() const { |
809 if (HasContentEditableAttributeSet()) | 842 if (HasContentEditableAttributeSet()) |
810 return true; | 843 return true; |
811 | 844 |
812 switch (RoleValue()) { | 845 switch (RoleValue()) { |
813 case kTextFieldRole: | 846 case kTextFieldRole: |
814 case kComboBoxRole: | 847 case kComboBoxRole: |
815 case kSearchBoxRole: | 848 case kSearchBoxRole: |
816 case kSpinButtonRole: | 849 case kSpinButtonRole: |
817 return true; | 850 return true; |
(...skipping 2440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3258 return String(); | 3291 return String(); |
3259 return ToTextControlElement(node)->StrippedPlaceholder(); | 3292 return ToTextControlElement(node)->StrippedPlaceholder(); |
3260 } | 3293 } |
3261 | 3294 |
3262 DEFINE_TRACE(AXNodeObject) { | 3295 DEFINE_TRACE(AXNodeObject) { |
3263 visitor->Trace(node_); | 3296 visitor->Trace(node_); |
3264 AXObject::Trace(visitor); | 3297 AXObject::Trace(visitor); |
3265 } | 3298 } |
3266 | 3299 |
3267 } // namespace blink | 3300 } // namespace blink |
OLD | NEW |