Changeset 151853 in webkit


Ignore:
Timestamp:
Jun 21, 2013 1:37:31 PM (11 years ago)
Author:
eric.carlson@apple.com
Message:

Update platform text track menu
https://bugs.webkit.org/show_bug.cgi?id=117884

Reviewed by Jer Noble.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::setSelectedTextTrack):

  • html/track/TextTrack.cpp:

(WebCore::TextTrack::platformTextTrack):

  • platform/graphics/PlatformTextTrack.h:

(WebCore::PlatformTextTrack::create):
(WebCore::PlatformTextTrack::uniqueId):
(WebCore::PlatformTextTrack::captionMenuOffItem):
(WebCore::PlatformTextTrack::captionMenuAutomaticItem):
(WebCore::PlatformTextTrack::PlatformTextTrack):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r151852 r151853  
     12013-06-21  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Update platform text track menu
     4        https://bugs.webkit.org/show_bug.cgi?id=117884
     5
     6        Reviewed by Jer Noble.
     7
     8        * html/HTMLMediaElement.cpp:
     9        (WebCore::HTMLMediaElement::setSelectedTextTrack):
     10        * html/track/TextTrack.cpp:
     11        (WebCore::TextTrack::platformTextTrack):
     12        * platform/graphics/PlatformTextTrack.h:
     13        (WebCore::PlatformTextTrack::create):
     14        (WebCore::PlatformTextTrack::uniqueId):
     15        (WebCore::PlatformTextTrack::captionMenuOffItem):
     16        (WebCore::PlatformTextTrack::captionMenuAutomaticItem):
     17        (WebCore::PlatformTextTrack::PlatformTextTrack):
     18
    1192013-06-21  James Craig  <james@cookiecrook.com>
    220
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r151684 r151853  
    29492949
    29502950    if (!platformTrack) {
    2951         setSelectedTextTrack(0);
     2951        setSelectedTextTrack(TextTrack::captionMenuOffItem());
    29522952        return;
    29532953    }
    29542954
    29552955    TextTrack* textTrack;
    2956     size_t i;
    2957     for (i = 0; i < m_textTracks->length(); ++i) {
    2958         textTrack = m_textTracks->item(i);
    2959        
    2960         if (textTrack->platformTextTrack() == platformTrack)
    2961             break;
    2962     }
    2963 
    2964     if (i == m_textTracks->length())
    2965         return;
     2956    if (platformTrack == PlatformTextTrack::captionMenuOffItem())
     2957        textTrack = TextTrack::captionMenuOffItem();
     2958    else if (platformTrack == PlatformTextTrack::captionMenuAutomaticItem())
     2959        textTrack = TextTrack::captionMenuAutomaticItem();
     2960    else {
     2961        size_t i;
     2962        for (i = 0; i < m_textTracks->length(); ++i) {
     2963            textTrack = m_textTracks->item(i);
     2964           
     2965            if (textTrack->platformTextTrack() == platformTrack)
     2966                break;
     2967        }
     2968        if (i == m_textTracks->length())
     2969            return;
     2970    }
     2971
    29662972    setSelectedTextTrack(textTrack);
    29672973}
  • trunk/Source/WebCore/html/track/TextTrack.cpp

    r148688 r151853  
    528528PassRefPtr<PlatformTextTrack> TextTrack::platformTextTrack()
    529529{
     530    static int uniqueId = 0;
     531
    530532    if (m_platformTextTrack)
    531533        return m_platformTextTrack;
     
    553555        type = PlatformTextTrack::InBand;
    554556
    555     m_platformTextTrack = PlatformTextTrack::create(this, label(), language(), platformKind, type);
     557    m_platformTextTrack = PlatformTextTrack::create(this, label(), language(), platformKind, type, ++uniqueId);
    556558
    557559    return m_platformTextTrack;
  • trunk/Source/WebCore/platform/graphics/PlatformTextTrack.h

    r148285 r151853  
    6161    };
    6262
    63     static PassRefPtr<PlatformTextTrack> create(PlatformTextTrackClient* client, const String& label, const String& language, TrackKind kind, TrackType type)
     63    static PassRefPtr<PlatformTextTrack> create(PlatformTextTrackClient* client, const String& label, const String& language, TrackKind kind, TrackType type, int uniqueId)
    6464    {
    65         return adoptRef(new PlatformTextTrack(client, label, language, kind, type));
     65        return adoptRef(new PlatformTextTrack(client, label, language, kind, type, uniqueId));
    6666    }
    6767
     
    7373    String language() const { return m_language; }
    7474    PlatformTextTrackClient* client() const { return m_client; }
    75    
     75    int uniqueId() const { return m_uniqueId; }
     76
     77    static PlatformTextTrack* captionMenuOffItem()
     78    {
     79        DEFINE_STATIC_LOCAL(RefPtr<PlatformTextTrack>, off, (PlatformTextTrack::create(0, "off menu item", "", Subtitle, InBand, 0)));
     80        return off.get();
     81    }
     82
     83    static PlatformTextTrack* captionMenuAutomaticItem()
     84    {
     85        DEFINE_STATIC_LOCAL(RefPtr<PlatformTextTrack>, automatic, (PlatformTextTrack::create(0, "automatic menu item", "", Subtitle, InBand, 0)));
     86        return automatic.get();
     87    }
     88
    7689protected:
    77     PlatformTextTrack(PlatformTextTrackClient* client, const String& label, const String& language, TrackKind kind, TrackType type)
     90    PlatformTextTrack(PlatformTextTrackClient* client, const String& label, const String& language, TrackKind kind, TrackType type, int uniqueId)
    7891        : m_label(label)
    7992        , m_language(language)
     
    8194        , m_type(type)
    8295        , m_client(client)
     96        , m_uniqueId(uniqueId)
    8397    {
    8498    }
     
    89103    TrackType m_type;
    90104    PlatformTextTrackClient* m_client;
     105    int m_uniqueId;
    91106};
    92107
Note: See TracChangeset for help on using the changeset viewer.