| 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 "base/debug/stack_trace.h" |
| 29 #include "core/dom/AccessibleNode.h" | 30 #include "core/dom/AccessibleNode.h" |
| 31 #include "core/html/HTMLSelectElement.h" |
| 30 #include "modules/accessibility/AXMenuListPopup.h" | 32 #include "modules/accessibility/AXMenuListPopup.h" |
| 31 #include "modules/accessibility/AXObjectCacheImpl.h" | 33 #include "modules/accessibility/AXObjectCacheImpl.h" |
| 32 | 34 |
| 33 namespace blink { | 35 namespace blink { |
| 34 | 36 |
| 35 using namespace HTMLNames; | 37 using namespace HTMLNames; |
| 36 | 38 |
| 37 AXMenuListOption::AXMenuListOption(HTMLOptionElement* element, | 39 AXMenuListOption::AXMenuListOption(HTMLOptionElement* element, |
| 38 AXObjectCacheImpl& ax_object_cache) | 40 AXObjectCacheImpl& ax_object_cache) |
| 39 : AXMockObject(ax_object_cache), element_(element) {} | 41 : AXMockObject(ax_object_cache), element_(element) { |
| 42 LOG(INFO) << "this " << this << "; element " << element |
| 43 << " textContent:" << element->textContent().Utf8().data() |
| 44 << "; trace: "; |
| 45 base::debug::StackTrace trace; |
| 46 trace.Print(); |
| 47 } |
| 40 | 48 |
| 41 AXMenuListOption::~AXMenuListOption() { | 49 AXMenuListOption::~AXMenuListOption() { |
| 42 DCHECK(!element_); | 50 DCHECK(!element_); |
| 43 } | 51 } |
| 44 | 52 |
| 45 void AXMenuListOption::Detach() { | 53 void AXMenuListOption::Detach() { |
| 46 element_ = nullptr; | 54 element_ = nullptr; |
| 47 AXMockObject::Detach(); | 55 AXMockObject::Detach(); |
| 48 } | 56 } |
| 49 | 57 |
| 50 AccessibilityRole AXMenuListOption::RoleValue() const { | 58 AccessibilityRole AXMenuListOption::RoleValue() const { |
| 51 const AtomicString& aria_role = | 59 const AtomicString& aria_role = |
| 52 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kRole); | 60 GetAOMPropertyOrARIAAttribute(AOMStringProperty::kRole); |
| 53 if (aria_role.IsEmpty()) | 61 if (aria_role.IsEmpty()) |
| 54 return kMenuListOptionRole; | 62 return kMenuListOptionRole; |
| 55 | 63 |
| 56 AccessibilityRole role = AriaRoleToWebCoreRole(aria_role); | 64 AccessibilityRole role = AriaRoleToWebCoreRole(aria_role); |
| 57 if (role) | 65 if (role) |
| 58 return role; | 66 return role; |
| 59 return kMenuListOptionRole; | 67 return kMenuListOptionRole; |
| 60 } | 68 } |
| 61 | 69 |
| 62 Element* AXMenuListOption::ActionElement() const { | 70 Element* AXMenuListOption::ActionElement() const { |
| 63 return element_; | 71 return element_; |
| 64 } | 72 } |
| 65 | 73 |
| 74 AXObject* AXMenuListOption::ComputeParent() const { |
| 75 LOG(INFO) << "ComputeParent for MenuListOption " << this; |
| 76 Node* node = GetNode(); |
| 77 if (!node) { |
| 78 LOG(INFO) << "!node"; |
| 79 return nullptr; |
| 80 } |
| 81 HTMLSelectElement* select = toHTMLOptionElement(node)->OwnerSelectElement(); |
| 82 if (!select) { |
| 83 LOG(INFO) << "!select"; |
| 84 return nullptr; |
| 85 } |
| 86 LOG(INFO) << "Found select"; |
| 87 AXObject* select_ax_object = AxObjectCache().GetOrCreate(select); |
| 88 if (select_ax_object->HasChildren()) { |
| 89 const auto& child_objects = select_ax_object->Children(); |
| 90 DCHECK(!child_objects.IsEmpty()); |
| 91 DCHECK_EQ(child_objects.size(), 1UL); |
| 92 DCHECK(child_objects[0]->IsMenuListPopup()); |
| 93 ToAXMenuListPopup(child_objects[0].Get())->UpdateChildrenIfNecessary(); |
| 94 } else { |
| 95 select_ax_object->UpdateChildrenIfNecessary(); |
| 96 } |
| 97 LOG(INFO) << "Returning parent_.Get(): " << parent_.Get(); |
| 98 return parent_.Get(); |
| 99 } |
| 100 |
| 66 bool AXMenuListOption::IsEnabled() const { | 101 bool AXMenuListOption::IsEnabled() const { |
| 67 // isDisabledFormControl() returns true if the parent <select> element is | 102 // isDisabledFormControl() returns true if the parent <select> element is |
| 68 // disabled, which we don't want. | 103 // disabled, which we don't want. |
| 69 return element_ && !element_->OwnElementDisabled(); | 104 return element_ && !element_->OwnElementDisabled(); |
| 70 } | 105 } |
| 71 | 106 |
| 72 bool AXMenuListOption::IsVisible() const { | 107 bool AXMenuListOption::IsVisible() const { |
| 73 if (!parent_) | 108 if (!parent_) |
| 74 return false; | 109 return false; |
| 75 | 110 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 194 |
| 160 return text_alternative; | 195 return text_alternative; |
| 161 } | 196 } |
| 162 | 197 |
| 163 DEFINE_TRACE(AXMenuListOption) { | 198 DEFINE_TRACE(AXMenuListOption) { |
| 164 visitor->Trace(element_); | 199 visitor->Trace(element_); |
| 165 AXMockObject::Trace(visitor); | 200 AXMockObject::Trace(visitor); |
| 166 } | 201 } |
| 167 | 202 |
| 168 } // namespace blink | 203 } // namespace blink |
| OLD | NEW |