RESOLVED FIXED 58346
Convert media controls hooks to a client interface
https://bugs.webkit.org/show_bug.cgi?id=58346
Summary Convert media controls hooks to a client interface
Dimitri Glazkov (Google)
Reported 2011-04-12 10:31:17 PDT
To facilitate cleaner separation of concerns and allow ports build their own DOM UI (rather than hacking it in using RenderTheme), we should create a MediaControlsClient interface, which is consumed by HTMLMediaElement. The implementors of the interface can then supply their own implementation of media controls.
Attachments
Patch (18.03 KB, patch)
2011-04-15 18:19 PDT, Steve Lacey
no flags
Patch (21.65 KB, patch)
2011-04-15 18:34 PDT, Steve Lacey
no flags
Patch (21.48 KB, patch)
2011-04-15 22:58 PDT, Steve Lacey
no flags
Patch (50.35 KB, patch)
2011-04-18 11:19 PDT, Steve Lacey
no flags
Patch (28.94 KB, patch)
2011-04-18 12:26 PDT, Steve Lacey
no flags
Patch (31.33 KB, patch)
2011-04-18 13:58 PDT, Steve Lacey
no flags
Patch (29.51 KB, patch)
2011-04-18 14:48 PDT, Steve Lacey
no flags
Dimitri Glazkov (Google)
Comment 1 2011-04-12 10:33:26 PDT
The hooks mentioned above are all the methods on MediaControlRootElement that HTMLMediaElement uses to signal a change of the state: void show(); void hide(); void makeOpaque(); void makeTransparent(); void reset(); void playbackProgressed(); void playbackStarted(); void playbackStopped(); void changedMute(); void changedVolume(); void enteredFullscreen(); void exitedFullscreen(); void reportedError(); void changedNetworkState(); void loadedMetadata(); void changedClosedCaptionsVisibility(); void showVolumeSlider(); void updateTimeDisplay();
Steve Lacey
Comment 2 2011-04-13 13:46:39 PDT
Am looking at taking this on. From a quick look, it seems like we could (which is basically reiterating Dimitri's comment): 1) Create a MediaControlsClient interface. 2) Derive MediaControls from that and rename to MediaControlRootElement. 3) Have MediaElement use that. This seems fairly simple and would keep everything working. Ports can then implement their own MediaControlClient instead of MediaControlRootElement as and when they wish. Any gotchas?
Dimitri Glazkov (Google)
Comment 3 2011-04-13 13:49:38 PDT
(In reply to comment #2) > Am looking at taking this on. > > From a quick look, it seems like we could (which is basically reiterating Dimitri's comment): > > 1) Create a MediaControlsClient interface. > 2) Derive MediaControls from that and rename to MediaControlRootElement. > 3) Have MediaElement use that. > > This seems fairly simple and would keep everything working. Ports can then implement their own MediaControlClient instead of MediaControlRootElement as and when they wish. > > Any gotchas? This is a reasonable first step.
Steve Lacey
Comment 4 2011-04-15 18:19:29 PDT
Steve Lacey
Comment 5 2011-04-15 18:34:02 PDT
Steve Lacey
Comment 6 2011-04-15 18:34:44 PDT
First patch was missing project.pbxproj change. Fixed in second patch.
Dimitri Glazkov (Google)
Comment 7 2011-04-15 19:48:29 PDT
Comment on attachment 89900 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=89900&action=review > Source/WebCore/html/shadow/MediaControlClient.h:38 > +class MediaControlClient : public HTMLDivElement { This is interesting. If it's a subclass of an HTMLDivElement, it's probably not a client. I was imagining MediaControlClient to not be a subclass of anything, but maybe that would be too convoluted. I think what you have is fine, but you need to get rid of the Client designation. This is a base class, and the convention in WebKit is to use a Base suffix. So this would be an HTMLMediaControlBase.h
Steve Lacey
Comment 8 2011-04-15 20:49:43 PDT
Thanks for the quick review! That was what I thought too. But the issue became one that ideally: 1) The HTMLMediaElement would maintain a reference to the controls interface on the object. 2) The object is added to the shadow root, which maintains a reference. Who owns what then becomes tricky and you'd end up splitting into various objects and lifetimes become an issue. It became simpler just to think of the interface as a base class. Anyhow - yup! I should have changed the name :-) Will fix on Monday.
Steve Lacey
Comment 9 2011-04-15 22:14:48 PDT
Clarification: MediaControlBase or HTMLMediaControlBase? I expect the former as it's not a core html element.
Steve Lacey
Comment 10 2011-04-15 22:58:08 PDT
Steve Lacey
Comment 11 2011-04-15 22:58:43 PDT
New patch is a pure name change MediaControlClient -> MediaControlBase.
Dimitri Glazkov (Google)
Comment 12 2011-04-16 09:52:59 PDT
Comment on attachment 89917 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=89917&action=review > Source/WebCore/WebCore.xcodeproj/project.pbxproj:22965 > + 1F0D6E0E13590DE700236592 /* MediaControlBase.h in Headers */, The XCode changes look like they haven't been sorted. Can you run sort-XCode-project-files on this? > Source/WebCore/html/shadow/MediaControlBase.h:34 > +#include <HTMLDivElement.h> > +#include <HTMLMediaElement.h> > +#include <HTMLNames.h> "", not <> > Source/WebCore/html/shadow/MediaControlBase.h:38 > +class MediaControlBase : public HTMLDivElement { I am sorry about flip-flopping here, but looking at callsites, it's clear that they are working with an interface, not a base class. So we should call this new thing MediaControls, not MediaControlBase. > Source/WebCore/html/shadow/MediaControlBase.h:42 > + // This function is to be implemented in your platform-specific media port-specific. > Source/WebCore/html/shadow/MediaControlBase.h:73 > + MediaControlBase(HTMLMediaElement* mediaElement) > + : HTMLDivElement(HTMLNames::divTag, mediaElement->document()) { } I know you want to keep this change to only have a header file, but you could save a couple of header includes if you just have a source file with it. > Source/WebCore/html/shadow/MediaControlBase.h:81 > +#endif extra break after first endif would be helpful. > Source/WebCore/html/shadow/MediaControlRootElement.h:28 > +#ifndef MediaControlRootElement_h > +#define MediaControlRootElement_h Ha! Thanks for noticing this one.
Alexis Menard (darktears)
Comment 13 2011-04-18 07:27:43 PDT
Comment on attachment 89917 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=89917&action=review > Source/WebCore/html/HTMLMediaElement.h:338 > + Extra spaces?
Alexis Menard (darktears)
Comment 14 2011-04-18 07:28:27 PDT
Just a stupid question but this is only for the logic part right? The styling will still happen is RenderThemeXYZ ?
Steve Lacey
Comment 15 2011-04-18 11:19:08 PDT
Steve Lacey
Comment 16 2011-04-18 11:22:05 PDT
(In reply to comment #12) > (From update of attachment 89917 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=89917&action=review > > > Source/WebCore/WebCore.xcodeproj/project.pbxproj:22965 > > + 1F0D6E0E13590DE700236592 /* MediaControlBase.h in Headers */, > > The XCode changes look like they haven't been sorted. Can you run sort-XCode-project-files on this? Done. Though this resulted in a lot of changes! Am presuming this hasn't been run for a while and that the script did the right thing... > > > Source/WebCore/html/shadow/MediaControlBase.h:34 > > +#include <HTMLDivElement.h> > > +#include <HTMLMediaElement.h> > > +#include <HTMLNames.h> > > "", not <> Done. > > > Source/WebCore/html/shadow/MediaControlBase.h:38 > > +class MediaControlBase : public HTMLDivElement { > > I am sorry about flip-flopping here, but looking at callsites, it's clear that they are working with an interface, not a base class. So we should call this new thing MediaControls, not MediaControlBase. Done. > > > Source/WebCore/html/shadow/MediaControlBase.h:42 > > + // This function is to be implemented in your platform-specific media > > port-specific. Done. > > > Source/WebCore/html/shadow/MediaControlBase.h:73 > > + MediaControlBase(HTMLMediaElement* mediaElement) > > + : HTMLDivElement(HTMLNames::divTag, mediaElement->document()) { } > > I know you want to keep this change to only have a header file, but you could save a couple of header includes if you just have a source file with it. Done. > > > Source/WebCore/html/shadow/MediaControlBase.h:81 > > +#endif > > extra break after first endif would be helpful. Done. Was just following the style in other includes... > > > Source/WebCore/html/shadow/MediaControlRootElement.h:28 > > +#ifndef MediaControlRootElement_h > > +#define MediaControlRootElement_h > > Ha! Thanks for noticing this one.
Steve Lacey
Comment 17 2011-04-18 11:22:57 PDT
(In reply to comment #13) > (From update of attachment 89917 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=89917&action=review > > > Source/WebCore/html/HTMLMediaElement.h:338 > > + > > Extra spaces? My change removed some spurious spaces due to me adding an new member and then taking it away. Are the spaces needed?
Early Warning System Bot
Comment 18 2011-04-18 11:31:28 PDT
Steve Lacey
Comment 19 2011-04-18 12:26:16 PDT
Steve Lacey
Comment 20 2011-04-18 12:27:54 PDT
(In reply to comment #18) > Attachment 90059 [details] did not build on qt: > Build output: http://queues.webkit.org/results/8457976 Should be fixed in the followup patch. Messed up the pbxproj. Nice catch by the bots...
Early Warning System Bot
Comment 21 2011-04-18 13:02:36 PDT
Steve Lacey
Comment 22 2011-04-18 13:17:05 PDT
(In reply to comment #21) > Attachment 90069 [details] did not build on qt: > Build output: http://queues.webkit.org/results/8473016 Looks like MediaControls.cpp is not being pulled into the qt build. I can't see any missing makefile. Is there another file where this should be listed? A grep over webkit for another doesn't show any missing change. Any clues?
Steve Lacey
Comment 23 2011-04-18 13:58:42 PDT
Steve Lacey
Comment 24 2011-04-18 14:00:13 PDT
(In reply to comment #22) > (In reply to comment #21) > > Attachment 90069 [details] [details] did not build on qt: > > Build output: http://queues.webkit.org/results/8473016 > > > Looks like MediaControls.cpp is not being pulled into the qt build. I can't see any missing makefile. Is there another file where this should be listed? A grep over webkit for another doesn't show any missing change. > > Any clues? Answering my own question: missed WebCore.pro.
Steve Lacey
Comment 25 2011-04-18 14:48:32 PDT
Steve Lacey
Comment 26 2011-04-18 14:49:14 PDT
(In reply to comment #25) > Created an attachment (id=90098) [details] > Patch No change other than a merge with head to try and get the qt bot to apply the patch successfully.
WebKit Commit Bot
Comment 27 2011-04-18 21:26:13 PDT
The commit-queue encountered the following flaky tests while processing attachment 90098 [details]: http/tests/misc/favicon-loads-with-icon-loading-override.html bug 58412 (author: alice.liu@apple.com) http/tests/media/video-load-twice.html bug 51138 (authors: eric.carlson@apple.com and jamesr@chromium.org) The commit-queue is continuing to process your patch.
WebKit Commit Bot
Comment 28 2011-04-18 21:28:51 PDT
Comment on attachment 90098 [details] Patch Clearing flags on attachment: 90098 Committed r84222: <http://trac.webkit.org/changeset/84222>
WebKit Commit Bot
Comment 29 2011-04-18 21:28:58 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.