Title: [122599] trunk/Source/WebKit/blackberry
Revision
122599
Author
[email protected]
Date
2012-07-13 10:23:16 -0700 (Fri, 13 Jul 2012)

Log Message

[BlackBerry] Add support for attributes to define keyboard and enter key type on the Virtual Keyboard
https://bugs.webkit.org/show_bug.cgi?id=91248

Reviewed by Antonio Gomes.

PR 174733.

Add data-blackberry-virtual-keyboard-type and
data-blackberry-virtual-keyboard-enter-key to
enable configuration of the desired virtual keyboard
using element attributes.

Reviewed Internally by Gen Mak.

* Api/WebPageClient.h:
* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::convertStringToKeyboardType):
(WebKit):
(BlackBerry::WebKit::keyboardTypeAttribute):
(BlackBerry::WebKit::convertStringToKeyboardEnterKeyType):
(BlackBerry::WebKit::keyboardEnterKeyTypeAttribute):
(BlackBerry::WebKit::InputHandler::setElementFocused):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/WebPageClient.h (122598 => 122599)


--- trunk/Source/WebKit/blackberry/Api/WebPageClient.h	2012-07-13 17:19:28 UTC (rev 122598)
+++ trunk/Source/WebKit/blackberry/Api/WebPageClient.h	2012-07-13 17:23:16 UTC (rev 122599)
@@ -135,7 +135,7 @@
     virtual void notifyContentRendered(const Platform::IntRect&) = 0;
     virtual void resizeSurfaceIfNeeded() = 0;
 
-    virtual void inputFocusGained(Platform::BlackBerryInputType, int inputStyle) = 0;
+    virtual void inputFocusGained(Platform::BlackBerryInputType, int inputStyle, Platform::VirtualKeyboardType, Platform::VirtualKeyboardEnterKeyType) = 0;
     virtual void inputFocusLost() = 0;
     virtual void inputTextChanged() = 0;
     virtual void inputSelectionChanged(unsigned selectionStart, unsigned selectionEnd) = 0;

Modified: trunk/Source/WebKit/blackberry/ChangeLog (122598 => 122599)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-07-13 17:19:28 UTC (rev 122598)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-07-13 17:23:16 UTC (rev 122599)
@@ -1,3 +1,28 @@
+2012-07-13  Mike Fenton  <[email protected]>
+
+        [BlackBerry] Add support for attributes to define keyboard and enter key type on the Virtual Keyboard
+        https://bugs.webkit.org/show_bug.cgi?id=91248
+
+        Reviewed by Antonio Gomes.
+
+        PR 174733.
+
+        Add data-blackberry-virtual-keyboard-type and
+        data-blackberry-virtual-keyboard-enter-key to
+        enable configuration of the desired virtual keyboard
+        using element attributes.
+
+        Reviewed Internally by Gen Mak.
+
+        * Api/WebPageClient.h:
+        * WebKitSupport/InputHandler.cpp:
+        (BlackBerry::WebKit::convertStringToKeyboardType):
+        (WebKit):
+        (BlackBerry::WebKit::keyboardTypeAttribute):
+        (BlackBerry::WebKit::convertStringToKeyboardEnterKeyType):
+        (BlackBerry::WebKit::keyboardEnterKeyTypeAttribute):
+        (BlackBerry::WebKit::InputHandler::setElementFocused):
+
 2012-07-13  Jacky Jiang  <[email protected]>
 
         [BlackBerry] resetBitmapZoomScale called while zooming preventing pinch zoom

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (122598 => 122599)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-07-13 17:19:28 UTC (rev 122598)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-07-13 17:23:16 UTC (rev 122599)
@@ -32,6 +32,7 @@
 #include "FocusController.h"
 #include "Frame.h"
 #include "FrameView.h"
+#include "HTMLFormElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "HTMLOptGroupElement.h"
@@ -212,6 +213,117 @@
     return DEFAULT_STYLE;
 }
 
+static VirtualKeyboardType convertStringToKeyboardType(const AtomicString& string)
+{
+    DEFINE_STATIC_LOCAL(AtomicString, Default, ("default"));
+    DEFINE_STATIC_LOCAL(AtomicString, Url, ("url"));
+    DEFINE_STATIC_LOCAL(AtomicString, Email, ("email"));
+    DEFINE_STATIC_LOCAL(AtomicString, Password, ("password"));
+    DEFINE_STATIC_LOCAL(AtomicString, Web, ("web"));
+    DEFINE_STATIC_LOCAL(AtomicString, Number, ("number"));
+    DEFINE_STATIC_LOCAL(AtomicString, Symbol, ("symbol"));
+    DEFINE_STATIC_LOCAL(AtomicString, Phone, ("phone"));
+    DEFINE_STATIC_LOCAL(AtomicString, Pin, ("pin"));
+    DEFINE_STATIC_LOCAL(AtomicString, Hex, ("hexadecimal"));
+
+    if (string.isEmpty())
+        return VKBTypeNotSet;
+    if (equalIgnoringCase(string, Default))
+        return VKBTypeDefault;
+    if (equalIgnoringCase(string, Url))
+        return VKBTypeUrl;
+    if (equalIgnoringCase(string, Email))
+        return VKBTypeEmail;
+    if (equalIgnoringCase(string, Password))
+        return VKBTypePassword;
+    if (equalIgnoringCase(string, Web))
+        return VKBTypeWeb;
+    if (equalIgnoringCase(string, Number))
+        return VKBTypeNumPunc;
+    if (equalIgnoringCase(string, Symbol))
+        return VKBTypeSymbol;
+    if (equalIgnoringCase(string, Phone))
+        return VKBTypePhone;
+    if (equalIgnoringCase(string, Pin) || equalIgnoringCase(string, Hex))
+        return VKBTypePin;
+    return VKBTypeNotSet;
+}
+
+static VirtualKeyboardType keyboardTypeAttribute(const WebCore::Element* element)
+{
+    DEFINE_STATIC_LOCAL(QualifiedName, keyboardTypeAttr, (nullAtom, "data-blackberry-virtual-keyboard-type", nullAtom));
+
+    if (element->fastHasAttribute(keyboardTypeAttr)) {
+        AtomicString attributeString = element->fastGetAttribute(keyboardTypeAttr);
+        return convertStringToKeyboardType(attributeString);
+    }
+
+    if (element->isFormControlElement()) {
+        const HTMLFormControlElement* formElement = static_cast<const HTMLFormControlElement*>(element);
+        if (formElement->form() && formElement->form()->fastHasAttribute(keyboardTypeAttr)) {
+            AtomicString attributeString = formElement->form()->fastGetAttribute(keyboardTypeAttr);
+            return convertStringToKeyboardType(attributeString);
+        }
+    }
+
+    return VKBTypeNotSet;
+}
+
+static VirtualKeyboardEnterKeyType convertStringToKeyboardEnterKeyType(const AtomicString& string)
+{
+    DEFINE_STATIC_LOCAL(AtomicString, Default, ("default"));
+    DEFINE_STATIC_LOCAL(AtomicString, Connect, ("connect"));
+    DEFINE_STATIC_LOCAL(AtomicString, Done, ("done"));
+    DEFINE_STATIC_LOCAL(AtomicString, Go, ("go"));
+    DEFINE_STATIC_LOCAL(AtomicString, Join, ("join"));
+    DEFINE_STATIC_LOCAL(AtomicString, Next, ("next"));
+    DEFINE_STATIC_LOCAL(AtomicString, Search, ("search"));
+    DEFINE_STATIC_LOCAL(AtomicString, Send, ("send"));
+    DEFINE_STATIC_LOCAL(AtomicString, Submit, ("submit"));
+
+    if (string.isEmpty())
+        return VKBEnterKeyNotSet;
+    if (equalIgnoringCase(string, Default))
+        return VKBEnterKeyDefault;
+    if (equalIgnoringCase(string, Connect))
+        return VKBEnterKeyConnect;
+    if (equalIgnoringCase(string, Done))
+        return VKBEnterKeyDone;
+    if (equalIgnoringCase(string, Go))
+        return VKBEnterKeyGo;
+    if (equalIgnoringCase(string, Join))
+        return VKBEnterKeyJoin;
+    if (equalIgnoringCase(string, Next))
+        return VKBEnterKeyNext;
+    if (equalIgnoringCase(string, Search))
+        return VKBEnterKeySearch;
+    if (equalIgnoringCase(string, Send))
+        return VKBEnterKeySend;
+    if (equalIgnoringCase(string, Submit))
+        return VKBEnterKeySubmit;
+    return VKBEnterKeyNotSet;
+}
+
+static VirtualKeyboardEnterKeyType keyboardEnterKeyTypeAttribute(const WebCore::Element* element)
+{
+    DEFINE_STATIC_LOCAL(QualifiedName, keyboardEnterKeyTypeAttr, (nullAtom, "data-blackberry-virtual-keyboard-enter-key", nullAtom));
+
+    if (element->fastHasAttribute(keyboardEnterKeyTypeAttr)) {
+        AtomicString attributeString = element->fastGetAttribute(keyboardEnterKeyTypeAttr);
+        return convertStringToKeyboardEnterKeyType(attributeString);
+    }
+
+    if (element->isFormControlElement()) {
+        const HTMLFormControlElement* formElement = static_cast<const HTMLFormControlElement*>(element);
+        if (formElement->form() && formElement->form()->fastHasAttribute(keyboardEnterKeyTypeAttr)) {
+            AtomicString attributeString = formElement->form()->fastGetAttribute(keyboardEnterKeyTypeAttr);
+            return convertStringToKeyboardEnterKeyType(attributeString);
+        }
+    }
+
+    return VKBEnterKeyNotSet;
+}
+
 WTF::String InputHandler::elementText()
 {
     if (!isActiveTextEdit())
@@ -479,9 +591,12 @@
     BlackBerryInputType type = elementType(element);
     m_currentFocusElementTextEditMask = inputStyle(type, element);
 
-    FocusLog(LogLevelInfo, "InputHandler::setElementFocused, Type=%d, Style=%d", type, m_currentFocusElementTextEditMask);
-    m_webPage->m_client->inputFocusGained(type, m_currentFocusElementTextEditMask);
+    VirtualKeyboardType keyboardType = keyboardTypeAttribute(element);
+    VirtualKeyboardEnterKeyType enterKeyType = keyboardEnterKeyTypeAttribute(element);
 
+    FocusLog(LogLevelInfo, "InputHandler::setElementFocused, Type=%d, Style=%d, Keyboard Type=%d, Enter Key=%d", type, m_currentFocusElementTextEditMask, keyboardType, enterKeyType);
+    m_webPage->m_client->inputFocusGained(type, m_currentFocusElementTextEditMask, keyboardType, enterKeyType);
+
     handleInputLocaleChanged(m_webPage->m_webSettings->isWritingDirectionRTL());
 
     if (!m_delayKeyboardVisibilityChange)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to