Bug 136193 - Random Gamepad cleanup
Summary: Random Gamepad cleanup
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Brady Eidson
URL:
Keywords:
Depends on:
Blocks: 134076
  Show dependency treegraph
 
Reported: 2014-08-22 21:36 PDT by Brady Eidson
Modified: 2022-03-01 02:48 PST (History)
1 user (show)

See Also:


Attachments
Patch v1 (8.85 KB, patch)
2014-08-22 21:38 PDT, Brady Eidson
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brady Eidson 2014-08-22 21:36:40 PDT
Random Gamepad cleanup

Suggested as review feedback in https://bugs.webkit.org/show_bug.cgi?id=134386
Comment 1 Brady Eidson 2014-08-22 21:38:51 PDT
Created attachment 237025 [details]
Patch v1
Comment 2 Sam Weinig 2014-08-23 12:29:06 PDT
Comment on attachment 237025 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=237025&action=review

> Source/WebCore/Modules/gamepad/NavigatorGamepad.cpp:79
> +    if (index >= m_gamepads.size() || !m_gamepads[index])
> +        return adoptRef(*Gamepad::create(platformGamepad).leakRef());

This looks suspect. Why can't you just return what Gamepad::create() returns (you may have to chance Gamepad::create()  to return a PassRef<> I guess)?

> Source/WebCore/page/DOMWindow.h:451
> +#if ENABLE(GAMEPAD)
> +        WeakPtr<DOMWindow> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
> +#endif

While Gamepad may be the only one using this right now, I don't think it makes sense to put this under #if ENABLE(GAMEPAD).
Comment 3 Brady Eidson 2014-08-23 13:37:34 PDT
(In reply to comment #2)
> (From update of attachment 237025 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=237025&action=review
> 
> > Source/WebCore/Modules/gamepad/NavigatorGamepad.cpp:79
> > +    if (index >= m_gamepads.size() || !m_gamepads[index])
> > +        return adoptRef(*Gamepad::create(platformGamepad).leakRef());
> 
> This looks suspect. Why can't you just return what Gamepad::create() returns (you may have to chance Gamepad::create()  to return a PassRef<> I guess)?

Right, and since we have to maintain a sparse Vector of Gamepads and we can't have null Ref<>s in that Vector, I think it makes more sense to keep Gamepad::create() returning PassRefPtr<> and play this trick here.

> 
> > Source/WebCore/page/DOMWindow.h:451
> > +#if ENABLE(GAMEPAD)
> > +        WeakPtr<DOMWindow> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
> > +#endif
> 
> While Gamepad may be the only one using this right now, I don't think it makes sense to put this under #if ENABLE(GAMEPAD).

Sure thing.
Comment 4 Brady Eidson 2014-08-23 13:40:43 PDT
http://trac.webkit.org/changeset/172890