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 |
(...skipping 10 matching lines...) Expand all Loading... |
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 "core/html/HTMLSelectElement.h" |
| 31 #include "modules/accessibility/AXMenuList.h" |
31 #include "modules/accessibility/AXMenuListPopup.h" | 32 #include "modules/accessibility/AXMenuListPopup.h" |
32 #include "modules/accessibility/AXObjectCacheImpl.h" | 33 #include "modules/accessibility/AXObjectCacheImpl.h" |
33 | 34 |
34 namespace blink { | 35 namespace blink { |
35 | 36 |
36 using namespace HTMLNames; | 37 using namespace HTMLNames; |
37 | 38 |
38 AXMenuListOption::AXMenuListOption(HTMLOptionElement* element, | 39 AXMenuListOption::AXMenuListOption(HTMLOptionElement* element, |
39 AXObjectCacheImpl& ax_object_cache) | 40 AXObjectCacheImpl& ax_object_cache) |
40 : AXMockObject(ax_object_cache), element_(element) {} | 41 : AXMockObject(ax_object_cache), element_(element) {} |
41 | 42 |
42 AXMenuListOption::~AXMenuListOption() { | 43 AXMenuListOption::~AXMenuListOption() { |
43 DCHECK(!element_); | 44 DCHECK(!element_); |
44 } | 45 } |
45 | 46 |
46 void AXMenuListOption::Detach() { | 47 void AXMenuListOption::Detach() { |
47 element_ = nullptr; | 48 element_ = nullptr; |
48 AXMockObject::Detach(); | 49 AXMockObject::Detach(); |
49 } | 50 } |
50 | 51 |
| 52 LocalFrameView* AXMenuListOption::DocumentFrameView() const { |
| 53 if (IsDetached()) |
| 54 return nullptr; |
| 55 return element_->GetDocument().View(); |
| 56 } |
| 57 |
51 AccessibilityRole AXMenuListOption::RoleValue() const { | 58 AccessibilityRole AXMenuListOption::RoleValue() const { |
52 const AtomicString& aria_role = | 59 const AtomicString& aria_role = |
53 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kRole); | 60 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kRole); |
54 if (aria_role.IsEmpty()) | 61 if (aria_role.IsEmpty()) |
55 return kMenuListOptionRole; | 62 return kMenuListOptionRole; |
56 | 63 |
57 AccessibilityRole role = AriaRoleToWebCoreRole(aria_role); | 64 AccessibilityRole role = AriaRoleToWebCoreRole(aria_role); |
58 if (role) | 65 if (role) |
59 return role; | 66 return role; |
60 return kMenuListOptionRole; | 67 return kMenuListOptionRole; |
61 } | 68 } |
62 | 69 |
63 Element* AXMenuListOption::ActionElement() const { | 70 Element* AXMenuListOption::ActionElement() const { |
64 return element_; | 71 return element_; |
65 } | 72 } |
66 | 73 |
67 AXObjectImpl* AXMenuListOption::ComputeParent() const { | 74 AXObjectImpl* AXMenuListOption::ComputeParent() const { |
68 Node* node = GetNode(); | 75 Node* node = GetNode(); |
69 if (!node) | 76 if (!node) |
70 return nullptr; | 77 return nullptr; |
71 HTMLSelectElement* select = toHTMLOptionElement(node)->OwnerSelectElement(); | 78 HTMLSelectElement* select = toHTMLOptionElement(node)->OwnerSelectElement(); |
72 if (!select) | 79 if (!select) |
73 return nullptr; | 80 return nullptr; |
74 AXObjectImpl* select_ax_object = AxObjectCache().GetOrCreate(select); | 81 AXObjectImpl* select_ax_object = AxObjectCache().GetOrCreate(select); |
75 if (select_ax_object->HasChildren()) { | 82 |
76 const auto& child_objects = select_ax_object->Children(); | 83 // This happens if the <select> is not rendered. Return it and move on. |
77 DCHECK(!child_objects.IsEmpty()); | 84 if (!select_ax_object->IsMenuList()) |
| 85 return select_ax_object; |
| 86 |
| 87 AXMenuList* menu_list = ToAXMenuList(select_ax_object); |
| 88 if (menu_list->HasChildren()) { |
| 89 const auto& child_objects = menu_list->Children(); |
| 90 if (child_objects.IsEmpty()) |
| 91 return nullptr; |
78 DCHECK_EQ(child_objects.size(), 1UL); | 92 DCHECK_EQ(child_objects.size(), 1UL); |
79 DCHECK(child_objects[0]->IsMenuListPopup()); | 93 DCHECK(child_objects[0]->IsMenuListPopup()); |
80 ToAXMenuListPopup(child_objects[0].Get())->UpdateChildrenIfNecessary(); | 94 ToAXMenuListPopup(child_objects[0].Get())->UpdateChildrenIfNecessary(); |
81 } else { | 95 } else { |
82 select_ax_object->UpdateChildrenIfNecessary(); | 96 menu_list->UpdateChildrenIfNecessary(); |
83 } | 97 } |
84 return parent_.Get(); | 98 return parent_.Get(); |
85 } | 99 } |
86 | 100 |
87 bool AXMenuListOption::IsEnabled() const { | 101 bool AXMenuListOption::IsEnabled() const { |
88 // isDisabledFormControl() returns true if the parent <select> element is | 102 // isDisabledFormControl() returns true if the parent <select> element is |
89 // disabled, which we don't want. | 103 // disabled, which we don't want. |
90 return element_ && !element_->OwnElementDisabled(); | 104 return element_ && !element_->OwnElementDisabled(); |
91 } | 105 } |
92 | 106 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 218 |
205 return 0; | 219 return 0; |
206 } | 220 } |
207 | 221 |
208 DEFINE_TRACE(AXMenuListOption) { | 222 DEFINE_TRACE(AXMenuListOption) { |
209 visitor->Trace(element_); | 223 visitor->Trace(element_); |
210 AXMockObject::Trace(visitor); | 224 AXMockObject::Trace(visitor); |
211 } | 225 } |
212 | 226 |
213 } // namespace blink | 227 } // namespace blink |
OLD | NEW |