+2014-02-07 Brendan Long <b.long@cablelabs.com>
+
+ Update TextTrack API to current spec
+ https://bugs.webkit.org/show_bug.cgi?id=122218
+
+ Refactoring VTTCue out of TextTrackCue.
+
+ Reviewed by Eric Carlson.
+
+ * js/dom/constructor-length.html: Add VTTCue constructor.
+ * platform/efl/js/dom/global-constructors-attributes-expected.txt: Same.
+ * platform/efl/js/dom/constructor-length-expected.txt: Same.
+ * js/dom/global-constructors-attributes-expected.txt: Same.
+ * platform/gtk-wk2/js/dom/constructor-length-expected.txt: Same.
+ * platform/gtk-wk2/js/dom/global-constructors-attributes-expected.txt: Same.
+ * platform/gtk/js/dom/constructor-length-expected.txt: Same.
+ * platform/gtk/js/dom/global-constructors-attributes-expected.txt: Same.
+ * platform/mac-mountainlion/js/dom/global-constructors-attributes-expected.txt: Same.
+ * platform/mac/js/dom/constructor-length-expected.txt: Same.
+ * platform/mac/js/dom/global-constructors-attributes-expected.txt: Same.
+ * platform/win/js/dom/global-constructors-attributes-expected.txt: Same.
+ * media/track/track-cues-cuechange-expected.txt: Cues are of type VTTCue now.
+ * media/track/track-cues-enter-exit-expected.txt: Same.
+ * media/track/track-vttcue-expected.txt: Test VTTCue interface.
+ * media/track/track-vttcue.html: Same.
+ * media/video-test.js:
+ (testExpected): Add "instanceof" as a valid operator.
+
2014-02-07 Mihai Tica <mitica@adobe.com>
[CSS Background Blending] Unprefix the -webkit-background-blend-mode property
shouldBe('Uint32Array.length', '3');
shouldBe('Uint8Array.length', '3');
shouldBe('Uint8ClampedArray.length', '3');
+shouldBe('VTTCue.length', '3');
shouldBe('WebGLContextEvent.length', '1');
shouldBe('WebKitAnimationEvent.length', '1');
shouldBe('WebKitCSSMatrix.length', '0');
PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').value is VTTCue
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').value is WaveShaperNode
PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('set') is false
EVENT(cuechange) from TextTrack
EVENT(cuechange) from <track>
Cue entered
-EXPECTED ([object TextTrackCue] == '[object TextTrackCue]') OK
+EXPECTED ([object VTTCue] == '[object VTTCue]') OK
EXPECTED (currentCue.id == '1') OK
EVENT(cuechange) from TextTrack
EVENT(cuechange) from TextTrack
EVENT(cuechange) from <track>
Cue entered
-EXPECTED ([object TextTrackCue] == '[object TextTrackCue]') OK
+EXPECTED ([object VTTCue] == '[object VTTCue]') OK
EXPECTED (currentCue.id == '2') OK
EVENT(cuechange) from TextTrack
EVENT(cuechange) from TextTrack
EVENT(cuechange) from <track>
Cue entered
-EXPECTED ([object TextTrackCue] == '[object TextTrackCue]') OK
+EXPECTED ([object VTTCue] == '[object VTTCue]') OK
EXPECTED (currentCue.id == '3') OK
EVENT(cuechange) from TextTrack
EVENT(enter)
This cue is the currently active cue:
-EXPECTED ([object TextTrackCue] == '[object TextTrackCue]') OK
+EXPECTED ([object VTTCue] == '[object VTTCue]') OK
EXPECTED (currentCue.id == '1') OK
EVENT(exit)
EVENT(enter)
This cue is the currently active cue:
-EXPECTED ([object TextTrackCue] == '[object TextTrackCue]') OK
+EXPECTED ([object VTTCue] == '[object VTTCue]') OK
EXPECTED (currentCue.id == '2') OK
EVENT(exit)
EVENT(enter)
This cue is the currently active cue:
-EXPECTED ([object TextTrackCue] == '[object TextTrackCue]') OK
+EXPECTED ([object VTTCue] == '[object VTTCue]') OK
EXPECTED (currentCue.id == '3') OK
EVENT(exit)
--- /dev/null
+Tests VTTCue interface
+
+
+
+*** Test cue loaded from the file.
+RUN(trackCue = cues[0])
+EXPECTED (trackCue instanceof '[object TextTrackCueConstructor]') OK
+EXPECTED (trackCue.track == '[object TextTrack]') OK
+EXPECTED (trackCue.id == '1') OK
+EXPECTED (trackCue.startTime == '0') OK
+EXPECTED (trackCue.endTime == '0.3') OK
+EXPECTED (trackCue.pauseOnExit == 'false') OK
+EXPECTED (trackCue instanceof '[object VTTCueConstructor]') OK
+EXPECTED (trackCue.vertical == '') OK
+EXPECTED (trackCue.snapToLines == 'true') OK
+EXPECTED (trackCue.line == '-1') OK
+EXPECTED (trackCue.position == '50') OK
+EXPECTED (trackCue.size == '100') OK
+EXPECTED (trackCue.align == 'middle') OK
+EXPECTED (trackCue.text == 'Lorem') OK
+EXPECTED (serialize(trackCue.getCueAsHTML()) == 'Lorem') OK
+
+*** Create a new cue, check values
+RUN(newCue = new VTTCue(3.14, 6.28, 'Pie'))
+EXPECTED (newCue instanceof '[object TextTrackCueConstructor]') OK
+EXPECTED (newCue.track == 'null') OK
+EXPECTED (newCue.id == '') OK
+EXPECTED (newCue.startTime == '3.14') OK
+EXPECTED (newCue.endTime == '6.28') OK
+EXPECTED (newCue.pauseOnExit == 'false') OK
+EXPECTED (newCue instanceof '[object VTTCueConstructor]') OK
+EXPECTED (newCue.vertical == '') OK
+EXPECTED (newCue.snapToLines == 'true') OK
+EXPECTED (newCue.line == '-1') OK
+EXPECTED (newCue.position == '50') OK
+EXPECTED (newCue.size == '100') OK
+EXPECTED (newCue.align == 'middle') OK
+EXPECTED (newCue.text == 'Pie') OK
+EXPECTED (serialize(newCue.getCueAsHTML()) == 'Pie') OK
+END OF TEST
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <script src=../media-file.js></script>
+ <script src=../video-test.js></script>
+ <script>
+
+ var cues;
+
+ function serialize(documentFragment)
+ {
+ return new XMLSerializer().serializeToString(documentFragment);
+ }
+
+ function trackLoaded()
+ {
+ var testTrack = document.getElementById('testTrack');
+ cues = testTrack.track.cues;
+
+ consoleWrite("<br>*** Test cue loaded from the file.");
+ run("trackCue = cues[0]");
+
+ testExpected("trackCue", TextTrackCue, "instanceof");
+ testExpected("trackCue.track", testTrack.track);
+ testExpected("trackCue.id", "1");
+ testExpected("trackCue.startTime", 0);
+ testExpected("trackCue.endTime", 0.3);
+ testExpected("trackCue.pauseOnExit", false);
+
+ testExpected("trackCue", VTTCue, "instanceof");
+ testExpected("trackCue.vertical", "");
+ testExpected("trackCue.snapToLines", true);
+ testExpected("trackCue.line", -1);
+ testExpected("trackCue.position", 50);
+ testExpected("trackCue.size", 100);
+ testExpected("trackCue.align", "middle");
+ testExpected("trackCue.text", "Lorem");
+ testExpected("serialize(trackCue.getCueAsHTML())", 'Lorem');
+
+ consoleWrite("<br>*** Create a new cue, check values");
+ run("newCue = new VTTCue(3.14, 6.28, 'Pie')");
+
+ testExpected("newCue", TextTrackCue, "instanceof");
+ testExpected("newCue.track", null);
+ testExpected("newCue.id", '');
+ testExpected("newCue.startTime", 3.14);
+ testExpected("newCue.endTime", 6.28);
+ testExpected("newCue.pauseOnExit", false);
+
+ testExpected("newCue", VTTCue, "instanceof");
+ testExpected("newCue.vertical", "");
+ testExpected("newCue.snapToLines", true);
+ testExpected("newCue.line", -1);
+ testExpected("newCue.position", 50);
+ testExpected("newCue.size", 100);
+ testExpected("newCue.align", "middle");
+ testExpected("newCue.text", "Pie");
+ testExpected("serialize(newCue.getCueAsHTML())", 'Pie');
+
+ endTest();
+ }
+
+ setCaptionDisplayMode('Automatic');
+ </script>
+ </head>
+ <body>
+ <p>Tests VTTCue interface</p>
+ <video>
+ <track id="testTrack" src="captions-webvtt/captions-fast.vtt" kind="captions" onload="trackLoaded()" default>
+ </video>
+ </body>
+</html>
case '!=': success = observed != expected; break;
case '==': success = observed == expected; break;
case '===': success = observed === expected; break;
+ case 'instanceof': success = observed instanceof expected; break;
}
reportExpected(success, testFuncString, comparison, expected, observed)
PASS Uint32Array.length is 3
PASS Uint8Array.length is 3
PASS Uint8ClampedArray.length is 3
+PASS VTTCue.length is 3
PASS WebGLContextEvent.length is 1
PASS WebKitAnimationEvent.length is 1
PASS WebKitCSSMatrix.length is 0
PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').value is VTTCue
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').value is WaveShaperNode
PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('set') is false
PASS Uint32Array.length is 3
PASS Uint8Array.length is 3
PASS Uint8ClampedArray.length is 3
+PASS VTTCue.length is 3
PASS WebGLContextEvent.length is 1
PASS WebKitAnimationEvent.length is 1
PASS WebKitCSSMatrix.length is 0
PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').value is VTTCue
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'VideoStreamTrack').value is VideoStreamTrack
PASS Object.getOwnPropertyDescriptor(global, 'VideoStreamTrack').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'VideoStreamTrack').hasOwnProperty('set') is false
PASS Uint32Array.length is 3
PASS Uint8Array.length is 3
PASS Uint8ClampedArray.length is 3
+PASS VTTCue.length is 3
PASS WebGLContextEvent.length is 1
PASS WebKitAnimationEvent.length is 1
PASS WebKitCSSMatrix.length is 0
PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').value is VTTCue
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'VideoStreamTrack').value is VideoStreamTrack
PASS Object.getOwnPropertyDescriptor(global, 'VideoStreamTrack').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'VideoStreamTrack').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').value is VTTCue
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').value is WaveShaperNode
PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('set') is false
PASS Uint32Array.length is 3
PASS Uint8Array.length is 3
PASS Uint8ClampedArray.length is 3
+PASS VTTCue.length is 3
PASS WebGLContextEvent.length is 1
PASS WebKitAnimationEvent.length is 1
PASS WebKitCSSMatrix.length is 0
PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').value is VTTCue
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').value is WaveShaperNode
PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'UIEvent').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'UIEvent').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'UIEvent').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').value is VTTCue
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'WebKitAnimationEvent').value is WebKitAnimationEvent
PASS Object.getOwnPropertyDescriptor(global, 'WebKitAnimationEvent').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'WebKitAnimationEvent').hasOwnProperty('set') is false
rendering/RenderTextControlSingleLine.cpp
rendering/RenderTextFragment.cpp
rendering/RenderTextLineBoxes.cpp
- rendering/RenderTextTrackCue.cpp
rendering/RenderTheme.cpp
rendering/RenderTreeAsText.cpp
rendering/RenderVideo.cpp
rendering/RenderView.cpp
+ rendering/RenderVTTCue.cpp
rendering/RenderWidget.cpp
rendering/RootInlineBox.cpp
rendering/ScrollBehavior.cpp
html/track/TrackEvent.idl
html/track/VideoTrack.idl
html/track/VideoTrackList.idl
+ html/track/VTTCue.idl
)
list(APPEND WebCore_SOURCES
html/track/TrackListBase.cpp
html/track/VideoTrack.cpp
html/track/VideoTrackList.cpp
+ html/track/VTTCue.cpp
html/track/WebVTTElement.cpp
html/track/WebVTTParser.cpp
html/track/WebVTTTokenizer.cpp
+2014-02-07 Brendan Long <b.long@cablelabs.com>
+
+ Update TextTrack API to current spec
+ https://bugs.webkit.org/show_bug.cgi?id=122218
+
+ Refactoring VTTCue out of TextTrackCue.
+
+ Reviewed by Eric Carlson.
+
+ Test: media/track/track-vttcue.html
+
+ * CMakeLists.txt: Add VTTCue and rename RenderTextTrackCue to RenderVTTCue.
+ * DerivedSources.cpp: Same.
+ * DerivedSources.make: Same.
+ * GNUmakefile.list.am: Same.
+ * PlatformGTK.cmake: Same.
+ * WebCore.vcxproj/WebCore.vcxproj: Same.
+ * WebCore.vcxproj/WebCore.vcxproj.filters: Same.
+ * WebCore.xcodeproj/project.pbxproj: Same.
+ * bindings/js/JSTextTrackCueCustom.cpp:
+ (WebCore::toJS): Use VTTCue DOM wrapper for VTTCue and its subclasses.
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::updateActiveTextTrackCues): Convert to VTTCue as needed.
+ (WebCore::HTMLMediaElement::textTrackRemoveCue): Same.
+ * html/HTMLMediaElement.h: Only print cue.text in debug output if the cue type has a .text attribute
+ * html/shadow/MediaControlElements.cpp:
+ (WebCore::MediaControlTextTrackContainerElement::updateDisplay): Convert to VTTCue as needed, and fix TextTrackCueBox to VTTCueBox.
+ (WebCore::MediaControlTextTrackContainerElement::updateTimerFired): Convert to VTTCue as needed.
+ * html/track/InbandGenericTextTrack.cpp:
+ (WebCore::InbandGenericTextTrack::addGenericCue): Use refactored VTTCue attributes.
+ * html/track/InbandWebVTTTextTrack.cpp:
+ (WebCore::InbandWebVTTTextTrack::newCuesParsed): Use VTTCue's constructor instead of deprecated TextTrackCue constructor.
+ * html/track/TextTrack.cpp:
+ (WebCore::TextTrack::setMode): Convert to VTTCue as needed.
+ (WebCore::TextTrack::hasCue): Make this function only accept VTTCues, since it's only used for them anyway, and convert existing cues to VTTCues as needed.
+ * html/track/TextTrack.h: Same as hasCue above.
+ * html/track/TextTrackCue.cpp: Refactor a lot of code out. Everything that was removed went to VTTCue.cpp.
+ (WebCore::TextTrackCue::create): For backwards compatibility, just call VTTCue::create().
+ (WebCore::TextTrackCue::TextTrackCue): Refactor a lot of code out.
+ (WebCore::TextTrackCue::~TextTrackCue): Same.
+ (WebCore::TextTrackCue::didChange): Same.
+ (WebCore::TextTrackCue::setIsActive): Same.
+ * html/track/TextTrackCue.h: Same.
+ * html/track/TextTrackCue.idl: Remove VTTCue attributes and add custom toJS function.
+ * html/track/TextTrackCueGeneric.cpp: Use VTTCue instead of TextTrackCue.
+ * html/track/TextTrackCueGeneric.h: Same.
+ * html/track/VTTCue.cpp: Copied from Source/WebCore/html/track/TextTrackCue.cpp.
+ * html/track/VTTCue.h: Copied from Source/WebCore/html/track/TextTrackCue.h.
+ * html/track/VTTCue.idl: Copied from Source/WebCore/html/track/TextTrackCue.idl.
+ * loader/TextTrackLoader.cpp:
+ (WebCore::TextTrackLoader::getNewCues): Use VTTCue instead of TextTrackCue.
+ * page/CaptionUserPreferencesMediaAF.cpp:
+ (WebCore::CaptionUserPreferencesMediaAF::captionsStyleSheetOverride): Use VTTCueBox instead of TextTrackCueBox.
+ * rendering/RenderVTTCue.cpp: Renamed from Source/WebCore/rendering/RenderTextTrackCue.cpp. Changed to use VTTCue instead of TextTrackCue.
+ * rendering/RenderVTTCue.h: Renamed from Source/WebCore/rendering/RenderTextTrackCue.h. Changed to use VTTCue instead of TextTrackCue.
+ * rendering/RenderingAllInOne.cpp: Rename RenderTextTrackCue to RenderVTTCue.
+
2014-02-07 Gavin Barraclough <barraclough@apple.com>
Should report user input to PageThrottler
#include "JSTextTrackCueList.cpp"
#include "JSTextTrackList.cpp"
#include "JSTrackEvent.cpp"
+#include "JSVTTCue.cpp"
#include "JSVideoTrack.cpp"
#include "JSVideoTrackList.cpp"
#endif
$(WebCore)/html/track/TrackEvent.idl \
$(WebCore)/html/track/VideoTrack.idl \
$(WebCore)/html/track/VideoTrackList.idl \
+ $(WebCore)/html/track/VTTCue.idl \
$(WebCore)/inspector/CommandLineAPIHost.idl \
$(WebCore)/inspector/InspectorFrontendHost.idl \
$(WebCore)/inspector/ScriptProfile.idl \
DerivedSources/WebCore/JSVideoTrack.h \
DerivedSources/WebCore/JSVideoTrackList.cpp \
DerivedSources/WebCore/JSVideoTrackList.h \
+ DerivedSources/WebCore/JSVTTCue.cpp \
+ DerivedSources/WebCore/JSVTTCue.h \
DerivedSources/WebCore/JSWaveShaperNode.cpp \
DerivedSources/WebCore/JSWaveShaperNode.h \
DerivedSources/WebCore/JSPeriodicWave.cpp \
$(WebCore)/html/track/TrackEvent.idl \
$(WebCore)/html/track/VideoTrack.idl \
$(WebCore)/html/track/VideoTrackList.idl \
+ $(WebCore)/html/track/VTTCue.idl \
$(WebCore)/inspector/CommandLineAPIHost.idl \
$(WebCore)/inspector/InspectorFrontendHost.idl \
$(WebCore)/inspector/ScriptProfile.idl \
Source/WebCore/html/track/VideoTrack.h \
Source/WebCore/html/track/VideoTrackList.cpp \
Source/WebCore/html/track/VideoTrackList.h \
+ Source/WebCore/html/track/VTTCue.cpp \
+ Source/WebCore/html/track/VTTCue.h \
Source/WebCore/html/track/WebVTTElement.cpp \
Source/WebCore/html/track/WebVTTElement.h \
Source/WebCore/html/track/WebVTTParser.cpp \
Source/WebCore/rendering/RenderTextControlMultiLine.h \
Source/WebCore/rendering/RenderTextControlSingleLine.cpp \
Source/WebCore/rendering/RenderTextControlSingleLine.h \
- Source/WebCore/rendering/RenderTextTrackCue.cpp \
- Source/WebCore/rendering/RenderTextTrackCue.h \
Source/WebCore/rendering/RenderTextFragment.cpp \
Source/WebCore/rendering/RenderTextFragment.h \
Source/WebCore/rendering/RenderTextLineBoxes.cpp \
Source/WebCore/rendering/RenderVideo.h \
Source/WebCore/rendering/RenderView.cpp \
Source/WebCore/rendering/RenderView.h \
+ Source/WebCore/rendering/RenderVTTCue.cpp \
+ Source/WebCore/rendering/RenderVTTCue.h \
Source/WebCore/rendering/RenderWidget.cpp \
Source/WebCore/rendering/RenderWidget.h \
Source/WebCore/rendering/RootInlineBox.cpp \
html/track/TrackEvent.idl
html/track/VideoTrack.idl
html/track/VideoTrackList.idl
+ html/track/VTTCue.idl
)
endif ()
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
- <ClCompile Include="..\rendering\RenderTextTrackCue.cpp">
+ <ClCompile Include="..\rendering\RenderTheme.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
- <ClCompile Include="..\rendering\RenderTheme.cpp">
+ <ClCompile Include="..\rendering\RenderThemeSafari.cpp" />
+ <ClCompile Include="..\rendering\RenderThemeWin.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
- <ClCompile Include="..\rendering\RenderThemeSafari.cpp" />
- <ClCompile Include="..\rendering\RenderThemeWin.cpp">
+ <ClCompile Include="..\rendering\RenderTreeAsText.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
- <ClCompile Include="..\rendering\RenderTreeAsText.cpp">
+ <ClCompile Include="..\rendering\RenderVTTCue.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
<ClCompile Include="..\html\track\TextTrackList.cpp" />
<ClCompile Include="..\html\track\TrackBase.cpp" />
<ClCompile Include="..\html\track\TrackEvent.cpp" />
+ <ClCompile Include="..\html\track\VTTCue.cpp" />
<ClCompile Include="..\html\track\WebVTTParser.cpp" />
<ClCompile Include="..\html\track\WebVTTTokenizer.cpp" />
<ClCompile Include="..\bindings\generic\ActiveDOMCallback.cpp" />
<ClInclude Include="..\rendering\RenderTextControlSingleLine.h" />
<ClInclude Include="..\rendering\RenderTextFragment.h" />
<ClInclude Include="..\rendering\RenderTextLineBoxes.h" />
- <ClInclude Include="..\rendering\RenderTextTrackCue.h" />
<ClInclude Include="..\rendering\RenderTheme.h" />
<CustomBuildStep Include="..\rendering\RenderThemeSafari.h" />
<CustomBuildStep Include="..\rendering\RenderThemeWin.h" />
<ClInclude Include="..\rendering\RenderTreeAsText.h" />
+ <ClInclude Include="..\rendering\RenderVTTCue.h" />
<ClInclude Include="..\rendering\RenderVideo.h" />
<ClInclude Include="..\rendering\RenderView.h" />
<ClInclude Include="..\rendering\RenderWidget.h" />
<ClInclude Include="..\html\track\TextTrackList.h" />
<ClInclude Include="..\html\track\TrackBase.h" />
<ClInclude Include="..\html\track\TrackEvent.h" />
+ <ClInclude Include="..\html\track\VTTCue.h" />
<ClInclude Include="..\html\track\WebVTTParser.h" />
<ClInclude Include="..\html\track\WebVTTToken.h" />
<ClInclude Include="..\html\track\WebVTTTokenizer.h" />
<ClCompile Include="..\rendering\RenderTextFragment.cpp">
<Filter>rendering</Filter>
</ClCompile>
- <ClCompile Include="..\rendering\RenderTextTrackCue.cpp">
- <Filter>rendering</Filter>
- </ClCompile>
<ClCompile Include="..\rendering\RenderTheme.cpp">
<Filter>rendering</Filter>
</ClCompile>
<ClCompile Include="..\rendering\RenderTreeAsText.cpp">
<Filter>rendering</Filter>
</ClCompile>
+ <ClCompile Include="..\rendering\RenderVTTCue.cpp">
+ <Filter>rendering</Filter>
+ </ClCompile>
<ClCompile Include="..\rendering\RenderVideo.cpp">
<Filter>rendering</Filter>
</ClCompile>
<ClCompile Include="..\html\track\TrackEvent.cpp">
<Filter>html\track</Filter>
</ClCompile>
+ <ClCompile Include="..\html\track\VTTCue.cpp">
+ <Filter>html\track</Filter>
+ </ClCompile>
<ClCompile Include="..\html\track\WebVTTParser.cpp">
<Filter>html\track</Filter>
</ClCompile>
<ClInclude Include="..\rendering\RenderTextFragment.h">
<Filter>rendering</Filter>
</ClInclude>
- <ClInclude Include="..\rendering\RenderTextTrackCue.h">
- <Filter>rendering</Filter>
- </ClInclude>
<ClInclude Include="..\rendering\RenderTheme.h">
<Filter>rendering</Filter>
</ClInclude>
<ClInclude Include="..\rendering\RenderTreeAsText.h">
<Filter>rendering</Filter>
</ClInclude>
+ <ClInclude Include="..\rendering\RenderVTTCue.h">
+ <Filter>rendering</Filter>
+ </ClInclude>
<ClInclude Include="..\rendering\RenderVideo.h">
<Filter>rendering</Filter>
</ClInclude>
<ClInclude Include="..\html\track\TrackEvent.h">
<Filter>html\track</Filter>
</ClInclude>
+ <ClInclude Include="..\html\track\VTTCue.h">
+ <Filter>html\track</Filter>
+ </ClInclude>
<ClInclude Include="..\html\track\WebVTTParser.h">
<Filter>html\track</Filter>
</ClInclude>
86BE340315058CB200CE0FD8 /* PerformanceEntryList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86BE33FD15058CB200CE0FD8 /* PerformanceEntryList.cpp */; };
86BE340415058CB200CE0FD8 /* PerformanceEntryList.h in Headers */ = {isa = PBXBuildFile; fileRef = 86BE33FE15058CB200CE0FD8 /* PerformanceEntryList.h */; };
86D982F7125C154000AD9E3D /* DocumentTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 86D982F6125C154000AD9E3D /* DocumentTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 86FF886115DE3D0700BD6B28 /* RenderTextTrackCue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86FF885E15DE3B8200BD6B28 /* RenderTextTrackCue.cpp */; };
- 86FF886215DE3D0700BD6B28 /* RenderTextTrackCue.h in Headers */ = {isa = PBXBuildFile; fileRef = 86FF885F15DE3B8200BD6B28 /* RenderTextTrackCue.h */; };
8931DE5B14C44C44000DC9D2 /* JSBlobCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8931DE5A14C44C44000DC9D2 /* JSBlobCustom.cpp */; };
898785F0122E1E87003AABDA /* JSFileException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 898785EE122E1E87003AABDA /* JSFileException.cpp */; };
898785F1122E1E87003AABDA /* JSFileException.h in Headers */ = {isa = PBXBuildFile; fileRef = 898785EF122E1E87003AABDA /* JSFileException.h */; };
BE16C59317CFE17200852C04 /* InbandGenericTextTrack.h in Headers */ = {isa = PBXBuildFile; fileRef = BE16C58F17CFE17200852C04 /* InbandGenericTextTrack.h */; };
BE16C59417CFE17200852C04 /* InbandWebVTTTextTrack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE16C59017CFE17200852C04 /* InbandWebVTTTextTrack.cpp */; };
BE16C59517CFE17200852C04 /* InbandWebVTTTextTrack.h in Headers */ = {isa = PBXBuildFile; fileRef = BE16C59117CFE17200852C04 /* InbandWebVTTTextTrack.h */; };
+ BE20507918A458680080647E /* VTTCue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE20507618A458460080647E /* VTTCue.cpp */; };
+ BE20507A18A4586B0080647E /* VTTCue.h in Headers */ = {isa = PBXBuildFile; fileRef = BE20507718A458460080647E /* VTTCue.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ BE20507D18A458BF0080647E /* RenderVTTCue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE20507B18A458B10080647E /* RenderVTTCue.cpp */; };
+ BE20507E18A458C20080647E /* RenderVTTCue.h in Headers */ = {isa = PBXBuildFile; fileRef = BE20507C18A458B10080647E /* RenderVTTCue.h */; };
+ BE20508118A460BC0080647E /* JSVTTCue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE20507F18A460AA0080647E /* JSVTTCue.cpp */; };
+ BE20508218A460C30080647E /* JSVTTCue.h in Headers */ = {isa = PBXBuildFile; fileRef = BE20508018A460AA0080647E /* JSVTTCue.h */; };
BE6DF70B171CA2C500DD52B8 /* JSVideoTrackCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE6DF708171CA2C500DD52B8 /* JSVideoTrackCustom.cpp */; };
BE6DF70D171CA2C500DD52B8 /* JSVideoTrackListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE6DF70A171CA2C500DD52B8 /* JSVideoTrackListCustom.cpp */; };
BE6DF711171CA2DA00DD52B8 /* JSAudioTrackCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE6DF70E171CA2DA00DD52B8 /* JSAudioTrackCustom.cpp */; };
86BE33FE15058CB200CE0FD8 /* PerformanceEntryList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceEntryList.h; sourceTree = "<group>"; };
86BE33FF15058CB200CE0FD8 /* PerformanceEntryList.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PerformanceEntryList.idl; sourceTree = "<group>"; };
86D982F6125C154000AD9E3D /* DocumentTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentTiming.h; sourceTree = "<group>"; };
- 86FF885E15DE3B8200BD6B28 /* RenderTextTrackCue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTextTrackCue.cpp; sourceTree = "<group>"; };
- 86FF885F15DE3B8200BD6B28 /* RenderTextTrackCue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTextTrackCue.h; sourceTree = "<group>"; };
892ABE5C16EEE2AA009F3587 /* JSNavigatorStorageQuota.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNavigatorStorageQuota.cpp; sourceTree = "<group>"; };
892ABE5D16EEE2AA009F3587 /* JSNavigatorStorageQuota.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNavigatorStorageQuota.h; sourceTree = "<group>"; };
892ABE5F16EEE2E5009F3587 /* JSDOMWindowQuota.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMWindowQuota.h; sourceTree = "<group>"; };
BE16C58F17CFE17200852C04 /* InbandGenericTextTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandGenericTextTrack.h; sourceTree = "<group>"; };
BE16C59017CFE17200852C04 /* InbandWebVTTTextTrack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InbandWebVTTTextTrack.cpp; sourceTree = "<group>"; };
BE16C59117CFE17200852C04 /* InbandWebVTTTextTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandWebVTTTextTrack.h; sourceTree = "<group>"; };
+ BE20507618A458460080647E /* VTTCue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VTTCue.cpp; sourceTree = "<group>"; };
+ BE20507718A458460080647E /* VTTCue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VTTCue.h; sourceTree = "<group>"; };
+ BE20507818A458460080647E /* VTTCue.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VTTCue.idl; sourceTree = "<group>"; };
+ BE20507B18A458B10080647E /* RenderVTTCue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderVTTCue.cpp; sourceTree = "<group>"; };
+ BE20507C18A458B10080647E /* RenderVTTCue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderVTTCue.h; sourceTree = "<group>"; };
+ BE20507F18A460AA0080647E /* JSVTTCue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVTTCue.cpp; sourceTree = "<group>"; };
+ BE20508018A460AA0080647E /* JSVTTCue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVTTCue.h; sourceTree = "<group>"; };
BE6DF708171CA2C500DD52B8 /* JSVideoTrackCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVideoTrackCustom.cpp; sourceTree = "<group>"; };
BE6DF70A171CA2C500DD52B8 /* JSVideoTrackListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVideoTrackListCustom.cpp; sourceTree = "<group>"; };
BE6DF70E171CA2DA00DD52B8 /* JSAudioTrackCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAudioTrackCustom.cpp; sourceTree = "<group>"; };
E44614130CD6826900FADA75 /* JSTimeRanges.h */,
07846340145B151A00A58DF1 /* JSTrackEvent.cpp */,
07846341145B151A00A58DF1 /* JSTrackEvent.h */,
+ BE20507F18A460AA0080647E /* JSVTTCue.cpp */,
+ BE20508018A460AA0080647E /* JSVTTCue.h */,
15C77092100D3CA8005BA267 /* JSValidityState.cpp */,
15C77091100D3CA8005BA267 /* JSValidityState.h */,
BE8EF046171C9014009B48C3 /* JSVideoTrack.cpp */,
070334D21459FFAC008D8D45 /* TrackEvent.idl */,
BE88E0BF1715CE2600658D98 /* TrackListBase.cpp */,
BE88E0C01715CE2600658D98 /* TrackListBase.h */,
+ BE20507618A458460080647E /* VTTCue.cpp */,
+ BE20507718A458460080647E /* VTTCue.h */,
+ BE20507818A458460080647E /* VTTCue.idl */,
BE88E0D21715D2A200658D98 /* VideoTrack.cpp */,
BE88E0D31715D2A200658D98 /* VideoTrack.h */,
BE88E0D41715D2A200658D98 /* VideoTrack.idl */,
BCEA484F097D93020094C9E4 /* RenderTextFragment.h */,
E4C91A17180999FB00A17F6D /* RenderTextLineBoxes.cpp */,
E4C91A15180999F100A17F6D /* RenderTextLineBoxes.h */,
- 86FF885E15DE3B8200BD6B28 /* RenderTextTrackCue.cpp */,
- 86FF885F15DE3B8200BD6B28 /* RenderTextTrackCue.h */,
BCEA484A097D93020094C9E4 /* RenderTheme.cpp */,
BCEA484B097D93020094C9E4 /* RenderTheme.h */,
FED13D500CEA949700D89466 /* RenderThemeIOS.h */,
BCEA4849097D93020094C9E4 /* RenderThemeMac.mm */,
93955A4203D72932008635CE /* RenderTreeAsText.cpp */,
93955A4103D72932008635CE /* RenderTreeAsText.h */,
+ BE20507B18A458B10080647E /* RenderVTTCue.cpp */,
+ BE20507C18A458B10080647E /* RenderVTTCue.h */,
E4B41E330CBFB60900AF2ECE /* RenderVideo.cpp */,
E4B41E340CBFB60900AF2ECE /* RenderVideo.h */,
BCEA4828097D93020094C9E4 /* RenderView.cpp */,
FD31601012B0267600C1A359 /* AudioListener.h in Headers */,
0705852417FDC140005F2BCB /* MediaTrackConstraints.h in Headers */,
A14832CA187F678000DA63A6 /* WebCoreThreadMessage.h in Headers */,
+ BE20507E18A458C20080647E /* RenderVTTCue.h in Headers */,
FD31601312B0267600C1A359 /* AudioNode.h in Headers */,
FD31601612B0267600C1A359 /* AudioNodeInput.h in Headers */,
FD31601812B0267600C1A359 /* AudioNodeOutput.h in Headers */,
083DAEA70F01A7FB00342754 /* RenderTextControlMultiLine.h in Headers */,
083DAEA90F01A7FB00342754 /* RenderTextControlSingleLine.h in Headers */,
BCEA488E097D93020094C9E4 /* RenderTextFragment.h in Headers */,
- 86FF886215DE3D0700BD6B28 /* RenderTextTrackCue.h in Headers */,
BCEA488A097D93020094C9E4 /* RenderTheme.h in Headers */,
BCEA4887097D93020094C9E4 /* RenderThemeMac.h in Headers */,
93F1998C08245E59001E9ABC /* RenderTreeAsText.h in Headers */,
41D168EA10226E89009BC827 /* SharedWorkerRepository.h in Headers */,
E1B7839C163740A70007B692 /* SharedWorkerStrategy.h in Headers */,
41D168EE10226E89009BC827 /* SharedWorkerThread.h in Headers */,
+ BE20507A18A4586B0080647E /* VTTCue.h in Headers */,
B2C3DA650D006CD600EF6F26 /* SimpleFontData.h in Headers */,
E4B65A5C132FACB00070E7BE /* TileLayer.h in Headers */,
C5A1EA7D152BCF08004D00B6 /* SimplifyMarkupCommand.h in Headers */,
51D719F6181106E00016DC51 /* IDBVersionChangeEvent.h in Headers */,
0FF50272102BA96A0066F39A /* StyleMedia.h in Headers */,
BC5EB74E0E81E06700B25965 /* StyleMultiColData.h in Headers */,
+ BE20508218A460C30080647E /* JSVTTCue.h in Headers */,
A80E6DFC0A199067007FB8C5 /* StyleProperties.h in Headers */,
E1B25107152A0BB00069B779 /* StylePropertyShorthand.h in Headers */,
BC2272E40E82EE9B00E7F975 /* StyleRareInheritedData.h in Headers */,
FD31609412B026F700C1A359 /* FFTConvolver.cpp in Sources */,
FD31609612B026F700C1A359 /* FFTFrame.cpp in Sources */,
932AD70517EFA2C30038F8FF /* MainFrame.cpp in Sources */,
+ BE20507918A458680080647E /* VTTCue.cpp in Sources */,
FD3160C012B0272A00C1A359 /* FFTFrameMac.cpp in Sources */,
976D6C80122B8A3D001FD1F7 /* File.cpp in Sources */,
934FE9E50B5CA539003E4A73 /* FileChooser.cpp in Sources */,
8A7CC97012076F8A001D4588 /* PendingScript.cpp in Sources */,
E526AF3F1727F8F200E41781 /* Performance.cpp in Sources */,
0F54DCD81880F867003EEDBB /* DOMTouchEvent.mm in Sources */,
+ BE20508118A460BC0080647E /* JSVTTCue.cpp in Sources */,
07DC5FD417D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp in Sources */,
86BE340315058CB200CE0FD8 /* PerformanceEntryList.cpp in Sources */,
8AF4E55511DC5A36000ED3DE /* PerformanceNavigation.cpp in Sources */,
083DAEA60F01A7FB00342754 /* RenderTextControlMultiLine.cpp in Sources */,
083DAEA80F01A7FB00342754 /* RenderTextControlSingleLine.cpp in Sources */,
BCEA488D097D93020094C9E4 /* RenderTextFragment.cpp in Sources */,
- 86FF886115DE3D0700BD6B28 /* RenderTextTrackCue.cpp in Sources */,
BCEA4889097D93020094C9E4 /* RenderTheme.cpp in Sources */,
BCEA4888097D93020094C9E4 /* RenderThemeMac.mm in Sources */,
93F19AD508245E59001E9ABC /* RenderTreeAsText.cpp in Sources */,
E139866315478474001E3F65 /* StyleResolver.cpp in Sources */,
E4BBED4C14FCDBA1003F0B98 /* StyleRule.cpp in Sources */,
E4946EAE156E64DD00D3297F /* StyleRuleImport.cpp in Sources */,
+ BE20507D18A458BF0080647E /* RenderVTTCue.cpp in Sources */,
A8EA800D0A19516E00A8EF5F /* StyleSheet.cpp in Sources */,
E4F9EEF2156D9FFA00D23E7E /* StyleSheetContents.cpp in Sources */,
A8EA800B0A19516E00A8EF5F /* StyleSheetList.cpp in Sources */,
#include "JSTextTrackCue.h"
#include "JSTrackCustom.h"
+#include "JSVTTCue.h"
#include "TextTrack.h"
using namespace JSC;
return visitor.containsOpaqueRoot(root(textTrackCue.track()));
}
+JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, TextTrackCue* cue)
+{
+ if (!cue)
+ return jsNull();
+
+ JSObject* wrapper = getCachedWrapper(currentWorld(exec), cue);
+
+ if (wrapper)
+ return wrapper;
+
+ // This switch will make more sense once we support DataCue
+ switch (cue->cueType()) {
+ case TextTrackCue::WebVTT:
+ case TextTrackCue::Generic:
+ return CREATE_DOM_WRAPPER(exec, globalObject, VTTCue, cue);
+ default:
+ ASSERT_NOT_REACHED();
+ return jsNull();
+ }
+}
+
void JSTextTrackCue::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
JSTextTrackCue* jsTextTrackCue = jsCast<JSTextTrackCue*>(cell);
activeSetChanged = true;
for (size_t i = 0; i < currentCuesSize; ++i) {
- currentCues[i].data()->updateDisplayTree(movieTime);
+ TextTrackCue* cue = currentCues[i].data();
- if (!currentCues[i].data()->isActive())
+ if (cue->isRenderable())
+ toVTTCue(cue)->updateDisplayTree(movieTime);
+
+ if (!cue->isActive())
activeSetChanged = true;
}
m_currentlyActiveCues.remove(index);
}
- cue->removeDisplayTree();
+ if (cue->isRenderable())
+ toVTTCue(cue.get())->removeDisplayTree();
updateActiveTextTrackCues(currentTime());
}
#include "PODIntervalTree.h"
#include "TextTrack.h"
#include "TextTrackCue.h"
+#include "VTTCue.h"
#include "VideoTrack.h"
#endif
struct ValueToString<TextTrackCue*> {
static String string(TextTrackCue* const& cue)
{
- return String::format("%p id=%s interval=%f-->%f cue=%s)", cue, cue->id().utf8().data(), cue->startTime(), cue->endTime(), cue->text().utf8().data());
+ String text;
+ if (cue->isRenderable())
+ text = toVTTCue(cue)->text();
+ return String::format("%p id=%s interval=%f-->%f cue=%s)", cue, cue->id().utf8().data(), cue->startTime(), cue->endTime(), text.utf8().data());
}
};
#endif
// corresponding CSS boxes added to output, in text track cue order, run the
// following substeps:
for (size_t i = 0; i < activeCues.size(); ++i) {
- TextTrackCue* cue = activeCues[i].data();
+ TextTrackCue* textTrackCue = activeCues[i].data();
+ if (!textTrackCue->isRenderable())
+ continue;
+
+ VTTCue* cue = toVTTCue(textTrackCue);
ASSERT(cue->isActive());
if (!cue->track() || !cue->track()->isRendered() || !cue->isActive() || cue->text().isEmpty())
continue;
- RefPtr<TextTrackCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size());
+ RefPtr<VTTCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size());
if (displayBox->hasChildNodes() && !contains(displayBox.get())) {
// Note: the display tree of a cue is removed when the active flag of the cue is unset.
appendChild(displayBox, ASSERT_NO_EXCEPTION);
CueList activeCues = mediaElement->currentlyActiveCues();
for (size_t i = 0; i < activeCues.size(); ++i) {
TextTrackCue* cue = activeCues[i].data();
- cue->setFontSize(m_fontSize, m_videoDisplaySize.size(), m_fontSizeIsImportant);
+ if (!cue->isRenderable())
+ continue;
+
+ toVTTCue(cue)->setFontSize(m_fontSize, m_videoDisplaySize.size(), m_fontSizeIsImportant);
}
updateDisplay();
}
RefPtr<TextTrackCueGeneric> cue = TextTrackCueGeneric::create(*scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
updateCueFromCueData(cue.get(), cueData.get());
- if (hasCue(cue.get(), TextTrackCue::IgnoreDuration)) {
+ if (hasCue(cue.get(), VTTCue::IgnoreDuration)) {
LOG(Media, "InbandGenericTextTrack::addGenericCue ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n", cueData->startTime(), cueData->endTime(), cueData->content().utf8().data());
return;
}
m_webVTTParser->getNewCues(cues);
for (size_t i = 0; i < cues.size(); ++i) {
RefPtr<WebVTTCueData> cueData = cues[i];
- RefPtr<TextTrackCue> cue = TextTrackCue::create(*scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
+ RefPtr<VTTCue> cue = VTTCue::create(*scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
cue->setId(cueData->id());
cue->setCueSettings(cueData->settings());
- if (hasCue(cue.get(), TextTrackCue::IgnoreDuration)) {
+ if (hasCue(cue.get(), VTTCue::IgnoreDuration)) {
LOG(Media, "InbandWebVTTTextTrack::newCuesParsed ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n", cueData->startTime(), cueData->endTime(), cueData->content().utf8().data());
return;
}
if (mode == disabledKeyword() && m_client && m_cues)
m_client->textTrackRemoveCues(this, m_cues.get());
- if (mode != showingKeyword() && m_cues)
- for (size_t i = 0; i < m_cues->length(); ++i)
- m_cues->item(i)->removeDisplayTree();
+ if (mode != showingKeyword() && m_cues) {
+ for (size_t i = 0; i < m_cues->length(); ++i) {
+ TextTrackCue* cue = m_cues->item(i);
+ if (cue->isRenderable())
+ toVTTCue(cue)->removeDisplayTree();
+ }
+ }
m_mode = mode;
return m_renderedTrackIndex;
}
-bool TextTrack::hasCue(TextTrackCue* cue, TextTrackCue::CueMatchRules match)
+bool TextTrack::hasCue(VTTCue* cue, VTTCue::CueMatchRules match)
{
if (cue->startTime() < 0 || cue->endTime() < 0)
return false;
return false;
existingCue = m_cues->item(searchStart - 1);
+ if (!cue->isRenderable())
+ continue;
+
if (!existingCue || cue->startTime() > existingCue->startTime())
return false;
- if (!existingCue->isEqual(*cue, match))
+ if (!toVTTCue(existingCue)->isEqual(*cue, match))
continue;
return true;
size_t index = (searchStart + searchEnd) / 2;
existingCue = m_cues->item(index);
- if (cue->startTime() < existingCue->startTime() || (match != TextTrackCue::IgnoreDuration && cue->startTime() == existingCue->startTime() && cue->endTime() > existingCue->endTime()))
+ if (cue->startTime() < existingCue->startTime() || (match != VTTCue::IgnoreDuration && cue->startTime() == existingCue->startTime() && cue->endTime() > existingCue->endTime()))
searchEnd = index;
else
searchStart = index + 1;
#include "ExceptionCode.h"
#include "TextTrackCue.h"
#include "TrackBase.h"
+#include "VTTCue.h"
#include <wtf/PassOwnPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/text/WTFString.h>
void addCue(PassRefPtr<TextTrackCue>);
virtual void removeCue(TextTrackCue*, ExceptionCode&);
- bool hasCue(TextTrackCue*, TextTrackCue::CueMatchRules = TextTrackCue::MatchAllFields);
+ bool hasCue(VTTCue*, VTTCue::CueMatchRules = VTTCue::MatchAllFields);
#if ENABLE(VIDEO_TRACK) && ENABLE(WEBVTT_REGIONS)
TextTrackRegionList* regions();
#include "HTMLSpanElement.h"
#include "Logging.h"
#include "NodeTraversal.h"
-#include "RenderTextTrackCue.h"
#include "Text.h"
#include "TextTrack.h"
#include "TextTrackCueList.h"
-#include "WebVTTElement.h"
-#include "WebVTTParser.h"
+#include "VTTCue.h"
#include <wtf/MathExtras.h>
#include <wtf/text/StringBuilder.h>
namespace WebCore {
static const int invalidCueIndex = -1;
-static const int undefinedPosition = -1;
-static const String& startKeyword()
+PassRefPtr<TextTrackCue> TextTrackCue::create(ScriptExecutionContext& context, double start, double end, const String& content)
{
- DEFINE_STATIC_LOCAL(const String, start, (ASCIILiteral("start")));
- return start;
+ return VTTCue::create(context, start, end, content);
}
-static const String& middleKeyword()
-{
- DEFINE_STATIC_LOCAL(const String, middle, (ASCIILiteral("middle")));
- return middle;
-}
-
-static const String& endKeyword()
-{
- DEFINE_STATIC_LOCAL(const String, end, (ASCIILiteral("end")));
- return end;
-}
-
-static const String& horizontalKeyword()
-{
- return emptyString();
-}
-
-static const String& verticalGrowingLeftKeyword()
-{
- DEFINE_STATIC_LOCAL(const String, verticalrl, (ASCIILiteral("rl")));
- return verticalrl;
-}
-
-static const String& verticalGrowingRightKeyword()
-{
- DEFINE_STATIC_LOCAL(const String, verticallr, (ASCIILiteral("lr")));
- return verticallr;
-}
-
-// ----------------------------
-
-TextTrackCueBox::TextTrackCueBox(Document& document, TextTrackCue* cue)
- : HTMLElement(divTag, document)
- , m_cue(cue)
-{
- setPseudo(textTrackCueBoxShadowPseudoId());
-}
-
-TextTrackCue* TextTrackCueBox::getCue() const
-{
- return m_cue;
-}
-
-void TextTrackCueBox::applyCSSProperties(const IntSize&)
-{
- // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79916
-
- // 3.5.1 On the (root) List of WebVTT Node Objects:
-
- // the 'position' property must be set to 'absolute'
- setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
-
- // the 'unicode-bidi' property must be set to 'plaintext'
- setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueWebkitPlaintext);
-
- // the 'direction' property must be set to direction
- setInlineStyleProperty(CSSPropertyDirection, m_cue->getCSSWritingDirection());
-
- // the 'writing-mode' property must be set to writing-mode
- setInlineStyleProperty(CSSPropertyWebkitWritingMode, m_cue->getCSSWritingMode(), false);
-
- std::pair<float, float> position = m_cue->getCSSPosition();
-
- // the 'top' property must be set to top,
- setInlineStyleProperty(CSSPropertyTop, static_cast<double>(position.second), CSSPrimitiveValue::CSS_PERCENTAGE);
-
- // the 'left' property must be set to left
- setInlineStyleProperty(CSSPropertyLeft, static_cast<double>(position.first), CSSPrimitiveValue::CSS_PERCENTAGE);
-
- // the 'width' property must be set to width, and the 'height' property must be set to height
- if (m_cue->vertical() == horizontalKeyword()) {
- setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue->getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
- setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto);
- } else {
- setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto);
- setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue->getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
- }
-
- // The 'text-align' property on the (root) List of WebVTT Node Objects must
- // be set to the value in the second cell of the row of the table below
- // whose first cell is the value of the corresponding cue's text track cue
- // alignment:
- if (m_cue->align() == startKeyword())
- setInlineStyleProperty(CSSPropertyTextAlign, CSSValueStart);
- else if (m_cue->align() == endKeyword())
- setInlineStyleProperty(CSSPropertyTextAlign, CSSValueEnd);
- else
- setInlineStyleProperty(CSSPropertyTextAlign, CSSValueCenter);
-
- if (!m_cue->snapToLines()) {
- // 10.13.1 Set up x and y:
- // Note: x and y are set through the CSS left and top above.
-
- // 10.13.2 Position the boxes in boxes such that the point x% along the
- // width of the bounding box of the boxes in boxes is x% of the way
- // across the width of the video's rendering area, and the point y%
- // along the height of the bounding box of the boxes in boxes is y%
- // of the way across the height of the video's rendering area, while
- // maintaining the relative positions of the boxes in boxes to each
- // other.
- setInlineStyleProperty(CSSPropertyWebkitTransform,
- String::format("translate(-%.2f%%, -%.2f%%)", position.first, position.second));
-
- setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre);
- }
-}
-
-const AtomicString& TextTrackCueBox::textTrackCueBoxShadowPseudoId()
-{
- DEFINE_STATIC_LOCAL(const AtomicString, trackDisplayBoxShadowPseudoId, ("-webkit-media-text-track-display", AtomicString::ConstructFromLiteral));
- return trackDisplayBoxShadowPseudoId;
-}
-
-RenderPtr<RenderElement> TextTrackCueBox::createElementRenderer(PassRef<RenderStyle> style)
-{
- return createRenderer<RenderTextTrackCue>(*this, std::move(style));
-}
-
-// ----------------------------
-
-TextTrackCue::TextTrackCue(ScriptExecutionContext& context, double start, double end, const String& content)
+TextTrackCue::TextTrackCue(ScriptExecutionContext& context, double start, double end)
: m_startTime(start)
, m_endTime(end)
- , m_content(content)
- , m_linePosition(undefinedPosition)
- , m_computedLinePosition(undefinedPosition)
- , m_textPosition(50)
- , m_cueSize(100)
, m_cueIndex(invalidCueIndex)
, m_processingCueChanges(0)
- , m_writingDirection(Horizontal)
- , m_cueAlignment(Middle)
- , m_webVTTNodeTree(0)
, m_track(0)
, m_scriptExecutionContext(context)
, m_isActive(false)
, m_pauseOnExit(false)
- , m_snapToLines(true)
- , m_cueBackgroundBox(HTMLSpanElement::create(spanTag, toDocument(context)))
- , m_displayTreeShouldChange(true)
- , m_displayDirection(CSSValueLtr)
{
ASSERT(m_scriptExecutionContext.isDocument());
-
- // 4. If the text track cue writing direction is horizontal, then let
- // writing-mode be 'horizontal-tb'. Otherwise, if the text track cue writing
- // direction is vertical growing left, then let writing-mode be
- // 'vertical-rl'. Otherwise, the text track cue writing direction is
- // vertical growing right; let writing-mode be 'vertical-lr'.
- m_displayWritingModeMap[Horizontal] = CSSValueHorizontalTb;
- m_displayWritingModeMap[VerticalGrowingLeft] = CSSValueVerticalRl;
- m_displayWritingModeMap[VerticalGrowingRight] = CSSValueVerticalLr;
}
TextTrackCue::~TextTrackCue()
{
- removeDisplayTree();
-}
-
-PassRefPtr<TextTrackCueBox> TextTrackCue::createDisplayTree()
-{
- return TextTrackCueBox::create(ownerDocument(), this);
-}
-
-TextTrackCueBox* TextTrackCue::displayTreeInternal()
-{
- if (!m_displayTree)
- m_displayTree = createDisplayTree();
- return m_displayTree.get();
}
void TextTrackCue::willChange()
if (m_track)
m_track->cueDidChange(this);
-
- m_displayTreeShouldChange = true;
}
TextTrack* TextTrackCue::track() const
m_pauseOnExit = value;
}
-const String& TextTrackCue::vertical() const
-{
- switch (m_writingDirection) {
- case Horizontal:
- return horizontalKeyword();
- case VerticalGrowingLeft:
- return verticalGrowingLeftKeyword();
- case VerticalGrowingRight:
- return verticalGrowingRightKeyword();
- default:
- ASSERT_NOT_REACHED();
- return emptyString();
- }
-}
-
-void TextTrackCue::setVertical(const String& value, ExceptionCode& ec)
-{
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-vertical
- // On setting, the text track cue writing direction must be set to the value given
- // in the first cell of the row in the table above whose second cell is a
- // case-sensitive match for the new value, if any. If none of the values match, then
- // the user agent must instead throw a SyntaxError exception.
-
- WritingDirection direction = m_writingDirection;
- if (value == horizontalKeyword())
- direction = Horizontal;
- else if (value == verticalGrowingLeftKeyword())
- direction = VerticalGrowingLeft;
- else if (value == verticalGrowingRightKeyword())
- direction = VerticalGrowingRight;
- else
- ec = SYNTAX_ERR;
-
- if (direction == m_writingDirection)
- return;
-
- willChange();
- m_writingDirection = direction;
- didChange();
-}
-
-void TextTrackCue::setSnapToLines(bool value)
-{
- if (m_snapToLines == value)
- return;
-
- willChange();
- m_snapToLines = value;
- didChange();
-}
-
-void TextTrackCue::setLine(int position, ExceptionCode& ec)
-{
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line
- // On setting, if the text track cue snap-to-lines flag is not set, and the new
- // value is negative or greater than 100, then throw an IndexSizeError exception.
- if (!m_snapToLines && (position < 0 || position > 100)) {
- ec = INDEX_SIZE_ERR;
- return;
- }
-
- // Otherwise, set the text track cue line position to the new value.
- if (m_linePosition == position)
- return;
-
- willChange();
- m_linePosition = position;
- m_computedLinePosition = calculateComputedLinePosition();
- didChange();
-}
-
-void TextTrackCue::setPosition(int position, ExceptionCode& ec)
-{
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-position
- // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception.
- // Otherwise, set the text track cue text position to the new value.
- if (position < 0 || position > 100) {
- ec = INDEX_SIZE_ERR;
- return;
- }
-
- // Otherwise, set the text track cue line position to the new value.
- if (m_textPosition == position)
- return;
-
- willChange();
- m_textPosition = position;
- didChange();
-}
-
-void TextTrackCue::setSize(int size, ExceptionCode& ec)
-{
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size
- // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError
- // exception. Otherwise, set the text track cue size to the new value.
- if (size < 0 || size > 100) {
- ec = INDEX_SIZE_ERR;
- return;
- }
-
- // Otherwise, set the text track cue line position to the new value.
- if (m_cueSize == size)
- return;
-
- willChange();
- m_cueSize = size;
- didChange();
-}
-
-const String& TextTrackCue::align() const
-{
- switch (m_cueAlignment) {
- case Start:
- return startKeyword();
- case Middle:
- return middleKeyword();
- case End:
- return endKeyword();
- default:
- ASSERT_NOT_REACHED();
- return emptyString();
- }
-}
-
-void TextTrackCue::setAlign(const String& value, ExceptionCode& ec)
-{
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-align
- // On setting, the text track cue alignment must be set to the value given in the
- // first cell of the row in the table above whose second cell is a case-sensitive
- // match for the new value, if any. If none of the values match, then the user
- // agent must instead throw a SyntaxError exception.
-
- CueAlignment alignment = m_cueAlignment;
- if (value == startKeyword())
- alignment = Start;
- else if (value == middleKeyword())
- alignment = Middle;
- else if (value == endKeyword())
- alignment = End;
- else
- ec = SYNTAX_ERR;
-
- if (alignment == m_cueAlignment)
- return;
-
- willChange();
- m_cueAlignment = alignment;
- didChange();
-}
-
-void TextTrackCue::setText(const String& text)
-{
- if (m_content == text)
- return;
-
- willChange();
- // Clear the document fragment but don't bother to create it again just yet as we can do that
- // when it is requested.
- m_webVTTNodeTree = 0;
- m_content = text;
- didChange();
-}
-
int TextTrackCue::cueIndex()
{
if (m_cueIndex == invalidCueIndex) {
m_cueIndex = invalidCueIndex;
}
-void TextTrackCue::createWebVTTNodeTree()
-{
- if (!m_webVTTNodeTree)
- m_webVTTNodeTree = WebVTTParser::create(0, &m_scriptExecutionContext)->createDocumentFragmentFromCueText(m_content);
-}
-
-void TextTrackCue::copyWebVTTNodeToDOMTree(ContainerNode* webVTTNode, ContainerNode* parent)
-{
- for (Node* node = webVTTNode->firstChild(); node; node = node->nextSibling()) {
- RefPtr<Node> clonedNode;
- if (node->isWebVTTElement())
- clonedNode = toWebVTTElement(node)->createEquivalentHTMLElement(ownerDocument());
- else
- clonedNode = node->cloneNode(false);
- parent->appendChild(clonedNode, ASSERT_NO_EXCEPTION);
- if (node->isContainerNode())
- copyWebVTTNodeToDOMTree(toContainerNode(node), toContainerNode(clonedNode.get()));
- }
-}
-
-PassRefPtr<DocumentFragment> TextTrackCue::getCueAsHTML()
-{
- createWebVTTNodeTree();
- if (!m_webVTTNodeTree)
- return 0;
-
- RefPtr<DocumentFragment> clonedFragment = DocumentFragment::create(ownerDocument());
- copyWebVTTNodeToDOMTree(m_webVTTNodeTree.get(), clonedFragment.get());
- return clonedFragment.release();
-}
-
-PassRefPtr<DocumentFragment> TextTrackCue::createCueRenderingTree()
-{
- RefPtr<DocumentFragment> clonedFragment;
- createWebVTTNodeTree();
- if (!m_webVTTNodeTree)
- return 0;
-
- clonedFragment = DocumentFragment::create(ownerDocument());
- m_webVTTNodeTree->cloneChildNodes(clonedFragment.get());
- return clonedFragment.release();
-}
-
bool TextTrackCue::dispatchEvent(PassRefPtr<Event> event)
{
// When a TextTrack's mode is disabled: no cues are active, no events fired.
return EventTarget::dispatchEvent(event);
}
-#if ENABLE(WEBVTT_REGIONS)
-void TextTrackCue::setRegionId(const String& regionId)
-{
- if (m_regionId == regionId)
- return;
-
- willChange();
- m_regionId = regionId;
- didChange();
-}
-#endif
-
bool TextTrackCue::isActive()
{
return m_isActive && track() && track()->mode() != TextTrack::disabledKeyword();
void TextTrackCue::setIsActive(bool active)
{
m_isActive = active;
-
- if (!active) {
- if (!hasDisplayTree())
- return;
-
- // Remove the display tree as soon as the cue becomes inactive.
- displayTreeInternal()->remove(ASSERT_NO_EXCEPTION);
- }
-}
-
-int TextTrackCue::calculateComputedLinePosition()
-{
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#text-track-cue-computed-line-position
-
- // If the text track cue line position is numeric, then that is the text
- // track cue computed line position.
- if (m_linePosition != undefinedPosition)
- return m_linePosition;
-
- // If the text track cue snap-to-lines flag of the text track cue is not
- // set, the text track cue computed line position is the value 100;
- if (!m_snapToLines)
- return 100;
-
- // Otherwise, it is the value returned by the following algorithm:
-
- // If cue is not associated with a text track, return -1 and abort these
- // steps.
- if (!track())
- return -1;
-
- // Let n be the number of text tracks whose text track mode is showing or
- // showing by default and that are in the media element's list of text
- // tracks before track.
- int n = track()->trackIndexRelativeToRenderedTracks();
-
- // Increment n by one.
- n++;
-
- // Negate n.
- n = -n;
-
- return n;
-}
-
-static bool isCueParagraphSeparator(UChar character)
-{
- // Within a cue, paragraph boundaries are only denoted by Type B characters,
- // such as U+000A LINE FEED (LF), U+0085 NEXT LINE (NEL), and U+2029 PARAGRAPH SEPARATOR.
- return u_charType(character) == U_PARAGRAPH_SEPARATOR;
-}
-
-void TextTrackCue::determineTextDirection()
-{
- DEFINE_STATIC_LOCAL(const String, rtTag, (ASCIILiteral("rt")));
- createWebVTTNodeTree();
- if (!m_webVTTNodeTree)
- return;
-
- // Apply the Unicode Bidirectional Algorithm's Paragraph Level steps to the
- // concatenation of the values of each WebVTT Text Object in nodes, in a
- // pre-order, depth-first traversal, excluding WebVTT Ruby Text Objects and
- // their descendants.
- StringBuilder paragraphBuilder;
- for (Node* node = m_webVTTNodeTree->firstChild(); node; node = NodeTraversal::next(node, m_webVTTNodeTree.get())) {
- // FIXME: The code does not match the comment above. This does not actually exclude Ruby Text Object descendant.
- if (!node->isTextNode() || node->localName() == rtTag)
- continue;
-
- paragraphBuilder.append(node->nodeValue());
- }
-
- String paragraph = paragraphBuilder.toString();
- if (!paragraph.length())
- return;
-
- for (size_t i = 0; i < paragraph.length(); ++i) {
- UChar current = paragraph[i];
- if (!current || isCueParagraphSeparator(current))
- return;
-
- if (UChar current = paragraph[i]) {
- UCharDirection charDirection = u_charDirection(current);
- if (charDirection == U_LEFT_TO_RIGHT) {
- m_displayDirection = CSSValueLtr;
- return;
- }
- if (charDirection == U_RIGHT_TO_LEFT || charDirection == U_RIGHT_TO_LEFT_ARABIC) {
- m_displayDirection = CSSValueRtl;
- return;
- }
- }
- }
-}
-
-void TextTrackCue::calculateDisplayParameters()
-{
- // Steps 10.2, 10.3
- determineTextDirection();
-
- // 10.4 If the text track cue writing direction is horizontal, then let
- // block-flow be 'tb'. Otherwise, if the text track cue writing direction is
- // vertical growing left, then let block-flow be 'lr'. Otherwise, the text
- // track cue writing direction is vertical growing right; let block-flow be
- // 'rl'.
- m_displayWritingMode = m_displayWritingModeMap[m_writingDirection];
-
- // 10.5 Determine the value of maximum size for cue as per the appropriate
- // rules from the following list:
- int maximumSize = m_textPosition;
- if ((m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueLtr)
- || (m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueRtl)
- || (m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Start)
- || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Start)) {
- maximumSize = 100 - m_textPosition;
- } else if ((m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueLtr)
- || (m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueRtl)
- || (m_writingDirection == VerticalGrowingLeft && m_cueAlignment == End)
- || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == End)) {
- maximumSize = m_textPosition;
- } else if (m_cueAlignment == Middle) {
- maximumSize = m_textPosition <= 50 ? m_textPosition : (100 - m_textPosition);
- maximumSize = maximumSize * 2;
- }
-
- // 10.6 If the text track cue size is less than maximum size, then let size
- // be text track cue size. Otherwise, let size be maximum size.
- m_displaySize = std::min(m_cueSize, maximumSize);
-
- // 10.8 Determine the value of x-position or y-position for cue as per the
- // appropriate rules from the following list:
- if (m_writingDirection == Horizontal) {
- if (m_cueAlignment == Start) {
- if (m_displayDirection == CSSValueLtr)
- m_displayPosition.first = m_textPosition;
- else
- m_displayPosition.first = 100 - m_textPosition - m_displaySize;
- } else if (m_cueAlignment == End) {
- if (m_displayDirection == CSSValueRtl)
- m_displayPosition.first = 100 - m_textPosition;
- else
- m_displayPosition.first = m_textPosition - m_displaySize;
- }
- }
-
- if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Start)
- || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Start)) {
- m_displayPosition.second = m_textPosition;
- } else if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == End)
- || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == End)) {
- m_displayPosition.second = 100 - m_textPosition;
- }
-
- if (m_writingDirection == Horizontal && m_cueAlignment == Middle) {
- if (m_displayDirection == CSSValueLtr)
- m_displayPosition.first = m_textPosition - m_displaySize / 2;
- else
- m_displayPosition.first = 100 - m_textPosition - m_displaySize / 2;
- }
-
- if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Middle)
- || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Middle))
- m_displayPosition.second = m_textPosition - m_displaySize / 2;
-
- // 10.9 Determine the value of whichever of x-position or y-position is not
- // yet calculated for cue as per the appropriate rules from the following
- // list:
- if (m_snapToLines && m_displayPosition.second == undefinedPosition && m_writingDirection == Horizontal)
- m_displayPosition.second = 0;
-
- if (!m_snapToLines && m_displayPosition.second == undefinedPosition && m_writingDirection == Horizontal)
- m_displayPosition.second = m_computedLinePosition;
-
- if (m_snapToLines && m_displayPosition.first == undefinedPosition
- && (m_writingDirection == VerticalGrowingLeft || m_writingDirection == VerticalGrowingRight))
- m_displayPosition.first = 0;
-
- if (!m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writingDirection == VerticalGrowingRight))
- m_displayPosition.first = m_computedLinePosition;
-
- // A text track cue has a text track cue computed line position whose value
- // is defined in terms of the other aspects of the cue.
- m_computedLinePosition = calculateComputedLinePosition();
-}
-
-void TextTrackCue::markFutureAndPastNodes(ContainerNode* root, double previousTimestamp, double movieTime)
-{
- DEFINE_STATIC_LOCAL(const String, timestampTag, (ASCIILiteral("timestamp")));
-
- bool isPastNode = true;
- double currentTimestamp = previousTimestamp;
- if (currentTimestamp > movieTime)
- isPastNode = false;
-
- for (Node* child = root->firstChild(); child; child = NodeTraversal::next(child, root)) {
- if (child->nodeName() == timestampTag) {
- unsigned position = 0;
- String timestamp = child->nodeValue();
- double currentTimestamp = WebVTTParser::create(0, &m_scriptExecutionContext)->collectTimeStamp(timestamp, &position);
- ASSERT(currentTimestamp != -1);
-
- if (currentTimestamp > movieTime)
- isPastNode = false;
- }
-
- if (child->isWebVTTElement()) {
- toWebVTTElement(child)->setIsPastNode(isPastNode);
- // Make an elemenet id match a cue id for style matching purposes.
- if (!m_id.isEmpty())
- toElement(child)->setIdAttribute(m_id);
- }
- }
-}
-
-void TextTrackCue::updateDisplayTree(double movieTime)
-{
- // The display tree may contain WebVTT timestamp objects representing
- // timestamps (processing instructions), along with displayable nodes.
-
- if (!track()->isRendered())
- return;
-
- // Clear the contents of the set.
- m_cueBackgroundBox->removeChildren();
-
- // Update the two sets containing past and future WebVTT objects.
- RefPtr<DocumentFragment> referenceTree = createCueRenderingTree();
- if (!referenceTree)
- return;
-
- markFutureAndPastNodes(referenceTree.get(), startTime(), movieTime);
- m_cueBackgroundBox->appendChild(referenceTree);
-}
-
-TextTrackCueBox* TextTrackCue::getDisplayTree(const IntSize& videoSize)
-{
- RefPtr<TextTrackCueBox> displayTree = displayTreeInternal();
- if (!m_displayTreeShouldChange || !track()->isRendered())
- return displayTree.get();
-
- // 10.1 - 10.10
- calculateDisplayParameters();
-
- // 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:
- 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.
-
- // Note: This is contained by default in m_cueBackgroundBox.
- m_cueBackgroundBox->setPseudo(cueShadowPseudoId());
- displayTree->appendChild(m_cueBackgroundBox, ASSERT_NO_EXCEPTION);
-
- // 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.)
- displayTree->applyCSSProperties(videoSize);
-
- m_displayTreeShouldChange = false;
-
- // 10.15. Let cue's text track cue display state have the CSS boxes in
- // boxes.
- return displayTree.get();
-}
-
-void TextTrackCue::removeDisplayTree()
-{
- if (!hasDisplayTree())
- return;
- displayTreeInternal()->remove(ASSERT_NO_EXCEPTION);
-}
-
-std::pair<double, double> TextTrackCue::getPositionCoordinates() const
-{
- // This method is used for setting x and y when snap to lines is not set.
- std::pair<double, double> coordinates;
-
- if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) {
- coordinates.first = m_textPosition;
- coordinates.second = m_computedLinePosition;
-
- return coordinates;
- }
-
- if (m_writingDirection == Horizontal && m_displayDirection == CSSValueRtl) {
- coordinates.first = 100 - m_textPosition;
- coordinates.second = m_computedLinePosition;
-
- return coordinates;
- }
-
- if (m_writingDirection == VerticalGrowingLeft) {
- coordinates.first = 100 - m_computedLinePosition;
- coordinates.second = m_textPosition;
-
- return coordinates;
- }
-
- if (m_writingDirection == VerticalGrowingRight) {
- coordinates.first = m_computedLinePosition;
- coordinates.second = m_textPosition;
-
- return coordinates;
- }
-
- ASSERT_NOT_REACHED();
-
- return coordinates;
-}
-
-TextTrackCue::CueSetting TextTrackCue::settingName(const String& name)
-{
- DEFINE_STATIC_LOCAL(const String, verticalKeyword, (ASCIILiteral("vertical")));
- DEFINE_STATIC_LOCAL(const String, lineKeyword, (ASCIILiteral("line")));
- DEFINE_STATIC_LOCAL(const String, positionKeyword, (ASCIILiteral("position")));
- DEFINE_STATIC_LOCAL(const String, sizeKeyword, (ASCIILiteral("size")));
- DEFINE_STATIC_LOCAL(const String, alignKeyword, (ASCIILiteral("align")));
-#if ENABLE(WEBVTT_REGIONS)
- DEFINE_STATIC_LOCAL(const String, regionIdKeyword, (ASCIILiteral("region")));
-#endif
-
- if (name == verticalKeyword)
- return Vertical;
- else if (name == lineKeyword)
- return Line;
- else if (name == positionKeyword)
- return Position;
- else if (name == sizeKeyword)
- return Size;
- else if (name == alignKeyword)
- return Align;
-#if ENABLE(WEBVTT_REGIONS)
- else if (name == regionIdKeyword)
- return RegionId;
-#endif
-
- return None;
-}
-
-void TextTrackCue::setCueSettings(const String& input)
-{
- m_settings = input;
- unsigned position = 0;
-
- while (position < input.length()) {
-
- // The WebVTT cue settings part of a WebVTT cue consists of zero or more of the following components, in any order,
- // separated from each other by one or more U+0020 SPACE characters or U+0009 CHARACTER TABULATION (tab) characters.
- while (position < input.length() && WebVTTParser::isValidSettingDelimiter(input[position]))
- position++;
- if (position >= input.length())
- break;
-
- // When the user agent is to parse the WebVTT settings given by a string input for a text track cue cue,
- // the user agent must run the following steps:
- // 1. Let settings be the result of splitting input on spaces.
- // 2. For each token setting in the list settings, run the following substeps:
- // 1. If setting does not contain a U+003A COLON character (:), or if the first U+003A COLON character (:)
- // in setting is either the first or last character of setting, then jump to the step labeled next setting.
- unsigned endOfSetting = position;
- String setting = WebVTTParser::collectWord(input, &endOfSetting);
- CueSetting name;
- size_t colonOffset = setting.find(':', 1);
- if (colonOffset == notFound || colonOffset == 0 || colonOffset == setting.length() - 1)
- goto NextSetting;
-
- // 2. Let name be the leading substring of setting up to and excluding the first U+003A COLON character (:) in that string.
- name = settingName(setting.substring(0, colonOffset));
-
- // 3. Let value be the trailing substring of setting starting from the character immediately after the first U+003A COLON character (:) in that string.
- position += colonOffset + 1;
- if (position >= input.length())
- break;
-
- // 4. Run the appropriate substeps that apply for the value of name, as follows:
- switch (name) {
- case Vertical:
- {
- // If name is a case-sensitive match for "vertical"
- // 1. If value is a case-sensitive match for the string "rl", then let cue's text track cue writing direction
- // be vertical growing left.
- String writingDirection = WebVTTParser::collectWord(input, &position);
- if (writingDirection == verticalGrowingLeftKeyword())
- m_writingDirection = VerticalGrowingLeft;
-
- // 2. Otherwise, if value is a case-sensitive match for the string "lr", then let cue's text track cue writing
- // direction be vertical growing right.
- else if (writingDirection == verticalGrowingRightKeyword())
- m_writingDirection = VerticalGrowingRight;
- }
- break;
- case Line:
- {
- // 1-2 - Collect chars that are either '-', '%', or a digit.
- // 1. If value contains any characters other than U+002D HYPHEN-MINUS characters (-), U+0025 PERCENT SIGN
- // characters (%), and characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump
- // to the step labeled next setting.
- StringBuilder linePositionBuilder;
- while (position < input.length() && (input[position] == '-' || input[position] == '%' || isASCIIDigit(input[position])))
- linePositionBuilder.append(input[position++]);
- if (position < input.length() && !WebVTTParser::isValidSettingDelimiter(input[position]))
- break;
-
- // 2. If value does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
- // NINE (9), then jump to the step labeled next setting.
- // 3. If any character in value other than the first character is a U+002D HYPHEN-MINUS character (-), then
- // jump to the step labeled next setting.
- // 4. If any character in value other than the last character is a U+0025 PERCENT SIGN character (%), then
- // jump to the step labeled next setting.
- String linePosition = linePositionBuilder.toString();
- if (linePosition.find('-', 1) != notFound || linePosition.reverseFind("%", linePosition.length() - 2) != notFound)
- break;
-
- // 5. If the first character in value is a U+002D HYPHEN-MINUS character (-) and the last character in value is a
- // U+0025 PERCENT SIGN character (%), then jump to the step labeled next setting.
- if (linePosition[0] == '-' && linePosition[linePosition.length() - 1] == '%')
- break;
-
- // 6. Ignoring the trailing percent sign, if any, interpret value as a (potentially signed) integer, and
- // let number be that number.
- // NOTE: toInt ignores trailing non-digit characters, such as '%'.
- bool validNumber;
- int number = linePosition.toInt(&validNumber);
- if (!validNumber)
- break;
-
- // 7. If the last character in value is a U+0025 PERCENT SIGN character (%), but number is not in the range
- // 0 ≤ number ≤ 100, then jump to the step labeled next setting.
- // 8. Let cue's text track cue line position be number.
- // 9. If the last character in value is a U+0025 PERCENT SIGN character (%), then let cue's text track cue
- // snap-to-lines flag be false. Otherwise, let it be true.
- if (linePosition[linePosition.length() - 1] == '%') {
- if (number < 0 || number > 100)
- break;
-
- // 10 - If '%' then set snap-to-lines flag to false.
- m_snapToLines = false;
- }
-
- m_linePosition = number;
- }
- break;
- case Position:
- {
- // 1. If value contains any characters other than U+0025 PERCENT SIGN characters (%) and characters in the range
- // U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump to the step labeled next setting.
- // 2. If value does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9),
- // then jump to the step labeled next setting.
- String textPosition = WebVTTParser::collectDigits(input, &position);
- if (textPosition.isEmpty())
- break;
- if (position >= input.length())
- break;
-
- // 3. If any character in value other than the last character is a U+0025 PERCENT SIGN character (%), then jump
- // to the step labeled next setting.
- // 4. If the last character in value is not a U+0025 PERCENT SIGN character (%), then jump to the step labeled
- // next setting.
- if (input[position++] != '%')
- break;
- if (position < input.length() && !WebVTTParser::isValidSettingDelimiter(input[position]))
- break;
-
- // 5. Ignoring the trailing percent sign, interpret value as an integer, and let number be that number.
- // 6. If number is not in the range 0 ≤ number ≤ 100, then jump to the step labeled next setting.
- // NOTE: toInt ignores trailing non-digit characters, such as '%'.
- bool validNumber;
- int number = textPosition.toInt(&validNumber);
- if (!validNumber)
- break;
- if (number < 0 || number > 100)
- break;
-
- // 7. Let cue's text track cue text position be number.
- m_textPosition = number;
- }
- break;
- case Size:
- {
- // 1. If value contains any characters other than U+0025 PERCENT SIGN characters (%) and characters in the
- // range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump to the step labeled next setting.
- // 2. If value does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
- // NINE (9), then jump to the step labeled next setting.
- String cueSize = WebVTTParser::collectDigits(input, &position);
- if (cueSize.isEmpty())
- break;
- if (position >= input.length())
- break;
-
- // 3. If any character in value other than the last character is a U+0025 PERCENT SIGN character (%),
- // then jump to the step labeled next setting.
- // 4. If the last character in value is not a U+0025 PERCENT SIGN character (%), then jump to the step
- // labeled next setting.
- if (input[position++] != '%')
- break;
- if (position < input.length() && !WebVTTParser::isValidSettingDelimiter(input[position]))
- break;
-
- // 5. Ignoring the trailing percent sign, interpret value as an integer, and let number be that number.
- // 6. If number is not in the range 0 ≤ number ≤ 100, then jump to the step labeled next setting.
- bool validNumber;
- int number = cueSize.toInt(&validNumber);
- if (!validNumber)
- break;
- if (number < 0 || number > 100)
- break;
-
- // 7. Let cue's text track cue size be number.
- m_cueSize = number;
- }
- break;
- case Align:
- {
- String cueAlignment = WebVTTParser::collectWord(input, &position);
-
- // 1. If value is a case-sensitive match for the string "start", then let cue's text track cue alignment be start alignment.
- if (cueAlignment == startKeyword())
- m_cueAlignment = Start;
-
- // 2. If value is a case-sensitive match for the string "middle", then let cue's text track cue alignment be middle alignment.
- else if (cueAlignment == middleKeyword())
- m_cueAlignment = Middle;
-
- // 3. If value is a case-sensitive match for the string "end", then let cue's text track cue alignment be end alignment.
- else if (cueAlignment == endKeyword())
- m_cueAlignment = End;
- }
- break;
-#if ENABLE(WEBVTT_REGIONS)
- case RegionId:
- m_regionId = WebVTTParser::collectWord(input, &position);
- break;
-#endif
- case None:
- break;
- }
-
-NextSetting:
- position = endOfSetting;
- }
-#if ENABLE(WEBVTT_REGIONS)
- // If cue's line position is not auto or cue's size is not 100 or cue's
- // writing direction is not horizontal, but cue's region identifier is not
- // the empty string, let cue's region identifier be the empty string.
- if (m_regionId.isEmpty())
- return;
-
- if (m_linePosition != undefinedPosition || m_cueSize != 100 || m_writingDirection != Horizontal)
- m_regionId = emptyString();
-#endif
-}
-
-CSSValueID TextTrackCue::getCSSWritingDirection() const
-{
- return m_displayDirection;
-}
-
-CSSValueID TextTrackCue::getCSSWritingMode() const
-{
- return m_displayWritingMode;
-}
-
-int TextTrackCue::getCSSSize() const
-{
- return m_displaySize;
-}
-
-std::pair<double, double> TextTrackCue::getCSSPosition() const
-{
- if (!m_snapToLines)
- return getPositionCoordinates();
-
- return m_displayPosition;
-}
-
-bool TextTrackCue::isEqual(const TextTrackCue& cue, CueMatchRules match) const
-{
- if (cueType() != cue.cueType())
- return false;
-
- if (match != IgnoreDuration && m_endTime != cue.endTime())
- return false;
- if (m_startTime != cue.startTime())
- return false;
- if (m_content != cue.text())
- return false;
- if (m_settings != cue.cueSettings())
- return false;
- if (m_id != cue.id())
- return false;
- if (m_textPosition != cue.position())
- return false;
- if (m_linePosition != cue.line())
- return false;
- if (m_cueSize != cue.size())
- return false;
- if (align() != cue.align())
- return false;
-
- return true;
}
bool TextTrackCue::isOrderedBefore(const TextTrackCue* other) const
return startTime() < other->startTime() || (startTime() == other->startTime() && endTime() > other->endTime());
}
-void TextTrackCue::setFontSize(int fontSize, const IntSize&, bool important)
-{
- if (!hasDisplayTree() || !fontSize)
- return;
-
- LOG(Media, "TextTrackCue::setFontSize - setting cue font size to %i", fontSize);
-
- displayTreeInternal()->setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX, important);
-}
-
} // namespace WebCore
#endif
namespace WebCore {
-class DocumentFragment;
-class HTMLSpanElement;
-class ScriptExecutionContext;
class TextTrack;
-class TextTrackCue;
-
-// ----------------------------
-
-class TextTrackCueBox : public HTMLElement {
-public:
- static PassRefPtr<TextTrackCueBox> create(Document& document, TextTrackCue* cue)
- {
- return adoptRef(new TextTrackCueBox(document, cue));
- }
-
- TextTrackCue* getCue() const;
- virtual void applyCSSProperties(const IntSize& videoSize);
-
- static const AtomicString& textTrackCueBoxShadowPseudoId();
-
-protected:
- TextTrackCueBox(Document&, TextTrackCue*);
-
- virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override;
-
- TextTrackCue* m_cue;
-};
-
-// ----------------------------
class TextTrackCue : public RefCounted<TextTrackCue>, public EventTargetWithInlineData {
public:
- static PassRefPtr<TextTrackCue> create(ScriptExecutionContext& context, double start, double end, const String& content)
- {
- return adoptRef(new TextTrackCue(context, start, end, content));
- }
+ static PassRefPtr<TextTrackCue> create(ScriptExecutionContext&, double start, double end, const String& content);
static const AtomicString& cueShadowPseudoId()
{
bool pauseOnExit() const { return m_pauseOnExit; }
void setPauseOnExit(bool);
- const String& vertical() const;
- void setVertical(const String&, ExceptionCode&);
-
- bool snapToLines() const { return m_snapToLines; }
- void setSnapToLines(bool);
-
- int line() const { return m_linePosition; }
- virtual void setLine(int, ExceptionCode&);
-
- int position() const { return m_textPosition; }
- virtual void setPosition(int, ExceptionCode&);
-
- int size() const { return m_cueSize; }
- virtual void setSize(int, ExceptionCode&);
-
- const String& align() const;
- void setAlign(const String&, ExceptionCode&);
-
- const String& text() const { return m_content; }
- void setText(const String&);
-
- const String& cueSettings() const { return m_settings; }
- void setCueSettings(const String&);
-
int cueIndex();
void invalidateCueIndex();
- PassRefPtr<DocumentFragment> getCueAsHTML();
- PassRefPtr<DocumentFragment> createCueRenderingTree();
-
using EventTarget::dispatchEvent;
virtual bool dispatchEvent(PassRefPtr<Event>) override;
-#if ENABLE(WEBVTT_REGIONS)
- const String& regionId() const { return m_regionId; }
- void setRegionId(const String&);
-#endif
-
bool isActive();
- void setIsActive(bool);
-
- bool hasDisplayTree() const { return m_displayTree; }
- TextTrackCueBox* getDisplayTree(const IntSize& videoSize);
- HTMLSpanElement* element() const { return m_cueBackgroundBox.get(); }
-
- void updateDisplayTree(double);
- void removeDisplayTree();
- void markFutureAndPastNodes(ContainerNode*, double, double);
-
- int calculateComputedLinePosition();
- std::pair<double, double> getPositionCoordinates() const;
+ virtual void setIsActive(bool);
virtual EventTargetInterface eventTargetInterface() const override final { return TextTrackCueEventTargetInterfaceType; }
virtual ScriptExecutionContext* scriptExecutionContext() const override final { return &m_scriptExecutionContext; }
- std::pair<double, double> getCSSPosition() const;
-
- int getCSSSize() const;
- CSSValueID getCSSWritingDirection() const;
- CSSValueID getCSSWritingMode() const;
-
- enum WritingDirection {
- Horizontal,
- VerticalGrowingLeft,
- VerticalGrowingRight,
- NumberOfWritingDirections
- };
- WritingDirection getWritingDirection() const { return m_writingDirection; }
-
- enum CueAlignment {
- Start,
- Middle,
- End
- };
- CueAlignment getAlignment() const { return m_cueAlignment; }
-
- virtual void setFontSize(int, const IntSize&, bool important);
-
- enum CueMatchRules {
- MatchAllFields,
- IgnoreDuration,
- };
- virtual bool isEqual(const TextTrackCue&, CueMatchRules) const;
-
virtual bool isOrderedBefore(const TextTrackCue*) const;
enum CueType {
Generic,
WebVTT
};
- virtual CueType cueType() const { return WebVTT; }
+ virtual CueType cueType() const = 0;
+ virtual bool isRenderable() const { return false; }
void willChange();
- void didChange();
-
+ virtual void didChange();
+
DEFINE_ATTRIBUTE_EVENT_LISTENER(enter);
DEFINE_ATTRIBUTE_EVENT_LISTENER(exit);
using RefCounted<TextTrackCue>::deref;
protected:
- TextTrackCue(ScriptExecutionContext&, double start, double end, const String& content);
+ TextTrackCue(ScriptExecutionContext&, double start, double end);
Document& ownerDocument() { return toDocument(m_scriptExecutionContext); }
- virtual PassRefPtr<TextTrackCueBox> createDisplayTree();
- TextTrackCueBox* displayTreeInternal();
-
private:
- void createWebVTTNodeTree();
- void copyWebVTTNodeToDOMTree(ContainerNode* WebVTTNode, ContainerNode* root);
-
- void parseSettings(const String&);
-
- void determineTextDirection();
- void calculateDisplayParameters();
virtual void refEventTarget() override final { ref(); }
virtual void derefEventTarget() override final { deref(); }
- enum CueSetting {
- None,
- Vertical,
- Line,
- Position,
- Size,
- Align,
-#if ENABLE(WEBVTT_REGIONS)
- RegionId
-#endif
- };
- CueSetting settingName(const String&);
-
String m_id;
double m_startTime;
double m_endTime;
- String m_content;
- String m_settings;
- int m_linePosition;
- int m_computedLinePosition;
- int m_textPosition;
- int m_cueSize;
int m_cueIndex;
int m_processingCueChanges;
- WritingDirection m_writingDirection;
-
- CueAlignment m_cueAlignment;
-
- RefPtr<DocumentFragment> m_webVTTNodeTree;
TextTrack* m_track;
ScriptExecutionContext& m_scriptExecutionContext;
bool m_isActive;
bool m_pauseOnExit;
- bool m_snapToLines;
-
- RefPtr<HTMLSpanElement> m_cueBackgroundBox;
-
- bool m_displayTreeShouldChange;
- RefPtr<TextTrackCueBox> m_displayTree;
-
- CSSValueID m_displayDirection;
-
- CSSValueID m_displayWritingModeMap[NumberOfWritingDirections];
- CSSValueID m_displayWritingMode;
-
- int m_displaySize;
-
- std::pair<float, float> m_displayPosition;
-#if ENABLE(WEBVTT_REGIONS)
- String m_regionId;
-#endif
};
} // namespace WebCore
EventTarget,
JSCustomMarkFunction,
CustomIsReachable,
+ CustomToJSObject,
SkipVTableValidation,
] interface TextTrackCue {
readonly attribute TextTrack track;
[SetterRaisesException] attribute double endTime;
attribute boolean pauseOnExit;
- [SetterRaisesException] attribute DOMString vertical;
- attribute boolean snapToLines;
- [SetterRaisesException] attribute long line;
- [SetterRaisesException] attribute long position;
- [SetterRaisesException] attribute long size;
- [SetterRaisesException] attribute DOMString align;
-
- attribute DOMString text;
- DocumentFragment getCueAsHTML();
-
attribute EventListener onenter;
attribute EventListener onexit;
EventListener listener,
optional boolean useCapture);
[RaisesException] boolean dispatchEvent(Event evt);
-
-#if defined(ENABLE_WEBVTT_REGIONS) && ENABLE_WEBVTT_REGIONS
- attribute DOMString regionId;
-#endif
};
namespace WebCore {
-class TextTrackCueGenericBoxElement final : public TextTrackCueBox {
+class TextTrackCueGenericBoxElement final : public VTTCueBox {
public:
static PassRefPtr<TextTrackCueGenericBoxElement> create(Document& document, TextTrackCueGeneric* cue)
{
virtual void applyCSSProperties(const IntSize&) override;
private:
- TextTrackCueGenericBoxElement(Document&, TextTrackCue*);
+ TextTrackCueGenericBoxElement(Document&, VTTCue*);
};
-TextTrackCueGenericBoxElement::TextTrackCueGenericBoxElement(Document& document, TextTrackCue* cue)
- : TextTrackCueBox(document, cue)
+TextTrackCueGenericBoxElement::TextTrackCueGenericBoxElement(Document& document, VTTCue* cue)
+ : VTTCueBox(document, cue)
{
}
setInlineStyleProperty(CSSPropertyLeft, static_cast<float>(cue->position()), CSSPrimitiveValue::CSS_PERCENTAGE);
setInlineStyleProperty(CSSPropertyTop, static_cast<float>(cue->line()), CSSPrimitiveValue::CSS_PERCENTAGE);
- if (cue->getWritingDirection() == TextTrackCue::Horizontal)
+ if (cue->getWritingDirection() == VTTCue::Horizontal)
setInlineStyleProperty(CSSPropertyWidth, size, CSSPrimitiveValue::CSS_PERCENTAGE);
else
setInlineStyleProperty(CSSPropertyHeight, size, CSSPrimitiveValue::CSS_PERCENTAGE);
if (cue->highlightColor().isValid())
cueElement->setInlineStyleProperty(CSSPropertyBackgroundColor, cue->highlightColor().serialized());
- if (cue->getWritingDirection() == TextTrackCue::Horizontal)
+ if (cue->getWritingDirection() == VTTCue::Horizontal)
setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto);
else
setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto);
if (cue->baseFontSizeRelativeToVideoHeight())
cue->setFontSize(cue->baseFontSizeRelativeToVideoHeight(), videoSize, false);
- if (cue->getAlignment() == TextTrackCue::Middle)
+ if (cue->getAlignment() == VTTCue::Middle)
setInlineStyleProperty(CSSPropertyTextAlign, CSSValueCenter);
- else if (cue->getAlignment() == TextTrackCue::End)
+ else if (cue->getAlignment() == VTTCue::End)
setInlineStyleProperty(CSSPropertyTextAlign, CSSValueEnd);
else
setInlineStyleProperty(CSSPropertyTextAlign, CSSValueStart);
}
TextTrackCueGeneric::TextTrackCueGeneric(ScriptExecutionContext& context, double start, double end, const String& content)
- : TextTrackCue(context, start, end, content)
+ : VTTCue(context, start, end, content)
, m_baseFontSizeRelativeToVideoHeight(0)
, m_fontSizeMultiplier(0)
, m_defaultPosition(true)
{
}
-PassRefPtr<TextTrackCueBox> TextTrackCueGeneric::createDisplayTree()
+PassRefPtr<VTTCueBox> TextTrackCueGeneric::createDisplayTree()
{
return TextTrackCueGenericBoxElement::create(ownerDocument(), this);
}
void TextTrackCueGeneric::setLine(int line, ExceptionCode& ec)
{
m_defaultPosition = false;
- TextTrackCue::setLine(line, ec);
+ VTTCue::setLine(line, ec);
}
void TextTrackCueGeneric::setPosition(int position, ExceptionCode& ec)
{
m_defaultPosition = false;
- TextTrackCue::setPosition(position, ec);
+ VTTCue::setPosition(position, ec);
}
void TextTrackCueGeneric::setFontSize(int fontSize, const IntSize& videoSize, bool important)
return;
if (important || !baseFontSizeRelativeToVideoHeight()) {
- TextTrackCue::setFontSize(fontSize, videoSize, important);
+ VTTCue::setFontSize(fontSize, videoSize, important);
return;
}
LOG(Media, "TextTrackCueGeneric::setFontSize - setting cue font size to %li", lround(size));
}
-bool TextTrackCueGeneric::isEqual(const TextTrackCue& cue, TextTrackCue::CueMatchRules match) const
+bool TextTrackCueGeneric::isEqual(const VTTCue& cue, VTTCue::CueMatchRules match) const
{
if (cue.cueType() != TextTrackCue::Generic)
return false;
if (m_backgroundColor != other->backgroundColor())
return false;
- return TextTrackCue::isEqual(cue, match);
+ return VTTCue::isEqual(cue, match);
}
bool TextTrackCueGeneric::isOrderedBefore(const TextTrackCue* that) const
{
- if (TextTrackCue::isOrderedBefore(that))
+ if (VTTCue::isOrderedBefore(that))
return true;
if (that->cueType() == Generic && startTime() == that->startTime() && endTime() == that->endTime()) {
// Further order generic cues by their calculated line value.
std::pair<double, double> thisPosition = getPositionCoordinates();
- std::pair<double, double> thatPosition = that->getPositionCoordinates();
+ std::pair<double, double> thatPosition = toVTTCue(that)->getPositionCoordinates();
return thisPosition.second > thatPosition.second || (thisPosition.second == thatPosition.second && thisPosition.first < thatPosition.first);
}
#if ENABLE(VIDEO_TRACK)
#include "Color.h"
-#include "TextTrackCue.h"
+#include "VTTCue.h"
namespace WebCore {
class GenericCueData;
// A "generic" cue is a non-WebVTT cue, so it is not positioned/sized with the WebVTT logic.
-class TextTrackCueGeneric final : public TextTrackCue {
+class TextTrackCueGeneric final : public VTTCue {
public:
static PassRefPtr<TextTrackCueGeneric> create(ScriptExecutionContext& context, double start, double end, const String& content)
{
virtual ~TextTrackCueGeneric() { }
- virtual PassRefPtr<TextTrackCueBox> createDisplayTree() override;
+ virtual PassRefPtr<VTTCueBox> createDisplayTree() override;
virtual void setLine(int, ExceptionCode&) override;
virtual void setPosition(int, ExceptionCode&) override;
virtual void setFontSize(int, const IntSize&, bool important) override;
- virtual bool isEqual(const TextTrackCue&, CueMatchRules) const override;
+ virtual bool isEqual(const VTTCue&, CueMatchRules) const override;
virtual TextTrackCue::CueType cueType() const override { return TextTrackCue::Generic; }
--- /dev/null
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(VIDEO_TRACK)
+#include "VTTCue.h"
+
+#include "CSSPropertyNames.h"
+#include "CSSValueKeywords.h"
+#include "DocumentFragment.h"
+#include "Event.h"
+#include "HTMLDivElement.h"
+#include "HTMLSpanElement.h"
+#include "Logging.h"
+#include "NodeTraversal.h"
+#include "RenderVTTCue.h"
+#include "Text.h"
+#include "TextTrack.h"
+#include "TextTrackCueList.h"
+#include "WebVTTElement.h"
+#include "WebVTTParser.h"
+#include <wtf/MathExtras.h>
+#include <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+static const int undefinedPosition = -1;
+
+static const String& startKeyword()
+{
+ DEFINE_STATIC_LOCAL(const String, start, (ASCIILiteral("start")));
+ return start;
+}
+
+static const String& middleKeyword()
+{
+ DEFINE_STATIC_LOCAL(const String, middle, (ASCIILiteral("middle")));
+ return middle;
+}
+
+static const String& endKeyword()
+{
+ DEFINE_STATIC_LOCAL(const String, end, (ASCIILiteral("end")));
+ return end;
+}
+
+static const String& horizontalKeyword()
+{
+ return emptyString();
+}
+
+static const String& verticalGrowingLeftKeyword()
+{
+ DEFINE_STATIC_LOCAL(const String, verticalrl, (ASCIILiteral("rl")));
+ return verticalrl;
+}
+
+static const String& verticalGrowingRightKeyword()
+{
+ DEFINE_STATIC_LOCAL(const String, verticallr, (ASCIILiteral("lr")));
+ return verticallr;
+}
+
+// ----------------------------
+
+VTTCueBox::VTTCueBox(Document& document, VTTCue* cue)
+ : HTMLElement(divTag, document)
+ , m_cue(cue)
+{
+ setPseudo(vttCueBoxShadowPseudoId());
+}
+
+VTTCue* VTTCueBox::getCue() const
+{
+ return m_cue;
+}
+
+void VTTCueBox::applyCSSProperties(const IntSize&)
+{
+ // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79916
+
+ // 3.5.1 On the (root) List of WebVTT Node Objects:
+
+ // the 'position' property must be set to 'absolute'
+ setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
+
+ // the 'unicode-bidi' property must be set to 'plaintext'
+ setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueWebkitPlaintext);
+
+ // the 'direction' property must be set to direction
+ setInlineStyleProperty(CSSPropertyDirection, m_cue->getCSSWritingDirection());
+
+ // the 'writing-mode' property must be set to writing-mode
+ setInlineStyleProperty(CSSPropertyWebkitWritingMode, m_cue->getCSSWritingMode(), false);
+
+ std::pair<float, float> position = m_cue->getCSSPosition();
+
+ // the 'top' property must be set to top,
+ setInlineStyleProperty(CSSPropertyTop, static_cast<double>(position.second), CSSPrimitiveValue::CSS_PERCENTAGE);
+
+ // the 'left' property must be set to left
+ setInlineStyleProperty(CSSPropertyLeft, static_cast<double>(position.first), CSSPrimitiveValue::CSS_PERCENTAGE);
+
+ // the 'width' property must be set to width, and the 'height' property must be set to height
+ if (m_cue->vertical() == horizontalKeyword()) {
+ setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue->getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
+ setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto);
+ } else {
+ setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto);
+ setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue->getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
+ }
+
+ // The 'text-align' property on the (root) List of WebVTT Node Objects must
+ // be set to the value in the second cell of the row of the table below
+ // whose first cell is the value of the corresponding cue's text track cue
+ // alignment:
+ if (m_cue->align() == startKeyword())
+ setInlineStyleProperty(CSSPropertyTextAlign, CSSValueStart);
+ else if (m_cue->align() == endKeyword())
+ setInlineStyleProperty(CSSPropertyTextAlign, CSSValueEnd);
+ else
+ setInlineStyleProperty(CSSPropertyTextAlign, CSSValueCenter);
+
+ if (!m_cue->snapToLines()) {
+ // 10.13.1 Set up x and y:
+ // Note: x and y are set through the CSS left and top above.
+
+ // 10.13.2 Position the boxes in boxes such that the point x% along the
+ // width of the bounding box of the boxes in boxes is x% of the way
+ // across the width of the video's rendering area, and the point y%
+ // along the height of the bounding box of the boxes in boxes is y%
+ // of the way across the height of the video's rendering area, while
+ // maintaining the relative positions of the boxes in boxes to each
+ // other.
+ setInlineStyleProperty(CSSPropertyWebkitTransform,
+ String::format("translate(-%.2f%%, -%.2f%%)", position.first, position.second));
+
+ setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre);
+ }
+}
+
+const AtomicString& VTTCueBox::vttCueBoxShadowPseudoId()
+{
+ DEFINE_STATIC_LOCAL(const AtomicString, trackDisplayBoxShadowPseudoId, ("-webkit-media-text-track-display", AtomicString::ConstructFromLiteral));
+ return trackDisplayBoxShadowPseudoId;
+}
+
+RenderPtr<RenderElement> VTTCueBox::createElementRenderer(PassRef<RenderStyle> style)
+{
+ return createRenderer<RenderVTTCue>(*this, std::move(style));
+}
+
+// ----------------------------
+
+VTTCue::VTTCue(ScriptExecutionContext& context, double start, double end, const String& content)
+ : TextTrackCue(context, start, end)
+ , m_content(content)
+ , m_linePosition(undefinedPosition)
+ , m_computedLinePosition(undefinedPosition)
+ , m_textPosition(50)
+ , m_cueSize(100)
+ , m_writingDirection(Horizontal)
+ , m_cueAlignment(Middle)
+ , m_webVTTNodeTree(0)
+ , m_snapToLines(true)
+ , m_cueBackgroundBox(HTMLSpanElement::create(spanTag, toDocument(context)))
+ , m_displayTreeShouldChange(true)
+ , m_displayDirection(CSSValueLtr)
+ , m_displayWritingMode(CSSValueInherit)
+ , m_displaySize(0)
+{
+ // 4. If the text track cue writing direction is horizontal, then let
+ // writing-mode be 'horizontal-tb'. Otherwise, if the text track cue writing
+ // direction is vertical growing left, then let writing-mode be
+ // 'vertical-rl'. Otherwise, the text track cue writing direction is
+ // vertical growing right; let writing-mode be 'vertical-lr'.
+ m_displayWritingModeMap[Horizontal] = CSSValueHorizontalTb;
+ m_displayWritingModeMap[VerticalGrowingLeft] = CSSValueVerticalRl;
+ m_displayWritingModeMap[VerticalGrowingRight] = CSSValueVerticalLr;
+}
+
+VTTCue::~VTTCue()
+{
+ removeDisplayTree();
+}
+
+PassRefPtr<VTTCueBox> VTTCue::createDisplayTree()
+{
+ return VTTCueBox::create(ownerDocument(), this);
+}
+
+VTTCueBox* VTTCue::displayTreeInternal()
+{
+ if (!m_displayTree)
+ m_displayTree = createDisplayTree();
+ return m_displayTree.get();
+}
+
+void VTTCue::didChange()
+{
+ TextTrackCue::didChange();
+ m_displayTreeShouldChange = true;
+}
+
+const String& VTTCue::vertical() const
+{
+ switch (m_writingDirection) {
+ case Horizontal:
+ return horizontalKeyword();
+ case VerticalGrowingLeft:
+ return verticalGrowingLeftKeyword();
+ case VerticalGrowingRight:
+ return verticalGrowingRightKeyword();
+ default:
+ ASSERT_NOT_REACHED();
+ return emptyString();
+ }
+}
+
+void VTTCue::setVertical(const String& value, ExceptionCode& ec)
+{
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-vertical
+ // On setting, the text track cue writing direction must be set to the value given
+ // in the first cell of the row in the table above whose second cell is a
+ // case-sensitive match for the new value, if any. If none of the values match, then
+ // the user agent must instead throw a SyntaxError exception.
+
+ WritingDirection direction = m_writingDirection;
+ if (value == horizontalKeyword())
+ direction = Horizontal;
+ else if (value == verticalGrowingLeftKeyword())
+ direction = VerticalGrowingLeft;
+ else if (value == verticalGrowingRightKeyword())
+ direction = VerticalGrowingRight;
+ else
+ ec = SYNTAX_ERR;
+
+ if (direction == m_writingDirection)
+ return;
+
+ willChange();
+ m_writingDirection = direction;
+ didChange();
+}
+
+void VTTCue::setSnapToLines(bool value)
+{
+ if (m_snapToLines == value)
+ return;
+
+ willChange();
+ m_snapToLines = value;
+ didChange();
+}
+
+void VTTCue::setLine(int position, ExceptionCode& ec)
+{
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line
+ // On setting, if the text track cue snap-to-lines flag is not set, and the new
+ // value is negative or greater than 100, then throw an IndexSizeError exception.
+ if (!m_snapToLines && (position < 0 || position > 100)) {
+ ec = INDEX_SIZE_ERR;
+ return;
+ }
+
+ // Otherwise, set the text track cue line position to the new value.
+ if (m_linePosition == position)
+ return;
+
+ willChange();
+ m_linePosition = position;
+ m_computedLinePosition = calculateComputedLinePosition();
+ didChange();
+}
+
+void VTTCue::setPosition(int position, ExceptionCode& ec)
+{
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-position
+ // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception.
+ // Otherwise, set the text track cue text position to the new value.
+ if (position < 0 || position > 100) {
+ ec = INDEX_SIZE_ERR;
+ return;
+ }
+
+ // Otherwise, set the text track cue line position to the new value.
+ if (m_textPosition == position)
+ return;
+
+ willChange();
+ m_textPosition = position;
+ didChange();
+}
+
+void VTTCue::setSize(int size, ExceptionCode& ec)
+{
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size
+ // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError
+ // exception. Otherwise, set the text track cue size to the new value.
+ if (size < 0 || size > 100) {
+ ec = INDEX_SIZE_ERR;
+ return;
+ }
+
+ // Otherwise, set the text track cue line position to the new value.
+ if (m_cueSize == size)
+ return;
+
+ willChange();
+ m_cueSize = size;
+ didChange();
+}
+
+const String& VTTCue::align() const
+{
+ switch (m_cueAlignment) {
+ case Start:
+ return startKeyword();
+ case Middle:
+ return middleKeyword();
+ case End:
+ return endKeyword();
+ default:
+ ASSERT_NOT_REACHED();
+ return emptyString();
+ }
+}
+
+void VTTCue::setAlign(const String& value, ExceptionCode& ec)
+{
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-align
+ // On setting, the text track cue alignment must be set to the value given in the
+ // first cell of the row in the table above whose second cell is a case-sensitive
+ // match for the new value, if any. If none of the values match, then the user
+ // agent must instead throw a SyntaxError exception.
+
+ CueAlignment alignment = m_cueAlignment;
+ if (value == startKeyword())
+ alignment = Start;
+ else if (value == middleKeyword())
+ alignment = Middle;
+ else if (value == endKeyword())
+ alignment = End;
+ else
+ ec = SYNTAX_ERR;
+
+ if (alignment == m_cueAlignment)
+ return;
+
+ willChange();
+ m_cueAlignment = alignment;
+ didChange();
+}
+
+void VTTCue::setText(const String& text)
+{
+ if (m_content == text)
+ return;
+
+ willChange();
+ // Clear the document fragment but don't bother to create it again just yet as we can do that
+ // when it is requested.
+ m_webVTTNodeTree = 0;
+ m_content = text;
+ didChange();
+}
+
+void VTTCue::createWebVTTNodeTree()
+{
+ if (!m_webVTTNodeTree)
+ m_webVTTNodeTree = WebVTTParser::create(0, scriptExecutionContext())->createDocumentFragmentFromCueText(m_content);
+}
+
+void VTTCue::copyWebVTTNodeToDOMTree(ContainerNode* webVTTNode, ContainerNode* parent)
+{
+ for (Node* node = webVTTNode->firstChild(); node; node = node->nextSibling()) {
+ RefPtr<Node> clonedNode;
+ if (node->isWebVTTElement())
+ clonedNode = toWebVTTElement(node)->createEquivalentHTMLElement(ownerDocument());
+ else
+ clonedNode = node->cloneNode(false);
+ parent->appendChild(clonedNode, ASSERT_NO_EXCEPTION);
+ if (node->isContainerNode())
+ copyWebVTTNodeToDOMTree(toContainerNode(node), toContainerNode(clonedNode.get()));
+ }
+}
+
+PassRefPtr<DocumentFragment> VTTCue::getCueAsHTML()
+{
+ createWebVTTNodeTree();
+ if (!m_webVTTNodeTree)
+ return 0;
+
+ RefPtr<DocumentFragment> clonedFragment = DocumentFragment::create(ownerDocument());
+ copyWebVTTNodeToDOMTree(m_webVTTNodeTree.get(), clonedFragment.get());
+ return clonedFragment.release();
+}
+
+PassRefPtr<DocumentFragment> VTTCue::createCueRenderingTree()
+{
+ RefPtr<DocumentFragment> clonedFragment;
+ createWebVTTNodeTree();
+ if (!m_webVTTNodeTree)
+ return 0;
+
+ clonedFragment = DocumentFragment::create(ownerDocument());
+ m_webVTTNodeTree->cloneChildNodes(clonedFragment.get());
+ return clonedFragment.release();
+}
+
+#if ENABLE(WEBVTT_REGIONS)
+void VTTCue::setRegionId(const String& regionId)
+{
+ if (m_regionId == regionId)
+ return;
+
+ willChange();
+ m_regionId = regionId;
+ didChange();
+}
+#endif
+
+void VTTCue::setIsActive(bool active)
+{
+ TextTrackCue::setIsActive(active);
+
+ if (!active) {
+ if (!hasDisplayTree())
+ return;
+
+ // Remove the display tree as soon as the cue becomes inactive.
+ displayTreeInternal()->remove(ASSERT_NO_EXCEPTION);
+ }
+}
+
+int VTTCue::calculateComputedLinePosition()
+{
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#text-track-cue-computed-line-position
+
+ // If the text track cue line position is numeric, then that is the text
+ // track cue computed line position.
+ if (m_linePosition != undefinedPosition)
+ return m_linePosition;
+
+ // If the text track cue snap-to-lines flag of the text track cue is not
+ // set, the text track cue computed line position is the value 100;
+ if (!m_snapToLines)
+ return 100;
+
+ // Otherwise, it is the value returned by the following algorithm:
+
+ // If cue is not associated with a text track, return -1 and abort these
+ // steps.
+ if (!track())
+ return -1;
+
+ // Let n be the number of text tracks whose text track mode is showing or
+ // showing by default and that are in the media element's list of text
+ // tracks before track.
+ int n = track()->trackIndexRelativeToRenderedTracks();
+
+ // Increment n by one.
+ n++;
+
+ // Negate n.
+ n = -n;
+
+ return n;
+}
+
+static bool isCueParagraphSeparator(UChar character)
+{
+ // Within a cue, paragraph boundaries are only denoted by Type B characters,
+ // such as U+000A LINE FEED (LF), U+0085 NEXT LINE (NEL), and U+2029 PARAGRAPH SEPARATOR.
+ return u_charType(character) == U_PARAGRAPH_SEPARATOR;
+}
+
+void VTTCue::determineTextDirection()
+{
+ DEFINE_STATIC_LOCAL(const String, rtTag, (ASCIILiteral("rt")));
+ createWebVTTNodeTree();
+ if (!m_webVTTNodeTree)
+ return;
+
+ // Apply the Unicode Bidirectional Algorithm's Paragraph Level steps to the
+ // concatenation of the values of each WebVTT Text Object in nodes, in a
+ // pre-order, depth-first traversal, excluding WebVTT Ruby Text Objects and
+ // their descendants.
+ StringBuilder paragraphBuilder;
+ for (Node* node = m_webVTTNodeTree->firstChild(); node; node = NodeTraversal::next(node, m_webVTTNodeTree.get())) {
+ // FIXME: The code does not match the comment above. This does not actually exclude Ruby Text Object descendant.
+ if (!node->isTextNode() || node->localName() == rtTag)
+ continue;
+
+ paragraphBuilder.append(node->nodeValue());
+ }
+
+ String paragraph = paragraphBuilder.toString();
+ if (!paragraph.length())
+ return;
+
+ for (size_t i = 0; i < paragraph.length(); ++i) {
+ UChar current = paragraph[i];
+ if (!current || isCueParagraphSeparator(current))
+ return;
+
+ if (UChar current = paragraph[i]) {
+ UCharDirection charDirection = u_charDirection(current);
+ if (charDirection == U_LEFT_TO_RIGHT) {
+ m_displayDirection = CSSValueLtr;
+ return;
+ }
+ if (charDirection == U_RIGHT_TO_LEFT || charDirection == U_RIGHT_TO_LEFT_ARABIC) {
+ m_displayDirection = CSSValueRtl;
+ return;
+ }
+ }
+ }
+}
+
+void VTTCue::calculateDisplayParameters()
+{
+ // Steps 10.2, 10.3
+ determineTextDirection();
+
+ // 10.4 If the text track cue writing direction is horizontal, then let
+ // block-flow be 'tb'. Otherwise, if the text track cue writing direction is
+ // vertical growing left, then let block-flow be 'lr'. Otherwise, the text
+ // track cue writing direction is vertical growing right; let block-flow be
+ // 'rl'.
+ m_displayWritingMode = m_displayWritingModeMap[m_writingDirection];
+
+ // 10.5 Determine the value of maximum size for cue as per the appropriate
+ // rules from the following list:
+ int maximumSize = m_textPosition;
+ if ((m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueLtr)
+ || (m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueRtl)
+ || (m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Start)
+ || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Start)) {
+ maximumSize = 100 - m_textPosition;
+ } else if ((m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueLtr)
+ || (m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueRtl)
+ || (m_writingDirection == VerticalGrowingLeft && m_cueAlignment == End)
+ || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == End)) {
+ maximumSize = m_textPosition;
+ } else if (m_cueAlignment == Middle) {
+ maximumSize = m_textPosition <= 50 ? m_textPosition : (100 - m_textPosition);
+ maximumSize = maximumSize * 2;
+ }
+
+ // 10.6 If the text track cue size is less than maximum size, then let size
+ // be text track cue size. Otherwise, let size be maximum size.
+ m_displaySize = std::min(m_cueSize, maximumSize);
+
+ // 10.8 Determine the value of x-position or y-position for cue as per the
+ // appropriate rules from the following list:
+ if (m_writingDirection == Horizontal) {
+ if (m_cueAlignment == Start) {
+ if (m_displayDirection == CSSValueLtr)
+ m_displayPosition.first = m_textPosition;
+ else
+ m_displayPosition.first = 100 - m_textPosition - m_displaySize;
+ } else if (m_cueAlignment == End) {
+ if (m_displayDirection == CSSValueRtl)
+ m_displayPosition.first = 100 - m_textPosition;
+ else
+ m_displayPosition.first = m_textPosition - m_displaySize;
+ }
+ }
+
+ if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Start)
+ || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Start)) {
+ m_displayPosition.second = m_textPosition;
+ } else if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == End)
+ || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == End)) {
+ m_displayPosition.second = 100 - m_textPosition;
+ }
+
+ if (m_writingDirection == Horizontal && m_cueAlignment == Middle) {
+ if (m_displayDirection == CSSValueLtr)
+ m_displayPosition.first = m_textPosition - m_displaySize / 2;
+ else
+ m_displayPosition.first = 100 - m_textPosition - m_displaySize / 2;
+ }
+
+ if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Middle)
+ || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Middle))
+ m_displayPosition.second = m_textPosition - m_displaySize / 2;
+
+ // 10.9 Determine the value of whichever of x-position or y-position is not
+ // yet calculated for cue as per the appropriate rules from the following
+ // list:
+ if (m_snapToLines && m_displayPosition.second == undefinedPosition && m_writingDirection == Horizontal)
+ m_displayPosition.second = 0;
+
+ if (!m_snapToLines && m_displayPosition.second == undefinedPosition && m_writingDirection == Horizontal)
+ m_displayPosition.second = m_computedLinePosition;
+
+ if (m_snapToLines && m_displayPosition.first == undefinedPosition
+ && (m_writingDirection == VerticalGrowingLeft || m_writingDirection == VerticalGrowingRight))
+ m_displayPosition.first = 0;
+
+ if (!m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writingDirection == VerticalGrowingRight))
+ m_displayPosition.first = m_computedLinePosition;
+
+ // A text track cue has a text track cue computed line position whose value
+ // is defined in terms of the other aspects of the cue.
+ m_computedLinePosition = calculateComputedLinePosition();
+}
+
+void VTTCue::markFutureAndPastNodes(ContainerNode* root, double previousTimestamp, double movieTime)
+{
+ DEFINE_STATIC_LOCAL(const String, timestampTag, (ASCIILiteral("timestamp")));
+
+ bool isPastNode = true;
+ double currentTimestamp = previousTimestamp;
+ if (currentTimestamp > movieTime)
+ isPastNode = false;
+
+ for (Node* child = root->firstChild(); child; child = NodeTraversal::next(child, root)) {
+ if (child->nodeName() == timestampTag) {
+ unsigned position = 0;
+ String timestamp = child->nodeValue();
+ double currentTimestamp = WebVTTParser::create(0, scriptExecutionContext())->collectTimeStamp(timestamp, &position);
+ ASSERT(currentTimestamp != -1);
+
+ if (currentTimestamp > movieTime)
+ isPastNode = false;
+ }
+
+ if (child->isWebVTTElement()) {
+ toWebVTTElement(child)->setIsPastNode(isPastNode);
+ // Make an elemenet id match a cue id for style matching purposes.
+ if (!id().isEmpty())
+ toElement(child)->setIdAttribute(id());
+ }
+ }
+}
+
+void VTTCue::updateDisplayTree(double movieTime)
+{
+ // The display tree may contain WebVTT timestamp objects representing
+ // timestamps (processing instructions), along with displayable nodes.
+
+ if (!track()->isRendered())
+ return;
+
+ // Clear the contents of the set.
+ m_cueBackgroundBox->removeChildren();
+
+ // Update the two sets containing past and future WebVTT objects.
+ RefPtr<DocumentFragment> referenceTree = createCueRenderingTree();
+ if (!referenceTree)
+ return;
+
+ markFutureAndPastNodes(referenceTree.get(), startTime(), movieTime);
+ m_cueBackgroundBox->appendChild(referenceTree);
+}
+
+VTTCueBox* VTTCue::getDisplayTree(const IntSize& videoSize)
+{
+ RefPtr<VTTCueBox> displayTree = displayTreeInternal();
+ if (!m_displayTreeShouldChange || !track()->isRendered())
+ return displayTree.get();
+
+ // 10.1 - 10.10
+ calculateDisplayParameters();
+
+ // 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:
+ 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.
+
+ // Note: This is contained by default in m_cueBackgroundBox.
+ m_cueBackgroundBox->setPseudo(cueShadowPseudoId());
+ displayTree->appendChild(m_cueBackgroundBox, ASSERT_NO_EXCEPTION);
+
+ // 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.)
+ displayTree->applyCSSProperties(videoSize);
+
+ m_displayTreeShouldChange = false;
+
+ // 10.15. Let cue's text track cue display state have the CSS boxes in
+ // boxes.
+ return displayTree.get();
+}
+
+void VTTCue::removeDisplayTree()
+{
+ if (!hasDisplayTree())
+ return;
+ displayTreeInternal()->remove(ASSERT_NO_EXCEPTION);
+}
+
+std::pair<double, double> VTTCue::getPositionCoordinates() const
+{
+ // This method is used for setting x and y when snap to lines is not set.
+ std::pair<double, double> coordinates;
+
+ if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) {
+ coordinates.first = m_textPosition;
+ coordinates.second = m_computedLinePosition;
+
+ return coordinates;
+ }
+
+ if (m_writingDirection == Horizontal && m_displayDirection == CSSValueRtl) {
+ coordinates.first = 100 - m_textPosition;
+ coordinates.second = m_computedLinePosition;
+
+ return coordinates;
+ }
+
+ if (m_writingDirection == VerticalGrowingLeft) {
+ coordinates.first = 100 - m_computedLinePosition;
+ coordinates.second = m_textPosition;
+
+ return coordinates;
+ }
+
+ if (m_writingDirection == VerticalGrowingRight) {
+ coordinates.first = m_computedLinePosition;
+ coordinates.second = m_textPosition;
+
+ return coordinates;
+ }
+
+ ASSERT_NOT_REACHED();
+
+ return coordinates;
+}
+
+VTTCue::CueSetting VTTCue::settingName(const String& name)
+{
+ DEFINE_STATIC_LOCAL(const String, verticalKeyword, (ASCIILiteral("vertical")));
+ DEFINE_STATIC_LOCAL(const String, lineKeyword, (ASCIILiteral("line")));
+ DEFINE_STATIC_LOCAL(const String, positionKeyword, (ASCIILiteral("position")));
+ DEFINE_STATIC_LOCAL(const String, sizeKeyword, (ASCIILiteral("size")));
+ DEFINE_STATIC_LOCAL(const String, alignKeyword, (ASCIILiteral("align")));
+#if ENABLE(WEBVTT_REGIONS)
+ DEFINE_STATIC_LOCAL(const String, regionIdKeyword, (ASCIILiteral("region")));
+#endif
+
+ if (name == verticalKeyword)
+ return Vertical;
+ if (name == lineKeyword)
+ return Line;
+ if (name == positionKeyword)
+ return Position;
+ if (name == sizeKeyword)
+ return Size;
+ if (name == alignKeyword)
+ return Align;
+#if ENABLE(WEBVTT_REGIONS)
+ if (name == regionIdKeyword)
+ return RegionId;
+#endif
+
+ return None;
+}
+
+void VTTCue::setCueSettings(const String& input)
+{
+ m_settings = input;
+ unsigned position = 0;
+
+ while (position < input.length()) {
+
+ // The WebVTT cue settings part of a WebVTT cue consists of zero or more of the following components, in any order,
+ // separated from each other by one or more U+0020 SPACE characters or U+0009 CHARACTER TABULATION (tab) characters.
+ while (position < input.length() && WebVTTParser::isValidSettingDelimiter(input[position]))
+ position++;
+ if (position >= input.length())
+ break;
+
+ // When the user agent is to parse the WebVTT settings given by a string input for a text track cue cue,
+ // the user agent must run the following steps:
+ // 1. Let settings be the result of splitting input on spaces.
+ // 2. For each token setting in the list settings, run the following substeps:
+ // 1. If setting does not contain a U+003A COLON character (:), or if the first U+003A COLON character (:)
+ // in setting is either the first or last character of setting, then jump to the step labeled next setting.
+ unsigned endOfSetting = position;
+ String setting = WebVTTParser::collectWord(input, &endOfSetting);
+ CueSetting name;
+ size_t colonOffset = setting.find(':', 1);
+ if (colonOffset == notFound || !colonOffset || colonOffset == setting.length() - 1)
+ goto NextSetting;
+
+ // 2. Let name be the leading substring of setting up to and excluding the first U+003A COLON character (:) in that string.
+ name = settingName(setting.substring(0, colonOffset));
+
+ // 3. Let value be the trailing substring of setting starting from the character immediately after the first U+003A COLON character (:) in that string.
+ position += colonOffset + 1;
+ if (position >= input.length())
+ break;
+
+ // 4. Run the appropriate substeps that apply for the value of name, as follows:
+ switch (name) {
+ case Vertical:
+ {
+ // If name is a case-sensitive match for "vertical"
+ // 1. If value is a case-sensitive match for the string "rl", then let cue's text track cue writing direction
+ // be vertical growing left.
+ String writingDirection = WebVTTParser::collectWord(input, &position);
+ if (writingDirection == verticalGrowingLeftKeyword())
+ m_writingDirection = VerticalGrowingLeft;
+
+ // 2. Otherwise, if value is a case-sensitive match for the string "lr", then let cue's text track cue writing
+ // direction be vertical growing right.
+ else if (writingDirection == verticalGrowingRightKeyword())
+ m_writingDirection = VerticalGrowingRight;
+ }
+ break;
+ case Line:
+ {
+ // 1-2 - Collect chars that are either '-', '%', or a digit.
+ // 1. If value contains any characters other than U+002D HYPHEN-MINUS characters (-), U+0025 PERCENT SIGN
+ // characters (%), and characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump
+ // to the step labeled next setting.
+ StringBuilder linePositionBuilder;
+ while (position < input.length() && (input[position] == '-' || input[position] == '%' || isASCIIDigit(input[position])))
+ linePositionBuilder.append(input[position++]);
+ if (position < input.length() && !WebVTTParser::isValidSettingDelimiter(input[position]))
+ break;
+
+ // 2. If value does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
+ // NINE (9), then jump to the step labeled next setting.
+ // 3. If any character in value other than the first character is a U+002D HYPHEN-MINUS character (-), then
+ // jump to the step labeled next setting.
+ // 4. If any character in value other than the last character is a U+0025 PERCENT SIGN character (%), then
+ // jump to the step labeled next setting.
+ String linePosition = linePositionBuilder.toString();
+ if (linePosition.find('-', 1) != notFound || linePosition.reverseFind("%", linePosition.length() - 2) != notFound)
+ break;
+
+ // 5. If the first character in value is a U+002D HYPHEN-MINUS character (-) and the last character in value is a
+ // U+0025 PERCENT SIGN character (%), then jump to the step labeled next setting.
+ if (linePosition[0] == '-' && linePosition[linePosition.length() - 1] == '%')
+ break;
+
+ // 6. Ignoring the trailing percent sign, if any, interpret value as a (potentially signed) integer, and
+ // let number be that number.
+ // NOTE: toInt ignores trailing non-digit characters, such as '%'.
+ bool validNumber;
+ int number = linePosition.toInt(&validNumber);
+ if (!validNumber)
+ break;
+
+ // 7. If the last character in value is a U+0025 PERCENT SIGN character (%), but number is not in the range
+ // 0 ≤ number ≤ 100, then jump to the step labeled next setting.
+ // 8. Let cue's text track cue line position be number.
+ // 9. If the last character in value is a U+0025 PERCENT SIGN character (%), then let cue's text track cue
+ // snap-to-lines flag be false. Otherwise, let it be true.
+ if (linePosition[linePosition.length() - 1] == '%') {
+ if (number < 0 || number > 100)
+ break;
+
+ // 10 - If '%' then set snap-to-lines flag to false.
+ m_snapToLines = false;
+ }
+
+ m_linePosition = number;
+ }
+ break;
+ case Position:
+ {
+ // 1. If value contains any characters other than U+0025 PERCENT SIGN characters (%) and characters in the range
+ // U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump to the step labeled next setting.
+ // 2. If value does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9),
+ // then jump to the step labeled next setting.
+ String textPosition = WebVTTParser::collectDigits(input, &position);
+ if (textPosition.isEmpty())
+ break;
+ if (position >= input.length())
+ break;
+
+ // 3. If any character in value other than the last character is a U+0025 PERCENT SIGN character (%), then jump
+ // to the step labeled next setting.
+ // 4. If the last character in value is not a U+0025 PERCENT SIGN character (%), then jump to the step labeled
+ // next setting.
+ if (input[position++] != '%')
+ break;
+ if (position < input.length() && !WebVTTParser::isValidSettingDelimiter(input[position]))
+ break;
+
+ // 5. Ignoring the trailing percent sign, interpret value as an integer, and let number be that number.
+ // 6. If number is not in the range 0 ≤ number ≤ 100, then jump to the step labeled next setting.
+ // NOTE: toInt ignores trailing non-digit characters, such as '%'.
+ bool validNumber;
+ int number = textPosition.toInt(&validNumber);
+ if (!validNumber)
+ break;
+ if (number < 0 || number > 100)
+ break;
+
+ // 7. Let cue's text track cue text position be number.
+ m_textPosition = number;
+ }
+ break;
+ case Size:
+ {
+ // 1. If value contains any characters other than U+0025 PERCENT SIGN characters (%) and characters in the
+ // range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump to the step labeled next setting.
+ // 2. If value does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
+ // NINE (9), then jump to the step labeled next setting.
+ String cueSize = WebVTTParser::collectDigits(input, &position);
+ if (cueSize.isEmpty())
+ break;
+ if (position >= input.length())
+ break;
+
+ // 3. If any character in value other than the last character is a U+0025 PERCENT SIGN character (%),
+ // then jump to the step labeled next setting.
+ // 4. If the last character in value is not a U+0025 PERCENT SIGN character (%), then jump to the step
+ // labeled next setting.
+ if (input[position++] != '%')
+ break;
+ if (position < input.length() && !WebVTTParser::isValidSettingDelimiter(input[position]))
+ break;
+
+ // 5. Ignoring the trailing percent sign, interpret value as an integer, and let number be that number.
+ // 6. If number is not in the range 0 ≤ number ≤ 100, then jump to the step labeled next setting.
+ bool validNumber;
+ int number = cueSize.toInt(&validNumber);
+ if (!validNumber)
+ break;
+ if (number < 0 || number > 100)
+ break;
+
+ // 7. Let cue's text track cue size be number.
+ m_cueSize = number;
+ }
+ break;
+ case Align:
+ {
+ String cueAlignment = WebVTTParser::collectWord(input, &position);
+
+ // 1. If value is a case-sensitive match for the string "start", then let cue's text track cue alignment be start alignment.
+ if (cueAlignment == startKeyword())
+ m_cueAlignment = Start;
+
+ // 2. If value is a case-sensitive match for the string "middle", then let cue's text track cue alignment be middle alignment.
+ else if (cueAlignment == middleKeyword())
+ m_cueAlignment = Middle;
+
+ // 3. If value is a case-sensitive match for the string "end", then let cue's text track cue alignment be end alignment.
+ else if (cueAlignment == endKeyword())
+ m_cueAlignment = End;
+ }
+ break;
+#if ENABLE(WEBVTT_REGIONS)
+ case RegionId:
+ m_regionId = WebVTTParser::collectWord(input, &position);
+ break;
+#endif
+ case None:
+ break;
+ }
+
+NextSetting:
+ position = endOfSetting;
+ }
+#if ENABLE(WEBVTT_REGIONS)
+ // If cue's line position is not auto or cue's size is not 100 or cue's
+ // writing direction is not horizontal, but cue's region identifier is not
+ // the empty string, let cue's region identifier be the empty string.
+ if (m_regionId.isEmpty())
+ return;
+
+ if (m_linePosition != undefinedPosition || m_cueSize != 100 || m_writingDirection != Horizontal)
+ m_regionId = emptyString();
+#endif
+}
+
+CSSValueID VTTCue::getCSSWritingDirection() const
+{
+ return m_displayDirection;
+}
+
+CSSValueID VTTCue::getCSSWritingMode() const
+{
+ return m_displayWritingMode;
+}
+
+int VTTCue::getCSSSize() const
+{
+ return m_displaySize;
+}
+
+std::pair<double, double> VTTCue::getCSSPosition() const
+{
+ if (!m_snapToLines)
+ return getPositionCoordinates();
+
+ return m_displayPosition;
+}
+
+bool VTTCue::isEqual(const VTTCue& cue, CueMatchRules match) const
+{
+ if (cueType() != cue.cueType())
+ return false;
+
+ if (match != IgnoreDuration && endTime() != cue.endTime())
+ return false;
+ if (startTime() != cue.startTime())
+ return false;
+ if (text() != cue.text())
+ return false;
+ if (cueSettings() != cue.cueSettings())
+ return false;
+ if (id() != cue.id())
+ return false;
+ if (position() != cue.position())
+ return false;
+ if (line() != cue.line())
+ return false;
+ if (size() != cue.size())
+ return false;
+ if (align() != cue.align())
+ return false;
+
+ return true;
+}
+
+void VTTCue::setFontSize(int fontSize, const IntSize&, bool important)
+{
+ if (!hasDisplayTree() || !fontSize)
+ return;
+
+ LOG(Media, "TextTrackCue::setFontSize - setting cue font size to %i", fontSize);
+
+ displayTreeInternal()->setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX, important);
+}
+
+VTTCue* toVTTCue(TextTrackCue* cue)
+{
+ return const_cast<VTTCue*>(toVTTCue(const_cast<const TextTrackCue*>(cue)));
+}
+
+const VTTCue* toVTTCue(const TextTrackCue* cue)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(cue->isRenderable());
+ return static_cast<const VTTCue*>(cue);
+}
+
+} // namespace WebCore
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef VTTCue_h
+#define VTTCue_h
+
+#if ENABLE(VIDEO_TRACK)
+
+#include "EventTarget.h"
+#include "HTMLElement.h"
+#include "TextTrackCue.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class DocumentFragment;
+class HTMLSpanElement;
+class ScriptExecutionContext;
+class VTTCue;
+
+// ----------------------------
+
+class VTTCueBox : public HTMLElement {
+public:
+ static PassRefPtr<VTTCueBox> create(Document& document, VTTCue* cue)
+ {
+ return adoptRef(new VTTCueBox(document, cue));
+ }
+
+ VTTCue* getCue() const;
+ virtual void applyCSSProperties(const IntSize& videoSize);
+
+ static const AtomicString& vttCueBoxShadowPseudoId();
+
+protected:
+ VTTCueBox(Document&, VTTCue*);
+
+ virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override;
+
+ VTTCue* m_cue;
+};
+
+// ----------------------------
+
+class VTTCue : public TextTrackCue {
+public:
+ static PassRefPtr<VTTCue> create(ScriptExecutionContext& context, double start, double end, const String& content)
+ {
+ return adoptRef(new VTTCue(context, start, end, content));
+ }
+
+ virtual ~VTTCue();
+
+ const String& vertical() const;
+ void setVertical(const String&, ExceptionCode&);
+
+ bool snapToLines() const { return m_snapToLines; }
+ void setSnapToLines(bool);
+
+ int line() const { return m_linePosition; }
+ virtual void setLine(int, ExceptionCode&);
+
+ int position() const { return m_textPosition; }
+ virtual void setPosition(int, ExceptionCode&);
+
+ int size() const { return m_cueSize; }
+ virtual void setSize(int, ExceptionCode&);
+
+ const String& align() const;
+ void setAlign(const String&, ExceptionCode&);
+
+ const String& text() const { return m_content; }
+ void setText(const String&);
+
+ const String& cueSettings() const { return m_settings; }
+ void setCueSettings(const String&);
+
+ PassRefPtr<DocumentFragment> getCueAsHTML();
+ PassRefPtr<DocumentFragment> createCueRenderingTree();
+
+#if ENABLE(WEBVTT_REGIONS)
+ const String& regionId() const { return m_regionId; }
+ void setRegionId(const String&);
+#endif
+
+ virtual void setIsActive(bool);
+
+ bool hasDisplayTree() const { return m_displayTree; }
+ VTTCueBox* getDisplayTree(const IntSize& videoSize);
+ HTMLSpanElement* element() const { return m_cueBackgroundBox.get(); }
+
+ void updateDisplayTree(double);
+ void removeDisplayTree();
+ void markFutureAndPastNodes(ContainerNode*, double, double);
+
+ int calculateComputedLinePosition();
+ std::pair<double, double> getPositionCoordinates() const;
+
+ std::pair<double, double> getCSSPosition() const;
+
+ int getCSSSize() const;
+ CSSValueID getCSSWritingDirection() const;
+ CSSValueID getCSSWritingMode() const;
+
+ enum WritingDirection {
+ Horizontal,
+ VerticalGrowingLeft,
+ VerticalGrowingRight,
+ NumberOfWritingDirections
+ };
+ WritingDirection getWritingDirection() const { return m_writingDirection; }
+
+ enum CueAlignment {
+ Start,
+ Middle,
+ End
+ };
+ CueAlignment getAlignment() const { return m_cueAlignment; }
+
+ virtual void setFontSize(int, const IntSize&, bool important);
+
+ enum CueMatchRules {
+ MatchAllFields,
+ IgnoreDuration,
+ };
+ virtual bool isEqual(const VTTCue&, CueMatchRules) const;
+
+ virtual CueType cueType() const { return WebVTT; }
+ virtual bool isRenderable() const override final { return true; }
+
+ virtual void didChange() override;
+
+protected:
+ VTTCue(ScriptExecutionContext&, double start, double end, const String& content);
+
+ virtual PassRefPtr<VTTCueBox> createDisplayTree();
+ VTTCueBox* displayTreeInternal();
+
+private:
+ void createWebVTTNodeTree();
+ void copyWebVTTNodeToDOMTree(ContainerNode* WebVTTNode, ContainerNode* root);
+
+ void parseSettings(const String&);
+
+ void determineTextDirection();
+ void calculateDisplayParameters();
+
+ enum CueSetting {
+ None,
+ Vertical,
+ Line,
+ Position,
+ Size,
+ Align,
+#if ENABLE(WEBVTT_REGIONS)
+ RegionId
+#endif
+ };
+ CueSetting settingName(const String&);
+
+ String m_content;
+ String m_settings;
+ int m_linePosition;
+ int m_computedLinePosition;
+ int m_textPosition;
+ int m_cueSize;
+
+ WritingDirection m_writingDirection;
+ CueAlignment m_cueAlignment;
+
+ RefPtr<DocumentFragment> m_webVTTNodeTree;
+
+ bool m_snapToLines;
+
+ RefPtr<HTMLSpanElement> m_cueBackgroundBox;
+
+ bool m_displayTreeShouldChange;
+ RefPtr<VTTCueBox> m_displayTree;
+
+ CSSValueID m_displayDirection;
+
+ CSSValueID m_displayWritingModeMap[NumberOfWritingDirections];
+ CSSValueID m_displayWritingMode;
+
+ int m_displaySize;
+
+ std::pair<float, float> m_displayPosition;
+#if ENABLE(WEBVTT_REGIONS)
+ String m_regionId;
+#endif
+};
+
+VTTCue* toVTTCue(TextTrackCue*);
+const VTTCue* toVTTCue(const TextTrackCue*);
+
+} // namespace WebCore
+
+#endif
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+[
+ Conditional=VIDEO_TRACK,
+ Constructor(double startTime, double endTime, DOMString text),
+ ConstructorCallWith=ScriptExecutionContext,
+ JSGenerateToJSObject,
+ JSGenerateToNativeObject,
+] interface VTTCue : TextTrackCue {
+ [SetterRaisesException] attribute DOMString vertical;
+ attribute boolean snapToLines;
+ [SetterRaisesException] attribute double line;
+ [SetterRaisesException] attribute double position;
+ [SetterRaisesException] attribute double size;
+ [SetterRaisesException] attribute DOMString align;
+ attribute DOMString text;
+ DocumentFragment getCueAsHTML();
+
+#if defined(ENABLE_WEBVTT_REGIONS) && ENABLE_WEBVTT_REGIONS
+ attribute DOMString regionId;
+#endif
+};
#include "Logging.h"
#include "ResourceBuffer.h"
#include "SecurityOrigin.h"
-#include "TextTrackCue.h"
+#include "VTTCue.h"
#include "WebVTTParser.h"
namespace WebCore {
m_cueParser->getNewCues(newCues);
for (size_t i = 0; i < newCues.size(); ++i) {
RefPtr<WebVTTCueData> data = newCues[i];
- RefPtr<TextTrackCue> cue = TextTrackCue::create(*m_scriptExecutionContext, data->startTime(), data->endTime(), data->content());
+ RefPtr<VTTCue> cue = VTTCue::create(*m_scriptExecutionContext, data->startTime(), data->endTime(), data->content());
cue->setId(data->id());
cue->setCueSettings(data->settings());
outputCues.append(cue);
#include "Logging.h"
#include "MediaControlElements.h"
#include "SoftLinking.h"
-#include "TextTrackCue.h"
#include "TextTrackList.h"
#include "UserStyleSheetTypes.h"
+#include "VTTCue.h"
#include <wtf/RetainPtr.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
String windowCornerRadius = windowRoundedCornerRadiusCSS();
if (!windowColor.isEmpty() || !windowCornerRadius.isEmpty()) {
captionsOverrideStyleSheet.append(" video::");
- captionsOverrideStyleSheet.append(TextTrackCueBox::textTrackCueBoxShadowPseudoId());
+ captionsOverrideStyleSheet.append(VTTCueBox::vttCueBoxShadowPseudoId());
captionsOverrideStyleSheet.append('{');
if (!windowColor.isEmpty())
#include "config.h"
#if ENABLE(VIDEO_TRACK)
+#include "RenderVTTCue.h"
-#include "RenderTextTrackCue.h"
#include "RenderView.h"
-
-#include "RenderView.h"
-#include "TextTrackCue.h"
#include "TextTrackCueGeneric.h"
+#include "VTTCue.h"
#include <wtf/StackStats.h>
namespace WebCore {
-RenderTextTrackCue::RenderTextTrackCue(TextTrackCueBox& element, PassRef<RenderStyle> style)
+RenderVTTCue::RenderVTTCue(VTTCueBox& element, PassRef<RenderStyle> style)
: RenderBlockFlow(element, std::move(style))
, m_cue(element.getCue())
{
}
-void RenderTextTrackCue::layout()
+void RenderVTTCue::layout()
{
StackStats::LayoutCheckPoint layoutCheckPoint;
RenderBlockFlow::layout();
LayoutStateMaintainer statePusher(view(), *this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
if (m_cue->cueType()== TextTrackCue::WebVTT) {
- if (m_cue->snapToLines())
+ if (toVTTCue(m_cue)->snapToLines())
repositionCueSnapToLinesSet();
else
repositionCueSnapToLinesNotSet();
statePusher.pop();
}
-bool RenderTextTrackCue::initializeLayoutParameters(InlineFlowBox*& firstLineBox, LayoutUnit& step, LayoutUnit& position)
+bool RenderVTTCue::initializeLayoutParameters(InlineFlowBox*& firstLineBox, LayoutUnit& step, LayoutUnit& position)
{
ASSERT(firstChild());
// 1. Horizontal: Let step be the height of the first line box in boxes.
// Vertical: Let step be the width of the first line box in boxes.
- step = m_cue->getWritingDirection() == TextTrackCue::Horizontal ? firstLineBox->height() : firstLineBox->width();
+ step = m_cue->getWritingDirection() == VTTCue::Horizontal ? firstLineBox->height() : firstLineBox->width();
// 2. If step is zero, then jump to the step labeled done positioning below.
if (!step)
int linePosition = m_cue->calculateComputedLinePosition();
// 4. Vertical Growing Left: Add one to line position then negate it.
- if (m_cue->getWritingDirection() == TextTrackCue::VerticalGrowingLeft)
+ if (m_cue->getWritingDirection() == VTTCue::VerticalGrowingLeft)
linePosition = -(linePosition + 1);
// 5. Let position be the result of multiplying step and line position.
// 6. Vertical Growing Left: Decrease position by the width of the
// bounding box of the boxes in boxes, then increase position by step.
- if (m_cue->getWritingDirection() == TextTrackCue::VerticalGrowingLeft) {
+ if (m_cue->getWritingDirection() == VTTCue::VerticalGrowingLeft) {
position -= width();
position += step;
}
if (linePosition < 0) {
// Horizontal / Vertical: ... then increase position by the
// height / width of the video's rendering area ...
- position += m_cue->getWritingDirection() == TextTrackCue::Horizontal ? parentBlock->height() : parentBlock->width();
+ position += m_cue->getWritingDirection() == VTTCue::Horizontal ? parentBlock->height() : parentBlock->width();
// ... and negate step.
step = -step;
return true;
}
-void RenderTextTrackCue::placeBoxInDefaultPosition(LayoutUnit position, bool& switched)
+void RenderVTTCue::placeBoxInDefaultPosition(LayoutUnit position, bool& switched)
{
// 8. Move all boxes in boxes ...
- if (m_cue->getWritingDirection() == TextTrackCue::Horizontal)
+ if (m_cue->getWritingDirection() == VTTCue::Horizontal)
// Horizontal: ... down by the distance given by position
setY(y() + position);
else
switched = false;
}
-bool RenderTextTrackCue::isOutside() const
+bool RenderVTTCue::isOutside() const
{
return !rectIsWithinContainer(absoluteContentBox());
}
-bool RenderTextTrackCue::rectIsWithinContainer(const IntRect& rect) const
+bool RenderVTTCue::rectIsWithinContainer(const IntRect& rect) const
{
return containingBlock()->absoluteBoundingBoxRect().contains(rect);
}
-bool RenderTextTrackCue::isOverlapping() const
+bool RenderVTTCue::isOverlapping() const
{
return overlappingObject();
}
-RenderObject* RenderTextTrackCue::overlappingObject() const
+RenderObject* RenderVTTCue::overlappingObject() const
{
return overlappingObjectForRect(absoluteBoundingBoxRect());
}
-RenderObject* RenderTextTrackCue::overlappingObjectForRect(const IntRect& rect) const
+RenderObject* RenderVTTCue::overlappingObjectForRect(const IntRect& rect) const
{
for (RenderObject* box = previousSibling(); box; box = box->previousSibling()) {
IntRect boxRect = box->absoluteBoundingBoxRect();
return 0;
}
-bool RenderTextTrackCue::shouldSwitchDirection(InlineFlowBox* firstLineBox, LayoutUnit step) const
+bool RenderVTTCue::shouldSwitchDirection(InlineFlowBox* firstLineBox, LayoutUnit step) const
{
LayoutUnit top = y();
LayoutUnit left = x();
// boxes is now below the bottom of the video's rendering area, jump
// to the step labeled switch direction.
LayoutUnit parentHeight = containingBlock()->height();
- if (m_cue->getWritingDirection() == TextTrackCue::Horizontal && ((step < 0 && top < 0) || (step > 0 && bottom > parentHeight)))
+ if (m_cue->getWritingDirection() == VTTCue::Horizontal && ((step < 0 && top < 0) || (step > 0 && bottom > parentHeight)))
return true;
// 12. Vertical: If step is negative and the left edge of the first line
// first line box in boxes is now to the right of the right edge of
// the video's rendering area, jump to the step labeled switch direction.
LayoutUnit parentWidth = containingBlock()->width();
- if (m_cue->getWritingDirection() != TextTrackCue::Horizontal && ((step < 0 && left < 0) || (step > 0 && right > parentWidth)))
+ if (m_cue->getWritingDirection() != VTTCue::Horizontal && ((step < 0 && left < 0) || (step > 0 && right > parentWidth)))
return true;
return false;
}
-void RenderTextTrackCue::moveBoxesByStep(LayoutUnit step)
+void RenderVTTCue::moveBoxesByStep(LayoutUnit step)
{
// 13. Horizontal: Move all the boxes in boxes down by the distance
// given by step. (If step is negative, then this will actually
// result in an upwards movement of the boxes in absolute terms.)
- if (m_cue->getWritingDirection() == TextTrackCue::Horizontal)
+ if (m_cue->getWritingDirection() == VTTCue::Horizontal)
setY(y() + step);
// 13. Vertical: Move all the boxes in boxes right by the distance
setX(x() + step);
}
-bool RenderTextTrackCue::switchDirection(bool& switched, LayoutUnit& step)
+bool RenderVTTCue::switchDirection(bool& switched, LayoutUnit& step)
{
// 15. Switch direction: Move all the boxes in boxes back to their
// default position as determined in the step above labeled default.
return true;
}
-void RenderTextTrackCue::moveIfNecessaryToKeepWithinContainer()
+void RenderVTTCue::moveIfNecessaryToKeepWithinContainer()
{
IntRect containerRect = containingBlock()->absoluteBoundingBoxRect();
IntRect cueRect = absoluteBoundingBoxRect();
setX(x() + horizontalAdjustment);
}
-bool RenderTextTrackCue::findNonOverlappingPosition(int& newX, int& newY) const
+bool RenderVTTCue::findNonOverlappingPosition(int& newX, int& newY) const
{
newX = x();
newY = y();
// Move the box up, looking for a non-overlapping position:
while (RenderObject* box = overlappingObjectForRect(destRect)) {
- if (m_cue->getWritingDirection() == TextTrackCue::Horizontal)
+ if (m_cue->getWritingDirection() == VTTCue::Horizontal)
destRect.setY(box->absoluteBoundingBoxRect().y() - destRect.height());
else
destRect.setX(box->absoluteBoundingBoxRect().x() - destRect.width());
// Move the box down, looking for a non-overlapping position:
while (RenderObject* box = overlappingObjectForRect(destRect)) {
- if (m_cue->getWritingDirection() == TextTrackCue::Horizontal)
+ if (m_cue->getWritingDirection() == VTTCue::Horizontal)
destRect.setY(box->absoluteBoundingBoxRect().maxY());
else
destRect.setX(box->absoluteBoundingBoxRect().maxX());
return false;
}
-void RenderTextTrackCue::repositionCueSnapToLinesSet()
+void RenderVTTCue::repositionCueSnapToLinesSet()
{
InlineFlowBox* firstLineBox;
LayoutUnit step;
moveIfNecessaryToKeepWithinContainer();
}
-void RenderTextTrackCue::repositionGenericCue()
+void RenderVTTCue::repositionGenericCue()
{
ASSERT(firstChild());
InlineFlowBox* firstLineBox = toRenderInline(firstChild())->firstLineBox();
repositionCueSnapToLinesNotSet();
}
-void RenderTextTrackCue::repositionCueSnapToLinesNotSet()
+void RenderVTTCue::repositionCueSnapToLinesNotSet()
{
// 3. If none of the boxes in boxes would overlap any of the boxes in output, and all the boxes in
// output are within the video's rendering area, then jump to the step labeled done positioning below.
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef RenderTextTrackCue_h
-#define RenderTextTrackCue_h
+#ifndef RenderVTTCue_h
+#define RenderVTTCue_h
#if ENABLE(VIDEO_TRACK)
namespace WebCore {
class RenderBox;
-class TextTrackCueBox;
+class VTTCue;
+class VTTCueBox;
-class RenderTextTrackCue final : public RenderBlockFlow {
+class RenderVTTCue final : public RenderBlockFlow {
public:
- RenderTextTrackCue(TextTrackCueBox&, PassRef<RenderStyle>);
+ RenderVTTCue(VTTCueBox&, PassRef<RenderStyle>);
private:
virtual void layout() override;
void repositionCueSnapToLinesNotSet();
void repositionGenericCue();
- TextTrackCue* m_cue;
+ VTTCue* m_cue;
FloatPoint m_fallbackPosition;
};
} // namespace WebCore
#endif
-#endif // RenderTextTrackCue_h
+#endif // RenderVTTCue_h
#include "RenderTextControlSingleLine.cpp"
#include "RenderTextFragment.cpp"
#include "RenderTextLineBoxes.cpp"
-#include "RenderTextTrackCue.cpp"
#include "RenderTheme.cpp"
#if PLATFORM(WIN)
#include "RenderThemeWin.cpp"
#endif
#include "RenderTreeAsText.cpp"
+#include "RenderVTTCue.cpp"
#include "RenderVideo.cpp"
#include "RenderView.cpp"
#include "RenderWidget.cpp"