+2011-11-17 Eunmi Lee <eunmi15.lee@samsung.com>
+
+ [EFL] Move keyIdentifierForEvasKeyName() and windowsKeyCodeForEvasKeyName() to the
+ EflKeyboardUtilities.cpp to use in the WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=62451
+
+ Reviewed by Martin Robinson.
+
+ The keyIdentifierForEvasKeyName() and windowsKeyCodeForEvasKeyName() were static functions
+ in the PlatformKeyboardEventEfl.cpp. But they are also needed in the WebKit2 EFL port, so I
+ moved them to the separated file - EflKeyboardUtilities.cpp.
+
+ * PlatformEfl.cmake:
+ * platform/efl/EflKeyboardUtilities.cpp: Copied from Source/WebCore/platform/efl/PlatformKeyboardEventEfl.cpp.
+ (WebCore::createKeyMap):
+ (WebCore::createWindowsKeyMap):
+ (WebCore::keyIdentifierForEvasKeyName):
+ (WebCore::windowsKeyCodeForEvasKeyName):
+ * platform/efl/EflKeyboardUtilities.h: Added.
+ * platform/efl/PlatformKeyboardEventEfl.cpp:
+
2011-11-17 Martin Robinson <mrobinson@igalia.com>
[GTK] The process freezes when you right click on windowless Flash
platform/efl/CursorEfl.cpp
platform/efl/DragDataEfl.cpp
platform/efl/DragImageEfl.cpp
+ platform/efl/EflKeyboardUtilities.cpp
platform/efl/EventLoopEfl.cpp
platform/efl/FileSystemEfl.cpp
platform/efl/KURLEfl.cpp
--- /dev/null
+/*
+ * Copyright (C) 2011 Samsung Electronics
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "EflKeyboardUtilities.h"
+
+#include "WindowsKeyboardCodes.h"
+#include <wtf/HashMap.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+typedef HashMap<String, String> KeyMap;
+typedef HashMap<String, int> WindowsKeyMap;
+
+static KeyMap& keyMap()
+{
+ DEFINE_STATIC_LOCAL(KeyMap, keyMap, ());
+ return keyMap;
+}
+
+static WindowsKeyMap& windowsKeyMap()
+{
+ DEFINE_STATIC_LOCAL(WindowsKeyMap, windowsKeyMap, ());
+ return windowsKeyMap;
+}
+
+static void createKeyMap()
+{
+ for (unsigned int i = 1; i < 25; i++) {
+ String key = "F" + String::number(i);
+ keyMap().set(key, key);
+ }
+ keyMap().set("Alt_L", "Alt");
+ keyMap().set("ISO_Level3_Shift", "Alt");
+ keyMap().set("Menu", "Alt");
+ keyMap().set("Shift_L", "Shift");
+ keyMap().set("Shift_R", "Shift");
+ keyMap().set("Down", "Down");
+ keyMap().set("End", "End");
+ keyMap().set("Return", "Enter");
+ keyMap().set("KP_Enter", "Enter");
+ keyMap().set("Home", "Home");
+ keyMap().set("Insert", "Insert");
+ keyMap().set("Left", "Left");
+ keyMap().set("Down", "Down");
+ keyMap().set("Next", "PageDown");
+ keyMap().set("Prior", "PageUp");
+ keyMap().set("Right", "Right");
+ keyMap().set("Up", "Up");
+ keyMap().set("Delete", "U+007F");
+ keyMap().set("Tab", "U+0009");
+ keyMap().set("ISO_Left_Tab", "U+0009");
+}
+
+static void createWindowsKeyMap()
+{
+ windowsKeyMap().set("Return", VK_RETURN);
+ windowsKeyMap().set("KP_Return", VK_RETURN);
+ windowsKeyMap().set("Alt_L", VK_MENU);
+ windowsKeyMap().set("ISO_Level3_Shift", VK_MENU);
+ windowsKeyMap().set("Menu", VK_MENU);
+ windowsKeyMap().set("Shift_L", VK_SHIFT);
+ windowsKeyMap().set("Shift_R", VK_SHIFT);
+ windowsKeyMap().set("Control_L", VK_CONTROL);
+ windowsKeyMap().set("Control_R", VK_CONTROL);
+ windowsKeyMap().set("Pause", VK_PAUSE);
+ windowsKeyMap().set("Break", VK_PAUSE);
+ windowsKeyMap().set("Caps_Lock", VK_CAPITAL);
+ windowsKeyMap().set("Scroll_Lock", VK_SCROLL);
+ windowsKeyMap().set("Num_Lock", VK_NUMLOCK);
+ windowsKeyMap().set("Escape", VK_ESCAPE);
+ windowsKeyMap().set("Tab", VK_TAB);
+ windowsKeyMap().set("ISO_Left_Tab", VK_TAB);
+ windowsKeyMap().set("BackSpace", VK_BACK);
+ windowsKeyMap().set("Space", VK_SPACE);
+ windowsKeyMap().set("Next", VK_NEXT);
+ windowsKeyMap().set("Prior", VK_PRIOR);
+ windowsKeyMap().set("Home", VK_HOME);
+ windowsKeyMap().set("End", VK_END);
+ windowsKeyMap().set("Right", VK_RIGHT);
+ windowsKeyMap().set("Left", VK_LEFT);
+ windowsKeyMap().set("Up", VK_UP);
+ windowsKeyMap().set("Down", VK_DOWN);
+ windowsKeyMap().set("Print", VK_PRINT);
+ windowsKeyMap().set("Insert", VK_INSERT);
+ windowsKeyMap().set("Delete", VK_DELETE);
+
+ windowsKeyMap().set("comma", VK_OEM_COMMA);
+ windowsKeyMap().set("less", VK_OEM_COMMA);
+ windowsKeyMap().set("period", VK_OEM_PERIOD);
+ windowsKeyMap().set("greater", VK_OEM_PERIOD);
+ windowsKeyMap().set("semicolon", VK_OEM_1);
+ windowsKeyMap().set("colon", VK_OEM_1);
+ windowsKeyMap().set("slash", VK_OEM_2);
+ windowsKeyMap().set("question", VK_OEM_2);
+ windowsKeyMap().set("grave", VK_OEM_3);
+ windowsKeyMap().set("asciitilde", VK_OEM_3);
+ windowsKeyMap().set("bracketleft", VK_OEM_4);
+ windowsKeyMap().set("braceleft", VK_OEM_4);
+ windowsKeyMap().set("backslash", VK_OEM_5);
+ windowsKeyMap().set("bar", VK_OEM_5);
+ windowsKeyMap().set("bracketright", VK_OEM_6);
+ windowsKeyMap().set("braceright", VK_OEM_6);
+ windowsKeyMap().set("apostrophe", VK_OEM_7);
+ windowsKeyMap().set("quotedbl", VK_OEM_7);
+
+ // Set alphabet to the windowsKeyMap.
+ const char* alphabet = "abcdefghijklmnopqrstuvwxyz";
+ for (unsigned int i = 0; i < 26; i++) {
+ String key(alphabet + i, 1);
+ windowsKeyMap().set(key, VK_A + i);
+ }
+
+ // Set digits to the windowsKeyMap.
+ for (unsigned int i = 0; i < 10; i++) {
+ String key = String::number(i);
+ windowsKeyMap().set(key, VK_0 + i);
+ }
+
+ // Set shifted digits to the windowsKeyMap.
+ windowsKeyMap().set("exclam", VK_1);
+ windowsKeyMap().set("at", VK_2);
+ windowsKeyMap().set("numbersign", VK_3);
+ windowsKeyMap().set("dollar", VK_4);
+ windowsKeyMap().set("percent", VK_5);
+ windowsKeyMap().set("asciicircum", VK_6);
+ windowsKeyMap().set("ampersand", VK_7);
+ windowsKeyMap().set("asterisk", VK_8);
+ windowsKeyMap().set("parenleft", VK_9);
+ windowsKeyMap().set("parenright", VK_0);
+ windowsKeyMap().set("minus", VK_OEM_MINUS);
+ windowsKeyMap().set("underscore", VK_OEM_MINUS);
+ windowsKeyMap().set("equal", VK_OEM_PLUS);
+ windowsKeyMap().set("plus", VK_OEM_PLUS);
+
+ // Set F_XX keys to the windowsKeyMap.
+ for (unsigned int i = 1; i < 25; i++) {
+ String key = "F" + String::number(i);
+ windowsKeyMap().set(key, VK_F1 + i);
+ }
+}
+
+String keyIdentifierForEvasKeyName(String& keyName)
+{
+ if (keyMap().isEmpty())
+ createKeyMap();
+
+ if (keyMap().contains(keyName))
+ return keyMap().get(keyName);
+
+ return keyName;
+}
+
+int windowsKeyCodeForEvasKeyName(String& keyName)
+{
+ if (windowsKeyMap().isEmpty())
+ createWindowsKeyMap();
+
+ if (windowsKeyMap().contains(keyName))
+ return windowsKeyMap().get(keyName);
+
+ return 0;
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * Copyright (C) 2011 Samsung Electronics
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EflKeyboardUtilities_h
+#define EflKeyboardUtilities_h
+
+namespace WTF {
+class String;
+}
+
+namespace WebCore {
+
+WTF::String keyIdentifierForEvasKeyName(WTF::String&);
+int windowsKeyCodeForEvasKeyName(WTF::String&);
+
+} // namespace WebCore
+
+#endif // EflKeyboardUtilities_h
*/
#include "config.h"
-
#include "PlatformKeyboardEvent.h"
+#include "EflKeyboardUtilities.h"
#include "NotImplemented.h"
#include "TextEncoding.h"
-#include "WindowsKeyboardCodes.h"
-
#include <Evas.h>
#include <stdio.h>
-#include <wtf/HashMap.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
namespace WebCore {
-typedef HashMap<String, String> KeyMap;
-typedef HashMap<String, int> WindowsKeyMap;
-
-static KeyMap gKeyMap;
-static WindowsKeyMap gWindowsKeyMap;
-
-static void createKeyMap()
-{
- for (unsigned int i = 1; i < 25; i++) {
- String key = "F" + String::number(i);
- gKeyMap.set(key, key);
- }
- gKeyMap.set("Alt_L", "Alt");
- gKeyMap.set("ISO_Level3_Shift", "Alt");
- gKeyMap.set("Menu", "Alt");
- gKeyMap.set("Shift_L", "Shift");
- gKeyMap.set("Shift_R", "Shift");
- gKeyMap.set("Down", "Down");
- gKeyMap.set("End", "End");
- gKeyMap.set("Return", "Enter");
- gKeyMap.set("KP_Enter", "Enter");
- gKeyMap.set("Home", "Home");
- gKeyMap.set("Insert", "Insert");
- gKeyMap.set("Left", "Left");
- gKeyMap.set("Down", "Down");
- gKeyMap.set("Next", "PageDown");
- gKeyMap.set("Prior", "PageUp");
- gKeyMap.set("Right", "Right");
- gKeyMap.set("Up", "Up");
- gKeyMap.set("Delete", "U+007F");
- gKeyMap.set("Tab", "U+0009");
- gKeyMap.set("ISO_Left_Tab", "U+0009");
-}
-
-static void createWindowsKeyMap()
-{
- gWindowsKeyMap.set("Return", VK_RETURN);
- gWindowsKeyMap.set("KP_Return", VK_RETURN);
- gWindowsKeyMap.set("Alt_L", VK_MENU);
- gWindowsKeyMap.set("ISO_Level3_Shift", VK_MENU);
- gWindowsKeyMap.set("Menu", VK_MENU);
- gWindowsKeyMap.set("Shift_L", VK_SHIFT);
- gWindowsKeyMap.set("Shift_R", VK_SHIFT);
- gWindowsKeyMap.set("Control_L", VK_CONTROL);
- gWindowsKeyMap.set("Control_R", VK_CONTROL);
- gWindowsKeyMap.set("Pause", VK_PAUSE);
- gWindowsKeyMap.set("Break", VK_PAUSE);
- gWindowsKeyMap.set("Caps_Lock", VK_CAPITAL);
- gWindowsKeyMap.set("Scroll_Lock", VK_SCROLL);
- gWindowsKeyMap.set("Num_Lock", VK_NUMLOCK);
- gWindowsKeyMap.set("Escape", VK_ESCAPE);
- gWindowsKeyMap.set("Tab", VK_TAB);
- gWindowsKeyMap.set("ISO_Left_Tab", VK_TAB);
- gWindowsKeyMap.set("BackSpace", VK_BACK);
- gWindowsKeyMap.set("Space", VK_SPACE);
- gWindowsKeyMap.set("Next", VK_NEXT);
- gWindowsKeyMap.set("Prior", VK_PRIOR);
- gWindowsKeyMap.set("Home", VK_HOME);
- gWindowsKeyMap.set("End", VK_END);
- gWindowsKeyMap.set("Right", VK_RIGHT);
- gWindowsKeyMap.set("Left", VK_LEFT);
- gWindowsKeyMap.set("Up", VK_UP);
- gWindowsKeyMap.set("Down", VK_DOWN);
- gWindowsKeyMap.set("Print", VK_PRINT);
- gWindowsKeyMap.set("Insert", VK_INSERT);
- gWindowsKeyMap.set("Delete", VK_DELETE);
-
- gWindowsKeyMap.set("comma", VK_OEM_COMMA);
- gWindowsKeyMap.set("less", VK_OEM_COMMA);
- gWindowsKeyMap.set("period", VK_OEM_PERIOD);
- gWindowsKeyMap.set("greater", VK_OEM_PERIOD);
- gWindowsKeyMap.set("semicolon", VK_OEM_1);
- gWindowsKeyMap.set("colon", VK_OEM_1);
- gWindowsKeyMap.set("slash", VK_OEM_2);
- gWindowsKeyMap.set("question", VK_OEM_2);
- gWindowsKeyMap.set("grave", VK_OEM_3);
- gWindowsKeyMap.set("asciitilde", VK_OEM_3);
- gWindowsKeyMap.set("bracketleft", VK_OEM_4);
- gWindowsKeyMap.set("braceleft", VK_OEM_4);
- gWindowsKeyMap.set("backslash", VK_OEM_5);
- gWindowsKeyMap.set("bar", VK_OEM_5);
- gWindowsKeyMap.set("bracketright", VK_OEM_6);
- gWindowsKeyMap.set("braceright", VK_OEM_6);
- gWindowsKeyMap.set("apostrophe", VK_OEM_7);
- gWindowsKeyMap.set("quotedbl", VK_OEM_7);
-
- // Alphabet
- const char* alphabet = "abcdefghijklmnopqrstuvwxyz";
- for (unsigned int i = 0; i < 26; i++) {
- String key(alphabet + i, 1);
- gWindowsKeyMap.set(key, VK_A + i);
- }
-
- // Digits
- for (unsigned int i = 0; i < 10; i++) {
- String key = String::number(i);
- gWindowsKeyMap.set(key, VK_0 + i);
- }
-
- // Shifted digits
- gWindowsKeyMap.set("exclam", VK_1);
- gWindowsKeyMap.set("at", VK_2);
- gWindowsKeyMap.set("numbersign", VK_3);
- gWindowsKeyMap.set("dollar", VK_4);
- gWindowsKeyMap.set("percent", VK_5);
- gWindowsKeyMap.set("asciicircum", VK_6);
- gWindowsKeyMap.set("ampersand", VK_7);
- gWindowsKeyMap.set("asterisk", VK_8);
- gWindowsKeyMap.set("parenleft", VK_9);
- gWindowsKeyMap.set("parenright", VK_0);
- gWindowsKeyMap.set("minus", VK_OEM_MINUS);
- gWindowsKeyMap.set("underscore", VK_OEM_MINUS);
- gWindowsKeyMap.set("equal", VK_OEM_PLUS);
- gWindowsKeyMap.set("plus", VK_OEM_PLUS);
-
- // F_XX
- for (unsigned int i = 1; i < 25; i++) {
- String key = "F" + String::number(i);
- gWindowsKeyMap.set(key, VK_F1 + i);
- }
-}
-
-static String keyIdentifierForEvasKeyName(String& keyName)
-{
- if (gKeyMap.isEmpty())
- createKeyMap();
-
- if (gKeyMap.contains(keyName))
- return gKeyMap.get(keyName);
-
- return keyName;
-}
-
-static int windowsKeyCodeForEvasKeyName(String& keyName)
-{
- if (gWindowsKeyMap.isEmpty())
- createWindowsKeyMap();
-
- if (gWindowsKeyMap.contains(keyName))
- return gWindowsKeyMap.get(keyName);
-
- return 0;
-}
-
PlatformKeyboardEvent::PlatformKeyboardEvent(const Evas_Event_Key_Down* event)
: m_type(KeyDown)
, m_text(String::fromUTF8(event->string))