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

Side by Side Diff: Source/core/accessibility/AccessibilityListBoxOption.cpp

Issue 18970003: Introduce isHTMLOptGroupElement and toHTMLOptGroupElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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
« no previous file with comments | « no previous file | Source/core/css/SelectorChecker.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 PassRefPtr<AccessibilityListBoxOption> AccessibilityListBoxOption::create() 53 PassRefPtr<AccessibilityListBoxOption> AccessibilityListBoxOption::create()
54 { 54 {
55 return adoptRef(new AccessibilityListBoxOption()); 55 return adoptRef(new AccessibilityListBoxOption());
56 } 56 }
57 57
58 bool AccessibilityListBoxOption::isEnabled() const 58 bool AccessibilityListBoxOption::isEnabled() const
59 { 59 {
60 if (!m_optionElement) 60 if (!m_optionElement)
61 return false; 61 return false;
62 62
63 if (m_optionElement->hasTagName(optgroupTag)) 63 if (isHTMLOptGroupElement(m_optionElement))
64 return false; 64 return false;
65 65
66 if (equalIgnoringCase(getAttribute(aria_disabledAttr), "true")) 66 if (equalIgnoringCase(getAttribute(aria_disabledAttr), "true"))
67 return false; 67 return false;
68 68
69 if (m_optionElement->hasAttribute(disabledAttr)) 69 if (m_optionElement->hasAttribute(disabledAttr))
70 return false; 70 return false;
71 71
72 return true; 72 return true;
73 } 73 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 { 147 {
148 if (!m_optionElement) 148 if (!m_optionElement)
149 return String(); 149 return String();
150 150
151 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); 151 const AtomicString& ariaLabel = getAttribute(aria_labelAttr);
152 if (!ariaLabel.isNull()) 152 if (!ariaLabel.isNull())
153 return ariaLabel; 153 return ariaLabel;
154 154
155 if (m_optionElement->hasTagName(optionTag)) 155 if (m_optionElement->hasTagName(optionTag))
156 return toHTMLOptionElement(m_optionElement)->text(); 156 return toHTMLOptionElement(m_optionElement)->text();
157 157
158 if (m_optionElement->hasTagName(optgroupTag)) 158 if (isHTMLOptGroupElement(m_optionElement))
159 return static_cast<HTMLOptGroupElement*>(m_optionElement)->groupLabelTex t(); 159 return toHTMLOptGroupElement(m_optionElement)->groupLabelText();
160 160
161 return String(); 161 return String();
162 } 162 }
163 163
164 Element* AccessibilityListBoxOption::actionElement() const 164 Element* AccessibilityListBoxOption::actionElement() const
165 { 165 {
166 return m_optionElement; 166 return m_optionElement;
167 } 167 }
168 168
169 AccessibilityObject* AccessibilityListBoxOption::parentObject() const 169 AccessibilityObject* AccessibilityListBoxOption::parentObject() const
170 { 170 {
(...skipping 22 matching lines...) Expand all
193 selectElement->accessKeySetSelectedIndex(optionIndex); 193 selectElement->accessKeySetSelectedIndex(optionIndex);
194 } 194 }
195 195
196 HTMLSelectElement* AccessibilityListBoxOption::listBoxOptionParentNode() const 196 HTMLSelectElement* AccessibilityListBoxOption::listBoxOptionParentNode() const
197 { 197 {
198 if (!m_optionElement) 198 if (!m_optionElement)
199 return 0; 199 return 0;
200 200
201 if (m_optionElement->hasTagName(optionTag)) 201 if (m_optionElement->hasTagName(optionTag))
202 return toHTMLOptionElement(m_optionElement)->ownerSelectElement(); 202 return toHTMLOptionElement(m_optionElement)->ownerSelectElement();
203 203
204 if (m_optionElement->hasTagName(optgroupTag)) 204 if (isHTMLOptGroupElement(m_optionElement))
205 return static_cast<HTMLOptGroupElement*>(m_optionElement)->ownerSelectEl ement(); 205 return toHTMLOptGroupElement(m_optionElement)->ownerSelectElement();
206 206
207 return 0; 207 return 0;
208 } 208 }
209 209
210 int AccessibilityListBoxOption::listBoxOptionIndex() const 210 int AccessibilityListBoxOption::listBoxOptionIndex() const
211 { 211 {
212 if (!m_optionElement) 212 if (!m_optionElement)
213 return -1; 213 return -1;
214 214
215 HTMLSelectElement* selectElement = listBoxOptionParentNode(); 215 HTMLSelectElement* selectElement = listBoxOptionParentNode();
216 if (!selectElement) 216 if (!selectElement)
217 return -1; 217 return -1;
218 218
219 const Vector<HTMLElement*>& listItems = selectElement->listItems(); 219 const Vector<HTMLElement*>& listItems = selectElement->listItems();
220 unsigned length = listItems.size(); 220 unsigned length = listItems.size();
221 for (unsigned i = 0; i < length; i++) 221 for (unsigned i = 0; i < length; i++)
222 if (listItems[i] == m_optionElement) 222 if (listItems[i] == m_optionElement)
223 return i; 223 return i;
224 224
225 return -1; 225 return -1;
226 } 226 }
227 227
228 } // namespace WebCore 228 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/SelectorChecker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698