Closed Bug 947241 Opened 11 years ago Closed 11 years ago

Make Gamepad use the new attributes with cached sequence return values infrastructure

Categories

(Core :: DOM: Core & HTML, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Details

Attachments

(1 file, 1 obsolete file)

It fits like a glove.
Attachment #8343760 - Flags: review?(ted)
Attachment #8343760 - Flags: review?(peterv)
Comment on attachment 8343760 [details] [diff] [review]
Make Gamepad used cached sequences for its buttons and axes.

Review of attachment 8343760 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/gamepad/Gamepad.cpp
@@ +68,2 @@
>    mAxes[aAxis] = aValue;
> +  if (changed) {

I would do:

if (mAxes[aAxis] != aValue) {
  mAxes[aAxis] = aValue;
  GamepadBinding::ClearCachedAxesValue(this);
}

@@ +72,4 @@
>  }
>  
> +void
> +Gamepad::GetButtons(nsTArray<nsRefPtr<GamepadButton> >& aButtons)

Don't need the extra space anymore
Comment on attachment 8343760 [details] [diff] [review]
Make Gamepad used cached sequences for its buttons and axes.

Review of attachment 8343760 [details] [diff] [review]:
-----------------------------------------------------------------

This is so much nicer, I'm weeping with joy!

::: dom/gamepad/Gamepad.cpp
@@ +68,3 @@
>    mAxes[aAxis] = aValue;
> +  if (changed) {
> +    GamepadBinding::ClearCachedAxesValue(this);

So ClearCachedAxesValue is a bindings-generated method that comes from having [Cached] on the webidl method? Magic!

@@ +82,2 @@
>  {
> +  aAxes = mAxes;

Should we just inline these both in the class declaration? (You removed the previously-inlined overloads of these.)

::: dom/gamepad/Gamepad.h
@@ +89,5 @@
>    nsString mID;
>    uint32_t mIndex;
>  
>    // The mapping in use.
>    GamepadMappingType mMapping;

There's an mButtonsVariant field you can remove:
http://hg.mozilla.org/mozilla-central/annotate/1401e4b394ad/dom/gamepad/Gamepad.h#l116
Attachment #8343760 - Flags: review?(ted) → review+
> I would do:

Yes, done.

> Don't need the extra space anymore

Mmm...ok.  ;)

> So ClearCachedAxesValue is a bindings-generated method 

Yup.  https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bindings#Cached

> Should we just inline these both in the class declaration?

Makes sense, done.  They ended up shorter than I first expected.

> There's an mButtonsVariant field you can remove:

Yup, done.
Also, fixed a problem where we weren't actually CCing mButtons (!).
Attachment #8343760 - Attachment is obsolete: true
Attachment #8343760 - Flags: review?(peterv)
(In reply to Boris Zbarsky [:bz] from comment #4)
> > So ClearCachedAxesValue is a bindings-generated method 
> 
> Yup.  https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bindings#Cached

It would be nicer if that wiki mentioned the generated ClearCached${x}Value method explicitly, but awesome that this is documented!
Hmm.  It's mentioned under [StoreInSlot], but you're right.  I'll make it clearer.
Attachment #8343795 - Flags: review?(peterv) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/29725ca96a8d
Flags: in-testsuite?
Whiteboard: [need review]
Target Milestone: --- → mozilla29
https://hg.mozilla.org/mozilla-central/rev/29725ca96a8d
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: