Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: third_party/WebKit/Source/core/html/track/InbandTextTrack.cpp

Issue 1973343002: Clean up HTMLTrackElement.kind invalid/missing value default handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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 "core/html/track/InbandTextTrack.h" 26 #include "core/html/track/InbandTextTrack.h"
27 27
28 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
29 #include "core/html/HTMLMediaElement.h" 28 #include "core/html/HTMLMediaElement.h"
30 #include "core/html/track/vtt/VTTCue.h" 29 #include "core/html/track/vtt/VTTCue.h"
31 #include "platform/Logging.h"
32 #include "public/platform/WebInbandTextTrack.h" 30 #include "public/platform/WebInbandTextTrack.h"
33 #include "public/platform/WebString.h" 31 #include "public/platform/WebString.h"
34 #include <math.h>
35 32
36 using blink::WebInbandTextTrack; 33 using blink::WebInbandTextTrack;
37 using blink::WebString; 34 using blink::WebString;
38 35
39 namespace blink { 36 namespace blink {
40 37
38 namespace {
39
40 const AtomicString& textTrackKindToString(WebInbandTextTrack::Kind kind)
41 {
42 switch (kind) {
43 case WebInbandTextTrack::KindSubtitles:
44 return TextTrack::subtitlesKeyword();
45 case WebInbandTextTrack::KindCaptions:
46 return TextTrack::captionsKeyword();
47 case WebInbandTextTrack::KindDescriptions:
48 return TextTrack::descriptionsKeyword();
49 case WebInbandTextTrack::KindChapters:
50 return TextTrack::chaptersKeyword();
51 case WebInbandTextTrack::KindMetadata:
52 return TextTrack::metadataKeyword();
53 case WebInbandTextTrack::KindNone:
54 default:
55 break;
56 }
57 ASSERT_NOT_REACHED();
58 return TextTrack::subtitlesKeyword();
59 }
60
61 } // namespace
62
41 InbandTextTrack* InbandTextTrack::create(WebInbandTextTrack* webTrack) 63 InbandTextTrack* InbandTextTrack::create(WebInbandTextTrack* webTrack)
42 { 64 {
43 return new InbandTextTrack(webTrack); 65 return new InbandTextTrack(webTrack);
44 } 66 }
45 67
46 InbandTextTrack::InbandTextTrack(WebInbandTextTrack* webTrack) 68 InbandTextTrack::InbandTextTrack(WebInbandTextTrack* webTrack)
47 : TextTrack(subtitlesKeyword(), webTrack->label(), webTrack->language(), web Track->id(), InBand) 69 : TextTrack(textTrackKindToString(webTrack->kind()), webTrack->label(), webT rack->language(), webTrack->id(), InBand)
48 , m_webTrack(webTrack) 70 , m_webTrack(webTrack)
49 { 71 {
50 m_webTrack->setClient(this); 72 m_webTrack->setClient(this);
51
52 switch (m_webTrack->kind()) {
53 case WebInbandTextTrack::KindSubtitles:
54 setKind(TextTrack::subtitlesKeyword());
55 break;
56 case WebInbandTextTrack::KindCaptions:
57 setKind(TextTrack::captionsKeyword());
58 break;
59 case WebInbandTextTrack::KindDescriptions:
60 setKind(TextTrack::descriptionsKeyword());
61 break;
62 case WebInbandTextTrack::KindChapters:
63 setKind(TextTrack::chaptersKeyword());
64 break;
65 case WebInbandTextTrack::KindMetadata:
66 setKind(TextTrack::metadataKeyword());
67 break;
68 case WebInbandTextTrack::KindNone:
69 default:
70 ASSERT_NOT_REACHED();
71 break;
72 }
73 } 73 }
74 74
75 InbandTextTrack::~InbandTextTrack() 75 InbandTextTrack::~InbandTextTrack()
76 { 76 {
77 if (m_webTrack) 77 if (m_webTrack)
78 m_webTrack->setClient(nullptr); 78 m_webTrack->setClient(nullptr);
79 } 79 }
80 80
81 void InbandTextTrack::setTrackList(TextTrackList* trackList) 81 void InbandTextTrack::setTrackList(TextTrackList* trackList)
82 { 82 {
(...skipping 10 matching lines...) Expand all
93 { 93 {
94 HTMLMediaElement* owner = mediaElement(); 94 HTMLMediaElement* owner = mediaElement();
95 ASSERT(owner); 95 ASSERT(owner);
96 VTTCue* cue = VTTCue::create(owner->document(), start, end, content); 96 VTTCue* cue = VTTCue::create(owner->document(), start, end, content);
97 cue->setId(id); 97 cue->setId(id);
98 cue->parseSettings(settings); 98 cue->parseSettings(settings);
99 addCue(cue); 99 addCue(cue);
100 } 100 }
101 101
102 } // namespace blink 102 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/track/AudioTrack.cpp ('k') | third_party/WebKit/Source/core/html/track/TextTrack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698