Source/WebCore: The main code structure for placing future text track cue rendering
code and main outer rendering steps.
https://bugs.webkit.org/show_bug.cgi?id=79746

Patch by Victor Carbune <[email protected]> on 2012-03-11
Reviewed by Eric Carlson.

No new tests. Only refactoring, but some chromium tests require rebaselining
and have been marked accordingly.

* css/mediaControls.css:
(::-webkit-media-controls): Changed the default display to -webkit-box, as
captions need to always be rendered on top of the controls, if they are visible.
(audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel):
Default position attribute is now relative, handled by the parent -webkit-box
(video::-webkit-media-text-track-container): The position of the container is
now relative, handled by -webkit-box.
(video::-webkit-media-text-track-display): Adjusted text color to match
the color required in the WebVTT spec (section 3.5.1 'color' property)
* css/mediaControlsChromium.css:
(audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel):
Default position attribute is now relative, handled by the parent -webkit-box

* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlPanelElement::MediaControlPanelElement): Added a timer
for the webkit fade out transition event. This timer is required for setting
the display property to 'none', when the fade out transition is over. Otherwise,
captions would not be displayed at the bottom of the video.
(WebCore::MediaControlPanelElement::startTimer): Added.
(WebCore):
(WebCore::MediaControlPanelElement::stopTimer): Added.
(WebCore::MediaControlPanelElement::transitionTimerFired): Added. If the current
state of the controls is transparent, the display property is set to 'none'.
(WebCore::MediaControlPanelElement::makeOpaque): The inline display:'none' property
is removed before the fade in transition.
(WebCore::MediaControlPanelElement::makeTransparent): Added the timer start.
(WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement):
Removed m_bottom as it is not needed anymore.
(WebCore::MediaControlTextTrackContainerElement::updateDisplay): Added. Main
function for the rendering rules.
(WebCore::MediaControlTextTrackContainerElement::updateSizes): The bottom position
needs not to be set anymore.
* html/shadow/MediaControlElements.h:
(MediaControlPanelElement): Added timer internals.
(MediaControlTextTrackContainerElement): Added updateDisplay() and removed unused
variables.

(WebCore):
* html/shadow/MediaControlRootElement.cpp: Removed m_textTrackDisplay
and duplicated code with MediaControlRootElementChromium (only minimum
function calls to the main text track container)
(WebCore::MediaControlRootElement::MediaControlRootElement):
(WebCore::MediaControlRootElement::setMediaController):
(WebCore::MediaControlRootElement::createTextTrackDisplay):
(WebCore::MediaControlRootElement::updateTextTrackDisplay):

* html/shadow/MediaControlRootElementChromium.cpp: Removed m_textTrackDisplay
and duplicate code with MediaControlRootElement (only minimum function calls
to the main text track container remained)
(WebCore::MediaControlRootElementChromium::MediaControlRootElementChromium):
(WebCore::MediaControlRootElementChromium::setMediaController):
(WebCore::MediaControlRootElementChromium::createTextTrackDisplay):
(WebCore::MediaControlRootElementChromium::updateTextTrackDisplay):

(WebCore):
* html/track/TextTrackCue.cpp: Enhanced structure for supporting more complex
rendering required by the WebVTT spec.
(WebCore::TextTrackCue::TextTrackCue):
(WebCore::TextTrackCue::cueDidChange): Mark the display tree as obsolete, so that
it needs to be re-computed.
(WebCore::TextTrackCue::setIsActive): The display tree needs to be removed as
soon as the cue becomes inactive. Adjusted this method to support the functionality.
(WebCore):
(WebCore::TextTrackCue::determineDisplayParameters): Added. This method will hold
main positioning parameter computations for a TextTrackCue
(WebCore):
(WebCore::TextTrackCue::getDisplayTree): Added. This method returns the root node
of the CSS boxes that need to be displayed on top of the video, for the current
instance.
* html/track/TextTrackCue.h:
(WebCore):
(TextTrackCue):

LayoutTests: Updated layout tests for basic rendering of cues.
Some Chromium tests require rebaselining and have been marked accordingly.

https://bugs.webkit.org/show_bug.cgi?id=79746

Patch by Victor Carbune <[email protected]> on 2012-03-11
Reviewed by Eric Carlson.

* media/media-controls.js: Adjusted helper function.
(mediaControlsElement):
(textTrackDisplayElement): If the method is called with only
one parameter, it returns the text track container instead of
a specific cue.
* media/track/track-cue-mutable-text-expected.txt: Adjusted.
* media/track/track-cue-nothing-to-render-expected.txt: Adjusted.
* media/track/track-cue-rendering-expected.txt: Adjusted.
* media/track/track-cue-rendering.html: Adjusted.
* platform/chromium/test_expectations.txt: Marked tests that need to
be rebaselined accordingly.

git-svn-id: svn://svn.chromium.org/blink/trunk@110409 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/third_party/WebKit/LayoutTests/media/media-controls.js b/third_party/WebKit/LayoutTests/media/media-controls.js
index 4487d18..e4449d9 100644
--- a/third_party/WebKit/LayoutTests/media/media-controls.js
+++ b/third_party/WebKit/LayoutTests/media/media-controls.js
@@ -2,7 +2,6 @@
 function mediaControlsElement(first, id)
 {
     for (var element = first; element; element = element.nextSibling) {
-
         // Not every element in the media controls has a shadow pseudo ID, eg. the
         // text nodes for the time values, so guard against exceptions.
         try {
@@ -35,9 +34,20 @@
 
 function textTrackDisplayElement(parentElement, id)
 {
-    var controlID = "-webkit-media-text-track-" + id;
-    var displayElement = mediaControlsElement(internals.shadowRoot(parentElement).firstChild, controlID);
+    var textTrackContainerID = "-webkit-media-text-track-container";
+    var containerElement = mediaControlsElement(internals.shadowRoot(parentElement).firstChild, "-webkit-media-text-track-container");
+
+    if (!containerElement)
+        throw "Failed to find text track container element";
+
+    if (!id)
+        return containerElement;
+
+    var controlID = "-webkit-media-text-track-" + arguments[1];
+
+    var displayElement = mediaControlsElement(containerElement.firstChild, controlID);
     if (!displayElement)
-        throw "Failed to find media control element ID '" + controlID + "'";
+        throw "No text track cue with display id '" + controlID + "' is currently visible";
+
     return displayElement;
-}
\ No newline at end of file
+}