[BlackBerry] CHHW - Characters that are using 32 bits encoding get trunked to 16bits
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2013 15:24:28 +0000 (15:24 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2013 15:24:28 +0000 (15:24 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142120 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/PlatformKeyboardEvent.h
Source/WebCore/platform/blackberry/PlatformKeyboardEventBlackBerry.cpp
Source/WebKit/blackberry/Api/WebPage.cpp
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp
Source/WebKit/blackberry/WebKitSupport/InputHandler.h
Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp
Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h
Tools/ChangeLog
Tools/DumpRenderTree/blackberry/EventSender.cpp

index 107d192..65c6751 100644 (file)
@@ -1,3 +1,23 @@
+2013-02-07  Xiaobo Wang  <xbwang@torchmobile.com.cn>
+
+        [BlackBerry] CHHW - Characters that are using 32 bits encoding get trunked to 16bits
+        https://bugs.webkit.org/show_bug.cgi?id=109126
+        PR 292540
+
+        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):
+
 2013-02-07  Mike West  <mkwst@chromium.org>
 
         Replace ExceptionCode assertions with ASSERT_NO_EXCEPTION macro.
index b6e92d7..00c7846 100644 (file)
@@ -138,7 +138,7 @@ namespace WebCore {
         static void getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey);
 
 #if PLATFORM(BLACKBERRY)
-        unsigned short unmodifiedCharacter() const { return m_unmodifiedCharacter; }
+        unsigned unmodifiedCharacter() const { return m_unmodifiedCharacter; }
 #endif
 
 #if PLATFORM(MAC)
@@ -192,7 +192,7 @@ namespace WebCore {
         bool m_isSystemKey;
 
 #if PLATFORM(BLACKBERRY)
-        unsigned short m_unmodifiedCharacter;
+        unsigned m_unmodifiedCharacter;
 #endif
 
 #if PLATFORM(MAC)
index 0758913..a22f729 100644 (file)
@@ -30,7 +30,7 @@
 
 namespace WebCore {
 
-static String keyIdentifierForBlackBerryCharacter(unsigned short character)
+static String keyIdentifierForBlackBerryCharacter(unsigned character)
 {
     switch (character) {
     case KEYCODE_RETURN:
@@ -111,7 +111,7 @@ static String keyIdentifierForBlackBerryCharacter(unsigned short character)
     }
 }
 
-static int windowsKeyCodeForBlackBerryCharacter(unsigned short character)
+static int windowsKeyCodeForBlackBerryCharacter(unsigned character)
 {
     switch (character) {
     case KEYCODE_RETURN:
@@ -357,7 +357,7 @@ static int windowsKeyCodeForBlackBerryCharacter(unsigned short character)
     }
 }
 
-unsigned short adjustCharacterFromOS(unsigned short character)
+unsigned adjustCharacterFromOS(unsigned character)
 {
     // Use windows key character as ASCII value when possible to enhance readability.
     switch (character) {
@@ -446,8 +446,16 @@ PlatformKeyboardEvent::PlatformKeyboardEvent(const BlackBerry::Platform::Keyboar
     , m_isKeypad(false)
     , m_unmodifiedCharacter(event.character())
 {
-    unsigned short character = adjustCharacterFromOS(event.character());
-    m_text = String(&character, 1);
+    unsigned character = adjustCharacterFromOS(event.character());
+    UChar utf16[3] = {0};
+    int destLength = 0;
+    UErrorCode ec = U_ZERO_ERROR;
+    u_strFromUTF32(utf16, 3, &destLength, reinterpret_cast<UChar32*>(&character), 1, &ec);
+    if (ec) {
+        BBLOG(BlackBerry::Platform::LogLevelCritical, "PlatformKeyboardEvent::PlatformKeyboardEvent Error converting 0x%x to string ec (%d).", character, ec);
+        return;
+    }
+    m_text = String(utf16, destLength);
     m_unmodifiedText = m_text;
 
     if (event.character() == KEYCODE_BACK_TAB)
index ba63856..b3f4c2f 100644 (file)
@@ -4272,7 +4272,7 @@ void WebPage::setForcedTextEncoding(const BlackBerry::Platform::String& encoding
         return d->focusedOrMainFrame()->loader()->reloadWithOverrideEncoding(encoding);
 }
 
-static void handleScrolling(unsigned short character, WebPagePrivate* scroller)
+static void handleScrolling(unsigned character, WebPagePrivate* scroller)
 {
     const int scrollFactor = 20;
     int dx = 0, dy = 0;
index fb63314..3e6512c 100644 (file)
@@ -1,3 +1,30 @@
+2013-02-07  Xiaobo Wang  <xbwang@torchmobile.com.cn>
+
+        [BlackBerry] CHHW - Characters that are using 32 bits encoding get trunked to 16bits
+        https://bugs.webkit.org/show_bug.cgi?id=109126
+        PR 292540
+
+        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):
+
 2013-02-07  Sean Wang  <Xuewen.Wang@torchmobile.com.cn>
 
         [BlackBerry] Reader Mode: Opening two links quickly from reader mode causes browser bad state
index 221a170..0a344a6 100644 (file)
@@ -1553,7 +1553,7 @@ void InputHandler::cancelSelection()
 bool InputHandler::handleKeyboardInput(const Platform::KeyboardEvent& keyboardEvent, bool changeIsPartOfComposition)
 {
     InputLog(Platform::LogLevelInfo,
-        "InputHandler::handleKeyboardInput received character='%c', type=%d",
+        "InputHandler::handleKeyboardInput received character='%lc', type=%d",
         keyboardEvent.character(), keyboardEvent.type());
 
     // Clearing the m_shouldNotifyWebView state on any KeyboardEvent.
index 023c580..79c51e2 100644 (file)
@@ -238,7 +238,7 @@ private:
     int32_t m_processingTransactionId;
 
     bool m_shouldNotifyWebView;
-    unsigned short m_expectedKeyUpChar;
+    unsigned m_expectedKeyUpChar;
 
     imf_sp_text_t m_spellCheckingOptionsRequest;
     WebCore::IntSize m_screenOffset;
index 611dfe6..e1dee89 100644 (file)
@@ -184,7 +184,7 @@ static VisiblePosition visiblePositionForPointIgnoringClipping(const Frame& fram
     return visiblePos;
 }
 
-static unsigned short directionOfPointRelativeToRect(const WebCore::IntPoint& point, const WebCore::IntRect& rect, const bool useTopPadding = true, const bool useBottomPadding = true)
+static unsigned directionOfPointRelativeToRect(const WebCore::IntPoint& point, const WebCore::IntRect& rect, const bool useTopPadding = true, const bool useBottomPadding = true)
 {
     ASSERT(!rect.contains(point));
 
@@ -265,7 +265,7 @@ void SelectionHandler::setCaretPosition(const WebCore::IntPoint& position)
     if (RenderObject* focusedRenderer = focusedFrame->document()->focusedNode()->renderer()) {
         WebCore::IntRect nodeOutlineBounds(focusedRenderer->absoluteOutlineBounds());
         if (!nodeOutlineBounds.contains(relativePoint)) {
-            if (unsigned short character = directionOfPointRelativeToRect(relativePoint, currentCaretRect))
+            if (unsigned character = directionOfPointRelativeToRect(relativePoint, currentCaretRect))
                 m_webPage->m_inputHandler->handleKeyboardInput(Platform::KeyboardEvent(character));
 
             // Send the selection changed in case this does not trigger a selection change to
@@ -293,7 +293,7 @@ void SelectionHandler::inputHandlerDidFinishProcessingChange()
 }
 
 // This function makes sure we are not reducing the selection to a caret selection.
-static bool shouldExtendSelectionInDirection(const VisibleSelection& selection, unsigned short character)
+static bool shouldExtendSelectionInDirection(const VisibleSelection& selection, unsigned character)
 {
     FrameSelection tempSelection;
     tempSelection.setSelection(selection);
@@ -327,7 +327,7 @@ static int clamp(const int min, const int value, const int max)
     return value < min ? min : std::min(value, max);
 }
 
-static VisiblePosition directionalVisiblePositionAtExtentOfBox(Frame* frame, const WebCore::IntRect& boundingBox, unsigned short direction, const WebCore::IntPoint& basePoint)
+static VisiblePosition directionalVisiblePositionAtExtentOfBox(Frame* frame, const WebCore::IntRect& boundingBox, unsigned direction, const WebCore::IntPoint& basePoint)
 {
     ASSERT(frame);
 
@@ -365,7 +365,7 @@ static bool pointIsOutsideOfBoundingBoxInDirection(unsigned direction, const Web
     return false;
 }
 
-unsigned short SelectionHandler::extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, VisibleSelection& newSelection)
+unsigned SelectionHandler::extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, VisibleSelection& newSelection)
 {
     Frame* focusedFrame = m_webPage->focusedOrMainFrame();
     if (!focusedFrame->document()->focusedNode() || !focusedFrame->document()->focusedNode()->renderer())
@@ -381,7 +381,7 @@ unsigned short SelectionHandler::extendSelectionToFieldBoundary(bool isStartHand
 
     // Start handle is outside of the field. Treat it as the changed handle and move
     // relative to the start caret rect.
-    unsigned short character = directionOfPointRelativeToRect(selectionPoint, caretRect, isStartHandle /* useTopPadding */, !isStartHandle /* useBottomPadding */);
+    unsigned character = directionOfPointRelativeToRect(selectionPoint, caretRect, isStartHandle /* useTopPadding */, !isStartHandle /* useBottomPadding */);
 
     // Prevent incorrect movement, handles can only extend the selection this way
     // to prevent inversion of the handles.
@@ -439,7 +439,7 @@ bool SelectionHandler::updateOrHandleInputSelection(VisibleSelection& newSelecti
     if (startIsOutsideOfField && endIsOutsideOfField)
         return false;
 
-    unsigned short character = 0;
+    unsigned character = 0;
     if (startIsOutsideOfField) {
         character = extendSelectionToFieldBoundary(true /* isStartHandle */, relativeStart, newSelection);
         if (character) {
index a58e518..d431573 100644 (file)
@@ -85,7 +85,7 @@ private:
                                       , const WebCore::IntPoint& relativeEnd);
     WebCore::Node* DOMContainerNodeForVisiblePosition(const WebCore::VisiblePosition&) const;
     bool shouldUpdateSelectionOrCaretForPoint(const WebCore::IntPoint&, const WebCore::IntRect&, bool startCaret = true) const;
-    unsigned short extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, WebCore::VisibleSelection& newSelection);
+    unsigned extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, WebCore::VisibleSelection& newSelection);
     WebCore::IntPoint clipPointToVisibleContainer(const WebCore::IntPoint&) const;
 
     bool inputNodeOverridesTouch() const;
index 83c96c7..c43df15 100644 (file)
@@ -1,3 +1,16 @@
+2013-02-07  Xiaobo Wang  <xbwang@torchmobile.com.cn>
+
+        [BlackBerry] CHHW - Characters that are using 32 bits encoding get trunked to 16bits
+        https://bugs.webkit.org/show_bug.cgi?id=109126
+        PR 292540
+
+        Reviewed by Yong Li.
+
+        Change char code to 4 bytes.
+
+        * DumpRenderTree/blackberry/EventSender.cpp:
+        (keyDownCallback):
+
 2013-02-07  Gavin Peters  <gavinp@chromium.org>
 
         Unreviewed, rolling out r142090.
index a2c8dee..b2a8f22 100644 (file)
@@ -121,7 +121,7 @@ static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JS
 
     JSStringRef character = JSValueToStringCopy(context, arguments[0], exception);
     ASSERT(!*exception);
-    short charCode = 0;
+    unsigned charCode = 0;
     bool needsShiftKeyModifier = false;
     if (JSStringIsEqualToUTF8CString(character, "leftArrow"))
         charCode = KEYCODE_LEFT;