| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/html/track/InbandTextTrack.h" | 27 #include "core/html/track/InbandTextTrack.h" |
| 28 | 28 |
| 29 #include "bindings/v8/ExceptionStatePlaceholder.h" | 29 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 30 #include "core/html/track/TextTrackCue.h" | 30 #include "core/html/track/TextTrackCue.h" |
| 31 #include "platform/Logging.h" | 31 #include "platform/Logging.h" |
| 32 #include "platform/graphics/media/InbandTextTrackPrivate.h" | 32 #include "public/platform/WebInbandTextTrack.h" |
| 33 #include "public/platform/WebString.h" |
| 33 #include "wtf/UnusedParam.h" | 34 #include "wtf/UnusedParam.h" |
| 34 #include <math.h> | 35 #include <math.h> |
| 35 | 36 |
| 37 using blink::WebInbandTextTrack; |
| 38 using blink::WebString; |
| 39 |
| 36 namespace WebCore { | 40 namespace WebCore { |
| 37 | 41 |
| 38 PassRefPtr<InbandTextTrack> InbandTextTrack::create(Document& document, TextTrac
kClient* client, PassRefPtr<InbandTextTrackPrivate> playerPrivate) | 42 PassRefPtr<InbandTextTrack> InbandTextTrack::create(Document& document, TextTrac
kClient* client, WebInbandTextTrack* webTrack) |
| 39 { | 43 { |
| 40 return adoptRef(new InbandTextTrack(document, client, playerPrivate)); | 44 return adoptRef(new InbandTextTrack(document, client, webTrack)); |
| 41 } | 45 } |
| 42 | 46 |
| 43 InbandTextTrack::InbandTextTrack(Document& document, TextTrackClient* client, Pa
ssRefPtr<InbandTextTrackPrivate> tracksPrivate) | 47 InbandTextTrack::InbandTextTrack(Document& document, TextTrackClient* client, We
bInbandTextTrack* webTrack) |
| 44 : TextTrack(document, client, emptyAtom, tracksPrivate->label(), tracksPriva
te->language(), InBand) | 48 : TextTrack(document, client, emptyAtom, webTrack->label(), webTrack->langua
ge(), InBand) |
| 45 , m_private(tracksPrivate) | 49 , m_webTrack(webTrack) |
| 46 { | 50 { |
| 47 m_private->setClient(this); | 51 m_webTrack->setClient(this); |
| 48 | 52 |
| 49 switch (m_private->kind()) { | 53 switch (m_webTrack->kind()) { |
| 50 case InbandTextTrackPrivate::Subtitles: | 54 case WebInbandTextTrack::KindSubtitles: |
| 51 setKind(TextTrack::subtitlesKeyword()); | 55 setKind(TextTrack::subtitlesKeyword()); |
| 52 break; | 56 break; |
| 53 case InbandTextTrackPrivate::Captions: | 57 case WebInbandTextTrack::KindCaptions: |
| 54 setKind(TextTrack::captionsKeyword()); | 58 setKind(TextTrack::captionsKeyword()); |
| 55 break; | 59 break; |
| 56 case InbandTextTrackPrivate::Descriptions: | 60 case WebInbandTextTrack::KindDescriptions: |
| 57 setKind(TextTrack::descriptionsKeyword()); | 61 setKind(TextTrack::descriptionsKeyword()); |
| 58 break; | 62 break; |
| 59 case InbandTextTrackPrivate::Chapters: | 63 case WebInbandTextTrack::KindChapters: |
| 60 setKind(TextTrack::chaptersKeyword()); | 64 setKind(TextTrack::chaptersKeyword()); |
| 61 break; | 65 break; |
| 62 case InbandTextTrackPrivate::Metadata: | 66 case WebInbandTextTrack::KindMetadata: |
| 63 setKind(TextTrack::metadataKeyword()); | 67 setKind(TextTrack::metadataKeyword()); |
| 64 break; | 68 break; |
| 65 case InbandTextTrackPrivate::None: | 69 case WebInbandTextTrack::KindNone: |
| 66 default: | 70 default: |
| 67 ASSERT_NOT_REACHED(); | 71 ASSERT_NOT_REACHED(); |
| 68 break; | 72 break; |
| 69 } | 73 } |
| 70 } | 74 } |
| 71 | 75 |
| 72 InbandTextTrack::~InbandTextTrack() | 76 InbandTextTrack::~InbandTextTrack() |
| 73 { | 77 { |
| 74 // Make sure m_private was cleared by trackRemoved() before destruction. | 78 // Make sure m_webTrack was cleared by trackRemoved() before destruction. |
| 75 ASSERT(!m_private); | 79 ASSERT(!m_webTrack); |
| 76 } | 80 } |
| 77 | 81 |
| 78 size_t InbandTextTrack::inbandTrackIndex() | 82 size_t InbandTextTrack::inbandTrackIndex() |
| 79 { | 83 { |
| 80 ASSERT(m_private); | 84 ASSERT(m_webTrack); |
| 81 return m_private->textTrackIndex(); | 85 return m_webTrack->textTrackIndex(); |
| 82 } | 86 } |
| 83 | 87 |
| 84 void InbandTextTrack::trackRemoved() | 88 void InbandTextTrack::trackRemoved() |
| 85 { | 89 { |
| 86 ASSERT(m_private); | 90 ASSERT(m_webTrack); |
| 87 m_private->setClient(0); | 91 m_webTrack->setClient(0); |
| 88 m_private = 0; | 92 m_webTrack = 0; |
| 89 clearClient(); | 93 clearClient(); |
| 90 } | 94 } |
| 91 | 95 |
| 92 void InbandTextTrack::addWebVTTCue(InbandTextTrackPrivate* trackPrivate, double
start, double end, const String& id, const String& content, const String& settin
gs) | 96 void InbandTextTrack::addWebVTTCue(double start, double end, const WebString& id
, const WebString& content, const WebString& settings) |
| 93 { | 97 { |
| 94 ASSERT_UNUSED(trackPrivate, trackPrivate == m_private); | |
| 95 | |
| 96 RefPtr<TextTrackCue> cue = TextTrackCue::create(document(), start, end, cont
ent); | 98 RefPtr<TextTrackCue> cue = TextTrackCue::create(document(), start, end, cont
ent); |
| 97 cue->setId(id); | 99 cue->setId(id); |
| 98 cue->setCueSettings(settings); | 100 cue->setCueSettings(settings); |
| 99 | 101 |
| 100 if (hasCue(cue.get())) | 102 if (hasCue(cue.get())) |
| 101 return; | 103 return; |
| 102 | 104 |
| 103 addCue(cue); | 105 addCue(cue); |
| 104 } | 106 } |
| 105 | 107 |
| 106 } // namespace WebCore | 108 } // namespace WebCore |
| OLD | NEW |