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

Unified Diff: third_party/WebKit/Source/core/html/track/TextTrack.cpp

Issue 1976183002: Add TextTrack::isVisualKind helper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/track/TextTrack.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/track/TextTrack.cpp
diff --git a/third_party/WebKit/Source/core/html/track/TextTrack.cpp b/third_party/WebKit/Source/core/html/track/TextTrack.cpp
index 097a1f29b8fb11754118f371cab53c6a636e3a8c..6520bbbb0a6506dd2f513704f327a383a2dc0878 100644
--- a/third_party/WebKit/Source/core/html/track/TextTrack.cpp
+++ b/third_party/WebKit/Source/core/html/track/TextTrack.cpp
@@ -138,6 +138,11 @@ void TextTrack::setTrackList(TextTrackList* trackList)
invalidateTrackIndex();
}
+bool TextTrack::isVisualKind() const
+{
+ return kind() == subtitlesKeyword() || kind() == captionsKeyword();
+}
+
void TextTrack::setKind(const AtomicString& newKind)
{
AtomicString oldKind = kind();
@@ -145,10 +150,8 @@ void TextTrack::setKind(const AtomicString& 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());
- }
+ if (oldKind != kind() && mode() == showingKeyword() && !isVisualKind())
+ setMode(hiddenKeyword());
}
void TextTrack::setMode(const AtomicString& mode)
@@ -416,25 +419,13 @@ void TextTrack::invalidateTrackIndex()
bool TextTrack::isRendered() const
{
- if (kind() != captionsKeyword() && kind() != subtitlesKeyword())
- return false;
-
- if (m_mode != showingKeyword())
- return false;
-
- return true;
+ return m_mode == showingKeyword() && isVisualKind();
}
bool TextTrack::canBeRendered() const
{
// A track can be displayed when it's of kind captions or subtitles and hasn't failed to load.
- if (kind() != captionsKeyword() && kind() != subtitlesKeyword())
- return false;
-
- if (getReadinessState() == FailedToLoad)
- return false;
-
- return true;
+ return getReadinessState() != FailedToLoad && isVisualKind();
}
TextTrackCueList* TextTrack::ensureTextTrackCueList()
« no previous file with comments | « third_party/WebKit/Source/core/html/track/TextTrack.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698