Source/WebCore/ChangeLog

 12014-02-07 Brendan Long <b.long@cablelabs.com>
 2
 3 Update TextTrack API to current spec
 4 https://bugs.webkit.org/show_bug.cgi?id=122218
 5
 6 Refactoring VTTCue out of TextTrackCue.
 7
 8 Reviewed by NOBODY (OOPS!).
 9
 10 Test: media/track/track-vttcue.html
 11
 12 * CMakeLists.txt: Add VTTCue and rename RenderTextTrackCue to RenderVTTCue.
 13 * DerivedSources.cpp: Same.
 14 * DerivedSources.make: Same.
 15 * GNUmakefile.list.am: Same.
 16 * PlatformGTK.cmake: Same.
 17 * WebCore.vcxproj/WebCore.vcxproj: Same.
 18 * WebCore.vcxproj/WebCore.vcxproj.filters: Same.
 19 * WebCore.xcodeproj/project.pbxproj: Same.
 20 * bindings/js/JSTextTrackCueCustom.cpp:
 21 (WebCore::toJS): Use VTTCue DOM wrapper for VTTCue and its subclasses.
 22 * html/HTMLMediaElement.cpp:
 23 (WebCore::HTMLMediaElement::updateActiveTextTrackCues): Convert to VTTCue as needed.
 24 (WebCore::HTMLMediaElement::textTrackRemoveCue): Same.
 25 * html/HTMLMediaElement.h: Only print cue.text in debug output if the cue type has a .text attribute
 26 * html/shadow/MediaControlElements.cpp:
 27 (WebCore::MediaControlTextTrackContainerElement::updateDisplay): Convert to VTTCue as needed, and fix TextTrackCueBox to VTTCueBox.
 28 (WebCore::MediaControlTextTrackContainerElement::updateTimerFired): Convert to VTTCue as needed.
 29 * html/track/InbandGenericTextTrack.cpp:
 30 (WebCore::InbandGenericTextTrack::addGenericCue): Use refactored VTTCue attributes.
 31 * html/track/InbandWebVTTTextTrack.cpp:
 32 (WebCore::InbandWebVTTTextTrack::newCuesParsed): Use VTTCue's constructor instead of deprecated TextTrackCue constructor.
 33 * html/track/TextTrack.cpp:
 34 (WebCore::TextTrack::setMode): Convert to VTTCue as needed.
 35 (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.
 36 * html/track/TextTrack.h: Same as hasCue above.
 37 * html/track/TextTrackCue.cpp: Refactor a lot of code out. Everything that was removed went to VTTCue.cpp.
 38 (WebCore::TextTrackCue::create): For backwards compatibility, just call VTTCue::create().
 39 (WebCore::TextTrackCue::TextTrackCue): Refactor a lot of code out.
 40 (WebCore::TextTrackCue::~TextTrackCue): Same.
 41 (WebCore::TextTrackCue::didChange): Same.
 42 (WebCore::TextTrackCue::setIsActive): Same.
 43 * html/track/TextTrackCue.h: Same.
 44 * html/track/TextTrackCue.idl: Remove VTTCue attributes and add custom toJS function.
 45 * html/track/TextTrackCueGeneric.cpp: Use VTTCue instead of TextTrackCue.
 46 * html/track/TextTrackCueGeneric.h: Same.
 47 * html/track/VTTCue.cpp: Copied from Source/WebCore/html/track/TextTrackCue.cpp.
 48 * html/track/VTTCue.h: Copied from Source/WebCore/html/track/TextTrackCue.h.
 49 * html/track/VTTCue.idl: Copied from Source/WebCore/html/track/TextTrackCue.idl.
 50 * loader/TextTrackLoader.cpp:
 51 (WebCore::TextTrackLoader::getNewCues): Use VTTCue instead of TextTrackCue.
 52 * page/CaptionUserPreferencesMediaAF.cpp:
 53 (WebCore::CaptionUserPreferencesMediaAF::captionsStyleSheetOverride): Use VTTCueBox instead of TextTrackCueBox.
 54 * rendering/RenderVTTCue.cpp: Renamed from Source/WebCore/rendering/RenderTextTrackCue.cpp. Changed to use VTTCue instead of TextTrackCue.
 55 * rendering/RenderVTTCue.h: Renamed from Source/WebCore/rendering/RenderTextTrackCue.h. Changed to use VTTCue instead of TextTrackCue.
 56 * rendering/RenderingAllInOne.cpp: Rename RenderTextTrackCue to RenderVTTCue.
 57
1582014-02-07 Andreas Kling <akling@apple.com>
259
360 CTTE: DocumentThreadableLoader always has a Document.

Source/WebCore/CMakeLists.txt

@@set(WebCore_SOURCES
21832183 rendering/RenderTextControlSingleLine.cpp
21842184 rendering/RenderTextFragment.cpp
21852185 rendering/RenderTextLineBoxes.cpp
2186  rendering/RenderTextTrackCue.cpp
21872186 rendering/RenderTheme.cpp
21882187 rendering/RenderTreeAsText.cpp
21892188 rendering/RenderVideo.cpp
21902189 rendering/RenderView.cpp
 2190 rendering/RenderVTTCue.cpp
21912191 rendering/RenderWidget.cpp
21922192 rendering/RootInlineBox.cpp
21932193 rendering/ScrollBehavior.cpp

@@if (ENABLE_VIDEO_TRACK)
26982698 html/track/TrackEvent.idl
26992699 html/track/VideoTrack.idl
27002700 html/track/VideoTrackList.idl
 2701 html/track/VTTCue.idl
27012702 )
27022703
27032704 list(APPEND WebCore_SOURCES

@@if (ENABLE_VIDEO_TRACK)
27172718 html/track/TrackListBase.cpp
27182719 html/track/VideoTrack.cpp
27192720 html/track/VideoTrackList.cpp
 2721 html/track/VTTCue.cpp
27202722 html/track/WebVTTElement.cpp
27212723 html/track/WebVTTParser.cpp
27222724 html/track/WebVTTTokenizer.cpp

Source/WebCore/DerivedSources.cpp

469469#include "JSTextTrackCueList.cpp"
470470#include "JSTextTrackList.cpp"
471471#include "JSTrackEvent.cpp"
 472#include "JSVTTCue.cpp"
472473#include "JSVideoTrack.cpp"
473474#include "JSVideoTrackList.cpp"
474475#endif

Source/WebCore/DerivedSources.make

@@BINDING_IDLS = \
451451 $(WebCore)/html/track/TrackEvent.idl \
452452 $(WebCore)/html/track/VideoTrack.idl \
453453 $(WebCore)/html/track/VideoTrackList.idl \
 454 $(WebCore)/html/track/VTTCue.idl \
454455 $(WebCore)/inspector/CommandLineAPIHost.idl \
455456 $(WebCore)/inspector/InspectorFrontendHost.idl \
456457 $(WebCore)/inspector/ScriptProfile.idl \

Source/WebCore/GNUmakefile.list.am

@@webcore_built_sources += \
743743 DerivedSources/WebCore/JSVideoTrack.h \
744744 DerivedSources/WebCore/JSVideoTrackList.cpp \
745745 DerivedSources/WebCore/JSVideoTrackList.h \
 746 DerivedSources/WebCore/JSVTTCue.cpp \
 747 DerivedSources/WebCore/JSVTTCue.h \
746748 DerivedSources/WebCore/JSWaveShaperNode.cpp \
747749 DerivedSources/WebCore/JSWaveShaperNode.h \
748750 DerivedSources/WebCore/JSPeriodicWave.cpp \

@@dom_binding_idls += \
15431545 $(WebCore)/html/track/TrackEvent.idl \
15441546 $(WebCore)/html/track/VideoTrack.idl \
15451547 $(WebCore)/html/track/VideoTrackList.idl \
 1548 $(WebCore)/html/track/VTTCue.idl \
15461549 $(WebCore)/inspector/CommandLineAPIHost.idl \
15471550 $(WebCore)/inspector/InspectorFrontendHost.idl \
15481551 $(WebCore)/inspector/ScriptProfile.idl \

@@webcore_sources += \
36923695 Source/WebCore/html/track/VideoTrack.h \
36933696 Source/WebCore/html/track/VideoTrackList.cpp \
36943697 Source/WebCore/html/track/VideoTrackList.h \
 3698 Source/WebCore/html/track/VTTCue.cpp \
 3699 Source/WebCore/html/track/VTTCue.h \
36953700 Source/WebCore/html/track/WebVTTElement.cpp \
36963701 Source/WebCore/html/track/WebVTTElement.h \
36973702 Source/WebCore/html/track/WebVTTParser.cpp \

@@webcore_sources += \
44524457 Source/WebCore/rendering/RenderTextControlMultiLine.h \
44534458 Source/WebCore/rendering/RenderTextControlSingleLine.cpp \
44544459 Source/WebCore/rendering/RenderTextControlSingleLine.h \
4455  Source/WebCore/rendering/RenderTextTrackCue.cpp \
4456  Source/WebCore/rendering/RenderTextTrackCue.h \
44574460 Source/WebCore/rendering/RenderTextFragment.cpp \
44584461 Source/WebCore/rendering/RenderTextFragment.h \
44594462 Source/WebCore/rendering/RenderTextLineBoxes.cpp \

@@webcore_sources += \
44664469 Source/WebCore/rendering/RenderVideo.h \
44674470 Source/WebCore/rendering/RenderView.cpp \
44684471 Source/WebCore/rendering/RenderView.h \
 4472 Source/WebCore/rendering/RenderVTTCue.cpp \
 4473 Source/WebCore/rendering/RenderVTTCue.h \
44694474 Source/WebCore/rendering/RenderWidget.cpp \
44704475 Source/WebCore/rendering/RenderWidget.h \
44714476 Source/WebCore/rendering/RootInlineBox.cpp \

Source/WebCore/PlatformGTK.cmake

@@if (ENABLE_WEBKIT2)
650650 html/track/TrackEvent.idl
651651 html/track/VideoTrack.idl
652652 html/track/VideoTrackList.idl
 653 html/track/VTTCue.idl
653654 )
654655 endif ()
655656

Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

1096210962 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
1096310963 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
1096410964 </ClCompile>
10965  <ClCompile Include="..\rendering\RenderTextTrackCue.cpp">
 10965 <ClCompile Include="..\rendering\RenderTheme.cpp">
1096610966 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
1096710967 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1096810968 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>

1097610976 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
1097710977 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
1097810978 </ClCompile>
10979  <ClCompile Include="..\rendering\RenderTheme.cpp">
 10979 <ClCompile Include="..\rendering\RenderThemeSafari.cpp" />
 10980 <ClCompile Include="..\rendering\RenderThemeWin.cpp">
1098010981 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
1098110982 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1098210983 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>

1099010991 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
1099110992 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
1099210993 </ClCompile>
10993  <ClCompile Include="..\rendering\RenderThemeSafari.cpp" />
10994  <ClCompile Include="..\rendering\RenderThemeWin.cpp">
 10994 <ClCompile Include="..\rendering\RenderTreeAsText.cpp">
1099510995 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
1099610996 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1099710997 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>

1100511005 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
1100611006 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
1100711007 </ClCompile>
11008  <ClCompile Include="..\rendering\RenderTreeAsText.cpp">
 11008 <ClCompile Include="..\rendering\RenderVTTCue.cpp">
1100911009 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
1101011010 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1101111011 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>

1567115671 <ClCompile Include="..\html\track\TextTrackList.cpp" />
1567215672 <ClCompile Include="..\html\track\TrackBase.cpp" />
1567315673 <ClCompile Include="..\html\track\TrackEvent.cpp" />
 15674 <ClCompile Include="..\html\track\VTTCue.cpp" />
1567415675 <ClCompile Include="..\html\track\WebVTTParser.cpp" />
1567515676 <ClCompile Include="..\html\track\WebVTTTokenizer.cpp" />
1567615677 <ClCompile Include="..\bindings\generic\ActiveDOMCallback.cpp" />

1982419825 <ClInclude Include="..\rendering\RenderTextControlSingleLine.h" />
1982519826 <ClInclude Include="..\rendering\RenderTextFragment.h" />
1982619827 <ClInclude Include="..\rendering\RenderTextLineBoxes.h" />
19827  <ClInclude Include="..\rendering\RenderTextTrackCue.h" />
1982819828 <ClInclude Include="..\rendering\RenderTheme.h" />
1982919829 <CustomBuildStep Include="..\rendering\RenderThemeSafari.h" />
1983019830 <CustomBuildStep Include="..\rendering\RenderThemeWin.h" />
1983119831 <ClInclude Include="..\rendering\RenderTreeAsText.h" />
 19832 <ClInclude Include="..\rendering\RenderVTTCue.h" />
1983219833 <ClInclude Include="..\rendering\RenderVideo.h" />
1983319834 <ClInclude Include="..\rendering\RenderView.h" />
1983419835 <ClInclude Include="..\rendering\RenderWidget.h" />

2042620427 <ClInclude Include="..\html\track\TextTrackList.h" />
2042720428 <ClInclude Include="..\html\track\TrackBase.h" />
2042820429 <ClInclude Include="..\html\track\TrackEvent.h" />
 20430 <ClInclude Include="..\html\track\VTTCue.h" />
2042920431 <ClInclude Include="..\html\track\WebVTTParser.h" />
2043020432 <ClInclude Include="..\html\track\WebVTTToken.h" />
2043120433 <ClInclude Include="..\html\track\WebVTTTokenizer.h" />

Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

26612661 <ClCompile Include="..\rendering\RenderTextFragment.cpp">
26622662 <Filter>rendering</Filter>
26632663 </ClCompile>
2664  <ClCompile Include="..\rendering\RenderTextTrackCue.cpp">
2665  <Filter>rendering</Filter>
2666  </ClCompile>
26672664 <ClCompile Include="..\rendering\RenderTheme.cpp">
26682665 <Filter>rendering</Filter>
26692666 </ClCompile>

26762673 <ClCompile Include="..\rendering\RenderTreeAsText.cpp">
26772674 <Filter>rendering</Filter>
26782675 </ClCompile>
 2676 <ClCompile Include="..\rendering\RenderVTTCue.cpp">
 2677 <Filter>rendering</Filter>
 2678 </ClCompile>
26792679 <ClCompile Include="..\rendering\RenderVideo.cpp">
26802680 <Filter>rendering</Filter>
26812681 </ClCompile>

42004200 <ClCompile Include="..\html\track\TrackEvent.cpp">
42014201 <Filter>html\track</Filter>
42024202 </ClCompile>
 4203 <ClCompile Include="..\html\track\VTTCue.cpp">
 4204 <Filter>html\track</Filter>
 4205 </ClCompile>
42034206 <ClCompile Include="..\html\track\WebVTTParser.cpp">
42044207 <Filter>html\track</Filter>
42054208 </ClCompile>

94829485 <ClInclude Include="..\rendering\RenderTextFragment.h">
94839486 <Filter>rendering</Filter>
94849487 </ClInclude>
9485  <ClInclude Include="..\rendering\RenderTextTrackCue.h">
9486  <Filter>rendering</Filter>
9487  </ClInclude>
94889488 <ClInclude Include="..\rendering\RenderTheme.h">
94899489 <Filter>rendering</Filter>
94909490 </ClInclude>
94919491 <ClInclude Include="..\rendering\RenderTreeAsText.h">
94929492 <Filter>rendering</Filter>
94939493 </ClInclude>
 9494 <ClInclude Include="..\rendering\RenderVTTCue.h">
 9495 <Filter>rendering</Filter>
 9496 </ClInclude>
94949497 <ClInclude Include="..\rendering\RenderVideo.h">
94959498 <Filter>rendering</Filter>
94969499 </ClInclude>

1122211225 <ClInclude Include="..\html\track\TrackEvent.h">
1122311226 <Filter>html\track</Filter>
1122411227 </ClInclude>
 11228 <ClInclude Include="..\html\track\VTTCue.h">
 11229 <Filter>html\track</Filter>
 11230 </ClInclude>
1122511231 <ClInclude Include="..\html\track\WebVTTParser.h">
1122611232 <Filter>html\track</Filter>
1122711233 </ClInclude>

Source/WebCore/WebCore.xcodeproj/project.pbxproj

29332933 86BE340315058CB200CE0FD8 /* PerformanceEntryList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86BE33FD15058CB200CE0FD8 /* PerformanceEntryList.cpp */; };
29342934 86BE340415058CB200CE0FD8 /* PerformanceEntryList.h in Headers */ = {isa = PBXBuildFile; fileRef = 86BE33FE15058CB200CE0FD8 /* PerformanceEntryList.h */; };
29352935 86D982F7125C154000AD9E3D /* DocumentTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 86D982F6125C154000AD9E3D /* DocumentTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
2936  86FF886115DE3D0700BD6B28 /* RenderTextTrackCue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86FF885E15DE3B8200BD6B28 /* RenderTextTrackCue.cpp */; };
2937  86FF886215DE3D0700BD6B28 /* RenderTextTrackCue.h in Headers */ = {isa = PBXBuildFile; fileRef = 86FF885F15DE3B8200BD6B28 /* RenderTextTrackCue.h */; };
29382936 8931DE5B14C44C44000DC9D2 /* JSBlobCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8931DE5A14C44C44000DC9D2 /* JSBlobCustom.cpp */; };
29392937 898785F0122E1E87003AABDA /* JSFileException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 898785EE122E1E87003AABDA /* JSFileException.cpp */; };
29402938 898785F1122E1E87003AABDA /* JSFileException.h in Headers */ = {isa = PBXBuildFile; fileRef = 898785EF122E1E87003AABDA /* JSFileException.h */; };

53175315 BE16C59317CFE17200852C04 /* InbandGenericTextTrack.h in Headers */ = {isa = PBXBuildFile; fileRef = BE16C58F17CFE17200852C04 /* InbandGenericTextTrack.h */; };
53185316 BE16C59417CFE17200852C04 /* InbandWebVTTTextTrack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE16C59017CFE17200852C04 /* InbandWebVTTTextTrack.cpp */; };
53195317 BE16C59517CFE17200852C04 /* InbandWebVTTTextTrack.h in Headers */ = {isa = PBXBuildFile; fileRef = BE16C59117CFE17200852C04 /* InbandWebVTTTextTrack.h */; };
 5318 BE20507918A458680080647E /* VTTCue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE20507618A458460080647E /* VTTCue.cpp */; };
 5319 BE20507A18A4586B0080647E /* VTTCue.h in Headers */ = {isa = PBXBuildFile; fileRef = BE20507718A458460080647E /* VTTCue.h */; settings = {ATTRIBUTES = (Private, ); }; };
 5320 BE20507D18A458BF0080647E /* RenderVTTCue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE20507B18A458B10080647E /* RenderVTTCue.cpp */; };
 5321 BE20507E18A458C20080647E /* RenderVTTCue.h in Headers */ = {isa = PBXBuildFile; fileRef = BE20507C18A458B10080647E /* RenderVTTCue.h */; };
 5322 BE20508118A460BC0080647E /* JSVTTCue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE20507F18A460AA0080647E /* JSVTTCue.cpp */; };
 5323 BE20508218A460C30080647E /* JSVTTCue.h in Headers */ = {isa = PBXBuildFile; fileRef = BE20508018A460AA0080647E /* JSVTTCue.h */; };
53205324 BE6DF70B171CA2C500DD52B8 /* JSVideoTrackCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE6DF708171CA2C500DD52B8 /* JSVideoTrackCustom.cpp */; };
53215325 BE6DF70D171CA2C500DD52B8 /* JSVideoTrackListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE6DF70A171CA2C500DD52B8 /* JSVideoTrackListCustom.cpp */; };
53225326 BE6DF711171CA2DA00DD52B8 /* JSAudioTrackCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE6DF70E171CA2DA00DD52B8 /* JSAudioTrackCustom.cpp */; };

98249828 86BE33FE15058CB200CE0FD8 /* PerformanceEntryList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceEntryList.h; sourceTree = "<group>"; };
98259829 86BE33FF15058CB200CE0FD8 /* PerformanceEntryList.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PerformanceEntryList.idl; sourceTree = "<group>"; };
98269830 86D982F6125C154000AD9E3D /* DocumentTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentTiming.h; sourceTree = "<group>"; };
9827  86FF885E15DE3B8200BD6B28 /* RenderTextTrackCue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTextTrackCue.cpp; sourceTree = "<group>"; };
9828  86FF885F15DE3B8200BD6B28 /* RenderTextTrackCue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTextTrackCue.h; sourceTree = "<group>"; };
98299831 892ABE5C16EEE2AA009F3587 /* JSNavigatorStorageQuota.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNavigatorStorageQuota.cpp; sourceTree = "<group>"; };
98309832 892ABE5D16EEE2AA009F3587 /* JSNavigatorStorageQuota.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNavigatorStorageQuota.h; sourceTree = "<group>"; };
98319833 892ABE5F16EEE2E5009F3587 /* JSDOMWindowQuota.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMWindowQuota.h; sourceTree = "<group>"; };

1251612518 BE16C58F17CFE17200852C04 /* InbandGenericTextTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandGenericTextTrack.h; sourceTree = "<group>"; };
1251712519 BE16C59017CFE17200852C04 /* InbandWebVTTTextTrack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InbandWebVTTTextTrack.cpp; sourceTree = "<group>"; };
1251812520 BE16C59117CFE17200852C04 /* InbandWebVTTTextTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandWebVTTTextTrack.h; sourceTree = "<group>"; };
 12521 BE20507618A458460080647E /* VTTCue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VTTCue.cpp; sourceTree = "<group>"; };
 12522 BE20507718A458460080647E /* VTTCue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VTTCue.h; sourceTree = "<group>"; };
 12523 BE20507818A458460080647E /* VTTCue.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VTTCue.idl; sourceTree = "<group>"; };
 12524 BE20507B18A458B10080647E /* RenderVTTCue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderVTTCue.cpp; sourceTree = "<group>"; };
 12525 BE20507C18A458B10080647E /* RenderVTTCue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderVTTCue.h; sourceTree = "<group>"; };
 12526 BE20507F18A460AA0080647E /* JSVTTCue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVTTCue.cpp; sourceTree = "<group>"; };
 12527 BE20508018A460AA0080647E /* JSVTTCue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVTTCue.h; sourceTree = "<group>"; };
1251912528 BE6DF708171CA2C500DD52B8 /* JSVideoTrackCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVideoTrackCustom.cpp; sourceTree = "<group>"; };
1252012529 BE6DF70A171CA2C500DD52B8 /* JSVideoTrackListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVideoTrackListCustom.cpp; sourceTree = "<group>"; };
1252112530 BE6DF70E171CA2DA00DD52B8 /* JSAudioTrackCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAudioTrackCustom.cpp; sourceTree = "<group>"; };

1823618245 E44614130CD6826900FADA75 /* JSTimeRanges.h */,
1823718246 07846340145B151A00A58DF1 /* JSTrackEvent.cpp */,
1823818247 07846341145B151A00A58DF1 /* JSTrackEvent.h */,
 18248 BE20507F18A460AA0080647E /* JSVTTCue.cpp */,
 18249 BE20508018A460AA0080647E /* JSVTTCue.h */,
1823918250 15C77092100D3CA8005BA267 /* JSValidityState.cpp */,
1824018251 15C77091100D3CA8005BA267 /* JSValidityState.h */,
1824118252 BE8EF046171C9014009B48C3 /* JSVideoTrack.cpp */,

1910319114 070334D21459FFAC008D8D45 /* TrackEvent.idl */,
1910419115 BE88E0BF1715CE2600658D98 /* TrackListBase.cpp */,
1910519116 BE88E0C01715CE2600658D98 /* TrackListBase.h */,
 19117 BE20507618A458460080647E /* VTTCue.cpp */,
 19118 BE20507718A458460080647E /* VTTCue.h */,
 19119 BE20507818A458460080647E /* VTTCue.idl */,
1910619120 BE88E0D21715D2A200658D98 /* VideoTrack.cpp */,
1910719121 BE88E0D31715D2A200658D98 /* VideoTrack.h */,
1910819122 BE88E0D41715D2A200658D98 /* VideoTrack.idl */,

2175521769 BCEA484F097D93020094C9E4 /* RenderTextFragment.h */,
2175621770 E4C91A17180999FB00A17F6D /* RenderTextLineBoxes.cpp */,
2175721771 E4C91A15180999F100A17F6D /* RenderTextLineBoxes.h */,
21758  86FF885E15DE3B8200BD6B28 /* RenderTextTrackCue.cpp */,
21759  86FF885F15DE3B8200BD6B28 /* RenderTextTrackCue.h */,
2176021772 BCEA484A097D93020094C9E4 /* RenderTheme.cpp */,
2176121773 BCEA484B097D93020094C9E4 /* RenderTheme.h */,
2176221774 FED13D500CEA949700D89466 /* RenderThemeIOS.h */,

2176521777 BCEA4849097D93020094C9E4 /* RenderThemeMac.mm */,
2176621778 93955A4203D72932008635CE /* RenderTreeAsText.cpp */,
2176721779 93955A4103D72932008635CE /* RenderTreeAsText.h */,
 21780 BE20507B18A458B10080647E /* RenderVTTCue.cpp */,
 21781 BE20507C18A458B10080647E /* RenderVTTCue.h */,
2176821782 E4B41E330CBFB60900AF2ECE /* RenderVideo.cpp */,
2176921783 E4B41E340CBFB60900AF2ECE /* RenderVideo.h */,
2177021784 BCEA4828097D93020094C9E4 /* RenderView.cpp */,

2268822702 FD31601012B0267600C1A359 /* AudioListener.h in Headers */,
2268922703 0705852417FDC140005F2BCB /* MediaTrackConstraints.h in Headers */,
2269022704 A14832CA187F678000DA63A6 /* WebCoreThreadMessage.h in Headers */,
 22705 BE20507E18A458C20080647E /* RenderVTTCue.h in Headers */,
2269122706 FD31601312B0267600C1A359 /* AudioNode.h in Headers */,
2269222707 FD31601612B0267600C1A359 /* AudioNodeInput.h in Headers */,
2269322708 FD31601812B0267600C1A359 /* AudioNodeOutput.h in Headers */,

2502025035 083DAEA70F01A7FB00342754 /* RenderTextControlMultiLine.h in Headers */,
2502125036 083DAEA90F01A7FB00342754 /* RenderTextControlSingleLine.h in Headers */,
2502225037 BCEA488E097D93020094C9E4 /* RenderTextFragment.h in Headers */,
25023  86FF886215DE3D0700BD6B28 /* RenderTextTrackCue.h in Headers */,
2502425038 BCEA488A097D93020094C9E4 /* RenderTheme.h in Headers */,
2502525039 BCEA4887097D93020094C9E4 /* RenderThemeMac.h in Headers */,
2502625040 93F1998C08245E59001E9ABC /* RenderTreeAsText.h in Headers */,

2516925183 41D168EA10226E89009BC827 /* SharedWorkerRepository.h in Headers */,
2517025184 E1B7839C163740A70007B692 /* SharedWorkerStrategy.h in Headers */,
2517125185 41D168EE10226E89009BC827 /* SharedWorkerThread.h in Headers */,
 25186 BE20507A18A4586B0080647E /* VTTCue.h in Headers */,
2517225187 B2C3DA650D006CD600EF6F26 /* SimpleFontData.h in Headers */,
2517325188 E4B65A5C132FACB00070E7BE /* TileLayer.h in Headers */,
2517425189 C5A1EA7D152BCF08004D00B6 /* SimplifyMarkupCommand.h in Headers */,

2528525300 51D719F6181106E00016DC51 /* IDBVersionChangeEvent.h in Headers */,
2528625301 0FF50272102BA96A0066F39A /* StyleMedia.h in Headers */,
2528725302 BC5EB74E0E81E06700B25965 /* StyleMultiColData.h in Headers */,
 25303 BE20508218A460C30080647E /* JSVTTCue.h in Headers */,
2528825304 A80E6DFC0A199067007FB8C5 /* StyleProperties.h in Headers */,
2528925305 E1B25107152A0BB00069B779 /* StylePropertyShorthand.h in Headers */,
2529025306 BC2272E40E82EE9B00E7F975 /* StyleRareInheritedData.h in Headers */,

2692026936 FD31609412B026F700C1A359 /* FFTConvolver.cpp in Sources */,
2692126937 FD31609612B026F700C1A359 /* FFTFrame.cpp in Sources */,
2692226938 932AD70517EFA2C30038F8FF /* MainFrame.cpp in Sources */,
 26939 BE20507918A458680080647E /* VTTCue.cpp in Sources */,
2692326940 FD3160C012B0272A00C1A359 /* FFTFrameMac.cpp in Sources */,
2692426941 976D6C80122B8A3D001FD1F7 /* File.cpp in Sources */,
2692526942 934FE9E50B5CA539003E4A73 /* FileChooser.cpp in Sources */,

2815928176 8A7CC97012076F8A001D4588 /* PendingScript.cpp in Sources */,
2816028177 E526AF3F1727F8F200E41781 /* Performance.cpp in Sources */,
2816128178 0F54DCD81880F867003EEDBB /* DOMTouchEvent.mm in Sources */,
 28179 BE20508118A460BC0080647E /* JSVTTCue.cpp in Sources */,
2816228180 07DC5FD417D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp in Sources */,
2816328181 86BE340315058CB200CE0FD8 /* PerformanceEntryList.cpp in Sources */,
2816428182 8AF4E55511DC5A36000ED3DE /* PerformanceNavigation.cpp in Sources */,

2832828346 083DAEA60F01A7FB00342754 /* RenderTextControlMultiLine.cpp in Sources */,
2832928347 083DAEA80F01A7FB00342754 /* RenderTextControlSingleLine.cpp in Sources */,
2833028348 BCEA488D097D93020094C9E4 /* RenderTextFragment.cpp in Sources */,
28331  86FF886115DE3D0700BD6B28 /* RenderTextTrackCue.cpp in Sources */,
2833228349 BCEA4889097D93020094C9E4 /* RenderTheme.cpp in Sources */,
2833328350 BCEA4888097D93020094C9E4 /* RenderThemeMac.mm in Sources */,
2833428351 93F19AD508245E59001E9ABC /* RenderTreeAsText.cpp in Sources */,

2858428601 E139866315478474001E3F65 /* StyleResolver.cpp in Sources */,
2858528602 E4BBED4C14FCDBA1003F0B98 /* StyleRule.cpp in Sources */,
2858628603 E4946EAE156E64DD00D3297F /* StyleRuleImport.cpp in Sources */,
 28604 BE20507D18A458BF0080647E /* RenderVTTCue.cpp in Sources */,
2858728605 A8EA800D0A19516E00A8EF5F /* StyleSheet.cpp in Sources */,
2858828606 E4F9EEF2156D9FFA00D23E7E /* StyleSheetContents.cpp in Sources */,
2858928607 A8EA800B0A19516E00A8EF5F /* StyleSheetList.cpp in Sources */,

Source/WebCore/bindings/js/JSTextTrackCueCustom.cpp

2929
3030#include "JSTextTrackCue.h"
3131#include "JSTrackCustom.h"
 32#include "JSVTTCue.h"
3233#include "TextTrack.h"
3334
3435using namespace JSC;

@@bool JSTextTrackCueOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> h
5657 return visitor.containsOpaqueRoot(root(textTrackCue.track()));
5758}
5859
 60JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, TextTrackCue* cue)
 61{
 62 if (!cue)
 63 return jsNull();
 64
 65 JSObject* wrapper = getCachedWrapper(currentWorld(exec), cue);
 66
 67 if (wrapper)
 68 return wrapper;
 69
 70 // This switch will make more sense once we support DataCue
 71 switch (cue->cueType()) {
 72 case TextTrackCue::WebVTT:
 73 case TextTrackCue::Generic:
 74 return CREATE_DOM_WRAPPER(exec, globalObject, VTTCue, cue);
 75 default:
 76 ASSERT_NOT_REACHED();
 77 return jsNull();
 78 }
 79}
 80
5981void JSTextTrackCue::visitChildren(JSCell* cell, SlotVisitor& visitor)
6082{
6183 JSTextTrackCue* jsTextTrackCue = jsCast<JSTextTrackCue*>(cell);

Source/WebCore/html/HTMLMediaElement.cpp

@@void HTMLMediaElement::updateActiveTextTrackCues(double movieTime)
13741374 activeSetChanged = true;
13751375
13761376 for (size_t i = 0; i < currentCuesSize; ++i) {
1377  currentCues[i].data()->updateDisplayTree(movieTime);
 1377 TextTrackCue* cue = currentCues[i].data();
13781378
1379  if (!currentCues[i].data()->isActive())
 1379 if (cue->cueType() == TextTrackCue::WebVTT || cue->cueType() == TextTrackCue::Generic)
 1380 toVTTCue(cue)->updateDisplayTree(movieTime);
 1381
 1382 if (!cue->isActive())
13801383 activeSetChanged = true;
13811384 }
13821385

@@void HTMLMediaElement::textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue> c
16681671 m_currentlyActiveCues.remove(index);
16691672 }
16701673
1671  cue->removeDisplayTree();
 1674 if (cue->cueType() == TextTrackCue::WebVTT || cue->cueType() == TextTrackCue::Generic)
 1675 toVTTCue(cue.get())->removeDisplayTree();
16721676 updateActiveTextTrackCues(currentTime());
16731677}
16741678

Source/WebCore/html/HTMLMediaElement.h

4747#include "PODIntervalTree.h"
4848#include "TextTrack.h"
4949#include "TextTrackCue.h"
 50#include "VTTCue.h"
5051#include "VideoTrack.h"
5152#endif
5253

@@template <>
845846struct ValueToString<TextTrackCue*> {
846847 static String string(TextTrackCue* const& cue)
847848 {
848  return String::format("%p id=%s interval=%f-->%f cue=%s)", cue, cue->id().utf8().data(), cue->startTime(), cue->endTime(), cue->text().utf8().data());
 849 String text;
 850 if (cue->cueType() == TextTrackCue::WebVTT || cue->cueType() == TextTrackCue::Generic)
 851 text = toVTTCue(cue)->text();
 852 return String::format("%p id=%s interval=%f-->%f cue=%s)", cue, cue->id().utf8().data(), cue->startTime(), cue->endTime(), text.utf8().data());
849853 }
850854};
851855#endif

Source/WebCore/html/shadow/MediaControlElements.cpp

@@void MediaControlTextTrackContainerElement::updateDisplay()
12811281 // corresponding CSS boxes added to output, in text track cue order, run the
12821282 // following substeps:
12831283 for (size_t i = 0; i < activeCues.size(); ++i) {
1284  TextTrackCue* cue = activeCues[i].data();
 1284 TextTrackCue* textTrackCue = activeCues[i].data();
 1285 if (textTrackCue->cueType() != TextTrackCue::WebVTT && textTrackCue->cueType() != TextTrackCue::Generic)
 1286 continue;
 1287
 1288 VTTCue* cue = toVTTCue(textTrackCue);
12851289
12861290 ASSERT(cue->isActive());
12871291 if (!cue->track() || !cue->track()->isRendered() || !cue->isActive() || cue->text().isEmpty())
12881292 continue;
12891293
1290  RefPtr<TextTrackCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size());
 1294 RefPtr<VTTCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size());
12911295 if (displayBox->hasChildNodes() && !contains(displayBox.get())) {
12921296 // Note: the display tree of a cue is removed when the active flag of the cue is unset.
12931297 appendChild(displayBox, ASSERT_NO_EXCEPTION);

@@void MediaControlTextTrackContainerElement::updateTimerFired(Timer<MediaControlT
13371341 CueList activeCues = mediaElement->currentlyActiveCues();
13381342 for (size_t i = 0; i < activeCues.size(); ++i) {
13391343 TextTrackCue* cue = activeCues[i].data();
1340  cue->setFontSize(m_fontSize, m_videoDisplaySize.size(), m_fontSizeIsImportant);
 1344 if (cue->cueType() == TextTrackCue::WebVTT || cue->cueType() == TextTrackCue::Generic)
 1345 toVTTCue(cue)->setFontSize(m_fontSize, m_videoDisplaySize.size(), m_fontSizeIsImportant);
13411346 }
13421347 updateDisplay();
13431348}

Source/WebCore/html/track/InbandGenericTextTrack.cpp

@@void InbandGenericTextTrack::addGenericCue(InbandTextTrackPrivate* trackPrivate,
151151
152152 RefPtr<TextTrackCueGeneric> cue = TextTrackCueGeneric::create(*scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
153153 updateCueFromCueData(cue.get(), cueData.get());
154  if (hasCue(cue.get(), TextTrackCue::IgnoreDuration)) {
 154 if (hasCue(cue.get(), VTTCue::IgnoreDuration)) {
155155 LOG(Media, "InbandGenericTextTrack::addGenericCue ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n", cueData->startTime(), cueData->endTime(), cueData->content().utf8().data());
156156 return;
157157 }

Source/WebCore/html/track/InbandWebVTTTextTrack.cpp

@@void InbandWebVTTTextTrack::newCuesParsed()
6363 m_webVTTParser->getNewCues(cues);
6464 for (size_t i = 0; i < cues.size(); ++i) {
6565 RefPtr<WebVTTCueData> cueData = cues[i];
66  RefPtr<TextTrackCue> cue = TextTrackCue::create(*scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
 66 RefPtr<VTTCue> cue = VTTCue::create(*scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
6767 cue->setId(cueData->id());
6868 cue->setCueSettings(cueData->settings());
6969
70  if (hasCue(cue.get(), TextTrackCue::IgnoreDuration)) {
 70 if (hasCue(cue.get(), VTTCue::IgnoreDuration)) {
7171 LOG(Media, "InbandWebVTTTextTrack::newCuesParsed ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n", cueData->startTime(), cueData->endTime(), cueData->content().utf8().data());
7272 return;
7373 }

Source/WebCore/html/track/TextTrack.cpp

@@void TextTrack::setMode(const AtomicString& mode)
220220 if (mode == disabledKeyword() && m_client && m_cues)
221221 m_client->textTrackRemoveCues(this, m_cues.get());
222222
223  if (mode != showingKeyword() && m_cues)
224  for (size_t i = 0; i < m_cues->length(); ++i)
225  m_cues->item(i)->removeDisplayTree();
 223 if (mode != showingKeyword() && m_cues) {
 224 for (size_t i = 0; i < m_cues->length(); ++i) {
 225 TextTrackCue* cue = m_cues->item(i);
 226 if (cue->cueType() == TextTrackCue::WebVTT || cue->cueType() == TextTrackCue::Generic)
 227 toVTTCue(cue)->removeDisplayTree();
 228 }
 229 }
226230
227231 m_mode = mode;
228232

@@int TextTrack::trackIndexRelativeToRenderedTracks()
471475 return m_renderedTrackIndex;
472476}
473477
474 bool TextTrack::hasCue(TextTrackCue* cue, TextTrackCue::CueMatchRules match)
 478bool TextTrack::hasCue(VTTCue* cue, VTTCue::CueMatchRules match)
475479{
476480 if (cue->startTime() < 0 || cue->endTime() < 0)
477481 return false;

@@bool TextTrack::hasCue(TextTrackCue* cue, TextTrackCue::CueMatchRules match)
507511 return false;
508512
509513 existingCue = m_cues->item(searchStart - 1);
 514 if (existingCue->cueType() != TextTrackCue::WebVTT && existingCue->cueType() != TextTrackCue::Generic)
 515 continue;
 516
510517 if (!existingCue || cue->startTime() > existingCue->startTime())
511518 return false;
512519
513  if (!existingCue->isEqual(*cue, match))
 520 if (!toVTTCue(existingCue)->isEqual(*cue, match))
514521 continue;
515522
516523 return true;

@@bool TextTrack::hasCue(TextTrackCue* cue, TextTrackCue::CueMatchRules match)
519526
520527 size_t index = (searchStart + searchEnd) / 2;
521528 existingCue = m_cues->item(index);
522  if (cue->startTime() < existingCue->startTime() || (match != TextTrackCue::IgnoreDuration && cue->startTime() == existingCue->startTime() && cue->endTime() > existingCue->endTime()))
 529 if (cue->startTime() < existingCue->startTime() || (match != VTTCue::IgnoreDuration && cue->startTime() == existingCue->startTime() && cue->endTime() > existingCue->endTime()))
523530 searchEnd = index;
524531 else
525532 searchStart = index + 1;

Source/WebCore/html/track/TextTrack.h

3232#include "ExceptionCode.h"
3333#include "TextTrackCue.h"
3434#include "TrackBase.h"
 35#include "VTTCue.h"
3536#include <wtf/PassOwnPtr.h>
3637#include <wtf/RefCounted.h>
3738#include <wtf/text/WTFString.h>

@@public:
110111 void addCue(PassRefPtr<TextTrackCue>);
111112 virtual void removeCue(TextTrackCue*, ExceptionCode&);
112113
113  bool hasCue(TextTrackCue*, TextTrackCue::CueMatchRules = TextTrackCue::MatchAllFields);
 114 bool hasCue(VTTCue*, VTTCue::CueMatchRules = VTTCue::MatchAllFields);
114115
115116#if ENABLE(VIDEO_TRACK) && ENABLE(WEBVTT_REGIONS)
116117 TextTrackRegionList* regions();

Source/WebCore/html/track/TextTrackCue.cpp

4343#include "HTMLSpanElement.h"
4444#include "Logging.h"
4545#include "NodeTraversal.h"
46 #include "RenderTextTrackCue.h"
4746#include "Text.h"
4847#include "TextTrack.h"
4948#include "TextTrackCueList.h"
50 #include "WebVTTElement.h"
51 #include "WebVTTParser.h"
 49#include "VTTCue.h"
5250#include <wtf/MathExtras.h>
5351#include <wtf/text/StringBuilder.h>
5452
5553namespace WebCore {
5654
5755static const int invalidCueIndex = -1;
58 static const int undefinedPosition = -1;
5956
60 static const String& startKeyword()
 57PassRefPtr<TextTrackCue> TextTrackCue::create(ScriptExecutionContext& context, double start, double end, const String& content)
6158{
62  DEFINE_STATIC_LOCAL(const String, start, (ASCIILiteral("start")));
63  return start;
 59 return VTTCue::create(context, start, end, content);
6460}
6561
66 static const String& middleKeyword()
67 {
68  DEFINE_STATIC_LOCAL(const String, middle, (ASCIILiteral("middle")));
69  return middle;
70 }
71 
72 static const String& endKeyword()
73 {
74  DEFINE_STATIC_LOCAL(const String, end, (ASCIILiteral("end")));
75  return end;
76 }
77 
78 static const String& horizontalKeyword()
79 {
80  return emptyString();
81 }
82 
83 static const String& verticalGrowingLeftKeyword()
84 {
85  DEFINE_STATIC_LOCAL(const String, verticalrl, (ASCIILiteral("rl")));
86  return verticalrl;
87 }
88 
89 static const String& verticalGrowingRightKeyword()
90 {
91  DEFINE_STATIC_LOCAL(const String, verticallr, (ASCIILiteral("lr")));
92  return verticallr;
93 }
94 
95 // ----------------------------
96 
97 TextTrackCueBox::TextTrackCueBox(Document& document, TextTrackCue* cue)
98  : HTMLElement(divTag, document)
99  , m_cue(cue)
100 {
101  setPseudo(textTrackCueBoxShadowPseudoId());
102 }
103 
104 TextTrackCue* TextTrackCueBox::getCue() const
105 {
106  return m_cue;
107 }
108 
109 void TextTrackCueBox::applyCSSProperties(const IntSize&)
110 {
111  // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79916
112 
113  // 3.5.1 On the (root) List of WebVTT Node Objects:
114 
115  // the 'position' property must be set to 'absolute'
116  setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
117 
118  // the 'unicode-bidi' property must be set to 'plaintext'
119  setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueWebkitPlaintext);
120 
121  // the 'direction' property must be set to direction
122  setInlineStyleProperty(CSSPropertyDirection, m_cue->getCSSWritingDirection());
123 
124  // the 'writing-mode' property must be set to writing-mode
125  setInlineStyleProperty(CSSPropertyWebkitWritingMode, m_cue->getCSSWritingMode(), false);
126 
127  std::pair<float, float> position = m_cue->getCSSPosition();
128 
129  // the 'top' property must be set to top,
130  setInlineStyleProperty(CSSPropertyTop, static_cast<double>(position.second), CSSPrimitiveValue::CSS_PERCENTAGE);
131 
132  // the 'left' property must be set to left
133  setInlineStyleProperty(CSSPropertyLeft, static_cast<double>(position.first), CSSPrimitiveValue::CSS_PERCENTAGE);
134 
135  // the 'width' property must be set to width, and the 'height' property must be set to height
136  if (m_cue->vertical() == horizontalKeyword()) {
137  setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue->getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
138  setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto);
139  } else {
140  setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto);
141  setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue->getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
142  }
143 
144  // The 'text-align' property on the (root) List of WebVTT Node Objects must
145  // be set to the value in the second cell of the row of the table below
146  // whose first cell is the value of the corresponding cue's text track cue
147  // alignment:
148  if (m_cue->align() == startKeyword())
149  setInlineStyleProperty(CSSPropertyTextAlign, CSSValueStart);
150  else if (m_cue->align() == endKeyword())
151  setInlineStyleProperty(CSSPropertyTextAlign, CSSValueEnd);
152  else
153  setInlineStyleProperty(CSSPropertyTextAlign, CSSValueCenter);
154 
155  if (!m_cue->snapToLines()) {
156  // 10.13.1 Set up x and y:
157  // Note: x and y are set through the CSS left and top above.
158 
159  // 10.13.2 Position the boxes in boxes such that the point x% along the
160  // width of the bounding box of the boxes in boxes is x% of the way
161  // across the width of the video's rendering area, and the point y%
162  // along the height of the bounding box of the boxes in boxes is y%
163  // of the way across the height of the video's rendering area, while
164  // maintaining the relative positions of the boxes in boxes to each
165  // other.
166  setInlineStyleProperty(CSSPropertyWebkitTransform,
167  String::format("translate(-%.2f%%, -%.2f%%)", position.first, position.second));
168 
169  setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre);
170  }
171 }
172 
173 const AtomicString& TextTrackCueBox::textTrackCueBoxShadowPseudoId()
174 {
175  DEFINE_STATIC_LOCAL(const AtomicString, trackDisplayBoxShadowPseudoId, ("-webkit-media-text-track-display", AtomicString::ConstructFromLiteral));
176  return trackDisplayBoxShadowPseudoId;
177 }
178 
179 RenderPtr<RenderElement> TextTrackCueBox::createElementRenderer(PassRef<RenderStyle> style)
180 {
181  return createRenderer<RenderTextTrackCue>(*this, std::move(style));
182 }
183 
184 // ----------------------------
185 
186 TextTrackCue::TextTrackCue(ScriptExecutionContext& context, double start, double end, const String& content)
 62TextTrackCue::TextTrackCue(ScriptExecutionContext& context, double start, double end)
18763 : m_startTime(start)
18864 , m_endTime(end)
189  , m_content(content)
190  , m_linePosition(undefinedPosition)
191  , m_computedLinePosition(undefinedPosition)
192  , m_textPosition(50)
193  , m_cueSize(100)
19465 , m_cueIndex(invalidCueIndex)
19566 , m_processingCueChanges(0)
196  , m_writingDirection(Horizontal)
197  , m_cueAlignment(Middle)
198  , m_webVTTNodeTree(0)
19967 , m_track(0)
20068 , m_scriptExecutionContext(context)
20169 , m_isActive(false)
20270 , m_pauseOnExit(false)
203  , m_snapToLines(true)
204  , m_cueBackgroundBox(HTMLSpanElement::create(spanTag, toDocument(context)))
205  , m_displayTreeShouldChange(true)
206  , m_displayDirection(CSSValueLtr)
20771{
20872 ASSERT(m_scriptExecutionContext.isDocument());
209 
210  // 4. If the text track cue writing direction is horizontal, then let
211  // writing-mode be 'horizontal-tb'. Otherwise, if the text track cue writing
212  // direction is vertical growing left, then let writing-mode be
213  // 'vertical-rl'. Otherwise, the text track cue writing direction is
214  // vertical growing right; let writing-mode be 'vertical-lr'.
215  m_displayWritingModeMap[Horizontal] = CSSValueHorizontalTb;
216  m_displayWritingModeMap[VerticalGrowingLeft] = CSSValueVerticalRl;
217  m_displayWritingModeMap[VerticalGrowingRight] = CSSValueVerticalLr;
21873}
21974
22075TextTrackCue::~TextTrackCue()
22176{
222  removeDisplayTree();
223 }
224 
225 PassRefPtr<TextTrackCueBox> TextTrackCue::createDisplayTree()
226 {
227  return TextTrackCueBox::create(ownerDocument(), this);
228 }
229 
230 TextTrackCueBox* TextTrackCue::displayTreeInternal()
231 {
232  if (!m_displayTree)
233  m_displayTree = createDisplayTree();
234  return m_displayTree.get();
23577}
23678
23779void TextTrackCue::willChange()

@@void TextTrackCue::didChange()
25193
25294 if (m_track)
25395 m_track->cueDidChange(this);
254 
255  m_displayTreeShouldChange = true;
25696}
25797
25898TextTrack* TextTrackCue::track() const

@@void TextTrackCue::setPauseOnExit(bool value)
317157 m_pauseOnExit = value;
318158}
319159
320 const String& TextTrackCue::vertical() const
321 {
322  switch (m_writingDirection) {
323  case Horizontal:
324  return horizontalKeyword();
325  case VerticalGrowingLeft:
326  return verticalGrowingLeftKeyword();
327  case VerticalGrowingRight:
328  return verticalGrowingRightKeyword();
329  default:
330  ASSERT_NOT_REACHED();
331  return emptyString();
332  }
333 }
334 
335 void TextTrackCue::setVertical(const String& value, ExceptionCode& ec)
336 {
337  // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-vertical
338  // On setting, the text track cue writing direction must be set to the value given
339  // in the first cell of the row in the table above whose second cell is a
340  // case-sensitive match for the new value, if any. If none of the values match, then
341  // the user agent must instead throw a SyntaxError exception.
342 
343  WritingDirection direction = m_writingDirection;
344  if (value == horizontalKeyword())
345  direction = Horizontal;
346  else if (value == verticalGrowingLeftKeyword())
347  direction = VerticalGrowingLeft;
348  else if (value == verticalGrowingRightKeyword())
349  direction = VerticalGrowingRight;
350  else
351  ec = SYNTAX_ERR;
352 
353  if (direction == m_writingDirection)
354  return;
355 
356  willChange();
357  m_writingDirection = direction;
358  didChange();
359 }
360 
361 void TextTrackCue::setSnapToLines(bool value)
362 {
363  if (m_snapToLines == value)
364  return;
365 
366  willChange();
367  m_snapToLines = value;
368  didChange();
369 }
370 
371 void TextTrackCue::setLine(int position, ExceptionCode& ec)
372 {
373  // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line
374  // On setting, if the text track cue snap-to-lines flag is not set, and the new
375  // value is negative or greater than 100, then throw an IndexSizeError exception.
376  if (!m_snapToLines && (position < 0 || position > 100)) {
377  ec = INDEX_SIZE_ERR;
378  return;
379  }
380 
381  // Otherwise, set the text track cue line position to the new value.
382  if (m_linePosition == position)
383  return;
384 
385  willChange();
386  m_linePosition = position;
387  m_computedLinePosition = calculateComputedLinePosition();
388  didChange();
389 }
390 
391 void TextTrackCue::setPosition(int position, ExceptionCode& ec)
392 {
393  // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-position
394  // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception.
395  // Otherwise, set the text track cue text position to the new value.
396  if (position < 0 || position > 100) {
397  ec = INDEX_SIZE_ERR;
398  return;
399  }
400 
401  // Otherwise, set the text track cue line position to the new value.
402  if (m_textPosition == position)
403  return;
404 
405  willChange();
406  m_textPosition = position;
407  didChange();
408 }
409 
410 void TextTrackCue::setSize(int size, ExceptionCode& ec)
411 {
412  // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size
413  // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError
414  // exception. Otherwise, set the text track cue size to the new value.
415  if (size < 0 || size > 100) {
416  ec = INDEX_SIZE_ERR;
417  return;
418  }
419 
420  // Otherwise, set the text track cue line position to the new value.
421  if (m_cueSize == size)
422  return;
423 
424  willChange();
425  m_cueSize = size;
426  didChange();
427 }
428 
429 const String& TextTrackCue::align() const
430 {
431  switch (m_cueAlignment) {
432  case Start:
433  return startKeyword();
434  case Middle:
435  return middleKeyword();
436  case End:
437  return endKeyword();
438  default:
439  ASSERT_NOT_REACHED();
440  return emptyString();
441  }
442 }
443 
444 void TextTrackCue::setAlign(const String& value, ExceptionCode& ec)
445 {
446  // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-align
447  // On setting, the text track cue alignment must be set to the value given in the
448  // first cell of the row in the table above whose second cell is a case-sensitive
449  // match for the new value, if any. If none of the values match, then the user
450  // agent must instead throw a SyntaxError exception.
451 
452  CueAlignment alignment = m_cueAlignment;
453  if (value == startKeyword())
454  alignment = Start;
455  else if (value == middleKeyword())
456  alignment = Middle;
457  else if (value == endKeyword())
458  alignment = End;
459  else
460  ec = SYNTAX_ERR;
461 
462  if (alignment == m_cueAlignment)
463  return;
464 
465  willChange();
466  m_cueAlignment = alignment;
467  didChange();
468 }
469 
470 void TextTrackCue::setText(const String& text)
471 {
472  if (m_content == text)
473  return;
474 
475  willChange();
476  // Clear the document fragment but don't bother to create it again just yet as we can do that
477  // when it is requested.
478  m_webVTTNodeTree = 0;
479  m_content = text;
480  didChange();
481 }
482 
483160int TextTrackCue::cueIndex()
484161{
485162 if (m_cueIndex == invalidCueIndex) {

@@void TextTrackCue::invalidateCueIndex()
497174 m_cueIndex = invalidCueIndex;
498175}
499176
500 void TextTrackCue::createWebVTTNodeTree()
501 {
502  if (!m_webVTTNodeTree)
503  m_webVTTNodeTree = WebVTTParser::create(0, &m_scriptExecutionContext)->createDocumentFragmentFromCueText(m_content);
504 }
505 
506 void TextTrackCue::copyWebVTTNodeToDOMTree(ContainerNode* webVTTNode, ContainerNode* parent)
507 {
508  for (Node* node = webVTTNode->firstChild(); node; node = node->nextSibling()) {
509  RefPtr<Node> clonedNode;
510  if (node->isWebVTTElement())
511  clonedNode = toWebVTTElement(node)->createEquivalentHTMLElement(ownerDocument());
512  else
513  clonedNode = node->cloneNode(false);
514  parent->appendChild(clonedNode, ASSERT_NO_EXCEPTION);
515  if (node->isContainerNode())
516  copyWebVTTNodeToDOMTree(toContainerNode(node), toContainerNode(clonedNode.get()));
517  }
518 }
519 
520 PassRefPtr<DocumentFragment> TextTrackCue::getCueAsHTML()
521 {
522  createWebVTTNodeTree();
523  if (!m_webVTTNodeTree)
524  return 0;
525 
526  RefPtr<DocumentFragment> clonedFragment = DocumentFragment::create(ownerDocument());
527  copyWebVTTNodeToDOMTree(m_webVTTNodeTree.get(), clonedFragment.get());
528  return clonedFragment.release();
529 }
530 
531 PassRefPtr<DocumentFragment> TextTrackCue::createCueRenderingTree()
532 {
533  RefPtr<DocumentFragment> clonedFragment;
534  createWebVTTNodeTree();
535  if (!m_webVTTNodeTree)
536  return 0;
537 
538  clonedFragment = DocumentFragment::create(ownerDocument());
539  m_webVTTNodeTree->cloneChildNodes(clonedFragment.get());
540  return clonedFragment.release();
541 }
542 
543177bool TextTrackCue::dispatchEvent(PassRefPtr<Event> event)
544178{
545179 // When a TextTrack's mode is disabled: no cues are active, no events fired.

@@bool TextTrackCue::dispatchEvent(PassRefPtr<Event> event)
549183 return EventTarget::dispatchEvent(event);
550184}
551185
552 #if ENABLE(WEBVTT_REGIONS)
553 void TextTrackCue::setRegionId(const String& regionId)
554 {
555  if (m_regionId == regionId)
556  return;
557 
558  willChange();
559  m_regionId = regionId;
560  didChange();
561 }
562 #endif
563 
564186bool TextTrackCue::isActive()
565187{
566188 return m_isActive && track() && track()->mode() != TextTrack::disabledKeyword();

@@bool TextTrackCue::isActive()
569191void TextTrackCue::setIsActive(bool active)
570192{
571193 m_isActive = active;
572 
573  if (!active) {
574  if (!hasDisplayTree())
575  return;
576 
577  // Remove the display tree as soon as the cue becomes inactive.
578  displayTreeInternal()->remove(ASSERT_NO_EXCEPTION);
579  }
580 }
581 
582 int TextTrackCue::calculateComputedLinePosition()
583 {
584  // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#text-track-cue-computed-line-position
585 
586  // If the text track cue line position is numeric, then that is the text
587  // track cue computed line position.
588  if (m_linePosition != undefinedPosition)
589  return m_linePosition;
590 
591  // If the text track cue snap-to-lines flag of the text track cue is not
592  // set, the text track cue computed line position is the value 100;
593  if (!m_snapToLines)
594  return 100;
595 
596  // Otherwise, it is the value returned by the following algorithm:
597 
598  // If cue is not associated with a text track, return -1 and abort these
599  // steps.
600  if (!track())
601  return -1;
602 
603  // Let n be the number of text tracks whose text track mode is showing or
604  // showing by default and that are in the media element's list of text
605  // tracks before track.
606  int n = track()->trackIndexRelativeToRenderedTracks();
607 
608  // Increment n by one.
609  n++;
610 
611  // Negate n.
612  n = -n;
613 
614  return n;
615 }
616 
617 static bool isCueParagraphSeparator(UChar character)
618 {
619  // Within a cue, paragraph boundaries are only denoted by Type B characters,
620  // such as U+000A LINE FEED (LF), U+0085 NEXT LINE (NEL), and U+2029 PARAGRAPH SEPARATOR.
621  return u_charType(character) == U_PARAGRAPH_SEPARATOR;
622 }
623 
624 void TextTrackCue::determineTextDirection()
625 {
626  DEFINE_STATIC_LOCAL(const String, rtTag, (ASCIILiteral("rt")));
627  createWebVTTNodeTree();
628  if (!m_webVTTNodeTree)
629  return;
630 
631  // Apply the Unicode Bidirectional Algorithm's Paragraph Level steps to the
632  // concatenation of the values of each WebVTT Text Object in nodes, in a
633  // pre-order, depth-first traversal, excluding WebVTT Ruby Text Objects and
634  // their descendants.
635  StringBuilder paragraphBuilder;
636  for (Node* node = m_webVTTNodeTree->firstChild(); node; node = NodeTraversal::next(node, m_webVTTNodeTree.get())) {
637  // FIXME: The code does not match the comment above. This does not actually exclude Ruby Text Object descendant.
638  if (!node->isTextNode() || node->localName() == rtTag)
639  continue;
640 
641  paragraphBuilder.append(node->nodeValue());
642  }
643 
644  String paragraph = paragraphBuilder.toString();
645  if (!paragraph.length())
646  return;
647 
648  for (size_t i = 0; i < paragraph.length(); ++i) {
649  UChar current = paragraph[i];
650  if (!current || isCueParagraphSeparator(current))
651  return;
652 
653  if (UChar current = paragraph[i]) {
654  UCharDirection charDirection = u_charDirection(current);
655  if (charDirection == U_LEFT_TO_RIGHT) {
656  m_displayDirection = CSSValueLtr;
657  return;
658  }
659  if (charDirection == U_RIGHT_TO_LEFT || charDirection == U_RIGHT_TO_LEFT_ARABIC) {
660  m_displayDirection = CSSValueRtl;
661  return;
662  }
663  }
664  }
665 }
666 
667 void TextTrackCue::calculateDisplayParameters()
668 {
669  // Steps 10.2, 10.3
670  determineTextDirection();
671 
672  // 10.4 If the text track cue writing direction is horizontal, then let
673  // block-flow be 'tb'. Otherwise, if the text track cue writing direction is
674  // vertical growing left, then let block-flow be 'lr'. Otherwise, the text
675  // track cue writing direction is vertical growing right; let block-flow be
676  // 'rl'.
677  m_displayWritingMode = m_displayWritingModeMap[m_writingDirection];
678 
679  // 10.5 Determine the value of maximum size for cue as per the appropriate
680  // rules from the following list:
681  int maximumSize = m_textPosition;
682  if ((m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueLtr)
683  || (m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueRtl)
684  || (m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Start)
685  || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Start)) {
686  maximumSize = 100 - m_textPosition;
687  } else if ((m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueLtr)
688  || (m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueRtl)
689  || (m_writingDirection == VerticalGrowingLeft && m_cueAlignment == End)
690  || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == End)) {
691  maximumSize = m_textPosition;
692  } else if (m_cueAlignment == Middle) {
693  maximumSize = m_textPosition <= 50 ? m_textPosition : (100 - m_textPosition);
694  maximumSize = maximumSize * 2;
695  }
696 
697  // 10.6 If the text track cue size is less than maximum size, then let size
698  // be text track cue size. Otherwise, let size be maximum size.
699  m_displaySize = std::min(m_cueSize, maximumSize);
700 
701  // 10.8 Determine the value of x-position or y-position for cue as per the
702  // appropriate rules from the following list:
703  if (m_writingDirection == Horizontal) {
704  if (m_cueAlignment == Start) {
705  if (m_displayDirection == CSSValueLtr)
706  m_displayPosition.first = m_textPosition;
707  else
708  m_displayPosition.first = 100 - m_textPosition - m_displaySize;
709  } else if (m_cueAlignment == End) {
710  if (m_displayDirection == CSSValueRtl)
711  m_displayPosition.first = 100 - m_textPosition;
712  else
713  m_displayPosition.first = m_textPosition - m_displaySize;
714  }
715  }
716 
717  if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Start)
718  || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Start)) {
719  m_displayPosition.second = m_textPosition;
720  } else if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == End)
721  || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == End)) {
722  m_displayPosition.second = 100 - m_textPosition;
723  }
724 
725  if (m_writingDirection == Horizontal && m_cueAlignment == Middle) {
726  if (m_displayDirection == CSSValueLtr)
727  m_displayPosition.first = m_textPosition - m_displaySize / 2;
728  else
729  m_displayPosition.first = 100 - m_textPosition - m_displaySize / 2;
730  }
731 
732  if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Middle)
733  || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Middle))
734  m_displayPosition.second = m_textPosition - m_displaySize / 2;
735 
736  // 10.9 Determine the value of whichever of x-position or y-position is not
737  // yet calculated for cue as per the appropriate rules from the following
738  // list:
739  if (m_snapToLines && m_displayPosition.second == undefinedPosition && m_writingDirection == Horizontal)
740  m_displayPosition.second = 0;
741 
742  if (!m_snapToLines && m_displayPosition.second == undefinedPosition && m_writingDirection == Horizontal)
743  m_displayPosition.second = m_computedLinePosition;
744 
745  if (m_snapToLines && m_displayPosition.first == undefinedPosition
746  && (m_writingDirection == VerticalGrowingLeft || m_writingDirection == VerticalGrowingRight))
747  m_displayPosition.first = 0;
748 
749  if (!m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writingDirection == VerticalGrowingRight))
750  m_displayPosition.first = m_computedLinePosition;
751 
752  // A text track cue has a text track cue computed line position whose value
753  // is defined in terms of the other aspects of the cue.
754  m_computedLinePosition = calculateComputedLinePosition();
755 }
756 
757 void TextTrackCue::markFutureAndPastNodes(ContainerNode* root, double previousTimestamp, double movieTime)
758 {
759  DEFINE_STATIC_LOCAL(const String, timestampTag, (ASCIILiteral("timestamp")));
760 
761  bool isPastNode = true;
762  double currentTimestamp = previousTimestamp;
763  if (currentTimestamp > movieTime)
764  isPastNode = false;
765 
766  for (Node* child = root->firstChild(); child; child = NodeTraversal::next(child, root)) {
767  if (child->nodeName() == timestampTag) {
768  unsigned position = 0;
769  String timestamp = child->nodeValue();
770  double currentTimestamp = WebVTTParser::create(0, &m_scriptExecutionContext)->collectTimeStamp(timestamp, &position);
771  ASSERT(currentTimestamp != -1);
772 
773  if (currentTimestamp > movieTime)
774  isPastNode = false;
775  }
776 
777  if (child->isWebVTTElement()) {
778  toWebVTTElement(child)->setIsPastNode(isPastNode);
779  // Make an elemenet id match a cue id for style matching purposes.
780  if (!m_id.isEmpty())
781  toElement(child)->setIdAttribute(m_id);
782  }
783  }
784 }
785 
786 void TextTrackCue::updateDisplayTree(double movieTime)
787 {
788  // The display tree may contain WebVTT timestamp objects representing
789  // timestamps (processing instructions), along with displayable nodes.
790 
791  if (!track()->isRendered())
792  return;
793 
794  // Clear the contents of the set.
795  m_cueBackgroundBox->removeChildren();
796 
797  // Update the two sets containing past and future WebVTT objects.
798  RefPtr<DocumentFragment> referenceTree = createCueRenderingTree();
799  if (!referenceTree)
800  return;
801 
802  markFutureAndPastNodes(referenceTree.get(), startTime(), movieTime);
803  m_cueBackgroundBox->appendChild(referenceTree);
804 }
805 
806 TextTrackCueBox* TextTrackCue::getDisplayTree(const IntSize& videoSize)
807 {
808  RefPtr<TextTrackCueBox> displayTree = displayTreeInternal();
809  if (!m_displayTreeShouldChange || !track()->isRendered())
810  return displayTree.get();
811 
812  // 10.1 - 10.10
813  calculateDisplayParameters();
814 
815  // 10.11. Apply the terms of the CSS specifications to nodes within the
816  // following constraints, thus obtaining a set of CSS boxes positioned
817  // relative to an initial containing block:
818  displayTree->removeChildren();
819 
820  // The document tree is the tree of WebVTT Node Objects rooted at nodes.
821 
822  // The children of the nodes must be wrapped in an anonymous box whose
823  // 'display' property has the value 'inline'. This is the WebVTT cue
824  // background box.
825 
826  // Note: This is contained by default in m_cueBackgroundBox.
827  m_cueBackgroundBox->setPseudo(cueShadowPseudoId());
828  displayTree->appendChild(m_cueBackgroundBox, ASSERT_NO_EXCEPTION);
829 
830  // FIXME(BUG 79916): Runs of children of WebVTT Ruby Objects that are not
831  // WebVTT Ruby Text Objects must be wrapped in anonymous boxes whose
832  // 'display' property has the value 'ruby-base'.
833 
834  // FIXME(BUG 79916): Text runs must be wrapped according to the CSS
835  // line-wrapping rules, except that additionally, regardless of the value of
836  // the 'white-space' property, lines must be wrapped at the edge of their
837  // containing blocks, even if doing so requires splitting a word where there
838  // is no line breaking opportunity. (Thus, normally text wraps as needed,
839  // but if there is a particularly long word, it does not overflow as it
840  // normally would in CSS, it is instead forcibly wrapped at the box's edge.)
841  displayTree->applyCSSProperties(videoSize);
842 
843  m_displayTreeShouldChange = false;
844 
845  // 10.15. Let cue's text track cue display state have the CSS boxes in
846  // boxes.
847  return displayTree.get();
848 }
849 
850 void TextTrackCue::removeDisplayTree()
851 {
852  if (!hasDisplayTree())
853  return;
854  displayTreeInternal()->remove(ASSERT_NO_EXCEPTION);
855 }
856 
857 std::pair<double, double> TextTrackCue::getPositionCoordinates() const
858 {
859  // This method is used for setting x and y when snap to lines is not set.
860  std::pair<double, double> coordinates;
861 
862  if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) {
863  coordinates.first = m_textPosition;
864  coordinates.second = m_computedLinePosition;
865 
866  return coordinates;
867  }
868 
869  if (m_writingDirection == Horizontal && m_displayDirection == CSSValueRtl) {
870  coordinates.first = 100 - m_textPosition;
871  coordinates.second = m_computedLinePosition;
872 
873  return coordinates;
874  }
875 
876  if (m_writingDirection == VerticalGrowingLeft) {
877  coordinates.first = 100 - m_computedLinePosition;
878  coordinates.second = m_textPosition;
879 
880  return coordinates;
881  }
882 
883  if (m_writingDirection == VerticalGrowingRight) {
884  coordinates.first = m_computedLinePosition;
885  coordinates.second = m_textPosition;
886 
887  return coordinates;
888  }
889 
890  ASSERT_NOT_REACHED();
891 
892  return coordinates;
893 }
894 
895 TextTrackCue::CueSetting TextTrackCue::settingName(const String& name)
896 {
897  DEFINE_STATIC_LOCAL(const String, verticalKeyword, (ASCIILiteral("vertical")));
898  DEFINE_STATIC_LOCAL(const String, lineKeyword, (ASCIILiteral("line")));
899  DEFINE_STATIC_LOCAL(const String, positionKeyword, (ASCIILiteral("position")));
900  DEFINE_STATIC_LOCAL(const String, sizeKeyword, (ASCIILiteral("size")));
901  DEFINE_STATIC_LOCAL(const String, alignKeyword, (ASCIILiteral("align")));
902 #if ENABLE(WEBVTT_REGIONS)
903  DEFINE_STATIC_LOCAL(const String, regionIdKeyword, (ASCIILiteral("region")));
904 #endif
905 
906  if (name == verticalKeyword)
907  return Vertical;
908  else if (name == lineKeyword)
909  return Line;
910  else if (name == positionKeyword)
911  return Position;
912  else if (name == sizeKeyword)
913  return Size;
914  else if (name == alignKeyword)
915  return Align;
916 #if ENABLE(WEBVTT_REGIONS)
917  else if (name == regionIdKeyword)
918  return RegionId;
919 #endif
920 
921  return None;
922 }
923 
924 void TextTrackCue::setCueSettings(const String& input)
925 {
926  m_settings = input;
927  unsigned position = 0;
928 
929  while (position < input.length()) {
930 
931  // The WebVTT cue settings part of a WebVTT cue consists of zero or more of the following components, in any order,
932  // separated from each other by one or more U+0020 SPACE characters or U+0009 CHARACTER TABULATION (tab) characters.
933  while (position < input.length() && WebVTTParser::isValidSettingDelimiter(input[position]))
934  position++;
935  if (position >= input.length())
936  break;
937 
938  // When the user agent is to parse the WebVTT settings given by a string input for a text track cue cue,
939  // the user agent must run the following steps:
940  // 1. Let settings be the result of splitting input on spaces.
941  // 2. For each token setting in the list settings, run the following substeps:
942  // 1. If setting does not contain a U+003A COLON character (:), or if the first U+003A COLON character (:)
943  // in setting is either the first or last character of setting, then jump to the step labeled next setting.
944  unsigned endOfSetting = position;
945  String setting = WebVTTParser::collectWord(input, &endOfSetting);
946  CueSetting name;
947  size_t colonOffset = setting.find(':', 1);
948  if (colonOffset == notFound || colonOffset == 0 || colonOffset == setting.length() - 1)
949  goto NextSetting;
950 
951  // 2. Let name be the leading substring of setting up to and excluding the first U+003A COLON character (:) in that string.
952  name = settingName(setting.substring(0, colonOffset));
953 
954  // 3. Let value be the trailing substring of setting starting from the character immediately after the first U+003A COLON character (:) in that string.
955  position += colonOffset + 1;
956  if (position >= input.length())
957  break;
958 
959  // 4. Run the appropriate substeps that apply for the value of name, as follows:
960  switch (name) {
961  case Vertical:
962  {
963  // If name is a case-sensitive match for "vertical"
964  // 1. If value is a case-sensitive match for the string "rl", then let cue's text track cue writing direction
965  // be vertical growing left.
966  String writingDirection = WebVTTParser::collectWord(input, &position);
967  if (writingDirection == verticalGrowingLeftKeyword())
968  m_writingDirection = VerticalGrowingLeft;
969 
970  // 2. Otherwise, if value is a case-sensitive match for the string "lr", then let cue's text track cue writing
971  // direction be vertical growing right.
972  else if (writingDirection == verticalGrowingRightKeyword())
973  m_writingDirection = VerticalGrowingRight;
974  }
975  break;
976  case Line:
977  {
978  // 1-2 - Collect chars that are either '-', '%', or a digit.
979  // 1. If value contains any characters other than U+002D HYPHEN-MINUS characters (-), U+0025 PERCENT SIGN
980  // characters (%), and characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump
981  // to the step labeled next setting.
982  StringBuilder linePositionBuilder;
983  while (position < input.length() && (input[position] == '-' || input[position] == '%' || isASCIIDigit(input[position])))
984  linePositionBuilder.append(input[position++]);
985  if (position < input.length() && !WebVTTParser::isValidSettingDelimiter(input[position]))
986  break;
987 
988  // 2. If value does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
989  // NINE (9), then jump to the step labeled next setting.
990  // 3. If any character in value other than the first character is a U+002D HYPHEN-MINUS character (-), then
991  // jump to the step labeled next setting.
992  // 4. If any character in value other than the last character is a U+0025 PERCENT SIGN character (%), then
993  // jump to the step labeled next setting.
994  String linePosition = linePositionBuilder.toString();
995  if (linePosition.find('-', 1) != notFound || linePosition.reverseFind("%", linePosition.length() - 2) != notFound)
996  break;
997 
998  // 5. If the first character in value is a U+002D HYPHEN-MINUS character (-) and the last character in value is a
999  // U+0025 PERCENT SIGN character (%), then jump to the step labeled next setting.
1000  if (linePosition[0] == '-' && linePosition[linePosition.length() - 1] == '%')
1001  break;
1002 
1003  // 6. Ignoring the trailing percent sign, if any, interpret value as a (potentially signed) integer, and
1004  // let number be that number.
1005  // NOTE: toInt ignores trailing non-digit characters, such as '%'.
1006  bool validNumber;
1007  int number = linePosition.toInt(&validNumber);
1008  if (!validNumber)
1009  break;
1010 
1011  // 7. If the last character in value is a U+0025 PERCENT SIGN character (%), but number is not in the range
1012  // 0 ≤ number ≤ 100, then jump to the step labeled next setting.
1013  // 8. Let cue's text track cue line position be number.
1014  // 9. If the last character in value is a U+0025 PERCENT SIGN character (%), then let cue's text track cue
1015  // snap-to-lines flag be false. Otherwise, let it be true.
1016  if (linePosition[linePosition.length() - 1] == '%') {
1017  if (number < 0 || number > 100)
1018  break;
1019 
1020  // 10 - If '%' then set snap-to-lines flag to false.
1021  m_snapToLines = false;
1022  }
1023 
1024  m_linePosition = number;
1025  }
1026  break;
1027  case Position:
1028  {
1029  // 1. If value contains any characters other than U+0025 PERCENT SIGN characters (%) and characters in the range
1030  // U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump to the step labeled next setting.
1031  // 2. If value does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9),
1032  // then jump to the step labeled next setting.
1033  String textPosition = WebVTTParser::collectDigits(input, &position);
1034  if (textPosition.isEmpty())
1035  break;
1036  if (position >= input.length())
1037  break;
1038 
1039  // 3. If any character in value other than the last character is a U+0025 PERCENT SIGN character (%), then jump
1040  // to the step labeled next setting.
1041  // 4. If the last character in value is not a U+0025 PERCENT SIGN character (%), then jump to the step labeled
1042  // next setting.
1043  if (input[position++] != '%')
1044  break;
1045  if (position < input.length() && !WebVTTParser::isValidSettingDelimiter(input[position]))
1046  break;
1047 
1048  // 5. Ignoring the trailing percent sign, interpret value as an integer, and let number be that number.
1049  // 6. If number is not in the range 0 ≤ number ≤ 100, then jump to the step labeled next setting.
1050  // NOTE: toInt ignores trailing non-digit characters, such as '%'.
1051  bool validNumber;
1052  int number = textPosition.toInt(&validNumber);
1053  if (!validNumber)
1054  break;
1055  if (number < 0 || number > 100)
1056  break;
1057 
1058  // 7. Let cue's text track cue text position be number.
1059  m_textPosition = number;
1060  }
1061  break;
1062  case Size:
1063  {
1064  // 1. If value contains any characters other than U+0025 PERCENT SIGN characters (%) and characters in the
1065  // range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump to the step labeled next setting.
1066  // 2. If value does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
1067  // NINE (9), then jump to the step labeled next setting.
1068  String cueSize = WebVTTParser::collectDigits(input, &position);
1069  if (cueSize.isEmpty())
1070  break;
1071  if (position >= input.length())
1072  break;
1073 
1074  // 3. If any character in value other than the last character is a U+0025 PERCENT SIGN character (%),
1075  // then jump to the step labeled next setting.
1076  // 4. If the last character in value is not a U+0025 PERCENT SIGN character (%), then jump to the step
1077  // labeled next setting.
1078  if (input[position++] != '%')
1079  break;
1080  if (position < input.length() && !WebVTTParser::isValidSettingDelimiter(input[position]))
1081  break;
1082 
1083  // 5. Ignoring the trailing percent sign, interpret value as an integer, and let number be that number.
1084  // 6. If number is not in the range 0 ≤ number ≤ 100, then jump to the step labeled next setting.
1085  bool validNumber;
1086  int number = cueSize.toInt(&validNumber);
1087  if (!validNumber)
1088  break;
1089  if (number < 0 || number > 100)
1090  break;
1091 
1092  // 7. Let cue's text track cue size be number.
1093  m_cueSize = number;
1094  }
1095  break;
1096  case Align:
1097  {
1098  String cueAlignment = WebVTTParser::collectWord(input, &position);
1099 
1100  // 1. If value is a case-sensitive match for the string "start", then let cue's text track cue alignment be start alignment.
1101  if (cueAlignment == startKeyword())
1102  m_cueAlignment = Start;
1103 
1104  // 2. If value is a case-sensitive match for the string "middle", then let cue's text track cue alignment be middle alignment.
1105  else if (cueAlignment == middleKeyword())
1106  m_cueAlignment = Middle;
1107 
1108  // 3. If value is a case-sensitive match for the string "end", then let cue's text track cue alignment be end alignment.
1109  else if (cueAlignment == endKeyword())
1110  m_cueAlignment = End;
1111  }
1112  break;
1113 #if ENABLE(WEBVTT_REGIONS)
1114  case RegionId:
1115  m_regionId = WebVTTParser::collectWord(input, &position);
1116  break;
1117 #endif
1118  case None:
1119  break;
1120  }
1121 
1122 NextSetting:
1123  position = endOfSetting;
1124  }
1125 #if ENABLE(WEBVTT_REGIONS)
1126  // If cue's line position is not auto or cue's size is not 100 or cue's
1127  // writing direction is not horizontal, but cue's region identifier is not
1128  // the empty string, let cue's region identifier be the empty string.
1129  if (m_regionId.isEmpty())
1130  return;
1131 
1132  if (m_linePosition != undefinedPosition || m_cueSize != 100 || m_writingDirection != Horizontal)
1133  m_regionId = emptyString();
1134 #endif
1135 }
1136 
1137 CSSValueID TextTrackCue::getCSSWritingDirection() const
1138 {
1139  return m_displayDirection;
1140 }
1141 
1142 CSSValueID TextTrackCue::getCSSWritingMode() const
1143 {
1144  return m_displayWritingMode;
1145 }
1146 
1147 int TextTrackCue::getCSSSize() const
1148 {
1149  return m_displaySize;
1150 }
1151 
1152 std::pair<double, double> TextTrackCue::getCSSPosition() const
1153 {
1154  if (!m_snapToLines)
1155  return getPositionCoordinates();
1156 
1157  return m_displayPosition;
1158 }
1159 
1160 bool TextTrackCue::isEqual(const TextTrackCue& cue, CueMatchRules match) const
1161 {
1162  if (cueType() != cue.cueType())
1163  return false;
1164 
1165  if (match != IgnoreDuration && m_endTime != cue.endTime())
1166  return false;
1167  if (m_startTime != cue.startTime())
1168  return false;
1169  if (m_content != cue.text())
1170  return false;
1171  if (m_settings != cue.cueSettings())
1172  return false;
1173  if (m_id != cue.id())
1174  return false;
1175  if (m_textPosition != cue.position())
1176  return false;
1177  if (m_linePosition != cue.line())
1178  return false;
1179  if (m_cueSize != cue.size())
1180  return false;
1181  if (align() != cue.align())
1182  return false;
1183 
1184  return true;
1185194}
1186195
1187196bool TextTrackCue::isOrderedBefore(const TextTrackCue* other) const

@@bool TextTrackCue::isOrderedBefore(const TextTrackCue* other) const
1189198 return startTime() < other->startTime() || (startTime() == other->startTime() && endTime() > other->endTime());
1190199}
1191200
1192 void TextTrackCue::setFontSize(int fontSize, const IntSize&, bool important)
1193 {
1194  if (!hasDisplayTree() || !fontSize)
1195  return;
1196 
1197  LOG(Media, "TextTrackCue::setFontSize - setting cue font size to %i", fontSize);
1198 
1199  displayTreeInternal()->setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX, important);
1200 }
1201 
1202201} // namespace WebCore
1203202
1204203#endif

Source/WebCore/html/track/TextTrackCue.h

4141
4242namespace WebCore {
4343
44 class DocumentFragment;
45 class HTMLSpanElement;
46 class ScriptExecutionContext;
4744class TextTrack;
48 class TextTrackCue;
49 
50 // ----------------------------
51 
52 class TextTrackCueBox : public HTMLElement {
53 public:
54  static PassRefPtr<TextTrackCueBox> create(Document& document, TextTrackCue* cue)
55  {
56  return adoptRef(new TextTrackCueBox(document, cue));
57  }
58 
59  TextTrackCue* getCue() const;
60  virtual void applyCSSProperties(const IntSize& videoSize);
61 
62  static const AtomicString& textTrackCueBoxShadowPseudoId();
63 
64 protected:
65  TextTrackCueBox(Document&, TextTrackCue*);
66 
67  virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override;
68 
69  TextTrackCue* m_cue;
70 };
71 
72 // ----------------------------
7345
7446class TextTrackCue : public RefCounted<TextTrackCue>, public EventTargetWithInlineData {
7547public:
76  static PassRefPtr<TextTrackCue> create(ScriptExecutionContext& context, double start, double end, const String& content)
77  {
78  return adoptRef(new TextTrackCue(context, start, end, content));
79  }
 48 static PassRefPtr<TextTrackCue> create(ScriptExecutionContext&, double start, double end, const String& content);
8049
8150 static const AtomicString& cueShadowPseudoId()
8251 {

@@public:
10170 bool pauseOnExit() const { return m_pauseOnExit; }
10271 void setPauseOnExit(bool);
10372
104  const String& vertical() const;
105  void setVertical(const String&, ExceptionCode&);
106 
107  bool snapToLines() const { return m_snapToLines; }
108  void setSnapToLines(bool);
109 
110  int line() const { return m_linePosition; }
111  virtual void setLine(int, ExceptionCode&);
112 
113  int position() const { return m_textPosition; }
114  virtual void setPosition(int, ExceptionCode&);
115 
116  int size() const { return m_cueSize; }
117  virtual void setSize(int, ExceptionCode&);
118 
119  const String& align() const;
120  void setAlign(const String&, ExceptionCode&);
121 
122  const String& text() const { return m_content; }
123  void setText(const String&);
124 
125  const String& cueSettings() const { return m_settings; }
126  void setCueSettings(const String&);
127 
12873 int cueIndex();
12974 void invalidateCueIndex();
13075
131  PassRefPtr<DocumentFragment> getCueAsHTML();
132  PassRefPtr<DocumentFragment> createCueRenderingTree();
133 
13476 using EventTarget::dispatchEvent;
13577 virtual bool dispatchEvent(PassRefPtr<Event>) override;
13678
137 #if ENABLE(WEBVTT_REGIONS)
138  const String& regionId() const { return m_regionId; }
139  void setRegionId(const String&);
140 #endif
141 
14279 bool isActive();
143  void setIsActive(bool);
144 
145  bool hasDisplayTree() const { return m_displayTree; }
146  TextTrackCueBox* getDisplayTree(const IntSize& videoSize);
147  HTMLSpanElement* element() const { return m_cueBackgroundBox.get(); }
148 
149  void updateDisplayTree(double);
150  void removeDisplayTree();
151  void markFutureAndPastNodes(ContainerNode*, double, double);
152 
153  int calculateComputedLinePosition();
154  std::pair<double, double> getPositionCoordinates() const;
 80 virtual void setIsActive(bool);
15581
15682 virtual EventTargetInterface eventTargetInterface() const override final { return TextTrackCueEventTargetInterfaceType; }
15783 virtual ScriptExecutionContext* scriptExecutionContext() const override final { return &m_scriptExecutionContext; }
15884
159  std::pair<double, double> getCSSPosition() const;
160 
161  int getCSSSize() const;
162  CSSValueID getCSSWritingDirection() const;
163  CSSValueID getCSSWritingMode() const;
164 
165  enum WritingDirection {
166  Horizontal,
167  VerticalGrowingLeft,
168  VerticalGrowingRight,
169  NumberOfWritingDirections
170  };
171  WritingDirection getWritingDirection() const { return m_writingDirection; }
172 
173  enum CueAlignment {
174  Start,
175  Middle,
176  End
177  };
178  CueAlignment getAlignment() const { return m_cueAlignment; }
179 
180  virtual void setFontSize(int, const IntSize&, bool important);
181 
182  enum CueMatchRules {
183  MatchAllFields,
184  IgnoreDuration,
185  };
186  virtual bool isEqual(const TextTrackCue&, CueMatchRules) const;
187 
18885 virtual bool isOrderedBefore(const TextTrackCue*) const;
18986
19087 enum CueType {
19188 Generic,
19289 WebVTT
19390 };
194  virtual CueType cueType() const { return WebVTT; }
 91 virtual CueType cueType() const = 0;
19592
19693 void willChange();
197  void didChange();
198 
 94 virtual void didChange();
 95
19996 DEFINE_ATTRIBUTE_EVENT_LISTENER(enter);
20097 DEFINE_ATTRIBUTE_EVENT_LISTENER(exit);
20198

@@public:
203100 using RefCounted<TextTrackCue>::deref;
204101
205102protected:
206  TextTrackCue(ScriptExecutionContext&, double start, double end, const String& content);
 103 TextTrackCue(ScriptExecutionContext&, double start, double end);
207104
208105 Document& ownerDocument() { return toDocument(m_scriptExecutionContext); }
209106
210  virtual PassRefPtr<TextTrackCueBox> createDisplayTree();
211  TextTrackCueBox* displayTreeInternal();
212 
213107private:
214  void createWebVTTNodeTree();
215  void copyWebVTTNodeToDOMTree(ContainerNode* WebVTTNode, ContainerNode* root);
216 
217  void parseSettings(const String&);
218 
219  void determineTextDirection();
220  void calculateDisplayParameters();
221108
222109 virtual void refEventTarget() override final { ref(); }
223110 virtual void derefEventTarget() override final { deref(); }
224111
225  enum CueSetting {
226  None,
227  Vertical,
228  Line,
229  Position,
230  Size,
231  Align,
232 #if ENABLE(WEBVTT_REGIONS)
233  RegionId
234 #endif
235  };
236  CueSetting settingName(const String&);
237 
238112 String m_id;
239113 double m_startTime;
240114 double m_endTime;
241  String m_content;
242  String m_settings;
243  int m_linePosition;
244  int m_computedLinePosition;
245  int m_textPosition;
246  int m_cueSize;
247115 int m_cueIndex;
248116 int m_processingCueChanges;
249117
250  WritingDirection m_writingDirection;
251 
252  CueAlignment m_cueAlignment;
253 
254  RefPtr<DocumentFragment> m_webVTTNodeTree;
255118 TextTrack* m_track;
256119
257120 ScriptExecutionContext& m_scriptExecutionContext;
258121
259122 bool m_isActive;
260123 bool m_pauseOnExit;
261  bool m_snapToLines;
262 
263  RefPtr<HTMLSpanElement> m_cueBackgroundBox;
264 
265  bool m_displayTreeShouldChange;
266  RefPtr<TextTrackCueBox> m_displayTree;
267 
268  CSSValueID m_displayDirection;
269 
270  CSSValueID m_displayWritingModeMap[NumberOfWritingDirections];
271  CSSValueID m_displayWritingMode;
272 
273  int m_displaySize;
274 
275  std::pair<float, float> m_displayPosition;
276 #if ENABLE(WEBVTT_REGIONS)
277  String m_regionId;
278 #endif
279124};
280125
281126} // namespace WebCore

Source/WebCore/html/track/TextTrackCue.idl

3131 EventTarget,
3232 JSCustomMarkFunction,
3333 CustomIsReachable,
 34 CustomToJSObject,
3435 SkipVTableValidation,
3536] interface TextTrackCue {
3637 readonly attribute TextTrack track;

4041 [SetterRaisesException] attribute double endTime;
4142 attribute boolean pauseOnExit;
4243
43  [SetterRaisesException] attribute DOMString vertical;
44  attribute boolean snapToLines;
45  [SetterRaisesException] attribute long line;
46  [SetterRaisesException] attribute long position;
47  [SetterRaisesException] attribute long size;
48  [SetterRaisesException] attribute DOMString align;
49 
50  attribute DOMString text;
51  DocumentFragment getCueAsHTML();
52 
5344 attribute EventListener onenter;
5445 attribute EventListener onexit;
5546

6152 EventListener listener,
6253 optional boolean useCapture);
6354 [RaisesException] boolean dispatchEvent(Event evt);
64 
65 #if defined(ENABLE_WEBVTT_REGIONS) && ENABLE_WEBVTT_REGIONS
66  attribute DOMString regionId;
67 #endif
6855};
6956

Source/WebCore/html/track/TextTrackCueGeneric.cpp

4141
4242namespace WebCore {
4343
44 class TextTrackCueGenericBoxElement final : public TextTrackCueBox {
 44class TextTrackCueGenericBoxElement final : public VTTCueBox {
4545public:
4646 static PassRefPtr<TextTrackCueGenericBoxElement> create(Document& document, TextTrackCueGeneric* cue)
4747 {

@@public:
5151 virtual void applyCSSProperties(const IntSize&) override;
5252
5353private:
54  TextTrackCueGenericBoxElement(Document&, TextTrackCue*);
 54 TextTrackCueGenericBoxElement(Document&, VTTCue*);
5555};
5656
57 TextTrackCueGenericBoxElement::TextTrackCueGenericBoxElement(Document& document, TextTrackCue* cue)
58  : TextTrackCueBox(document, cue)
 57TextTrackCueGenericBoxElement::TextTrackCueGenericBoxElement(Document& document, VTTCue* cue)
 58 : VTTCueBox(document, cue)
5959{
6060}
6161

@@void TextTrackCueGenericBoxElement::applyCSSProperties(const IntSize& videoSize)
7575 setInlineStyleProperty(CSSPropertyLeft, static_cast<float>(cue->position()), CSSPrimitiveValue::CSS_PERCENTAGE);
7676 setInlineStyleProperty(CSSPropertyTop, static_cast<float>(cue->line()), CSSPrimitiveValue::CSS_PERCENTAGE);
7777
78  if (cue->getWritingDirection() == TextTrackCue::Horizontal)
 78 if (cue->getWritingDirection() == VTTCue::Horizontal)
7979 setInlineStyleProperty(CSSPropertyWidth, size, CSSPrimitiveValue::CSS_PERCENTAGE);
8080 else
8181 setInlineStyleProperty(CSSPropertyHeight, size, CSSPrimitiveValue::CSS_PERCENTAGE);

@@void TextTrackCueGenericBoxElement::applyCSSProperties(const IntSize& videoSize)
8686 if (cue->highlightColor().isValid())
8787 cueElement->setInlineStyleProperty(CSSPropertyBackgroundColor, cue->highlightColor().serialized());
8888
89  if (cue->getWritingDirection() == TextTrackCue::Horizontal)
 89 if (cue->getWritingDirection() == VTTCue::Horizontal)
9090 setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto);
9191 else
9292 setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto);

@@void TextTrackCueGenericBoxElement::applyCSSProperties(const IntSize& videoSize)
9494 if (cue->baseFontSizeRelativeToVideoHeight())
9595 cue->setFontSize(cue->baseFontSizeRelativeToVideoHeight(), videoSize, false);
9696
97  if (cue->getAlignment() == TextTrackCue::Middle)
 97 if (cue->getAlignment() == VTTCue::Middle)
9898 setInlineStyleProperty(CSSPropertyTextAlign, CSSValueCenter);
99  else if (cue->getAlignment() == TextTrackCue::End)
 99 else if (cue->getAlignment() == VTTCue::End)
100100 setInlineStyleProperty(CSSPropertyTextAlign, CSSValueEnd);
101101 else
102102 setInlineStyleProperty(CSSPropertyTextAlign, CSSValueStart);

@@void TextTrackCueGenericBoxElement::applyCSSProperties(const IntSize& videoSize)
109109}
110110
111111TextTrackCueGeneric::TextTrackCueGeneric(ScriptExecutionContext& context, double start, double end, const String& content)
112  : TextTrackCue(context, start, end, content)
 112 : VTTCue(context, start, end, content)
113113 , m_baseFontSizeRelativeToVideoHeight(0)
114114 , m_fontSizeMultiplier(0)
115115 , m_defaultPosition(true)
116116{
117117}
118118
119 PassRefPtr<TextTrackCueBox> TextTrackCueGeneric::createDisplayTree()
 119PassRefPtr<VTTCueBox> TextTrackCueGeneric::createDisplayTree()
120120{
121121 return TextTrackCueGenericBoxElement::create(ownerDocument(), this);
122122}

@@PassRefPtr<TextTrackCueBox> TextTrackCueGeneric::createDisplayTree()
124124void TextTrackCueGeneric::setLine(int line, ExceptionCode& ec)
125125{
126126 m_defaultPosition = false;
127  TextTrackCue::setLine(line, ec);
 127 VTTCue::setLine(line, ec);
128128}
129129
130130void TextTrackCueGeneric::setPosition(int position, ExceptionCode& ec)
131131{
132132 m_defaultPosition = false;
133  TextTrackCue::setPosition(position, ec);
 133 VTTCue::setPosition(position, ec);
134134}
135135
136136void TextTrackCueGeneric::setFontSize(int fontSize, const IntSize& videoSize, bool important)

@@void TextTrackCueGeneric::setFontSize(int fontSize, const IntSize& videoSize, bo
139139 return;
140140
141141 if (important || !baseFontSizeRelativeToVideoHeight()) {
142  TextTrackCue::setFontSize(fontSize, videoSize, important);
 142 VTTCue::setFontSize(fontSize, videoSize, important);
143143 return;
144144 }
145145

@@void TextTrackCueGeneric::setFontSize(int fontSize, const IntSize& videoSize, bo
151151 LOG(Media, "TextTrackCueGeneric::setFontSize - setting cue font size to %li", lround(size));
152152}
153153
154 bool TextTrackCueGeneric::isEqual(const TextTrackCue& cue, TextTrackCue::CueMatchRules match) const
 154bool TextTrackCueGeneric::isEqual(const VTTCue& cue, VTTCue::CueMatchRules match) const
155155{
156156 if (cue.cueType() != TextTrackCue::Generic)
157157 return false;

@@bool TextTrackCueGeneric::isEqual(const TextTrackCue& cue, TextTrackCue::CueMatc
169169 if (m_backgroundColor != other->backgroundColor())
170170 return false;
171171
172  return TextTrackCue::isEqual(cue, match);
 172 return VTTCue::isEqual(cue, match);
173173}
174174
175175bool TextTrackCueGeneric::isOrderedBefore(const TextTrackCue* that) const
176176{
177  if (TextTrackCue::isOrderedBefore(that))
 177 if (VTTCue::isOrderedBefore(that))
178178 return true;
179179
180180 if (that->cueType() == Generic && startTime() == that->startTime() && endTime() == that->endTime()) {
181181 // Further order generic cues by their calculated line value.
182182 std::pair<double, double> thisPosition = getPositionCoordinates();
183  std::pair<double, double> thatPosition = that->getPositionCoordinates();
 183 std::pair<double, double> thatPosition = toVTTCue(that)->getPositionCoordinates();
184184 return thisPosition.second > thatPosition.second || (thisPosition.second == thatPosition.second && thisPosition.first < thatPosition.first);
185185 }
186186

Source/WebCore/html/track/TextTrackCueGeneric.h

2929#if ENABLE(VIDEO_TRACK)
3030
3131#include "Color.h"
32 #include "TextTrackCue.h"
 32#include "VTTCue.h"
3333
3434namespace WebCore {
3535
3636class GenericCueData;
3737
3838// A "generic" cue is a non-WebVTT cue, so it is not positioned/sized with the WebVTT logic.
39 class TextTrackCueGeneric final : public TextTrackCue {
 39class TextTrackCueGeneric final : public VTTCue {
4040public:
4141 static PassRefPtr<TextTrackCueGeneric> create(ScriptExecutionContext& context, double start, double end, const String& content)
4242 {

@@public:
4545
4646 virtual ~TextTrackCueGeneric() { }
4747
48  virtual PassRefPtr<TextTrackCueBox> createDisplayTree() override;
 48 virtual PassRefPtr<VTTCueBox> createDisplayTree() override;
4949
5050 virtual void setLine(int, ExceptionCode&) override;
5151 virtual void setPosition(int, ExceptionCode&) override;

@@public:
7272
7373 virtual void setFontSize(int, const IntSize&, bool important) override;
7474
75  virtual bool isEqual(const TextTrackCue&, CueMatchRules) const override;
 75 virtual bool isEqual(const VTTCue&, CueMatchRules) const override;
7676
7777 virtual TextTrackCue::CueType cueType() const override { return TextTrackCue::Generic; }
7878

Source/WebCore/html/track/VTTCue.cpp

 1/*
 2 * Copyright (C) 2011 Google Inc. All rights reserved.
 3 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions are
 7 * met:
 8 *
 9 * * Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * * Redistributions in binary form must reproduce the above
 12 * copyright notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * * Neither the name of Google Inc. nor the names of its
 16 * contributors may be used to endorse or promote products derived from
 17 * this software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#include "config.h"
 33
 34#if ENABLE(VIDEO_TRACK)
 35#include "VTTCue.h"
 36
 37#include "CSSPropertyNames.h"
 38#include "CSSValueKeywords.h"
 39#include "DocumentFragment.h"
 40#include "Event.h"
 41#include "HTMLDivElement.h"
 42#include "HTMLSpanElement.h"
 43#include "Logging.h"
 44#include "NodeTraversal.h"
 45#include "RenderVTTCue.h"
 46#include "Text.h"
 47#include "TextTrack.h"
 48#include "TextTrackCueList.h"
 49#include "WebVTTElement.h"
 50#include "WebVTTParser.h"
 51#include <wtf/MathExtras.h>
 52#include <wtf/text/StringBuilder.h>
 53
 54namespace WebCore {
 55
 56static const int undefinedPosition = -1;
 57
 58static const String& startKeyword()
 59{
 60 DEFINE_STATIC_LOCAL(const String, start, (ASCIILiteral("start")));
 61 return start;
 62}
 63
 64static const String& middleKeyword()
 65{
 66 DEFINE_STATIC_LOCAL(const String, middle, (ASCIILiteral("middle")));
 67 return middle;
 68}
 69
 70static const String& endKeyword()
 71{
 72 DEFINE_STATIC_LOCAL(const String, end, (ASCIILiteral("end")));
 73 return end;
 74}
 75
 76static const String& horizontalKeyword()
 77{
 78 return emptyString();
 79}
 80
 81static const String& verticalGrowingLeftKeyword()
 82{
 83 DEFINE_STATIC_LOCAL(const String, verticalrl, (ASCIILiteral("rl")));
 84 return verticalrl;
 85}
 86
 87static const String& verticalGrowingRightKeyword()
 88{
 89 DEFINE_STATIC_LOCAL(const String, verticallr, (ASCIILiteral("lr")));
 90 return verticallr;
 91}
 92
 93// ----------------------------
 94
 95VTTCueBox::VTTCueBox(Document& document, VTTCue* cue)
 96 : HTMLElement(divTag, document)
 97 , m_cue(cue)
 98{
 99 setPseudo(vttCueBoxShadowPseudoId());
 100}
 101
 102VTTCue* VTTCueBox::getCue() const
 103{
 104 return m_cue;
 105}
 106
 107void VTTCueBox::applyCSSProperties(const IntSize&)
 108{
 109 // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79916
 110
 111 // 3.5.1 On the (root) List of WebVTT Node Objects:
 112
 113 // the 'position' property must be set to 'absolute'
 114 setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
 115
 116 // the 'unicode-bidi' property must be set to 'plaintext'
 117 setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueWebkitPlaintext);
 118
 119 // the 'direction' property must be set to direction
 120 setInlineStyleProperty(CSSPropertyDirection, m_cue->getCSSWritingDirection());
 121
 122 // the 'writing-mode' property must be set to writing-mode
 123 setInlineStyleProperty(CSSPropertyWebkitWritingMode, m_cue->getCSSWritingMode(), false);
 124
 125 std::pair<float, float> position = m_cue->getCSSPosition();
 126
 127 // the 'top' property must be set to top,
 128 setInlineStyleProperty(CSSPropertyTop, static_cast<double>(position.second), CSSPrimitiveValue::CSS_PERCENTAGE);
 129
 130 // the 'left' property must be set to left
 131 setInlineStyleProperty(CSSPropertyLeft, static_cast<double>(position.first), CSSPrimitiveValue::CSS_PERCENTAGE);
 132
 133 // the 'width' property must be set to width, and the 'height' property must be set to height
 134 if (m_cue->vertical() == horizontalKeyword()) {
 135 setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue->getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
 136 setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto);
 137 } else {
 138 setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto);
 139 setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue->getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
 140 }
 141
 142 // The 'text-align' property on the (root) List of WebVTT Node Objects must
 143 // be set to the value in the second cell of the row of the table below
 144 // whose first cell is the value of the corresponding cue's text track cue
 145 // alignment:
 146 if (m_cue->align() == startKeyword())
 147 setInlineStyleProperty(CSSPropertyTextAlign, CSSValueStart);
 148 else if (m_cue->align() == endKeyword())
 149 setInlineStyleProperty(CSSPropertyTextAlign, CSSValueEnd);
 150 else
 151 setInlineStyleProperty(CSSPropertyTextAlign, CSSValueCenter);
 152
 153 if (!m_cue->snapToLines()) {
 154 // 10.13.1 Set up x and y:
 155 // Note: x and y are set through the CSS left and top above.
 156
 157 // 10.13.2 Position the boxes in boxes such that the point x% along the
 158 // width of the bounding box of the boxes in boxes is x% of the way
 159 // across the width of the video's rendering area, and the point y%
 160 // along the height of the bounding box of the boxes in boxes is y%
 161 // of the way across the height of the video's rendering area, while
 162 // maintaining the relative positions of the boxes in boxes to each
 163 // other.
 164 setInlineStyleProperty(CSSPropertyWebkitTransform,
 165 String::format("translate(-%.2f%%, -%.2f%%)", position.first, position.second));
 166
 167 setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre);
 168 }
 169}
 170
 171const AtomicString& VTTCueBox::vttCueBoxShadowPseudoId()
 172{
 173 DEFINE_STATIC_LOCAL(const AtomicString, trackDisplayBoxShadowPseudoId, ("-webkit-media-text-track-display", AtomicString::ConstructFromLiteral));
 174 return trackDisplayBoxShadowPseudoId;
 175}
 176
 177RenderPtr<RenderElement> VTTCueBox::createElementRenderer(PassRef<RenderStyle> style)
 178{
 179 return createRenderer<RenderVTTCue>(*this, std::move(style));
 180}
 181
 182// ----------------------------
 183
 184VTTCue::VTTCue(ScriptExecutionContext& context, double start, double end, const String& content)
 185 : TextTrackCue(context, start, end)
 186 , m_content(content)
 187 , m_linePosition(undefinedPosition)
 188 , m_computedLinePosition(undefinedPosition)
 189 , m_textPosition(50)
 190 , m_cueSize(100)
 191 , m_writingDirection(Horizontal)
 192 , m_cueAlignment(Middle)
 193 , m_webVTTNodeTree(0)
 194 , m_snapToLines(true)
 195 , m_cueBackgroundBox(HTMLSpanElement::create(spanTag, toDocument(context)))
 196 , m_displayTreeShouldChange(true)
 197 , m_displayDirection(CSSValueLtr)
 198 , m_displayWritingMode(CSSValueInherit)
 199 , m_displaySize(0)
 200{
 201 // 4. If the text track cue writing direction is horizontal, then let
 202 // writing-mode be 'horizontal-tb'. Otherwise, if the text track cue writing
 203 // direction is vertical growing left, then let writing-mode be
 204 // 'vertical-rl'. Otherwise, the text track cue writing direction is
 205 // vertical growing right; let writing-mode be 'vertical-lr'.
 206 m_displayWritingModeMap[Horizontal] = CSSValueHorizontalTb;
 207 m_displayWritingModeMap[VerticalGrowingLeft] = CSSValueVerticalRl;
 208 m_displayWritingModeMap[VerticalGrowingRight] = CSSValueVerticalLr;
 209}
 210
 211VTTCue::~VTTCue()
 212{
 213 removeDisplayTree();
 214}
 215
 216PassRefPtr<VTTCueBox> VTTCue::createDisplayTree()
 217{
 218 return VTTCueBox::create(ownerDocument(), this);
 219}
 220
 221VTTCueBox* VTTCue::displayTreeInternal()
 222{
 223 if (!m_displayTree)
 224 m_displayTree = createDisplayTree();
 225 return m_displayTree.get();
 226}
 227
 228void VTTCue::didChange()
 229{
 230 TextTrackCue::didChange();
 231 m_displayTreeShouldChange = true;
 232}
 233
 234const String& VTTCue::vertical() const
 235{
 236 switch (m_writingDirection) {
 237 case Horizontal:
 238 return horizontalKeyword();
 239 case VerticalGrowingLeft:
 240 return verticalGrowingLeftKeyword();
 241 case VerticalGrowingRight:
 242 return verticalGrowingRightKeyword();
 243 default:
 244 ASSERT_NOT_REACHED();
 245 return emptyString();
 246 }
 247}
 248
 249void VTTCue::setVertical(const String& value, ExceptionCode& ec)
 250{
 251 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-vertical
 252 // On setting, the text track cue writing direction must be set to the value given
 253 // in the first cell of the row in the table above whose second cell is a
 254 // case-sensitive match for the new value, if any. If none of the values match, then
 255 // the user agent must instead throw a SyntaxError exception.
 256
 257 WritingDirection direction = m_writingDirection;
 258 if (value == horizontalKeyword())
 259 direction = Horizontal;
 260 else if (value == verticalGrowingLeftKeyword())
 261 direction = VerticalGrowingLeft;
 262 else if (value == verticalGrowingRightKeyword())
 263 direction = VerticalGrowingRight;
 264 else
 265 ec = SYNTAX_ERR;
 266
 267 if (direction == m_writingDirection)
 268 return;
 269
 270 willChange();
 271 m_writingDirection = direction;
 272 didChange();
 273}
 274
 275void VTTCue::setSnapToLines(bool value)
 276{
 277 if (m_snapToLines == value)
 278 return;
 279
 280 willChange();
 281 m_snapToLines = value;
 282 didChange();
 283}
 284
 285void VTTCue::setLine(int position, ExceptionCode& ec)
 286{
 287 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line
 288 // On setting, if the text track cue snap-to-lines flag is not set, and the new
 289 // value is negative or greater than 100, then throw an IndexSizeError exception.
 290 if (!m_snapToLines && (position < 0 || position > 100)) {
 291 ec = INDEX_SIZE_ERR;
 292 return;
 293 }
 294
 295 // Otherwise, set the text track cue line position to the new value.
 296 if (m_linePosition == position)
 297 return;
 298
 299 willChange();
 300 m_linePosition = position;
 301 m_computedLinePosition = calculateComputedLinePosition();
 302 didChange();
 303}
 304
 305void VTTCue::setPosition(int position, ExceptionCode& ec)
 306{
 307 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-position
 308 // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception.
 309 // Otherwise, set the text track cue text position to the new value.
 310 if (position < 0 || position > 100) {
 311 ec = INDEX_SIZE_ERR;
 312 return;
 313 }
 314
 315 // Otherwise, set the text track cue line position to the new value.
 316 if (m_textPosition == position)
 317 return;
 318
 319 willChange();
 320 m_textPosition = position;
 321 didChange();
 322}
 323
 324void VTTCue::setSize(int size, ExceptionCode& ec)
 325{
 326 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size
 327 // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError
 328 // exception. Otherwise, set the text track cue size to the new value.
 329 if (size < 0 || size > 100) {
 330 ec = INDEX_SIZE_ERR;
 331 return;
 332 }
 333
 334 // Otherwise, set the text track cue line position to the new value.
 335 if (m_cueSize == size)
 336 return;
 337
 338 willChange();
 339 m_cueSize = size;
 340 didChange();
 341}
 342
 343const String& VTTCue::align() const
 344{
 345 switch (m_cueAlignment) {
 346 case Start:
 347 return startKeyword();
 348 case Middle:
 349 return middleKeyword();
 350 case End:
 351 return endKeyword();
 352 default:
 353 ASSERT_NOT_REACHED();
 354 return emptyString();
 355 }
 356}
 357
 358void VTTCue::setAlign(const String& value, ExceptionCode& ec)
 359{
 360 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-align
 361 // On setting, the text track cue alignment must be set to the value given in the
 362 // first cell of the row in the table above whose second cell is a case-sensitive
 363 // match for the new value, if any. If none of the values match, then the user
 364 // agent must instead throw a SyntaxError exception.
 365
 366 CueAlignment alignment = m_cueAlignment;
 367 if (value == startKeyword())
 368 alignment = Start;
 369 else if (value == middleKeyword())
 370 alignment = Middle;
 371 else if (value == endKeyword())
 372 alignment = End;
 373 else
 374 ec = SYNTAX_ERR;
 375
 376 if (alignment == m_cueAlignment)
 377 return;
 378
 379 willChange();
 380 m_cueAlignment = alignment;
 381 didChange();
 382}
 383
 384void VTTCue::setText(const String& text)
 385{
 386 if (m_content == text)
 387 return;
 388
 389 willChange();
 390 // Clear the document fragment but don't bother to create it again just yet as we can do that
 391 // when it is requested.
 392 m_webVTTNodeTree = 0;
 393 m_content = text;
 394 didChange();
 395}
 396
 397void VTTCue::createWebVTTNodeTree()
 398{
 399 if (!m_webVTTNodeTree)
 400 m_webVTTNodeTree = WebVTTParser::create(0, scriptExecutionContext())->createDocumentFragmentFromCueText(m_content);
 401}
 402
 403void VTTCue::copyWebVTTNodeToDOMTree(ContainerNode* webVTTNode, ContainerNode* parent)
 404{
 405 for (Node* node = webVTTNode->firstChild(); node; node = node->nextSibling()) {
 406 RefPtr<Node> clonedNode;
 407 if (node->isWebVTTElement())
 408 clonedNode = toWebVTTElement(node)->createEquivalentHTMLElement(ownerDocument());
 409 else
 410 clonedNode = node->cloneNode(false);
 411 parent->appendChild(clonedNode, ASSERT_NO_EXCEPTION);
 412 if (node->isContainerNode())
 413 copyWebVTTNodeToDOMTree(toContainerNode(node), toContainerNode(clonedNode.get()));
 414 }
 415}
 416
 417PassRefPtr<DocumentFragment> VTTCue::getCueAsHTML()
 418{
 419 createWebVTTNodeTree();
 420 if (!m_webVTTNodeTree)
 421 return 0;
 422
 423 RefPtr<DocumentFragment> clonedFragment = DocumentFragment::create(ownerDocument());
 424 copyWebVTTNodeToDOMTree(m_webVTTNodeTree.get(), clonedFragment.get());
 425 return clonedFragment.release();
 426}
 427
 428PassRefPtr<DocumentFragment> VTTCue::createCueRenderingTree()
 429{
 430 RefPtr<DocumentFragment> clonedFragment;
 431 createWebVTTNodeTree();
 432 if (!m_webVTTNodeTree)
 433 return 0;
 434
 435 clonedFragment = DocumentFragment::create(ownerDocument());
 436 m_webVTTNodeTree->cloneChildNodes(clonedFragment.get());
 437 return clonedFragment.release();
 438}
 439
 440#if ENABLE(WEBVTT_REGIONS)
 441void VTTCue::setRegionId(const String& regionId)
 442{
 443 if (m_regionId == regionId)
 444 return;
 445
 446 willChange();
 447 m_regionId = regionId;
 448 didChange();
 449}
 450#endif
 451
 452void VTTCue::setIsActive(bool active)
 453{
 454 TextTrackCue::setIsActive(active);
 455
 456 if (!active) {
 457 if (!hasDisplayTree())
 458 return;
 459
 460 // Remove the display tree as soon as the cue becomes inactive.
 461 displayTreeInternal()->remove(ASSERT_NO_EXCEPTION);
 462 }
 463}
 464
 465int VTTCue::calculateComputedLinePosition()
 466{
 467 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#text-track-cue-computed-line-position
 468
 469 // If the text track cue line position is numeric, then that is the text
 470 // track cue computed line position.
 471 if (m_linePosition != undefinedPosition)
 472 return m_linePosition;
 473
 474 // If the text track cue snap-to-lines flag of the text track cue is not
 475 // set, the text track cue computed line position is the value 100;
 476 if (!m_snapToLines)
 477 return 100;
 478
 479 // Otherwise, it is the value returned by the following algorithm:
 480
 481 // If cue is not associated with a text track, return -1 and abort these
 482 // steps.
 483 if (!track())
 484 return -1;
 485
 486 // Let n be the number of text tracks whose text track mode is showing or
 487 // showing by default and that are in the media element's list of text
 488 // tracks before track.
 489 int n = track()->trackIndexRelativeToRenderedTracks();
 490
 491 // Increment n by one.
 492 n++;
 493
 494 // Negate n.
 495 n = -n;
 496
 497 return n;
 498}
 499
 500static bool isCueParagraphSeparator(UChar character)
 501{
 502 // Within a cue, paragraph boundaries are only denoted by Type B characters,
 503 // such as U+000A LINE FEED (LF), U+0085 NEXT LINE (NEL), and U+2029 PARAGRAPH SEPARATOR.
 504 return u_charType(character) == U_PARAGRAPH_SEPARATOR;
 505}
 506
 507void VTTCue::determineTextDirection()
 508{
 509 DEFINE_STATIC_LOCAL(const String, rtTag, (ASCIILiteral("rt")));
 510 createWebVTTNodeTree();
 511 if (!m_webVTTNodeTree)
 512 return;
 513
 514 // Apply the Unicode Bidirectional Algorithm's Paragraph Level steps to the
 515 // concatenation of the values of each WebVTT Text Object in nodes, in a
 516 // pre-order, depth-first traversal, excluding WebVTT Ruby Text Objects and
 517 // their descendants.
 518 StringBuilder paragraphBuilder;
 519 for (Node* node = m_webVTTNodeTree->firstChild(); node; node = NodeTraversal::next(node, m_webVTTNodeTree.get())) {
 520 // FIXME: The code does not match the comment above. This does not actually exclude Ruby Text Object descendant.
 521 if (!node->isTextNode() || node->localName() == rtTag)
 522 continue;
 523
 524 paragraphBuilder.append(node->nodeValue());
 525 }
 526
 527 String paragraph = paragraphBuilder.toString();
 528 if (!paragraph.length())
 529 return;
 530
 531 for (size_t i = 0; i < paragraph.length(); ++i) {
 532 UChar current = paragraph[i];
 533 if (!current || isCueParagraphSeparator(current))
 534 return;
 535
 536 if (UChar current = paragraph[i]) {
 537 UCharDirection charDirection = u_charDirection(current);
 538 if (charDirection == U_LEFT_TO_RIGHT) {
 539 m_displayDirection = CSSValueLtr;
 540 return;
 541 }
 542 if (charDirection == U_RIGHT_TO_LEFT || charDirection == U_RIGHT_TO_LEFT_ARABIC) {
 543 m_displayDirection = CSSValueRtl;
 544 return;
 545 }
 546 }
 547 }
 548}
 549
 550void VTTCue::calculateDisplayParameters()
 551{
 552 // Steps 10.2, 10.3
 553 determineTextDirection();
 554
 555 // 10.4 If the text track cue writing direction is horizontal, then let
 556 // block-flow be 'tb'. Otherwise, if the text track cue writing direction is
 557 // vertical growing left, then let block-flow be 'lr'. Otherwise, the text
 558 // track cue writing direction is vertical growing right; let block-flow be
 559 // 'rl'.
 560 m_displayWritingMode = m_displayWritingModeMap[m_writingDirection];
 561
 562 // 10.5 Determine the value of maximum size for cue as per the appropriate
 563 // rules from the following list:
 564 int maximumSize = m_textPosition;
 565 if ((m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueLtr)
 566 || (m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueRtl)
 567 || (m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Start)
 568 || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Start)) {
 569 maximumSize = 100 - m_textPosition;
 570 } else if ((m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueLtr)
 571 || (m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueRtl)
 572 || (m_writingDirection == VerticalGrowingLeft && m_cueAlignment == End)
 573 || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == End)) {
 574 maximumSize = m_textPosition;
 575 } else if (m_cueAlignment == Middle) {
 576 maximumSize = m_textPosition <= 50 ? m_textPosition : (100 - m_textPosition);
 577 maximumSize = maximumSize * 2;
 578 }
 579
 580 // 10.6 If the text track cue size is less than maximum size, then let size
 581 // be text track cue size. Otherwise, let size be maximum size.
 582 m_displaySize = std::min(m_cueSize, maximumSize);
 583
 584 // 10.8 Determine the value of x-position or y-position for cue as per the
 585 // appropriate rules from the following list:
 586 if (m_writingDirection == Horizontal) {
 587 if (m_cueAlignment == Start) {
 588 if (m_displayDirection == CSSValueLtr)
 589 m_displayPosition.first = m_textPosition;
 590 else
 591 m_displayPosition.first = 100 - m_textPosition - m_displaySize;
 592 } else if (m_cueAlignment == End) {
 593 if (m_displayDirection == CSSValueRtl)
 594 m_displayPosition.first = 100 - m_textPosition;
 595 else
 596 m_displayPosition.first = m_textPosition - m_displaySize;
 597 }
 598 }
 599
 600 if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Start)
 601 || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Start)) {
 602 m_displayPosition.second = m_textPosition;
 603 } else if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == End)
 604 || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == End)) {
 605 m_displayPosition.second = 100 - m_textPosition;
 606 }
 607
 608 if (m_writingDirection == Horizontal && m_cueAlignment == Middle) {
 609 if (m_displayDirection == CSSValueLtr)
 610 m_displayPosition.first = m_textPosition - m_displaySize / 2;
 611 else
 612 m_displayPosition.first = 100 - m_textPosition - m_displaySize / 2;
 613 }
 614
 615 if ((m_writingDirection == VerticalGrowingLeft && m_cueAlignment == Middle)
 616 || (m_writingDirection == VerticalGrowingRight && m_cueAlignment == Middle))
 617 m_displayPosition.second = m_textPosition - m_displaySize / 2;
 618
 619 // 10.9 Determine the value of whichever of x-position or y-position is not
 620 // yet calculated for cue as per the appropriate rules from the following
 621 // list:
 622 if (m_snapToLines && m_displayPosition.second == undefinedPosition && m_writingDirection == Horizontal)
 623 m_displayPosition.second = 0;
 624
 625 if (!m_snapToLines && m_displayPosition.second == undefinedPosition && m_writingDirection == Horizontal)
 626 m_displayPosition.second = m_computedLinePosition;
 627
 628 if (m_snapToLines && m_displayPosition.first == undefinedPosition
 629 && (m_writingDirection == VerticalGrowingLeft || m_writingDirection == VerticalGrowingRight))
 630 m_displayPosition.first = 0;
 631
 632 if (!m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writingDirection == VerticalGrowingRight))
 633 m_displayPosition.first = m_computedLinePosition;
 634
 635 // A text track cue has a text track cue computed line position whose value
 636 // is defined in terms of the other aspects of the cue.
 637 m_computedLinePosition = calculateComputedLinePosition();
 638}
 639
 640void VTTCue::markFutureAndPastNodes(ContainerNode* root, double previousTimestamp, double movieTime)
 641{
 642 DEFINE_STATIC_LOCAL(const String, timestampTag, (ASCIILiteral("timestamp")));
 643
 644 bool isPastNode = true;
 645 double currentTimestamp = previousTimestamp;
 646 if (currentTimestamp > movieTime)
 647 isPastNode = false;
 648
 649 for (Node* child = root->firstChild(); child; child = NodeTraversal::next(child, root)) {
 650 if (child->nodeName() == timestampTag) {
 651 unsigned position = 0;
 652 String timestamp = child->nodeValue();
 653 double currentTimestamp = WebVTTParser::create(0, scriptExecutionContext())->collectTimeStamp(timestamp, &position);
 654 ASSERT(currentTimestamp != -1);
 655
 656 if (currentTimestamp > movieTime)
 657 isPastNode = false;
 658 }
 659
 660 if (child->isWebVTTElement()) {
 661 toWebVTTElement(child)->setIsPastNode(isPastNode);
 662 // Make an elemenet id match a cue id for style matching purposes.
 663 if (!id().isEmpty())
 664 toElement(child)->setIdAttribute(id());
 665 }
 666 }
 667}
 668
 669void VTTCue::updateDisplayTree(double movieTime)
 670{
 671 // The display tree may contain WebVTT timestamp objects representing
 672 // timestamps (processing instructions), along with displayable nodes.
 673
 674 if (!track()->isRendered())
 675 return;
 676
 677 // Clear the contents of the set.
 678 m_cueBackgroundBox->removeChildren();
 679
 680 // Update the two sets containing past and future WebVTT objects.
 681 RefPtr<DocumentFragment> referenceTree = createCueRenderingTree();
 682 if (!referenceTree)
 683 return;
 684
 685 markFutureAndPastNodes(referenceTree.get(), startTime(), movieTime);
 686 m_cueBackgroundBox->appendChild(referenceTree);
 687}
 688
 689VTTCueBox* VTTCue::getDisplayTree(const IntSize& videoSize)
 690{
 691 RefPtr<VTTCueBox> displayTree = displayTreeInternal();
 692 if (!m_displayTreeShouldChange || !track()->isRendered())
 693 return displayTree.get();
 694
 695 // 10.1 - 10.10
 696 calculateDisplayParameters();
 697
 698 // 10.11. Apply the terms of the CSS specifications to nodes within the
 699 // following constraints, thus obtaining a set of CSS boxes positioned
 700 // relative to an initial containing block:
 701 displayTree->removeChildren();
 702
 703 // The document tree is the tree of WebVTT Node Objects rooted at nodes.
 704
 705 // The children of the nodes must be wrapped in an anonymous box whose
 706 // 'display' property has the value 'inline'. This is the WebVTT cue
 707 // background box.
 708
 709 // Note: This is contained by default in m_cueBackgroundBox.
 710 m_cueBackgroundBox->setPseudo(cueShadowPseudoId());
 711 displayTree->appendChild(m_cueBackgroundBox, ASSERT_NO_EXCEPTION);
 712
 713 // FIXME(BUG 79916): Runs of children of WebVTT Ruby Objects that are not
 714 // WebVTT Ruby Text Objects must be wrapped in anonymous boxes whose
 715 // 'display' property has the value 'ruby-base'.
 716
 717 // FIXME(BUG 79916): Text runs must be wrapped according to the CSS
 718 // line-wrapping rules, except that additionally, regardless of the value of
 719 // the 'white-space' property, lines must be wrapped at the edge of their
 720 // containing blocks, even if doing so requires splitting a word where there
 721 // is no line breaking opportunity. (Thus, normally text wraps as needed,
 722 // but if there is a particularly long word, it does not overflow as it
 723 // normally would in CSS, it is instead forcibly wrapped at the box's edge.)
 724 displayTree->applyCSSProperties(videoSize);
 725
 726 m_displayTreeShouldChange = false;
 727
 728 // 10.15. Let cue's text track cue display state have the CSS boxes in
 729 // boxes.
 730 return displayTree.get();
 731}
 732
 733void VTTCue::removeDisplayTree()
 734{
 735 if (!hasDisplayTree())
 736 return;
 737 displayTreeInternal()->remove(ASSERT_NO_EXCEPTION);
 738}
 739
 740std::pair<double, double> VTTCue::getPositionCoordinates() const
 741{
 742 // This method is used for setting x and y when snap to lines is not set.
 743 std::pair<double, double> coordinates;
 744
 745 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) {
 746 coordinates.first = m_textPosition;
 747 coordinates.second = m_computedLinePosition;
 748
 749 return coordinates;
 750 }
 751
 752 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueRtl) {
 753 coordinates.first = 100 - m_textPosition;
 754 coordinates.second = m_computedLinePosition;
 755
 756 return coordinates;
 757 }
 758
 759 if (m_writingDirection == VerticalGrowingLeft) {
 760 coordinates.first = 100 - m_computedLinePosition;
 761 coordinates.second = m_textPosition;
 762
 763 return coordinates;
 764 }
 765
 766 if (m_writingDirection == VerticalGrowingRight) {
 767 coordinates.first = m_computedLinePosition;
 768 coordinates.second = m_textPosition;
 769
 770 return coordinates;
 771 }
 772
 773 ASSERT_NOT_REACHED();
 774
 775 return coordinates;
 776}
 777
 778VTTCue::CueSetting VTTCue::settingName(const String& name)
 779{
 780 DEFINE_STATIC_LOCAL(const String, verticalKeyword, (ASCIILiteral("vertical")));
 781 DEFINE_STATIC_LOCAL(const String, lineKeyword, (ASCIILiteral("line")));
 782 DEFINE_STATIC_LOCAL(const String, positionKeyword, (ASCIILiteral("position")));
 783 DEFINE_STATIC_LOCAL(const String, sizeKeyword, (ASCIILiteral("size")));
 784 DEFINE_STATIC_LOCAL(const String, alignKeyword, (ASCIILiteral("align")));
 785#if ENABLE(WEBVTT_REGIONS)
 786 DEFINE_STATIC_LOCAL(const String, regionIdKeyword, (ASCIILiteral("region")));
 787#endif
 788
 789 if (name == verticalKeyword)
 790 return Vertical;
 791 if (name == lineKeyword)
 792 return Line;
 793 if (name == positionKeyword)
 794 return Position;
 795 if (name == sizeKeyword)
 796 return Size;
 797 if (name == alignKeyword)
 798 return Align;
 799#if ENABLE(WEBVTT_REGIONS)
 800 if (name == regionIdKeyword)
 801 return RegionId;
 802#endif
 803
 804 return None;
 805}
 806
 807void VTTCue::setCueSettings(const String& input)
 808{
 809 m_settings = input;
 810 unsigned position = 0;
 811
 812 while (position < input.length()) {
 813
 814 // The WebVTT cue settings part of a WebVTT cue consists of zero or more of the following components, in any order,
 815 // separated from each other by one or more U+0020 SPACE characters or U+0009 CHARACTER TABULATION (tab) characters.
 816 while (position < input.length() && WebVTTParser::isValidSettingDelimiter(input[position]))
 817 position++;
 818 if (position >= input.length())
 819 break;
 820
 821 // When the user agent is to parse the WebVTT settings given by a string input for a text track cue cue,
 822 // the user agent must run the following steps:
 823 // 1. Let settings be the result of splitting input on spaces.
 824 // 2. For each token setting in the list settings, run the following substeps:
 825 // 1. If setting does not contain a U+003A COLON character (:), or if the first U+003A COLON character (:)
 826 // in setting is either the first or last character of setting, then jump to the step labeled next setting.
 827 unsigned endOfSetting = position;
 828 String setting = WebVTTParser::collectWord(input, &endOfSetting);
 829 CueSetting name;
 830 size_t colonOffset = setting.find(':', 1);
 831 if (colonOffset == notFound || !colonOffset || colonOffset == setting.length() - 1)
 832 goto NextSetting;
 833
 834 // 2. Let name be the leading substring of setting up to and excluding the first U+003A COLON character (:) in that string.
 835 name = settingName(setting.substring(0, colonOffset));
 836
 837 // 3. Let value be the trailing substring of setting starting from the character immediately after the first U+003A COLON character (:) in that string.
 838 position += colonOffset + 1;
 839 if (position >= input.length())
 840 break;
 841
 842 // 4. Run the appropriate substeps that apply for the value of name, as follows:
 843 switch (name) {
 844 case Vertical:
 845 {
 846 // If name is a case-sensitive match for "vertical"
 847 // 1. If value is a case-sensitive match for the string "rl", then let cue's text track cue writing direction
 848 // be vertical growing left.
 849 String writingDirection = WebVTTParser::collectWord(input, &position);
 850 if (writingDirection == verticalGrowingLeftKeyword())
 851 m_writingDirection = VerticalGrowingLeft;
 852
 853 // 2. Otherwise, if value is a case-sensitive match for the string "lr", then let cue's text track cue writing
 854 // direction be vertical growing right.
 855 else if (writingDirection == verticalGrowingRightKeyword())
 856 m_writingDirection = VerticalGrowingRight;
 857 }
 858 break;
 859 case Line:
 860 {
 861 // 1-2 - Collect chars that are either '-', '%', or a digit.
 862 // 1. If value contains any characters other than U+002D HYPHEN-MINUS characters (-), U+0025 PERCENT SIGN
 863 // characters (%), and characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump
 864 // to the step labeled next setting.
 865 StringBuilder linePositionBuilder;
 866 while (position < input.length() && (input[position] == '-' || input[position] == '%' || isASCIIDigit(input[position])))
 867 linePositionBuilder.append(input[position++]);
 868 if (position < input.length() && !WebVTTParser::isValidSettingDelimiter(input[position]))
 869 break;
 870
 871 // 2. If value does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
 872 // NINE (9), then jump to the step labeled next setting.
 873 // 3. If any character in value other than the first character is a U+002D HYPHEN-MINUS character (-), then
 874 // jump to the step labeled next setting.
 875 // 4. If any character in value other than the last character is a U+0025 PERCENT SIGN character (%), then
 876 // jump to the step labeled next setting.
 877 String linePosition = linePositionBuilder.toString();
 878 if (linePosition.find('-', 1) != notFound || linePosition.reverseFind("%", linePosition.length() - 2) != notFound)
 879 break;
 880
 881 // 5. If the first character in value is a U+002D HYPHEN-MINUS character (-) and the last character in value is a
 882 // U+0025 PERCENT SIGN character (%), then jump to the step labeled next setting.
 883 if (linePosition[0] == '-' && linePosition[linePosition.length() - 1] == '%')
 884 break;
 885
 886 // 6. Ignoring the trailing percent sign, if any, interpret value as a (potentially signed) integer, and
 887 // let number be that number.
 888 // NOTE: toInt ignores trailing non-digit characters, such as '%'.
 889 bool validNumber;
 890 int number = linePosition.toInt(&validNumber);
 891 if (!validNumber)
 892 break;
 893
 894 // 7. If the last character in value is a U+0025 PERCENT SIGN character (%), but number is not in the range
 895 // 0 ≤ number ≤ 100, then jump to the step labeled next setting.
 896 // 8. Let cue's text track cue line position be number.
 897 // 9. If the last character in value is a U+0025 PERCENT SIGN character (%), then let cue's text track cue
 898 // snap-to-lines flag be false. Otherwise, let it be true.
 899 if (linePosition[linePosition.length() - 1] == '%') {
 900 if (number < 0 || number > 100)
 901 break;
 902
 903 // 10 - If '%' then set snap-to-lines flag to false.
 904 m_snapToLines = false;
 905 }
 906
 907 m_linePosition = number;
 908 }
 909 break;
 910 case Position:
 911 {
 912 // 1. If value contains any characters other than U+0025 PERCENT SIGN characters (%) and characters in the range
 913 // U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump to the step labeled next setting.
 914 // 2. If value does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9),
 915 // then jump to the step labeled next setting.
 916 String textPosition = WebVTTParser::collectDigits(input, &position);
 917 if (textPosition.isEmpty())
 918 break;
 919 if (position >= input.length())
 920 break;
 921
 922 // 3. If any character in value other than the last character is a U+0025 PERCENT SIGN character (%), then jump
 923 // to the step labeled next setting.
 924 // 4. If the last character in value is not a U+0025 PERCENT SIGN character (%), then jump to the step labeled
 925 // next setting.
 926 if (input[position++] != '%')
 927 break;
 928 if (position < input.length() && !WebVTTParser::isValidSettingDelimiter(input[position]))
 929 break;
 930
 931 // 5. Ignoring the trailing percent sign, interpret value as an integer, and let number be that number.
 932 // 6. If number is not in the range 0 ≤ number ≤ 100, then jump to the step labeled next setting.
 933 // NOTE: toInt ignores trailing non-digit characters, such as '%'.
 934 bool validNumber;
 935 int number = textPosition.toInt(&validNumber);
 936 if (!validNumber)
 937 break;
 938 if (number < 0 || number > 100)
 939 break;
 940
 941 // 7. Let cue's text track cue text position be number.
 942 m_textPosition = number;
 943 }
 944 break;
 945 case Size:
 946 {
 947 // 1. If value contains any characters other than U+0025 PERCENT SIGN characters (%) and characters in the
 948 // range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then jump to the step labeled next setting.
 949 // 2. If value does not contain at least one character in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT
 950 // NINE (9), then jump to the step labeled next setting.
 951 String cueSize = WebVTTParser::collectDigits(input, &position);
 952 if (cueSize.isEmpty())
 953 break;
 954 if (position >= input.length())
 955 break;
 956
 957 // 3. If any character in value other than the last character is a U+0025 PERCENT SIGN character (%),
 958 // then jump to the step labeled next setting.
 959 // 4. If the last character in value is not a U+0025 PERCENT SIGN character (%), then jump to the step
 960 // labeled next setting.
 961 if (input[position++] != '%')
 962 break;
 963 if (position < input.length() && !WebVTTParser::isValidSettingDelimiter(input[position]))
 964 break;
 965
 966 // 5. Ignoring the trailing percent sign, interpret value as an integer, and let number be that number.
 967 // 6. If number is not in the range 0 ≤ number ≤ 100, then jump to the step labeled next setting.
 968 bool validNumber;
 969 int number = cueSize.toInt(&validNumber);
 970 if (!validNumber)
 971 break;
 972 if (number < 0 || number > 100)
 973 break;
 974
 975 // 7. Let cue's text track cue size be number.
 976 m_cueSize = number;
 977 }
 978 break;
 979 case Align:
 980 {
 981 String cueAlignment = WebVTTParser::collectWord(input, &position);
 982
 983 // 1. If value is a case-sensitive match for the string "start", then let cue's text track cue alignment be start alignment.
 984 if (cueAlignment == startKeyword())
 985 m_cueAlignment = Start;
 986
 987 // 2. If value is a case-sensitive match for the string "middle", then let cue's text track cue alignment be middle alignment.
 988 else if (cueAlignment == middleKeyword())
 989 m_cueAlignment = Middle;
 990
 991 // 3. If value is a case-sensitive match for the string "end", then let cue's text track cue alignment be end alignment.
 992 else if (cueAlignment == endKeyword())
 993 m_cueAlignment = End;
 994 }
 995 break;
 996#if ENABLE(WEBVTT_REGIONS)
 997 case RegionId:
 998 m_regionId = WebVTTParser::collectWord(input, &position);
 999 break;
 1000#endif
 1001 case None:
 1002 break;
 1003 }
 1004
 1005NextSetting:
 1006 position = endOfSetting;
 1007 }
 1008#if ENABLE(WEBVTT_REGIONS)
 1009 // If cue's line position is not auto or cue's size is not 100 or cue's
 1010 // writing direction is not horizontal, but cue's region identifier is not
 1011 // the empty string, let cue's region identifier be the empty string.
 1012 if (m_regionId.isEmpty())
 1013 return;
 1014
 1015 if (m_linePosition != undefinedPosition || m_cueSize != 100 || m_writingDirection != Horizontal)
 1016 m_regionId = emptyString();
 1017#endif
 1018}
 1019
 1020CSSValueID VTTCue::getCSSWritingDirection() const
 1021{
 1022 return m_displayDirection;
 1023}
 1024
 1025CSSValueID VTTCue::getCSSWritingMode() const
 1026{
 1027 return m_displayWritingMode;
 1028}
 1029
 1030int VTTCue::getCSSSize() const
 1031{
 1032 return m_displaySize;
 1033}
 1034
 1035std::pair<double, double> VTTCue::getCSSPosition() const
 1036{
 1037 if (!m_snapToLines)
 1038 return getPositionCoordinates();
 1039
 1040 return m_displayPosition;
 1041}
 1042
 1043bool VTTCue::isEqual(const VTTCue& cue, CueMatchRules match) const
 1044{
 1045 if (cueType() != cue.cueType())
 1046 return false;
 1047
 1048 if (match != IgnoreDuration && endTime() != cue.endTime())
 1049 return false;
 1050 if (startTime() != cue.startTime())
 1051 return false;
 1052 if (text() != cue.text())
 1053 return false;
 1054 if (cueSettings() != cue.cueSettings())
 1055 return false;
 1056 if (id() != cue.id())
 1057 return false;
 1058 if (position() != cue.position())
 1059 return false;
 1060 if (line() != cue.line())
 1061 return false;
 1062 if (size() != cue.size())
 1063 return false;
 1064 if (align() != cue.align())
 1065 return false;
 1066
 1067 return true;
 1068}
 1069
 1070void VTTCue::setFontSize(int fontSize, const IntSize&, bool important)
 1071{
 1072 if (!hasDisplayTree() || !fontSize)
 1073 return;
 1074
 1075 LOG(Media, "TextTrackCue::setFontSize - setting cue font size to %i", fontSize);
 1076
 1077 displayTreeInternal()->setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX, important);
 1078}
 1079
 1080VTTCue* toVTTCue(TextTrackCue* cue)
 1081{
 1082 return const_cast<VTTCue*>(toVTTCue(const_cast<const TextTrackCue*>(cue)));
 1083}
 1084
 1085const VTTCue* toVTTCue(const TextTrackCue* cue)
 1086{
 1087 ASSERT_WITH_SECURITY_IMPLICATION(cue->cueType() == TextTrackCue::WebVTT || cue->cueType() == TextTrackCue::Generic);
 1088 return static_cast<const VTTCue*>(cue);
 1089}
 1090
 1091} // namespace WebCore
 1092
 1093#endif

Source/WebCore/html/track/VTTCue.h

 1/*
 2 * Copyright (C) 2011 Google Inc. All rights reserved.
 3 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions are
 7 * met:
 8 *
 9 * * Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * * Redistributions in binary form must reproduce the above
 12 * copyright notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * * Neither the name of Google Inc. nor the names of its
 16 * contributors may be used to endorse or promote products derived from
 17 * this software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#ifndef VTTCue_h
 33#define VTTCue_h
 34
 35#if ENABLE(VIDEO_TRACK)
 36
 37#include "EventTarget.h"
 38#include "HTMLElement.h"
 39#include "TextTrackCue.h"
 40#include <wtf/PassOwnPtr.h>
 41#include <wtf/RefCounted.h>
 42
 43namespace WebCore {
 44
 45class DocumentFragment;
 46class HTMLSpanElement;
 47class ScriptExecutionContext;
 48class VTTCue;
 49
 50// ----------------------------
 51
 52class VTTCueBox : public HTMLElement {
 53public:
 54 static PassRefPtr<VTTCueBox> create(Document& document, VTTCue* cue)
 55 {
 56 return adoptRef(new VTTCueBox(document, cue));
 57 }
 58
 59 VTTCue* getCue() const;
 60 virtual void applyCSSProperties(const IntSize& videoSize);
 61
 62 static const AtomicString& vttCueBoxShadowPseudoId();
 63
 64protected:
 65 VTTCueBox(Document&, VTTCue*);
 66
 67 virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override;
 68
 69 VTTCue* m_cue;
 70};
 71
 72// ----------------------------
 73
 74class VTTCue : public TextTrackCue {
 75public:
 76 static PassRefPtr<VTTCue> create(ScriptExecutionContext& context, double start, double end, const String& content)
 77 {
 78 return adoptRef(new VTTCue(context, start, end, content));
 79 }
 80
 81 virtual ~VTTCue();
 82
 83 const String& vertical() const;
 84 void setVertical(const String&, ExceptionCode&);
 85
 86 bool snapToLines() const { return m_snapToLines; }
 87 void setSnapToLines(bool);
 88
 89 int line() const { return m_linePosition; }
 90 virtual void setLine(int, ExceptionCode&);
 91
 92 int position() const { return m_textPosition; }
 93 virtual void setPosition(int, ExceptionCode&);
 94
 95 int size() const { return m_cueSize; }
 96 virtual void setSize(int, ExceptionCode&);
 97
 98 const String& align() const;
 99 void setAlign(const String&, ExceptionCode&);
 100
 101 const String& text() const { return m_content; }
 102 void setText(const String&);
 103
 104 const String& cueSettings() const { return m_settings; }
 105 void setCueSettings(const String&);
 106
 107 PassRefPtr<DocumentFragment> getCueAsHTML();
 108 PassRefPtr<DocumentFragment> createCueRenderingTree();
 109
 110#if ENABLE(WEBVTT_REGIONS)
 111 const String& regionId() const { return m_regionId; }
 112 void setRegionId(const String&);
 113#endif
 114
 115 virtual void setIsActive(bool);
 116
 117 bool hasDisplayTree() const { return m_displayTree; }
 118 VTTCueBox* getDisplayTree(const IntSize& videoSize);
 119 HTMLSpanElement* element() const { return m_cueBackgroundBox.get(); }
 120
 121 void updateDisplayTree(double);
 122 void removeDisplayTree();
 123 void markFutureAndPastNodes(ContainerNode*, double, double);
 124
 125 int calculateComputedLinePosition();
 126 std::pair<double, double> getPositionCoordinates() const;
 127
 128 std::pair<double, double> getCSSPosition() const;
 129
 130 int getCSSSize() const;
 131 CSSValueID getCSSWritingDirection() const;
 132 CSSValueID getCSSWritingMode() const;
 133
 134 enum WritingDirection {
 135 Horizontal,
 136 VerticalGrowingLeft,
 137 VerticalGrowingRight,
 138 NumberOfWritingDirections
 139 };
 140 WritingDirection getWritingDirection() const { return m_writingDirection; }
 141
 142 enum CueAlignment {
 143 Start,
 144 Middle,
 145 End
 146 };
 147 CueAlignment getAlignment() const { return m_cueAlignment; }
 148
 149 virtual void setFontSize(int, const IntSize&, bool important);
 150
 151 enum CueMatchRules {
 152 MatchAllFields,
 153 IgnoreDuration,
 154 };
 155 virtual bool isEqual(const VTTCue&, CueMatchRules) const;
 156
 157 virtual CueType cueType() const { return WebVTT; }
 158
 159 virtual void didChange() override;
 160
 161protected:
 162 VTTCue(ScriptExecutionContext&, double start, double end, const String& content);
 163
 164 virtual PassRefPtr<VTTCueBox> createDisplayTree();
 165 VTTCueBox* displayTreeInternal();
 166
 167private:
 168 void createWebVTTNodeTree();
 169 void copyWebVTTNodeToDOMTree(ContainerNode* WebVTTNode, ContainerNode* root);
 170
 171 void parseSettings(const String&);
 172
 173 void determineTextDirection();
 174 void calculateDisplayParameters();
 175
 176 enum CueSetting {
 177 None,
 178 Vertical,
 179 Line,
 180 Position,
 181 Size,
 182 Align,
 183#if ENABLE(WEBVTT_REGIONS)
 184 RegionId
 185#endif
 186 };
 187 CueSetting settingName(const String&);
 188
 189 String m_content;
 190 String m_settings;
 191 int m_linePosition;
 192 int m_computedLinePosition;
 193 int m_textPosition;
 194 int m_cueSize;
 195
 196 WritingDirection m_writingDirection;
 197 CueAlignment m_cueAlignment;
 198
 199 RefPtr<DocumentFragment> m_webVTTNodeTree;
 200
 201 bool m_snapToLines;
 202
 203 RefPtr<HTMLSpanElement> m_cueBackgroundBox;
 204
 205 bool m_displayTreeShouldChange;
 206 RefPtr<VTTCueBox> m_displayTree;
 207
 208 CSSValueID m_displayDirection;
 209
 210 CSSValueID m_displayWritingModeMap[NumberOfWritingDirections];
 211 CSSValueID m_displayWritingMode;
 212
 213 int m_displaySize;
 214
 215 std::pair<float, float> m_displayPosition;
 216#if ENABLE(WEBVTT_REGIONS)
 217 String m_regionId;
 218#endif
 219};
 220
 221VTTCue* toVTTCue(TextTrackCue*);
 222const VTTCue* toVTTCue(const TextTrackCue*);
 223
 224} // namespace WebCore
 225
 226#endif
 227#endif

Source/WebCore/html/track/VTTCue.idl

 1/*
 2 * Copyright (C) 2011 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25[
 26 Conditional=VIDEO_TRACK,
 27 Constructor(double startTime, double endTime, DOMString text),
 28 ConstructorCallWith=ScriptExecutionContext,
 29 JSGenerateToJSObject,
 30 JSGenerateToNativeObject,
 31] interface VTTCue : TextTrackCue {
 32 [SetterRaisesException] attribute DOMString vertical;
 33 attribute boolean snapToLines;
 34 [SetterRaisesException] attribute double line;
 35 [SetterRaisesException] attribute double position;
 36 [SetterRaisesException] attribute double size;
 37 [SetterRaisesException] attribute DOMString align;
 38 attribute DOMString text;
 39 DocumentFragment getCueAsHTML();
 40
 41#if defined(ENABLE_WEBVTT_REGIONS) && ENABLE_WEBVTT_REGIONS
 42 attribute DOMString regionId;
 43#endif
 44};

Source/WebCore/loader/TextTrackLoader.cpp

3737#include "Logging.h"
3838#include "ResourceBuffer.h"
3939#include "SecurityOrigin.h"
40 #include "TextTrackCue.h"
 40#include "VTTCue.h"
4141#include "WebVTTParser.h"
4242
4343namespace WebCore {

@@void TextTrackLoader::getNewCues(Vector<RefPtr<TextTrackCue>>& outputCues)
213213 m_cueParser->getNewCues(newCues);
214214 for (size_t i = 0; i < newCues.size(); ++i) {
215215 RefPtr<WebVTTCueData> data = newCues[i];
216  RefPtr<TextTrackCue> cue = TextTrackCue::create(*m_scriptExecutionContext, data->startTime(), data->endTime(), data->content());
 216 RefPtr<VTTCue> cue = VTTCue::create(*m_scriptExecutionContext, data->startTime(), data->endTime(), data->content());
217217 cue->setId(data->id());
218218 cue->setCueSettings(data->settings());
219219 outputCues.append(cue);

Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp

4040#include "Logging.h"
4141#include "MediaControlElements.h"
4242#include "SoftLinking.h"
43 #include "TextTrackCue.h"
4443#include "TextTrackList.h"
4544#include "UserStyleSheetTypes.h"
 45#include "VTTCue.h"
4646#include <wtf/RetainPtr.h>
4747#include <wtf/text/CString.h>
4848#include <wtf/text/StringBuilder.h>

@@String CaptionUserPreferencesMediaAF::captionsStyleSheetOverride() const
543543 String windowCornerRadius = windowRoundedCornerRadiusCSS();
544544 if (!windowColor.isEmpty() || !windowCornerRadius.isEmpty()) {
545545 captionsOverrideStyleSheet.append(" video::");
546  captionsOverrideStyleSheet.append(TextTrackCueBox::textTrackCueBoxShadowPseudoId());
 546 captionsOverrideStyleSheet.append(VTTCueBox::vttCueBoxShadowPseudoId());
547547 captionsOverrideStyleSheet.append('{');
548548
549549 if (!windowColor.isEmpty())

Source/WebCore/rendering/RenderTextTrackCue.cpp

1 /*
2  * Copyright (C) 2012 Victor Carbune (victor@rosedu.org)
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "config.h"
27 
28 #if ENABLE(VIDEO_TRACK)
29 
30 #include "RenderTextTrackCue.h"
31 #include "RenderView.h"
32 
33 #include "RenderView.h"
34 #include "TextTrackCue.h"
35 #include "TextTrackCueGeneric.h"
36 #include <wtf/StackStats.h>
37 
38 namespace WebCore {
39 
40 RenderTextTrackCue::RenderTextTrackCue(TextTrackCueBox& element, PassRef<RenderStyle> style)
41  : RenderBlockFlow(element, std::move(style))
42  , m_cue(element.getCue())
43 {
44 }
45 
46 void RenderTextTrackCue::layout()
47 {
48  StackStats::LayoutCheckPoint layoutCheckPoint;
49  RenderBlockFlow::layout();
50 
51  LayoutStateMaintainer statePusher(view(), *this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
52 
53  if (m_cue->cueType()== TextTrackCue::WebVTT) {
54  if (m_cue->snapToLines())
55  repositionCueSnapToLinesSet();
56  else
57  repositionCueSnapToLinesNotSet();
58  } else
59  repositionGenericCue();
60 
61  statePusher.pop();
62 }
63 
64 bool RenderTextTrackCue::initializeLayoutParameters(InlineFlowBox*& firstLineBox, LayoutUnit& step, LayoutUnit& position)
65 {
66  ASSERT(firstChild());
67 
68  RenderBlock* parentBlock = containingBlock();
69  firstLineBox = toRenderInline(firstChild())->firstLineBox();
70  if (!firstLineBox)
71  firstLineBox = this->firstRootBox();
72 
73  // 1. Horizontal: Let step be the height of the first line box in boxes.
74  // Vertical: Let step be the width of the first line box in boxes.
75  step = m_cue->getWritingDirection() == TextTrackCue::Horizontal ? firstLineBox->height() : firstLineBox->width();
76 
77  // 2. If step is zero, then jump to the step labeled done positioning below.
78  if (!step)
79  return false;
80 
81  // 3. Let line position be the text track cue computed line position.
82  int linePosition = m_cue->calculateComputedLinePosition();
83 
84  // 4. Vertical Growing Left: Add one to line position then negate it.
85  if (m_cue->getWritingDirection() == TextTrackCue::VerticalGrowingLeft)
86  linePosition = -(linePosition + 1);
87 
88  // 5. Let position be the result of multiplying step and line position.
89  position = step * linePosition;
90 
91  // 6. Vertical Growing Left: Decrease position by the width of the
92  // bounding box of the boxes in boxes, then increase position by step.
93  if (m_cue->getWritingDirection() == TextTrackCue::VerticalGrowingLeft) {
94  position -= width();
95  position += step;
96  }
97 
98  // 7. If line position is less than zero...
99  if (linePosition < 0) {
100  // Horizontal / Vertical: ... then increase position by the
101  // height / width of the video's rendering area ...
102  position += m_cue->getWritingDirection() == TextTrackCue::Horizontal ? parentBlock->height() : parentBlock->width();
103 
104  // ... and negate step.
105  step = -step;
106  }
107 
108  return true;
109 }
110 
111 void RenderTextTrackCue::placeBoxInDefaultPosition(LayoutUnit position, bool& switched)
112 {
113  // 8. Move all boxes in boxes ...
114  if (m_cue->getWritingDirection() == TextTrackCue::Horizontal)
115  // Horizontal: ... down by the distance given by position
116  setY(y() + position);
117  else
118  // Vertical: ... right by the distance given by position
119  setX(x() + position);
120 
121  // 9. Default: Remember the position of all the boxes in boxes as their
122  // default position.
123  m_fallbackPosition = FloatPoint(x(), y());
124 
125  // 10. Let switched be false.
126  switched = false;
127 }
128 
129 bool RenderTextTrackCue::isOutside() const
130 {
131  return !rectIsWithinContainer(absoluteContentBox());
132 }
133 
134 bool RenderTextTrackCue::rectIsWithinContainer(const IntRect& rect) const
135 {
136  return containingBlock()->absoluteBoundingBoxRect().contains(rect);
137 }
138 
139 
140 bool RenderTextTrackCue::isOverlapping() const
141 {
142  return overlappingObject();
143 }
144 
145 RenderObject* RenderTextTrackCue::overlappingObject() const
146 {
147  return overlappingObjectForRect(absoluteBoundingBoxRect());
148 }
149 
150 RenderObject* RenderTextTrackCue::overlappingObjectForRect(const IntRect& rect) const
151 {
152  for (RenderObject* box = previousSibling(); box; box = box->previousSibling()) {
153  IntRect boxRect = box->absoluteBoundingBoxRect();
154 
155  if (rect.intersects(boxRect))
156  return box;
157  }
158 
159  return 0;
160 }
161 
162 bool RenderTextTrackCue::shouldSwitchDirection(InlineFlowBox* firstLineBox, LayoutUnit step) const
163 {
164  LayoutUnit top = y();
165  LayoutUnit left = x();
166  LayoutUnit bottom = top + firstLineBox->height();
167  LayoutUnit right = left + firstLineBox->width();
168 
169  // 12. Horizontal: If step is negative and the top of the first line
170  // box in boxes is now above the top of the video's rendering area,
171  // or if step is positive and the bottom of the first line box in
172  // boxes is now below the bottom of the video's rendering area, jump
173  // to the step labeled switch direction.
174  LayoutUnit parentHeight = containingBlock()->height();
175  if (m_cue->getWritingDirection() == TextTrackCue::Horizontal && ((step < 0 && top < 0) || (step > 0 && bottom > parentHeight)))
176  return true;
177 
178  // 12. Vertical: If step is negative and the left edge of the first line
179  // box in boxes is now to the left of the left edge of the video's
180  // rendering area, or if step is positive and the right edge of the
181  // first line box in boxes is now to the right of the right edge of
182  // the video's rendering area, jump to the step labeled switch direction.
183  LayoutUnit parentWidth = containingBlock()->width();
184  if (m_cue->getWritingDirection() != TextTrackCue::Horizontal && ((step < 0 && left < 0) || (step > 0 && right > parentWidth)))
185  return true;
186 
187  return false;
188 }
189 
190 void RenderTextTrackCue::moveBoxesByStep(LayoutUnit step)
191 {
192  // 13. Horizontal: Move all the boxes in boxes down by the distance
193  // given by step. (If step is negative, then this will actually
194  // result in an upwards movement of the boxes in absolute terms.)
195  if (m_cue->getWritingDirection() == TextTrackCue::Horizontal)
196  setY(y() + step);
197 
198  // 13. Vertical: Move all the boxes in boxes right by the distance
199  // given by step. (If step is negative, then this will actually
200  // result in a leftwards movement of the boxes in absolute terms.)
201  else
202  setX(x() + step);
203 }
204 
205 bool RenderTextTrackCue::switchDirection(bool& switched, LayoutUnit& step)
206 {
207  // 15. Switch direction: Move all the boxes in boxes back to their
208  // default position as determined in the step above labeled default.
209  setX(m_fallbackPosition.x());
210  setY(m_fallbackPosition.y());
211 
212  // 16. If switched is true, jump to the step labeled done
213  // positioning below.
214  if (switched)
215  return false;
216 
217  // 17. Negate step.
218  step = -step;
219 
220  // 18. Set switched to true.
221  switched = true;
222  return true;
223 }
224 
225 void RenderTextTrackCue::moveIfNecessaryToKeepWithinContainer()
226 {
227  IntRect containerRect = containingBlock()->absoluteBoundingBoxRect();
228  IntRect cueRect = absoluteBoundingBoxRect();
229 
230  int topOverflow = cueRect.y() - containerRect.y();
231  int bottomOverflow = containerRect.maxY() - cueRect.maxY();
232 
233  int verticalAdjustment = 0;
234  if (topOverflow < 0)
235  verticalAdjustment = -topOverflow;
236  else if (bottomOverflow < 0)
237  verticalAdjustment = bottomOverflow;
238 
239  if (verticalAdjustment)
240  setY(y() + verticalAdjustment);
241 
242  int leftOverflow = cueRect.x() - containerRect.x();
243  int rightOverflow = containerRect.maxX() - cueRect.maxX();
244 
245  int horizontalAdjustment = 0;
246  if (leftOverflow < 0)
247  horizontalAdjustment = -leftOverflow;
248  else if (rightOverflow < 0)
249  horizontalAdjustment = rightOverflow;
250 
251  if (horizontalAdjustment)
252  setX(x() + horizontalAdjustment);
253 }
254 
255 bool RenderTextTrackCue::findNonOverlappingPosition(int& newX, int& newY) const
256 {
257  newX = x();
258  newY = y();
259  IntRect srcRect = absoluteBoundingBoxRect();
260  IntRect destRect = srcRect;
261 
262  // Move the box up, looking for a non-overlapping position:
263  while (RenderObject* box = overlappingObjectForRect(destRect)) {
264  if (m_cue->getWritingDirection() == TextTrackCue::Horizontal)
265  destRect.setY(box->absoluteBoundingBoxRect().y() - destRect.height());
266  else
267  destRect.setX(box->absoluteBoundingBoxRect().x() - destRect.width());
268  }
269 
270  if (rectIsWithinContainer(destRect)) {
271  newX += destRect.x() - srcRect.x();
272  newY += destRect.y() - srcRect.y();
273  return true;
274  }
275 
276  destRect = srcRect;
277 
278  // Move the box down, looking for a non-overlapping position:
279  while (RenderObject* box = overlappingObjectForRect(destRect)) {
280  if (m_cue->getWritingDirection() == TextTrackCue::Horizontal)
281  destRect.setY(box->absoluteBoundingBoxRect().maxY());
282  else
283  destRect.setX(box->absoluteBoundingBoxRect().maxX());
284  }
285 
286  if (rectIsWithinContainer(destRect)) {
287  newX += destRect.x() - srcRect.x();
288  newY += destRect.y() - srcRect.y();
289  return true;
290  }
291 
292  return false;
293 }
294 
295 void RenderTextTrackCue::repositionCueSnapToLinesSet()
296 {
297  InlineFlowBox* firstLineBox;
298  LayoutUnit step;
299  LayoutUnit position;
300  if (!initializeLayoutParameters(firstLineBox, step, position))
301  return;
302 
303  bool switched;
304  placeBoxInDefaultPosition(position, switched);
305 
306  // 11. Step loop: If none of the boxes in boxes would overlap any of the boxes
307  // in output and all the boxes in output are within the video's rendering area
308  // then jump to the step labeled done positioning.
309  while (isOutside() || isOverlapping()) {
310  if (!shouldSwitchDirection(firstLineBox, step))
311  // 13. Move all the boxes in boxes ...
312  // 14. Jump back to the step labeled step loop.
313  moveBoxesByStep(step);
314  else if (!switchDirection(switched, step))
315  break;
316 
317  // 19. Jump back to the step labeled step loop.
318  }
319 
320  // Acommodate extra top and bottom padding, border or margin.
321  // Note: this is supported only for internal UA styling, not through the cue selector.
322  if (hasInlineDirectionBordersPaddingOrMargin())
323  moveIfNecessaryToKeepWithinContainer();
324 }
325 
326 void RenderTextTrackCue::repositionGenericCue()
327 {
328  ASSERT(firstChild());
329  InlineFlowBox* firstLineBox = toRenderInline(firstChild())->firstLineBox();
330  if (static_cast<TextTrackCueGeneric*>(m_cue)->useDefaultPosition() && firstLineBox) {
331  LayoutUnit parentWidth = containingBlock()->logicalWidth();
332  LayoutUnit width = firstLineBox->width();
333  LayoutUnit right = (parentWidth / 2) - (width / 2);
334  setX(right);
335  }
336  repositionCueSnapToLinesNotSet();
337 }
338 
339 void RenderTextTrackCue::repositionCueSnapToLinesNotSet()
340 {
341  // 3. If none of the boxes in boxes would overlap any of the boxes in output, and all the boxes in
342  // output are within the video's rendering area, then jump to the step labeled done positioning below.
343  if (!isOutside() && !isOverlapping())
344  return;
345 
346  // 4. If there is a position to which the boxes in boxes can be moved while maintaining the relative
347  // positions of the boxes in boxes to each other such that none of the boxes in boxes would overlap
348  // any of the boxes in output, and all the boxes in output would be within the video's rendering area,
349  // then move the boxes in boxes to the closest such position to their current position, and then jump
350  // to the step labeled done positioning below. If there are multiple such positions that are equidistant
351  // from their current position, use the highest one amongst them; if there are several at that height,
352  // then use the leftmost one amongst them.
353  moveIfNecessaryToKeepWithinContainer();
354  int x = 0;
355  int y = 0;
356  if (!findNonOverlappingPosition(x, y))
357  return;
358 
359  setX(x);
360  setY(y);
361 }
362 
363 } // namespace WebCore
364 
365 #endif

Source/WebCore/rendering/RenderTextTrackCue.h

1 /*
2  * Copyright (C) 2012 Victor Carbune (victor@rosedu.org)
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef RenderTextTrackCue_h
27 #define RenderTextTrackCue_h
28 
29 #if ENABLE(VIDEO_TRACK)
30 
31 #include "FloatPoint.h"
32 #include "RenderBlockFlow.h"
33 #include "RenderInline.h"
34 
35 namespace WebCore {
36 
37 class RenderBox;
38 class TextTrackCueBox;
39 
40 class RenderTextTrackCue final : public RenderBlockFlow {
41 public:
42  RenderTextTrackCue(TextTrackCueBox&, PassRef<RenderStyle>);
43 
44 private:
45  virtual void layout() override;
46 
47  bool isOutside() const;
48  bool rectIsWithinContainer(const IntRect&) const;
49  bool isOverlapping() const;
50  RenderObject* overlappingObject() const;
51  RenderObject* overlappingObjectForRect(const IntRect&) const;
52  bool shouldSwitchDirection(InlineFlowBox*, LayoutUnit) const;
53 
54  void moveBoxesByStep(LayoutUnit);
55  bool switchDirection(bool&, LayoutUnit&);
56  void moveIfNecessaryToKeepWithinContainer();
57  bool findNonOverlappingPosition(int& x, int& y) const;
58 
59  bool initializeLayoutParameters(InlineFlowBox*&, LayoutUnit&, LayoutUnit&);
60  void placeBoxInDefaultPosition(LayoutUnit, bool&);
61  void repositionCueSnapToLinesSet();
62  void repositionCueSnapToLinesNotSet();
63  void repositionGenericCue();
64 
65  TextTrackCue* m_cue;
66  FloatPoint m_fallbackPosition;
67 };
68 
69 } // namespace WebCore
70 
71 #endif
72 #endif // RenderTextTrackCue_h

Source/WebCore/rendering/RenderVTTCue.cpp

 1/*
 2 * Copyright (C) 2012 Victor Carbune (victor@rosedu.org)
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27
 28#if ENABLE(VIDEO_TRACK)
 29#include "RenderVTTCue.h"
 30
 31#include "RenderView.h"
 32#include "TextTrackCueGeneric.h"
 33#include "VTTCue.h"
 34#include <wtf/StackStats.h>
 35
 36namespace WebCore {
 37
 38RenderVTTCue::RenderVTTCue(VTTCueBox& element, PassRef<RenderStyle> style)
 39 : RenderBlockFlow(element, std::move(style))
 40 , m_cue(element.getCue())
 41{
 42}
 43
 44void RenderVTTCue::layout()
 45{
 46 StackStats::LayoutCheckPoint layoutCheckPoint;
 47 RenderBlockFlow::layout();
 48
 49 LayoutStateMaintainer statePusher(view(), *this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
 50
 51 if (m_cue->cueType()== VTTCue::WebVTT) {
 52 if (toVTTCue(m_cue)->snapToLines())
 53 repositionCueSnapToLinesSet();
 54 else
 55 repositionCueSnapToLinesNotSet();
 56 } else
 57 repositionGenericCue();
 58
 59 statePusher.pop();
 60}
 61
 62bool RenderVTTCue::initializeLayoutParameters(InlineFlowBox*& firstLineBox, LayoutUnit& step, LayoutUnit& position)
 63{
 64 ASSERT(firstChild());
 65
 66 RenderBlock* parentBlock = containingBlock();
 67 firstLineBox = toRenderInline(firstChild())->firstLineBox();
 68 if (!firstLineBox)
 69 firstLineBox = this->firstRootBox();
 70
 71 // 1. Horizontal: Let step be the height of the first line box in boxes.
 72 // Vertical: Let step be the width of the first line box in boxes.
 73 step = m_cue->getWritingDirection() == VTTCue::Horizontal ? firstLineBox->height() : firstLineBox->width();
 74
 75 // 2. If step is zero, then jump to the step labeled done positioning below.
 76 if (!step)
 77 return false;
 78
 79 // 3. Let line position be the text track cue computed line position.
 80 int linePosition = m_cue->calculateComputedLinePosition();
 81
 82 // 4. Vertical Growing Left: Add one to line position then negate it.
 83 if (m_cue->getWritingDirection() == VTTCue::VerticalGrowingLeft)
 84 linePosition = -(linePosition + 1);
 85
 86 // 5. Let position be the result of multiplying step and line position.
 87 position = step * linePosition;
 88
 89 // 6. Vertical Growing Left: Decrease position by the width of the
 90 // bounding box of the boxes in boxes, then increase position by step.
 91 if (m_cue->getWritingDirection() == VTTCue::VerticalGrowingLeft) {
 92 position -= width();
 93 position += step;
 94 }
 95
 96 // 7. If line position is less than zero...
 97 if (linePosition < 0) {
 98 // Horizontal / Vertical: ... then increase position by the
 99 // height / width of the video's rendering area ...
 100 position += m_cue->getWritingDirection() == VTTCue::Horizontal ? parentBlock->height() : parentBlock->width();
 101
 102 // ... and negate step.
 103 step = -step;
 104 }
 105
 106 return true;
 107}
 108
 109void RenderVTTCue::placeBoxInDefaultPosition(LayoutUnit position, bool& switched)
 110{
 111 // 8. Move all boxes in boxes ...
 112 if (m_cue->getWritingDirection() == VTTCue::Horizontal)
 113 // Horizontal: ... down by the distance given by position
 114 setY(y() + position);
 115 else
 116 // Vertical: ... right by the distance given by position
 117 setX(x() + position);
 118
 119 // 9. Default: Remember the position of all the boxes in boxes as their
 120 // default position.
 121 m_fallbackPosition = FloatPoint(x(), y());
 122
 123 // 10. Let switched be false.
 124 switched = false;
 125}
 126
 127bool RenderVTTCue::isOutside() const
 128{
 129 return !rectIsWithinContainer(absoluteContentBox());
 130}
 131
 132bool RenderVTTCue::rectIsWithinContainer(const IntRect& rect) const
 133{
 134 return containingBlock()->absoluteBoundingBoxRect().contains(rect);
 135}
 136
 137
 138bool RenderVTTCue::isOverlapping() const
 139{
 140 return overlappingObject();
 141}
 142
 143RenderObject* RenderVTTCue::overlappingObject() const
 144{
 145 return overlappingObjectForRect(absoluteBoundingBoxRect());
 146}
 147
 148RenderObject* RenderVTTCue::overlappingObjectForRect(const IntRect& rect) const
 149{
 150 for (RenderObject* box = previousSibling(); box; box = box->previousSibling()) {
 151 IntRect boxRect = box->absoluteBoundingBoxRect();
 152
 153 if (rect.intersects(boxRect))
 154 return box;
 155 }
 156
 157 return 0;
 158}
 159
 160bool RenderVTTCue::shouldSwitchDirection(InlineFlowBox* firstLineBox, LayoutUnit step) const
 161{
 162 LayoutUnit top = y();
 163 LayoutUnit left = x();
 164 LayoutUnit bottom = top + firstLineBox->height();
 165 LayoutUnit right = left + firstLineBox->width();
 166
 167 // 12. Horizontal: If step is negative and the top of the first line
 168 // box in boxes is now above the top of the video's rendering area,
 169 // or if step is positive and the bottom of the first line box in
 170 // boxes is now below the bottom of the video's rendering area, jump
 171 // to the step labeled switch direction.
 172 LayoutUnit parentHeight = containingBlock()->height();
 173 if (m_cue->getWritingDirection() == VTTCue::Horizontal && ((step < 0 && top < 0) || (step > 0 && bottom > parentHeight)))
 174 return true;
 175
 176 // 12. Vertical: If step is negative and the left edge of the first line
 177 // box in boxes is now to the left of the left edge of the video's
 178 // rendering area, or if step is positive and the right edge of the
 179 // first line box in boxes is now to the right of the right edge of
 180 // the video's rendering area, jump to the step labeled switch direction.
 181 LayoutUnit parentWidth = containingBlock()->width();
 182 if (m_cue->getWritingDirection() != VTTCue::Horizontal && ((step < 0 && left < 0) || (step > 0 && right > parentWidth)))
 183 return true;
 184
 185 return false;
 186}
 187
 188void RenderVTTCue::moveBoxesByStep(LayoutUnit step)
 189{
 190 // 13. Horizontal: Move all the boxes in boxes down by the distance
 191 // given by step. (If step is negative, then this will actually
 192 // result in an upwards movement of the boxes in absolute terms.)
 193 if (m_cue->getWritingDirection() == VTTCue::Horizontal)
 194 setY(y() + step);
 195
 196 // 13. Vertical: Move all the boxes in boxes right by the distance
 197 // given by step. (If step is negative, then this will actually
 198 // result in a leftwards movement of the boxes in absolute terms.)
 199 else
 200 setX(x() + step);
 201}
 202
 203bool RenderVTTCue::switchDirection(bool& switched, LayoutUnit& step)
 204{
 205 // 15. Switch direction: Move all the boxes in boxes back to their
 206 // default position as determined in the step above labeled default.
 207 setX(m_fallbackPosition.x());
 208 setY(m_fallbackPosition.y());
 209
 210 // 16. If switched is true, jump to the step labeled done
 211 // positioning below.
 212 if (switched)
 213 return false;
 214
 215 // 17. Negate step.
 216 step = -step;
 217
 218 // 18. Set switched to true.
 219 switched = true;
 220 return true;
 221}
 222
 223void RenderVTTCue::moveIfNecessaryToKeepWithinContainer()
 224{
 225 IntRect containerRect = containingBlock()->absoluteBoundingBoxRect();
 226 IntRect cueRect = absoluteBoundingBoxRect();
 227
 228 int topOverflow = cueRect.y() - containerRect.y();
 229 int bottomOverflow = containerRect.maxY() - cueRect.maxY();
 230
 231 int verticalAdjustment = 0;
 232 if (topOverflow < 0)
 233 verticalAdjustment = -topOverflow;
 234 else if (bottomOverflow < 0)
 235 verticalAdjustment = bottomOverflow;
 236
 237 if (verticalAdjustment)
 238 setY(y() + verticalAdjustment);
 239
 240 int leftOverflow = cueRect.x() - containerRect.x();
 241 int rightOverflow = containerRect.maxX() - cueRect.maxX();
 242
 243 int horizontalAdjustment = 0;
 244 if (leftOverflow < 0)
 245 horizontalAdjustment = -leftOverflow;
 246 else if (rightOverflow < 0)
 247 horizontalAdjustment = rightOverflow;
 248
 249 if (horizontalAdjustment)
 250 setX(x() + horizontalAdjustment);
 251}
 252
 253bool RenderVTTCue::findNonOverlappingPosition(int& newX, int& newY) const
 254{
 255 newX = x();
 256 newY = y();
 257 IntRect srcRect = absoluteBoundingBoxRect();
 258 IntRect destRect = srcRect;
 259
 260 // Move the box up, looking for a non-overlapping position:
 261 while (RenderObject* box = overlappingObjectForRect(destRect)) {
 262 if (m_cue->getWritingDirection() == VTTCue::Horizontal)
 263 destRect.setY(box->absoluteBoundingBoxRect().y() - destRect.height());
 264 else
 265 destRect.setX(box->absoluteBoundingBoxRect().x() - destRect.width());
 266 }
 267
 268 if (rectIsWithinContainer(destRect)) {
 269 newX += destRect.x() - srcRect.x();
 270 newY += destRect.y() - srcRect.y();
 271 return true;
 272 }
 273
 274 destRect = srcRect;
 275
 276 // Move the box down, looking for a non-overlapping position:
 277 while (RenderObject* box = overlappingObjectForRect(destRect)) {
 278 if (m_cue->getWritingDirection() == VTTCue::Horizontal)
 279 destRect.setY(box->absoluteBoundingBoxRect().maxY());
 280 else
 281 destRect.setX(box->absoluteBoundingBoxRect().maxX());
 282 }
 283
 284 if (rectIsWithinContainer(destRect)) {
 285 newX += destRect.x() - srcRect.x();
 286 newY += destRect.y() - srcRect.y();
 287 return true;
 288 }
 289
 290 return false;
 291}
 292
 293void RenderVTTCue::repositionCueSnapToLinesSet()
 294{
 295 InlineFlowBox* firstLineBox;
 296 LayoutUnit step;
 297 LayoutUnit position;
 298 if (!initializeLayoutParameters(firstLineBox, step, position))
 299 return;
 300
 301 bool switched;
 302 placeBoxInDefaultPosition(position, switched);
 303
 304 // 11. Step loop: If none of the boxes in boxes would overlap any of the boxes
 305 // in output and all the boxes in output are within the video's rendering area
 306 // then jump to the step labeled done positioning.
 307 while (isOutside() || isOverlapping()) {
 308 if (!shouldSwitchDirection(firstLineBox, step))
 309 // 13. Move all the boxes in boxes ...
 310 // 14. Jump back to the step labeled step loop.
 311 moveBoxesByStep(step);
 312 else if (!switchDirection(switched, step))
 313 break;
 314
 315 // 19. Jump back to the step labeled step loop.
 316 }
 317
 318 // Acommodate extra top and bottom padding, border or margin.
 319 // Note: this is supported only for internal UA styling, not through the cue selector.
 320 if (hasInlineDirectionBordersPaddingOrMargin())
 321 moveIfNecessaryToKeepWithinContainer();
 322}
 323
 324void RenderVTTCue::repositionGenericCue()
 325{
 326 ASSERT(firstChild());
 327 InlineFlowBox* firstLineBox = toRenderInline(firstChild())->firstLineBox();
 328 if (static_cast<TextTrackCueGeneric*>(m_cue)->useDefaultPosition() && firstLineBox) {
 329 LayoutUnit parentWidth = containingBlock()->logicalWidth();
 330 LayoutUnit width = firstLineBox->width();
 331 LayoutUnit right = (parentWidth / 2) - (width / 2);
 332 setX(right);
 333 }
 334 repositionCueSnapToLinesNotSet();
 335}
 336
 337void RenderVTTCue::repositionCueSnapToLinesNotSet()
 338{
 339 // 3. If none of the boxes in boxes would overlap any of the boxes in output, and all the boxes in
 340 // output are within the video's rendering area, then jump to the step labeled done positioning below.
 341 if (!isOutside() && !isOverlapping())
 342 return;
 343
 344 // 4. If there is a position to which the boxes in boxes can be moved while maintaining the relative
 345 // positions of the boxes in boxes to each other such that none of the boxes in boxes would overlap
 346 // any of the boxes in output, and all the boxes in output would be within the video's rendering area,
 347 // then move the boxes in boxes to the closest such position to their current position, and then jump
 348 // to the step labeled done positioning below. If there are multiple such positions that are equidistant
 349 // from their current position, use the highest one amongst them; if there are several at that height,
 350 // then use the leftmost one amongst them.
 351 moveIfNecessaryToKeepWithinContainer();
 352 int x = 0;
 353 int y = 0;
 354 if (!findNonOverlappingPosition(x, y))
 355 return;
 356
 357 setX(x);
 358 setY(y);
 359}
 360
 361} // namespace WebCore
 362
 363#endif

Source/WebCore/rendering/RenderVTTCue.h

 1/*
 2 * Copyright (C) 2012 Victor Carbune (victor@rosedu.org)
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef RenderVTTCue_h
 27#define RenderVTTCue_h
 28
 29#if ENABLE(VIDEO_TRACK)
 30
 31#include "FloatPoint.h"
 32#include "RenderBlockFlow.h"
 33#include "RenderInline.h"
 34
 35namespace WebCore {
 36
 37class RenderBox;
 38class VTTCue;
 39class VTTCueBox;
 40
 41class RenderVTTCue final : public RenderBlockFlow {
 42public:
 43 RenderVTTCue(VTTCueBox&, PassRef<RenderStyle>);
 44
 45private:
 46 virtual void layout() override;
 47
 48 bool isOutside() const;
 49 bool rectIsWithinContainer(const IntRect&) const;
 50 bool isOverlapping() const;
 51 RenderObject* overlappingObject() const;
 52 RenderObject* overlappingObjectForRect(const IntRect&) const;
 53 bool shouldSwitchDirection(InlineFlowBox*, LayoutUnit) const;
 54
 55 void moveBoxesByStep(LayoutUnit);
 56 bool switchDirection(bool&, LayoutUnit&);
 57 void moveIfNecessaryToKeepWithinContainer();
 58 bool findNonOverlappingPosition(int& x, int& y) const;
 59
 60 bool initializeLayoutParameters(InlineFlowBox*&, LayoutUnit&, LayoutUnit&);
 61 void placeBoxInDefaultPosition(LayoutUnit, bool&);
 62 void repositionCueSnapToLinesSet();
 63 void repositionCueSnapToLinesNotSet();
 64 void repositionGenericCue();
 65
 66 VTTCue* m_cue;
 67 FloatPoint m_fallbackPosition;
 68};
 69
 70} // namespace WebCore
 71
 72#endif
 73#endif // RenderVTTCue_h

Source/WebCore/rendering/RenderingAllInOne.cpp

108108#include "RenderTextControlSingleLine.cpp"
109109#include "RenderTextFragment.cpp"
110110#include "RenderTextLineBoxes.cpp"
111 #include "RenderTextTrackCue.cpp"
112111#include "RenderTheme.cpp"
113112#if PLATFORM(WIN)
114113#include "RenderThemeWin.cpp"
115114#endif
116115#include "RenderTreeAsText.cpp"
 116#include "RenderVTTCue.cpp"
117117#include "RenderVideo.cpp"
118118#include "RenderView.cpp"
119119#include "RenderWidget.cpp"

LayoutTests/ChangeLog

 12014-02-07 Brendan Long <b.long@cablelabs.com>
 2
 3 Update TextTrack API to current spec
 4 https://bugs.webkit.org/show_bug.cgi?id=122218
 5
 6 Refactoring VTTCue out of TextTrackCue.
 7
 8 Reviewed by NOBODY (OOPS!).
 9
 10 * js/dom/constructor-length.html: Add VTTCue constructor.
 11 * platform/efl/js/dom/global-constructors-attributes-expected.txt: Same.
 12 * platform/efl/js/dom/constructor-length-expected.txt: Same.
 13 * js/dom/global-constructors-attributes-expected.txt: Same.
 14 * platform/gtk-wk2/js/dom/constructor-length-expected.txt: Same.
 15 * platform/gtk-wk2/js/dom/global-constructors-attributes-expected.txt: Same.
 16 * platform/gtk/js/dom/constructor-length-expected.txt: Same.
 17 * platform/gtk/js/dom/global-constructors-attributes-expected.txt: Same.
 18 * platform/mac-mountainlion/js/dom/global-constructors-attributes-expected.txt: Same.
 19 * platform/mac/js/dom/constructor-length-expected.txt: Same.
 20 * platform/mac/js/dom/global-constructors-attributes-expected.txt: Same.
 21 * platform/win/js/dom/global-constructors-attributes-expected.txt: Same.
 22 * media/track/track-cues-cuechange-expected.txt: Cues are of type VTTCue now.
 23 * media/track/track-cues-enter-exit-expected.txt: Same.
 24 * media/track/track-vttcue-expected.txt: Test VTTCue interface.
 25 * media/track/track-vttcue.html: Same.
 26 * media/video-test.js:
 27 (testExpected): Add "instanceof" as a valid operator.
 28
1292014-02-07 Michał Pakuła vel Rutka <m.pakula@samsung.com>
230
331 Unreviewed EFL gardening

LayoutTests/js/dom/constructor-length.html

@@shouldBe('Uint16Array.length', '3');
4646shouldBe('Uint32Array.length', '3');
4747shouldBe('Uint8Array.length', '3');
4848shouldBe('Uint8ClampedArray.length', '3');
 49shouldBe('VTTCue.length', '3');
4950shouldBe('WebGLContextEvent.length', '1');
5051shouldBe('WebKitAnimationEvent.length', '1');
5152shouldBe('WebKitCSSMatrix.length', '0');

LayoutTests/js/dom/global-constructors-attributes-expected.txt

@@PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('get') is fal
18231823PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
18241824PASS Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
18251825PASS Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
 1826PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').value is VTTCue
 1827PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('get') is false
 1828PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('set') is false
 1829PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').enumerable is false
 1830PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').configurable is true
18261831PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').value is WaveShaperNode
18271832PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('get') is false
18281833PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('set') is false

LayoutTests/media/track/track-cues-cuechange-expected.txt

@@RUN(video.play())
88EVENT(cuechange) from TextTrack
99EVENT(cuechange) from <track>
1010Cue entered
11 EXPECTED ([object TextTrackCue] == '[object TextTrackCue]') OK
 11EXPECTED ([object VTTCue] == '[object VTTCue]') OK
1212EXPECTED (currentCue.id == '1') OK
1313
1414EVENT(cuechange) from TextTrack

@@Cue exited
1818EVENT(cuechange) from TextTrack
1919EVENT(cuechange) from <track>
2020Cue entered
21 EXPECTED ([object TextTrackCue] == '[object TextTrackCue]') OK
 21EXPECTED ([object VTTCue] == '[object VTTCue]') OK
2222EXPECTED (currentCue.id == '2') OK
2323
2424EVENT(cuechange) from TextTrack

@@Cue exited
2828EVENT(cuechange) from TextTrack
2929EVENT(cuechange) from <track>
3030Cue entered
31 EXPECTED ([object TextTrackCue] == '[object TextTrackCue]') OK
 31EXPECTED ([object VTTCue] == '[object VTTCue]') OK
3232EXPECTED (currentCue.id == '3') OK
3333
3434EVENT(cuechange) from TextTrack

LayoutTests/media/track/track-cues-enter-exit-expected.txt

@@RUN(video.play())
77
88EVENT(enter)
99This cue is the currently active cue:
10 EXPECTED ([object TextTrackCue] == '[object TextTrackCue]') OK
 10EXPECTED ([object VTTCue] == '[object VTTCue]') OK
1111EXPECTED (currentCue.id == '1') OK
1212
1313EVENT(exit)
1414
1515EVENT(enter)
1616This cue is the currently active cue:
17 EXPECTED ([object TextTrackCue] == '[object TextTrackCue]') OK
 17EXPECTED ([object VTTCue] == '[object VTTCue]') OK
1818EXPECTED (currentCue.id == '2') OK
1919
2020EVENT(exit)
2121
2222EVENT(enter)
2323This cue is the currently active cue:
24 EXPECTED ([object TextTrackCue] == '[object TextTrackCue]') OK
 24EXPECTED ([object VTTCue] == '[object VTTCue]') OK
2525EXPECTED (currentCue.id == '3') OK
2626
2727EVENT(exit)

LayoutTests/media/track/track-vttcue-expected.txt

 1Tests VTTCue interface
 2
 3
 4
 5*** Test cue loaded from the file.
 6RUN(inbandCue = cues[0])
 7EXPECTED (inbandCue instanceof '[object TextTrackCueConstructor]') OK
 8EXPECTED (inbandCue.track == '[object TextTrack]') OK
 9EXPECTED (inbandCue.id == '1') OK
 10EXPECTED (inbandCue.startTime == '0') OK
 11EXPECTED (inbandCue.endTime == '0.3') OK
 12EXPECTED (inbandCue.pauseOnExit == 'false') OK
 13EXPECTED (inbandCue instanceof '[object VTTCueConstructor]') OK
 14EXPECTED (inbandCue.vertical == '') OK
 15EXPECTED (inbandCue.snapToLines == 'true') OK
 16EXPECTED (inbandCue.line == '-1') OK
 17EXPECTED (inbandCue.position == '50') OK
 18EXPECTED (inbandCue.size == '100') OK
 19EXPECTED (inbandCue.align == 'middle') OK
 20EXPECTED (inbandCue.text == 'Lorem') OK
 21EXPECTED (serialize(inbandCue.getCueAsHTML()) == 'Lorem') OK
 22
 23*** Create a new cue, check values
 24RUN(newCue = new VTTCue(3.14, 6.28, 'Pie'))
 25EXPECTED (newCue instanceof '[object TextTrackCueConstructor]') OK
 26EXPECTED (newCue.track == 'null') OK
 27EXPECTED (newCue.id == '') OK
 28EXPECTED (newCue.startTime == '3.14') OK
 29EXPECTED (newCue.endTime == '6.28') OK
 30EXPECTED (newCue.pauseOnExit == 'false') OK
 31EXPECTED (newCue instanceof '[object VTTCueConstructor]') OK
 32EXPECTED (newCue.vertical == '') OK
 33EXPECTED (newCue.snapToLines == 'true') OK
 34EXPECTED (newCue.line == '-1') OK
 35EXPECTED (newCue.position == '50') OK
 36EXPECTED (newCue.size == '100') OK
 37EXPECTED (newCue.align == 'middle') OK
 38EXPECTED (newCue.text == 'Pie') OK
 39EXPECTED (serialize(newCue.getCueAsHTML()) == 'Pie') OK
 40END OF TEST
 41

LayoutTests/media/track/track-vttcue.html

 1<!DOCTYPE html>
 2<html>
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5
 6 <script src=../media-file.js></script>
 7 <script src=../video-test.js></script>
 8 <script>
 9
 10 var cues;
 11
 12 function serialize(documentFragment)
 13 {
 14 return new XMLSerializer().serializeToString(documentFragment);
 15 }
 16
 17 function trackLoaded()
 18 {
 19 var testTrack = document.getElementById('testTrack');
 20 cues = testTrack.track.cues;
 21
 22 consoleWrite("<br>*** Test cue loaded from the file.");
 23 run("inbandCue = cues[0]");
 24
 25 testExpected("inbandCue", TextTrackCue, "instanceof");
 26 testExpected("inbandCue.track", testTrack.track);
 27 testExpected("inbandCue.id", "1");
 28 testExpected("inbandCue.startTime", 0);
 29 testExpected("inbandCue.endTime", 0.3);
 30 testExpected("inbandCue.pauseOnExit", false);
 31
 32 testExpected("inbandCue", VTTCue, "instanceof");
 33 testExpected("inbandCue.vertical", "");
 34 testExpected("inbandCue.snapToLines", true);
 35 testExpected("inbandCue.line", -1);
 36 testExpected("inbandCue.position", 50);
 37 testExpected("inbandCue.size", 100);
 38 testExpected("inbandCue.align", "middle");
 39 testExpected("inbandCue.text", "Lorem");
 40 testExpected("serialize(inbandCue.getCueAsHTML())", 'Lorem');
 41
 42 consoleWrite("<br>*** Create a new cue, check values");
 43 run("newCue = new VTTCue(3.14, 6.28, 'Pie')");
 44
 45 testExpected("newCue", TextTrackCue, "instanceof");
 46 testExpected("newCue.track", null);
 47 testExpected("newCue.id", '');
 48 testExpected("newCue.startTime", 3.14);
 49 testExpected("newCue.endTime", 6.28);
 50 testExpected("newCue.pauseOnExit", false);
 51
 52 testExpected("newCue", VTTCue, "instanceof");
 53 testExpected("newCue.vertical", "");
 54 testExpected("newCue.snapToLines", true);
 55 testExpected("newCue.line", -1);
 56 testExpected("newCue.position", 50);
 57 testExpected("newCue.size", 100);
 58 testExpected("newCue.align", "middle");
 59 testExpected("newCue.text", "Pie");
 60 testExpected("serialize(newCue.getCueAsHTML())", 'Pie');
 61
 62 endTest();
 63 }
 64
 65 setCaptionDisplayMode('Automatic');
 66 </script>
 67 </head>
 68 <body>
 69 <p>Tests VTTCue interface</p>
 70 <video>
 71 <track id="testTrack" src="captions-webvtt/captions-fast.vtt" kind="captions" onload="trackLoaded()" default>
 72 </video>
 73 </body>
 74</html>

LayoutTests/media/video-test.js

@@function testExpected(testFuncString, expected, comparison)
8383 case '!=': success = observed != expected; break;
8484 case '==': success = observed == expected; break;
8585 case '===': success = observed === expected; break;
 86 case 'instanceof': success = observed instanceof expected; break;
8687 }
8788
8889 reportExpected(success, testFuncString, comparison, expected, observed)

LayoutTests/platform/efl/js/dom/constructor-length-expected.txt

@@PASS Uint16Array.length is 3
4242PASS Uint32Array.length is 3
4343PASS Uint8Array.length is 3
4444PASS Uint8ClampedArray.length is 3
 45PASS VTTCue.length is 3
4546PASS WebGLContextEvent.length is 1
4647PASS WebKitAnimationEvent.length is 1
4748PASS WebKitCSSMatrix.length is 0

LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt

@@PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('get') is fal
18381838PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
18391839PASS Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
18401840PASS Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
 1841PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').value is VTTCue
 1842PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('get') is false
 1843PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('set') is false
 1844PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').enumerable is false
 1845PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').configurable is true
18411846PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').value is WaveShaperNode
18421847PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('get') is false
18431848PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('set') is false

LayoutTests/platform/gtk-wk2/js/dom/constructor-length-expected.txt

@@PASS Uint16Array.length is 3
4242PASS Uint32Array.length is 3
4343PASS Uint8Array.length is 3
4444PASS Uint8ClampedArray.length is 3
 45PASS VTTCue.length is 3
4546PASS WebGLContextEvent.length is 1
4647PASS WebKitAnimationEvent.length is 1
4748PASS WebKitCSSMatrix.length is 0

LayoutTests/platform/gtk-wk2/js/dom/global-constructors-attributes-expected.txt

@@PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('get') is fal
18931893PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
18941894PASS Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
18951895PASS Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
 1896PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').value is VTTCue
 1897PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('get') is false
 1898PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('set') is false
 1899PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').enumerable is false
 1900PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').configurable is true
18961901PASS Object.getOwnPropertyDescriptor(global, 'VideoStreamTrack').value is VideoStreamTrack
18971902PASS Object.getOwnPropertyDescriptor(global, 'VideoStreamTrack').hasOwnProperty('get') is false
18981903PASS Object.getOwnPropertyDescriptor(global, 'VideoStreamTrack').hasOwnProperty('set') is false

LayoutTests/platform/gtk/js/dom/constructor-length-expected.txt

@@PASS Uint16Array.length is 3
4242PASS Uint32Array.length is 3
4343PASS Uint8Array.length is 3
4444PASS Uint8ClampedArray.length is 3
 45PASS VTTCue.length is 3
4546PASS WebGLContextEvent.length is 1
4647PASS WebKitAnimationEvent.length is 1
4748PASS WebKitCSSMatrix.length is 0

LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt

@@PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('get') is fal
18881888PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
18891889PASS Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
18901890PASS Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
 1891PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').value is VTTCue
 1892PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('get') is false
 1893PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('set') is false
 1894PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').enumerable is false
 1895PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').configurable is true
18911896PASS Object.getOwnPropertyDescriptor(global, 'VideoStreamTrack').value is VideoStreamTrack
18921897PASS Object.getOwnPropertyDescriptor(global, 'VideoStreamTrack').hasOwnProperty('get') is false
18931898PASS Object.getOwnPropertyDescriptor(global, 'VideoStreamTrack').hasOwnProperty('set') is false

LayoutTests/platform/mac-mountainlion/js/dom/global-constructors-attributes-expected.txt

@@PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('get') is fal
18281828PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
18291829PASS Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
18301830PASS Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
 1831PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').value is VTTCue
 1832PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('get') is false
 1833PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('set') is false
 1834PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').enumerable is false
 1835PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').configurable is true
18311836PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').value is WaveShaperNode
18321837PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('get') is false
18331838PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('set') is false

LayoutTests/platform/mac/js/dom/constructor-length-expected.txt

@@PASS Uint16Array.length is 3
4242PASS Uint32Array.length is 3
4343PASS Uint8Array.length is 3
4444PASS Uint8ClampedArray.length is 3
 45PASS VTTCue.length is 3
4546PASS WebGLContextEvent.length is 1
4647PASS WebKitAnimationEvent.length is 1
4748PASS WebKitCSSMatrix.length is 0

LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt

@@PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('get') is fal
18381838PASS Object.getOwnPropertyDescriptor(global, 'URL').hasOwnProperty('set') is false
18391839PASS Object.getOwnPropertyDescriptor(global, 'URL').enumerable is false
18401840PASS Object.getOwnPropertyDescriptor(global, 'URL').configurable is true
 1841PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').value is VTTCue
 1842PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('get') is false
 1843PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('set') is false
 1844PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').enumerable is false
 1845PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').configurable is true
18411846PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').value is WaveShaperNode
18421847PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('get') is false
18431848PASS Object.getOwnPropertyDescriptor(global, 'WaveShaperNode').hasOwnProperty('set') is false

LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt

@@PASS Object.getOwnPropertyDescriptor(global, 'UIEvent').hasOwnProperty('get') is
16281628PASS Object.getOwnPropertyDescriptor(global, 'UIEvent').hasOwnProperty('set') is false
16291629PASS Object.getOwnPropertyDescriptor(global, 'UIEvent').enumerable is false
16301630PASS Object.getOwnPropertyDescriptor(global, 'UIEvent').configurable is true
 1631PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').value is VTTCue
 1632PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('get') is false
 1633PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').hasOwnProperty('set') is false
 1634PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').enumerable is false
 1635PASS Object.getOwnPropertyDescriptor(global, 'VTTCue').configurable is true
16311636PASS Object.getOwnPropertyDescriptor(global, 'WebKitAnimationEvent').value is WebKitAnimationEvent
16321637PASS Object.getOwnPropertyDescriptor(global, 'WebKitAnimationEvent').hasOwnProperty('get') is false
16331638PASS Object.getOwnPropertyDescriptor(global, 'WebKitAnimationEvent').hasOwnProperty('set') is false