Title: [116400] trunk/Source/WebKit
Revision
116400
Author
[email protected]
Date
2012-05-08 00:05:01 -0700 (Tue, 08 May 2012)

Log Message

[BlackBerry] AutofillManager implementation upstream
https://bugs.webkit.org/show_bug.cgi?id=85576

Patch by Jonathan Dong <[email protected]> on 2012-05-08
Reviewed by Rob Buis.

Source/WebKit:

Added WebKit/blackberry/WebCoreSupport/AutofillManager.cpp
into building system of BlackBerry porting.

* PlatformBlackBerry.cmake:

Source/WebKit/blackberry:

RIM PR: 136405
Implemented class AutofillManager to handle the form autofill
interactions.
It listens to text changed notification from text input, searches
autofill database for the suggested autofill candidate value,
and notifies WebPageClient to pop up a context dialog for user;
it also responds to user's choice by autofilling the text input.

* WebCoreSupport/AutofillManager.cpp: Added.
(WebCore):
(WebCore::AutofillManager::create):
(WebCore::AutofillManager::didChangeInTextField):
(WebCore::AutofillManager::autofillTextField):
(WebCore::AutofillManager::saveTextFields):
(WebCore::AutofillManager::clear):
* WebCoreSupport/AutofillManager.h: Added.
(WTF):
(WebKit):
(WebCore):
(AutofillManager):
(WebCore::AutofillManager::m_element):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (116399 => 116400)


--- trunk/Source/WebKit/ChangeLog	2012-05-08 06:59:45 UTC (rev 116399)
+++ trunk/Source/WebKit/ChangeLog	2012-05-08 07:05:01 UTC (rev 116400)
@@ -1,3 +1,15 @@
+2012-05-08  Jonathan Dong  <[email protected]>
+
+        [BlackBerry] AutofillManager implementation upstream
+        https://bugs.webkit.org/show_bug.cgi?id=85576
+
+        Reviewed by Rob Buis.
+
+        Added WebKit/blackberry/WebCoreSupport/AutofillManager.cpp
+        into building system of BlackBerry porting.
+
+        * PlatformBlackBerry.cmake:
+
 2012-05-03  Jer Noble  <[email protected]>
 
         Move WebKitFullScreenListener into its own file.

Modified: trunk/Source/WebKit/PlatformBlackBerry.cmake (116399 => 116400)


--- trunk/Source/WebKit/PlatformBlackBerry.cmake	2012-05-08 06:59:45 UTC (rev 116399)
+++ trunk/Source/WebKit/PlatformBlackBerry.cmake	2012-05-08 07:05:01 UTC (rev 116400)
@@ -56,6 +56,7 @@
     blackberry/Api/WebSettings.cpp
     blackberry/Api/WebViewportArguments.cpp
     blackberry/WebCoreSupport/AboutData.cpp
+    blackberry/WebCoreSupport/AutofillManager.cpp
     blackberry/WebCoreSupport/CacheClientBlackBerry.cpp
     blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp
     blackberry/WebCoreSupport/ClientExtension.cpp

Modified: trunk/Source/WebKit/blackberry/ChangeLog (116399 => 116400)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-05-08 06:59:45 UTC (rev 116399)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-05-08 07:05:01 UTC (rev 116400)
@@ -1,3 +1,32 @@
+2012-05-08  Jonathan Dong  <[email protected]>
+
+        [BlackBerry] AutofillManager implementation upstream
+        https://bugs.webkit.org/show_bug.cgi?id=85576
+
+        Reviewed by Rob Buis.
+
+        RIM PR: 136405
+        Implemented class AutofillManager to handle the form autofill
+        interactions.
+        It listens to text changed notification from text input, searches
+        autofill database for the suggested autofill candidate value,
+        and notifies WebPageClient to pop up a context dialog for user;
+        it also responds to user's choice by autofilling the text input.
+
+        * WebCoreSupport/AutofillManager.cpp: Added.
+        (WebCore):
+        (WebCore::AutofillManager::create):
+        (WebCore::AutofillManager::didChangeInTextField):
+        (WebCore::AutofillManager::autofillTextField):
+        (WebCore::AutofillManager::saveTextFields):
+        (WebCore::AutofillManager::clear):
+        * WebCoreSupport/AutofillManager.h: Added.
+        (WTF):
+        (WebKit):
+        (WebCore):
+        (AutofillManager):
+        (WebCore::AutofillManager::m_element):
+
 2012-05-07  Andrew Lo  <[email protected]>
 
         [BlackBerry] Delete previous buffer when new over-scroll image path is set

Added: trunk/Source/WebKit/blackberry/WebCoreSupport/AutofillManager.cpp (0 => 116400)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/AutofillManager.cpp	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/AutofillManager.cpp	2012-05-08 07:05:01 UTC (rev 116400)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+
+#include "AutofillManager.h"
+
+#include "AutofillBackingStore.h"
+#include "HTMLCollection.h"
+#include "HTMLFormElement.h"
+#include "HTMLInputElement.h"
+#include "WebPage_p.h"
+
+namespace WebCore {
+
+static bool isAutofillable(HTMLInputElement* element)
+{
+    return element && element->isTextField() && !element->isPasswordField()
+        && !element->isAutofilled() && element->shouldAutocomplete();
+}
+
+PassRefPtr<AutofillManager> AutofillManager::create(BlackBerry::WebKit::WebPagePrivate* page)
+{
+    return adoptRef(new AutofillManager(page));
+}
+
+void AutofillManager::didChangeInTextField(HTMLInputElement* element)
+{
+    if (!isAutofillable(element))
+        return;
+
+    if (m_element != element)
+        m_element = element;
+
+    // FIXME: Notify page client to popup a context dialog to display these autofill candidate items.
+}
+
+void AutofillManager::autofillTextField(const String& value)
+{
+    if (!m_element)
+        return;
+
+    m_element->setValue(value);
+    m_element->setAutofilled();
+}
+
+void AutofillManager::saveTextFields(HTMLFormElement* form)
+{
+    RefPtr<HTMLCollection> elements = form->elements();
+    size_t itemCount = elements->length();
+    for (size_t i = 0; i < itemCount; ++i) {
+        HTMLInputElement* element = form->item(i)->toInputElement();
+        if (!isAutofillable(element))
+            continue;
+        autofillBackingStore().add(element->getAttribute(HTMLNames::nameAttr).string(), element->value());
+    }
+}
+
+void AutofillManager::clear()
+{
+    autofillBackingStore().clear();
+}
+
+} // namespace WebCore

Added: trunk/Source/WebKit/blackberry/WebCoreSupport/AutofillManager.h (0 => 116400)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/AutofillManager.h	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/AutofillManager.h	2012-05-08 07:05:01 UTC (rev 116400)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef AutofillManager_h
+#define AutofillManager_h
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WTF {
+class String;
+}
+
+namespace BlackBerry {
+namespace WebKit {
+class WebPagePrivate;
+}
+}
+
+namespace WebCore {
+class HTMLFormElement;
+class HTMLInputElement;
+
+class AutofillManager : public RefCounted<AutofillManager> {
+public:
+    static PassRefPtr<AutofillManager> create(BlackBerry::WebKit::WebPagePrivate*);
+
+    void didChangeInTextField(HTMLInputElement*);
+    void autofillTextField(const WTF::String&);
+    void saveTextFields(HTMLFormElement*);
+
+    static void clear();
+
+private:
+    AutofillManager(BlackBerry::WebKit::WebPagePrivate* page) : m_webPagePrivate(page), m_element(0) { }
+
+    BlackBerry::WebKit::WebPagePrivate* m_webPagePrivate;
+    HTMLInputElement* m_element;
+};
+
+} // WebCore
+
+#endif // AutofillManager_h
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to