Changeset 142120 in webkit


Ignore:
Timestamp:
Feb 7, 2013 7:24:28 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry] CHHW - Characters that are using 32 bits encoding get trunked to 16bits
https://bugs.webkit.org/show_bug.cgi?id=109126
PR 292540

Source/WebCore:

Patch by Xiaobo Wang <xbwang@torchmobile.com.cn> on 2013-02-07
Reviewed by Yong Li.

Change char code to 4 bytes.
Need to convert UTF32 key char to UTF16 before constructing a WTF::String.

  • platform/PlatformKeyboardEvent.h:

(WebCore::PlatformKeyboardEvent::unmodifiedCharacter):
(PlatformKeyboardEvent):

  • platform/blackberry/PlatformKeyboardEventBlackBerry.cpp:

(WebCore::keyIdentifierForBlackBerryCharacter):
(WebCore::windowsKeyCodeForBlackBerryCharacter):
(WebCore::adjustCharacterFromOS):
(WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):

Source/WebKit/blackberry:

Patch by Xiaobo Wang <xbwang@torchmobile.com.cn> on 2013-02-07
Reviewed by Yong Li.
Internally reviewed by Mike Fenton.

Key char is UTF32 encoded, should be 4 bytes.

  • Api/WebPage.cpp:

(BlackBerry::WebKit::handleScrolling):

  • WebKitSupport/InputHandler.cpp:

(BlackBerry::WebKit::InputHandler::handleKeyboardInput):

  • WebKitSupport/InputHandler.h:

(InputHandler):

  • WebKitSupport/SelectionHandler.cpp:

(BlackBerry::WebKit::directionOfPointRelativeToRect):
(BlackBerry::WebKit::SelectionHandler::setCaretPosition):
(BlackBerry::WebKit::shouldExtendSelectionInDirection):
(BlackBerry::WebKit::directionalVisiblePositionAtExtentOfBox):
(BlackBerry::WebKit::SelectionHandler::extendSelectionToFieldBoundary):
(BlackBerry::WebKit::SelectionHandler::updateOrHandleInputSelection):

  • WebKitSupport/SelectionHandler.h:

(SelectionHandler):

Tools:

Patch by Xiaobo Wang <xbwang@torchmobile.com.cn> on 2013-02-07
Reviewed by Yong Li.

Change char code to 4 bytes.

  • DumpRenderTree/blackberry/EventSender.cpp:

(keyDownCallback):

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142118 r142120  
     12013-02-07  Xiaobo Wang  <xbwang@torchmobile.com.cn>
     2
     3        [BlackBerry] CHHW - Characters that are using 32 bits encoding get trunked to 16bits
     4        https://bugs.webkit.org/show_bug.cgi?id=109126
     5        PR 292540
     6
     7        Reviewed by Yong Li.
     8
     9        Change char code to 4 bytes.
     10        Need to convert UTF32 key char to UTF16 before constructing a WTF::String.
     11
     12        * platform/PlatformKeyboardEvent.h:
     13        (WebCore::PlatformKeyboardEvent::unmodifiedCharacter):
     14        (PlatformKeyboardEvent):
     15        * platform/blackberry/PlatformKeyboardEventBlackBerry.cpp:
     16        (WebCore::keyIdentifierForBlackBerryCharacter):
     17        (WebCore::windowsKeyCodeForBlackBerryCharacter):
     18        (WebCore::adjustCharacterFromOS):
     19        (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
     20
    1212013-02-07  Mike West  <mkwst@chromium.org>
    222
  • trunk/Source/WebCore/platform/PlatformKeyboardEvent.h

    r128572 r142120  
    139139
    140140#if PLATFORM(BLACKBERRY)
    141         unsigned short unmodifiedCharacter() const { return m_unmodifiedCharacter; }
     141        unsigned unmodifiedCharacter() const { return m_unmodifiedCharacter; }
    142142#endif
    143143
     
    193193
    194194#if PLATFORM(BLACKBERRY)
    195         unsigned short m_unmodifiedCharacter;
     195        unsigned m_unmodifiedCharacter;
    196196#endif
    197197
  • trunk/Source/WebCore/platform/blackberry/PlatformKeyboardEventBlackBerry.cpp

    r137817 r142120  
    3131namespace WebCore {
    3232
    33 static String keyIdentifierForBlackBerryCharacter(unsigned short character)
     33static String keyIdentifierForBlackBerryCharacter(unsigned character)
    3434{
    3535    switch (character) {
     
    112112}
    113113
    114 static int windowsKeyCodeForBlackBerryCharacter(unsigned short character)
     114static int windowsKeyCodeForBlackBerryCharacter(unsigned character)
    115115{
    116116    switch (character) {
     
    358358}
    359359
    360 unsigned short adjustCharacterFromOS(unsigned short character)
     360unsigned adjustCharacterFromOS(unsigned character)
    361361{
    362362    // Use windows key character as ASCII value when possible to enhance readability.
     
    447447    , m_unmodifiedCharacter(event.character())
    448448{
    449     unsigned short character = adjustCharacterFromOS(event.character());
    450     m_text = String(&character, 1);
     449    unsigned character = adjustCharacterFromOS(event.character());
     450    UChar utf16[3] = {0};
     451    int destLength = 0;
     452    UErrorCode ec = U_ZERO_ERROR;
     453    u_strFromUTF32(utf16, 3, &destLength, reinterpret_cast<UChar32*>(&character), 1, &ec);
     454    if (ec) {
     455        BBLOG(BlackBerry::Platform::LogLevelCritical, "PlatformKeyboardEvent::PlatformKeyboardEvent Error converting 0x%x to string ec (%d).", character, ec);
     456        return;
     457    }
     458    m_text = String(utf16, destLength);
    451459    m_unmodifiedText = m_text;
    452460
  • trunk/Source/WebKit/blackberry/Api/WebPage.cpp

    r141797 r142120  
    42734273}
    42744274
    4275 static void handleScrolling(unsigned short character, WebPagePrivate* scroller)
     4275static void handleScrolling(unsigned character, WebPagePrivate* scroller)
    42764276{
    42774277    const int scrollFactor = 20;
  • trunk/Source/WebKit/blackberry/ChangeLog

    r142117 r142120  
     12013-02-07  Xiaobo Wang  <xbwang@torchmobile.com.cn>
     2
     3        [BlackBerry] CHHW - Characters that are using 32 bits encoding get trunked to 16bits
     4        https://bugs.webkit.org/show_bug.cgi?id=109126
     5        PR 292540
     6
     7        Reviewed by Yong Li.
     8        Internally reviewed by Mike Fenton.
     9
     10        Key char is UTF32 encoded, should be 4 bytes.
     11
     12        * Api/WebPage.cpp:
     13        (BlackBerry::WebKit::handleScrolling):
     14        * WebKitSupport/InputHandler.cpp:
     15        (BlackBerry::WebKit::InputHandler::handleKeyboardInput):
     16        * WebKitSupport/InputHandler.h:
     17        (InputHandler):
     18        * WebKitSupport/SelectionHandler.cpp:
     19        (BlackBerry::WebKit::directionOfPointRelativeToRect):
     20        (BlackBerry::WebKit::SelectionHandler::setCaretPosition):
     21        (BlackBerry::WebKit::shouldExtendSelectionInDirection):
     22        (BlackBerry::WebKit::directionalVisiblePositionAtExtentOfBox):
     23        (BlackBerry::WebKit::SelectionHandler::extendSelectionToFieldBoundary):
     24        (BlackBerry::WebKit::SelectionHandler::updateOrHandleInputSelection):
     25        * WebKitSupport/SelectionHandler.h:
     26        (SelectionHandler):
     27
    1282013-02-07  Sean Wang  <Xuewen.Wang@torchmobile.com.cn>
    229
  • trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp

    r142116 r142120  
    15541554{
    15551555    InputLog(Platform::LogLevelInfo,
    1556         "InputHandler::handleKeyboardInput received character='%c', type=%d",
     1556        "InputHandler::handleKeyboardInput received character='%lc', type=%d",
    15571557        keyboardEvent.character(), keyboardEvent.type());
    15581558
  • trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.h

    r141623 r142120  
    239239
    240240    bool m_shouldNotifyWebView;
    241     unsigned short m_expectedKeyUpChar;
     241    unsigned m_expectedKeyUpChar;
    242242
    243243    imf_sp_text_t m_spellCheckingOptionsRequest;
  • trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp

    r140043 r142120  
    185185}
    186186
    187 static unsigned short directionOfPointRelativeToRect(const WebCore::IntPoint& point, const WebCore::IntRect& rect, const bool useTopPadding = true, const bool useBottomPadding = true)
     187static unsigned directionOfPointRelativeToRect(const WebCore::IntPoint& point, const WebCore::IntRect& rect, const bool useTopPadding = true, const bool useBottomPadding = true)
    188188{
    189189    ASSERT(!rect.contains(point));
     
    266266        WebCore::IntRect nodeOutlineBounds(focusedRenderer->absoluteOutlineBounds());
    267267        if (!nodeOutlineBounds.contains(relativePoint)) {
    268             if (unsigned short character = directionOfPointRelativeToRect(relativePoint, currentCaretRect))
     268            if (unsigned character = directionOfPointRelativeToRect(relativePoint, currentCaretRect))
    269269                m_webPage->m_inputHandler->handleKeyboardInput(Platform::KeyboardEvent(character));
    270270
     
    294294
    295295// This function makes sure we are not reducing the selection to a caret selection.
    296 static bool shouldExtendSelectionInDirection(const VisibleSelection& selection, unsigned short character)
     296static bool shouldExtendSelectionInDirection(const VisibleSelection& selection, unsigned character)
    297297{
    298298    FrameSelection tempSelection;
     
    328328}
    329329
    330 static VisiblePosition directionalVisiblePositionAtExtentOfBox(Frame* frame, const WebCore::IntRect& boundingBox, unsigned short direction, const WebCore::IntPoint& basePoint)
     330static VisiblePosition directionalVisiblePositionAtExtentOfBox(Frame* frame, const WebCore::IntRect& boundingBox, unsigned direction, const WebCore::IntPoint& basePoint)
    331331{
    332332    ASSERT(frame);
     
    366366}
    367367
    368 unsigned short SelectionHandler::extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, VisibleSelection& newSelection)
     368unsigned SelectionHandler::extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, VisibleSelection& newSelection)
    369369{
    370370    Frame* focusedFrame = m_webPage->focusedOrMainFrame();
     
    382382    // Start handle is outside of the field. Treat it as the changed handle and move
    383383    // relative to the start caret rect.
    384     unsigned short character = directionOfPointRelativeToRect(selectionPoint, caretRect, isStartHandle /* useTopPadding */, !isStartHandle /* useBottomPadding */);
     384    unsigned character = directionOfPointRelativeToRect(selectionPoint, caretRect, isStartHandle /* useTopPadding */, !isStartHandle /* useBottomPadding */);
    385385
    386386    // Prevent incorrect movement, handles can only extend the selection this way
     
    440440        return false;
    441441
    442     unsigned short character = 0;
     442    unsigned character = 0;
    443443    if (startIsOutsideOfField) {
    444444        character = extendSelectionToFieldBoundary(true /* isStartHandle */, relativeStart, newSelection);
  • trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h

    r138905 r142120  
    8686    WebCore::Node* DOMContainerNodeForVisiblePosition(const WebCore::VisiblePosition&) const;
    8787    bool shouldUpdateSelectionOrCaretForPoint(const WebCore::IntPoint&, const WebCore::IntRect&, bool startCaret = true) const;
    88     unsigned short extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, WebCore::VisibleSelection& newSelection);
     88    unsigned extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, WebCore::VisibleSelection& newSelection);
    8989    WebCore::IntPoint clipPointToVisibleContainer(const WebCore::IntPoint&) const;
    9090
  • trunk/Tools/ChangeLog

    r142109 r142120  
     12013-02-07  Xiaobo Wang  <xbwang@torchmobile.com.cn>
     2
     3        [BlackBerry] CHHW - Characters that are using 32 bits encoding get trunked to 16bits
     4        https://bugs.webkit.org/show_bug.cgi?id=109126
     5        PR 292540
     6
     7        Reviewed by Yong Li.
     8
     9        Change char code to 4 bytes.
     10
     11        * DumpRenderTree/blackberry/EventSender.cpp:
     12        (keyDownCallback):
     13
    1142013-02-07  Gavin Peters  <gavinp@chromium.org>
    215
  • trunk/Tools/DumpRenderTree/blackberry/EventSender.cpp

    r137880 r142120  
    122122    JSStringRef character = JSValueToStringCopy(context, arguments[0], exception);
    123123    ASSERT(!*exception);
    124     short charCode = 0;
     124    unsigned charCode = 0;
    125125    bool needsShiftKeyModifier = false;
    126126    if (JSStringIsEqualToUTF8CString(character, "leftArrow"))
Note: See TracChangeset for help on using the changeset viewer.