Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/AXMenuListPopup.cpp

Issue 2141483002: SELECT element: Simplify the code by optionList(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 Node* parentNode = m_parent->getNode(); 108 Node* parentNode = m_parent->getNode();
109 if (!isHTMLSelectElement(parentNode)) 109 if (!isHTMLSelectElement(parentNode))
110 return; 110 return;
111 111
112 HTMLSelectElement* htmlSelectElement = toHTMLSelectElement(parentNode); 112 HTMLSelectElement* htmlSelectElement = toHTMLSelectElement(parentNode);
113 m_haveChildren = true; 113 m_haveChildren = true;
114 114
115 if (m_activeIndex == -1) 115 if (m_activeIndex == -1)
116 m_activeIndex = getSelectedIndex(); 116 m_activeIndex = getSelectedIndex();
117 117
118 const HeapVector<Member<HTMLElement>>& listItems = htmlSelectElement->listIt ems(); 118 for (const auto& optionElement : htmlSelectElement->optionList()) {
119 unsigned length = listItems.size(); 119 AXMenuListOption* option = menuListOptionAXObject(optionElement);
120 for (unsigned i = 0; i < length; i++) {
121 AXMenuListOption* option = menuListOptionAXObject(listItems[i]);
122 if (option) { 120 if (option) {
123 option->setParent(this); 121 option->setParent(this);
124 m_children.append(option); 122 m_children.append(option);
125 } 123 }
126 } 124 }
127 } 125 }
128 126
129 void AXMenuListPopup::updateChildrenIfNecessary() 127 void AXMenuListPopup::updateChildrenIfNecessary()
130 { 128 {
131 if (m_haveChildren && m_parent && m_parent->needsToUpdateChildren()) 129 if (m_haveChildren && m_parent && m_parent->needsToUpdateChildren())
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 176
179 AXObject* AXMenuListPopup::activeDescendant() 177 AXObject* AXMenuListPopup::activeDescendant()
180 { 178 {
181 if (m_activeIndex < 0 || m_activeIndex >= static_cast<int>(children().size() )) 179 if (m_activeIndex < 0 || m_activeIndex >= static_cast<int>(children().size() ))
182 return nullptr; 180 return nullptr;
183 181
184 return m_children[m_activeIndex].get(); 182 return m_children[m_activeIndex].get();
185 } 183 }
186 184
187 } // namespace blink 185 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutMenuList.cpp ('k') | third_party/WebKit/Source/web/WebSearchableFormData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698