Changeset 122599 in webkit


Ignore:
Timestamp:
Jul 13, 2012 10:23:16 AM (12 years ago)
Author:
mifenton@rim.com
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):

Location:
trunk/Source/WebKit/blackberry
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/blackberry/Api/WebPageClient.h

    r122444 r122599  
    136136    virtual void resizeSurfaceIfNeeded() = 0;
    137137
    138     virtual void inputFocusGained(Platform::BlackBerryInputType, int inputStyle) = 0;
     138    virtual void inputFocusGained(Platform::BlackBerryInputType, int inputStyle, Platform::VirtualKeyboardType, Platform::VirtualKeyboardEnterKeyType) = 0;
    139139    virtual void inputFocusLost() = 0;
    140140    virtual void inputTextChanged() = 0;
  • trunk/Source/WebKit/blackberry/ChangeLog

    r122589 r122599  
     12012-07-13  Mike Fenton  <mifenton@rim.com>
     2
     3        [BlackBerry] Add support for attributes to define keyboard and enter key type on the Virtual Keyboard
     4        https://bugs.webkit.org/show_bug.cgi?id=91248
     5
     6        Reviewed by Antonio Gomes.
     7
     8        PR 174733.
     9
     10        Add data-blackberry-virtual-keyboard-type and
     11        data-blackberry-virtual-keyboard-enter-key to
     12        enable configuration of the desired virtual keyboard
     13        using element attributes.
     14
     15        Reviewed Internally by Gen Mak.
     16
     17        * Api/WebPageClient.h:
     18        * WebKitSupport/InputHandler.cpp:
     19        (BlackBerry::WebKit::convertStringToKeyboardType):
     20        (WebKit):
     21        (BlackBerry::WebKit::keyboardTypeAttribute):
     22        (BlackBerry::WebKit::convertStringToKeyboardEnterKeyType):
     23        (BlackBerry::WebKit::keyboardEnterKeyTypeAttribute):
     24        (BlackBerry::WebKit::InputHandler::setElementFocused):
     25
    1262012-07-13  Jacky Jiang  <zhajiang@rim.com>
    227
  • trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp

    r122364 r122599  
    3333#include "Frame.h"
    3434#include "FrameView.h"
     35#include "HTMLFormElement.h"
    3536#include "HTMLInputElement.h"
    3637#include "HTMLNames.h"
     
    213214}
    214215
     216static VirtualKeyboardType convertStringToKeyboardType(const AtomicString& string)
     217{
     218    DEFINE_STATIC_LOCAL(AtomicString, Default, ("default"));
     219    DEFINE_STATIC_LOCAL(AtomicString, Url, ("url"));
     220    DEFINE_STATIC_LOCAL(AtomicString, Email, ("email"));
     221    DEFINE_STATIC_LOCAL(AtomicString, Password, ("password"));
     222    DEFINE_STATIC_LOCAL(AtomicString, Web, ("web"));
     223    DEFINE_STATIC_LOCAL(AtomicString, Number, ("number"));
     224    DEFINE_STATIC_LOCAL(AtomicString, Symbol, ("symbol"));
     225    DEFINE_STATIC_LOCAL(AtomicString, Phone, ("phone"));
     226    DEFINE_STATIC_LOCAL(AtomicString, Pin, ("pin"));
     227    DEFINE_STATIC_LOCAL(AtomicString, Hex, ("hexadecimal"));
     228
     229    if (string.isEmpty())
     230        return VKBTypeNotSet;
     231    if (equalIgnoringCase(string, Default))
     232        return VKBTypeDefault;
     233    if (equalIgnoringCase(string, Url))
     234        return VKBTypeUrl;
     235    if (equalIgnoringCase(string, Email))
     236        return VKBTypeEmail;
     237    if (equalIgnoringCase(string, Password))
     238        return VKBTypePassword;
     239    if (equalIgnoringCase(string, Web))
     240        return VKBTypeWeb;
     241    if (equalIgnoringCase(string, Number))
     242        return VKBTypeNumPunc;
     243    if (equalIgnoringCase(string, Symbol))
     244        return VKBTypeSymbol;
     245    if (equalIgnoringCase(string, Phone))
     246        return VKBTypePhone;
     247    if (equalIgnoringCase(string, Pin) || equalIgnoringCase(string, Hex))
     248        return VKBTypePin;
     249    return VKBTypeNotSet;
     250}
     251
     252static VirtualKeyboardType keyboardTypeAttribute(const WebCore::Element* element)
     253{
     254    DEFINE_STATIC_LOCAL(QualifiedName, keyboardTypeAttr, (nullAtom, "data-blackberry-virtual-keyboard-type", nullAtom));
     255
     256    if (element->fastHasAttribute(keyboardTypeAttr)) {
     257        AtomicString attributeString = element->fastGetAttribute(keyboardTypeAttr);
     258        return convertStringToKeyboardType(attributeString);
     259    }
     260
     261    if (element->isFormControlElement()) {
     262        const HTMLFormControlElement* formElement = static_cast<const HTMLFormControlElement*>(element);
     263        if (formElement->form() && formElement->form()->fastHasAttribute(keyboardTypeAttr)) {
     264            AtomicString attributeString = formElement->form()->fastGetAttribute(keyboardTypeAttr);
     265            return convertStringToKeyboardType(attributeString);
     266        }
     267    }
     268
     269    return VKBTypeNotSet;
     270}
     271
     272static VirtualKeyboardEnterKeyType convertStringToKeyboardEnterKeyType(const AtomicString& string)
     273{
     274    DEFINE_STATIC_LOCAL(AtomicString, Default, ("default"));
     275    DEFINE_STATIC_LOCAL(AtomicString, Connect, ("connect"));
     276    DEFINE_STATIC_LOCAL(AtomicString, Done, ("done"));
     277    DEFINE_STATIC_LOCAL(AtomicString, Go, ("go"));
     278    DEFINE_STATIC_LOCAL(AtomicString, Join, ("join"));
     279    DEFINE_STATIC_LOCAL(AtomicString, Next, ("next"));
     280    DEFINE_STATIC_LOCAL(AtomicString, Search, ("search"));
     281    DEFINE_STATIC_LOCAL(AtomicString, Send, ("send"));
     282    DEFINE_STATIC_LOCAL(AtomicString, Submit, ("submit"));
     283
     284    if (string.isEmpty())
     285        return VKBEnterKeyNotSet;
     286    if (equalIgnoringCase(string, Default))
     287        return VKBEnterKeyDefault;
     288    if (equalIgnoringCase(string, Connect))
     289        return VKBEnterKeyConnect;
     290    if (equalIgnoringCase(string, Done))
     291        return VKBEnterKeyDone;
     292    if (equalIgnoringCase(string, Go))
     293        return VKBEnterKeyGo;
     294    if (equalIgnoringCase(string, Join))
     295        return VKBEnterKeyJoin;
     296    if (equalIgnoringCase(string, Next))
     297        return VKBEnterKeyNext;
     298    if (equalIgnoringCase(string, Search))
     299        return VKBEnterKeySearch;
     300    if (equalIgnoringCase(string, Send))
     301        return VKBEnterKeySend;
     302    if (equalIgnoringCase(string, Submit))
     303        return VKBEnterKeySubmit;
     304    return VKBEnterKeyNotSet;
     305}
     306
     307static VirtualKeyboardEnterKeyType keyboardEnterKeyTypeAttribute(const WebCore::Element* element)
     308{
     309    DEFINE_STATIC_LOCAL(QualifiedName, keyboardEnterKeyTypeAttr, (nullAtom, "data-blackberry-virtual-keyboard-enter-key", nullAtom));
     310
     311    if (element->fastHasAttribute(keyboardEnterKeyTypeAttr)) {
     312        AtomicString attributeString = element->fastGetAttribute(keyboardEnterKeyTypeAttr);
     313        return convertStringToKeyboardEnterKeyType(attributeString);
     314    }
     315
     316    if (element->isFormControlElement()) {
     317        const HTMLFormControlElement* formElement = static_cast<const HTMLFormControlElement*>(element);
     318        if (formElement->form() && formElement->form()->fastHasAttribute(keyboardEnterKeyTypeAttr)) {
     319            AtomicString attributeString = formElement->form()->fastGetAttribute(keyboardEnterKeyTypeAttr);
     320            return convertStringToKeyboardEnterKeyType(attributeString);
     321        }
     322    }
     323
     324    return VKBEnterKeyNotSet;
     325}
     326
    215327WTF::String InputHandler::elementText()
    216328{
     
    480592    m_currentFocusElementTextEditMask = inputStyle(type, element);
    481593
    482     FocusLog(LogLevelInfo, "InputHandler::setElementFocused, Type=%d, Style=%d", type, m_currentFocusElementTextEditMask);
    483     m_webPage->m_client->inputFocusGained(type, m_currentFocusElementTextEditMask);
     594    VirtualKeyboardType keyboardType = keyboardTypeAttribute(element);
     595    VirtualKeyboardEnterKeyType enterKeyType = keyboardEnterKeyTypeAttribute(element);
     596
     597    FocusLog(LogLevelInfo, "InputHandler::setElementFocused, Type=%d, Style=%d, Keyboard Type=%d, Enter Key=%d", type, m_currentFocusElementTextEditMask, keyboardType, enterKeyType);
     598    m_webPage->m_client->inputFocusGained(type, m_currentFocusElementTextEditMask, keyboardType, enterKeyType);
    484599
    485600    handleInputLocaleChanged(m_webPage->m_webSettings->isWritingDirectionRTL());
Note: See TracChangeset for help on using the changeset viewer.