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

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

Issue 2931893002: More precise use of multiline state (Closed)
Patch Set: Fix typo Created 3 years, 5 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) 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
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 i false, including for ARIA, says CORE-AAM.
David Tseng 2017/06/27 18:41:14 nit: is
817 if (is_edit_box)
818 return false;
819
820 // Root of contenteditable area.
821 return HasContentEditableAttributeSet();
822 }
823
795 // This only returns true if this is the element that actually has the 824 // This only returns true if this is the element that actually has the
796 // contentEditable attribute set, unlike node->hasEditableStyle() which will 825 // contentEditable attribute set, unlike node->hasEditableStyle() which will
797 // also return true if an ancestor is editable. 826 // also return true if an ancestor is editable.
798 bool AXNodeObject::HasContentEditableAttributeSet() const { 827 bool AXNodeObject::HasContentEditableAttributeSet() const {
799 const AtomicString& content_editable_value = 828 const AtomicString& content_editable_value =
800 GetAttribute(contenteditableAttr); 829 GetAttribute(contenteditableAttr);
801 if (content_editable_value.IsNull()) 830 if (content_editable_value.IsNull())
802 return false; 831 return false;
803 // Both "true" (case-insensitive) and the empty string count as true. 832 // Both "true" (case-insensitive) and the empty string count as true.
804 return content_editable_value.IsEmpty() || 833 return content_editable_value.IsEmpty() ||
805 EqualIgnoringASCIICase(content_editable_value, "true"); 834 EqualIgnoringASCIICase(content_editable_value, "true");
806 } 835 }
807 836
837 // TODO(aleventhal) Find a more appropriate name or consider returning false
838 // for everything but a searchbox or textfield, as a combobox and spinbox
839 // can contain a field but should not be considered edit controls themselves.
David Tseng 2017/06/27 18:41:14 Why not? <input type="text" role="combobox"> has n
808 bool AXNodeObject::IsTextControl() const { 840 bool AXNodeObject::IsTextControl() const {
809 if (HasContentEditableAttributeSet()) 841 if (HasContentEditableAttributeSet())
810 return true; 842 return true;
811 843
812 switch (RoleValue()) { 844 switch (RoleValue()) {
813 case kTextFieldRole: 845 case kTextFieldRole:
814 case kComboBoxRole: 846 case kComboBoxRole:
815 case kSearchBoxRole: 847 case kSearchBoxRole:
816 case kSpinButtonRole: 848 case kSpinButtonRole:
817 return true; 849 return true;
(...skipping 2440 matching lines...) Expand 10 before | Expand all | Expand 10 after
3258 return String(); 3290 return String();
3259 return ToTextControlElement(node)->StrippedPlaceholder(); 3291 return ToTextControlElement(node)->StrippedPlaceholder();
3260 } 3292 }
3261 3293
3262 DEFINE_TRACE(AXNodeObject) { 3294 DEFINE_TRACE(AXNodeObject) {
3263 visitor->Trace(node_); 3295 visitor->Trace(node_);
3264 AXObject::Trace(visitor); 3296 AXObject::Trace(visitor);
3265 } 3297 }
3266 3298
3267 } // namespace blink 3299 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698