- Revision
- 209240
- Author
- [email protected]
- Date
- 2016-12-02 09:16:17 -0800 (Fri, 02 Dec 2016)
Log Message
Remove use of WebCore::Dictionary in MediaSession
https://bugs.webkit.org/show_bug.cgi?id=165296
Reviewed by Chris Dumez.
I am not exactly sure of the status of this code. When I enabled it to test my
changes it did not compile until I fixed some things, and it's far out of date
of the latest draft of the Media Session Standard. But despite that I updated it.
* DerivedSources.make: Removed a line that was breaking the build for some
configurations, perhaps only for programmers from Apple, after r209198.
* Modules/mediasession/MediaSession.cpp:
(WebCore::MediaSession::MediaSession): Fixed so it compiles.
(WebCore::MediaSession::setMetadata): Changed argument to use a struct rather
htan a WebCore::Dictionary.
* Modules/mediasession/MediaSession.h: Added a Metadata struct, and used it.
Also fixed the arguments to the constructor.
* Modules/mediasession/MediaSession.idl: Added MediaMetadata and used it instead
of Dictionary.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (209239 => 209240)
--- trunk/Source/WebCore/ChangeLog 2016-12-02 16:44:23 UTC (rev 209239)
+++ trunk/Source/WebCore/ChangeLog 2016-12-02 17:16:17 UTC (rev 209240)
@@ -1,3 +1,26 @@
+2016-12-02 Darin Adler <[email protected]>
+
+ Remove use of WebCore::Dictionary in MediaSession
+ https://bugs.webkit.org/show_bug.cgi?id=165296
+
+ Reviewed by Chris Dumez.
+
+ I am not exactly sure of the status of this code. When I enabled it to test my
+ changes it did not compile until I fixed some things, and it's far out of date
+ of the latest draft of the Media Session Standard. But despite that I updated it.
+
+ * DerivedSources.make: Removed a line that was breaking the build for some
+ configurations, perhaps only for programmers from Apple, after r209198.
+
+ * Modules/mediasession/MediaSession.cpp:
+ (WebCore::MediaSession::MediaSession): Fixed so it compiles.
+ (WebCore::MediaSession::setMetadata): Changed argument to use a struct rather
+ htan a WebCore::Dictionary.
+ * Modules/mediasession/MediaSession.h: Added a Metadata struct, and used it.
+ Also fixed the arguments to the constructor.
+ * Modules/mediasession/MediaSession.idl: Added MediaMetadata and used it instead
+ of Dictionary.
+
2016-12-02 Dave Hyatt <[email protected]>
[CSS Parser] Make sure margin and font set the implicit flag properly
Modified: trunk/Source/WebCore/DerivedSources.make (209239 => 209240)
--- trunk/Source/WebCore/DerivedSources.make 2016-12-02 16:44:23 UTC (rev 209239)
+++ trunk/Source/WebCore/DerivedSources.make 2016-12-02 17:16:17 UTC (rev 209240)
@@ -835,8 +835,6 @@
ADDITIONAL_EVENT_NAMES =
ADDITIONAL_EVENT_TARGET_FACTORY =
--include WebCoreDerivedSourcesAdditions.make
-
JS_BINDING_IDLS += $(ADDITIONAL_BINDING_IDLS)
all : $(ADDITIONAL_BINDING_IDLS:%.idl=JS%.h)
Modified: trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp (209239 => 209240)
--- trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp 2016-12-02 16:44:23 UTC (rev 209239)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp 2016-12-02 17:16:17 UTC (rev 209240)
@@ -30,10 +30,11 @@
#include "Chrome.h"
#include "ChromeClient.h"
-#include "Dictionary.h"
#include "Event.h"
+#include "EventNames.h"
#include "HTMLMediaElement.h"
#include "MediaSessionManager.h"
+#include "Page.h"
namespace WebCore {
@@ -45,7 +46,7 @@
// 3. If media session's current media session type is "content", then create a new media remote controller for media
// session. (Otherwise media session has no media remote controller.)
if (m_kind == Kind::Content)
- m_controls = MediaRemoteControls::create(context, this);
+ m_controls = MediaRemoteControls::create(document, this);
MediaSessionManager::singleton().addMediaSession(*this);
}
@@ -113,33 +114,16 @@
return !m_activeParticipatingElements.isEmpty();
}
-void MediaSession::setMetadata(const Dictionary& metadata)
+void MediaSession::setMetadata(const std::optional<Metadata>& optionalMetadata)
{
- // 5.1.3
- // 1. Let media session be the current media session.
- // 2. Let baseURL be the API base URL specified by the entry settings object.
- // 3. Set media session's title to metadata's title.
- String title;
- metadata.get("title", title);
+ if (!optionalMetadata)
+ m_metadata = { };
+ else {
+ auto& metadata = optionalMetadata.value();
+ m_metadata = { metadata.title, metadata.artist, metadata.album, m_document.completeURL(metadata.artwork) };
+ }
- // 4. Set media session's artist name to metadata's artist.
- String artist;
- metadata.get("artist", artist);
-
- // 5. Set media session's album name to metadata's album.
- String album;
- metadata.get("album", album);
-
- // 6. If metadata's artwork is present, parse it using baseURL, and if that does not return failure, set media
- // session's artwork URL to the return value.
- URL artworkURL;
- String artworkPath;
- if (metadata.get("artwork", artworkPath))
- artworkURL = m_document.completeURL(artworkPath);
-
- m_metadata = MediaSessionMetadata(title, artist, album, artworkURL);
-
- if (Page *page = m_document.page())
+ if (auto* page = m_document.page())
page->chrome().client().mediaSessionMetadataDidChange(m_metadata);
}
Modified: trunk/Source/WebCore/Modules/mediasession/MediaSession.h (209239 => 209240)
--- trunk/Source/WebCore/Modules/mediasession/MediaSession.h 2016-12-02 16:44:23 UTC (rev 209239)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSession.h 2016-12-02 17:16:17 UTC (rev 209240)
@@ -29,10 +29,10 @@
#include "MediaRemoteControls.h"
#include "MediaSessionMetadata.h"
+#include <wtf/HashSet.h>
namespace WebCore {
-class Dictionary;
class Document;
class HTMLMediaElement;
@@ -41,6 +41,13 @@
enum class Kind { Content, Transient, TransientSolo, Ambient };
enum class State { Idle, Active, Interrupted };
+ struct Metadata {
+ String title;
+ String artist;
+ String album;
+ String artwork;
+ };
+
static Ref<MediaSession> create(Document& document, Kind kind)
{
return adoptRef(*new MediaSession(document, kind));
@@ -54,7 +61,7 @@
WEBCORE_EXPORT State currentState() const { return m_currentState; }
bool hasActiveMediaElements() const;
- void setMetadata(const Dictionary&);
+ void setMetadata(const std::optional<Metadata>&);
void deactivate();
@@ -76,7 +83,7 @@
private:
friend class HTMLMediaElement;
- MediaSession(Document&, const String&);
+ MediaSession(Document&, Kind);
void addMediaElement(HTMLMediaElement&);
void removeMediaElement(HTMLMediaElement&);
Modified: trunk/Source/WebCore/Modules/mediasession/MediaSession.idl (209239 => 209240)
--- trunk/Source/WebCore/Modules/mediasession/MediaSession.idl 2016-12-02 16:44:23 UTC (rev 209239)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSession.idl 2016-12-02 17:16:17 UTC (rev 209240)
@@ -25,15 +25,15 @@
[
Conditional=MEDIA_SESSION,
+ ConstructorCallWith=ScriptExecutionContext,
CustomConstructor(optional MediaSessionKind kind = "content"),
- ConstructorCallWith=ScriptExecutionContext,
+ ExportMacro=WEBCORE_EXPORT,
ImplementationLacksVTable,
- ExportMacro=WEBCORE_EXPORT,
] interface MediaSession {
readonly attribute MediaSessionKind kind;
readonly attribute MediaRemoteControls? controls;
- void setMetadata(Dictionary metadata);
+ void setMetadata(MediaMetadata? metadata);
void deactivate();
};
@@ -44,3 +44,10 @@
"transient-solo",
"ambient"
};
+
+dictionary MediaMetadata {
+ DOMString title;
+ DOMString artist;
+ DOMString album;
+ USVString artwork;
+};