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/ChangeLog b/third_party/WebKit/LayoutTests/ChangeLog
index 75092d83..2808070 100644
--- a/third_party/WebKit/LayoutTests/ChangeLog
+++ b/third_party/WebKit/LayoutTests/ChangeLog
@@ -1,3 +1,24 @@
+2012-03-11 Victor Carbune <[email protected]>
+
+ 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
+
+ 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.
+
2012-03-11 Noel Gordon <[email protected]>
Unreviewed gardening. Rebaseline svg/text/foreignObject-repaint.xml to close
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
+}
diff --git a/third_party/WebKit/LayoutTests/media/track/track-cue-mutable-text-expected.txt b/third_party/WebKit/LayoutTests/media/track/track-cue-mutable-text-expected.txt
index cea90a0..895ff05a 100644
--- a/third_party/WebKit/LayoutTests/media/track/track-cue-mutable-text-expected.txt
+++ b/third_party/WebKit/LayoutTests/media/track/track-cue-mutable-text-expected.txt
@@ -3,7 +3,7 @@
** Test initial cue info
EXPECTED (testTrack.track.activeCues.length == '0') OK
-EXPECTED (textTrackDisplayElement(video, 'display').innerText == '') OK
+No text track cue with display id '-webkit-media-text-track-display' is currently visible
EXPECTED (testTrack.track.cues[0].startTime == '1') OK
EXPECTED (testTrack.track.cues[1].startTime == '3') OK
EXPECTED (testTrack.track.cues[0].text == 'Lorem ipsum dolor sit amet,') OK
diff --git a/third_party/WebKit/LayoutTests/media/track/track-cue-nothing-to-render-expected.txt b/third_party/WebKit/LayoutTests/media/track/track-cue-nothing-to-render-expected.txt
index f6a5f88..2e8a789b 100644
--- a/third_party/WebKit/LayoutTests/media/track/track-cue-nothing-to-render-expected.txt
+++ b/third_party/WebKit/LayoutTests/media/track/track-cue-nothing-to-render-expected.txt
@@ -3,7 +3,7 @@
EVENT(canplaythrough)
EVENT(seeked)
EXPECTED (video.currentTime.toFixed(1) == '0.5') OK
-EXPECTED (textTrackDisplayElement(video, 'display').innerText == '') OK
+No text track cue with display id '-webkit-media-text-track-display' is currently visible
RUN(video.currentTime = 1.5)
EVENT(seeked)
@@ -14,7 +14,7 @@
RUN(video.currentTime = 2.5)
EVENT(seeked)
EXPECTED (video.currentTime.toFixed(1) == '2.5') OK
-EXPECTED (textTrackDisplayElement(video, 'display').innerText == '') OK
+No text track cue with display id '-webkit-media-text-track-display' is currently visible
RUN(video.currentTime = 3.3)
EVENT(seeked)
@@ -25,7 +25,7 @@
RUN(video.currentTime = 0.6)
EVENT(seeked)
EXPECTED (video.currentTime.toFixed(1) == '0.6') OK
-EXPECTED (textTrackDisplayElement(video, 'display').innerText == '') OK
+No text track cue with display id '-webkit-media-text-track-display' is currently visible
RUN(video.currentTime = 5.9)
EVENT(seeked)
@@ -36,7 +36,7 @@
RUN(video.currentTime = 4.4)
EVENT(seeked)
EXPECTED (video.currentTime.toFixed(1) == '4.4') OK
-EXPECTED (textTrackDisplayElement(video, 'display').innerText == '') OK
+No text track cue with display id '-webkit-media-text-track-display' is currently visible
RUN(video.currentTime = 7.9)
EVENT(seeked)
diff --git a/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-expected.txt b/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-expected.txt
index 1f2cedf..03d049a 100644
--- a/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-expected.txt
+++ b/third_party/WebKit/LayoutTests/media/track/track-cue-rendering-expected.txt
@@ -30,22 +30,22 @@
Test the cue display colors and font.
RUN(video.width = 320)
RUN(video.height = 240)
-EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'container')).fontSize == '12px') OK
+EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontSize == '12px') OK
RUN(video.width = 640)
RUN(video.height = 480)
-EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'container')).fontSize == '24px') OK
+EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontSize == '24px') OK
RUN(video.width = 1280)
RUN(video.height = 960)
-EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'container')).fontSize == '48px') OK
+EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontSize == '48px') OK
RUN(video.width = 2560)
RUN(video.height = 1440)
-EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'container')).fontSize == '72px') OK
+EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontSize == '72px') OK
-EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'container')).fontFamily == 'sans-serif') OK
-EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'container')).color == 'rgba(255, 255, 255, 0)') OK
+EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontFamily == 'sans-serif') OK
+EXPECTED (getComputedStyle(textTrackDisplayElement(video)).color == 'rgba(255, 255, 255, 0)') OK
EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'display')).backgroundColor == 'rgba(0, 0, 0, 0.796875)') OK
END OF TEST
diff --git a/third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html b/third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html
index 69a09cf..c17b717 100644
--- a/third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html
+++ b/third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html
@@ -18,7 +18,7 @@
run("video.width = " + width);
run("video.height = " + height);
document.body.offsetTop;
- testExpected("getComputedStyle(textTrackDisplayElement(video, 'container')).fontSize", parseInt(height * 0.05) + "px");
+ testExpected("getComputedStyle(textTrackDisplayElement(video)).fontSize", parseInt(height * 0.05) + "px");
consoleWrite("");
}
@@ -30,8 +30,8 @@
testFontSize(1280, 960);
testFontSize(2560, 1440);
- testExpected("getComputedStyle(textTrackDisplayElement(video, 'container')).fontFamily", "sans-serif");
- testExpected("getComputedStyle(textTrackDisplayElement(video, 'container')).color", "rgba(255, 255, 255, 0)");
+ testExpected("getComputedStyle(textTrackDisplayElement(video)).fontFamily", "sans-serif");
+ testExpected("getComputedStyle(textTrackDisplayElement(video)).color", "rgba(255, 255, 255, 0)");
testExpected("getComputedStyle(textTrackDisplayElement(video, 'display')).backgroundColor", "rgba(0, 0, 0, 0.796875)");
endTest();
diff --git a/third_party/WebKit/LayoutTests/platform/chromium/test_expectations.txt b/third_party/WebKit/LayoutTests/platform/chromium/test_expectations.txt
index ad0b988..8ba6608 100644
--- a/third_party/WebKit/LayoutTests/platform/chromium/test_expectations.txt
+++ b/third_party/WebKit/LayoutTests/platform/chromium/test_expectations.txt
@@ -3412,6 +3412,32 @@
BUGWK73865 : media/track/text-track-cue-is-reachable.html = TEXT CRASH
BUGWK73865 : media/track/text-track-is-reachable.html = TEXT CRASH
+// Need rebaselining
+BUGWK79746 : media/media-document-audio-repaint.html = IMAGE+TEXT
+BUGWK79746 : media/video-no-audio.html = IMAGE+TEXT
+BUGWK79746 : media/controls-strict.html = IMAGE+TEXT
+BUGWK79746 : media/video-volume-slider.html = IMAGE+TEXT
+BUGWK79746 : media/controls-styling.html = IMAGE+TEXT
+BUGWK79746 : media/video-display-toggle.html = IMAGE+TEXT
+BUGWK79746 : media/audio-controls-rendering.html = IMAGE+TEXT
+BUGWK79746 : media/video-zoom-controls.html = IMAGE+TEXT
+BUGWK79746 : media/video-controls-rendering.html = IMAGE+TEXT
+BUGWK79746 : media/controls-without-preload.html = IMAGE+TEXT
+BUGWK79746 : media/media-controls-clone.html = IMAGE+TEXT
+BUGWK79746 : fast/layers/video-layer.html = IMAGE+TEXT
+BUGWK79746 : media/video-empty-source.html = IMAGE+TEXT
+BUGWK79746 : media/video-playing-and-pause.html = IMAGE+TEXT
+BUGWK79746 : media/controls-after-reload.html = IMAGE+TEXT
+BUGWK79746 : media/audio-repaint.html = IMAGE+TEXT
+BUGWK79746 : media/controls-layout-direction.html = IMAGE
+BUGWK79746 : media/video-aspect-ratio.html = IMAGE
+BUGWK79746 : media/video-colorspace-yuv420.html = IMAGE
+BUGWK79746 : media/video-colorspace-yuv422.html = IMAGE
+BUGWK79746 : media/video-frame-accurate-seek.html = IMAGE
+BUGWK79746 : media/video-layer-crash.html = IMAGE
+BUGWK79746 : media/video-transformed.html = IMAGE
+BUGWK79746 : media/video-zoom.html = IMAGE
+
BUGWK72271 MAC DEBUG : fast/loader/javascript-url-in-embed.html = PASS CRASH
BUGWK72271 SNOWLEOPARD DEBUG : fast/dom/node-iterator-reference-node-moved-crash.html = PASS CRASH
@@ -3691,9 +3717,6 @@
BUGCR114777 : compositing/culling/filter-occlusion-blur-large.html = PASS IMAGE
BUGCR114777 : compositing/culling/filter-occlusion-blur.html = PASS IMAGE
-// Needs rebaseline
-BUGWK78878 : media/audio-repaint.html = IMAGE
-
// Needs new baselines.
BUGWK65072 : svg/text/exs-display-none.svg = IMAGE IMAGE+TEXT
BUGWK65072 : svg/text/ems-display-none.svg = IMAGE IMAGE+TEXT
diff --git a/third_party/WebKit/Source/WebCore/ChangeLog b/third_party/WebKit/Source/WebCore/ChangeLog
index 6bc51f42..8d7dea4 100644
--- a/third_party/WebKit/Source/WebCore/ChangeLog
+++ b/third_party/WebKit/Source/WebCore/ChangeLog
@@ -1,3 +1,87 @@
+2012-03-11 Victor Carbune <[email protected]>
+
+ 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
+
+ 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):
+
2012-03-11 Sheriff Bot <[email protected]>
Unreviewed, rolling out r110359.
diff --git a/third_party/WebKit/Source/WebCore/css/mediaControls.css b/third_party/WebKit/Source/WebCore/css/mediaControls.css
index 31c9d43..b81332fc 100644
--- a/third_party/WebKit/Source/WebCore/css/mediaControls.css
+++ b/third_party/WebKit/Source/WebCore/css/mediaControls.css
@@ -37,8 +37,11 @@
width: inherit;
height: inherit;
position: relative;
- display: block;
+ display: -webkit-box;
direction: ltr;
+ -webkit-box-align: start;
+ -webkit-box-pack: end;
+ -webkit-box-orient: vertical;
}
audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel {
@@ -46,7 +49,7 @@
-webkit-box-orient: horizontal;
-webkit-box-align: center;
-webkit-user-select: none;
- position: absolute;
+ position: relative;
bottom: 0;
width: 100%;
z-index: 0;
@@ -201,15 +204,16 @@
}
video::-webkit-media-text-track-container {
- position: absolute;
+ position: relative;
width: 100%;
overflow: hidden;
+ padding-bottom: 5px;
font-size: 22px;
font-family: sans-serif;
text-align: center;
color: rgba(255, 255, 255, 0);
-
+
letter-spacing: normal;
word-spacing: normal;
text-transform: none;
@@ -222,6 +226,6 @@
video::-webkit-media-text-track-display {
display: inline;
background-color: rgba(0, 0, 0, 0.8);
- color: yellow;
+ color: rgba(255, 255, 255, 1);
padding: 0px 2px;
}
diff --git a/third_party/WebKit/Source/WebCore/css/mediaControlsChromium.css b/third_party/WebKit/Source/WebCore/css/mediaControlsChromium.css
index 508d744..5fb62cc3 100644
--- a/third_party/WebKit/Source/WebCore/css/mediaControlsChromium.css
+++ b/third_party/WebKit/Source/WebCore/css/mediaControlsChromium.css
@@ -41,7 +41,7 @@
audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel {
-webkit-user-select: none;
- position: absolute;
+ position: relative;
overflow: visible;
bottom: 0;
width: 100%;
diff --git a/third_party/WebKit/Source/WebCore/html/shadow/MediaControlElements.cpp b/third_party/WebKit/Source/WebCore/html/shadow/MediaControlElements.cpp
index 8ca66a4..011adff7 100644
--- a/third_party/WebKit/Source/WebCore/html/shadow/MediaControlElements.cpp
+++ b/third_party/WebKit/Source/WebCore/html/shadow/MediaControlElements.cpp
@@ -40,6 +40,7 @@
#include "Frame.h"
#include "HTMLMediaElement.h"
#include "HTMLNames.h"
+#include "HTMLVideoElement.h"
#include "LocalizedStrings.h"
#include "MediaControls.h"
#include "MouseEvent.h"
@@ -52,6 +53,7 @@
#include "RenderView.h"
#include "ScriptController.h"
#include "Settings.h"
+#include "Text.h"
namespace WebCore {
@@ -107,6 +109,7 @@
, m_canBeDragged(false)
, m_isBeingDragged(false)
, m_opaque(true)
+ , m_transitionTimer(this, &MediaControlPanelElement::transitionTimerFired)
{
}
@@ -173,6 +176,32 @@
frame->eventHandler()->setCapturingMouseEventsNode(0);
}
+void MediaControlPanelElement::startTimer()
+{
+ stopTimer();
+
+ // The timer is required to set the property display:'none' on the panel,
+ // such that captions are correctly displayed at the bottom of the video
+ // at the end of the fadeout transition.
+ double duration = document()->page() ? document()->page()->theme()->mediaControlsFadeOutDuration() : 0;
+ m_transitionTimer.startOneShot(duration);
+}
+
+void MediaControlPanelElement::stopTimer()
+{
+ if (m_transitionTimer.isActive())
+ m_transitionTimer.stop();
+}
+
+
+void MediaControlPanelElement::transitionTimerFired(Timer<MediaControlPanelElement>*)
+{
+ if (!m_opaque)
+ hide();
+
+ stopTimer();
+}
+
void MediaControlPanelElement::setPosition(const LayoutPoint& position)
{
double left = position.x();
@@ -212,6 +241,8 @@
setInlineStyleProperty(CSSPropertyOpacity, 1.0, CSSPrimitiveValue::CSS_NUMBER);
m_opaque = true;
+
+ show();
}
void MediaControlPanelElement::makeTransparent()
@@ -224,6 +255,8 @@
setInlineStyleProperty(CSSPropertyOpacity, 0.0, CSSPrimitiveValue::CSS_NUMBER);
m_opaque = false;
+
+ startTimer();
}
void MediaControlPanelElement::defaultEventHandler(Event* event)
@@ -1165,7 +1198,6 @@
inline MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement(Document* document)
: MediaControlElement(document)
, m_fontSize(0)
- , m_bottom(0)
{
}
@@ -1187,16 +1219,89 @@
return id;
}
+void MediaControlTextTrackContainerElement::updateDisplay()
+{
+ HTMLMediaElement* mediaElement = toParentMediaElement(this);
+
+ // 1. If the media element is an audio element, or is another playback
+ // mechanism with no rendering area, abort these steps. There is nothing to
+ // render.
+ if (!mediaElement->isVideo())
+ return;
+
+ // 2. Let video be the media element or other playback mechanism.
+ HTMLVideoElement* video = static_cast<HTMLVideoElement*>(mediaElement);
+
+ // 3. Let output be an empty list of absolutely positioned CSS block boxes.
+ Vector<RefPtr<HTMLDivElement> > output;
+
+ // 4. If the user agent is exposing a user interface for video, add to
+ // output one or more completely transparent positioned CSS block boxes that
+ // cover the same region as the user interface.
+
+ // 5. If the last time these rules were run, the user agent was not exposing
+ // a user interface for video, but now it is, let reset be true. Otherwise,
+ // let reset be false.
+
+ // There is nothing to be done explicitly for 4th and 5th steps, as
+ // everything is handled through CSS. The caption box is on top of the
+ // controls box, in a container set with the -webkit-box display property.
+
+ // 6. Let tracks be the subset of video's list of text tracks that have as
+ // their rules for updating the text track rendering these rules for
+ // updating the display of WebVTT text tracks, and whose text track mode is
+ // showing or showing by default.
+ // 7. Let cues be an empty list of text track cues.
+ // 8. For each track track in tracks, append to cues all the cues from
+ // track's list of cues that have their text track cue active flag set.
+ CueList activeCues = video->currentlyActiveCues();
+
+ // 9. If reset is false, then, for each text track cue cue in cues: if cue's
+ // text track cue display state has a set of CSS boxes, then add those boxes
+ // to output, and remove cue from cues.
+
+ // There is nothing explicitly to be done here, as all the caching occurs
+ // within the TextTrackCue instance itself. If parameters of the cue change,
+ // the display tree is cleared.
+
+ // 10. For each text track cue cue in cues that has not yet had
+ // corresponding CSS boxes added to output, in text track cue order, run the
+ // following substeps:
+
+ // Simple renderer for now.
+ for (size_t i = 0; i < activeCues.size(); ++i) {
+ TextTrackCue* cue = activeCues[i].data();
+
+ ASSERT(cue->isActive());
+ if (!cue->track() || cue->track()->mode() != TextTrack::SHOWING)
+ continue;
+
+ RefPtr<HTMLDivElement> displayTree = cue->getDisplayTree();
+
+ // Append only new display trees.
+ if (displayTree->hasChildNodes() && !contains(displayTree.get()))
+ appendChild(displayTree, ASSERT_NO_EXCEPTION, true);
+
+ // The display tree of a cue is removed when the active flag of the cue is unset.
+
+ // FIXME(BUG 79750): Render the TextTrackCue when snap-to-lines is set.
+ // FIXME(BUG 79751): Render the TextTrackCue when snap-to-lines is not set.
+ }
+
+ // 11. Return output.
+ hasChildNodes() ? show() : hide();
+}
+
static const float mimimumFontSize = 16;
static const float videoHeightFontSizePercentage = .05;
static const float trackBottomMultiplier = .9;
-
+
void MediaControlTextTrackContainerElement::updateSizes()
{
HTMLMediaElement* mediaElement = toParentMediaElement(this);
if (!mediaElement || !mediaElement->renderer() || !mediaElement->renderer()->isVideo())
return;
-
+
IntRect videoBox = toRenderVideo(mediaElement->renderer())->videoBox();
if (m_videoDisplaySize == videoBox)
return;
@@ -1207,33 +1312,9 @@
m_fontSize = fontSize;
setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
}
-
- LayoutUnit bottom = static_cast<LayoutUnit>(m_videoDisplaySize.y() + m_videoDisplaySize.height() - (m_videoDisplaySize.height() * trackBottomMultiplier));
- if (bottom != m_bottom) {
- m_bottom = bottom;
- setInlineStyleProperty(CSSPropertyBottom, String::number(roundToInt(bottom)) + "px");
- }
}
-// ----------------------------
-
-MediaControlTextTrackDisplayElement::MediaControlTextTrackDisplayElement(Document* document)
- : MediaControlElement(document)
-{
-}
-
-PassRefPtr<MediaControlTextTrackDisplayElement> MediaControlTextTrackDisplayElement::create(Document* document)
-{
- return adoptRef(new MediaControlTextTrackDisplayElement(document));
-}
-
-const AtomicString& MediaControlTextTrackDisplayElement::shadowPseudoId() const
-{
- DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-text-track-display"));
- return id;
-}
-
-#endif
+#endif // ENABLE(VIDEO_TRACK)
// ----------------------------
diff --git a/third_party/WebKit/Source/WebCore/html/shadow/MediaControlElements.h b/third_party/WebKit/Source/WebCore/html/shadow/MediaControlElements.h
index 52055a4..dce26c1 100644
--- a/third_party/WebKit/Source/WebCore/html/shadow/MediaControlElements.h
+++ b/third_party/WebKit/Source/WebCore/html/shadow/MediaControlElements.h
@@ -122,6 +122,10 @@
void continueDrag(const LayoutPoint& eventLocation);
void endDrag();
+ void startTimer();
+ void stopTimer();
+ void transitionTimerFired(Timer<MediaControlPanelElement>*);
+
void setPosition(const LayoutPoint&);
bool m_canBeDragged;
@@ -129,6 +133,8 @@
bool m_opaque;
LayoutPoint m_dragStartPosition;
LayoutPoint m_dragStartEventLocation;
+
+ Timer<MediaControlPanelElement> m_transitionTimer;
};
// ----------------------------
@@ -491,9 +497,9 @@
#if ENABLE(VIDEO_TRACK)
class MediaControlTextTrackContainerElement : public MediaControlElement {
public:
-
static PassRefPtr<MediaControlTextTrackContainerElement> create(Document*);
-
+
+ void updateDisplay();
void updateSizes();
private:
@@ -505,23 +511,9 @@
IntRect m_videoDisplaySize;
float m_fontSize;
- LayoutUnit m_bottom;
};
-// ----------------------------
-
-class MediaControlTextTrackDisplayElement : public MediaControlElement {
-public:
- static PassRefPtr<MediaControlTextTrackDisplayElement> create(Document*);
-
-private:
- MediaControlTextTrackDisplayElement(Document*);
-
- virtual MediaControlElementType displayType() const { return MediaTextTrackDisplay; }
- virtual const AtomicString& shadowPseudoId() const;
-};
#endif
-
// ----------------------------
} // namespace WebCore
diff --git a/third_party/WebKit/Source/WebCore/html/shadow/MediaControlRootElement.cpp b/third_party/WebKit/Source/WebCore/html/shadow/MediaControlRootElement.cpp
index d26fe20..2383200f 100644
--- a/third_party/WebKit/Source/WebCore/html/shadow/MediaControlRootElement.cpp
+++ b/third_party/WebKit/Source/WebCore/html/shadow/MediaControlRootElement.cpp
@@ -73,7 +73,6 @@
, m_panel(0)
#if ENABLE(VIDEO_TRACK)
, m_textDisplayContainer(0)
- , m_textTrackDisplay(0)
#endif
, m_hideFullscreenControlsTimer(this, &MediaControlRootElement::hideFullscreenControlsTimerFired)
, m_isMouseOverControls(false)
@@ -277,8 +276,6 @@
#if ENABLE(VIDEO_TRACK)
if (m_textDisplayContainer)
m_textDisplayContainer->setMediaController(controller);
- if (m_textTrackDisplay)
- m_textTrackDisplay->setMediaController(controller);
#endif
reset();
}
@@ -604,16 +601,8 @@
RefPtr<MediaControlTextTrackContainerElement> textDisplayContainer = MediaControlTextTrackContainerElement::create(document());
m_textDisplayContainer = textDisplayContainer.get();
- RefPtr<MediaControlTextTrackDisplayElement> textDisplay = MediaControlTextTrackDisplayElement::create(document());
- m_textDisplayContainer->hide();
- m_textTrackDisplay = textDisplay.get();
-
- ExceptionCode ec;
- textDisplayContainer->appendChild(textDisplay.release(), ec, true);
- if (ec)
- return;
-
// Insert it before the first controller element so it always displays behind the controls.
+ ExceptionCode ec;
insertBefore(textDisplayContainer.release(), m_panel, ec, true);
}
@@ -636,28 +625,8 @@
if (!m_textDisplayContainer)
createTextTrackDisplay();
- CueList activeCues = toParentMediaElement(m_textDisplayContainer)->currentlyActiveCues();
- m_textTrackDisplay->removeChildren();
- bool nothingToDisplay = true;
- for (size_t i = 0; i < activeCues.size(); ++i) {
- TextTrackCue* cue = activeCues[i].data();
- ASSERT(cue->isActive());
- if (!cue->track() || cue->track()->mode() != TextTrack::SHOWING)
- continue;
+ m_textDisplayContainer->updateDisplay();
- String cueText = cue->text();
- if (!cueText.isEmpty()) {
- if (!nothingToDisplay)
- m_textTrackDisplay->appendChild(document()->createElement(HTMLNames::brTag, false), ASSERT_NO_EXCEPTION);
- m_textTrackDisplay->appendChild(document()->createTextNode(cueText), ASSERT_NO_EXCEPTION);
- nothingToDisplay = false;
- }
- }
-
- if (!nothingToDisplay)
- m_textDisplayContainer->show();
- else
- m_textDisplayContainer->hide();
}
#endif
diff --git a/third_party/WebKit/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp b/third_party/WebKit/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp
index e69d818d..663e51f 100644
--- a/third_party/WebKit/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp
+++ b/third_party/WebKit/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp
@@ -58,7 +58,6 @@
, m_panel(0)
#if ENABLE(VIDEO_TRACK)
, m_textDisplayContainer(0)
- , m_textTrackDisplay(0)
#endif
, m_opaque(true)
, m_isMouseOverControls(false)
@@ -158,8 +157,6 @@
#if ENABLE(VIDEO_TRACK)
if (m_textDisplayContainer)
m_textDisplayContainer->setMediaController(controller);
- if (m_textTrackDisplay)
- m_textTrackDisplay->setMediaController(controller);
#endif
reset();
}
@@ -335,16 +332,8 @@
RefPtr<MediaControlTextTrackContainerElement> textDisplayContainer = MediaControlTextTrackContainerElement::create(document());
m_textDisplayContainer = textDisplayContainer.get();
- RefPtr<MediaControlTextTrackDisplayElement> textDisplay = MediaControlTextTrackDisplayElement::create(document());
- m_textDisplayContainer->hide();
- m_textTrackDisplay = textDisplay.get();
-
- ExceptionCode ec;
- textDisplayContainer->appendChild(textDisplay.release(), ec, true);
- if (ec)
- return;
-
// Insert it before the first controller element so it always displays behind the controls.
+ ExceptionCode ec;
insertBefore(textDisplayContainer.release(), m_panel, ec, true);
}
@@ -367,31 +356,10 @@
if (!m_textDisplayContainer)
createTextTrackDisplay();
- CueList activeCues = toParentMediaElement(m_textDisplayContainer)->currentlyActiveCues();
- m_textTrackDisplay->removeChildren();
- bool nothingToDisplay = true;
- for (size_t i = 0; i < activeCues.size(); ++i) {
- TextTrackCue* cue = activeCues[i].data();
- ASSERT(cue->isActive());
- if (!cue->track() || cue->track()->mode() != TextTrack::SHOWING)
- continue;
-
- String cueText = cue->text();
- if (!cueText.isEmpty()) {
- if (!nothingToDisplay)
- m_textTrackDisplay->appendChild(document()->createElement(HTMLNames::brTag, false), ASSERT_NO_EXCEPTION);
- m_textTrackDisplay->appendChild(document()->createTextNode(cueText), ASSERT_NO_EXCEPTION);
- nothingToDisplay = false;
- }
- }
-
- if (!nothingToDisplay)
- m_textDisplayContainer->show();
- else
- m_textDisplayContainer->hide();
+ m_textDisplayContainer->updateDisplay();
}
#endif
-
+
const AtomicString& MediaControlRootElementChromium::shadowPseudoId() const
{
DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls"));
diff --git a/third_party/WebKit/Source/WebCore/html/track/TextTrackCue.cpp b/third_party/WebKit/Source/WebCore/html/track/TextTrackCue.cpp
index 83fb5e4..00ebb21a 100644
--- a/third_party/WebKit/Source/WebCore/html/track/TextTrackCue.cpp
+++ b/third_party/WebKit/Source/WebCore/html/track/TextTrackCue.cpp
@@ -35,8 +35,12 @@
#include "TextTrackCue.h"
-#include "Event.h"
+#include "CSSPropertyNames.h"
+#include "CSSValueKeywords.h"
#include "DocumentFragment.h"
+#include "Event.h"
+#include "HTMLDivElement.h"
+#include "Text.h"
#include "TextTrack.h"
#include "TextTrackCueList.h"
#include "WebVTTParser.h"
@@ -111,7 +115,10 @@
, m_isActive(false)
, m_pauseOnExit(pauseOnExit)
, m_snapToLines(true)
+ , m_displayTreeShouldChange(true)
+ , m_displayTree(HTMLDivElement::create(static_cast<Document*>(context)))
{
+ ASSERT(m_scriptExecutionContext->isDocument());
parseSettings(settings);
}
@@ -129,6 +136,8 @@
{
if (m_track)
m_track->cueDidChange(this);
+
+ m_displayTreeShouldChange = true;
}
TextTrack* TextTrackCue::track() const
@@ -394,6 +403,63 @@
void TextTrackCue::setIsActive(bool active)
{
m_isActive = active;
+
+ if (!active) {
+ // Remove the display tree as soon as the cue becomes inactive.
+ ExceptionCode ec;
+ m_displayTree->remove(ec);
+ }
+}
+
+void TextTrackCue::determineDisplayParameters()
+{
+ // FIXME(BUG 79749): Determine the text direction using the BIDI algorithm.
+ // Steps 10.2, 10.3
+
+ // FIXME(BUG 79747): Determine the display parameters from the rules.
+ // Steps 10.1, 10.4 - 10.10
+}
+
+PassRefPtr<HTMLDivElement> TextTrackCue::getDisplayTree()
+{
+ if (!m_displayTreeShouldChange)
+ return m_displayTree;
+
+ // 10.1 - 10.10
+ determineDisplayParameters();
+
+ // 10.11. Apply the terms of the CSS specifications to nodes within the
+ // following constraints, thus obtaining a set of CSS boxes positioned
+ // relative to an initial containing block:
+ m_displayTree->removeChildren();
+
+ // The document tree is the tree of WebVTT Node Objects rooted at nodes.
+
+ // The children of the nodes must be wrapped in an anonymous box whose
+ // 'display' property has the value 'inline'. This is the WebVTT cue
+ // background box.
+ m_displayTree->setShadowPseudoId(AtomicString("-webkit-media-text-track-display"), ASSERT_NO_EXCEPTION);
+ m_displayTree->appendChild(getCueAsHTML(), ASSERT_NO_EXCEPTION, true);
+
+ // FIXME(BUG 79916): Runs of children of WebVTT Ruby Objects that are not
+ // WebVTT Ruby Text Objects must be wrapped in anonymous boxes whose
+ // 'display' property has the value 'ruby-base'.
+
+ // FIXME(BUG 79916): Text runs must be wrapped according to the CSS
+ // line-wrapping rules, except that additionally, regardless of the value of
+ // the 'white-space' property, lines must be wrapped at the edge of their
+ // containing blocks, even if doing so requires splitting a word where there
+ // is no line breaking opportunity. (Thus, normally text wraps as needed,
+ // but if there is a particularly long word, it does not overflow as it
+ // normally would in CSS, it is instead forcibly wrapped at the box's edge.)
+
+ // FIXME(BUG 79750, 79751): Steps 10.12 - 10.14
+
+ m_displayTreeShouldChange = false;
+
+ // 10.15. Let cue's text track cue display state have the CSS boxes in
+ // boxes.
+ return m_displayTree;
}
void TextTrackCue::parseSettings(const String& input)
diff --git a/third_party/WebKit/Source/WebCore/html/track/TextTrackCue.h b/third_party/WebKit/Source/WebCore/html/track/TextTrackCue.h
index 6cf9793..401132d 100644
--- a/third_party/WebKit/Source/WebCore/html/track/TextTrackCue.h
+++ b/third_party/WebKit/Source/WebCore/html/track/TextTrackCue.h
@@ -43,6 +43,7 @@
class DocumentFragment;
class ScriptExecutionContext;
class TextTrack;
+class HTMLDivElement;
class TextTrackCue : public RefCounted<TextTrackCue>, public EventTarget {
public:
@@ -100,6 +101,8 @@
bool isActive();
void setIsActive(bool);
+ PassRefPtr<HTMLDivElement> getDisplayTree();
+
virtual const AtomicString& interfaceName() const;
virtual ScriptExecutionContext* scriptExecutionContext() const;
@@ -110,7 +113,6 @@
using RefCounted<TextTrackCue>::deref;
protected:
-
virtual EventTargetData* eventTargetData();
virtual EventTargetData* ensureEventTargetData();
@@ -118,6 +120,8 @@
TextTrackCue(ScriptExecutionContext*, const String& id, double start, double end, const String& content, const String& settings, bool pauseOnExit);
void parseSettings(const String&);
+ void determineDisplayParameters();
+
void cueWillChange();
void cueDidChange();
@@ -148,6 +152,9 @@
bool m_isActive;
bool m_pauseOnExit;
bool m_snapToLines;
+
+ bool m_displayTreeShouldChange;
+ RefPtr<HTMLDivElement> m_displayTree;
};
} // namespace WebCore