OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2010 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "modules/accessibility/AXMenuListOption.h" | 26 #include "modules/accessibility/AXMenuListOption.h" |
27 | 27 |
28 #include "SkMatrix44.h" | 28 #include "SkMatrix44.h" |
29 #include "core/dom/AccessibleNode.h" | 29 #include "core/dom/AccessibleNode.h" |
| 30 #include "core/html/HTMLSelectElement.h" |
30 #include "modules/accessibility/AXMenuListPopup.h" | 31 #include "modules/accessibility/AXMenuListPopup.h" |
31 #include "modules/accessibility/AXObjectCacheImpl.h" | 32 #include "modules/accessibility/AXObjectCacheImpl.h" |
32 | 33 |
33 namespace blink { | 34 namespace blink { |
34 | 35 |
35 using namespace HTMLNames; | 36 using namespace HTMLNames; |
36 | 37 |
37 AXMenuListOption::AXMenuListOption(HTMLOptionElement* element, | 38 AXMenuListOption::AXMenuListOption(HTMLOptionElement* element, |
38 AXObjectCacheImpl& ax_object_cache) | 39 AXObjectCacheImpl& ax_object_cache) |
39 : AXMockObject(ax_object_cache), element_(element) {} | 40 : AXMockObject(ax_object_cache), element_(element) {} |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return element_ && element_->Selected(); | 91 return element_ && element_->Selected(); |
91 } | 92 } |
92 | 93 |
93 void AXMenuListOption::SetSelected(bool b) { | 94 void AXMenuListOption::SetSelected(bool b) { |
94 if (!element_ || !CanSetSelectedAttribute()) | 95 if (!element_ || !CanSetSelectedAttribute()) |
95 return; | 96 return; |
96 | 97 |
97 element_->SetSelected(b); | 98 element_->SetSelected(b); |
98 } | 99 } |
99 | 100 |
| 101 bool AXMenuListOption::CanSetFocusAttribute() const { |
| 102 return CanSetSelectedAttribute(); |
| 103 } |
| 104 |
100 bool AXMenuListOption::CanSetSelectedAttribute() const { | 105 bool AXMenuListOption::CanSetSelectedAttribute() const { |
| 106 if (!isHTMLOptionElement(GetNode())) |
| 107 return false; |
| 108 |
| 109 if (toHTMLOptionElement(GetNode())->IsDisabledFormControl()) |
| 110 return false; |
| 111 |
| 112 HTMLSelectElement* select_element = ParentSelectNode(); |
| 113 if (!select_element || select_element->IsDisabledFormControl()) |
| 114 return false; |
| 115 |
101 return IsEnabled(); | 116 return IsEnabled(); |
102 } | 117 } |
103 | 118 |
104 bool AXMenuListOption::ComputeAccessibilityIsIgnored( | 119 bool AXMenuListOption::ComputeAccessibilityIsIgnored( |
105 IgnoredReasons* ignored_reasons) const { | 120 IgnoredReasons* ignored_reasons) const { |
106 return AccessibilityIsIgnoredByDefault(ignored_reasons); | 121 return AccessibilityIsIgnoredByDefault(ignored_reasons); |
107 } | 122 } |
108 | 123 |
109 void AXMenuListOption::GetRelativeBounds( | 124 void AXMenuListOption::GetRelativeBounds( |
110 AXObjectImpl** out_container, | 125 AXObjectImpl** out_container, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 if (name_sources) { | 168 if (name_sources) { |
154 name_sources->push_back(NameSource(found_text_alternative)); | 169 name_sources->push_back(NameSource(found_text_alternative)); |
155 name_sources->back().type = name_from; | 170 name_sources->back().type = name_from; |
156 name_sources->back().text = text_alternative; | 171 name_sources->back().text = text_alternative; |
157 found_text_alternative = true; | 172 found_text_alternative = true; |
158 } | 173 } |
159 | 174 |
160 return text_alternative; | 175 return text_alternative; |
161 } | 176 } |
162 | 177 |
| 178 HTMLSelectElement* AXMenuListOption::ParentSelectNode() const { |
| 179 if (!GetNode()) |
| 180 return 0; |
| 181 |
| 182 if (isHTMLOptionElement(GetNode())) |
| 183 return toHTMLOptionElement(GetNode())->OwnerSelectElement(); |
| 184 |
| 185 return 0; |
| 186 } |
| 187 |
163 DEFINE_TRACE(AXMenuListOption) { | 188 DEFINE_TRACE(AXMenuListOption) { |
164 visitor->Trace(element_); | 189 visitor->Trace(element_); |
165 AXMockObject::Trace(visitor); | 190 AXMockObject::Trace(visitor); |
166 } | 191 } |
167 | 192 |
168 } // namespace blink | 193 } // namespace blink |
OLD | NEW |