Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Issue 196503004: Share Gamepad and WebKitGamepad implementation (Closed)

Created:
6 years, 9 months ago by Nils Barth (inactive)
Modified:
6 years, 9 months ago
Reviewers:
eseidel
CC:
blink-reviews, Nils Barth (inactive), kojih, arv+blink, jsbell+bindings_chromium.org, sof, kouhei+bindings_chromium.org, abarth-chromium, marja+watch_chromium.org, adamk+blink_chromium.org, haraken, Nate Chapin, Inactive
Visibility:
Public.

Description

Share Gamepad and WebKitGamepad implementation Decided to just have C++ inheritance: Factor out GamepadCommon base class from Gamepad and WebKitGamepad https://codereview.chromium.org/195993007/ OLD: Variant of: Added non-prefixed navigator.getGamepads() with updated API https://codereview.chromium.org/183313003/ ...which shares the Blink implementation between the two IDL interfaces. Note the use of [ImplementedAs] on both the interfaces (to reuse the Gamepad implementation) and on the |buttons| attribute (to provide a different implementation of this attribute), as that differ between Gamepad and WebKitGamepad. For simplicity, CG-only changes in: Add [DoNotGenerateClassBindings] extended attribute https://codereview.chromium.org/196653003/ BUG=344556

Patch Set 1 #

Patch Set 2 : Tweak #

Patch Set 3 : Compiles and links #

Total comments: 8
Unified diffs Side-by-side diffs Delta from patch set Stats (+273 lines, -63 lines) Patch
M LayoutTests/gamepad/gamepad-api.html View 1 chunk +1 line, -0 lines 0 comments Download
M LayoutTests/gamepad/gamepad-api-expected.txt View 1 chunk +1 line, -0 lines 0 comments Download
M LayoutTests/gamepad/gamepad-polling-access.html View 2 chunks +24 lines, -0 lines 0 comments Download
M LayoutTests/gamepad/gamepad-polling-access-expected.txt View 3 chunks +23 lines, -0 lines 0 comments Download
M Source/bindings/IDLExtendedAttributes.txt View 1 chunk +1 line, -0 lines 0 comments Download
M Source/bindings/scripts/code_generator_v8.py View 1 chunk +3 lines, -0 lines 0 comments Download
M Source/bindings/scripts/v8_callback_interface.py View 1 chunk +1 line, -0 lines 0 comments Download
M Source/bindings/scripts/v8_interface.py View 1 chunk +1 line, -0 lines 0 comments Download
M Source/bindings/templates/interface.h View 1 2 chunks +2 lines, -0 lines 0 comments Download
M Source/bindings/templates/interface.cpp View 1 2 2 chunks +8 lines, -1 line 0 comments Download
M Source/bindings/templates/interface_base.cpp View 1 2 3 chunks +4 lines, -1 line 0 comments Download
M Source/core/frame/UseCounter.h View 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/frame/UseCounter.cpp View 1 chunk +3 lines, -0 lines 0 comments Download
M Source/modules/gamepad/Gamepad.h View 1 2 3 chunks +17 lines, -15 lines 4 comments Download
M Source/modules/gamepad/Gamepad.cpp View 1 2 1 chunk +19 lines, -14 lines 2 comments Download
M Source/modules/gamepad/Gamepad.idl View 2 chunks +2 lines, -3 lines 0 comments Download
A Source/modules/gamepad/GamepadButton.h View 1 chunk +38 lines, -0 lines 0 comments Download
A Source/modules/gamepad/GamepadButton.cpp View 1 chunk +30 lines, -0 lines 0 comments Download
A + Source/modules/gamepad/GamepadButton.idl View 1 chunk +5 lines, -3 lines 0 comments Download
M Source/modules/gamepad/GamepadList.h View 1 chunk +1 line, -1 line 0 comments Download
M Source/modules/gamepad/GamepadList.idl View 1 chunk +1 line, -1 line 0 comments Download
M Source/modules/gamepad/NavigatorGamepad.h View 3 chunks +4 lines, -0 lines 0 comments Download
M Source/modules/gamepad/NavigatorGamepad.cpp View 4 chunks +33 lines, -13 lines 0 comments Download
M Source/modules/gamepad/NavigatorGamepad.idl View 1 chunk +2 lines, -1 line 0 comments Download
A + Source/modules/gamepad/WebKitGamepad.h View 1 chunk +6 lines, -5 lines 2 comments Download
A Source/modules/gamepad/WebKitGamepad.idl View 1 2 1 chunk +17 lines, -0 lines 0 comments Download
A + Source/modules/gamepad/WebKitGamepadList.h View 1 chunk +5 lines, -5 lines 0 comments Download
A Source/modules/gamepad/WebKitGamepadList.idl View 1 chunk +13 lines, -0 lines 0 comments Download
M Source/modules/modules.gypi View 2 chunks +7 lines, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
eseidel
This looks really close. https://codereview.chromium.org/196503004/diff/40001/Source/modules/gamepad/Gamepad.h File Source/modules/gamepad/Gamepad.h (right): https://codereview.chromium.org/196503004/diff/40001/Source/modules/gamepad/Gamepad.h#newcode45 Source/modules/gamepad/Gamepad.h:45: virtual ~Gamepad(); What's virtual? Do ...
6 years, 9 months ago (2014-03-12 20:05:48 UTC) #1
eseidel
https://codereview.chromium.org/196503004/diff/40001/Source/modules/gamepad/Gamepad.cpp File Source/modules/gamepad/Gamepad.cpp (right): https://codereview.chromium.org/196503004/diff/40001/Source/modules/gamepad/Gamepad.cpp#newcode52 Source/modules/gamepad/Gamepad.cpp:52: for (unsigned i = 0; i < count; ++i) ...
6 years, 9 months ago (2014-03-12 20:06:45 UTC) #2
Nils Barth (inactive)
6 years, 9 months ago (2014-03-13 08:55:46 UTC) #3
Thanks for reviews Eric!
Turns out sharing a C++ implementation really doesn't work,
and anyway C++ inheritance in clearer, so closing.

https://codereview.chromium.org/196503004/diff/40001/Source/modules/gamepad/G...
File Source/modules/gamepad/Gamepad.cpp (right):

https://codereview.chromium.org/196503004/diff/40001/Source/modules/gamepad/G...
Source/modules/gamepad/Gamepad.cpp:52: for (unsigned i = 0; i < count; ++i) {
On 2014/03/12 20:06:46, eseidel wrote:
> I'm not sure if it's simpler to do the copying into the old buttons array on
the
> setter or the getter.  One could also use a dirty-bit if we did it on the
> getter.  Just depends on how often set vs. get is called I gues.  I doubt
either
> matters much.

(This is from upstream; as noted, doesn't make much difference;
I'm guessing getter called more than setter, hence that's the simple one.)

https://codereview.chromium.org/196503004/diff/40001/Source/modules/gamepad/G...
File Source/modules/gamepad/Gamepad.h (right):

https://codereview.chromium.org/196503004/diff/40001/Source/modules/gamepad/G...
Source/modules/gamepad/Gamepad.h:45: virtual ~Gamepad();
On 2014/03/12 20:05:49, eseidel wrote:
> What's virtual?  Do we need an OVERRIDE somewhere?

(This was from upstream and is gone now.)

https://codereview.chromium.org/196503004/diff/40001/Source/modules/gamepad/G...
Source/modules/gamepad/Gamepad.h:84: GamepadButtonVector m_buttons;
On 2014/03/12 20:05:49, eseidel wrote:
> Unclear how these should relate.  If you call both webkitGetGamepads and
> getGamepads should the buttons be identical?

This was mess from shoving both into the same class,
and is one reason we should use proper C++ inheritance
(with a separate base class).

https://codereview.chromium.org/196503004/diff/40001/Source/modules/gamepad/W...
File Source/modules/gamepad/WebKitGamepad.h (right):

https://codereview.chromium.org/196503004/diff/40001/Source/modules/gamepad/W...
Source/modules/gamepad/WebKitGamepad.h:8: #include "modules/gamepad/Gamepad.h"
On 2014/03/12 20:05:49, eseidel wrote:
> This is presumably needed to keep the bindings generator happy?  Seems we
should
> add a comment about such?

Yup, this was for CG; agreed a comment would've been in order.
(This was just as "first look", and turned out it was abandoned.)

> Also, I don't think we need the header guards. :)

Probably safe ;)

Powered by Google App Engine
This is Rietveld 408576698