LayoutTests/ChangeLog

 12013-01-22 Dima Gorbik <dgorbik@apple.com>
 2
 3 Implement :past pseudo class for the WebVTT ::cue pseudo element
 4 https://bugs.webkit.org/show_bug.cgi?id=105482
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * media/track/captions-webvtt/styling-timestamps.vtt: Added.
 9 * media/track/track-css-matching-timestamps-expected.txt: Added.
 10 * media/track/track-css-matching-timestamps.html: Added.
 11
1122013-01-21 Kentaro Hara <haraken@chromium.org>
213
314 Implement UIEvent constructor

LayoutTests/media/track/captions-webvtt/styling-timestamps.vtt

 1WEBVTT
 2
 31
 400:00.000 --> 00:01.000
 5<00:00.200><c>One</c><00:00.400><c> two</c><c><00:00.600><c><c> three</c><00:00.800><c> five</c> four</c></c>

LayoutTests/media/track/track-css-matching-timestamps-expected.txt

 1Test that cues are being matched properly by :past and :future pseudo classes.
 2EVENT(canplaythrough)
 3EVENT(seeked)
 4EXPECTED (getComputedStyle(cueNode).color == 'rgb(128, 128, 128)') OK
 5EXPECTED (getComputedStyle(cueNode).color == 'rgb(128, 128, 128)') OK
 6EXPECTED (getComputedStyle(cueNode).color == 'rgb(128, 128, 128)') OK
 7EXPECTED (getComputedStyle(cueNode).color == 'rgb(128, 128, 128)') OK
 8EXPECTED (getComputedStyle(cueNode).color == 'rgb(128, 128, 128)') OK
 9
 10RUN(video.currentTime = 0.3)
 11EVENT(seeked)
 12EXPECTED (getComputedStyle(cueNode).color == 'rgb(0, 255, 0)') OK
 13EXPECTED (getComputedStyle(cueNode).color == 'rgb(128, 128, 128)') OK
 14EXPECTED (getComputedStyle(cueNode).color == 'rgb(128, 128, 128)') OK
 15EXPECTED (getComputedStyle(cueNode).color == 'rgb(128, 128, 128)') OK
 16EXPECTED (getComputedStyle(cueNode).color == 'rgb(128, 128, 128)') OK
 17
 18RUN(video.currentTime = 0.5)
 19EVENT(seeked)
 20EXPECTED (getComputedStyle(cueNode).color == 'rgb(0, 255, 0)') OK
 21EXPECTED (getComputedStyle(cueNode).color == 'rgb(0, 255, 0)') OK
 22EXPECTED (getComputedStyle(cueNode).color == 'rgb(128, 128, 128)') OK
 23EXPECTED (getComputedStyle(cueNode).color == 'rgb(128, 128, 128)') OK
 24EXPECTED (getComputedStyle(cueNode).color == 'rgb(128, 128, 128)') OK
 25
 26RUN(video.currentTime = 0.7)
 27EVENT(seeked)
 28EXPECTED (getComputedStyle(cueNode).color == 'rgb(0, 255, 0)') OK
 29EXPECTED (getComputedStyle(cueNode).color == 'rgb(0, 255, 0)') OK
 30EXPECTED (getComputedStyle(cueNode).color == 'rgb(0, 255, 0)') OK
 31EXPECTED (getComputedStyle(cueNode).color == 'rgb(128, 128, 128)') OK
 32EXPECTED (getComputedStyle(cueNode).color == 'rgb(0, 255, 0)') OK
 33
 34RUN(video.currentTime = 0.9)
 35EVENT(seeked)
 36EXPECTED (getComputedStyle(cueNode).color == 'rgb(0, 255, 0)') OK
 37EXPECTED (getComputedStyle(cueNode).color == 'rgb(0, 255, 0)') OK
 38EXPECTED (getComputedStyle(cueNode).color == 'rgb(0, 255, 0)') OK
 39EXPECTED (getComputedStyle(cueNode).color == 'rgb(0, 255, 0)') OK
 40EXPECTED (getComputedStyle(cueNode).color == 'rgb(0, 255, 0)') OK
 41END OF TEST
 42

LayoutTests/media/track/track-css-matching-timestamps.html

 1<!DOCTYPE html>
 2<html>
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5
 6 <script src=../media-file.js></script>
 7 <script src=../video-test.js></script>
 8 <script src=../media-controls.js></script>
 9
 10 <style>
 11 video::cue {color: green}
 12 video::cue(:past) {color: lime}
 13 video::cue(:future) {color: gray}
 14 </style>
 15
 16 <script>
 17
 18 var cueNode;
 19 var seekedCount = 0;
 20 var seekTimes = [0.1, 0.3, 0.5, 0.7, 0.9];
 21
 22 var info = [["rgb(128, 128, 128)", "rgb(128, 128, 128)", "rgb(128, 128, 128)", "rgb(128, 128, 128)", "rgb(128, 128, 128)"],
 23 ["rgb(0, 255, 0)", "rgb(128, 128, 128)", "rgb(128, 128, 128)", "rgb(128, 128, 128)", "rgb(128, 128, 128)"],
 24 ["rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb(128, 128, 128)", "rgb(128, 128, 128)", "rgb(128, 128, 128)"],
 25 ["rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb(128, 128, 128)", "rgb(0, 255, 0)"],
 26 ["rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb(0, 255, 0)"]];
 27
 28 function seeked()
 29 {
 30 if (testEnded)
 31 return;
 32
 33 cueNode = textTrackDisplayElement(video, 'all-nodes').firstElementChild;
 34 testExpected("getComputedStyle(cueNode).color", info[seekedCount][0]);
 35 cueNode = cueNode.nextElementSibling;
 36 testExpected("getComputedStyle(cueNode).color", info[seekedCount][1]);
 37 cueNode = cueNode.nextElementSibling.firstElementChild.firstChild;
 38 testExpected("getComputedStyle(cueNode).color", info[seekedCount][2]);
 39 cueNode = cueNode.nextElementSibling;
 40 testExpected("getComputedStyle(cueNode).color", info[seekedCount][3]);
 41 cueNode = cueNode.parentNode;
 42 testExpected("getComputedStyle(cueNode).color", info[seekedCount][4]);
 43
 44 if (++seekedCount == info.length)
 45 endTest();
 46 else {
 47 consoleWrite("");
 48 run("video.currentTime = " + seekTimes[seekedCount]);
 49 }
 50 }
 51
 52 function loaded()
 53 {
 54 consoleWrite("Test that cues are being matched properly by :past and :future pseudo classes.");
 55 findMediaElement();
 56 video.src = findMediaFile('video', '../content/test');
 57 video.id = "testvideo";
 58 waitForEvent('seeked', seeked);
 59 waitForEvent('canplaythrough', function() { video.currentTime = seekTimes[0]; });
 60 }
 61
 62 </script>
 63 </head>
 64 <body onload="loaded()">
 65 <video controls >
 66 <track src="captions-webvtt/styling-timestamps.vtt" kind="captions" default>
 67 </video>
 68 </body>
 69</html>

Source/WebCore/ChangeLog

 12013-01-22 Dima Gorbik <dgorbik@apple.com>
 2
 3 Implement :past pseudo class for the WebVTT ::cue pseudo element
 4 https://bugs.webkit.org/show_bug.cgi?id=105482
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 It is good to have a designated pseudo class for this, though same could
 9 be achieved by using a combination of ::cue and ::cue(:future).
 10 Tests also check that nested timestamps work properly.
 11
 12 Test: media/track/track-css-matching-timestamps.html
 13
 14 * css/CSSSelector.cpp:
 15 (WebCore::CSSSelector::pseudoId):
 16 (WebCore::nameToPseudoTypeMap):
 17 (WebCore::CSSSelector::extractPseudoType):
 18 * css/CSSSelector.h:
 19 * css/SelectorChecker.cpp:
 20 (WebCore::SelectorChecker::checkOne):
 21
1222013-01-21 Kentaro Hara <haraken@chromium.org>
223
324 Implement UIEvent constructor

Source/WebCore/css/CSSSelector.cpp

@@PseudoId CSSSelector::pseudoId(PseudoType type)
238238#if ENABLE(VIDEO_TRACK)
239239 case PseudoCue:
240240 case PseudoFutureCue:
 241 case PseudoPastCue:
241242#endif
242243#if ENABLE(IFRAME_SEAMLESS)
243244 case PseudoSeamlessDocument:

@@static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap(
327328#if ENABLE(VIDEO_TRACK)
328329 DEFINE_STATIC_LOCAL(AtomicString, cue, ("cue(", AtomicString::ConstructFromLiteral));
329330 DEFINE_STATIC_LOCAL(AtomicString, futureCue, ("future", AtomicString::ConstructFromLiteral));
 331 DEFINE_STATIC_LOCAL(AtomicString, pastCue, ("past", AtomicString::ConstructFromLiteral));
330332#endif
331333#if ENABLE(IFRAME_SEAMLESS)
332334 DEFINE_STATIC_LOCAL(AtomicString, seamlessDocument, ("-webkit-seamless-document", AtomicString::ConstructFromLiteral));

@@static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap(
409411#if ENABLE(VIDEO_TRACK)
410412 nameToPseudoType->set(cue.impl(), CSSSelector::PseudoCue);
411413 nameToPseudoType->set(futureCue.impl(), CSSSelector::PseudoFutureCue);
 414 nameToPseudoType->set(pastCue.impl(), CSSSelector::PseudoPastCue);
412415#endif
413416#if ENABLE(IFRAME_SEAMLESS)
414417 nameToPseudoType->set(seamlessDocument.impl(), CSSSelector::PseudoSeamlessDocument);

@@void CSSSelector::extractPseudoType() const
539542 case PseudoOutOfRange:
540543#if ENABLE(VIDEO_TRACK)
541544 case PseudoFutureCue:
 545 case PseudoPastCue:
542546#endif
543547 break;
544548 case PseudoFirstPage:

Source/WebCore/css/CSSSelector.h

@@namespace WebCore {
160160#if ENABLE(VIDEO_TRACK)
161161 PseudoCue,
162162 PseudoFutureCue,
 163 PseudoPastCue,
163164#endif
164165#if ENABLE(IFRAME_SEAMLESS)
165166 PseudoSeamlessDocument

Source/WebCore/css/SelectorChecker.cpp

@@bool SelectorChecker::checkOne(const SelectorCheckingContext& context, const Sib
875875#if ENABLE(VIDEO_TRACK)
876876 case CSSSelector::PseudoFutureCue:
877877 return (element->isWebVTTElement() && toWebVTTElement(element)->webVTTNodeType() == WebVTTNodeTypeFuture);
 878 case CSSSelector::PseudoPastCue:
 879 return (element->isWebVTTElement() && toWebVTTElement(element)->webVTTNodeType() == WebVTTNodeTypePast);
878880#endif
879881
880882 case CSSSelector::PseudoHorizontal: