| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 return AccessibilityIsIgnoredByDefault(ignored_reasons); | 59 return AccessibilityIsIgnoredByDefault(ignored_reasons); |
| 60 } | 60 } |
| 61 | 61 |
| 62 AXMenuListOption* AXMenuListPopup::MenuListOptionAXObject( | 62 AXMenuListOption* AXMenuListPopup::MenuListOptionAXObject( |
| 63 HTMLElement* element) const { | 63 HTMLElement* element) const { |
| 64 DCHECK(element); | 64 DCHECK(element); |
| 65 if (!isHTMLOptionElement(*element)) | 65 if (!isHTMLOptionElement(*element)) |
| 66 return 0; | 66 return 0; |
| 67 | 67 |
| 68 AXObject* object = AxObjectCache().GetOrCreate(element); | 68 AXObject* object = AxObjectCache().GetOrCreate(element); |
| 69 if (!object || !object->IsMenuListOption()) | 69 LOG(INFO) << "Created " << object; |
| 70 if (!object || !object->IsMenuListOption()) { |
| 71 LOG(INFO) << "!object || !object->IsMenuListOption(): " << object; |
| 70 return 0; | 72 return 0; |
| 73 } |
| 71 | 74 |
| 75 LOG(INFO) << "Returning object " << object; |
| 72 return ToAXMenuListOption(object); | 76 return ToAXMenuListOption(object); |
| 73 } | 77 } |
| 74 | 78 |
| 75 int AXMenuListPopup::GetSelectedIndex() const { | 79 int AXMenuListPopup::GetSelectedIndex() const { |
| 76 if (!parent_) | 80 if (!parent_) |
| 77 return -1; | 81 return -1; |
| 78 | 82 |
| 79 Node* parent_node = parent_->GetNode(); | 83 Node* parent_node = parent_->GetNode(); |
| 80 if (!isHTMLSelectElement(parent_node)) | 84 if (!isHTMLSelectElement(parent_node)) |
| 81 return -1; | 85 return -1; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 101 if (!isHTMLSelectElement(parent_node)) | 105 if (!isHTMLSelectElement(parent_node)) |
| 102 return; | 106 return; |
| 103 | 107 |
| 104 HTMLSelectElement* html_select_element = toHTMLSelectElement(parent_node); | 108 HTMLSelectElement* html_select_element = toHTMLSelectElement(parent_node); |
| 105 have_children_ = true; | 109 have_children_ = true; |
| 106 | 110 |
| 107 if (active_index_ == -1) | 111 if (active_index_ == -1) |
| 108 active_index_ = GetSelectedIndex(); | 112 active_index_ = GetSelectedIndex(); |
| 109 | 113 |
| 110 for (const auto& option_element : html_select_element->GetOptionList()) { | 114 for (const auto& option_element : html_select_element->GetOptionList()) { |
| 115 LOG(INFO) << "Getting option for element"; |
| 111 AXMenuListOption* option = MenuListOptionAXObject(option_element); | 116 AXMenuListOption* option = MenuListOptionAXObject(option_element); |
| 117 LOG(INFO) << "Got option: " << option; |
| 112 if (option) { | 118 if (option) { |
| 119 LOG(INFO) << "Setting parent on option " << option; |
| 113 option->SetParent(this); | 120 option->SetParent(this); |
| 114 children_.push_back(option); | 121 children_.push_back(option); |
| 122 } else { |
| 123 LOG(INFO) << "no option"; |
| 115 } | 124 } |
| 116 } | 125 } |
| 117 } | 126 } |
| 118 | 127 |
| 119 void AXMenuListPopup::UpdateChildrenIfNecessary() { | 128 void AXMenuListPopup::UpdateChildrenIfNecessary() { |
| 129 LOG(INFO) << "AXMenuListPopup::UpdateChildrenIfNecessary"; |
| 130 LOG(INFO) << "have_children_: " << have_children_ << "; parent_: " << parent_; |
| 131 if (parent_) |
| 132 LOG(INFO) << "parent_->NeedsToUpdateChildren(): " |
| 133 << parent_->NeedsToUpdateChildren(); |
| 120 if (have_children_ && parent_ && parent_->NeedsToUpdateChildren()) | 134 if (have_children_ && parent_ && parent_->NeedsToUpdateChildren()) |
| 121 ClearChildren(); | 135 ClearChildren(); |
| 122 | 136 |
| 123 if (!have_children_) | 137 if (!have_children_) |
| 124 AddChildren(); | 138 AddChildren(); |
| 125 } | 139 } |
| 126 | 140 |
| 127 void AXMenuListPopup::DidUpdateActiveOption(int option_index) { | 141 void AXMenuListPopup::DidUpdateActiveOption(int option_index) { |
| 128 UpdateChildrenIfNecessary(); | 142 UpdateChildrenIfNecessary(); |
| 129 | 143 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 182 } |
| 169 | 183 |
| 170 AXObject* AXMenuListPopup::ActiveDescendant() { | 184 AXObject* AXMenuListPopup::ActiveDescendant() { |
| 171 if (active_index_ < 0 || active_index_ >= static_cast<int>(Children().size())) | 185 if (active_index_ < 0 || active_index_ >= static_cast<int>(Children().size())) |
| 172 return nullptr; | 186 return nullptr; |
| 173 | 187 |
| 174 return children_[active_index_].Get(); | 188 return children_[active_index_].Get(); |
| 175 } | 189 } |
| 176 | 190 |
| 177 } // namespace blink | 191 } // namespace blink |
| OLD | NEW |