Title: [145322] trunk/Source/WebCore
Revision
145322
Author
eric.carl...@apple.com
Date
2013-03-09 13:29:13 -0800 (Sat, 09 Mar 2013)

Log Message

Enable platform code to implement text track menu
https://bugs.webkit.org/show_bug.cgi?id=111924

Reviewed by Dean Jackson.

No new tests, the new code isn't enabled in any ports yet.

* WebCore.xcodeproj/project.pbxproj: Add PlatformTextTrack.h and PlatformTextTrackMenu.h.

* html/HTMLAudioElement.cpp:
(WebCore::HTMLAudioElement::createForJSConstructor): scheduleLoad -> scheduleDelayedAction.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Deal with scheduleLoad to scheduleDelayedAction rename.
(WebCore::HTMLMediaElement::parseAttribute): Ditto.
(WebCore::HTMLMediaElement::finishParsingChildren): Ditto.
(WebCore::HTMLMediaElement::insertedInto): Ditto.
(WebCore::HTMLMediaElement::scheduleDelayedAction): Ditto.
(WebCore::HTMLMediaElement::scheduleNextSourceChild): Ditto.
(WebCore::HTMLMediaElement::loadTimerFired): Ditto.
(WebCore::HTMLMediaElement::textTrackModeChanged): Notify platform menu of track change.
(WebCore::HTMLMediaElement::playInternal): Deal with scheduleLoad to scheduleDelayedAction rename.
(WebCore::HTMLMediaElement::pauseInternal): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerDidAddTrack): Ditto. Call addTrack() instead of appending
    the track directly.
(WebCore::HTMLMediaElement::setSelectedTextTrack): Deal with platform menu changing the
    selected track.
(WebCore::HTMLMediaElement::platformTextTracks): Return an array of PlatformTracks representing
    the current text tracks.
(WebCore::HTMLMediaElement::notifyMediaPlayerOfTextTrackChanges): Notify the platform menu
    that the list of text tracks has changed.
(WebCore::HTMLMediaElement::platformTextTrackMenu): Return the platform track menu, if any.
(WebCore::HTMLMediaElement::closeCaptionTracksChanged):
(WebCore::HTMLMediaElement::addTrack): Call addTrack() instead of appending the track directly.
(WebCore::HTMLMediaElement::removeTrack): Call closeCaptionTracksChanged.
(WebCore::HTMLMediaElement::addTextTrack): Call addTrack() instead of appending the track directly.
(WebCore::HTMLMediaElement::didAddTrack): Ditto.
(WebCore::HTMLMediaElement::didRemoveTrack): Deal with scheduleLoad to scheduleDelayedAction rename.
(WebCore::HTMLMediaElement::sourceWasAdded): Ditto.
(WebCore::HTMLMediaElement::clearMediaPlayer): Forget the platform track menu.
(WebCore::HTMLMediaElement::resume): Deal with scheduleLoad to scheduleDelayedAction rename.
* html/HTMLMediaElement.h:

* html/track/InbandTextTrack.h: scheduleLoad -> scheduleDelayedAction.

* html/track/TextTrack.cpp:
(WebCore::TextTrack::platformTextTrack): Create a PlatformTextTrack.
* html/track/TextTrack.h:

* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::implementsTextTrackControls): New, player private passthrough.
(WebCore::MediaPlayer::textTrackMenu): Ditto.
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:

* platform/graphics/PlatformTextTrack.h: Added.

* platform/graphics/PlatformTextTrackMenu.h: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (145321 => 145322)


--- trunk/Source/WebCore/ChangeLog	2013-03-09 21:27:34 UTC (rev 145321)
+++ trunk/Source/WebCore/ChangeLog	2013-03-09 21:29:13 UTC (rev 145322)
@@ -1,5 +1,66 @@
 2013-03-09  Eric Carlson  <eric.carl...@apple.com>
 
+        Enable platform code to implement text track menu
+        https://bugs.webkit.org/show_bug.cgi?id=111924
+
+        Reviewed by Dean Jackson.
+
+        No new tests, the new code isn't enabled in any ports yet.
+
+        * WebCore.xcodeproj/project.pbxproj: Add PlatformTextTrack.h and PlatformTextTrackMenu.h.
+
+        * html/HTMLAudioElement.cpp:
+        (WebCore::HTMLAudioElement::createForJSConstructor): scheduleLoad -> scheduleDelayedAction.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement): Deal with scheduleLoad to scheduleDelayedAction rename.
+        (WebCore::HTMLMediaElement::parseAttribute): Ditto.
+        (WebCore::HTMLMediaElement::finishParsingChildren): Ditto.
+        (WebCore::HTMLMediaElement::insertedInto): Ditto.
+        (WebCore::HTMLMediaElement::scheduleDelayedAction): Ditto.
+        (WebCore::HTMLMediaElement::scheduleNextSourceChild): Ditto.
+        (WebCore::HTMLMediaElement::loadTimerFired): Ditto.
+        (WebCore::HTMLMediaElement::textTrackModeChanged): Notify platform menu of track change.
+        (WebCore::HTMLMediaElement::playInternal): Deal with scheduleLoad to scheduleDelayedAction rename.
+        (WebCore::HTMLMediaElement::pauseInternal): Ditto.
+        (WebCore::HTMLMediaElement::mediaPlayerDidAddTrack): Ditto. Call addTrack() instead of appending 
+            the track directly.
+        (WebCore::HTMLMediaElement::setSelectedTextTrack): Deal with platform menu changing the
+            selected track.
+        (WebCore::HTMLMediaElement::platformTextTracks): Return an array of PlatformTracks representing
+            the current text tracks.
+        (WebCore::HTMLMediaElement::notifyMediaPlayerOfTextTrackChanges): Notify the platform menu
+            that the list of text tracks has changed.
+        (WebCore::HTMLMediaElement::platformTextTrackMenu): Return the platform track menu, if any.
+        (WebCore::HTMLMediaElement::closeCaptionTracksChanged): 
+        (WebCore::HTMLMediaElement::addTrack): Call addTrack() instead of appending the track directly.
+        (WebCore::HTMLMediaElement::removeTrack): Call closeCaptionTracksChanged.
+        (WebCore::HTMLMediaElement::addTextTrack): Call addTrack() instead of appending the track directly.
+        (WebCore::HTMLMediaElement::didAddTrack): Ditto.
+        (WebCore::HTMLMediaElement::didRemoveTrack): Deal with scheduleLoad to scheduleDelayedAction rename.
+        (WebCore::HTMLMediaElement::sourceWasAdded): Ditto.
+        (WebCore::HTMLMediaElement::clearMediaPlayer): Forget the platform track menu.
+        (WebCore::HTMLMediaElement::resume): Deal with scheduleLoad to scheduleDelayedAction rename.
+        * html/HTMLMediaElement.h:
+
+        * html/track/InbandTextTrack.h: scheduleLoad -> scheduleDelayedAction.
+
+        * html/track/TextTrack.cpp:
+        (WebCore::TextTrack::platformTextTrack): Create a PlatformTextTrack.
+        * html/track/TextTrack.h:
+
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::implementsTextTrackControls): New, player private passthrough.
+        (WebCore::MediaPlayer::textTrackMenu): Ditto.
+        * platform/graphics/MediaPlayer.h:
+        * platform/graphics/MediaPlayerPrivate.h:
+
+        * platform/graphics/PlatformTextTrack.h: Added.
+
+        * platform/graphics/PlatformTextTrackMenu.h: Added.
+
+2013-03-09  Eric Carlson  <eric.carl...@apple.com>
+
         Video size calculated incorrectly when PLUGIN_PROXY_FOR_VIDEO
         https://bugs.webkit.org/show_bug.cgi?id=111912
 

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (145321 => 145322)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-03-09 21:27:34 UTC (rev 145321)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-03-09 21:29:13 UTC (rev 145322)
@@ -7405,6 +7405,8 @@
 		0720B09F14D3323500642955 /* GenericEventQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericEventQueue.h; sourceTree = "<group>"; };
 		0720B09F14D3323500642956 /* GestureEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GestureEvent.cpp; sourceTree = "<group>"; };
 		0720B09F14D3323500642957 /* GestureEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GestureEvent.h; sourceTree = "<group>"; };
+		072847E216EBC5B00043CFA4 /* PlatformTextTrack.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformTextTrack.h; sourceTree = "<group>"; };
+		072847E316EBC5B00043CFA4 /* PlatformTextTrackMenu.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformTextTrackMenu.h; sourceTree = "<group>"; };
 		072CA86016CB4DC3008AE131 /* CaptionUserPreferences.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CaptionUserPreferences.cpp; sourceTree = "<group>"; };
 		0735EE690F40C5E4004A2604 /* MediaPlayerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlayerProxy.h; sourceTree = "<group>"; };
 		0753860014489E9800B78452 /* CachedTextTrack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedTextTrack.cpp; sourceTree = "<group>"; };
@@ -20795,6 +20797,8 @@
 				A8FA6E5C0E4CFDED00D5CF49 /* Pattern.cpp */,
 				A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */,
 				0562F9601573F88F0031CA16 /* PlatformLayer.h */,
+				072847E216EBC5B00043CFA4 /* PlatformTextTrack.h */,
+				072847E316EBC5B00043CFA4 /* PlatformTextTrackMenu.h */,
 				BCAB417F13E356E800D8AAF3 /* Region.cpp */,
 				BCAB418013E356E800D8AAF3 /* Region.h */,
 				A73F95FC12C97BFE0031AAF9 /* RoundedRect.cpp */,

Modified: trunk/Source/WebCore/html/HTMLAudioElement.cpp (145321 => 145322)


--- trunk/Source/WebCore/html/HTMLAudioElement.cpp	2013-03-09 21:27:34 UTC (rev 145321)
+++ trunk/Source/WebCore/html/HTMLAudioElement.cpp	2013-03-09 21:29:13 UTC (rev 145322)
@@ -1,6 +1,5 @@
 /*
- * Copyright (C) 2007, 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -53,7 +52,7 @@
     audio->setPreload("auto");
     if (!src.isNull()) {
         audio->setSrc(src);
-        audio->scheduleLoad(HTMLMediaElement::MediaResource);
+        audio->scheduleDelayedAction(HTMLMediaElement::LoadMediaResource);
     }
     audio->suspendIfNeeded();
     return audio.release();

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (145321 => 145322)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-03-09 21:27:34 UTC (rev 145321)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-03-09 21:29:13 UTC (rev 145322)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -129,6 +129,10 @@
 #include "MediaKeys.h"
 #endif
 
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+#include "PlatformTextTrack.h"
+#endif
+
 using namespace std;
 
 namespace WebCore {
@@ -261,7 +265,7 @@
     , m_minimumWallClockTimeToCacheMediaTime(0)
     , m_fragmentStartTime(MediaPlayer::invalidTime())
     , m_fragmentEndTime(MediaPlayer::invalidTime())
-    , m_pendingLoadFlags(0)
+    , m_pendingActionFlags(0)
     , m_playing(false)
     , m_isWaitingUntilMediaCanStart(false)
     , m_shouldDelayLoadEvent(false)
@@ -399,8 +403,8 @@
     if (name == srcAttr) {
         // Trigger a reload, as long as the 'src' attribute is present.
         if (!value.isNull()) {
-            clearMediaPlayer(MediaResource);
-            scheduleLoad(MediaResource);
+            clearMediaPlayer(LoadMediaResource);
+            scheduleDelayedAction(LoadMediaResource);
         }
     } else if (name == controlsAttr)
         configureMediaControls();
@@ -495,7 +499,7 @@
     
     for (Node* node = firstChild(); node; node = node->nextSibling()) {
         if (node->hasTagName(trackTag)) {
-            scheduleLoad(TextTrackResource);
+            scheduleDelayedAction(LoadTextTrackResource);
             break;
         }
     }
@@ -550,7 +554,7 @@
     LOG(Media, "HTMLMediaElement::insertedInto");
     HTMLElement::insertedInto(insertionPoint);
     if (insertionPoint->inDocument() && !getAttribute(srcAttr).isEmpty() && m_networkState == NETWORK_EMPTY)
-        scheduleLoad(MediaResource);
+        scheduleDelayedAction(LoadMediaResource);
     configureMediaControls();
     return InsertionDone;
 }
@@ -609,24 +613,29 @@
         renderer()->updateFromElement();
 }
 
-void HTMLMediaElement::scheduleLoad(LoadType loadType)
+void HTMLMediaElement::scheduleDelayedAction(DelayedActionType actionType)
 {
     LOG(Media, "HTMLMediaElement::scheduleLoad");
 
-    if ((loadType & MediaResource) && !(m_pendingLoadFlags & MediaResource)) {
+    if ((actionType & LoadMediaResource) && !(m_pendingActionFlags & LoadMediaResource)) {
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
         createMediaPlayerProxy();
 #endif
         
         prepareForLoad();
-        m_pendingLoadFlags |= MediaResource;
+        m_pendingActionFlags |= LoadMediaResource;
     }
 
 #if ENABLE(VIDEO_TRACK)
-    if (RuntimeEnabledFeatures::webkitVideoTrackEnabled() && (loadType & TextTrackResource))
-        m_pendingLoadFlags |= TextTrackResource;
+    if (RuntimeEnabledFeatures::webkitVideoTrackEnabled() && (actionType & LoadTextTrackResource))
+        m_pendingActionFlags |= LoadTextTrackResource;
 #endif
 
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+    if (actionType & TextTrackChangesNotification)
+        m_pendingActionFlags |= TextTrackChangesNotification;
+#endif
+
     if (!m_loadTimer.isActive())
         m_loadTimer.startOneShot(0);
 }
@@ -634,7 +643,7 @@
 void HTMLMediaElement::scheduleNextSourceChild()
 {
     // Schedule the timer to try the next <source> element WITHOUT resetting state ala prepareForLoad.
-    m_pendingLoadFlags |= MediaResource;
+    m_pendingActionFlags |= LoadMediaResource;
     m_loadTimer.startOneShot(0);
 }
 
@@ -654,18 +663,23 @@
     RefPtr<HTMLMediaElement> protect(this); // loadNextSourceChild may fire 'beforeload', which can make arbitrary DOM mutations.
 
 #if ENABLE(VIDEO_TRACK)
-    if (RuntimeEnabledFeatures::webkitVideoTrackEnabled() && (m_pendingLoadFlags & TextTrackResource))
+    if (RuntimeEnabledFeatures::webkitVideoTrackEnabled() && (m_pendingActionFlags & LoadTextTrackResource))
         configureTextTracks();
 #endif
 
-    if (m_pendingLoadFlags & MediaResource) {
+    if (m_pendingActionFlags & LoadMediaResource) {
         if (m_loadState == LoadingFromSourceElement)
             loadNextSourceChild();
         else
             loadInternal();
     }
 
-    m_pendingLoadFlags = 0;
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+    if (RuntimeEnabledFeatures::webkitVideoTrackEnabled() && (m_pendingActionFlags & TextTrackChangesNotification))
+        notifyMediaPlayerOfTextTrackChanges();
+#endif
+
+    m_pendingActionFlags = 0;
 }
 
 PassRefPtr<MediaError> HTMLMediaElement::error() const 
@@ -1385,6 +1399,11 @@
         }
     }
 
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+    if (platformTextTrackMenu())
+        platformTextTrackMenu()->trackWasSelected(track->platformTextTrack());
+#endif
+    
     configureTextTrackDisplay();
     updateActiveTextTrackCues(currentTime());
 }
@@ -2422,7 +2441,7 @@
 
     // 4.8.10.9. Playing the media resource
     if (!m_player || m_networkState == NETWORK_EMPTY)
-        scheduleLoad(MediaResource);
+        scheduleDelayedAction(LoadMediaResource);
 
     if (endedPlayback())
         seek(0, IGNORE_EXCEPTION);
@@ -2463,7 +2482,7 @@
 
     // 4.8.10.9. Playing the media resource
     if (!m_player || m_networkState == NETWORK_EMPTY)
-        scheduleLoad(MediaResource);
+        scheduleDelayedAction(LoadMediaResource);
 
     m_autoplaying = false;
 
@@ -2819,13 +2838,13 @@
     // 7. Set the new text track's mode to the mode consistent with the user's preferences and the requirements of
     // the relevant specification for the data.
     //  - This will happen in configureTextTracks()
-    scheduleLoad(TextTrackResource);
+    scheduleDelayedAction(LoadTextTrackResource);
     
     // 8. Add the new text track to the media element's list of text tracks.
     // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent
     // interface, with the track attribute initialized to the text track's TextTrack object, at the media element's
     // textTracks attribute's TextTrackList object.
-    textTracks()->append(textTrack);
+    addTrack(textTrack.get());
 }
 
 void HTMLMediaElement::mediaPlayerDidRemoveTrack(PassRefPtr<InbandTextTrackPrivate> prpTrack)
@@ -2845,6 +2864,89 @@
     removeTrack(textTrack.get());
 }
 
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+void HTMLMediaElement::setSelectedTextTrack(PassRefPtr<PlatformTextTrack> platformTrack)
+{
+    if (!m_textTracks)
+        return;
+
+    TrackDisplayUpdateScope scope(this);
+
+    if (!platformTrack) {
+        toggleTrackAtIndex(textTracksOffIndex(), true);
+        return;
+    }
+
+    TextTrack* textTrack;
+    size_t i;
+    for (i = 0; i < m_textTracks->length(); ++i) {
+        textTrack = m_textTracks->item(i);
+        
+        if (textTrack->platformTextTrack() == platformTrack)
+            break;
+    }
+
+    if (i == m_textTracks->length())
+        return;
+    toggleTrackAtIndex(i, true);
+}
+
+Vector<RefPtr<PlatformTextTrack> > HTMLMediaElement::platformTextTracks()
+{
+    if (!m_textTracks || !m_textTracks->length())
+        return Vector<RefPtr<PlatformTextTrack> >();
+    
+    Vector<RefPtr<PlatformTextTrack> > platformTracks;
+    for (size_t i = 0; i < m_textTracks->length(); ++i)
+        platformTracks.append(m_textTracks->item(i)->platformTextTrack());
+    
+    return platformTracks;
+}
+
+void HTMLMediaElement::notifyMediaPlayerOfTextTrackChanges()
+{
+    if (!m_textTracks || !m_textTracks->length() || !platformTextTrackMenu())
+        return;
+    
+    m_platformMenu->tracksDidChange();
+}
+
+PlatformTextTrackMenuInterface* HTMLMediaElement::platformTextTrackMenu()
+{
+    if (m_platformMenu)
+        return m_platformMenu.get();
+
+    if (!m_player->implementsTextTrackControls())
+        return 0;
+
+    m_platformMenu = m_player->textTrackMenu();
+    if (!m_platformMenu)
+        return 0;
+
+    m_platformMenu->setClient(this);
+
+    return m_platformMenu.get();
+}
+#endif // #if USE(PLATFORM_TEXT_TRACK_MENU)
+    
+void HTMLMediaElement::closeCaptionTracksChanged()
+{
+    if (hasMediaControls())
+        mediaControls()->closedCaptionTracksChanged();
+
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+    if (m_player->implementsTextTrackControls())
+        scheduleDelayedAction(TextTrackChangesNotification);
+#endif
+}
+
+void HTMLMediaElement::addTrack(TextTrack* track)
+{
+    textTracks()->append(track);
+    
+    closeCaptionTracksChanged();
+}
+
 void HTMLMediaElement::removeTrack(TextTrack* track)
 {
     TrackDisplayUpdateScope scope(this);
@@ -2852,6 +2954,8 @@
     if (cues)
         textTrackRemoveCues(track, cues);
     m_textTracks->remove(track);
+
+    closeCaptionTracksChanged();
 }
 
 void HTMLMediaElement::removeAllInbandTracks()
@@ -2894,7 +2998,7 @@
     // first append the track to the text track list.
 
     // 6. Add the new text track to the media element's list of text tracks.
-    textTracks()->append(textTrack);
+    addTrack(textTrack.get());
 
     // ... its text track readiness state to the text track loaded state ...
     textTrack->setReadinessState(TextTrack::Loaded);
@@ -2902,9 +3006,6 @@
     // ... its text track mode to the text track hidden mode, and its text track list of cues to an empty list ...
     textTrack->setMode(TextTrack::hiddenKeyword());
 
-    if (hasMediaControls())
-        mediaControls()->closedCaptionTracksChanged();
-
     return textTrack.release();
 }
 
@@ -2934,12 +3035,12 @@
     if (!textTrack)
         return;
     
-    textTracks()->append(textTrack);
+    addTrack(textTrack.get());
     
     // Do not schedule the track loading until parsing finishes so we don't start before all tracks
     // in the markup have been added.
     if (!m_parsingInProgress)
-        scheduleLoad(TextTrackResource);
+        scheduleDelayedAction(LoadTextTrackResource);
 
     if (hasMediaControls())
         mediaControls()->closedCaptionTracksChanged();
@@ -2974,9 +3075,6 @@
     // media element's list of text tracks.
     removeTrack(textTrack.get());
 
-    if (hasMediaControls())
-        mediaControls()->closedCaptionTracksChanged();
-
     size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get());
     if (index != notFound)
         m_textTracksWhenResourceSelectionBegan.remove(index);
@@ -3326,7 +3424,7 @@
     // attribute and whose networkState has the value NETWORK_EMPTY, the user agent must invoke 
     // the media element's resource selection algorithm.
     if (networkState() == HTMLMediaElement::NETWORK_EMPTY) {
-        scheduleLoad(MediaResource);
+        scheduleDelayedAction(LoadMediaResource);
         m_nextChildNodeToConsider = source;
         return;
     }
@@ -3869,6 +3967,13 @@
 
 void HTMLMediaElement::clearMediaPlayer(int flags)
 {
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+    if (platformTextTrackMenu()) {
+        m_platformMenu->setClient(0);
+        m_platformMenu = 0;
+    }
+#endif
+
 #if ENABLE(VIDEO_TRACK)
     removeAllInbandTracks();
 #endif
@@ -3884,7 +3989,7 @@
     stopPeriodicTimers();
     m_loadTimer.stop();
 
-    m_pendingLoadFlags &= ~flags;
+    m_pendingActionFlags &= ~flags;
     m_loadState = WaitingForSource;
 
 #if ENABLE(VIDEO_TRACK)
@@ -3948,7 +4053,7 @@
         //  MEDIA_ERR_ABORTED while the abortEvent is being sent, but cleared immediately afterwards).
         // This behavior is not specified but it seems like a sensible thing to do.
         // As it is not safe to immedately start loading now, let's schedule a load.
-        scheduleLoad(MediaResource);
+        scheduleDelayedAction(LoadMediaResource);
     }
 
     if (renderer())

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (145321 => 145322)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2013-03-09 21:27:34 UTC (rev 145321)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2013-03-09 21:29:13 UTC (rev 145322)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -86,6 +86,9 @@
 #if ENABLE(VIDEO_TRACK)
     , private TextTrackClient, private CaptionPreferencesChangedListener
 #endif
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+    , public PlatformTextTrackMenuClient
+#endif
 {
 public:
     MediaPlayer* player() const { return m_player.get(); }
@@ -108,11 +111,12 @@
     PlatformLayer* platformLayer() const;
 #endif
 
-    enum LoadType {
-        MediaResource = 1 << 0,
-        TextTrackResource = 1 << 1
+    enum DelayedActionType {
+        LoadMediaResource = 1 << 0,
+        LoadTextTrackResource = 1 << 1,
+        TextTrackChangesNotification = 1 << 2
     };
-    void scheduleLoad(LoadType);
+    void scheduleDelayedAction(DelayedActionType);
     
     MediaPlayer::MovieLoadType movieLoadType() const;
     
@@ -224,8 +228,11 @@
     TextTrackList* textTracks();
     CueList currentlyActiveCues() const { return m_currentlyActiveCues; }
 
+    void addTrack(TextTrack*);
     void removeTrack(TextTrack*);
     void removeAllInbandTracks();
+    void closeCaptionTracksChanged();
+    void notifyMediaPlayerOfTextTrackChanges();
 
     virtual void didAddTrack(HTMLTrackElement*);
     virtual void didRemoveTrack(HTMLTrackElement*);
@@ -233,6 +240,12 @@
     virtual void mediaPlayerDidAddTrack(PassRefPtr<InbandTextTrackPrivate>) OVERRIDE;
     virtual void mediaPlayerDidRemoveTrack(PassRefPtr<InbandTextTrackPrivate>) OVERRIDE;
 
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+    virtual void setSelectedTextTrack(PassRefPtr<PlatformTextTrack>) OVERRIDE;
+    virtual Vector<RefPtr<PlatformTextTrack> > platformTextTracks() OVERRIDE;
+    PlatformTextTrackMenuInterface* platformTextTrackMenu();
+#endif
+
     struct TrackGroup {
         enum GroupKind { CaptionsAndSubtitles, Description, Chapter, Metadata, Other };
 
@@ -644,8 +657,8 @@
     double m_fragmentStartTime;
     double m_fragmentEndTime;
 
-    typedef unsigned PendingLoadFlags;
-    PendingLoadFlags m_pendingLoadFlags;
+    typedef unsigned PendingActionFlags;
+    PendingActionFlags m_pendingActionFlags;
 
     bool m_playing : 1;
     bool m_isWaitingUntilMediaCanStart : 1;
@@ -718,6 +731,10 @@
 #if ENABLE(ENCRYPTED_MEDIA_V2)
     RefPtr<MediaKeys> m_mediaKeys;
 #endif
+
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+    RefPtr<PlatformTextTrackMenuInterface> m_platformMenu;
+#endif
 };
 
 #if ENABLE(VIDEO_TRACK)

Modified: trunk/Source/WebCore/html/track/InbandTextTrack.h (145321 => 145322)


--- trunk/Source/WebCore/html/track/InbandTextTrack.h	2013-03-09 21:27:34 UTC (rev 145321)
+++ trunk/Source/WebCore/html/track/InbandTextTrack.h	2013-03-09 21:29:13 UTC (rev 145322)
@@ -55,6 +55,10 @@
     virtual void addGenericCue(InbandTextTrackPrivate*, GenericCueData*) OVERRIDE;
     virtual void addWebVTTCue(InbandTextTrackPrivate*, double, double, const String&, const String&, const String&) OVERRIDE;
 
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+    virtual InbandTextTrackPrivate* privateTrack() OVERRIDE { return m_private.get(); }
+#endif
+
     RefPtr<InbandTextTrackPrivate> m_private;
 };
 

Modified: trunk/Source/WebCore/html/track/TextTrack.cpp (145321 => 145322)


--- trunk/Source/WebCore/html/track/TextTrack.cpp	2013-03-09 21:27:34 UTC (rev 145321)
+++ trunk/Source/WebCore/html/track/TextTrack.cpp	2013-03-09 21:29:13 UTC (rev 145322)
@@ -397,6 +397,38 @@
     return false;
 }
 
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+PassRefPtr<PlatformTextTrack> TextTrack::platformTextTrack()
+{
+    if (m_platformTextTrack)
+        return m_platformTextTrack;
+
+    PlatformTextTrack::TrackKind kind = PlatformTextTrack::Caption;
+    if (m_kind == subtitlesKeyword())
+        kind = PlatformTextTrack::Subtitle;
+    else if (m_kind == captionsKeyword())
+        kind = PlatformTextTrack::Caption;
+    else if (m_kind == descriptionsKeyword())
+        kind = PlatformTextTrack::Description;
+    else if (m_kind == chaptersKeyword())
+        kind = PlatformTextTrack::Chapter;
+    else if (m_kind == metadataKeyword())
+        kind = PlatformTextTrack::MetaData;
+
+    PlatformTextTrack::TrackType type = PlatformTextTrack::OutOfBand;
+    if (m_trackType == TrackElement)
+        type = PlatformTextTrack::OutOfBand;
+    else if (m_trackType == AddTrack)
+        type = PlatformTextTrack::Script;
+    else if (m_trackType == InBand)
+        type = PlatformTextTrack::InBand;
+
+    m_platformTextTrack = PlatformTextTrack::create(this, m_label, m_language, kind, type);
+
+    return m_platformTextTrack;
+}
+#endif
+
 } // namespace WebCore
 
 #endif

Modified: trunk/Source/WebCore/html/track/TextTrack.h (145321 => 145322)


--- trunk/Source/WebCore/html/track/TextTrack.h	2013-03-09 21:27:34 UTC (rev 145321)
+++ trunk/Source/WebCore/html/track/TextTrack.h	2013-03-09 21:29:13 UTC (rev 145322)
@@ -35,6 +35,10 @@
 #include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
 
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+#include "PlatformTextTrack.h"
+#endif
+
 namespace WebCore {
 
 class HTMLMediaElement;
@@ -53,7 +57,11 @@
     virtual void textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue>) = 0;
 };
 
-class TextTrack : public TrackBase {
+class TextTrack : public TrackBase
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+    , public PlatformTextTrackClient
+#endif
+    {
 public:
     static PassRefPtr<TextTrack> create(ScriptExecutionContext* context, TextTrackClient* client, const AtomicString& kind, const AtomicString& label, const AtomicString& language)
     {
@@ -125,6 +133,10 @@
 
     void removeAllCues();
 
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+    PassRefPtr<PlatformTextTrack> platformTextTrack();
+#endif
+
 protected:
     TextTrack(ScriptExecutionContext*, TextTrackClient*, const AtomicString& kind, const AtomicString& label, const AtomicString& language, TextTrackType);
 
@@ -132,6 +144,13 @@
 
 private:
     TextTrackCueList* ensureTextTrackCueList();
+
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+    virtual TextTrack* publicTrack() OVERRIDE { return this; }
+
+    RefPtr<PlatformTextTrack> m_platformTextTrack;
+#endif
+
     HTMLMediaElement* m_mediaElement;
     AtomicString m_kind;
     AtomicString m_label;

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (145321 => 145322)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2013-03-09 21:27:34 UTC (rev 145321)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2013-03-09 21:29:13 UTC (rev 145322)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -1120,8 +1120,20 @@
 {
     m_private->setTextTrackRepresentation(representation);
 }
-#endif
+#endif // ENABLE(VIDEO_TRACK)
 
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+bool MediaPlayer::implementsTextTrackControls() const
+{
+    return m_private->implementsTextTrackControls();
+}
+
+PassRefPtr<PlatformTextTrackMenuInterface> MediaPlayer::textTrackMenu()
+{
+    return m_private->textTrackMenu();
+}
+#endif // USE(PLATFORM_TEXT_TRACK_MENU)
+
 void MediaPlayer::resetMediaEngines()
 {
     installedMediaEngines(ResetEngines);

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (145321 => 145322)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2013-03-09 21:27:34 UTC (rev 145321)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2013-03-09 21:29:13 UTC (rev 145322)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -48,6 +48,10 @@
 #include "PlatformLayer.h"
 #endif
 
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+#include "PlatformTextTrackMenu.h"
+#endif
+
 OBJC_CLASS AVPlayer;
 OBJC_CLASS QTMovie;
 
@@ -437,6 +441,11 @@
 
     static void resetMediaEngines();
 
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+    bool implementsTextTrackControls() const;
+    PassRefPtr<PlatformTextTrackMenuInterface> textTrackMenu();
+#endif
+
 private:
     MediaPlayer(MediaPlayerClient*);
     void loadWithNextMediaEngine(MediaPlayerFactory*);

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (145321 => 145322)


--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2013-03-09 21:27:34 UTC (rev 145321)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2013-03-09 21:29:13 UTC (rev 145322)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,6 +36,7 @@
 
 class IntRect;
 class IntSize;
+class PlatformTextTrack;
 
 class MediaPlayerPrivateInterface {
     WTF_MAKE_NONCOPYABLE(MediaPlayerPrivateInterface); WTF_MAKE_FAST_ALLOCATED;
@@ -180,6 +181,12 @@
     virtual bool requiresTextTrackRepresentation() const { return false; }
     virtual void setTextTrackRepresentation(TextTrackRepresentation*) { }
 #endif
+
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+    virtual bool implementsTextTrackControls() const { return false; }
+    virtual PassRefPtr<PlatformTextTrackMenuInterface> textTrackMenu() { return 0; }
+#endif
+
 };
 
 }

Added: trunk/Source/WebCore/platform/graphics/PlatformTextTrack.h (0 => 145322)


--- trunk/Source/WebCore/platform/graphics/PlatformTextTrack.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/PlatformTextTrack.h	2013-03-09 21:29:13 UTC (rev 145322)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PlatformTextTrack_h
+#define PlatformTextTrack_h
+
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class TextTrack;
+class InbandTextTrackPrivate;
+
+class PlatformTextTrackClient {
+public:
+    virtual ~PlatformTextTrackClient() { }
+    
+    virtual TextTrack* publicTrack() = 0;
+    virtual InbandTextTrackPrivate* privateTrack() { return 0; }
+};
+
+class PlatformTextTrack : public RefCounted<PlatformTextTrack> {
+public:
+    enum TrackKind { Subtitle = 0, Caption = 1, Description = 2, Chapter = 3, MetaData = 4 };
+    enum TrackType { InBand = 0, OutOfBand = 1, Script = 2 };
+
+    static PassRefPtr<PlatformTextTrack> create(PlatformTextTrackClient* client, const String& label, const String& language, TrackKind kind, TrackType type)
+    {
+        return adoptRef(new PlatformTextTrack(client, label, language, kind, type));
+    }
+
+    virtual ~PlatformTextTrack() { }
+    
+    TrackType type() const { return m_type; }
+    TrackKind kind() const { return m_kind; }
+    String label() const { return m_label; }
+    String language() const { return m_language; }
+    PlatformTextTrackClient* client() const { return m_client; }
+    
+protected:
+    PlatformTextTrack(PlatformTextTrackClient* client, const String& label, const String& language, TrackKind kind, TrackType type)
+        : m_label(label)
+        , m_language(language)
+        , m_kind(kind)
+        , m_type(type)
+        , m_client(client)
+    {
+    }
+
+    String m_label;
+    String m_language;
+    TrackKind m_kind;
+    TrackType m_type;
+    PlatformTextTrackClient* m_client;
+};
+
+}
+
+#endif
+
+#endif // PlatformTextTrack_h

Added: trunk/Source/WebCore/platform/graphics/PlatformTextTrackMenu.h (0 => 145322)


--- trunk/Source/WebCore/platform/graphics/PlatformTextTrackMenu.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/PlatformTextTrackMenu.h	2013-03-09 21:29:13 UTC (rev 145322)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PlatformTextTrackMenu_h
+#define PlatformTextTrackMenu_h
+
+#if USE(PLATFORM_TEXT_TRACK_MENU)
+
+#include "PlatformTextTrack.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class PlatformTextTrack;
+
+class PlatformTextTrackMenuClient {
+public:
+    virtual ~PlatformTextTrackMenuClient() { }
+    
+    virtual void setSelectedTextTrack(PassRefPtr<PlatformTextTrack>) = 0;
+    virtual Vector<RefPtr<PlatformTextTrack> > platformTextTracks() = 0;
+};
+
+class PlatformTextTrackMenuInterface  : public RefCounted<PlatformTextTrackMenuInterface> {
+public:
+    explicit PlatformTextTrackMenuInterface() { }
+    virtual ~PlatformTextTrackMenuInterface() { }
+
+    virtual void tracksDidChange() = 0;
+    virtual void trackWasSelected(PassRefPtr<PlatformTextTrack>) = 0;
+    virtual void setClient(PlatformTextTrackMenuClient*) = 0;
+};
+
+}
+
+#endif // USE(PLATFORM_TEXT_TRACK_MENU)
+#endif // PlatformTextTrackMenu_h
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to