[WPE] Remove glib usage in PlatformKeyboardEventWPE.cpp
authorchris.reid@sony.com <chris.reid@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2018 16:13:06 +0000 (16:13 +0000)
committerchris.reid@sony.com <chris.reid@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2018 16:13:06 +0000 (16:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191606

Reviewed by Michael Catanzaro.

No behavior change.

Use StringBuilder::append(UChar32) as a generic way to convert a uint32_t code point to WTFString.

* platform/wpe/PlatformKeyboardEventWPE.cpp:
(WebCore::PlatformKeyboardEvent::keyValueForWPEKeyCode):
(WebCore::PlatformKeyboardEvent::singleCharacterString):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/wpe/PlatformKeyboardEventWPE.cpp

index 702d9d9..2b42fa1 100644 (file)
@@ -1,3 +1,18 @@
+2018-11-14  Christopher Reid  <chris.reid@sony.com>
+
+        [WPE] Remove glib usage in PlatformKeyboardEventWPE.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=191606
+
+        Reviewed by Michael Catanzaro.
+
+        No behavior change.
+
+        Use StringBuilder::append(UChar32) as a generic way to convert a uint32_t code point to WTFString.
+
+        * platform/wpe/PlatformKeyboardEventWPE.cpp:
+        (WebCore::PlatformKeyboardEvent::keyValueForWPEKeyCode):
+        (WebCore::PlatformKeyboardEvent::singleCharacterString):
+
 2018-11-13  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][IFC] Construct dedicated runs when the inline element requires it (part 2)
index e38129d..89b2fcb 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "WindowsKeyboardCodes.h"
 #include <wpe/wpe.h>
-#include <wtf/glib/GUniquePtr.h>
+#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 
@@ -426,12 +426,11 @@ String PlatformKeyboardEvent::keyValueForWPEKeyCode(unsigned keyCode)
         break;
     }
 
-    guint32 unicodeCharacter = wpe_key_code_to_unicode(keyCode);
-    if (unicodeCharacter) {
-        // UTF-8 will use up to 6 bytes.
-        char utf8[7] = { 0 };
-        g_unichar_to_utf8(unicodeCharacter, utf8);
-        return String::fromUTF8(utf8);
+    UChar32 unicodeCharacter = wpe_key_code_to_unicode(keyCode);
+    if (unicodeCharacter && U_IS_UNICODE_CHAR(unicodeCharacter)) {
+        StringBuilder builder;
+        builder.append(unicodeCharacter);
+        return builder.toString();
     }
 
     return "Unidentified"_s;
@@ -1304,11 +1303,12 @@ String PlatformKeyboardEvent::singleCharacterString(unsigned val)
         break;
     }
 
-    gunichar c = wpe_key_code_to_unicode(val);
-    glong length;
-    GUniquePtr<gunichar2> uchar16(g_ucs4_to_utf16(&c, 1, nullptr, &length, nullptr));
-    if (uchar16)
-        return String(reinterpret_cast<UChar*>(uchar16.get()), length);
+    UChar32 unicodeCharacter = wpe_key_code_to_unicode(val);
+    if (unicodeCharacter && U_IS_UNICODE_CHAR(unicodeCharacter)) {
+        StringBuilder builder;
+        builder.append(unicodeCharacter);
+        return builder.toString();
+    }
 
     return { };
 }