AI 144237: Fix for issue 1600838: error handling <select multiple="multiple"> when using <optgroup>. Previously, I was appending 0 to my selected list for <optgroup>s, as if 0 meant the item at that index is not selected. In reality, the list is a list of indeces which are selected, so this made the first item always selected if there was a multiple with an <optgroup>. Removed the erroneous append, and add some asserts.
BUG=1600838
Automated import of CL 144237
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 0746e2f..37279e2 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -1575,6 +1575,7 @@
}
WebCore::HTMLOptionElement* option = static_cast<WebCore::HTMLOptionElement*>(
m_select->item(m_select->listToOptionIndex(index)));
+ SkASSERT(option);
if (!option->selected()) {
option->setSelected(true);
m_select->onChange();
@@ -1596,6 +1597,7 @@
for (int i = 0; i < count; i++) {
option = static_cast<WebCore::HTMLOptionElement*>(
m_select->item(m_select->listToOptionIndex(array[i])));
+ SkASSERT(option);
option->setSelected(true);
}
m_viewImpl->contentInvalidate(m_select->getRect());
@@ -1807,8 +1809,6 @@
WebCore::HTMLOptGroupElement* optGroup = static_cast<WebCore::HTMLOptGroupElement*>(listItems[i]);
*names.append() = stringConverter(optGroup->groupLabelText());
*enabledArray.append() = 0;
- if (multiple)
- *selectedArray.append() = 0;
}
}
WebCoreReply* reply = new ListBoxReply(select, select->document()->frame(), this);