summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Scroggins <>2009-04-03 14:01:27 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-03 14:01:27 -0700
commit5168137a84110bca1b9ea8f8759eb8e8241ce6c8 (patch)
treed973c0036d2706669225b94870f69bcf9a0aec31
parent3620888aeeb06e4dd2960323413709461cab663b (diff)
downloadexternal_webkit-5168137a84110bca1b9ea8f8759eb8e8241ce6c8.zip
external_webkit-5168137a84110bca1b9ea8f8759eb8e8241ce6c8.tar.gz
external_webkit-5168137a84110bca1b9ea8f8759eb8e8241ce6c8.tar.bz2
AI 144499: Remove some unnecessary ifdef ANDROID code to make our merges simpler. Rather than using a private function, we now use public functions to accomplish the same task.
Automated import of CL 144499
-rw-r--r--WebCore/WebCorePrefixAndroid.h4
-rw-r--r--WebCore/html/HTMLSelectElement.h6
-rw-r--r--WebKit/android/jni/WebViewCore.cpp71
3 files changed, 40 insertions, 41 deletions
diff --git a/WebCore/WebCorePrefixAndroid.h b/WebCore/WebCorePrefixAndroid.h
index c92caa9..a354b08 100644
--- a/WebCore/WebCorePrefixAndroid.h
+++ b/WebCore/WebCorePrefixAndroid.h
@@ -92,10 +92,6 @@ typedef unsigned char flex_uint8_t;
#define ANDROID_META_SUPPORT
-// Give public access to a private method in HTMLSelectElement so that
-// we can use information from the java UI to deselect items of the element.
-#define ANDROID_DESELECT_SELECT
-
// Converts ListBoxes to dropdown popup lists.
#define ANDROID_LISTBOX_USES_MENU_LIST
diff --git a/WebCore/html/HTMLSelectElement.h b/WebCore/html/HTMLSelectElement.h
index e42c04f..ec49a82 100644
--- a/WebCore/html/HTMLSelectElement.h
+++ b/WebCore/html/HTMLSelectElement.h
@@ -141,13 +141,7 @@ private:
void recalcListItems(bool updateSelectedStates = true) const;
void checkListItems() const;
-#ifdef ANDROID_DESELECT_SELECT
-public:
-#endif
void deselectItems(HTMLOptionElement* excludeElement = 0);
-#ifdef ANDROID_DESELECT_SELECT
-private:
-#endif
#ifdef ANDROID_LISTBOX_USES_MENU_LIST
bool usesMenuList() const { return true; }
#else
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 37279e2..256c1f0 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -1560,47 +1560,56 @@ public:
// Special value for cancel. Do nothing.
return;
}
- // If the select element no longer exists, do to a page change, etc, silently return.
- if (!m_select || !FrameLoaderClientAndroid::get(m_viewImpl->m_mainFrame)->getCacheBuilder().validNode(m_frame, m_select))
+ // If the select element no longer exists, due to a page change, etc,
+ // silently return.
+ if (!m_select ||
+ !FrameLoaderClientAndroid::get(m_viewImpl->m_mainFrame)
+ ->getCacheBuilder().validNode(m_frame, m_select))
return;
- if (-1 == index) {
- if (m_select->selectedIndex() != -1) {
-#ifdef ANDROID_DESELECT_SELECT
- m_select->deselectItems();
-#endif
- m_select->onChange();
- m_viewImpl->contentInvalidate(m_select->getRect());
- }
- return;
- }
- 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();
- m_viewImpl->contentInvalidate(m_select->getRect());
- }
+ int optionIndex = m_select->listToOptionIndex(index);
+ m_select->setSelectedIndex(optionIndex, true, false);
+ m_select->onChange();
+ m_viewImpl->contentInvalidate(m_select->getRect());
}
// Response if the listbox allows multiple selection. array stores the listIndices
// of selected positions.
virtual void replyIntArray(const int* array, int count)
{
- // If the select element no longer exists, do to a page change, etc, silently return.
- if (!m_select || !FrameLoaderClientAndroid::get(m_viewImpl->m_mainFrame)->getCacheBuilder().validNode(m_frame, m_select))
+ // If the select element no longer exists, due to a page change, etc,
+ // silently return.
+ if (!m_select ||
+ !FrameLoaderClientAndroid::get(m_viewImpl->m_mainFrame)
+ ->getCacheBuilder().validNode(m_frame, m_select))
return;
-#ifdef ANDROID_DESELECT_SELECT
- m_select->deselectItems();
-#endif
+
+ // If count is 1 or 0, use replyInt.
+ SkASSERT(count > 1);
+
+ const Vector<HTMLElement*>& items = m_select->listItems();
+ size_t totalItems = items.size();
+ // Keep track of the position of the value we are comparing against.
+ int arrayIndex = 0;
+ // The value we are comparing against.
+ int selection = array[arrayIndex];
WebCore::HTMLOptionElement* option;
- 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);
+ for (size_t listIndex = 0; listIndex < totalItems; listIndex++) {
+ if (items[listIndex]->hasLocalName(WebCore::HTMLNames::optionTag)) {
+ option = static_cast<WebCore::HTMLOptionElement*>(
+ items[listIndex]);
+ if (listIndex == selection) {
+ option->setSelectedState(true);
+ arrayIndex++;
+ if (arrayIndex == count)
+ selection = -1;
+ else
+ selection = array[arrayIndex];
+ } else
+ option->setSelectedState(false);
+ }
}
- m_viewImpl->contentInvalidate(m_select->getRect());
+ m_select->onChange();
+ m_viewImpl->contentInvalidate(m_select->getRect());
}
private:
// The select element associated with this listbox.