Changeset 110409 in webkit


Ignore:
Timestamp:
Mar 11, 2012 9:47:28 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

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 <vcarbune@adobe.com> 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 <vcarbune@adobe.com> 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.

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r110408 r110409  
     12012-03-11  Victor Carbune  <vcarbune@adobe.com>
     2
     3        Updated layout tests for basic rendering of cues.
     4        Some Chromium tests require rebaselining and have been marked accordingly.
     5
     6        https://bugs.webkit.org/show_bug.cgi?id=79746
     7
     8        Reviewed by Eric Carlson.
     9
     10        * media/media-controls.js: Adjusted helper function.
     11        (mediaControlsElement):
     12        (textTrackDisplayElement): If the method is called with only
     13        one parameter, it returns the text track container instead of
     14        a specific cue.
     15        * media/track/track-cue-mutable-text-expected.txt: Adjusted.
     16        * media/track/track-cue-nothing-to-render-expected.txt: Adjusted.
     17        * media/track/track-cue-rendering-expected.txt: Adjusted.
     18        * media/track/track-cue-rendering.html: Adjusted.
     19        * platform/chromium/test_expectations.txt: Marked tests that need to
     20        be rebaselined accordingly.
     21
    1222012-03-11  Noel Gordon  <noel.gordon@gmail.com>
    223
  • trunk/LayoutTests/media/media-controls.js

    r103852 r110409  
    33{
    44    for (var element = first; element; element = element.nextSibling) {
    5 
    65        // Not every element in the media controls has a shadow pseudo ID, eg. the
    76        // text nodes for the time values, so guard against exceptions.
     
    3635function textTrackDisplayElement(parentElement, id)
    3736{
    38     var controlID = "-webkit-media-text-track-" + id;
    39     var displayElement = mediaControlsElement(internals.shadowRoot(parentElement).firstChild, controlID);
     37    var textTrackContainerID = "-webkit-media-text-track-container";
     38    var containerElement = mediaControlsElement(internals.shadowRoot(parentElement).firstChild, "-webkit-media-text-track-container");
     39
     40    if (!containerElement)
     41        throw "Failed to find text track container element";
     42
     43    if (!id)
     44        return containerElement;
     45
     46    var controlID = "-webkit-media-text-track-" + arguments[1];
     47
     48    var displayElement = mediaControlsElement(containerElement.firstChild, controlID);
    4049    if (!displayElement)
    41         throw "Failed to find media control element ID '" + controlID + "'";
     50        throw "No text track cue with display id '" + controlID + "' is currently visible";
     51
    4252    return displayElement;
    4353}
  • trunk/LayoutTests/media/track/track-cue-mutable-text-expected.txt

    r104624 r110409  
    44** Test initial cue info
    55EXPECTED (testTrack.track.activeCues.length == '0') OK
    6 EXPECTED (textTrackDisplayElement(video, 'display').innerText == '') OK
     6No text track cue with display id '-webkit-media-text-track-display' is currently visible
    77EXPECTED (testTrack.track.cues[0].startTime == '1') OK
    88EXPECTED (testTrack.track.cues[1].startTime == '3') OK
  • trunk/LayoutTests/media/track/track-cue-nothing-to-render-expected.txt

    r104624 r110409  
    44EVENT(seeked)
    55EXPECTED (video.currentTime.toFixed(1) == '0.5') OK
    6 EXPECTED (textTrackDisplayElement(video, 'display').innerText == '') OK
     6No text track cue with display id '-webkit-media-text-track-display' is currently visible
    77
    88RUN(video.currentTime = 1.5)
     
    1515EVENT(seeked)
    1616EXPECTED (video.currentTime.toFixed(1) == '2.5') OK
    17 EXPECTED (textTrackDisplayElement(video, 'display').innerText == '') OK
     17No text track cue with display id '-webkit-media-text-track-display' is currently visible
    1818
    1919RUN(video.currentTime = 3.3)
     
    2626EVENT(seeked)
    2727EXPECTED (video.currentTime.toFixed(1) == '0.6') OK
    28 EXPECTED (textTrackDisplayElement(video, 'display').innerText == '') OK
     28No text track cue with display id '-webkit-media-text-track-display' is currently visible
    2929
    3030RUN(video.currentTime = 5.9)
     
    3737EVENT(seeked)
    3838EXPECTED (video.currentTime.toFixed(1) == '4.4') OK
    39 EXPECTED (textTrackDisplayElement(video, 'display').innerText == '') OK
     39No text track cue with display id '-webkit-media-text-track-display' is currently visible
    4040
    4141RUN(video.currentTime = 7.9)
  • trunk/LayoutTests/media/track/track-cue-rendering-expected.txt

    r104624 r110409  
    3131RUN(video.width = 320)
    3232RUN(video.height = 240)
    33 EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'container')).fontSize == '12px') OK
     33EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontSize == '12px') OK
    3434
    3535RUN(video.width = 640)
    3636RUN(video.height = 480)
    37 EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'container')).fontSize == '24px') OK
     37EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontSize == '24px') OK
    3838
    3939RUN(video.width = 1280)
    4040RUN(video.height = 960)
    41 EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'container')).fontSize == '48px') OK
     41EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontSize == '48px') OK
    4242
    4343RUN(video.width = 2560)
    4444RUN(video.height = 1440)
    45 EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'container')).fontSize == '72px') OK
     45EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontSize == '72px') OK
    4646
    47 EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'container')).fontFamily == 'sans-serif') OK
    48 EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'container')).color == 'rgba(255, 255, 255, 0)') OK
     47EXPECTED (getComputedStyle(textTrackDisplayElement(video)).fontFamily == 'sans-serif') OK
     48EXPECTED (getComputedStyle(textTrackDisplayElement(video)).color == 'rgba(255, 255, 255, 0)') OK
    4949EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'display')).backgroundColor == 'rgba(0, 0, 0, 0.796875)') OK
    5050END OF TEST
  • trunk/LayoutTests/media/track/track-cue-rendering.html

    r104624 r110409  
    1919            run("video.height = " + height);
    2020            document.body.offsetTop;
    21             testExpected("getComputedStyle(textTrackDisplayElement(video, 'container')).fontSize", parseInt(height * 0.05) + "px");
     21            testExpected("getComputedStyle(textTrackDisplayElement(video)).fontSize", parseInt(height * 0.05) + "px");
    2222            consoleWrite("");
    2323        }
     
    3131            testFontSize(2560, 1440);
    3232
    33             testExpected("getComputedStyle(textTrackDisplayElement(video, 'container')).fontFamily", "sans-serif");
    34             testExpected("getComputedStyle(textTrackDisplayElement(video, 'container')).color", "rgba(255, 255, 255, 0)");
     33            testExpected("getComputedStyle(textTrackDisplayElement(video)).fontFamily", "sans-serif");
     34            testExpected("getComputedStyle(textTrackDisplayElement(video)).color", "rgba(255, 255, 255, 0)");
    3535            testExpected("getComputedStyle(textTrackDisplayElement(video, 'display')).backgroundColor", "rgba(0, 0, 0, 0.796875)");
    3636
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r110408 r110409  
    34133413BUGWK73865 : media/track/text-track-is-reachable.html = TEXT CRASH
    34143414
     3415// Need rebaselining
     3416BUGWK79746 : media/media-document-audio-repaint.html = IMAGE+TEXT
     3417BUGWK79746 : media/video-no-audio.html = IMAGE+TEXT
     3418BUGWK79746 : media/controls-strict.html = IMAGE+TEXT
     3419BUGWK79746 : media/video-volume-slider.html = IMAGE+TEXT
     3420BUGWK79746 : media/controls-styling.html = IMAGE+TEXT
     3421BUGWK79746 : media/video-display-toggle.html = IMAGE+TEXT
     3422BUGWK79746 : media/audio-controls-rendering.html = IMAGE+TEXT
     3423BUGWK79746 : media/video-zoom-controls.html = IMAGE+TEXT
     3424BUGWK79746 : media/video-controls-rendering.html = IMAGE+TEXT
     3425BUGWK79746 : media/controls-without-preload.html = IMAGE+TEXT
     3426BUGWK79746 : media/media-controls-clone.html = IMAGE+TEXT
     3427BUGWK79746 : fast/layers/video-layer.html = IMAGE+TEXT
     3428BUGWK79746 : media/video-empty-source.html = IMAGE+TEXT
     3429BUGWK79746 : media/video-playing-and-pause.html = IMAGE+TEXT
     3430BUGWK79746 : media/controls-after-reload.html = IMAGE+TEXT
     3431BUGWK79746 : media/audio-repaint.html = IMAGE+TEXT
     3432BUGWK79746 : media/controls-layout-direction.html = IMAGE
     3433BUGWK79746 : media/video-aspect-ratio.html = IMAGE
     3434BUGWK79746 : media/video-colorspace-yuv420.html = IMAGE
     3435BUGWK79746 : media/video-colorspace-yuv422.html = IMAGE
     3436BUGWK79746 : media/video-frame-accurate-seek.html = IMAGE
     3437BUGWK79746 : media/video-layer-crash.html = IMAGE
     3438BUGWK79746 : media/video-transformed.html = IMAGE
     3439BUGWK79746 : media/video-zoom.html = IMAGE
     3440
    34153441BUGWK72271 MAC DEBUG : fast/loader/javascript-url-in-embed.html = PASS CRASH
    34163442BUGWK72271 SNOWLEOPARD DEBUG : fast/dom/node-iterator-reference-node-moved-crash.html = PASS CRASH
     
    36913717BUGCR114777 : compositing/culling/filter-occlusion-blur-large.html = PASS IMAGE
    36923718BUGCR114777 : compositing/culling/filter-occlusion-blur.html = PASS IMAGE
    3693 
    3694 // Needs rebaseline
    3695 BUGWK78878 : media/audio-repaint.html = IMAGE
    36963719
    36973720// Needs new baselines.
  • trunk/Source/WebCore/ChangeLog

    r110405 r110409  
     12012-03-11  Victor Carbune  <vcarbune@adobe.com>
     2
     3        The main code structure for placing future text track cue rendering
     4        code and main outer rendering steps.
     5        https://bugs.webkit.org/show_bug.cgi?id=79746
     6
     7        Reviewed by Eric Carlson.
     8
     9        No new tests. Only refactoring, but some chromium tests require rebaselining
     10        and have been marked accordingly.
     11
     12        * css/mediaControls.css:
     13        (::-webkit-media-controls): Changed the default display to -webkit-box, as
     14        captions need to always be rendered on top of the controls, if they are visible.
     15        (audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel):
     16        Default position attribute is now relative, handled by the parent -webkit-box
     17        (video::-webkit-media-text-track-container): The position of the container is
     18        now relative, handled by -webkit-box.
     19        (video::-webkit-media-text-track-display): Adjusted text color to match
     20        the color required in the WebVTT spec (section 3.5.1 'color' property)
     21        * css/mediaControlsChromium.css:
     22        (audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel):
     23        Default position attribute is now relative, handled by the parent -webkit-box
     24
     25        * html/shadow/MediaControlElements.cpp:
     26        (WebCore::MediaControlPanelElement::MediaControlPanelElement): Added a timer
     27        for the webkit fade out transition event. This timer is required for setting
     28        the display property to 'none', when the fade out transition is over. Otherwise,
     29        captions would not be displayed at the bottom of the video.
     30        (WebCore::MediaControlPanelElement::startTimer): Added.
     31        (WebCore):
     32        (WebCore::MediaControlPanelElement::stopTimer): Added.
     33        (WebCore::MediaControlPanelElement::transitionTimerFired): Added. If the current
     34        state of the controls is transparent, the display property is set to 'none'.
     35        (WebCore::MediaControlPanelElement::makeOpaque): The inline display:'none' property
     36        is removed before the fade in transition.
     37        (WebCore::MediaControlPanelElement::makeTransparent): Added the timer start.
     38        (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement):
     39        Removed m_bottom as it is not needed anymore.
     40        (WebCore::MediaControlTextTrackContainerElement::updateDisplay): Added. Main
     41        function for the rendering rules.
     42        (WebCore::MediaControlTextTrackContainerElement::updateSizes): The bottom position
     43        needs not to be set anymore.
     44        * html/shadow/MediaControlElements.h:
     45        (MediaControlPanelElement): Added timer internals.
     46        (MediaControlTextTrackContainerElement): Added updateDisplay() and removed unused
     47        variables.
     48
     49        (WebCore):
     50        * html/shadow/MediaControlRootElement.cpp: Removed m_textTrackDisplay
     51        and duplicated code with MediaControlRootElementChromium (only minimum
     52        function calls to the main text track container)
     53        (WebCore::MediaControlRootElement::MediaControlRootElement):
     54        (WebCore::MediaControlRootElement::setMediaController):
     55        (WebCore::MediaControlRootElement::createTextTrackDisplay):
     56        (WebCore::MediaControlRootElement::updateTextTrackDisplay):
     57
     58        * html/shadow/MediaControlRootElementChromium.cpp: Removed m_textTrackDisplay
     59        and duplicate code with MediaControlRootElement (only minimum function calls
     60        to the main text track container remained)
     61        (WebCore::MediaControlRootElementChromium::MediaControlRootElementChromium):
     62        (WebCore::MediaControlRootElementChromium::setMediaController):
     63        (WebCore::MediaControlRootElementChromium::createTextTrackDisplay):
     64        (WebCore::MediaControlRootElementChromium::updateTextTrackDisplay):
     65
     66        (WebCore):
     67        * html/track/TextTrackCue.cpp: Enhanced structure for supporting more complex
     68        rendering required by the WebVTT spec.
     69        (WebCore::TextTrackCue::TextTrackCue):
     70        (WebCore::TextTrackCue::cueDidChange): Mark the display tree as obsolete, so that
     71        it needs to be re-computed.
     72        (WebCore::TextTrackCue::setIsActive): The display tree needs to be removed as
     73        soon as the cue becomes inactive. Adjusted this method to support the functionality.
     74        (WebCore):
     75        (WebCore::TextTrackCue::determineDisplayParameters): Added. This method will hold
     76        main positioning parameter computations for a TextTrackCue
     77        (WebCore):
     78        (WebCore::TextTrackCue::getDisplayTree): Added. This method returns the root node
     79        of the CSS boxes that need to be displayed on top of the video, for the current
     80        instance.
     81        * html/track/TextTrackCue.h:
     82        (WebCore):
     83        (TextTrackCue):
     84
    1852012-03-11  Sheriff Bot  <webkit.review.bot@gmail.com>
    286
  • trunk/Source/WebCore/css/mediaControls.css

    r104278 r110409  
    3838    height: inherit;
    3939    position: relative;
    40     display: block;
     40    display: -webkit-box;
    4141    direction: ltr;
     42    -webkit-box-align: start;
     43    -webkit-box-pack: end;
     44    -webkit-box-orient: vertical;
    4245}
    4346
     
    4750    -webkit-box-align: center;
    4851    -webkit-user-select: none;
    49     position: absolute;
     52    position: relative;
    5053    bottom: 0;
    5154    width: 100%;
     
    202205
    203206video::-webkit-media-text-track-container {
    204     position: absolute;
     207    position: relative;
    205208    width: 100%;
    206209    overflow: hidden;
     210    padding-bottom: 5px;
    207211
    208212    font-size: 22px;
     
    210214    text-align: center;
    211215    color: rgba(255, 255, 255, 0);
    212    
     216
    213217    letter-spacing: normal;
    214218    word-spacing: normal;
     
    223227    display: inline;
    224228    background-color: rgba(0, 0, 0, 0.8);
    225     color: yellow;
     229    color: rgba(255, 255, 255, 1);
    226230    padding: 0px 2px;
    227231}
  • trunk/Source/WebCore/css/mediaControlsChromium.css

    r104278 r110409  
    4242audio::-webkit-media-controls-panel, video::-webkit-media-controls-panel {
    4343    -webkit-user-select: none;
    44     position: absolute;
     44    position: relative;
    4545    overflow: visible;
    4646    bottom: 0;
  • trunk/Source/WebCore/html/shadow/MediaControlElements.cpp

    r109378 r110409  
    4141#include "HTMLMediaElement.h"
    4242#include "HTMLNames.h"
     43#include "HTMLVideoElement.h"
    4344#include "LocalizedStrings.h"
    4445#include "MediaControls.h"
     
    5354#include "ScriptController.h"
    5455#include "Settings.h"
     56#include "Text.h"
    5557
    5658namespace WebCore {
     
    108110    , m_isBeingDragged(false)
    109111    , m_opaque(true)
     112    , m_transitionTimer(this, &MediaControlPanelElement::transitionTimerFired)
    110113{
    111114}
     
    172175
    173176    frame->eventHandler()->setCapturingMouseEventsNode(0);
     177}
     178
     179void MediaControlPanelElement::startTimer()
     180{
     181    stopTimer();
     182
     183    // The timer is required to set the property display:'none' on the panel,
     184    // such that captions are correctly displayed at the bottom of the video
     185    // at the end of the fadeout transition.
     186    double duration = document()->page() ? document()->page()->theme()->mediaControlsFadeOutDuration() : 0;
     187    m_transitionTimer.startOneShot(duration);
     188}
     189
     190void MediaControlPanelElement::stopTimer()
     191{
     192    if (m_transitionTimer.isActive())
     193        m_transitionTimer.stop();
     194}
     195
     196
     197void MediaControlPanelElement::transitionTimerFired(Timer<MediaControlPanelElement>*)
     198{
     199    if (!m_opaque)
     200        hide();
     201
     202    stopTimer();
    174203}
    175204
     
    213242
    214243    m_opaque = true;
     244
     245    show();
    215246}
    216247
     
    225256
    226257    m_opaque = false;
     258
     259    startTimer();
    227260}
    228261
     
    11661199    : MediaControlElement(document)
    11671200    , m_fontSize(0)
    1168     , m_bottom(0)
    11691201{
    11701202}
     
    11881220}
    11891221
     1222void MediaControlTextTrackContainerElement::updateDisplay()
     1223{
     1224    HTMLMediaElement* mediaElement = toParentMediaElement(this);
     1225
     1226    // 1. If the media element is an audio element, or is another playback
     1227    // mechanism with no rendering area, abort these steps. There is nothing to
     1228    // render.
     1229    if (!mediaElement->isVideo())
     1230        return;
     1231
     1232    // 2. Let video be the media element or other playback mechanism.
     1233    HTMLVideoElement* video = static_cast<HTMLVideoElement*>(mediaElement);
     1234
     1235    // 3. Let output be an empty list of absolutely positioned CSS block boxes.
     1236    Vector<RefPtr<HTMLDivElement> > output;
     1237
     1238    // 4. If the user agent is exposing a user interface for video, add to
     1239    // output one or more completely transparent positioned CSS block boxes that
     1240    // cover the same region as the user interface.
     1241
     1242    // 5. If the last time these rules were run, the user agent was not exposing
     1243    // a user interface for video, but now it is, let reset be true. Otherwise,
     1244    // let reset be false.
     1245
     1246    // There is nothing to be done explicitly for 4th and 5th steps, as
     1247    // everything is handled through CSS. The caption box is on top of the
     1248    // controls box, in a container set with the -webkit-box display property.
     1249
     1250    // 6. Let tracks be the subset of video's list of text tracks that have as
     1251    // their rules for updating the text track rendering these rules for
     1252    // updating the display of WebVTT text tracks, and whose text track mode is
     1253    // showing or showing by default.
     1254    // 7. Let cues be an empty list of text track cues.
     1255    // 8. For each track track in tracks, append to cues all the cues from
     1256    // track's list of cues that have their text track cue active flag set.
     1257    CueList activeCues = video->currentlyActiveCues();
     1258
     1259    // 9. If reset is false, then, for each text track cue cue in cues: if cue's
     1260    // text track cue display state has a set of CSS boxes, then add those boxes
     1261    // to output, and remove cue from cues.
     1262
     1263    // There is nothing explicitly to be done here, as all the caching occurs
     1264    // within the TextTrackCue instance itself. If parameters of the cue change,
     1265    // the display tree is cleared.
     1266
     1267    // 10. For each text track cue cue in cues that has not yet had
     1268    // corresponding CSS boxes added to output, in text track cue order, run the
     1269    // following substeps:
     1270
     1271    // Simple renderer for now.
     1272    for (size_t i = 0; i < activeCues.size(); ++i) {
     1273        TextTrackCue* cue = activeCues[i].data();
     1274
     1275        ASSERT(cue->isActive());
     1276        if (!cue->track() || cue->track()->mode() != TextTrack::SHOWING)
     1277            continue;
     1278
     1279        RefPtr<HTMLDivElement> displayTree = cue->getDisplayTree();
     1280
     1281        // Append only new display trees.
     1282        if (displayTree->hasChildNodes() && !contains(displayTree.get()))
     1283            appendChild(displayTree, ASSERT_NO_EXCEPTION, true);
     1284
     1285        // The display tree of a cue is removed when the active flag of the cue is unset.
     1286
     1287        // FIXME(BUG 79750): Render the TextTrackCue when snap-to-lines is set.
     1288        // FIXME(BUG 79751): Render the TextTrackCue when snap-to-lines is not set.
     1289    }
     1290
     1291    // 11. Return output.
     1292    hasChildNodes() ? show() : hide();
     1293}
     1294
    11901295static const float mimimumFontSize = 16;
    11911296static const float videoHeightFontSizePercentage = .05;
    11921297static const float trackBottomMultiplier = .9;
    1193    
     1298
    11941299void MediaControlTextTrackContainerElement::updateSizes()
    11951300{
     
    11971302    if (!mediaElement || !mediaElement->renderer() || !mediaElement->renderer()->isVideo())
    11981303        return;
    1199    
     1304
    12001305    IntRect videoBox = toRenderVideo(mediaElement->renderer())->videoBox();
    12011306    if (m_videoDisplaySize == videoBox)
     
    12081313        setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
    12091314    }
    1210 
    1211     LayoutUnit bottom = static_cast<LayoutUnit>(m_videoDisplaySize.y() + m_videoDisplaySize.height() - (m_videoDisplaySize.height() * trackBottomMultiplier));
    1212     if (bottom != m_bottom) {
    1213         m_bottom = bottom;
    1214         setInlineStyleProperty(CSSPropertyBottom, String::number(roundToInt(bottom)) + "px");
    1215     }
    1216 }
    1217 
    1218 // ----------------------------
    1219 
    1220 MediaControlTextTrackDisplayElement::MediaControlTextTrackDisplayElement(Document* document)
    1221     : MediaControlElement(document)
    1222 {
    1223 }
    1224 
    1225 PassRefPtr<MediaControlTextTrackDisplayElement> MediaControlTextTrackDisplayElement::create(Document* document)
    1226 {
    1227     return adoptRef(new MediaControlTextTrackDisplayElement(document));
    1228 }
    1229 
    1230 const AtomicString& MediaControlTextTrackDisplayElement::shadowPseudoId() const
    1231 {
    1232     DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-text-track-display"));
    1233     return id;
    1234 }
    1235 
    1236 #endif
     1315}
     1316
     1317#endif // ENABLE(VIDEO_TRACK)
    12371318
    12381319// ----------------------------
  • trunk/Source/WebCore/html/shadow/MediaControlElements.h

    r109231 r110409  
    123123    void endDrag();
    124124
     125    void startTimer();
     126    void stopTimer();
     127    void transitionTimerFired(Timer<MediaControlPanelElement>*);
     128
    125129    void setPosition(const LayoutPoint&);
    126130
     
    130134    LayoutPoint m_dragStartPosition;
    131135    LayoutPoint m_dragStartEventLocation;
     136
     137    Timer<MediaControlPanelElement> m_transitionTimer;
    132138};
    133139
     
    492498class MediaControlTextTrackContainerElement : public MediaControlElement {
    493499public:
    494    
    495500    static PassRefPtr<MediaControlTextTrackContainerElement> create(Document*);
    496    
     501
     502    void updateDisplay();
    497503    void updateSizes();
    498504
     
    506512    IntRect m_videoDisplaySize;
    507513    float m_fontSize;
    508     LayoutUnit m_bottom;
    509 };
    510 
    511 // ----------------------------
    512 
    513 class MediaControlTextTrackDisplayElement : public MediaControlElement {
    514 public:
    515     static PassRefPtr<MediaControlTextTrackDisplayElement> create(Document*);
    516 
    517 private:
    518     MediaControlTextTrackDisplayElement(Document*);
    519 
    520     virtual MediaControlElementType displayType() const { return MediaTextTrackDisplay; }
    521     virtual const AtomicString& shadowPseudoId() const;
    522 };
     514};
     515
    523516#endif
    524 
    525517// ----------------------------
    526518
  • trunk/Source/WebCore/html/shadow/MediaControlRootElement.cpp

    r109231 r110409  
    7474#if ENABLE(VIDEO_TRACK)
    7575    , m_textDisplayContainer(0)
    76     , m_textTrackDisplay(0)
    7776#endif
    7877    , m_hideFullscreenControlsTimer(this, &MediaControlRootElement::hideFullscreenControlsTimerFired)
     
    278277    if (m_textDisplayContainer)
    279278        m_textDisplayContainer->setMediaController(controller);
    280     if (m_textTrackDisplay)
    281         m_textTrackDisplay->setMediaController(controller);
    282279#endif
    283280    reset();
     
    605602    m_textDisplayContainer = textDisplayContainer.get();
    606603
    607     RefPtr<MediaControlTextTrackDisplayElement> textDisplay = MediaControlTextTrackDisplayElement::create(document());
    608     m_textDisplayContainer->hide();
    609     m_textTrackDisplay = textDisplay.get();
    610 
     604    // Insert it before the first controller element so it always displays behind the controls.
    611605    ExceptionCode ec;
    612     textDisplayContainer->appendChild(textDisplay.release(), ec, true);
    613     if (ec)
    614         return;
    615 
    616     // Insert it before the first controller element so it always displays behind the controls.
    617606    insertBefore(textDisplayContainer.release(), m_panel, ec, true);
    618607}
     
    637626        createTextTrackDisplay();
    638627
    639     CueList activeCues = toParentMediaElement(m_textDisplayContainer)->currentlyActiveCues();
    640     m_textTrackDisplay->removeChildren();
    641     bool nothingToDisplay = true;
    642     for (size_t i = 0; i < activeCues.size(); ++i) {
    643         TextTrackCue* cue = activeCues[i].data();
    644         ASSERT(cue->isActive());
    645         if (!cue->track() || cue->track()->mode() != TextTrack::SHOWING)
    646             continue;
    647 
    648         String cueText = cue->text();
    649         if (!cueText.isEmpty()) {
    650             if (!nothingToDisplay)
    651                 m_textTrackDisplay->appendChild(document()->createElement(HTMLNames::brTag, false), ASSERT_NO_EXCEPTION);
    652             m_textTrackDisplay->appendChild(document()->createTextNode(cueText), ASSERT_NO_EXCEPTION);
    653             nothingToDisplay = false;
    654         }
    655     }
    656 
    657     if (!nothingToDisplay)
    658         m_textDisplayContainer->show();
    659     else
    660         m_textDisplayContainer->hide();
     628    m_textDisplayContainer->updateDisplay();
     629
    661630}
    662631#endif
  • trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp

    r104658 r110409  
    5959#if ENABLE(VIDEO_TRACK)
    6060    , m_textDisplayContainer(0)
    61     , m_textTrackDisplay(0)
    6261#endif
    6362    , m_opaque(true)
     
    159158    if (m_textDisplayContainer)
    160159        m_textDisplayContainer->setMediaController(controller);
    161     if (m_textTrackDisplay)
    162         m_textTrackDisplay->setMediaController(controller);
    163160#endif
    164161    reset();
     
    336333    m_textDisplayContainer = textDisplayContainer.get();
    337334
    338     RefPtr<MediaControlTextTrackDisplayElement> textDisplay = MediaControlTextTrackDisplayElement::create(document());
    339     m_textDisplayContainer->hide();
    340     m_textTrackDisplay = textDisplay.get();
    341 
     335    // Insert it before the first controller element so it always displays behind the controls.
    342336    ExceptionCode ec;
    343     textDisplayContainer->appendChild(textDisplay.release(), ec, true);
    344     if (ec)
    345         return;
    346 
    347     // Insert it before the first controller element so it always displays behind the controls.
    348337    insertBefore(textDisplayContainer.release(), m_panel, ec, true);
    349338}
     
    368357        createTextTrackDisplay();
    369358
    370     CueList activeCues = toParentMediaElement(m_textDisplayContainer)->currentlyActiveCues();
    371     m_textTrackDisplay->removeChildren();
    372     bool nothingToDisplay = true;
    373     for (size_t i = 0; i < activeCues.size(); ++i) {
    374         TextTrackCue* cue = activeCues[i].data();
    375         ASSERT(cue->isActive());
    376         if (!cue->track() || cue->track()->mode() != TextTrack::SHOWING)
    377             continue;
    378 
    379         String cueText = cue->text();
    380         if (!cueText.isEmpty()) {
    381             if (!nothingToDisplay)
    382                 m_textTrackDisplay->appendChild(document()->createElement(HTMLNames::brTag, false), ASSERT_NO_EXCEPTION);
    383             m_textTrackDisplay->appendChild(document()->createTextNode(cueText), ASSERT_NO_EXCEPTION);
    384             nothingToDisplay = false;
    385         }
    386     }
    387 
    388     if (!nothingToDisplay)
    389         m_textDisplayContainer->show();
    390     else
    391         m_textDisplayContainer->hide();
    392 }
    393 #endif
    394    
     359    m_textDisplayContainer->updateDisplay();
     360}
     361#endif
     362
    395363const AtomicString& MediaControlRootElementChromium::shadowPseudoId() const
    396364{
  • trunk/Source/WebCore/html/track/TextTrackCue.cpp

    r110308 r110409  
    3636#include "TextTrackCue.h"
    3737
     38#include "CSSPropertyNames.h"
     39#include "CSSValueKeywords.h"
     40#include "DocumentFragment.h"
    3841#include "Event.h"
    39 #include "DocumentFragment.h"
     42#include "HTMLDivElement.h"
     43#include "Text.h"
    4044#include "TextTrack.h"
    4145#include "TextTrackCueList.h"
     
    112116    , m_pauseOnExit(pauseOnExit)
    113117    , m_snapToLines(true)
    114 {
     118    , m_displayTreeShouldChange(true)
     119    , m_displayTree(HTMLDivElement::create(static_cast<Document*>(context)))
     120{
     121    ASSERT(m_scriptExecutionContext->isDocument());
    115122    parseSettings(settings);
    116123}
     
    130137    if (m_track)
    131138        m_track->cueDidChange(this);
     139
     140    m_displayTreeShouldChange = true;
    132141}
    133142
     
    395404{
    396405    m_isActive = active;
     406
     407    if (!active) {
     408        // Remove the display tree as soon as the cue becomes inactive.
     409        ExceptionCode ec;
     410        m_displayTree->remove(ec);
     411    }
     412}
     413
     414void TextTrackCue::determineDisplayParameters()
     415{
     416    // FIXME(BUG 79749): Determine the text direction using the BIDI algorithm.
     417    // Steps 10.2, 10.3
     418
     419    // FIXME(BUG 79747): Determine the display parameters from the rules.
     420    // Steps 10.1, 10.4 - 10.10
     421}
     422
     423PassRefPtr<HTMLDivElement> TextTrackCue::getDisplayTree()
     424{
     425    if (!m_displayTreeShouldChange)
     426        return m_displayTree;
     427
     428    // 10.1 - 10.10
     429    determineDisplayParameters();
     430
     431    // 10.11. Apply the terms of the CSS specifications to nodes within the
     432    // following constraints, thus obtaining a set of CSS boxes positioned
     433    // relative to an initial containing block:
     434    m_displayTree->removeChildren();
     435
     436    // The document tree is the tree of WebVTT Node Objects rooted at nodes.
     437
     438    // The children of the nodes must be wrapped in an anonymous box whose
     439    // 'display' property has the value 'inline'. This is the WebVTT cue
     440    // background box.
     441    m_displayTree->setShadowPseudoId(AtomicString("-webkit-media-text-track-display"), ASSERT_NO_EXCEPTION);
     442    m_displayTree->appendChild(getCueAsHTML(), ASSERT_NO_EXCEPTION, true);
     443
     444    // FIXME(BUG 79916): Runs of children of WebVTT Ruby Objects that are not
     445    // WebVTT Ruby Text Objects must be wrapped in anonymous boxes whose
     446    // 'display' property has the value 'ruby-base'.
     447
     448    // FIXME(BUG 79916): Text runs must be wrapped according to the CSS
     449    // line-wrapping rules, except that additionally, regardless of the value of
     450    // the 'white-space' property, lines must be wrapped at the edge of their
     451    // containing blocks, even if doing so requires splitting a word where there
     452    // is no line breaking opportunity. (Thus, normally text wraps as needed,
     453    // but if there is a particularly long word, it does not overflow as it
     454    // normally would in CSS, it is instead forcibly wrapped at the box's edge.)
     455
     456    // FIXME(BUG 79750, 79751): Steps 10.12 - 10.14
     457
     458    m_displayTreeShouldChange = false;
     459
     460    // 10.15. Let cue's text track cue display state have the CSS boxes in
     461    // boxes.
     462    return m_displayTree;
    397463}
    398464
  • trunk/Source/WebCore/html/track/TextTrackCue.h

    r110308 r110409  
    4444class ScriptExecutionContext;
    4545class TextTrack;
     46class HTMLDivElement;
    4647
    4748class TextTrackCue : public RefCounted<TextTrackCue>, public EventTarget {
     
    101102    void setIsActive(bool);
    102103
     104    PassRefPtr<HTMLDivElement> getDisplayTree();
     105
    103106    virtual const AtomicString& interfaceName() const;
    104107    virtual ScriptExecutionContext* scriptExecutionContext() const;
     
    111114
    112115protected:
    113 
    114116    virtual EventTargetData* eventTargetData();
    115117    virtual EventTargetData* ensureEventTargetData();
     
    119121
    120122    void parseSettings(const String&);
     123    void determineDisplayParameters();
     124
    121125    void cueWillChange();
    122126    void cueDidChange();
     
    149153    bool m_pauseOnExit;
    150154    bool m_snapToLines;
     155
     156    bool m_displayTreeShouldChange;
     157    RefPtr<HTMLDivElement> m_displayTree;
    151158};
    152159
Note: See TracChangeset for help on using the changeset viewer.