| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 { | 101 { |
| 102 return isHTMLOptionElement(getNode()) && toHTMLOptionElement(getNode())->sel
ected(); | 102 return isHTMLOptionElement(getNode()) && toHTMLOptionElement(getNode())->sel
ected(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 bool AXListBoxOption::isSelectedOptionActive() const | 105 bool AXListBoxOption::isSelectedOptionActive() const |
| 106 { | 106 { |
| 107 HTMLSelectElement* listBoxParentNode = listBoxOptionParentNode(); | 107 HTMLSelectElement* listBoxParentNode = listBoxOptionParentNode(); |
| 108 if (!listBoxParentNode) | 108 if (!listBoxParentNode) |
| 109 return false; | 109 return false; |
| 110 | 110 |
| 111 return listBoxParentNode->activeSelectionEndListIndex() == listBoxOptionInde
x(); | 111 return listBoxParentNode->activeSelectionEnd() == getNode(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool AXListBoxOption::computeAccessibilityIsIgnored(IgnoredReasons* ignoredReaso
ns) const | 114 bool AXListBoxOption::computeAccessibilityIsIgnored(IgnoredReasons* ignoredReaso
ns) const |
| 115 { | 115 { |
| 116 if (!getNode()) | 116 if (!getNode()) |
| 117 return true; | 117 return true; |
| 118 | 118 |
| 119 if (accessibilityIsIgnoredByDefault(ignoredReasons)) | 119 if (accessibilityIsIgnoredByDefault(ignoredReasons)) |
| 120 return true; | 120 return true; |
| 121 | 121 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 if (!selectElement) | 169 if (!selectElement) |
| 170 return; | 170 return; |
| 171 | 171 |
| 172 if (!canSetSelectedAttribute()) | 172 if (!canSetSelectedAttribute()) |
| 173 return; | 173 return; |
| 174 | 174 |
| 175 bool isOptionSelected = isSelected(); | 175 bool isOptionSelected = isSelected(); |
| 176 if ((isOptionSelected && selected) || (!isOptionSelected && !selected)) | 176 if ((isOptionSelected && selected) || (!isOptionSelected && !selected)) |
| 177 return; | 177 return; |
| 178 | 178 |
| 179 // Convert from the entire list index to the option index. | 179 selectElement->selectOptionByAccessKey(toHTMLOptionElement(getNode())); |
| 180 int optionIndex = selectElement->listToOptionIndex(listBoxOptionIndex()); | |
| 181 selectElement->accessKeySetSelectedIndex(optionIndex); | |
| 182 } | 180 } |
| 183 | 181 |
| 184 HTMLSelectElement* AXListBoxOption::listBoxOptionParentNode() const | 182 HTMLSelectElement* AXListBoxOption::listBoxOptionParentNode() const |
| 185 { | 183 { |
| 186 if (!getNode()) | 184 if (!getNode()) |
| 187 return 0; | 185 return 0; |
| 188 | 186 |
| 189 if (isHTMLOptionElement(getNode())) | 187 if (isHTMLOptionElement(getNode())) |
| 190 return toHTMLOptionElement(getNode())->ownerSelectElement(); | 188 return toHTMLOptionElement(getNode())->ownerSelectElement(); |
| 191 | 189 |
| 192 return 0; | 190 return 0; |
| 193 } | 191 } |
| 194 | 192 |
| 195 int AXListBoxOption::listBoxOptionIndex() const | |
| 196 { | |
| 197 HTMLSelectElement* selectElement = listBoxOptionParentNode(); | |
| 198 if (!selectElement) | |
| 199 return -1; | |
| 200 | |
| 201 const HeapVector<Member<HTMLElement>>& listItems = selectElement->listItems(
); | |
| 202 unsigned length = listItems.size(); | |
| 203 for (unsigned i = 0; i < length; i++) { | |
| 204 if (listItems[i] == getNode()) | |
| 205 return i; | |
| 206 } | |
| 207 | |
| 208 return -1; | |
| 209 } | |
| 210 | |
| 211 } // namespace blink | 193 } // namespace blink |
| OLD | NEW |