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; }
PassRefPtr<PlatformTextTrack> TextTrack::platformTextTrack() { if (m_platformTextTrack) return m_platformTextTrack; PlatformTextTrack::TrackKind platformKind = PlatformTextTrack::Caption; if (kind() == subtitlesKeyword()) platformKind = PlatformTextTrack::Subtitle; else if (kind() == captionsKeyword()) platformKind = PlatformTextTrack::Caption; else if (kind() == descriptionsKeyword()) platformKind = PlatformTextTrack::Description; else if (kind() == chaptersKeyword()) platformKind = PlatformTextTrack::Chapter; else if (kind() == metadataKeyword()) platformKind = PlatformTextTrack::MetaData; else if (kind() == forcedKeyword()) platformKind = PlatformTextTrack::Forced; 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, label(), language(), platformKind, type, uniqueId()); return m_platformTextTrack; }
bool TextTrack::isMainProgramContent() const { // "Main program" content is intrinsic to the presentation of the media file, regardless of locale. Content such as // directors commentary is not "main program" because it is not essential for the presentation. HTML5 doesn't have // a way to express this in a machine-reable form, it is typically done with the track label, so we assume that caption // tracks are main content and all other track types are not. return kind() == captionsKeyword(); }
bool VideoTrack::isValidKind(const AtomicString& kind) const { return (kind == alternativeKeyword()) || (kind == captionsKeyword()) || (kind == mainKeyword()) || (kind == signKeyword()) || (kind == subtitlesKeyword()) || (kind == commentaryKeyword()); }
bool TextTrack::isRendered() { if (kind() != captionsKeyword() && kind() != subtitlesKeyword() && kind() != forcedKeyword()) return false; if (m_mode != showingKeyword()) return false; return true; }
bool TextTrack::isRendered() { if (m_kind != captionsKeyword() && m_kind != subtitlesKeyword()) return false; if (m_mode != showingKeyword() && !m_showingByDefault) return false; return true; }
void TextTrack::setKind(const AtomicString& newKind) { AtomicString oldKind = kind(); TrackBase::setKind(newKind); // If kind changes from visual to non-visual and mode is 'showing', then force mode to 'hidden'. // FIXME: This is not per spec. crbug.com/460923 if (oldKind != kind() && mode() == showingKeyword()) { if (kind() != captionsKeyword() && kind() != subtitlesKeyword()) setMode(hiddenKeyword()); } }
bool TextTrack::isValidKindKeyword(const AtomicString& value) { if (equalIgnoringCase(value, subtitlesKeyword())) return true; if (equalIgnoringCase(value, captionsKeyword())) return true; if (equalIgnoringCase(value, descriptionsKeyword())) return true; if (equalIgnoringCase(value, chaptersKeyword())) return true; if (equalIgnoringCase(value, metadataKeyword())) return true; return false; }
bool TextTrack::isValidKindKeyword(const AtomicString& value) { if (value == subtitlesKeyword()) return true; if (value == captionsKeyword()) return true; if (value == descriptionsKeyword()) return true; if (value == chaptersKeyword()) return true; if (value == metadataKeyword()) return true; return false; }
bool VideoTrack::isValidKind(const AtomicString& value) const { if (value == alternativeKeyword()) return true; if (value == captionsKeyword()) return true; if (value == mainKeyword()) return true; if (value == signKeyword()) return true; if (value == subtitlesKeyword()) return true; if (value == commentaryKeyword()) return true; return false; }
TextTrack::TextTrack(ScriptExecutionContext* context, TextTrackClient* client, const AtomicString& kind, const AtomicString& id, const AtomicString& label, const AtomicString& language, TextTrackType type) : TrackBase(TrackBase::TextTrack, id, label, language) , m_scriptExecutionContext(context) , m_client(client) , m_trackType(type) , m_trackIndex(invalidTrackIndex) , m_renderedTrackIndex(invalidTrackIndex) { if (kind == captionsKeyword()) m_kind = Kind::Captions; else if (kind == chaptersKeyword()) m_kind = Kind::Chapters; else if (kind == descriptionsKeyword()) m_kind = Kind::Descriptions; else if (kind == forcedKeyword()) m_kind = Kind::Forced; else if (kind == metadataKeyword()) m_kind = Kind::Metadata; }
const AtomicString& TextTrack::kindKeyword() const { switch (m_kind) { case Kind::Captions: return captionsKeyword(); case Kind::Chapters: return chaptersKeyword(); case Kind::Descriptions: return descriptionsKeyword(); case Kind::Forced: return forcedKeyword(); case Kind::Metadata: return metadataKeyword(); case Kind::Subtitles: return subtitlesKeyword(); } ASSERT_NOT_REACHED(); return subtitlesKeyword(); }