Diff
Modified: trunk/LayoutTests/ChangeLog (101064 => 101065)
--- trunk/LayoutTests/ChangeLog 2011-11-23 12:06:49 UTC (rev 101064)
+++ trunk/LayoutTests/ChangeLog 2011-11-23 12:16:13 UTC (rev 101065)
@@ -1,3 +1,15 @@
+2011-11-23 Scott Graham <[email protected]>
+
+ Adding gamepad support
+ https://bugs.webkit.org/show_bug.cgi?id=69451
+
+ Reviewed by Darin Fisher.
+
+ * fast/dom/script-tests/prototype-inheritance.js: Exclude
+ gamepadController from enumeration.
+ * gamepad/gamepad-polling-access-expected.txt: Added.
+ * gamepad/gamepad-polling-access.html: Added.
+
2011-11-23 Nikolas Zimmermann <[email protected]>
Not reviewed. Rebaseline win results after r101052.
Modified: trunk/LayoutTests/fast/dom/script-tests/prototype-inheritance.js (101064 => 101065)
--- trunk/LayoutTests/fast/dom/script-tests/prototype-inheritance.js 2011-11-23 12:06:49 UTC (rev 101064)
+++ trunk/LayoutTests/fast/dom/script-tests/prototype-inheritance.js 2011-11-23 12:16:13 UTC (rev 101065)
@@ -12,6 +12,7 @@
"objCController", "textInputController", "navigationController",
"eventSender", "objCPlugin", "objCPluginFunction",
"appleScriptController", "plainText", "accessibilityController",
+ "gamepadController",
"internals",
// Ignore these properties because they do not exist in all implementations. They will be tested separately
"webkitNotifications",
Added: trunk/LayoutTests/gamepad/gamepad-polling-access-expected.txt (0 => 101065)
--- trunk/LayoutTests/gamepad/gamepad-polling-access-expected.txt (rev 0)
+++ trunk/LayoutTests/gamepad/gamepad-polling-access-expected.txt 2011-11-23 12:16:13 UTC (rev 101065)
@@ -0,0 +1,19 @@
+PASS navigator.webkitGamepads.length is 4
+PASS navigator.webkitGamepads[0] is undefined.
+PASS navigator.webkitGamepads[1] is undefined.
+PASS navigator.webkitGamepads[2] is undefined.
+PASS navigator.webkitGamepads[3] is undefined.
+PASS navigator.webkitGamepads[0] is non-null.
+PASS navigator.webkitGamepads[0] is undefined.
+PASS navigator.webkitGamepads[0].id is 'MockStick 3000'
+PASS navigator.webkitGamepads[0].buttons.length is 2
+PASS navigator.webkitGamepads[0].axes.length is 2
+PASS navigator.webkitGamepads[0].buttons[0] is 1.0
+PASS navigator.webkitGamepads[0].buttons[1] is 0.0
+PASS navigator.webkitGamepads[0].axes.length is 2
+PASS navigator.webkitGamepads[0].axes[0] is 0.5
+PASS navigator.webkitGamepads[0].axes[1] is -1.0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Typical polling access to gamepads contents.
Added: trunk/LayoutTests/gamepad/gamepad-polling-access.html (0 => 101065)
--- trunk/LayoutTests/gamepad/gamepad-polling-access.html (rev 0)
+++ trunk/LayoutTests/gamepad/gamepad-polling-access.html 2011-11-23 12:16:13 UTC (rev 101065)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<body>
+<script src=""
+<script>
+ if (window.gamepadController)
+ {
+ // start all disconnected
+ gamepadController.disconnect(0);
+ gamepadController.disconnect(1);
+ gamepadController.disconnect(2);
+ gamepadController.disconnect(3);
+ shouldBe("navigator.webkitGamepads.length", "4");
+ shouldBeUndefined("navigator.webkitGamepads[0]");
+ shouldBeUndefined("navigator.webkitGamepads[1]");
+ shouldBeUndefined("navigator.webkitGamepads[2]");
+ shouldBeUndefined("navigator.webkitGamepads[3]");
+
+ // connect and disconnect
+ gamepadController.connect(0);
+ shouldBeNonNull("navigator.webkitGamepads[0]");
+ gamepadController.disconnect(0);
+ shouldBeUndefined("navigator.webkitGamepads[0]");
+
+ // connect again, and check standard access
+ gamepadController.connect(0);
+ gamepadController.setId(0, "MockStick 3000");
+ gamepadController.setButtonCount(0, 2);
+ gamepadController.setAxisCount(0, 2);
+ gamepadController.setButtonData(0, 0, 1);
+ gamepadController.setButtonData(0, 1, 0);
+ gamepadController.setAxisData(0, 0, .5);
+ gamepadController.setAxisData(0, 1, -1.0);
+ shouldBe("navigator.webkitGamepads[0].id", "'MockStick 3000'");
+ shouldBe("navigator.webkitGamepads[0].buttons.length", "2");
+ shouldBe("navigator.webkitGamepads[0].axes.length", "2");
+ shouldBe("navigator.webkitGamepads[0].buttons[0]", "1.0");
+ shouldBe("navigator.webkitGamepads[0].buttons[1]", "0.0");
+ shouldBe("navigator.webkitGamepads[0].axes.length", "2");
+ shouldBe("navigator.webkitGamepads[0].axes[0]", "0.5");
+ shouldBe("navigator.webkitGamepads[0].axes[1]", "-1.0");
+ }
+ else
+ {
+ console.log("FAIL: no gamepadController available.")
+ }
+</script>
+<script src=""
+<p>Typical polling access to gamepads contents.</p>
+</body>
Modified: trunk/Source/WebCore/ChangeLog (101064 => 101065)
--- trunk/Source/WebCore/ChangeLog 2011-11-23 12:06:49 UTC (rev 101064)
+++ trunk/Source/WebCore/ChangeLog 2011-11-23 12:16:13 UTC (rev 101065)
@@ -1,3 +1,23 @@
+2011-11-23 Scott Graham <[email protected]>
+
+ Adding gamepad support
+ https://bugs.webkit.org/show_bug.cgi?id=69451
+
+ Reviewed by Darin Fisher.
+
+ Plumb gamepad data access through platform.
+
+ Test: gamepad/gamepad-polling-access.html
+
+ * WebCore.gypi:
+ * page/Navigator.cpp:
+ (WebCore::Navigator::webkitGamepads):
+ * page/Navigator.h:
+ * platform/Gamepads.h: Added.
+ * platform/chromium/GamepadsChromium.cpp: Added.
+ (WebCore::sampleGamepads):
+ * platform/chromium/PlatformSupport.h:
+
2011-11-23 Dmitry Lomov <[email protected]>
Get rid of WebCore dependencies from TypedArray implementation types
Modified: trunk/Source/WebCore/WebCore.gypi (101064 => 101065)
--- trunk/Source/WebCore/WebCore.gypi 2011-11-23 12:06:49 UTC (rev 101064)
+++ trunk/Source/WebCore/WebCore.gypi 2011-11-23 12:16:13 UTC (rev 101065)
@@ -3240,6 +3240,7 @@
'platform/chromium/FramelessScrollView.cpp',
'platform/chromium/FramelessScrollView.h',
'platform/chromium/FramelessScrollViewClient.h',
+ 'platform/chromium/GamepadsChromium.cpp',
'platform/chromium/GestureRecognizerChromium.cpp',
'platform/chromium/GestureRecognizerChromium.h',
'platform/chromium/KeyCodeConversion.h',
Modified: trunk/Source/WebCore/page/Navigator.cpp (101064 => 101065)
--- trunk/Source/WebCore/page/Navigator.cpp 2011-11-23 12:06:49 UTC (rev 101064)
+++ trunk/Source/WebCore/page/Navigator.cpp 2011-11-23 12:16:13 UTC (rev 101065)
@@ -47,6 +47,7 @@
#if ENABLE(GAMEPAD)
#include "GamepadList.h"
+#include "Gamepads.h"
#endif
#if ENABLE(MEDIA_STREAM)
@@ -311,8 +312,10 @@
#if ENABLE(GAMEPAD)
GamepadList* Navigator::webkitGamepads()
{
- // Stubbed until platform/ changes landed.
- return 0;
+ if (!m_gamepads)
+ m_gamepads = GamepadList::create();
+ sampleGamepads(m_gamepads.get());
+ return m_gamepads.get();
}
#endif
Modified: trunk/Source/WebCore/page/Navigator.h (101064 => 101065)
--- trunk/Source/WebCore/page/Navigator.h 2011-11-23 12:06:49 UTC (rev 101064)
+++ trunk/Source/WebCore/page/Navigator.h 2011-11-23 12:16:13 UTC (rev 101065)
@@ -85,6 +85,9 @@
mutable RefPtr<DOMPluginArray> m_plugins;
mutable RefPtr<DOMMimeTypeArray> m_mimeTypes;
mutable RefPtr<Geolocation> m_geolocation;
+#if ENABLE(GAMEPAD)
+ mutable RefPtr<GamepadList> m_gamepads;
+#endif
#if ENABLE(POINTER_LOCK)
mutable RefPtr<PointerLock> m_pointer;
#endif
Added: trunk/Source/WebCore/platform/Gamepads.h (0 => 101065)
--- trunk/Source/WebCore/platform/Gamepads.h (rev 0)
+++ trunk/Source/WebCore/platform/Gamepads.h 2011-11-23 12:16:13 UTC (rev 101065)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2011, Google Inc. 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 Gamepads_h
+#define Gamepads_h
+
+#if ENABLE(GAMEPAD)
+
+namespace WebCore {
+
+class GamepadList;
+
+void sampleGamepads(GamepadList* into);
+
+}
+
+#endif // ENABLE(GAMEPAD)
+
+#endif // Gamepads_h
Added: trunk/Source/WebCore/platform/chromium/GamepadsChromium.cpp (0 => 101065)
--- trunk/Source/WebCore/platform/chromium/GamepadsChromium.cpp (rev 0)
+++ trunk/Source/WebCore/platform/chromium/GamepadsChromium.cpp 2011-11-23 12:16:13 UTC (rev 101065)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2011, Google Inc. 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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 "Gamepads.h"
+
+#if ENABLE(GAMEPAD)
+
+#include "GamepadList.h"
+#include "PlatformSupport.h"
+
+namespace WebCore {
+
+class GamepadList;
+
+void sampleGamepads(GamepadList* into)
+{
+ PlatformSupport::sampleGamepads(into);
+}
+
+}
+
+#endif
Modified: trunk/Source/WebCore/platform/chromium/PlatformSupport.h (101064 => 101065)
--- trunk/Source/WebCore/platform/chromium/PlatformSupport.h 2011-11-23 12:06:49 UTC (rev 101064)
+++ trunk/Source/WebCore/platform/chromium/PlatformSupport.h 2011-11-23 12:16:13 UTC (rev 101065)
@@ -71,6 +71,7 @@
class Cursor;
class Document;
class Frame;
+class GamepadList;
class GeolocationServiceBridge;
class GeolocationServiceChromium;
class GraphicsContext;
@@ -182,6 +183,9 @@
// Injects key via keyPath into value. Returns true on success.
static PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const String& keyPath);
+ // Gamepad -----------------------------------------------------------
+ static void sampleGamepads(GamepadList* into);
+
// _javascript_ ---------------------------------------------------------
static void notifyJSOutOfMemory(Frame*);
static bool allowScriptDespiteSettings(const KURL& documentURL);
Modified: trunk/Source/WebKit/chromium/ChangeLog (101064 => 101065)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-11-23 12:06:49 UTC (rev 101064)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-11-23 12:16:13 UTC (rev 101065)
@@ -1,3 +1,17 @@
+2011-11-23 Scott Graham <[email protected]>
+
+ Adding gamepad support
+ https://bugs.webkit.org/show_bug.cgi?id=69451
+
+ Add implementation of sampleGamepads in Chromium platform. Retrieves
+ gamepad data from Chromium port and converts to DOM format, i.e.
+ GamepadList.
+
+ Reviewed by Darin Fisher.
+
+ * src/PlatformSupport.cpp:
+ (WebCore::PlatformSupport::sampleGamepads):
+
2011-11-23 Dmitry Lomov <[email protected]>
Get rid of WebCore dependencies from TypedArray implementation types
Modified: trunk/Source/WebKit/chromium/src/PlatformSupport.cpp (101064 => 101065)
--- trunk/Source/WebKit/chromium/src/PlatformSupport.cpp 2011-11-23 12:06:49 UTC (rev 101064)
+++ trunk/Source/WebKit/chromium/src/PlatformSupport.cpp 2011-11-23 12:16:13 UTC (rev 101065)
@@ -90,6 +90,7 @@
#include "Cookie.h"
#include "Document.h"
#include "FrameView.h"
+#include "GamepadList.h"
#include "GraphicsContext.h"
#include "IDBFactoryBackendProxy.h"
#include "KURL.h"
@@ -526,6 +527,31 @@
return webKitPlatformSupport()->injectIDBKeyIntoSerializedValue(key, value, keyPath);
}
+// Gamepad --------------------------------------------------------------------
+
+void PlatformSupport::sampleGamepads(GamepadList* into)
+{
+ WebGamepads gamepads;
+
+ webKitPlatformSupport()->sampleGamepads(gamepads);
+
+ for (unsigned i = 0; i < WebKit::WebGamepads::itemsLengthCap; ++i) {
+ WebGamepad& webGamepad = gamepads.items[i];
+ if (i < gamepads.length && webGamepad.connected) {
+ RefPtr<Gamepad> gamepad = into->item(i);
+ if (!gamepad)
+ gamepad = Gamepad::create();
+ gamepad->id(webGamepad.id);
+ gamepad->index(i);
+ gamepad->timestamp(webGamepad.timestamp);
+ gamepad->axes(webGamepad.axesLength, webGamepad.axes);
+ gamepad->buttons(webGamepad.buttonsLength, webGamepad.buttons);
+ into->set(i, gamepad);
+ } else
+ into->set(i, 0);
+ }
+}
+
// Keygen ---------------------------------------------------------------------
String PlatformSupport::signedPublicKeyAndChallengeString(
Modified: trunk/Tools/ChangeLog (101064 => 101065)
--- trunk/Tools/ChangeLog 2011-11-23 12:06:49 UTC (rev 101064)
+++ trunk/Tools/ChangeLog 2011-11-23 12:16:13 UTC (rev 101065)
@@ -1,3 +1,34 @@
+2011-11-23 Scott Graham <[email protected]>
+
+ Adding gamepad support
+ https://bugs.webkit.org/show_bug.cgi?id=69451
+
+ Reviewed by Darin Fisher.
+
+ Add a 'gamepadController' to Chromium DRT. Allows for setting of mock
+ gamepad data that will be retrieved when JS code pulls via API access.
+
+ * DumpRenderTree/DumpRenderTree.gypi:
+ * DumpRenderTree/chromium/GamepadController.cpp: Added.
+ (GamepadController::GamepadController):
+ (GamepadController::bindToJavascript):
+ (GamepadController::reset):
+ (GamepadController::connect):
+ (GamepadController::disconnect):
+ (GamepadController::setId):
+ (GamepadController::setButtonCount):
+ (GamepadController::setButtonData):
+ (GamepadController::setAxisCount):
+ (GamepadController::setAxisData):
+ (GamepadController::fallbackCallback):
+ * DumpRenderTree/chromium/GamepadController.h: Added.
+ * DumpRenderTree/chromium/TestShell.cpp:
+ (TestShell::TestShell):
+ (TestShell::resetTestController):
+ (TestShell::bindJSObjectsToWindow):
+ * DumpRenderTree/chromium/TestShell.h:
+ (TestShell::gamepadController):
+
2011-11-23 Raphael Kubo da Costa <[email protected]>
[CMake] Move the top-level logic to the top-level directory.
Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.gypi (101064 => 101065)
--- trunk/Tools/DumpRenderTree/DumpRenderTree.gypi 2011-11-23 12:06:49 UTC (rev 101064)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.gypi 2011-11-23 12:16:13 UTC (rev 101065)
@@ -16,6 +16,8 @@
'chromium/DumpRenderTree.cpp',
'chromium/EventSender.cpp',
'chromium/EventSender.h',
+ 'chromium/GamepadController.cpp',
+ 'chromium/GamepadController.h',
'chromium/LayoutTestController.cpp',
'chromium/LayoutTestController.h',
'chromium/MockSpellCheck.cpp',
Added: trunk/Tools/DumpRenderTree/chromium/GamepadController.cpp (0 => 101065)
--- trunk/Tools/DumpRenderTree/chromium/GamepadController.cpp (rev 0)
+++ trunk/Tools/DumpRenderTree/chromium/GamepadController.cpp 2011-11-23 12:16:13 UTC (rev 101065)
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 "GamepadController.h"
+
+#include "TestShell.h"
+
+using namespace WebKit;
+
+GamepadController::GamepadController(TestShell* shell)
+ : m_shell(shell)
+{
+ bindMethod("connect", &GamepadController::connect);
+ bindMethod("disconnect", &GamepadController::disconnect);
+ bindMethod("setId", &GamepadController::setId);
+ bindMethod("setButtonCount", &GamepadController::setButtonCount);
+ bindMethod("setButtonData", &GamepadController::setButtonData);
+ bindMethod("setAxisCount", &GamepadController::setAxisCount);
+ bindMethod("setAxisData", &GamepadController::setAxisData);
+
+ bindFallbackMethod(&GamepadController::fallbackCallback);
+
+ reset();
+}
+
+void GamepadController::bindToJavascript(WebFrame* frame, const WebString& classname)
+{
+ CppBoundClass::bindToJavascript(frame, classname);
+}
+
+void GamepadController::reset()
+{
+ memset(&internalData, 0, sizeof(internalData));
+}
+
+void GamepadController::connect(const CppArgumentList& args, CppVariant* result)
+{
+ if (args.size() < 1) {
+ printf("Invalid args");
+ return;
+ }
+ int index = args[0].toInt32();
+ internalData.items[index].connected = true;
+ internalData.length = 0;
+ for (unsigned i = 0; i < WebKit::WebGamepads::itemsLengthCap; ++i)
+ if (internalData.items[i].connected)
+ internalData.length = i + 1;
+ webkit_support::SetGamepadData(internalData);
+ result->setNull();
+}
+
+void GamepadController::disconnect(const CppArgumentList& args, CppVariant* result)
+{
+ if (args.size() < 1) {
+ printf("Invalid args");
+ return;
+ }
+ int index = args[0].toInt32();
+ internalData.items[index].connected = false;
+ internalData.length = 0;
+ for (unsigned i = 0; i < WebKit::WebGamepads::itemsLengthCap; ++i)
+ if (internalData.items[i].connected)
+ internalData.length = i + 1;
+ webkit_support::SetGamepadData(internalData);
+ result->setNull();
+}
+
+void GamepadController::setId(const CppArgumentList& args, CppVariant* result)
+{
+ if (args.size() < 2) {
+ printf("Invalid args");
+ return;
+ }
+ int index = args[0].toInt32();
+ std::string src = ""
+ const char* p = src.c_str();
+ memset(internalData.items[index].id, 0, sizeof(internalData.items[index].id));
+ for (unsigned i = 0; *p && i < WebKit::WebGamepad::idLengthCap - 1; ++i)
+ internalData.items[index].id[i] = *p++;
+ webkit_support::SetGamepadData(internalData);
+ result->setNull();
+}
+
+void GamepadController::setButtonCount(const CppArgumentList& args, CppVariant* result)
+{
+ if (args.size() < 2) {
+ printf("Invalid args");
+ return;
+ }
+ int index = args[0].toInt32();
+ int buttons = args[1].toInt32();
+ internalData.items[index].buttonsLength = buttons;
+ webkit_support::SetGamepadData(internalData);
+ result->setNull();
+}
+
+void GamepadController::setButtonData(const CppArgumentList& args, CppVariant* result)
+{
+ if (args.size() < 3) {
+ printf("Invalid args");
+ return;
+ }
+ int index = args[0].toInt32();
+ int button = args[1].toInt32();
+ double data = ""
+ internalData.items[index].buttons[button] = data;
+ webkit_support::SetGamepadData(internalData);
+ result->setNull();
+}
+
+void GamepadController::setAxisCount(const CppArgumentList& args, CppVariant* result)
+{
+ if (args.size() < 2) {
+ printf("Invalid args");
+ return;
+ }
+ int index = args[0].toInt32();
+ int axes = args[1].toInt32();
+ internalData.items[index].axesLength = axes;
+ webkit_support::SetGamepadData(internalData);
+ result->setNull();
+}
+
+void GamepadController::setAxisData(const CppArgumentList& args, CppVariant* result)
+{
+ if (args.size() < 3) {
+ printf("Invalid args");
+ return;
+ }
+ int index = args[0].toInt32();
+ int axis = args[1].toInt32();
+ double data = ""
+ internalData.items[index].axes[axis] = data;
+ webkit_support::SetGamepadData(internalData);
+ result->setNull();
+}
+
+void GamepadController::fallbackCallback(const CppArgumentList&, CppVariant* result)
+{
+ printf("CONSOLE MESSAGE: _javascript_ ERROR: unknown method called on "
+ "GamepadController\n");
+ result->setNull();
+}
Added: trunk/Tools/DumpRenderTree/chromium/GamepadController.h (0 => 101065)
--- trunk/Tools/DumpRenderTree/chromium/GamepadController.h (rev 0)
+++ trunk/Tools/DumpRenderTree/chromium/GamepadController.h 2011-11-23 12:16:13 UTC (rev 101065)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 GamepadController_h
+#define GamepadController_h
+
+#include "CppBoundClass.h"
+#include "WebGamepads.h"
+
+namespace WebKit {
+class WebGamepads;
+class WebFrame;
+}
+
+class TestShell;
+
+class GamepadController : public CppBoundClass {
+public:
+ explicit GamepadController(TestShell*);
+
+ void bindToJavascript(WebKit::WebFrame*, const WebKit::WebString& classname);
+ void reset();
+
+private:
+ // Bound methods and properties
+ void connect(const CppArgumentList&, CppVariant*);
+ void disconnect(const CppArgumentList&, CppVariant*);
+ void setId(const CppArgumentList&, CppVariant*);
+ void setButtonCount(const CppArgumentList&, CppVariant*);
+ void setButtonData(const CppArgumentList&, CppVariant*);
+ void setAxisCount(const CppArgumentList&, CppVariant*);
+ void setAxisData(const CppArgumentList&, CppVariant*);
+ void fallbackCallback(const CppArgumentList&, CppVariant*);
+
+ TestShell* m_shell;
+
+ WebKit::WebGamepads internalData;
+};
+
+#endif // GamepadController_h
Modified: trunk/Tools/DumpRenderTree/chromium/TestShell.cpp (101064 => 101065)
--- trunk/Tools/DumpRenderTree/chromium/TestShell.cpp 2011-11-23 12:06:49 UTC (rev 101064)
+++ trunk/Tools/DumpRenderTree/chromium/TestShell.cpp 2011-11-23 12:16:13 UTC (rev 101065)
@@ -127,6 +127,7 @@
m_webPermissions = adoptPtr(new WebPermissions(this));
m_accessibilityController = adoptPtr(new AccessibilityController(this));
+ m_gamepadController = adoptPtr(new GamepadController(this));
m_layoutTestController = adoptPtr(new LayoutTestController(this));
m_eventSender = adoptPtr(new EventSender(this));
m_plainTextController = adoptPtr(new PlainTextController());
@@ -270,6 +271,7 @@
resetWebSettings(*webView());
m_webPermissions->reset();
m_accessibilityController->reset();
+ m_gamepadController->reset();
m_layoutTestController->reset();
m_eventSender->reset();
m_webViewHost->reset();
@@ -673,6 +675,7 @@
{
WebTestingSupport::injectInternalsObject(frame);
m_accessibilityController->bindToJavascript(frame, WebString::fromUTF8("accessibilityController"));
+ m_gamepadController->bindToJavascript(frame, WebString::fromUTF8("gamepadController"));
m_layoutTestController->bindToJavascript(frame, WebString::fromUTF8("layoutTestController"));
m_eventSender->bindToJavascript(frame, WebString::fromUTF8("eventSender"));
m_plainTextController->bindToJavascript(frame, WebString::fromUTF8("plainText"));
Modified: trunk/Tools/DumpRenderTree/chromium/TestShell.h (101064 => 101065)
--- trunk/Tools/DumpRenderTree/chromium/TestShell.h 2011-11-23 12:06:49 UTC (rev 101064)
+++ trunk/Tools/DumpRenderTree/chromium/TestShell.h 2011-11-23 12:16:13 UTC (rev 101065)
@@ -33,6 +33,7 @@
#include "AccessibilityController.h"
#include "EventSender.h"
+#include "GamepadController.h"
#include "LayoutTestController.h"
#include "NotificationPresenter.h"
#include "PlainTextController.h"
@@ -91,6 +92,7 @@
LayoutTestController* layoutTestController() const { return m_layoutTestController.get(); }
EventSender* eventSender() const { return m_eventSender.get(); }
AccessibilityController* accessibilityController() const { return m_accessibilityController.get(); }
+ GamepadController* gamepadController() const { return m_gamepadController.get(); }
NotificationPresenter* notificationPresenter() const { return m_notificationPresenter.get(); }
TestEventPrinter* printer() const { return m_printer.get(); }
@@ -205,6 +207,7 @@
OwnPtr<DRTDevToolsAgent> m_drtDevToolsAgent;
OwnPtr<DRTDevToolsClient> m_drtDevToolsClient;
OwnPtr<AccessibilityController> m_accessibilityController;
+ OwnPtr<GamepadController> m_gamepadController;
OwnPtr<EventSender> m_eventSender;
OwnPtr<LayoutTestController> m_layoutTestController;
OwnPtr<PlainTextController> m_plainTextController;