OSDN Git Service

am 4fff0b9f: am 2bac1e45: Only invalidate the webview when the plugin has new content.
authorDerek Sollenberger <djsollen@google.com>
Mon, 7 Feb 2011 21:44:49 +0000 (13:44 -0800)
committerAndroid Git Automerger <android-git-automerger@android.com>
Mon, 7 Feb 2011 21:44:49 +0000 (13:44 -0800)
* commit '4fff0b9fdd23cd60b036e2ea48190e7a7d8dbf13':
  Only invalidate the webview when the plugin has new content.

14 files changed:
WebCore/config.h
WebCore/html/HTMLOptionElement.h
WebCore/platform/android/PopupMenuAndroid.cpp
WebCore/platform/android/PopupMenuAndroid.h
WebCore/platform/android/RenderThemeAndroid.cpp
WebCore/rendering/RenderBox.cpp
WebCore/rendering/RenderTheme.cpp
WebCore/rendering/RenderTheme.h
WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.h
WebKit/android/jni/WebCoreFrameBridge.cpp
WebKit/android/jni/WebCoreFrameBridge.h
WebKit/android/jni/WebViewCore.cpp

index 7174c4b..6117fef 100644 (file)
 #define ANDROID_META_SUPPORT
 
 // Converts ListBoxes to dropdown popup lists.
-#define ANDROID_LISTBOX_USES_MENU_LIST
+#define ENABLE_NO_LISTBOX_RENDERING 1
 
 #define ANDROID_MULTIPLE_WINDOWS
 #define ANDROID_CSS_RING
index deac66a..c1791d7 100644 (file)
 #include "HTMLFormControlElement.h"
 #include "OptionElement.h"
 
-#if PLATFORM(ANDROID)
-namespace android {
-class WebViewCore;
-class ListBoxReply;
-};
-#endif
-
 namespace WebCore {
 
 class HTMLSelectElement;
@@ -41,11 +34,6 @@ class HTMLSelectElement;
 class HTMLOptionElement : public HTMLFormControlElement, public OptionElement {
     friend class HTMLSelectElement;
     friend class RenderMenuList;
-#if PLATFORM(ANDROID)
-    friend class RenderThemeAndroid;
-    friend class android::WebViewCore;
-    friend class android::ListBoxReply;
-#endif
 
 public:
     static PassRefPtr<HTMLOptionElement> create(Document*, HTMLFormElement*);
index 2bae724..f4c351f 100644 (file)
@@ -31,7 +31,7 @@
 
 class PopupReply : public android::WebCoreReply {
 public:
-    PopupReply(const IntRect& rect, android::WebViewCore* view, PopupMenuClient* client)
+    PopupReply(const IntRect& rect, android::WebViewCore* view, ListPopupMenuClient* client)
         : m_rect(rect)
         , m_viewImpl(view)
         , m_popupClient(client)
@@ -53,9 +53,23 @@ public:
             m_viewImpl->contentInvalidate(m_rect);
     }
 
-    virtual void replyIntArray(const int*, int) {
-        // Should never be called.
-        SkASSERT(false);
+    virtual void replyIntArray(const int* values, int count)
+    {
+        if (m_popupClient) {
+            m_popupClient->popupDidHide();
+            if (0 == count) {
+                m_popupClient->valueChanged(-1, true);
+            } else {
+                for (int i = 0; i < count; i++) {
+                    m_popupClient->listBoxSelectItem(values[i],
+                        i != 0 /* allowMultiplySelection */,
+                        false /* shift */,
+                        i == count - 1 /* fireOnChangeNow */);
+                }
+            }
+        }
+        if (m_viewImpl)
+            m_viewImpl->contentInvalidate(m_rect);
     }
 
     void disconnectClient()
@@ -67,12 +81,12 @@ private:
     IntRect m_rect;
     // FIXME: Do not need this if we handle ChromeClientAndroid::formStateDidChange
     android::WebViewCore* m_viewImpl;
-    PopupMenuClient* m_popupClient;
+    ListPopupMenuClient* m_popupClient;
 };
 
 namespace WebCore {
 
-PopupMenuAndroid::PopupMenuAndroid(PopupMenuClient* menuList)
+PopupMenuAndroid::PopupMenuAndroid(ListPopupMenuClient* menuList)
     : m_popupClient(menuList)
     , m_reply(0)
 {
@@ -91,8 +105,7 @@ void PopupMenuAndroid::disconnectClient()
         m_reply = 0;
     }
 }
-// Copied from WebViewCore.cpp.  Once we move ListBox handling to this class,
-// we can remove the one in WebViewCore.cpp.
+
 // Convert a WTF::String into an array of characters where the first
 // character represents the length, for easy conversion to java.
 static uint16_t* stringConverter(const WTF::String& text)
@@ -122,9 +135,7 @@ void PopupMenuAndroid::show(const IntRect& rect, FrameView* frameView, int)
     SkTDArray<int> enabledArray;
     SkTDArray<int> selectedArray;
     int size = m_popupClient->listSize();
-    // If we use this for ListBoxes in addition to MenuLists, we will need to
-    // account for 'multiple'
-    bool multiple = false;
+    bool multiple = m_popupClient->multiple();
     for (int i = 0; i < size; i++) {
         *names.append() = stringConverter(m_popupClient->itemText(i));
         if (m_popupClient->itemIsSeparator(i)) {
index 48bce44..6c2c015 100644 (file)
@@ -34,18 +34,18 @@ class PopupReply;
 namespace WebCore {
 
 class FrameView;
-class PopupMenuClient;
+class ListPopupMenuClient;
 
 class PopupMenuAndroid : public PopupMenu {
 public:
-    PopupMenuAndroid(PopupMenuClient*);
+    PopupMenuAndroid(ListPopupMenuClient*);
     virtual ~PopupMenuAndroid();
     virtual void show(const IntRect&, FrameView*, int);
     virtual void hide() { }
     virtual void updateFromElement() { }
     virtual void disconnectClient();
 private:
-    PopupMenuClient* m_popupClient;
+    ListPopupMenuClient* m_popupClient;
     PopupReply* m_reply;
 };
 
index 87e7a6d..b43e0e6 100644 (file)
@@ -351,57 +351,9 @@ void RenderThemeAndroid::adjustTextAreaStyle(CSSStyleSelector*, RenderStyle* sty
 
 bool RenderThemeAndroid::paintTextArea(RenderObject* obj, const PaintInfo& info, const IntRect& rect)
 {
-    if (!obj->isListBox())
-        return true;
-
-    paintCombo(obj, info, rect);
-    RenderStyle* style = obj->style();
-    if (style)
-        style->setColor(Color::transparent);
-    Node* node = obj->node();
-    if (!node || !node->hasTagName(HTMLNames::selectTag))
-        return true;
-
-    HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node);
-    // The first item may be visible.  Make sure it does not draw.
-    // If it has a style, it overrides the RenderListBox's style, so we
-    // need to make sure both are set to transparent.
-    node = select->item(0);
-    if (node) {
-        RenderObject* renderer = node->renderer();
-        if (renderer) {
-            RenderStyle* renderStyle = renderer->style();
-            if (renderStyle)
-                renderStyle->setColor(Color::transparent);
-        }
-    }
-    // Find the first selected option, and draw its text.
-    // FIXME: In a later change, if there is more than one item selected,
-    // draw a string that says "X items" like iPhone Safari does
-    int index = select->selectedIndex();
-    node = select->item(index);
-    if (!node || !node->hasTagName(HTMLNames::optionTag))
-        return true;
-
-    HTMLOptionElement* option = static_cast<HTMLOptionElement*>(node);
-    String label = option->textIndentedToRespectGroupLabel();
-    SkRect r(rect);
-
-    SkPaint paint;
-    paint.setAntiAlias(true);
-    paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
-    // Values for text size and positioning determined by trial and error
-    paint.setTextSize(r.height() - SkIntToScalar(6));
-
-    SkCanvas* canvas = getCanvasFromInfo(info);
-    int saveCount = canvas->save();
-    r.fRight -= SkIntToScalar(RenderSkinCombo::extraWidth());
-    canvas->clipRect(r);
-    canvas->drawText(label.characters(), label.length() << 1,
-             r.fLeft + SkIntToScalar(5), r.fBottom - SkIntToScalar(5), paint);
-    canvas->restoreToCount(saveCount);
-
-    return true;    
+    if (obj->isMenuList())
+        paintCombo(obj, info, rect);
+    return true;
 }
 
 void RenderThemeAndroid::adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
@@ -414,16 +366,7 @@ bool RenderThemeAndroid::paintSearchField(RenderObject*, const PaintInfo&, const
     return true;    
 }
 
-void RenderThemeAndroid::adjustListboxStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
-{
-    style->setPaddingRight(Length(RenderSkinCombo::extraWidth(), Fixed));
-    style->setMaxHeight(Length(style->fontSize() + listboxPadding, Fixed));
-    // Make webkit draw invisible, since it will simply draw the first element
-    style->setColor(Color::transparent);
-    addIntrinsicMargins(style);
-}
-
-static void adjustMenuListStyleCommon(RenderStyle* style, Element* e)
+static void adjustMenuListStyleCommon(RenderStyle* style)
 {
     // Added to make room for our arrow and make the touch target less cramped.
     style->setPaddingLeft(Length(RenderSkinCombo::padding(), Fixed));
@@ -432,9 +375,14 @@ static void adjustMenuListStyleCommon(RenderStyle* style, Element* e)
     style->setPaddingRight(Length(RenderSkinCombo::extraWidth(), Fixed));
 }
 
+void RenderThemeAndroid::adjustListboxStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
+{
+    adjustMenuListButtonStyle(0, style, 0);
+}
+
 void RenderThemeAndroid::adjustMenuListStyle(CSSStyleSelector*, RenderStyle* style, Element* e) const
 {
-    adjustMenuListStyleCommon(style, e);
+    adjustMenuListStyleCommon(style);
     addIntrinsicMargins(style);
 }
 
@@ -450,7 +398,8 @@ bool RenderThemeAndroid::paintMenuList(RenderObject* obj, const PaintInfo& info,
     return paintCombo(obj, info, rect);
 }
 
-void RenderThemeAndroid::adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle* style, Element* e) const
+void RenderThemeAndroid::adjustMenuListButtonStyle(CSSStyleSelector*,
+        RenderStyle* style, Element*) const
 {
     // Copied from RenderThemeSafari.
     const float baseFontSize = 11.0f;
@@ -468,7 +417,7 @@ void RenderThemeAndroid::adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyl
     const int padding = 4;
     style->setPaddingTop(Length(padding, Fixed));
     style->setPaddingLeft(Length(padding, Fixed));
-    adjustMenuListStyleCommon(style, e);
+    adjustMenuListStyleCommon(style);
 }
 
 bool RenderThemeAndroid::paintMenuListButton(RenderObject* obj, const PaintInfo& info, const IntRect& rect) 
index fe78fd5..3c8e2ca 100644 (file)
@@ -39,7 +39,9 @@
 #include "FloatQuad.h"
 #include "Frame.h"
 #include "Page.h"
+#if PLATFORM(ANDROID)
 #include "PlatformBridge.h"
+#endif
 #include "RenderArena.h"
 #include "RenderFlexibleBox.h"
 #include "RenderInline.h"
@@ -2078,13 +2080,14 @@ void RenderBox::computeBlockDirectionMargins(RenderBlock* containingBlock)
 
 int RenderBox::containingBlockWidthForPositioned(const RenderBoxModelObject* containingBlock) const
 {
+#if PLATFORM(ANDROID)
     // Fixed element's position should be decided by the visible screen size.
     // That is in the doc coordindate.
     if (style()->position() == FixedPosition && containingBlock->isRenderView()) {
         const RenderView* view = toRenderView(containingBlock);
         return PlatformBridge::visibleScreenWidth(view->frameView());
     }
-
+#endif
     if (containingBlock->isBox()) {
         const RenderBox* containingBlockBox = toRenderBox(containingBlock);
         return containingBlockBox->width() - containingBlockBox->borderLeft() - containingBlockBox->borderRight() - containingBlockBox->verticalScrollbarWidth();
@@ -2114,14 +2117,15 @@ int RenderBox::containingBlockWidthForPositioned(const RenderBoxModelObject* con
 }
 
 int RenderBox::containingBlockHeightForPositioned(const RenderBoxModelObject* containingBlock) const
-{   
+{
+#if PLATFORM(ANDROID)
     // Fixed element's position should be decided by the visible screen size.
     // That is in the doc coordindate.
     if (style()->position() == FixedPosition && containingBlock->isRenderView()) {
         const RenderView* view = toRenderView(containingBlock);
         return PlatformBridge::visibleScreenHeight(view->frameView());
     }
-
+#endif
     int heightResult = 0;
     if (containingBlock->isBox())
          heightResult = toRenderBox(containingBlock)->height();
index 522bd4d..538b6c6 100644 (file)
@@ -198,7 +198,7 @@ void RenderTheme::adjustStyle(CSSStyleSelector* selector, RenderStyle* style, El
             return adjustTextFieldStyle(selector, style, e);
         case TextAreaPart:
             return adjustTextAreaStyle(selector, style, e);
-#ifdef ANDROID_LISTBOX_USES_MENU_LIST
+#if ENABLE(NO_LISTBOX_RENDERING)
         case ListboxPart:
             return adjustListboxStyle(selector, style, e);
 #endif
index aedb8eb..13c69e6 100644 (file)
@@ -236,7 +236,7 @@ protected:
     virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
     virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&) { return true; }
 
-#ifdef ANDROID_LISTBOX_USES_MENU_LIST
+#if ENABLE(NO_LISTBOX_RENDERING)
     virtual void adjustListboxStyle(CSSStyleSelector*, RenderStyle*, Element*) const {}
 #endif
     virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
index f0958d9..fb5701a 100644 (file)
@@ -536,7 +536,7 @@ bool ChromeClientAndroid::selectItemWritingDirectionIsNatural()
 
 PassRefPtr<PopupMenu> ChromeClientAndroid::createPopupMenu(PopupMenuClient* client) const
 {
-    return adoptRef(new PopupMenuAndroid(client));
+    return adoptRef(new PopupMenuAndroid(static_cast<ListPopupMenuClient*>(client)));
 }
 
 PassRefPtr<SearchPopupMenu> ChromeClientAndroid::createSearchPopupMenu(PopupMenuClient*) const
index cc21dad..535c0da 100644 (file)
@@ -577,6 +577,12 @@ void FrameLoaderClientAndroid::dispatchWillSubmitForm(FramePolicyFunction func,
     (m_frame->loader()->policyChecker()->*func)(PolicyUse);
 }
 
+void FrameLoaderClientAndroid::dispatchWillSendSubmitEvent(HTMLFormElement* form)
+{
+    if (m_webFrame->shouldSaveFormData())
+        m_webFrame->saveFormData(form);
+}
+
 void FrameLoaderClientAndroid::dispatchDidLoadMainResource(DocumentLoader*) {
     notImplemented();
 }
index 964ac6e..034333e 100644 (file)
@@ -223,7 +223,7 @@ namespace android {
         void enableOnDemandPlugins() { m_onDemandPluginsEnabled = true; }
 
         void dispatchDidChangeIcons();
-        void dispatchWillSendSubmitEvent(HTMLFormElement*) { }
+        void dispatchWillSendSubmitEvent(HTMLFormElement*);
     private:
         CacheBuilder        m_cacheBuilder;
         Frame*              m_frame;
index 9780d2d..1635b1d 100644 (file)
@@ -44,7 +44,6 @@
 #include "Element.h"
 #include "FocusController.h"
 #include "Font.h"
-#include "FormState.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClientAndroid.h"
@@ -220,6 +219,8 @@ struct WebFrame::JavaBrowserFrame
     jmethodID   mDidReceiveData;
     jmethodID   mDidFinishLoading;
     jmethodID   mSetCertificate;
+    jmethodID   mShouldSaveFormData;
+    jmethodID   mSaveFormData;
     AutoJObject frame(JNIEnv* env) {
         return getRealObject(env, mObj);
     }
@@ -292,6 +293,8 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page*
     mJavaFrame->mDidFinishLoading = env->GetMethodID(clazz, "didFinishLoading", "()V");
     mJavaFrame->mSetCertificate = env->GetMethodID(clazz, "setCertificate",
             "(Ljava/lang/String;Ljava/lang/String;JJ)V");
+    mJavaFrame->mShouldSaveFormData = env->GetMethodID(clazz, "shouldSaveFormData", "()Z");
+    mJavaFrame->mSaveFormData = env->GetMethodID(clazz, "saveFormData", "(Ljava/util/HashMap;)V");
     env->DeleteLocalRef(clazz);
 
     LOG_ASSERT(mJavaFrame->mStartLoadingResource, "Could not find method startLoadingResource");
@@ -322,6 +325,8 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page*
     LOG_ASSERT(mJavaFrame->mDidReceiveData, "Could not find method didReceiveData");
     LOG_ASSERT(mJavaFrame->mDidFinishLoading, "Could not find method didFinishLoading");
     LOG_ASSERT(mJavaFrame->mSetCertificate, "Could not find method setCertificate");
+    LOG_ASSERT(mJavaFrame->mShouldSaveFormData, "Could not find method shouldSaveFormData");
+    LOG_ASSERT(mJavaFrame->mSaveFormData, "Could not find method saveFormData");
 
     mUserAgent = WTF::String();
     mUserInitiatedAction = false;
@@ -782,6 +787,16 @@ WebFrame::canHandleRequest(const WebCore::ResourceRequest& request)
     return (ret == 0);
 }
 
+bool
+WebFrame::shouldSaveFormData()
+{
+    JNIEnv* env = getJNIEnv();
+    jboolean ret = env->CallBooleanMethod(mJavaFrame->frame(env).get(),
+            mJavaFrame->mShouldSaveFormData);
+    checkException(env);
+    return ret;
+}
+
 WebCore::Frame*
 WebFrame::createWindow(bool dialog, bool userGesture)
 {
@@ -1876,62 +1891,46 @@ static void SetUsernamePassword(JNIEnv *env, jobject obj,
     }
 }
 
-static jobject GetFormTextData(JNIEnv *env, jobject obj)
+void
+WebFrame::saveFormData(HTMLFormElement* form)
 {
-#ifdef ANDROID_INSTRUMENT
-    TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#endif
-    WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
-    LOG_ASSERT(pFrame, "GetFormTextData must take a valid frame pointer!");
-    jobject hashMap = NULL;
-
-    WTF::PassRefPtr<WebCore::HTMLCollection> collection = pFrame->document()->forms();
-    if (collection->length() > 0) {
+    if (form->autoComplete()) {
+        JNIEnv* env = getJNIEnv();
         jclass mapClass = env->FindClass("java/util/HashMap");
         LOG_ASSERT(mapClass, "Could not find HashMap class!");
         jmethodID init = env->GetMethodID(mapClass, "<init>", "(I)V");
         LOG_ASSERT(init, "Could not find constructor for HashMap");
-        hashMap = env->NewObject(mapClass, init, 1);
+        jobject hashMap = env->NewObject(mapClass, init, 1);
         LOG_ASSERT(hashMap, "Could not create a new HashMap");
         jmethodID put = env->GetMethodID(mapClass, "put",
                 "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
         LOG_ASSERT(put, "Could not find put method on HashMap");
-
-        WebCore::HTMLFormElement* form;
-        WebCore::HTMLInputElement* input;
-        for (WebCore::Node* node = collection->firstItem();
-             node && !node->namespaceURI().isNull() && !node->namespaceURI().isEmpty();
-             node = collection->nextItem()) {
-            form = static_cast<WebCore::HTMLFormElement*>(node);
-            if (form->autoComplete()) {
-                WTF::Vector<WebCore::HTMLFormControlElement*> elements = form->associatedElements();
-                size_t size = elements.size();
-                for (size_t i = 0; i < size; i++) {
-                    WebCore::HTMLFormControlElement* e = elements[i];
-                    if (e->hasTagName(WebCore::HTMLNames::inputTag)) {
-                        input = static_cast<WebCore::HTMLInputElement*>(e);
-                        if (input->isTextField() && !input->isPasswordField()
-                                && input->autoComplete()) {
-                            WTF::String value = input->value();
-                            int len = value.length();
-                            if (len) {
-                                const WTF::AtomicString& name = input->name();
-                                jstring key = wtfStringToJstring(env, name);
-                                jstring val = wtfStringToJstring(env, value);
-                                LOG_ASSERT(key && val, "name or value not set");
-                                env->CallObjectMethod(hashMap, put, key, val);
-                                env->DeleteLocalRef(key);
-                                env->DeleteLocalRef(val);
-                            }
-                        }
+        WTF::Vector<WebCore::HTMLFormControlElement*> elements = form->associatedElements();
+        size_t size = elements.size();
+        for (size_t i = 0; i < size; i++) {
+            WebCore::HTMLFormControlElement* e = elements[i];
+            if (e->hasTagName(WebCore::HTMLNames::inputTag)) {
+                WebCore::HTMLInputElement* input = static_cast<WebCore::HTMLInputElement*>(e);
+                if (input->isTextField() && !input->isPasswordField()
+                        && input->autoComplete()) {
+                    WTF::String value = input->value();
+                    int len = value.length();
+                    if (len) {
+                        const WTF::AtomicString& name = input->name();
+                        jstring key = wtfStringToJstring(env, name);
+                        jstring val = wtfStringToJstring(env, value);
+                        LOG_ASSERT(key && val, "name or value not set");
+                        env->CallObjectMethod(hashMap, put, key, val);
+                        env->DeleteLocalRef(key);
+                        env->DeleteLocalRef(val);
                     }
                 }
             }
         }
+        env->CallVoidMethod(mJavaFrame->frame(env).get(), mJavaFrame->mSaveFormData, hashMap);
+        env->DeleteLocalRef(hashMap);
         env->DeleteLocalRef(mapClass);
-
     }
-    return hashMap;
 }
 
 static void OrientationChanged(JNIEnv *env, jobject obj, int orientation)
@@ -2048,8 +2047,6 @@ static JNINativeMethod gBrowserFrameNativeMethods[] = {
         (void*) GetUsernamePassword },
     { "setUsernamePassword", "(Ljava/lang/String;Ljava/lang/String;)V",
         (void*) SetUsernamePassword },
-    { "getFormTextData", "()Ljava/util/HashMap;",
-        (void*) GetFormTextData },
     { "nativeOrientationChanged", "(I)V",
         (void*) OrientationChanged },
     { "nativeAuthenticationProceed", "(ILjava/lang/String;Ljava/lang/String;)V",
index ae62835..e507667 100644 (file)
@@ -37,6 +37,7 @@
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
+    class HTMLFormElement;
     class Frame;
     class HistoryItem;
     class Image;
@@ -128,15 +129,12 @@ class WebFrame : public WebCoreRefObject {
     void setCertificate(const std::string& issuedTo, const std::string& issuedBy, long long validNotBeforeMillis, long long validNotAfterMillis);
 
     /**
-     * When the user initiates an action (via trackball, key-press, or touch),
-     * we set mUserInitiatedAction to true.  If a load happens due to this click,
-     * then we ask the application if it wants to override
-     * the load. Otherwise, we attempt to load the resource internally.
+     * When the user initiates a click, we set mUserInitiatedAction to true.
+     * If a load happens due to this click, then we ask the application if it wants
+     * to override the load. Otherwise, we attempt to load the resource internally.
      */
     void setUserInitiatedAction(bool userInitiatedAction) { mUserInitiatedAction = userInitiatedAction; }
 
-    bool userInitiatedAction() { return mUserInitiatedAction; }
-    
     WebCore::Page* page() const { return mPage; }
 
     // Currently used only by the chrome net stack.  A similar field is used by
@@ -151,6 +149,8 @@ class WebFrame : public WebCoreRefObject {
     bool getUsernamePasswordFromDom(WebCore::Frame* frame, WTF::String& username, WTF::String& password);
     jbyteArray getPostData(const WebCore::ResourceRequest& request);
 
+    bool shouldSaveFormData();
+    void saveFormData(WebCore::HTMLFormElement*);
 private:
     struct JavaBrowserFrame;
     JavaBrowserFrame* mJavaFrame;
index b329e3b..f5e6fdd 100644 (file)
@@ -2888,94 +2888,6 @@ void WebViewCore::saveDocumentState(WebCore::Frame* frame)
     }
 }
 
-// Convert a WTF::String into an array of characters where the first
-// character represents the length, for easy conversion to java.
-static uint16_t* stringConverter(const WTF::String& text)
-{
-    size_t length = text.length();
-    uint16_t* itemName = new uint16_t[length+1];
-    itemName[0] = (uint16_t)length;
-    uint16_t* firstChar = &(itemName[1]);
-    memcpy((void*)firstChar, text.characters(), sizeof(UChar)*length);
-    return itemName;
-}
-
-// Response to dropdown created for a listbox.
-class ListBoxReply : public WebCoreReply {
-public:
-    ListBoxReply(WebCore::HTMLSelectElement* select, WebCore::Frame* frame, WebViewCore* view)
-        : m_select(select)
-        , m_frame(frame)
-        , m_viewImpl(view)
-    {}
-
-    // Response used for a multiple selection listbox if the user did not change
-    // anything, in which case -2 is used.
-    // Also used by a listbox which has single selection but a size is set.
-    virtual void replyInt(int index)
-    {
-        if (-2 == index) {
-            // Special value for cancel. Do nothing.
-            return;
-        }
-        // If the select element no longer exists, due to a page change, etc,
-        // silently return.
-        if (!m_select || !CacheBuilder::validNode(m_viewImpl->m_mainFrame,
-                m_frame, m_select))
-            return;
-        // Use a pointer to HTMLSelectElement's superclass, where
-        // listToOptionIndex is public
-        SelectElement* selectElement = m_select;
-        int optionIndex = selectElement->listToOptionIndex(index);
-        m_select->setSelectedIndex(optionIndex, true);
-        m_select->dispatchFormControlChangeEvent();
-        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, due to a page change, etc,
-        // silently return.
-        if (!m_select || !CacheBuilder::validNode(m_viewImpl->m_mainFrame,
-                m_frame, m_select))
-            return;
-
-        const WTF::Vector<Element*>& items = m_select->listItems();
-        int totalItems = static_cast<int>(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 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_select->dispatchFormControlChangeEvent();
-        m_viewImpl->contentInvalidate(m_select->getRect());
-    }
-private:
-    // The select element associated with this listbox.
-    WebCore::HTMLSelectElement* m_select;
-    // The frame of this select element, to verify that it is valid.
-    WebCore::Frame* m_frame;
-    // For calling invalidate and checking the select element's validity
-    WebViewCore* m_viewImpl;
-};
-
 // Create an array of java Strings.
 static jobjectArray makeLabelArray(JNIEnv* env, const uint16_t** labels, size_t count)
 {
@@ -3290,46 +3202,7 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node
             return true;
         }
 
-        WebCore::RenderObject* renderer = nodePtr->renderer();
-        if (renderer && renderer->isListBox()) {
-            WebCore::HTMLSelectElement* select = static_cast<WebCore::HTMLSelectElement*>(nodePtr);
-            const WTF::Vector<WebCore::Element*>& listItems = select->listItems();
-            SkTDArray<const uint16_t*> names;
-            // Possible values for enabledArray.  Keep in Sync with values in
-            // InvokeListBox.Container in WebView.java
-            enum OptionStatus {
-                OPTGROUP = -1,
-                OPTION_DISABLED = 0,
-                OPTION_ENABLED = 1,
-            };
-            SkTDArray<int> enabledArray;
-            SkTDArray<int> selectedArray;
-            int size = listItems.size();
-            bool multiple = select->multiple();
-            for (int i = 0; i < size; i++) {
-                if (listItems[i]->hasTagName(WebCore::HTMLNames::optionTag)) {
-                    WebCore::HTMLOptionElement* option = static_cast<WebCore::HTMLOptionElement*>(listItems[i]);
-                    *names.append() = stringConverter(option->textIndentedToRespectGroupLabel());
-                    *enabledArray.append() = option->disabled() ? OPTION_DISABLED : OPTION_ENABLED;
-                    if (multiple && option->selected())
-                        *selectedArray.append() = i;
-                } else if (listItems[i]->hasTagName(WebCore::HTMLNames::optgroupTag)) {
-                    WebCore::HTMLOptGroupElement* optGroup = static_cast<WebCore::HTMLOptGroupElement*>(listItems[i]);
-                    *names.append() = stringConverter(optGroup->groupLabelText());
-                    *enabledArray.append() = OPTGROUP;
-                }
-            }
-            WebCoreReply* reply = new ListBoxReply(select, select->document()->frame(), this);
-            // Use a pointer to HTMLSelectElement's superclass, where
-            // optionToListIndex is public.
-            SelectElement* selectElement = select;
-            listBoxRequest(reply, names.begin(), size, enabledArray.begin(), enabledArray.count(),
-                    multiple, selectedArray.begin(), multiple ? selectedArray.count() :
-                    selectElement->optionToListIndex(select->selectedIndex()));
-            DBG_NAV_LOG("list box");
-            return true;
-        }
-        scrollLayer(renderer, &m_mousePos);
+        scrollLayer(nodePtr->renderer(), &m_mousePos);
     }
     if (!valid || !framePtr)
         framePtr = m_mainFrame;