| OLD | NEW |
| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| 74 | 74 |
| 75 bool AXListBoxOption::isSelected() const | 75 bool AXListBoxOption::isSelected() const |
| 76 { | 76 { |
| 77 if (!m_optionElement) | 77 if (!isHTMLOptionElement(m_optionElement)) |
| 78 return false; | |
| 79 | |
| 80 if (!m_optionElement->hasTagName(optionTag)) | |
| 81 return false; | 78 return false; |
| 82 | 79 |
| 83 return toHTMLOptionElement(m_optionElement)->selected(); | 80 return toHTMLOptionElement(m_optionElement)->selected(); |
| 84 } | 81 } |
| 85 | 82 |
| 86 bool AXListBoxOption::isSelectedOptionActive() const | 83 bool AXListBoxOption::isSelectedOptionActive() const |
| 87 { | 84 { |
| 88 HTMLSelectElement* listBoxParentNode = listBoxOptionParentNode(); | 85 HTMLSelectElement* listBoxParentNode = listBoxOptionParentNode(); |
| 89 if (!listBoxParentNode) | 86 if (!listBoxParentNode) |
| 90 return false; | 87 return false; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 142 |
| 146 String AXListBoxOption::stringValue() const | 143 String AXListBoxOption::stringValue() const |
| 147 { | 144 { |
| 148 if (!m_optionElement) | 145 if (!m_optionElement) |
| 149 return String(); | 146 return String(); |
| 150 | 147 |
| 151 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); | 148 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); |
| 152 if (!ariaLabel.isNull()) | 149 if (!ariaLabel.isNull()) |
| 153 return ariaLabel; | 150 return ariaLabel; |
| 154 | 151 |
| 155 if (m_optionElement->hasTagName(optionTag)) | 152 if (isHTMLOptionElement(*m_optionElement)) |
| 156 return toHTMLOptionElement(m_optionElement)->text(); | 153 return toHTMLOptionElement(m_optionElement)->text(); |
| 157 | 154 |
| 158 if (m_optionElement->hasTagName(optgroupTag)) | 155 if (isHTMLOptGroupElement(*m_optionElement)) |
| 159 return toHTMLOptGroupElement(m_optionElement)->groupLabelText(); | 156 return toHTMLOptGroupElement(m_optionElement)->groupLabelText(); |
| 160 | 157 |
| 161 return String(); | 158 return String(); |
| 162 } | 159 } |
| 163 | 160 |
| 164 Element* AXListBoxOption::actionElement() const | 161 Element* AXListBoxOption::actionElement() const |
| 165 { | 162 { |
| 166 return m_optionElement; | 163 return m_optionElement; |
| 167 } | 164 } |
| 168 | 165 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 191 // Convert from the entire list index to the option index. | 188 // Convert from the entire list index to the option index. |
| 192 int optionIndex = selectElement->listToOptionIndex(listBoxOptionIndex()); | 189 int optionIndex = selectElement->listToOptionIndex(listBoxOptionIndex()); |
| 193 selectElement->accessKeySetSelectedIndex(optionIndex); | 190 selectElement->accessKeySetSelectedIndex(optionIndex); |
| 194 } | 191 } |
| 195 | 192 |
| 196 HTMLSelectElement* AXListBoxOption::listBoxOptionParentNode() const | 193 HTMLSelectElement* AXListBoxOption::listBoxOptionParentNode() const |
| 197 { | 194 { |
| 198 if (!m_optionElement) | 195 if (!m_optionElement) |
| 199 return 0; | 196 return 0; |
| 200 | 197 |
| 201 if (m_optionElement->hasTagName(optionTag)) | 198 if (isHTMLOptionElement(*m_optionElement)) |
| 202 return toHTMLOptionElement(m_optionElement)->ownerSelectElement(); | 199 return toHTMLOptionElement(m_optionElement)->ownerSelectElement(); |
| 203 | 200 |
| 204 if (m_optionElement->hasTagName(optgroupTag)) | 201 if (isHTMLOptGroupElement(*m_optionElement)) |
| 205 return toHTMLOptGroupElement(m_optionElement)->ownerSelectElement(); | 202 return toHTMLOptGroupElement(m_optionElement)->ownerSelectElement(); |
| 206 | 203 |
| 207 return 0; | 204 return 0; |
| 208 } | 205 } |
| 209 | 206 |
| 210 int AXListBoxOption::listBoxOptionIndex() const | 207 int AXListBoxOption::listBoxOptionIndex() const |
| 211 { | 208 { |
| 212 if (!m_optionElement) | 209 if (!m_optionElement) |
| 213 return -1; | 210 return -1; |
| 214 | 211 |
| 215 HTMLSelectElement* selectElement = listBoxOptionParentNode(); | 212 HTMLSelectElement* selectElement = listBoxOptionParentNode(); |
| 216 if (!selectElement) | 213 if (!selectElement) |
| 217 return -1; | 214 return -1; |
| 218 | 215 |
| 219 const Vector<HTMLElement*>& listItems = selectElement->listItems(); | 216 const Vector<HTMLElement*>& listItems = selectElement->listItems(); |
| 220 unsigned length = listItems.size(); | 217 unsigned length = listItems.size(); |
| 221 for (unsigned i = 0; i < length; i++) { | 218 for (unsigned i = 0; i < length; i++) { |
| 222 if (listItems[i] == m_optionElement) | 219 if (listItems[i] == m_optionElement) |
| 223 return i; | 220 return i; |
| 224 } | 221 } |
| 225 | 222 |
| 226 return -1; | 223 return -1; |
| 227 } | 224 } |
| 228 | 225 |
| 229 } // namespace WebCore | 226 } // namespace WebCore |
| OLD | NEW |