- Revision
- 141531
- Author
- vcarb...@chromium.org
- Date
- 2013-01-31 20:03:04 -0800 (Thu, 31 Jan 2013)
Log Message
[Track] Closed Caption button shouldn't be visible if all the track resources have failed loading
https://bugs.webkit.org/show_bug.cgi?id=106285
Reviewed by Eric Carlson.
Source/WebCore:
Updated existing test cases.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::textTracksAreReady): Checked whether there are tracks not loaded
when the algorithm began.
(WebCore::HTMLMediaElement::textTrackReadyStateChanged): If the ready state changed to
FailedToLoad the media controls should check whether there are other caption tracks
and hide the button if not.
(WebCore::HTMLMediaElement::didAddTrack): Added trigger to closedCaptionsTrackChanged.
(WebCore::HTMLMediaElement::hasClosedCaptions): Updated check to skip tracks that
failed to load.
* html/shadow/MediaControls.cpp:
(WebCore::MediaControls::reset): Used the newly added method.
(WebCore::MediaControls::refreshClosedCaptionsButtonVisibility): Added container method for
default behaviour for refreshing the visibility of the caption button.
(WebCore::MediaControls::closedCaptionTracksChanged): Used the newly added method.
(WebCore):
* html/shadow/MediaControls.h:
(MediaControls):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::textTracksAreReady):
(WebCore::HTMLMediaElement::textTrackReadyStateChanged):
(WebCore::HTMLMediaElement::setReadyState):
(WebCore::HTMLMediaElement::didAddTrack):
(WebCore::HTMLMediaElement::hasClosedCaptions):
* html/shadow/MediaControls.cpp:
(WebCore::MediaControls::reset):
(WebCore::MediaControls::refreshClosedCaptionsButtonVisibility):
(WebCore::MediaControls::closedCaptionTracksChanged):
(WebCore):
* html/shadow/MediaControls.h:
(MediaControls):
LayoutTests:
Updated tests to include improved behavior.
* media/video-controls-captions-expected.txt: Updated.
* media/video-controls-captions.html: Updated.
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (141530 => 141531)
--- trunk/LayoutTests/ChangeLog 2013-02-01 04:01:57 UTC (rev 141530)
+++ trunk/LayoutTests/ChangeLog 2013-02-01 04:03:04 UTC (rev 141531)
@@ -1,3 +1,15 @@
+2013-01-31 Victor Carbune <vcarb...@chromium.org>
+
+ [Track] Closed Caption button shouldn't be visible if all the track resources have failed loading
+ https://bugs.webkit.org/show_bug.cgi?id=106285
+
+ Reviewed by Eric Carlson.
+
+ Updated tests to include improved behavior.
+
+ * media/video-controls-captions-expected.txt: Updated.
+ * media/video-controls-captions.html: Updated.
+
2013-01-31 Dima Gorbik <dgor...@apple.com>
REGRESSION(r140231): media track layout tests crashing
Modified: trunk/LayoutTests/media/video-controls-captions-expected.txt (141530 => 141531)
--- trunk/LayoutTests/media/video-controls-captions-expected.txt 2013-02-01 04:01:57 UTC (rev 141530)
+++ trunk/LayoutTests/media/video-controls-captions-expected.txt 2013-02-01 04:03:04 UTC (rev 141531)
@@ -28,6 +28,23 @@
EXPECTED (captionsButtonCoordinates[0] <= '0') OK
EXPECTED (captionsButtonCoordinates[1] <= '0') OK
+** Add non-default text track through HTML with unloadable URI **
+EXPECTED (track.readyState == '0') OK
+EXPECTED (track.track.mode == 'disabled') OK
+EXPECTED (video.textTracks.length == '1') OK
+
+** Caption button should be visible and enabled because we have a captions track.
+EXPECTED (captionsButtonCoordinates[0] > '0') OK
+EXPECTED (captionsButtonCoordinates[1] > '0') OK
+EXPECTED (captionsButtonElement.disabled == 'false') OK
+
+*** Click the CC button.
+** Track failed to load **
+
+** Caption button should not be visible as there are no caption tracks.
+EXPECTED (captionsButtonCoordinates[0] <= '0') OK
+EXPECTED (captionsButtonCoordinates[1] <= '0') OK
+
** Add a text track through JS to the video element **
** Caption button should be visible and enabled because we have a captions track.
Modified: trunk/LayoutTests/media/video-controls-captions.html (141530 => 141531)
--- trunk/LayoutTests/media/video-controls-captions.html 2013-02-01 04:01:57 UTC (rev 141530)
+++ trunk/LayoutTests/media/video-controls-captions.html 2013-02-01 04:03:04 UTC (rev 141531)
@@ -9,6 +9,7 @@
<script>
var captionsButtonElement;
var captionsButtonCoordinates;
+ var track;
function addTextTrackThroughJS()
{
@@ -18,6 +19,24 @@
t.addCue(new TextTrackCue(0.0, 10.0, 'Some random caption text'));
}
+ function addUnloadableHTMLTrackElement()
+ {
+ consoleWrite("");
+ consoleWrite("** Add non-default text track through HTML with unloadable URI **");
+
+ track = document.createElement("track");
+ track.setAttribute("kind", "captions");
+ track.setAttribute("srclang", "en");
+ track.setAttribute("src", "invalid.vtt");
+
+ track.addEventListener("error", trackError);
+
+ video.appendChild(track);
+ testExpected("track.readyState", HTMLTrackElement.NONE);
+ testExpected("track.track.mode", "disabled");
+ testExpected("video.textTracks.length", 1);
+ }
+
function removeHTMLTrackElement()
{
consoleWrite("");
@@ -100,12 +119,25 @@
removeHTMLTrackElement();
testClosedCaptionsButtonVisibility(false);
+ addUnloadableHTMLTrackElement();
+ testClosedCaptionsButtonVisibility(true);
+
+ consoleWrite("");
+ clickCCButton();
+ }
+
+ function trackError()
+ {
+ consoleWrite("** Track failed to load **");
+ testClosedCaptionsButtonVisibility(false);
+
addTextTrackThroughJS();
testClosedCaptionsButtonVisibility(true);
endTest();
}
+
function loaded()
{
findMediaElement();
Modified: trunk/Source/WebCore/ChangeLog (141530 => 141531)
--- trunk/Source/WebCore/ChangeLog 2013-02-01 04:01:57 UTC (rev 141530)
+++ trunk/Source/WebCore/ChangeLog 2013-02-01 04:03:04 UTC (rev 141531)
@@ -1,3 +1,44 @@
+2013-01-31 Victor Carbune <vcarb...@chromium.org>
+
+ [Track] Closed Caption button shouldn't be visible if all the track resources have failed loading
+ https://bugs.webkit.org/show_bug.cgi?id=106285
+
+ Reviewed by Eric Carlson.
+
+ Updated existing test cases.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::textTracksAreReady): Checked whether there are tracks not loaded
+ when the algorithm began.
+ (WebCore::HTMLMediaElement::textTrackReadyStateChanged): If the ready state changed to
+ FailedToLoad the media controls should check whether there are other caption tracks
+ and hide the button if not.
+ (WebCore::HTMLMediaElement::didAddTrack): Added trigger to closedCaptionsTrackChanged.
+ (WebCore::HTMLMediaElement::hasClosedCaptions): Updated check to skip tracks that
+ failed to load.
+ * html/shadow/MediaControls.cpp:
+ (WebCore::MediaControls::reset): Used the newly added method.
+ (WebCore::MediaControls::refreshClosedCaptionsButtonVisibility): Added container method for
+ default behaviour for refreshing the visibility of the caption button.
+ (WebCore::MediaControls::closedCaptionTracksChanged): Used the newly added method.
+ (WebCore):
+ * html/shadow/MediaControls.h:
+ (MediaControls):
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::textTracksAreReady):
+ (WebCore::HTMLMediaElement::textTrackReadyStateChanged):
+ (WebCore::HTMLMediaElement::setReadyState):
+ (WebCore::HTMLMediaElement::didAddTrack):
+ (WebCore::HTMLMediaElement::hasClosedCaptions):
+ * html/shadow/MediaControls.cpp:
+ (WebCore::MediaControls::reset):
+ (WebCore::MediaControls::refreshClosedCaptionsButtonVisibility):
+ (WebCore::MediaControls::closedCaptionTracksChanged):
+ (WebCore):
+ * html/shadow/MediaControls.h:
+ (MediaControls):
+
2013-01-31 Dima Gorbik <dgor...@apple.com>
REGRESSION(r140231): media track layout tests crashing
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (141530 => 141531)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-02-01 04:01:57 UTC (rev 141530)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-02-01 04:03:04 UTC (rev 141531)
@@ -1331,7 +1331,8 @@
// in the disabled state when the element's resource selection algorithm last started now
// have a text track readiness state of loaded or failed to load.
for (unsigned i = 0; i < m_textTracksWhenResourceSelectionBegan.size(); ++i) {
- if (m_textTracksWhenResourceSelectionBegan[i]->readinessState() == TextTrack::Loading)
+ if (m_textTracksWhenResourceSelectionBegan[i]->readinessState() == TextTrack::Loading
+ || m_textTracksWhenResourceSelectionBegan[i]->readinessState() == TextTrack::NotLoaded)
return false;
}
@@ -1343,6 +1344,12 @@
if (m_player && m_textTracksWhenResourceSelectionBegan.contains(track)) {
if (track->readinessState() != TextTrack::Loading)
setReadyState(m_player->readyState());
+ } else {
+ // The track readiness state might have changed as a result of the user
+ // clicking the captions button. In this case, a check whether all the
+ // resources have failed loading should be done in order to hide the CC button.
+ if (hasMediaControls() && track->readinessState() == TextTrack::FailedToLoad)
+ mediaControls()->refreshClosedCaptionsButtonVisibility();
}
}
@@ -1841,8 +1848,10 @@
if (shouldUpdateDisplayState) {
updateDisplayState();
- if (hasMediaControls())
+ if (hasMediaControls()) {
+ mediaControls()->refreshClosedCaptionsButtonVisibility();
mediaControls()->updateStatusDisplay();
+ }
}
updatePlayState();
@@ -2901,6 +2910,9 @@
// in the markup have been added.
if (!m_parsingInProgress)
scheduleLoad(TextTrackResource);
+
+ if (hasMediaControls())
+ mediaControls()->closedCaptionTracksChanged();
}
void HTMLMediaElement::didRemoveTrack(HTMLTrackElement* trackElement)
@@ -4126,6 +4138,9 @@
#if ENABLE(VIDEO_TRACK)
if (RuntimeEnabledFeatures::webkitVideoTrackEnabled() && m_textTracks)
for (unsigned i = 0; i < m_textTracks->length(); ++i) {
+ if (m_textTracks->item(i)->readinessState() == TextTrack::FailedToLoad)
+ continue;
+
if (m_textTracks->item(i)->kind() == TextTrack::captionsKeyword()
|| m_textTracks->item(i)->kind() == TextTrack::subtitlesKeyword())
return true;
Modified: trunk/Source/WebCore/html/shadow/MediaControls.cpp (141530 => 141531)
--- trunk/Source/WebCore/html/shadow/MediaControls.cpp 2013-02-01 04:01:57 UTC (rev 141530)
+++ trunk/Source/WebCore/html/shadow/MediaControls.cpp 2013-02-01 04:03:04 UTC (rev 141531)
@@ -109,12 +109,7 @@
}
}
- if (m_toggleClosedCaptionsButton) {
- if (m_mediaController->hasClosedCaptions())
- m_toggleClosedCaptionsButton->show();
- else
- m_toggleClosedCaptionsButton->hide();
- }
+ refreshClosedCaptionsButtonVisibility();
if (m_fullScreenButton) {
if (m_mediaController->supportsFullscreen() && m_mediaController->hasVideo())
@@ -252,7 +247,7 @@
m_toggleClosedCaptionsButton->updateDisplayType();
}
-void MediaControls::closedCaptionTracksChanged()
+void MediaControls::refreshClosedCaptionsButtonVisibility()
{
if (!m_toggleClosedCaptionsButton)
return;
@@ -263,6 +258,11 @@
m_toggleClosedCaptionsButton->hide();
}
+void MediaControls::closedCaptionTracksChanged()
+{
+ refreshClosedCaptionsButtonVisibility();
+}
+
void MediaControls::enteredFullscreen()
{
m_isFullscreen = true;
Modified: trunk/Source/WebCore/html/shadow/MediaControls.h (141530 => 141531)
--- trunk/Source/WebCore/html/shadow/MediaControls.h 2013-02-01 04:01:57 UTC (rev 141530)
+++ trunk/Source/WebCore/html/shadow/MediaControls.h 2013-02-01 04:03:04 UTC (rev 141531)
@@ -88,6 +88,7 @@
virtual void changedVolume();
virtual void changedClosedCaptionsVisibility();
+ virtual void refreshClosedCaptionsButtonVisibility();
virtual void toggleClosedCaptionTrackList() { }
virtual void closedCaptionTracksChanged();