| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 187 |
| 188 void ExternalPopupMenu::didAcceptIndex(int index) | 188 void ExternalPopupMenu::didAcceptIndex(int index) |
| 189 { | 189 { |
| 190 // Calling methods on the HTMLSelectElement might lead to this object being | 190 // Calling methods on the HTMLSelectElement might lead to this object being |
| 191 // derefed. This ensures it does not get deleted while we are running this | 191 // derefed. This ensures it does not get deleted while we are running this |
| 192 // method. | 192 // method. |
| 193 int popupMenuItemIndex = toPopupMenuItemIndex(index, *m_ownerElement); | 193 int popupMenuItemIndex = toPopupMenuItemIndex(index, *m_ownerElement); |
| 194 | 194 |
| 195 if (m_ownerElement) { | 195 if (m_ownerElement) { |
| 196 m_ownerElement->popupDidHide(); | 196 m_ownerElement->popupDidHide(); |
| 197 m_ownerElement->valueChanged(popupMenuItemIndex); | 197 m_ownerElement->selectOptionByPopup(popupMenuItemIndex); |
| 198 } | 198 } |
| 199 m_webExternalPopupMenu = 0; | 199 m_webExternalPopupMenu = 0; |
| 200 } | 200 } |
| 201 | 201 |
| 202 // Android uses this function even for single SELECT. |
| 202 void ExternalPopupMenu::didAcceptIndices(const WebVector<int>& indices) | 203 void ExternalPopupMenu::didAcceptIndices(const WebVector<int>& indices) |
| 203 { | 204 { |
| 204 if (!m_ownerElement) { | 205 if (!m_ownerElement) { |
| 205 m_webExternalPopupMenu = 0; | 206 m_webExternalPopupMenu = 0; |
| 206 return; | 207 return; |
| 207 } | 208 } |
| 208 | 209 |
| 209 HTMLSelectElement* ownerElement = m_ownerElement; | 210 HTMLSelectElement* ownerElement = m_ownerElement; |
| 210 ownerElement->popupDidHide(); | 211 ownerElement->popupDidHide(); |
| 211 | 212 |
| 212 if (indices.size() == 0) { | 213 if (indices.size() == 0) { |
| 213 ownerElement->valueChanged(static_cast<unsigned>(-1)); | 214 ownerElement->selectOptionByPopup(-1); |
| 215 } else if (!ownerElement->multiple()) { |
| 216 ownerElement->selectOptionByPopup(toPopupMenuItemIndex(indices[indices.s
ize() - 1], *ownerElement)); |
| 214 } else { | 217 } else { |
| 218 Vector<int> listIndices; |
| 219 listIndices.reserveCapacity(indices.size()); |
| 215 for (size_t i = 0; i < indices.size(); ++i) | 220 for (size_t i = 0; i < indices.size(); ++i) |
| 216 ownerElement->listBoxSelectItem(toPopupMenuItemIndex(indices[i], *ow
nerElement), (i > 0), (i == indices.size() - 1)); | 221 listIndices.append(toPopupMenuItemIndex(indices[i], *ownerElement)); |
| 222 ownerElement->selectMultipleOptionsByPopup(listIndices); |
| 217 } | 223 } |
| 218 | 224 |
| 219 m_webExternalPopupMenu = 0; | 225 m_webExternalPopupMenu = 0; |
| 220 } | 226 } |
| 221 | 227 |
| 222 void ExternalPopupMenu::didCancel() | 228 void ExternalPopupMenu::didCancel() |
| 223 { | 229 { |
| 224 if (m_ownerElement) | 230 if (m_ownerElement) |
| 225 m_ownerElement->popupDidHide(); | 231 m_ownerElement->popupDidHide(); |
| 226 m_webExternalPopupMenu = 0; | 232 m_webExternalPopupMenu = 0; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 if (ownerElement.itemIsDisplayNone(*items[i])) | 300 if (ownerElement.itemIsDisplayNone(*items[i])) |
| 295 continue; | 301 continue; |
| 296 if (popupMenuItemIndex == i) | 302 if (popupMenuItemIndex == i) |
| 297 return indexTracker; | 303 return indexTracker; |
| 298 ++indexTracker; | 304 ++indexTracker; |
| 299 } | 305 } |
| 300 return -1; | 306 return -1; |
| 301 } | 307 } |
| 302 | 308 |
| 303 } // namespace blink | 309 } // namespace blink |
| OLD | NEW |