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

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

Issue 1435113003: Make use of new AX name calc in Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update inspector-protocol test expectations Created 5 years, 1 month 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 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 if (toHTMLOptionElement(node())->isDisabledFormControl()) 131 if (toHTMLOptionElement(node())->isDisabledFormControl())
132 return false; 132 return false;
133 133
134 HTMLSelectElement* selectElement = listBoxOptionParentNode(); 134 HTMLSelectElement* selectElement = listBoxOptionParentNode();
135 if (selectElement && selectElement->isDisabledFormControl()) 135 if (selectElement && selectElement->isDisabledFormControl())
136 return false; 136 return false;
137 137
138 return true; 138 return true;
139 } 139 }
140 140
141 String AXListBoxOption::stringValue() const 141 String AXListBoxOption::textAlternative(bool recursive, bool inAriaLabelledByTra versal, AXObjectSet& visited, AXNameFrom& nameFrom, AXRelatedObjectVector* relat edObjects, NameSources* nameSources) const
142 { 142 {
143 if (!node()) 143 if (!node())
144 return String(); 144 return String();
145 145
146 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); 146 const AtomicString& ariaLabel = getAttribute(aria_labelAttr);
147 if (!ariaLabel.isNull()) 147 if (!ariaLabel.isEmpty()) {
148 nameFrom = AXNameFromAttribute;
149 if (nameSources) {
150 nameSources->append(NameSource(false, aria_labelAttr));
151 nameSources->last().type = nameFrom;
152 nameSources->last().text = ariaLabel;
153 }
148 return ariaLabel; 154 return ariaLabel;
aboxhall 2015/11/16 22:03:28 Note: we shouldn't return immediately if nameSourc
dmazzoni 2015/11/17 17:04:29 Got it. I refactored this out into a new helper,
aboxhall 2015/11/17 20:06:21 Nice.
155 }
149 156
150 if (isHTMLOptionElement(node())) 157 if (!isHTMLOptionElement(node()))
151 return toHTMLOptionElement(node())->displayLabel(); 158 return String();
152 159
153 return String(); 160 nameFrom = AXNameFromContents;
161 if (nameSources) {
162 nameSources->append(NameSource(false));
aboxhall 2015/11/16 22:03:28 Then, this needs to be dependent on whether we fou
dmazzoni 2015/11/17 17:04:29 Done.
163 nameSources->last().type = nameFrom;
164 nameSources->last().text = toHTMLOptionElement(node())->displayLabel();
165 }
166
167 return toHTMLOptionElement(node())->displayLabel();
154 } 168 }
155 169
156 void AXListBoxOption::setSelected(bool selected) 170 void AXListBoxOption::setSelected(bool selected)
157 { 171 {
158 HTMLSelectElement* selectElement = listBoxOptionParentNode(); 172 HTMLSelectElement* selectElement = listBoxOptionParentNode();
159 if (!selectElement) 173 if (!selectElement)
160 return; 174 return;
161 175
162 if (!canSetSelectedAttribute()) 176 if (!canSetSelectedAttribute())
163 return; 177 return;
(...skipping 28 matching lines...) Expand all
192 unsigned length = listItems.size(); 206 unsigned length = listItems.size();
193 for (unsigned i = 0; i < length; i++) { 207 for (unsigned i = 0; i < length; i++) {
194 if (listItems[i] == node()) 208 if (listItems[i] == node())
195 return i; 209 return i;
196 } 210 }
197 211
198 return -1; 212 return -1;
199 } 213 }
200 214
201 } // namespace blink 215 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698