| Differences between
and this patch
- Source/WebCore/ChangeLog +91 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2013-01-21  Eric Carlson  <eric.carlson@apple.com>
2
3
        Support non-WebVTT cues from in-band text tracks
4
        https://bugs.webkit.org/show_bug.cgi?id=107046
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * CMakeLists.txt: Add new files.
9
        * GNUmakefile.list.am: Ditto.
10
        * Target.pri: Ditto.
11
        * WebCore.gypi: Ditto.
12
        * WebCore.vcproj/WebCore.vcproj: Ditto.
13
        * WebCore.xcodeproj/project.pbxproj: Ditto.
14
15
        * html/shadow/MediaControlElements.cpp:
16
        (WebCore::MediaControlTextTrackContainerElement::updateDisplay): Pass video size to getDisplayTree.
17
18
        * html/track/InbandTextTrack.cpp:
19
        (WebCore::InbandTextTrack::addGenericCue): New, create a generic cue if it doesn't already exist.
20
        (WebCore::InbandTextTrack::addWebVTTCue): Renamed from addCue.
21
        * html/track/InbandTextTrack.h:
22
23
        * html/track/TextTrack.cpp:
24
        (WebCore::TextTrack::hasCue): Moved from InbandTextTrack.cpp, use operator == instead of inline
25
            comparison so derived TextTrackCues can be compared.
26
        * html/track/TextTrack.h:
27
28
        * html/track/TextTrackCue.cpp:
29
        (WebCore::TextTrackCueBox::applyCSSProperties): Interface change.
30
        (WebCore::TextTrackCue::TextTrackCue): Don't create the display tree in the constructor, it may
31
            never be needed.
32
        (WebCore::TextTrackCue::createDisplayTree): New, create the display tree.
33
        (WebCore::TextTrackCue::displayTreeInternal): Display tree accessor, allows it to be created lazily.
34
        (WebCore::TextTrackCue::setAlign): Alignment -> CueAlignment.
35
        (WebCore::TextTrackCue::setIsActive): Use displayTreeInternal().
36
        (WebCore::TextTrackCue::getDisplayTree): Use displayTreeInternal(), pass video size to applyCSSProperties.
37
        (WebCore::TextTrackCue::removeDisplayTree): Use displayTreeInternal().
38
        (WebCore::TextTrackCue::operator==): New.
39
        * html/track/TextTrackCue.h:
40
        (WebCore::TextTrackCue::getAlignment): Alignment -> CueAlignment.
41
        (WebCore::TextTrackCue::operator!=): New.
42
        (WebCore::TextTrackCue::cueType): New, cue type identified needed by operator==.
43
        (WebCore::TextTrackCue::ownerDocument): New.
44
45
        * html/track/TextTrackCueGeneric.cpp: Added.
46
        (WebCore::TextTrackCueGenericBox::create):
47
        (WebCore::TextTrackCueGenericBox::TextTrackCueGenericBox):
48
        (WebCore::TextTrackCueGenericBox::applyCSSProperties):
49
        (WebCore:::TextTrackCue):
50
        (WebCore::TextTrackCueGeneric::createDisplayTree):
51
        (WebCore::TextTrackCueGeneric::operator==):
52
        * html/track/TextTrackCueGeneric.h: Added.
53
        (WebCore::TextTrackCueGeneric::create):
54
        (WebCore::TextTrackCueGeneric::~TextTrackCueGeneric):
55
        (WebCore::TextTrackCueGeneric::baseFontSizeRelativeToVideoHeight):
56
        (WebCore::TextTrackCueGeneric::setBaseFontSizeRelativeToVideoHeight):
57
        (WebCore::TextTrackCueGeneric::fontSizeMultiplier):
58
        (WebCore::TextTrackCueGeneric::setFontSizeMultiplier):
59
        (WebCore::TextTrackCueGeneric::fontName):
60
        (WebCore::TextTrackCueGeneric::setFontName):
61
        (WebCore::TextTrackCueGeneric::operator!=):
62
        (WebCore::TextTrackCueGeneric::cueType):
63
64
        * platform/graphics/InbandTextTrackPrivateClient.h:
65
        * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
66
        (WebCore::InbandTextTrackPrivateAVF::processCueAttributes): Copy cue attributes into GenericCueData
67
            struct instead of trying to convert to WebVTT settings string. Process font size,font base
68
            size, font name, and vertical layout attributes,
69
        (WebCore::InbandTextTrackPrivateAVF::processCue): Create separate cues for each attributed
70
            string in the array because each one can be at a different screen location.
71
        (WebCore::InbandTextTrackPrivateAVF::resetCueValues):
72
        * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h:
73
        (InbandTextTrackPrivateAVF):
74
75
        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
76
        (WebCore::MediaPlayerPrivateAVFoundation::seekCompleted): Reset any partially accumulated cues
77
            delivered since the seek was started.
78
        (WebCore::MediaPlayerPrivateAVFoundation::addGenericCue): Renamed from flushCurrentCue.
79
        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
80
81
        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
82
        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer): Whitespace cleanup.
83
        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Ditto.
84
        (WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Tell legible output to deliver cues
85
            without any additional styling needed by the internal renderer.
86
        (WebCore::MediaPlayerPrivateAVFoundationObjC::processTextTracks):
87
        (WebCore::MediaPlayerPrivateAVFoundationObjC::setCurrentTrack): Do nothing if asked to change
88
            to the track that is already current.
89
        (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]):
90
            Check to make sure that the client callback isn't NULL.
91
1
2013-01-21  Vladislav Kaznacheev  <kaznacheev@chromium.org>
92
2013-01-21  Vladislav Kaznacheev  <kaznacheev@chromium.org>
2
93
3
        [Inspector] Layout Elements panel in a single column when docked right.
94
        [Inspector] Layout Elements panel in a single column when docked right.
- Source/WebCore/CMakeLists.txt +1 lines
Lines 1581-1586 set(WebCore_SOURCES Source/WebCore/CMakeLists.txt_sec1
1581
    html/track/LoadableTextTrack.cpp
1581
    html/track/LoadableTextTrack.cpp
1582
    html/track/TextTrack.cpp
1582
    html/track/TextTrack.cpp
1583
    html/track/TextTrackCue.cpp
1583
    html/track/TextTrackCue.cpp
1584
    html/track/TextTrackCueGeneric.cpp
1584
    html/track/TextTrackCueList.cpp
1585
    html/track/TextTrackCueList.cpp
1585
    html/track/TextTrackList.cpp
1586
    html/track/TextTrackList.cpp
1586
    html/track/TrackBase.cpp
1587
    html/track/TrackBase.cpp
- Source/WebCore/GNUmakefile.list.am +2 lines
Lines 3672-3677 webcore_sources += \ Source/WebCore/GNUmakefile.list.am_sec1
3672
	Source/WebCore/html/track/TextTrack.h \
3672
	Source/WebCore/html/track/TextTrack.h \
3673
	Source/WebCore/html/track/TextTrackCue.cpp \
3673
	Source/WebCore/html/track/TextTrackCue.cpp \
3674
	Source/WebCore/html/track/TextTrackCue.h \
3674
	Source/WebCore/html/track/TextTrackCue.h \
3675
	Source/WebCore/html/track/TextTrackCueGeneric.cpp \
3676
	Source/WebCore/html/track/TextTrackCueGeneric.h \
3675
	Source/WebCore/html/track/TextTrackCueList.cpp \
3677
	Source/WebCore/html/track/TextTrackCueList.cpp \
3676
	Source/WebCore/html/track/TextTrackCueList.h \
3678
	Source/WebCore/html/track/TextTrackCueList.h \
3677
	Source/WebCore/html/track/TextTrackList.cpp \
3679
	Source/WebCore/html/track/TextTrackList.cpp \
- Source/WebCore/Target.pri +1 lines
Lines 1915-1920 HEADERS += \ Source/WebCore/Target.pri_sec1
1915
    html/track/LoadableTextTrack.h \
1915
    html/track/LoadableTextTrack.h \
1916
    html/track/TextTrack.h \
1916
    html/track/TextTrack.h \
1917
    html/track/TextTrackCue.h \
1917
    html/track/TextTrackCue.h \
1918
    html/track/TextTrackCueGeneric.h \
1918
    html/track/TextTrackCueList.h \
1919
    html/track/TextTrackCueList.h \
1919
    html/track/TextTrackList.h \
1920
    html/track/TextTrackList.h \
1920
    html/track/TrackBase.h \
1921
    html/track/TrackBase.h \
- Source/WebCore/WebCore.gypi +2 lines
Lines 3457-3462 Source/WebCore/WebCore.gypi_sec1
3457
            'html/track/TextTrack.h',
3457
            'html/track/TextTrack.h',
3458
            'html/track/TextTrackCue.cpp',
3458
            'html/track/TextTrackCue.cpp',
3459
            'html/track/TextTrackCue.h',
3459
            'html/track/TextTrackCue.h',
3460
            'html/track/TextTrackCueGeneric.cpp',
3461
            'html/track/TextTrackCueGeneric.h',
3460
            'html/track/TextTrackCueList.cpp',
3462
            'html/track/TextTrackCueList.cpp',
3461
            'html/track/TextTrackCueList.h',
3463
            'html/track/TextTrackCueList.h',
3462
            'html/track/TextTrackList.cpp',
3464
            'html/track/TextTrackList.cpp',
- Source/WebCore/WebCore.vcproj/WebCore.vcproj +8 lines
Lines 65265-65270 Source/WebCore/WebCore.vcproj/WebCore.vcproj_sec1
65265
					>
65265
					>
65266
				</File>
65266
				</File>
65267
				<File
65267
				<File
65268
					RelativePath="..\html\track\TextTrackCueGeneric.cpp"
65269
					>
65270
				</File>
65271
				<File
65272
					RelativePath="..\html\track\TextTrackCueGeneric.h"
65273
					>
65274
				</File>
65275
				<File
65268
					RelativePath="..\html\track\TextTrackCueList.cpp"
65276
					RelativePath="..\html\track\TextTrackCueList.cpp"
65269
					>
65277
					>
65270
				</File>
65278
				</File>
- Source/WebCore/WebCore.xcodeproj/project.pbxproj +8 lines
Lines 108-113 Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
108
		070756DF14239B4E00414161 /* JSTextTrackCueList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 070756D914239B4C00414161 /* JSTextTrackCueList.cpp */; };
108
		070756DF14239B4E00414161 /* JSTextTrackCueList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 070756D914239B4C00414161 /* JSTextTrackCueList.cpp */; };
109
		070756E014239B4E00414161 /* JSTextTrackCueList.h in Headers */ = {isa = PBXBuildFile; fileRef = 070756DA14239B4E00414161 /* JSTextTrackCueList.h */; };
109
		070756E014239B4E00414161 /* JSTextTrackCueList.h in Headers */ = {isa = PBXBuildFile; fileRef = 070756DA14239B4E00414161 /* JSTextTrackCueList.h */; };
110
		0709FC4E1025DEE30059CDBA /* AccessibilitySlider.h in Headers */ = {isa = PBXBuildFile; fileRef = 0709FC4D1025DEE30059CDBA /* AccessibilitySlider.h */; };
110
		0709FC4E1025DEE30059CDBA /* AccessibilitySlider.h in Headers */ = {isa = PBXBuildFile; fileRef = 0709FC4D1025DEE30059CDBA /* AccessibilitySlider.h */; };
111
		071A9EC2168FBC43002629F9 /* TextTrackCueGeneric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 071A9EC0168FB56C002629F9 /* TextTrackCueGeneric.cpp */; };
112
		071A9EC3168FBC55002629F9 /* TextTrackCueGeneric.h in Headers */ = {isa = PBXBuildFile; fileRef = 071A9EC1168FB56C002629F9 /* TextTrackCueGeneric.h */; settings = {ATTRIBUTES = (Private, ); }; };
111
		0720B0A014D3323500642955 /* GenericEventQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0720B09E14D3323500642955 /* GenericEventQueue.cpp */; };
113
		0720B0A014D3323500642955 /* GenericEventQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0720B09E14D3323500642955 /* GenericEventQueue.cpp */; };
112
		0720B0A014D3323500642956 /* GestureEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0720B09F14D3323500642956 /* GestureEvent.cpp */; };
114
		0720B0A014D3323500642956 /* GestureEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0720B09F14D3323500642956 /* GestureEvent.cpp */; };
113
		0720B0A114D3323500642955 /* GenericEventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0720B09F14D3323500642955 /* GenericEventQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
115
		0720B0A114D3323500642955 /* GenericEventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0720B09F14D3323500642955 /* GenericEventQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
Lines 7303-7308 Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
7303
		070756DA14239B4E00414161 /* JSTextTrackCueList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTextTrackCueList.h; sourceTree = "<group>"; };
7305
		070756DA14239B4E00414161 /* JSTextTrackCueList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTextTrackCueList.h; sourceTree = "<group>"; };
7304
		0709FC4D1025DEE30059CDBA /* AccessibilitySlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySlider.h; sourceTree = "<group>"; };
7306
		0709FC4D1025DEE30059CDBA /* AccessibilitySlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySlider.h; sourceTree = "<group>"; };
7305
		070DD8F50F01868000727DEB /* mediaControls.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mediaControls.css; sourceTree = "<group>"; };
7307
		070DD8F50F01868000727DEB /* mediaControls.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mediaControls.css; sourceTree = "<group>"; };
7308
		071A9EC0168FB56C002629F9 /* TextTrackCueGeneric.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextTrackCueGeneric.cpp; sourceTree = "<group>"; };
7309
		071A9EC1168FB56C002629F9 /* TextTrackCueGeneric.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackCueGeneric.h; sourceTree = "<group>"; };
7306
		0720B09E14D3323500642955 /* GenericEventQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GenericEventQueue.cpp; sourceTree = "<group>"; };
7310
		0720B09E14D3323500642955 /* GenericEventQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GenericEventQueue.cpp; sourceTree = "<group>"; };
7307
		0720B09F14D3323500642955 /* GenericEventQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericEventQueue.h; sourceTree = "<group>"; };
7311
		0720B09F14D3323500642955 /* GenericEventQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericEventQueue.h; sourceTree = "<group>"; };
7308
		0720B09F14D3323500642956 /* GestureEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GestureEvent.cpp; sourceTree = "<group>"; };
7312
		0720B09F14D3323500642956 /* GestureEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GestureEvent.cpp; sourceTree = "<group>"; };
Lines 19744-19749 Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
19744
				9759E93814EF1CF80026A2DD /* TextTrackCue.cpp */,
19748
				9759E93814EF1CF80026A2DD /* TextTrackCue.cpp */,
19745
				9759E93914EF1CF80026A2DD /* TextTrackCue.h */,
19749
				9759E93914EF1CF80026A2DD /* TextTrackCue.h */,
19746
				9759E93A14EF1CF80026A2DD /* TextTrackCue.idl */,
19750
				9759E93A14EF1CF80026A2DD /* TextTrackCue.idl */,
19751
				071A9EC0168FB56C002629F9 /* TextTrackCueGeneric.cpp */,
19752
				071A9EC1168FB56C002629F9 /* TextTrackCueGeneric.h */,
19747
				9759E93B14EF1CF80026A2DD /* TextTrackCueList.cpp */,
19753
				9759E93B14EF1CF80026A2DD /* TextTrackCueList.cpp */,
19748
				9759E93C14EF1CF80026A2DD /* TextTrackCueList.h */,
19754
				9759E93C14EF1CF80026A2DD /* TextTrackCueList.h */,
19749
				9759E93D14EF1CF80026A2DD /* TextTrackCueList.idl */,
19755
				9759E93D14EF1CF80026A2DD /* TextTrackCueList.idl */,
Lines 26027-26032 Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
26027
				B2C3DA4B0D006C1D00EF6F26 /* TextStream.h in Headers */,
26033
				B2C3DA4B0D006C1D00EF6F26 /* TextStream.h in Headers */,
26028
				9759E94014EF1CF80026A2DD /* TextTrack.h in Headers */,
26034
				9759E94014EF1CF80026A2DD /* TextTrack.h in Headers */,
26029
				9759E94314EF1CF80026A2DD /* TextTrackCue.h in Headers */,
26035
				9759E94314EF1CF80026A2DD /* TextTrackCue.h in Headers */,
26036
				071A9EC3168FBC55002629F9 /* TextTrackCueGeneric.h in Headers */,
26030
				9759E94614EF1CF80026A2DD /* TextTrackCueList.h in Headers */,
26037
				9759E94614EF1CF80026A2DD /* TextTrackCueList.h in Headers */,
26031
				076970871463AD8700F502CF /* TextTrackList.h in Headers */,
26038
				076970871463AD8700F502CF /* TextTrackList.h in Headers */,
26032
				B1AD4E7413A12A4600846B27 /* TextTrackLoader.h in Headers */,
26039
				B1AD4E7413A12A4600846B27 /* TextTrackLoader.h in Headers */,
Lines 29211-29216 Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec5
29211
				B2C3DA4A0D006C1D00EF6F26 /* TextStream.cpp in Sources */,
29218
				B2C3DA4A0D006C1D00EF6F26 /* TextStream.cpp in Sources */,
29212
				9759E93F14EF1CF80026A2DD /* TextTrack.cpp in Sources */,
29219
				9759E93F14EF1CF80026A2DD /* TextTrack.cpp in Sources */,
29213
				9759E94214EF1CF80026A2DD /* TextTrackCue.cpp in Sources */,
29220
				9759E94214EF1CF80026A2DD /* TextTrackCue.cpp in Sources */,
29221
				071A9EC2168FBC43002629F9 /* TextTrackCueGeneric.cpp in Sources */,
29214
				9759E94514EF1CF80026A2DD /* TextTrackCueList.cpp in Sources */,
29222
				9759E94514EF1CF80026A2DD /* TextTrackCueList.cpp in Sources */,
29215
				076970861463AD8700F502CF /* TextTrackList.cpp in Sources */,
29223
				076970861463AD8700F502CF /* TextTrackList.cpp in Sources */,
29216
				B1AD4E7313A12A4600846B27 /* TextTrackLoader.cpp in Sources */,
29224
				B1AD4E7313A12A4600846B27 /* TextTrackLoader.cpp in Sources */,
- Source/WebCore/html/HTMLMediaElement.cpp +5 lines
Lines 3819-3824 void HTMLMediaElement::clearMediaPlayer( Source/WebCore/html/HTMLMediaElement.cpp_sec1
3819
3819
3820
    m_pendingLoadFlags &= ~flags;
3820
    m_pendingLoadFlags &= ~flags;
3821
    m_loadState = WaitingForSource;
3821
    m_loadState = WaitingForSource;
3822
3823
#if ENABLE(VIDEO_TRACK)
3824
    if (m_textTracks)
3825
        configureTextTrackDisplay();
3826
#endif
3822
}
3827
}
3823
3828
3824
bool HTMLMediaElement::canSuspend() const
3829
bool HTMLMediaElement::canSuspend() const
- Source/WebCore/html/shadow/MediaControlElements.cpp -2 / +1 lines
Lines 1304-1311 void MediaControlTextTrackContainerEleme Source/WebCore/html/shadow/MediaControlElements.cpp_sec1
1304
        if (!cue->track() || !cue->track()->isRendered())
1304
        if (!cue->track() || !cue->track()->isRendered())
1305
            continue;
1305
            continue;
1306
1306
1307
        RefPtr<TextTrackCueBox> displayBox = cue->getDisplayTree();
1307
        RefPtr<TextTrackCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size());
1308
1309
        if (displayBox->hasChildNodes() && !contains(static_cast<Node*>(displayBox.get())))
1308
        if (displayBox->hasChildNodes() && !contains(static_cast<Node*>(displayBox.get())))
1310
            // Note: the display tree of a cue is removed when the active flag of the cue is unset.
1309
            // Note: the display tree of a cue is removed when the active flag of the cue is unset.
1311
            m_cueContainer->appendChild(displayBox, ASSERT_NO_EXCEPTION, false);
1310
            m_cueContainer->appendChild(displayBox, ASSERT_NO_EXCEPTION, false);
- Source/WebCore/html/track/InbandTextTrack.cpp -59 / +42 lines
Lines 32-40 Source/WebCore/html/track/InbandTextTrack.cpp_sec1
32
#include "Document.h"
32
#include "Document.h"
33
#include "Event.h"
33
#include "Event.h"
34
#include "InbandTextTrackPrivate.h"
34
#include "InbandTextTrackPrivate.h"
35
#include "Logging.h"
35
#include "MediaPlayer.h"
36
#include "MediaPlayer.h"
37
#include "TextTrackCueGeneric.h"
36
#include "TextTrackCueList.h"
38
#include "TextTrackCueList.h"
37
39
#include <math.h>
38
#include <wtf/UnusedParam.h>
40
#include <wtf/UnusedParam.h>
39
41
40
namespace WebCore {
42
namespace WebCore {
Lines 98-171 size_t InbandTextTrack::inbandTrackIndex Source/WebCore/html/track/InbandTextTrack.cpp_sec2
98
    return m_private->textTrackIndex();
100
    return m_private->textTrackIndex();
99
}
101
}
100
102
101
void InbandTextTrack::addCue(InbandTextTrackPrivate* trackPrivate, double start, double end, const String& id, const String& content, const String& settings)
103
void InbandTextTrack::addGenericCue(InbandTextTrackPrivate* trackPrivate, GenericCueData* cueData)
102
{
104
{
103
    UNUSED_PARAM(trackPrivate);
105
    UNUSED_PARAM(trackPrivate);
104
    ASSERT(trackPrivate == m_private);
106
    ASSERT(trackPrivate == m_private);
105
107
106
    RefPtr<TextTrackCue> cue = TextTrackCue::create(scriptExecutionContext(), start, end, content);
108
    RefPtr<TextTrackCueGeneric> cue = TextTrackCueGeneric::create(scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
107
    cue->setId(id);
108
    cue->setCueSettings(settings);
109
    cue->setTrack(this);
110
109
111
    if (!m_cues)
110
    cue->setId(cueData->id());
112
        m_cues = TextTrackCueList::create();
111
    cue->setBaseFontSizeRelativeToVideoHeight(cueData->baseFontSize());
113
    m_cues->add(cue);
112
    cue->setFontSizeMultiplier(cueData->relativeFontSize());
114
    
113
    cue->setFontName(cueData->fontName());
115
    if (client())
114
116
        client()->textTrackAddCues(this, m_cues.get());
115
    ExceptionCode ec;
116
    if (cueData->position() > 0)
117
        cue->setPosition(lround(cueData->position()), ec);
118
    if (cueData->line() > 0)
119
        cue->setLine(lround(cueData->line()), ec);
120
    if (cueData->size() > 0)
121
        cue->setSize(lround(cueData->size()), ec);
122
    if (cueData->align() == GenericCueData::Start)
123
        cue->setAlign(ASCIILiteral("start"), ec);
124
    else if (cueData->align() == GenericCueData::Middle)
125
        cue->setAlign(ASCIILiteral("middle"), ec);
126
    else if (cueData->align() == GenericCueData::End)
127
        cue->setAlign(ASCIILiteral("end"), ec);
128
    cue->setSnapToLines(false);
129
130
    if (hasCue(cue.get())) {
131
        LOG(Media, "InbandTextTrack::addGenericCue ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n",
132
            cueData->startTime(), cueData->endTime(), cueData->content().utf8().data());
133
        return;
134
    }
135
136
    addCue(cue);
117
}
137
}
118
138
119
bool InbandTextTrack::hasCue(InbandTextTrackPrivate*, double startTime, double endTime, const String& id, const String& content, const String& settings)
139
void InbandTextTrack::addWebVTTCue(InbandTextTrackPrivate* trackPrivate, double start, double end, const String& id, const String& content, const String& settings)
120
{
140
{
141
    UNUSED_PARAM(trackPrivate);
142
    ASSERT(trackPrivate == m_private);
121
143
122
    if (startTime < 0 || endTime < 0)
144
    RefPtr<TextTrackCue> cue = TextTrackCue::create(scriptExecutionContext(), start, end, content);
123
        return false;
145
    cue->setId(id);
124
146
    cue->setCueSettings(settings);
125
    if (!cues()->length())
126
        return false;
127
128
    size_t searchStart = 0;
129
    size_t searchEnd = cues()->length();
130
131
    while (1) {
132
        ASSERT(searchStart <= cues()->length());
133
        ASSERT(searchEnd <= cues()->length());
134
        
135
        TextTrackCue* cue;
136
        
137
        // Cues in the TextTrackCueList are maintained in start time order.
138
        if (searchStart == searchEnd) {
139
            if (!searchStart)
140
                return false;
141
            
142
            cue = cues()->item(searchStart - 1);
143
            if (!cue)
144
                return false;
145
            if (cue->startTime() != startTime)
146
                return false;
147
            if (cue->endTime() != endTime)
148
                return false;
149
            if (cue->text() != content)
150
                return false;
151
            if (cue->cueSettings() != settings)
152
                return false;
153
            if (cue->id() != id)
154
                return false;
155
            
156
            return true;
157
        }
158
        
159
        size_t index = (searchStart + searchEnd) / 2;
160
        cue = cues()->item(index);
161
        if (startTime < cue->startTime() || (startTime == cue->startTime() && endTime > cue->endTime()))
162
            searchEnd = index;
163
        else
164
            searchStart = index + 1;
165
    }
166
    
147
    
167
    ASSERT_NOT_REACHED();
148
    if (hasCue(cue.get()))
168
    return false;
149
        return;
150
151
    addCue(cue);
169
}
152
}
170
153
171
} // namespace WebCore
154
} // namespace WebCore
- Source/WebCore/html/track/InbandTextTrack.h -3 / +3 lines
Lines 1-5 Source/WebCore/html/track/InbandTextTrack.h_sec1
1
/*
1
/*
2
 * Copyright (C) 2012 Apple Inc. All rights reserved.
2
 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 51-58 public: Source/WebCore/html/track/InbandTextTrack.h_sec2
51
private:
51
private:
52
    InbandTextTrack(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>);
52
    InbandTextTrack(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>);
53
53
54
    virtual void addCue(InbandTextTrackPrivate*, double, double, const String&, const String&, const String&) OVERRIDE;
54
    virtual void addGenericCue(InbandTextTrackPrivate*, GenericCueData*) OVERRIDE;
55
    virtual bool hasCue(InbandTextTrackPrivate*, double, double, const String&, const String&, const String&) OVERRIDE;
55
    virtual void addWebVTTCue(InbandTextTrackPrivate*, double, double, const String&, const String&, const String&) OVERRIDE;
56
56
57
    RefPtr<InbandTextTrackPrivate> m_private;
57
    RefPtr<InbandTextTrackPrivate> m_private;
58
};
58
};
- Source/WebCore/html/track/TextTrack.cpp -1 / +59 lines
Lines 1-6 Source/WebCore/html/track/TextTrack.cpp_sec1
1
/*
1
/*
2
 * Copyright (C) 2011 Google Inc.  All rights reserved.
2
 * Copyright (C) 2011 Google Inc.  All rights reserved.
3
 * Copyright (C) 2011 Apple Inc.  All rights reserved.
3
 * Copyright (C) 2011, 2012, 2013 Apple Inc.  All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are
6
 * modification, are permitted provided that the following conditions are
Lines 339-344 int TextTrack::trackIndexRelativeToRende Source/WebCore/html/track/TextTrack.cpp_sec2
339
    return m_renderedTrackIndex;
339
    return m_renderedTrackIndex;
340
}
340
}
341
341
342
bool TextTrack::hasCue(TextTrackCue* cue)
343
{
344
    if (cue->startTime() < 0 || cue->endTime() < 0)
345
        return false;
346
    
347
    if (!m_cues || !m_cues->length())
348
        return false;
349
    
350
    size_t searchStart = 0;
351
    size_t searchEnd = m_cues->length();
352
    
353
    while (1) {
354
        ASSERT(searchStart <= m_cues->length());
355
        ASSERT(searchEnd <= m_cues->length());
356
        
357
        TextTrackCue* existingCue;
358
        
359
        // Cues in the TextTrackCueList are maintained in start time order.
360
        if (searchStart == searchEnd) {
361
            if (!searchStart)
362
                return false;
363
364
            // If there is more than one cue with the same start time, back up to first one so we
365
            // consider all of them.
366
            while (searchStart >= 2 && cue->startTime() == m_cues->item(searchStart - 2)->startTime())
367
                --searchStart;
368
            
369
            bool firstCompare = true;
370
            while (1) {
371
                if (!firstCompare)
372
                    ++searchStart;
373
                firstCompare = false;
374
                if (searchStart > m_cues->length())
375
                    return false;
376
377
                existingCue = m_cues->item(searchStart - 1);
378
                if (!existingCue || cue->startTime() > existingCue->startTime())
379
                    return false;
380
381
                if (*existingCue != *cue)
382
                    continue;
383
                
384
                return true;
385
            }
386
        }
387
        
388
        size_t index = (searchStart + searchEnd) / 2;
389
        existingCue = m_cues->item(index);
390
        if (cue->startTime() < existingCue->startTime() || (cue->startTime() == existingCue->startTime() && cue->endTime() > existingCue->endTime()))
391
            searchEnd = index;
392
        else
393
            searchStart = index + 1;
394
    }
395
    
396
    ASSERT_NOT_REACHED();
397
    return false;
398
}
399
342
} // namespace WebCore
400
} // namespace WebCore
343
401
344
#endif
402
#endif
- Source/WebCore/html/track/TextTrack.h -1 / +2 lines
Lines 1-6 Source/WebCore/html/track/TextTrack.h_sec1
1
/*
1
/*
2
 * Copyright (C) 2011 Google Inc. All rights reserved.
2
 * Copyright (C) 2011 Google Inc. All rights reserved.
3
 * Copyright (C) 2011, 2012 Apple Inc.  All rights reserved.
3
 * Copyright (C) 2011, 2012, 2013 Apple Inc.  All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
Lines 99-104 public: Source/WebCore/html/track/TextTrack.h_sec2
99
99
100
    void addCue(PassRefPtr<TextTrackCue>);
100
    void addCue(PassRefPtr<TextTrackCue>);
101
    void removeCue(TextTrackCue*, ExceptionCode&);
101
    void removeCue(TextTrackCue*, ExceptionCode&);
102
    bool hasCue(TextTrackCue*);
102
103
103
    void cueWillChange(TextTrackCue*);
104
    void cueWillChange(TextTrackCue*);
104
    void cueDidChange(TextTrackCue*);
105
    void cueDidChange(TextTrackCue*);
- Source/WebCore/html/track/TextTrackCue.cpp -13 / +51 lines
Lines 1-6 Source/WebCore/html/track/TextTrackCue.cpp_sec1
1
/*
1
/*
2
 * Copyright (C) 2011 Google Inc.  All rights reserved.
2
 * Copyright (C) 2011 Google Inc.  All rights reserved.
3
 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
3
 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are
6
 * modification, are permitted provided that the following conditions are
Lines 107-113 TextTrackCue* TextTrackCueBox::getCue() Source/WebCore/html/track/TextTrackCue.cpp_sec2
107
    return m_cue;
107
    return m_cue;
108
}
108
}
109
109
110
void TextTrackCueBox::applyCSSProperties()
110
void TextTrackCueBox::applyCSSProperties(const IntSize&)
111
{
111
{
112
    // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79916
112
    // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79916
113
113
Lines 210-216 TextTrackCue::TextTrackCue(ScriptExecuti Source/WebCore/html/track/TextTrackCue.cpp_sec3
210
    , m_snapToLines(true)
210
    , m_snapToLines(true)
211
    , m_allDocumentNodes(HTMLDivElement::create(static_cast<Document*>(context)))
211
    , m_allDocumentNodes(HTMLDivElement::create(static_cast<Document*>(context)))
212
    , m_displayTreeShouldChange(true)
212
    , m_displayTreeShouldChange(true)
213
    , m_displayTree(TextTrackCueBox::create(static_cast<Document*>(m_scriptExecutionContext), this))
214
{
213
{
215
    ASSERT(m_scriptExecutionContext->isDocument());
214
    ASSERT(m_scriptExecutionContext->isDocument());
216
215
Lines 228-233 TextTrackCue::~TextTrackCue() Source/WebCore/html/track/TextTrackCue.cpp_sec4
228
{
227
{
229
}
228
}
230
229
230
PassRefPtr<TextTrackCueBox> TextTrackCue::createDisplayTree()
231
{
232
    return TextTrackCueBox::create(ownerDocument(), this);
233
}
234
235
PassRefPtr<TextTrackCueBox> TextTrackCue::displayTreeInternal()
236
{
237
    if (!m_displayTree)
238
        m_displayTree = createDisplayTree();
239
    return m_displayTree;
240
}
241
231
void TextTrackCue::cueWillChange()
242
void TextTrackCue::cueWillChange()
232
{
243
{
233
    if (m_track)
244
    if (m_track)
Lines 438-444 void TextTrackCue::setAlign(const String Source/WebCore/html/track/TextTrackCue.cpp_sec5
438
    // match for the new value, if any. If none of the values match, then the user
449
    // match for the new value, if any. If none of the values match, then the user
439
    // agent must instead throw a SyntaxError exception.
450
    // agent must instead throw a SyntaxError exception.
440
    
451
    
441
    Alignment alignment = m_cueAlignment;
452
    CueAlignment alignment = m_cueAlignment;
442
    if (value == startKeyword())
453
    if (value == startKeyword())
443
        alignment = Start;
454
        alignment = Start;
444
    else if (value == middleKeyword())
455
    else if (value == middleKeyword())
Lines 545-552 void TextTrackCue::setIsActive(bool acti Source/WebCore/html/track/TextTrackCue.cpp_sec6
545
556
546
    if (!active) {
557
    if (!active) {
547
        // Remove the display tree as soon as the cue becomes inactive.
558
        // Remove the display tree as soon as the cue becomes inactive.
548
        ExceptionCode ec;
559
        displayTreeInternal()->remove(ASSERT_NO_EXCEPTION);
549
        m_displayTree->remove(ec);
550
    }
560
    }
551
}
561
}
552
562
Lines 722-731 void TextTrackCue::updateDisplayTree(flo Source/WebCore/html/track/TextTrackCue.cpp_sec7
722
    m_allDocumentNodes->appendChild(referenceTree);
732
    m_allDocumentNodes->appendChild(referenceTree);
723
}
733
}
724
734
725
PassRefPtr<TextTrackCueBox> TextTrackCue::getDisplayTree()
735
PassRefPtr<TextTrackCueBox> TextTrackCue::getDisplayTree(const IntSize& videoSize)
726
{
736
{
737
    RefPtr<TextTrackCueBox> displayTree = displayTreeInternal();
727
    if (!m_displayTreeShouldChange || !track()->isRendered())
738
    if (!m_displayTreeShouldChange || !track()->isRendered())
728
        return m_displayTree;
739
        return displayTree;
729
740
730
    // 10.1 - 10.10
741
    // 10.1 - 10.10
731
    calculateDisplayParameters();
742
    calculateDisplayParameters();
Lines 733-739 PassRefPtr<TextTrackCueBox> TextTrackCue Source/WebCore/html/track/TextTrackCue.cpp_sec8
733
    // 10.11. Apply the terms of the CSS specifications to nodes within the
744
    // 10.11. Apply the terms of the CSS specifications to nodes within the
734
    // following constraints, thus obtaining a set of CSS boxes positioned
745
    // following constraints, thus obtaining a set of CSS boxes positioned
735
    // relative to an initial containing block:
746
    // relative to an initial containing block:
736
    m_displayTree->removeChildren();
747
    displayTree->removeChildren();
737
748
738
    // The document tree is the tree of WebVTT Node Objects rooted at nodes.
749
    // The document tree is the tree of WebVTT Node Objects rooted at nodes.
739
750
Lines 743-749 PassRefPtr<TextTrackCueBox> TextTrackCue Source/WebCore/html/track/TextTrackCue.cpp_sec9
743
754
744
    // Note: This is contained by default in m_allDocumentNodes.
755
    // Note: This is contained by default in m_allDocumentNodes.
745
    m_allDocumentNodes->setPseudo(allNodesShadowPseudoId());
756
    m_allDocumentNodes->setPseudo(allNodesShadowPseudoId());
746
    m_displayTree->appendChild(m_allDocumentNodes, ASSERT_NO_EXCEPTION, true);
757
    displayTree->appendChild(m_allDocumentNodes, ASSERT_NO_EXCEPTION, true);
747
758
748
    // FIXME(BUG 79916): Runs of children of WebVTT Ruby Objects that are not
759
    // FIXME(BUG 79916): Runs of children of WebVTT Ruby Objects that are not
749
    // WebVTT Ruby Text Objects must be wrapped in anonymous boxes whose
760
    // WebVTT Ruby Text Objects must be wrapped in anonymous boxes whose
Lines 756-773 PassRefPtr<TextTrackCueBox> TextTrackCue Source/WebCore/html/track/TextTrackCue.cpp_sec10
756
    // is no line breaking opportunity. (Thus, normally text wraps as needed,
767
    // is no line breaking opportunity. (Thus, normally text wraps as needed,
757
    // but if there is a particularly long word, it does not overflow as it
768
    // but if there is a particularly long word, it does not overflow as it
758
    // normally would in CSS, it is instead forcibly wrapped at the box's edge.)
769
    // normally would in CSS, it is instead forcibly wrapped at the box's edge.)
759
    m_displayTree->applyCSSProperties();
770
    displayTree->applyCSSProperties(videoSize);
760
771
761
    m_displayTreeShouldChange = false;
772
    m_displayTreeShouldChange = false;
762
773
763
    // 10.15. Let cue's text track cue display state have the CSS boxes in
774
    // 10.15. Let cue's text track cue display state have the CSS boxes in
764
    // boxes.
775
    // boxes.
765
    return m_displayTree;
776
    return displayTree;
766
}
777
}
767
778
768
void TextTrackCue::removeDisplayTree()
779
void TextTrackCue::removeDisplayTree()
769
{
780
{
770
    m_displayTree->remove(ASSERT_NO_EXCEPTION);
781
    displayTreeInternal()->remove(ASSERT_NO_EXCEPTION);
771
}
782
}
772
783
773
std::pair<double, double> TextTrackCue::getPositionCoordinates() const
784
std::pair<double, double> TextTrackCue::getPositionCoordinates() const
Lines 1066-1071 EventTargetData* TextTrackCue::ensureEve Source/WebCore/html/track/TextTrackCue.cpp_sec11
1066
    return &m_eventTargetData;
1077
    return &m_eventTargetData;
1067
}
1078
}
1068
1079
1080
bool TextTrackCue::operator==(const TextTrackCue& cue) const
1081
{
1082
    if (cueType() != cue.cueType())
1083
        return false;
1084
1085
    if (m_endTime != cue.endTime())
1086
        return false;
1087
    if (m_startTime != cue.startTime())
1088
        return false;
1089
    if (m_content != cue.text())
1090
        return false;
1091
    if (m_settings != cue.cueSettings())
1092
        return false;
1093
    if (m_id != cue.id())
1094
        return false;
1095
    if (m_textPosition != cue.position())
1096
        return false;
1097
    if (m_linePosition != cue.line())
1098
        return false;
1099
    if (m_cueSize != cue.size())
1100
        return false;
1101
    if (align() != cue.align())
1102
        return false;
1103
    
1104
    return true;
1105
}
1106
1069
} // namespace WebCore
1107
} // namespace WebCore
1070
1108
1071
#endif
1109
#endif
- Source/WebCore/html/track/TextTrackCue.h -9 / +33 lines
Lines 1-5 Source/WebCore/html/track/TextTrackCue.h_sec1
1
/*
1
/*
2
 * Copyright (C) 2011 Google Inc.  All rights reserved.
2
 * Copyright (C) 2011 Google Inc.  All rights reserved.
3
 * Copyright (C) 2012, 2013 Apple Inc.  All rights reserved.
3
 *
4
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions are
6
 * modification, are permitted provided that the following conditions are
Lines 57-67 public: Source/WebCore/html/track/TextTrackCue.h_sec2
57
    }
58
    }
58
59
59
    TextTrackCue* getCue() const;
60
    TextTrackCue* getCue() const;
60
    void applyCSSProperties();
61
    virtual void applyCSSProperties(const IntSize& videoSize);
61
62
62
    static const AtomicString& textTrackCueBoxShadowPseudoId();
63
    static const AtomicString& textTrackCueBoxShadowPseudoId();
63
64
64
private:
65
protected:
65
    TextTrackCueBox(Document*, TextTrackCue*);
66
    TextTrackCueBox(Document*, TextTrackCue*);
66
67
67
    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE;
68
    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE;
Lines 122-134 public: Source/WebCore/html/track/TextTrackCue.h_sec3
122
    void setSnapToLines(bool);
123
    void setSnapToLines(bool);
123
124
124
    int line() const { return m_linePosition; }
125
    int line() const { return m_linePosition; }
125
    void setLine(int, ExceptionCode&);
126
    virtual void setLine(int, ExceptionCode&);
126
127
127
    int position() const { return m_textPosition; }
128
    int position() const { return m_textPosition; }
128
    void setPosition(int, ExceptionCode&);
129
    virtual void setPosition(int, ExceptionCode&);
129
130
130
    int size() const { return m_cueSize; }
131
    int size() const { return m_cueSize; }
131
    void setSize(int, ExceptionCode&);
132
    virtual void setSize(int, ExceptionCode&);
132
133
133
    const String& align() const;
134
    const String& align() const;
134
    void setAlign(const String&, ExceptionCode&);
135
    void setAlign(const String&, ExceptionCode&);
Lines 151-157 public: Source/WebCore/html/track/TextTrackCue.h_sec4
151
    bool isActive();
152
    bool isActive();
152
    void setIsActive(bool);
153
    void setIsActive(bool);
153
154
154
    PassRefPtr<TextTrackCueBox> getDisplayTree();
155
    PassRefPtr<TextTrackCueBox> getDisplayTree(const IntSize& videoSize);
155
    void updateDisplayTree(float);
156
    void updateDisplayTree(float);
156
    void removeDisplayTree();
157
    void removeDisplayTree();
157
    void markFutureAndPastNodes(ContainerNode*, double, double);
158
    void markFutureAndPastNodes(ContainerNode*, double, double);
Lines 173-178 public: Source/WebCore/html/track/TextTrackCue.h_sec5
173
    };
174
    };
174
    WritingDirection getWritingDirection() const { return m_writingDirection; }
175
    WritingDirection getWritingDirection() const { return m_writingDirection; }
175
176
177
    enum CueAlignment {
178
        Start,
179
        Middle,
180
        End
181
    };
182
    CueAlignment getAlignment() const { return m_cueAlignment; }
183
184
    virtual bool operator==(const TextTrackCue&) const;
185
    virtual bool operator!=(const TextTrackCue& cue) const
186
    {
187
        return !(*this == cue);
188
    }
189
    
190
    enum CueType {
191
        Generic,
192
        WebVTT
193
    };
194
    virtual CueType cueType() const { return WebVTT; }
195
176
    DEFINE_ATTRIBUTE_EVENT_LISTENER(enter);
196
    DEFINE_ATTRIBUTE_EVENT_LISTENER(enter);
177
    DEFINE_ATTRIBUTE_EVENT_LISTENER(exit);
197
    DEFINE_ATTRIBUTE_EVENT_LISTENER(exit);
178
198
Lines 183-191 protected: Source/WebCore/html/track/TextTrackCue.h_sec6
183
    virtual EventTargetData* eventTargetData();
203
    virtual EventTargetData* eventTargetData();
184
    virtual EventTargetData* ensureEventTargetData();
204
    virtual EventTargetData* ensureEventTargetData();
185
205
186
private:
187
    TextTrackCue(ScriptExecutionContext*, double start, double end, const String& content);
206
    TextTrackCue(ScriptExecutionContext*, double start, double end, const String& content);
188
207
208
    Document* ownerDocument() { return static_cast<Document*>(m_scriptExecutionContext); }
209
210
    virtual PassRefPtr<TextTrackCueBox> createDisplayTree();
211
    PassRefPtr<TextTrackCueBox> displayTreeInternal();
212
213
private:
189
    std::pair<double, double> getPositionCoordinates() const;
214
    std::pair<double, double> getPositionCoordinates() const;
190
    void parseSettings(const String&);
215
    void parseSettings(const String&);
191
216
Lines 213-220 private: Source/WebCore/html/track/TextTrackCue.h_sec7
213
238
214
    WritingDirection m_writingDirection;
239
    WritingDirection m_writingDirection;
215
240
216
    enum Alignment { Start, Middle, End };
241
    CueAlignment m_cueAlignment;
217
    Alignment m_cueAlignment;
218
242
219
    RefPtr<DocumentFragment> m_webVTTNodeTree;
243
    RefPtr<DocumentFragment> m_webVTTNodeTree;
220
    TextTrack* m_track;
244
    TextTrack* m_track;
- Source/WebCore/html/track/TextTrackCueGeneric.cpp +150 lines
Line 0 Source/WebCore/html/track/TextTrackCueGeneric.cpp_sec1
1
/*
2
 * Copyright (C) 2013 Apple 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
#include "config.h"
27
28
#if ENABLE(VIDEO_TRACK)
29
30
#include "TextTrackCueGeneric.h"
31
32
#include "CSSPropertyNames.h"
33
#include "CSSValueKeywords.h"
34
#include "HTMLDivElement.h"
35
#include "HTMLNames.h"
36
#include "InbandTextTrackPrivateClient.h"
37
#include "RenderObject.h"
38
#include "RenderTextTrackCue.h"
39
#include "ScriptExecutionContext.h"
40
#include "TextTrackCue.h"
41
42
namespace WebCore {
43
44
class TextTrackCueGenericBoxElement : public TextTrackCueBox {
45
public:
46
    static PassRefPtr<TextTrackCueGenericBoxElement> create(Document* document, TextTrackCueGeneric* cue)
47
    {
48
        return adoptRef(new TextTrackCueGenericBoxElement(document, cue));
49
    }
50
    
51
    virtual void applyCSSProperties(const IntSize&) OVERRIDE;
52
    
53
private:
54
    TextTrackCueGenericBoxElement(Document*, TextTrackCue*);
55
};
56
57
TextTrackCueGenericBoxElement::TextTrackCueGenericBoxElement(Document* document, TextTrackCue* cue)
58
    : TextTrackCueBox(document, cue)
59
{
60
}
61
62
void TextTrackCueGenericBoxElement::applyCSSProperties(const IntSize& videoSize)
63
{
64
    setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
65
    setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueWebkitPlaintext);
66
    
67
    TextTrackCueGeneric* cue = static_cast<TextTrackCueGeneric*>(getCue());
68
69
    if (cue->useDefaultPosition()) {
70
        setInlineStyleProperty(CSSPropertyBottom, "0");
71
        setInlineStyleProperty(CSSPropertyMarginBottom, 1.0, CSSPrimitiveValue::CSS_PERCENTAGE);
72
    } else {
73
        setInlineStyleProperty(CSSPropertyLeft, static_cast<float>(cue->position()), CSSPrimitiveValue::CSS_PERCENTAGE);
74
        setInlineStyleProperty(CSSPropertyTop, static_cast<float>(cue->line()), CSSPrimitiveValue::CSS_PERCENTAGE);
75
    }
76
77
    float size = static_cast<float>(cue->getCSSSize());
78
    if (cue->getWritingDirection() == TextTrackCue::Horizontal) {
79
        setInlineStyleProperty(CSSPropertyDirection, CSSValueLtr);
80
        setInlineStyleProperty(CSSPropertyWidth, size, CSSPrimitiveValue::CSS_PERCENTAGE);
81
        setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto);
82
    } else {
83
        setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto);
84
        setInlineStyleProperty(CSSPropertyHeight, size,  CSSPrimitiveValue::CSS_PERCENTAGE);
85
    }
86
87
    if (cue->baseFontSizeRelativeToVideoHeight()) {
88
        double fontSize = videoSize.height() * cue->baseFontSizeRelativeToVideoHeight() / 100;
89
        if (cue->fontSizeMultiplier())
90
            fontSize *= cue->fontSizeMultiplier() / 100;
91
        setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
92
    }
93
94
    if (cue->getAlignment() == TextTrackCue::Start)
95
        setInlineStyleProperty(CSSPropertyTextAlign, CSSValueStart);
96
    else if (cue->getAlignment() == TextTrackCue::End)
97
        setInlineStyleProperty(CSSPropertyTextAlign, CSSValueEnd);
98
    else
99
        setInlineStyleProperty(CSSPropertyTextAlign, CSSValueCenter);
100
101
    setInlineStyleProperty(CSSPropertyWebkitWritingMode, cue->getCSSWritingMode(), false);
102
    setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePreWrap);
103
    setInlineStyleProperty(CSSPropertyWordBreak, CSSValueNormal);
104
}
105
106
TextTrackCueGeneric::TextTrackCueGeneric(ScriptExecutionContext* context, double start, double end, const String& content)
107
    : TextTrackCue(context, start, end, content)
108
    , m_baseFontSizeRelativeToVideoHeight(0)
109
    , m_fontSizeMultiplier(0)
110
    , m_defaultPosition(true)
111
{
112
}
113
114
PassRefPtr<TextTrackCueBox> TextTrackCueGeneric::createDisplayTree()
115
{
116
    return TextTrackCueGenericBoxElement::create(ownerDocument(), this);
117
}
118
119
void TextTrackCueGeneric::setLine(int line, ExceptionCode& ec)
120
{
121
    m_defaultPosition = false;
122
    TextTrackCue::setLine(line, ec);
123
}
124
125
void TextTrackCueGeneric::setPosition(int position, ExceptionCode& ec)
126
{
127
    m_defaultPosition = false;
128
    TextTrackCue::setPosition(position, ec);
129
}
130
131
bool TextTrackCueGeneric::operator==(const TextTrackCue& cue) const
132
{
133
    if (cue.cueType() != TextTrackCue::Generic)
134
        return false;
135
136
    const TextTrackCueGeneric* other = static_cast<const TextTrackCueGeneric*>(&cue);
137
138
    if (m_baseFontSizeRelativeToVideoHeight != other->baseFontSizeRelativeToVideoHeight())
139
        return false;
140
    if (m_fontSizeMultiplier != other->fontSizeMultiplier())
141
        return false;
142
    if (m_fontName != other->fontName())
143
        return false;
144
145
    return TextTrackCue::operator==(cue);
146
}
147
    
148
} // namespace WebCore
149
150
#endif
- Source/WebCore/html/track/TextTrackCueGeneric.h +85 lines
Line 0 Source/WebCore/html/track/TextTrackCueGeneric.h_sec1
1
/*
2
 * Copyright (C) 2013 Apple 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
#ifndef TextTrackCueGeneric_h
27
#define TextTrackCueGeneric_h
28
29
#if ENABLE(VIDEO_TRACK)
30
31
#include "HTMLElement.h"
32
#include "TextTrackCue.h"
33
#include <wtf/RefCounted.h>
34
35
namespace WebCore {
36
37
class GenericCueData;
38
39
// A "generic" cue is a non-WebVTT cue, so it is not positioned/sized with the WebVTT logic.
40
class TextTrackCueGeneric : public TextTrackCue {
41
public:
42
    static PassRefPtr<TextTrackCueGeneric> create(ScriptExecutionContext* context, double start, double end, const String& content)
43
    {
44
        return adoptRef(new TextTrackCueGeneric(context, start, end, content));
45
    }
46
    
47
    virtual ~TextTrackCueGeneric() { }
48
49
    virtual PassRefPtr<TextTrackCueBox> createDisplayTree() OVERRIDE;
50
51
    virtual void setLine(int, ExceptionCode&) OVERRIDE;
52
    virtual void setPosition(int, ExceptionCode&) OVERRIDE;
53
54
    bool useDefaultPosition() const { return m_defaultPosition; }
55
    
56
    double baseFontSizeRelativeToVideoHeight() const { return m_baseFontSizeRelativeToVideoHeight; }
57
    void setBaseFontSizeRelativeToVideoHeight(double size) { m_baseFontSizeRelativeToVideoHeight = size; }
58
59
    double fontSizeMultiplier() const { return m_fontSizeMultiplier; }
60
    void setFontSizeMultiplier(double size) { m_fontSizeMultiplier = size; }
61
62
    String fontName() const { return m_fontName; }
63
    void setFontName(String name) { m_fontName = name; }
64
65
    virtual bool operator==(const TextTrackCue&) const OVERRIDE;
66
    virtual bool operator!=(const TextTrackCue& cue) const OVERRIDE
67
    {
68
        return !(*this == cue);
69
    }
70
71
    virtual TextTrackCue::CueType cueType() const OVERRIDE { return TextTrackCue::Generic; }
72
73
private:
74
    TextTrackCueGeneric(ScriptExecutionContext*, double start, double end, const String&);
75
    
76
    double m_baseFontSizeRelativeToVideoHeight;
77
    double m_fontSizeMultiplier;
78
    String m_fontName;
79
    bool m_defaultPosition;
80
};
81
82
} // namespace WebCore
83
84
#endif
85
#endif
- Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h -3 / +74 lines
Lines 1-5 Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h_sec1
1
/*
1
/*
2
 * Copyright (C) 2012 Apple Inc. All rights reserved.
2
 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 26-31 Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h_sec2
26
#ifndef InbandTextTrackPrivateClient_h
26
#ifndef InbandTextTrackPrivateClient_h
27
#define InbandTextTrackPrivateClient_h
27
#define InbandTextTrackPrivateClient_h
28
28
29
#include <wtf/Noncopyable.h>
29
#include <wtf/text/WTFString.h>
30
#include <wtf/text/WTFString.h>
30
31
31
#if ENABLE(VIDEO_TRACK)
32
#if ENABLE(VIDEO_TRACK)
Lines 34-45 namespace WebCore { Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h_sec3
34
35
35
class InbandTextTrackPrivate;
36
class InbandTextTrackPrivate;
36
37
38
class GenericCueData {
39
    WTF_MAKE_NONCOPYABLE(GenericCueData); WTF_MAKE_FAST_ALLOCATED;
40
public:
41
    GenericCueData()
42
        : m_startTime(0)
43
        , m_endTime(0)
44
        , m_line(-1)
45
        , m_position(-1)
46
        , m_size(-1)
47
        , m_align(None)
48
        , m_baseFontSize(0)
49
        , m_relativeFontSize(0)
50
    {
51
    }
52
    virtual ~GenericCueData() { }
53
54
    double startTime() const { return m_startTime; }
55
    void setStartTime(double startTime) { m_startTime = startTime; }
56
57
    double endTime() const { return m_endTime; }
58
    void setEndTime(double endTime) { m_endTime = endTime; }
59
60
    String id() const { return m_id; }
61
    void setId(String id) { m_id = id; }
62
63
    String content() const { return m_content; }
64
    void setContent(String content) { m_content = content; }
65
66
    double line() const { return m_line; }
67
    void setLine(double line) { m_line = line; }
68
69
    double position() const { return m_position; }
70
    void setPosition(double position) { m_position = position; }
71
72
    double size() const { return m_size; }
73
    void setSize(double size) { m_size = size; }
74
75
    enum Alignment {
76
        None,
77
        Start,
78
        Middle,
79
        End
80
    };
81
    Alignment align() const { return m_align; }
82
    void setAlign(Alignment align) { m_align = align; }
83
84
    String fontName() const { return m_fontName; }
85
    void setFontName(String fontName) { m_fontName = fontName; }
86
87
    double baseFontSize() const { return m_baseFontSize; }
88
    void setBaseFontSize(double baseFontSize) { m_baseFontSize = baseFontSize; }
89
90
    double relativeFontSize() const { return m_relativeFontSize; }
91
    void setRelativeFontSize(double relativeFontSize) { m_relativeFontSize = relativeFontSize; }
92
    
93
private:
94
95
    double m_startTime;
96
    double m_endTime;
97
    String m_id;
98
    String m_content;
99
    double m_line;
100
    double m_position;
101
    double m_size;
102
    Alignment m_align;
103
    String m_fontName;
104
    double m_baseFontSize;
105
    double m_relativeFontSize;
106
};
107
37
class InbandTextTrackPrivateClient {
108
class InbandTextTrackPrivateClient {
38
public:
109
public:
39
    virtual ~InbandTextTrackPrivateClient() { }
110
    virtual ~InbandTextTrackPrivateClient() { }
40
    
111
    
41
    virtual void addCue(InbandTextTrackPrivate*, double /*start*/, double /*end*/, const String& /*id*/, const String& /*content*/, const String& /*settings*/) = 0;
112
    virtual void addWebVTTCue(InbandTextTrackPrivate*, double /*start*/, double /*end*/, const String& /*id*/, const String& /*content*/, const String& /*settings*/) = 0;
42
    virtual bool hasCue(InbandTextTrackPrivate*, double /*start*/, double /*end*/, const String& /*id*/, const String& /*content*/, const String& /*settings*/) = 0;
113
    virtual void addGenericCue(InbandTextTrackPrivate*, GenericCueData*) = 0;
43
};
114
};
44
115
45
} // namespace WebCore
116
} // namespace WebCore
- Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp -29 / +108 lines
Lines 1-5 Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec1
1
/*
1
/*
2
 * Copyright (C) 2012 Apple Inc. All rights reserved.
2
 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 29-34 Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec2
29
29
30
#include "InbandTextTrackPrivateAVF.h"
30
#include "InbandTextTrackPrivateAVF.h"
31
31
32
#include "InbandTextTrackPrivateClient.h"
32
#include "Logging.h"
33
#include "Logging.h"
33
#include "MediaPlayerPrivateAVFoundation.h"
34
#include "MediaPlayerPrivateAVFoundation.h"
34
#include "SoftLinking.h"
35
#include "SoftLinking.h"
Lines 36-41 Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec3
36
#include <wtf/UnusedParam.h>
37
#include <wtf/UnusedParam.h>
37
#include <wtf/text/CString.h>
38
#include <wtf/text/CString.h>
38
#include <wtf/text/WTFString.h>
39
#include <wtf/text/WTFString.h>
40
#include <wtf/unicode/CharacterNames.h>
39
41
40
SOFT_LINK_FRAMEWORK_OPTIONAL(CoreMedia)
42
SOFT_LINK_FRAMEWORK_OPTIONAL(CoreMedia)
41
43
Lines 52-57 SOFT_LINK_POINTER_OPTIONAL(CoreMedia, kC Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec4
52
SOFT_LINK_POINTER_OPTIONAL(CoreMedia, kCMTextMarkupAttribute_VerticalLayout, CFStringRef)
54
SOFT_LINK_POINTER_OPTIONAL(CoreMedia, kCMTextMarkupAttribute_VerticalLayout, CFStringRef)
53
SOFT_LINK_POINTER_OPTIONAL(CoreMedia, kCMTextVerticalLayout_LeftToRight, CFStringRef)
55
SOFT_LINK_POINTER_OPTIONAL(CoreMedia, kCMTextVerticalLayout_LeftToRight, CFStringRef)
54
SOFT_LINK_POINTER_OPTIONAL(CoreMedia, kCMTextVerticalLayout_RightToLeft, CFStringRef)
56
SOFT_LINK_POINTER_OPTIONAL(CoreMedia, kCMTextVerticalLayout_RightToLeft, CFStringRef)
57
SOFT_LINK_POINTER_OPTIONAL(CoreMedia, kCMTextMarkupAttribute_BaseFontSizePercentageRelativeToVideoHeight, CFStringRef)
58
SOFT_LINK_POINTER_OPTIONAL(CoreMedia, kCMTextMarkupAttribute_RelativeFontSize, CFStringRef)
59
SOFT_LINK_POINTER_OPTIONAL(CoreMedia, kCMTextMarkupAttribute_FontFamilyName, CFStringRef)
55
60
56
#define kCMTextMarkupAttribute_Alignment getkCMTextMarkupAttribute_Alignment()
61
#define kCMTextMarkupAttribute_Alignment getkCMTextMarkupAttribute_Alignment()
57
#define kCMTextMarkupAlignmentType_Start getkCMTextMarkupAlignmentType_Start()
62
#define kCMTextMarkupAlignmentType_Start getkCMTextMarkupAlignmentType_Start()
Lines 66-71 SOFT_LINK_POINTER_OPTIONAL(CoreMedia, kC Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec5
66
#define kCMTextMarkupAttribute_VerticalLayout getkCMTextMarkupAttribute_VerticalLayout()
71
#define kCMTextMarkupAttribute_VerticalLayout getkCMTextMarkupAttribute_VerticalLayout()
67
#define kCMTextVerticalLayout_LeftToRight getkCMTextVerticalLayout_LeftToRight()
72
#define kCMTextVerticalLayout_LeftToRight getkCMTextVerticalLayout_LeftToRight()
68
#define kCMTextVerticalLayout_RightToLeft getkCMTextVerticalLayout_RightToLeft()
73
#define kCMTextVerticalLayout_RightToLeft getkCMTextVerticalLayout_RightToLeft()
74
#define kCMTextMarkupAttribute_BaseFontSizePercentageRelativeToVideoHeight getkCMTextMarkupAttribute_BaseFontSizePercentageRelativeToVideoHeight()
75
#define kCMTextMarkupAttribute_RelativeFontSize getkCMTextMarkupAttribute_RelativeFontSize()
76
#define kCMTextMarkupAttribute_FontFamilyName getkCMTextMarkupAttribute_FontFamilyName()
69
77
70
using namespace std;
78
using namespace std;
71
79
Lines 84-90 InbandTextTrackPrivateAVF::~InbandTextTr Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec6
84
    disconnect();
92
    disconnect();
85
}
93
}
86
94
87
void InbandTextTrackPrivateAVF::processCueAttributes(CFAttributedStringRef attributedString, StringBuilder& content, StringBuilder& settings)
95
void InbandTextTrackPrivateAVF::processCueAttributes(CFAttributedStringRef attributedString, GenericCueData* cueData)
88
{
96
{
89
    // Some of the attributes we translate into per-cue WebVTT settings are are repeated on each part of an attributed string so only
97
    // Some of the attributes we translate into per-cue WebVTT settings are are repeated on each part of an attributed string so only
90
    // process the first instance of each.
98
    // process the first instance of each.
Lines 93-102 void InbandTextTrackPrivateAVF::processC Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec7
93
        Position = 1 << 1,
101
        Position = 1 << 1,
94
        Size = 1 << 2,
102
        Size = 1 << 2,
95
        Vertical = 1 << 3,
103
        Vertical = 1 << 3,
96
        Align = 1 << 4
104
        Align = 1 << 4,
105
        FontName = 1 << 5
97
    };
106
    };
98
    unsigned processed = 0;
107
    unsigned processed = 0;
99
108
109
    StringBuilder content;
100
    String attributedStringValue = CFAttributedStringGetString(attributedString);
110
    String attributedStringValue = CFAttributedStringGetString(attributedString);
101
    CFIndex length = attributedStringValue.length();
111
    CFIndex length = attributedStringValue.length();
102
    if (!length)
112
    if (!length)
Lines 110-115 void InbandTextTrackPrivateAVF::processC Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec8
110
            continue;
120
            continue;
111
121
112
        StringBuilder tagStart;
122
        StringBuilder tagStart;
123
        CFStringRef valueString;
113
        String tagEnd;
124
        String tagEnd;
114
        CFIndex attributeCount = CFDictionaryGetCount(attributes);
125
        CFIndex attributeCount = CFDictionaryGetCount(attributes);
115
        Vector<const void*> keys(attributeCount);
126
        Vector<const void*> keys(attributeCount);
Lines 123-129 void InbandTextTrackPrivateAVF::processC Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec9
123
                continue;
134
                continue;
124
135
125
            if (CFStringCompare(key, kCMTextMarkupAttribute_Alignment, 0) == kCFCompareEqualTo) {
136
            if (CFStringCompare(key, kCMTextMarkupAttribute_Alignment, 0) == kCFCompareEqualTo) {
126
                CFStringRef valueString = static_cast<CFStringRef>(value);
137
                valueString = static_cast<CFStringRef>(value);
127
                if (CFGetTypeID(valueString) != CFStringGetTypeID() || !CFStringGetLength(valueString))
138
                if (CFGetTypeID(valueString) != CFStringGetTypeID() || !CFStringGetLength(valueString))
128
                    continue;
139
                    continue;
129
                if (processed & Align)
140
                if (processed & Align)
Lines 131-141 void InbandTextTrackPrivateAVF::processC Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec10
131
                processed |= Align;
142
                processed |= Align;
132
143
133
                if (CFStringCompare(valueString, kCMTextMarkupAlignmentType_Start, 0) == kCFCompareEqualTo)
144
                if (CFStringCompare(valueString, kCMTextMarkupAlignmentType_Start, 0) == kCFCompareEqualTo)
134
                    settings.append("align:start ");
145
                    cueData->setAlign(GenericCueData::Start);
135
                else if (CFStringCompare(valueString, kCMTextMarkupAlignmentType_Middle, 0) == kCFCompareEqualTo)
146
                else if (CFStringCompare(valueString, kCMTextMarkupAlignmentType_Middle, 0) == kCFCompareEqualTo)
136
                    settings.append("align:middle ");
147
                    cueData->setAlign(GenericCueData::Middle);
137
                else if (CFStringCompare(valueString, kCMTextMarkupAlignmentType_End, 0) == kCFCompareEqualTo)
148
                else if (CFStringCompare(valueString, kCMTextMarkupAlignmentType_End, 0) == kCFCompareEqualTo)
138
                    settings.append("align:end ");
149
                    cueData->setAlign(GenericCueData::End);
139
                else
150
                else
140
                    ASSERT_NOT_REACHED();
151
                    ASSERT_NOT_REACHED();
141
152
Lines 170-178 void InbandTextTrackPrivateAVF::processC Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec11
170
            }
181
            }
171
182
172
            if (CFStringCompare(key, kCMTextMarkupAttribute_OrthogonalLinePositionPercentageRelativeToWritingDirection, 0) == kCFCompareEqualTo) {
183
            if (CFStringCompare(key, kCMTextMarkupAttribute_OrthogonalLinePositionPercentageRelativeToWritingDirection, 0) == kCFCompareEqualTo) {
173
                // Ignore the line position if the attributes also specify "size" so we keep WebVTT's default line logic
174
                if (CFDictionaryGetValue(attributes, kCMTextMarkupAttribute_WritingDirectionSizePercentage))
175
                    continue;
176
                if (CFGetTypeID(value) != CFNumberGetTypeID())
184
                if (CFGetTypeID(value) != CFNumberGetTypeID())
177
                    continue;
185
                    continue;
178
                if (processed & Line)
186
                if (processed & Line)
Lines 180-188 void InbandTextTrackPrivateAVF::processC Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec12
180
                processed |= Line;
188
                processed |= Line;
181
189
182
                CFNumberRef valueNumber = static_cast<CFNumberRef>(value);
190
                CFNumberRef valueNumber = static_cast<CFNumberRef>(value);
183
                double position;
191
                double line;
184
                CFNumberGetValue(valueNumber, kCFNumberFloat64Type, &position);
192
                CFNumberGetValue(valueNumber, kCFNumberFloat64Type, &line);
185
                settings.append(String::format("line:%ld%% ", lrint(position)));
193
                cueData->setLine(line);
186
                continue;
194
                continue;
187
            }
195
            }
188
196
Lines 196-202 void InbandTextTrackPrivateAVF::processC Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec13
196
                CFNumberRef valueNumber = static_cast<CFNumberRef>(value);
204
                CFNumberRef valueNumber = static_cast<CFNumberRef>(value);
197
                double position;
205
                double position;
198
                CFNumberGetValue(valueNumber, kCFNumberFloat64Type, &position);
206
                CFNumberGetValue(valueNumber, kCFNumberFloat64Type, &position);
199
                settings.append(String::format("position:%ld%% ", lrint(position)));
207
                cueData->setPosition(position);
200
                continue;
208
                continue;
201
            }
209
            }
202
210
Lines 208-223 void InbandTextTrackPrivateAVF::processC Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec14
208
                processed |= Size;
216
                processed |= Size;
209
217
210
                CFNumberRef valueNumber = static_cast<CFNumberRef>(value);
218
                CFNumberRef valueNumber = static_cast<CFNumberRef>(value);
211
                double position;
219
                double size;
212
                CFNumberGetValue(valueNumber, kCFNumberFloat64Type, &position);
220
                CFNumberGetValue(valueNumber, kCFNumberFloat64Type, &size);
213
                settings.append(String::format("size:%ld%% ", lrint(position)));
221
                cueData->setSize(size);
222
                continue;
223
            }
224
225
            if (CFStringCompare(key, kCMTextMarkupAttribute_VerticalLayout, 0) == kCFCompareEqualTo) {
226
                valueString = static_cast<CFStringRef>(value);
227
                if (CFGetTypeID(valueString) != CFStringGetTypeID() || !CFStringGetLength(valueString))
228
                    continue;
229
                
230
                if (CFStringCompare(valueString, kCMTextVerticalLayout_LeftToRight, 0) == kCFCompareEqualTo)
231
                    tagStart.append(leftToRightMark);
232
                else if (CFStringCompare(valueString, kCMTextVerticalLayout_RightToLeft, 0) == kCFCompareEqualTo)
233
                    tagStart.append(rightToLeftMark);
234
                continue;
235
            }
236
            
237
            if (CFStringCompare(key, kCMTextMarkupAttribute_BaseFontSizePercentageRelativeToVideoHeight, 0) == kCFCompareEqualTo) {
238
                if (CFGetTypeID(value) != CFNumberGetTypeID())
239
                    continue;
240
                
241
                CFNumberRef valueNumber = static_cast<CFNumberRef>(value);
242
                double baseFontSize;
243
                CFNumberGetValue(valueNumber, kCFNumberFloat64Type, &baseFontSize);
244
                cueData->setBaseFontSize(baseFontSize);
245
                continue;
246
            }
247
            
248
            if (CFStringCompare(key, kCMTextMarkupAttribute_RelativeFontSize, 0) == kCFCompareEqualTo) {
249
                if (CFGetTypeID(value) != CFNumberGetTypeID())
250
                    continue;
251
                
252
                CFNumberRef valueNumber = static_cast<CFNumberRef>(value);
253
                double relativeFontSize;
254
                CFNumberGetValue(valueNumber, kCFNumberFloat64Type, &relativeFontSize);
255
                cueData->setRelativeFontSize(relativeFontSize);
256
                continue;
257
            }
258
259
            if (CFStringCompare(key, kCMTextMarkupAttribute_FontFamilyName, 0) == kCFCompareEqualTo) {
260
                valueString = static_cast<CFStringRef>(value);
261
                if (CFGetTypeID(valueString) != CFStringGetTypeID() || !CFStringGetLength(valueString))
262
                    continue;
263
                if (processed & FontName)
264
                    continue;
265
                processed |= FontName;
266
                
267
                cueData->setFontName(valueString);
214
                continue;
268
                continue;
215
            }
269
            }
216
        }
270
        }
271
217
        content.append(tagStart);
272
        content.append(tagStart);
218
        content.append(attributedStringValue.substring(effectiveRange.location, effectiveRange.length));
273
        content.append(attributedStringValue.substring(effectiveRange.location, effectiveRange.length));
219
        content.append(tagEnd);
274
        content.append(tagEnd);
220
    }
275
    }
276
277
    if (content.length())
278
        cueData->setContent(content.toString());
221
}
279
}
222
280
223
void InbandTextTrackPrivateAVF::processCue(CFArrayRef attributedStrings, double time)
281
void InbandTextTrackPrivateAVF::processCue(CFArrayRef attributedStrings, double time)
Lines 228-248 void InbandTextTrackPrivateAVF::processC Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec15
228
    if (m_havePartialCue) {
286
    if (m_havePartialCue) {
229
        // Cues do not have an explicit duration, they are displayed until the next "cue" (which might be empty) is emitted.
287
        // Cues do not have an explicit duration, they are displayed until the next "cue" (which might be empty) is emitted.
230
        m_currentCueEndTime = time;
288
        m_currentCueEndTime = time;
231
        LOG(Media, "InbandTextTrackPrivateAVF::processCue flushing cue: start=%.2f, end=%.2f, settings=\"%s\", content=\"%s\" \n",
289
232
            m_currentCueStartTime, m_currentCueEndTime,
290
        if (m_currentCueEndTime >= m_currentCueStartTime) {
233
            m_currentCueSettings.toString().utf8().data(), m_currentCueContent.toString().utf8().data());
291
            for (size_t i = 0; i < m_cues.size(); i++) {
234
        m_player->flushCurrentCue(this);
292
293
                GenericCueData* cueData = m_cues[i].get();
294
295
                LOG(Media, "InbandTextTrackPrivateAVF::processCue flushing cue: start=%.2f, end=%.2f, content=\"%s\" \n",
296
                    m_currentCueStartTime, m_currentCueEndTime, cueData->content().utf8().data());
297
                
298
                if (!cueData->content().length())
299
                    continue;
300
                
301
                cueData->setStartTime(m_currentCueStartTime);
302
                cueData->setEndTime(m_currentCueEndTime);
303
                
304
                // AVFoundation cue "position" is to the center of the text so adjust relative to the edge because we will use it to
305
                // set CSS "left".
306
                if (cueData->position() >= 0 && cueData->size() > 0)
307
                    cueData->setPosition(cueData->position() - cueData->size() / 2);
308
                
309
                m_player->addGenericCue(this, cueData);
310
            }
311
        } else
312
            LOG(Media, "InbandTextTrackPrivateAVF::processCue negative length cue(s) ignored: start=%.2f, end=%.2f\n", m_currentCueStartTime, m_currentCueEndTime);
313
235
        resetCueValues();
314
        resetCueValues();
236
    }
315
    }
237
316
238
    CFIndex count = CFArrayGetCount(attributedStrings);
317
    CFIndex count = CFArrayGetCount(attributedStrings);
318
    if (!count)
319
        return;
320
239
    for (CFIndex i = 0; i < count; i++) {
321
    for (CFIndex i = 0; i < count; i++) {
240
        CFAttributedStringRef attributedString = static_cast<CFAttributedStringRef>(CFArrayGetValueAtIndex(attributedStrings, i));
322
        CFAttributedStringRef attributedString = static_cast<CFAttributedStringRef>(CFArrayGetValueAtIndex(attributedStrings, i));
241
323
242
        if (!attributedString || !CFAttributedStringGetLength(attributedString))
324
        if (!attributedString || !CFAttributedStringGetLength(attributedString))
243
            continue;
325
            continue;
244
326
245
        processCueAttributes(attributedString, m_currentCueContent, m_currentCueSettings);
327
        m_cues.append(adoptPtr(new GenericCueData));
328
        processCueAttributes(attributedString, m_cues[i].get());
246
        m_currentCueStartTime = time;
329
        m_currentCueStartTime = time;
247
        m_havePartialCue = true;
330
        m_havePartialCue = true;
248
    }
331
    }
Lines 256-272 void InbandTextTrackPrivateAVF::disconne Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp_sec16
256
339
257
void InbandTextTrackPrivateAVF::resetCueValues()
340
void InbandTextTrackPrivateAVF::resetCueValues()
258
{
341
{
259
    if (m_havePartialCue && !m_currentCueEndTime) {
342
    if (m_havePartialCue && !m_currentCueEndTime)
260
        LOG(Media, "InbandTextTrackPrivateAVF::resetCueValues flushing data for cue: start=%.2f, end=%.2f, settings=\"%s\", content=\"%s\" \n",
343
        LOG(Media, "InbandTextTrackPrivateAVF::resetCueValues flushing data for cues: start=%.2f\n", m_currentCueStartTime);
261
            m_currentCueStartTime, m_currentCueEndTime, m_currentCueSettings.toString().utf8().data(), m_currentCueContent.toString().utf8().data());
262
    }
263
344
345
    m_cues.resize(0);
264
    m_havePartialCue = false;
346
    m_havePartialCue = false;
265
    m_currentCueId = String();
266
    m_currentCueStartTime = 0;
347
    m_currentCueStartTime = 0;
267
    m_currentCueEndTime = 0;
348
    m_currentCueEndTime = 0;
268
    m_currentCueSettings.clear();
269
    m_currentCueContent.clear();
270
}
349
}
271
350
272
void InbandTextTrackPrivateAVF::setMode(InbandTextTrackPrivate::Mode newMode)
351
void InbandTextTrackPrivateAVF::setMode(InbandTextTrackPrivate::Mode newMode)
- Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h -15 / +9 lines
Lines 1-5 Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h_sec1
1
/*
1
/*
2
 * Copyright (C) 2012 Apple Inc. All rights reserved.
2
 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 35-54 Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h_sec2
35
namespace WebCore {
35
namespace WebCore {
36
36
37
class MediaPlayerPrivateAVFoundation;
37
class MediaPlayerPrivateAVFoundation;
38
class GenericCueData;
38
39
39
class InbandTextTrackPrivateAVF : public InbandTextTrackPrivate {
40
class InbandTextTrackPrivateAVF : public InbandTextTrackPrivate {
40
public:
41
public:
41
    ~InbandTextTrackPrivateAVF();
42
43
    String id() const { return m_currentCueId; }
44
    double start() const { return m_currentCueStartTime; }
45
    double end() const { return m_currentCueEndTime; }
46
    String settings() { return m_currentCueSettings.toString(); }
47
    String content() { return m_currentCueContent.toString(); }
48
42
49
    void processCue(CFArrayRef, double);
43
    ~InbandTextTrackPrivateAVF();
50
51
    void resetCueValues();
52
44
53
    virtual void setMode(InbandTextTrackPrivate::Mode) OVERRIDE;
45
    virtual void setMode(InbandTextTrackPrivate::Mode) OVERRIDE;
54
46
Lines 60-75 public: Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h_sec3
60
    bool hasBeenReported() const { return m_hasBeenReported; }
52
    bool hasBeenReported() const { return m_hasBeenReported; }
61
    void setHasBeenReported(bool reported) { m_hasBeenReported = reported; }
53
    void setHasBeenReported(bool reported) { m_hasBeenReported = reported; }
62
54
55
    void processCue(CFArrayRef, double);
56
    void resetCueValues();
57
63
protected:
58
protected:
64
    InbandTextTrackPrivateAVF(MediaPlayerPrivateAVFoundation*);
59
    InbandTextTrackPrivateAVF(MediaPlayerPrivateAVFoundation*);
65
60
66
    void processCueAttributes(CFAttributedStringRef, StringBuilder& content, StringBuilder& settings);
61
    void processCueAttributes(CFAttributedStringRef, GenericCueData*);
67
62
68
    String m_currentCueId;
69
    double m_currentCueStartTime;
63
    double m_currentCueStartTime;
70
    double m_currentCueEndTime;
64
    double m_currentCueEndTime;
71
    StringBuilder m_currentCueSettings;
65
72
    StringBuilder m_currentCueContent;
66
    Vector<OwnPtr<GenericCueData> > m_cues;
73
67
74
    MediaPlayerPrivateAVFoundation* m_player;
68
    MediaPlayerPrivateAVFoundation* m_player;
75
    int m_index;
69
    int m_index;
- Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp -9 / +8 lines
Lines 582-587 void MediaPlayerPrivateAVFoundation::see Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp_sec1
582
    LOG(Media, "MediaPlayerPrivateAVFoundation::seekCompleted(%p) - finished = %d", this, finished);
582
    LOG(Media, "MediaPlayerPrivateAVFoundation::seekCompleted(%p) - finished = %d", this, finished);
583
    UNUSED_PARAM(finished);
583
    UNUSED_PARAM(finished);
584
584
585
#if HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT)
586
    if (currentTrack())
587
        currentTrack()->resetCueValues();
588
#endif
589
585
    m_seekTo = MediaPlayer::invalidTime();
590
    m_seekTo = MediaPlayer::invalidTime();
586
    updateStates();
591
    updateStates();
587
    m_player->timeChanged();
592
    m_player->timeChanged();
Lines 811-829 void MediaPlayerPrivateAVFoundation::dis Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp_sec2
811
}
816
}
812
817
813
#if HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT)
818
#if HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT)
814
void MediaPlayerPrivateAVFoundation::flushCurrentCue(InbandTextTrackPrivateAVF* track)
819
void MediaPlayerPrivateAVFoundation::addGenericCue(InbandTextTrackPrivateAVF* track, GenericCueData* cueData)
815
{
820
{
816
    if (!track->client())
821
    if (!track->client())
817
        return;
822
        return;
818
823
819
    // AVFoundation returns a cue every time the data is buffered, only add it once.
824
    LOG(Media, "MediaPlayerPrivateAVFoundation::addGenericCue(%p) - adding cue for time %.2f", this, cueData->startTime());
820
    if (track->client()->hasCue(track, track->start(), track->end(), track->id(), track->content(), track->settings())) {
825
    track->client()->addGenericCue(track, cueData);
821
        LOG(Media, "MediaPlayerPrivateAVFoundation::flushCurrentCue(%p) - already have cue for time %.2f", this, track->start());
822
        return;
823
    }
824
825
    LOG(Media, "MediaPlayerPrivateAVFoundation::flushCurrentCue(%p) - adding cue for time %.2f", this, track->start());
826
    track->client()->addCue(track, track->start(), track->end(), track->id(), track->content(), track->settings());
827
}
826
}
828
827
829
void MediaPlayerPrivateAVFoundation::configureInbandTracks()
828
void MediaPlayerPrivateAVFoundation::configureInbandTracks()
- Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h -1 / +2 lines
Lines 36-41 Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h_sec1
36
namespace WebCore {
36
namespace WebCore {
37
37
38
class InbandTextTrackPrivateAVF;
38
class InbandTextTrackPrivateAVF;
39
class GenericCueData;
39
40
40
class MediaPlayerPrivateAVFoundation : public MediaPlayerPrivateInterface {
41
class MediaPlayerPrivateAVFoundation : public MediaPlayerPrivateInterface {
41
public:
42
public:
Lines 118-124 public: Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h_sec2
118
    void clearMainThreadPendingFlag();
119
    void clearMainThreadPendingFlag();
119
120
120
#if HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT)
121
#if HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT)
121
    void flushCurrentCue(InbandTextTrackPrivateAVF*);
122
    void addGenericCue(InbandTextTrackPrivateAVF*, GenericCueData*);
122
    void trackModeChanged();
123
    void trackModeChanged();
123
#endif
124
#endif
124
125
- Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm -10 / +12 lines
Lines 106-111 SOFT_LINK_CLASS(AVFoundation, AVMediaSel Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm_sec1
106
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicLegible, NSString *)
106
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicLegible, NSString *)
107
SOFT_LINK_POINTER(AVFoundation, AVMediaTypeSubtitle, NSString *)
107
SOFT_LINK_POINTER(AVFoundation, AVMediaTypeSubtitle, NSString *)
108
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicContainsOnlyForcedSubtitles, NSString *)
108
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicContainsOnlyForcedSubtitles, NSString *)
109
SOFT_LINK_POINTER(AVFoundation, AVPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly, NSString *)
109
110
110
#define AVPlayerItemLegibleOutput getAVPlayerItemLegibleOutputClass()
111
#define AVPlayerItemLegibleOutput getAVPlayerItemLegibleOutputClass()
111
#define AVMediaSelectionGroup getAVMediaSelectionGroupClass()
112
#define AVMediaSelectionGroup getAVMediaSelectionGroupClass()
Lines 113-118 SOFT_LINK_POINTER(AVFoundation, AVMediaC Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm_sec2
113
#define AVMediaCharacteristicLegible getAVMediaCharacteristicLegible()
114
#define AVMediaCharacteristicLegible getAVMediaCharacteristicLegible()
114
#define AVMediaTypeSubtitle getAVMediaTypeSubtitle()
115
#define AVMediaTypeSubtitle getAVMediaTypeSubtitle()
115
#define AVMediaCharacteristicContainsOnlyForcedSubtitles getAVMediaCharacteristicContainsOnlyForcedSubtitles()
116
#define AVMediaCharacteristicContainsOnlyForcedSubtitles getAVMediaCharacteristicContainsOnlyForcedSubtitles()
117
#define AVPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly getAVPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly()
116
#endif
118
#endif
117
119
118
#define kCMTimeZero getkCMTimeZero()
120
#define kCMTimeZero getkCMTimeZero()
Lines 391-397 void MediaPlayerPrivateAVFoundationObjC: Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm_sec3
391
#if HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT)
393
#if HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT)
392
    [m_avPlayer.get() setAppliesMediaSelectionCriteriaAutomatically:YES];
394
    [m_avPlayer.get() setAppliesMediaSelectionCriteriaAutomatically:YES];
393
#endif
395
#endif
394
    
395
396
396
    if (m_avPlayerItem)
397
    if (m_avPlayerItem)
397
        [m_avPlayer.get() replaceCurrentItemWithPlayerItem:m_avPlayerItem.get()];
398
        [m_avPlayer.get() replaceCurrentItemWithPlayerItem:m_avPlayerItem.get()];
Lines 410-416 void MediaPlayerPrivateAVFoundationObjC: Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm_sec4
410
411
411
    // Create the player item so we can load media data. 
412
    // Create the player item so we can load media data. 
412
    m_avPlayerItem.adoptNS([[AVPlayerItem alloc] initWithAsset:m_avAsset.get()]);
413
    m_avPlayerItem.adoptNS([[AVPlayerItem alloc] initWithAsset:m_avAsset.get()]);
413
    
414
414
    [[NSNotificationCenter defaultCenter] addObserver:m_objcObserver.get() selector:@selector(didEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:m_avPlayerItem.get()];
415
    [[NSNotificationCenter defaultCenter] addObserver:m_objcObserver.get() selector:@selector(didEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:m_avPlayerItem.get()];
415
416
416
    for (NSString *keyName in itemKVOProperties())
417
    for (NSString *keyName in itemKVOProperties())
Lines 897-902 void MediaPlayerPrivateAVFoundationObjC: Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm_sec5
897
898
898
        [m_legibleOutput.get() setDelegate:m_objcObserver.get() queue:dispatch_get_main_queue()];
899
        [m_legibleOutput.get() setDelegate:m_objcObserver.get() queue:dispatch_get_main_queue()];
899
        [m_legibleOutput.get() setAdvanceIntervalForDelegateInvocation:NSTimeIntervalSince1970];
900
        [m_legibleOutput.get() setAdvanceIntervalForDelegateInvocation:NSTimeIntervalSince1970];
901
        [m_legibleOutput.get() setTextStylingResolution:AVPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly];
900
        [m_avPlayerItem.get() addOutput:m_legibleOutput.get()];
902
        [m_avPlayerItem.get() addOutput:m_legibleOutput.get()];
901
    }
903
    }
902
#endif
904
#endif
Lines 1212-1218 void MediaPlayerPrivateAVFoundationObjC: Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm_sec6
1212
        LOG(Media, "MediaPlayerPrivateAVFoundationObjC::processTextTracks(%p) - nil mediaSelectionGroup", this);
1214
        LOG(Media, "MediaPlayerPrivateAVFoundationObjC::processTextTracks(%p) - nil mediaSelectionGroup", this);
1213
        return;
1215
        return;
1214
    }
1216
    }
1215
1217
    
1216
    Vector<RefPtr<InbandTextTrackPrivateAVF> > removedTextTracks = m_textTracks;
1218
    Vector<RefPtr<InbandTextTrackPrivateAVF> > removedTextTracks = m_textTracks;
1217
    NSArray *legibleOptions = [AVMediaSelectionGroup playableMediaSelectionOptionsFromArray:[legibleGroup options]];
1219
    NSArray *legibleOptions = [AVMediaSelectionGroup playableMediaSelectionOptionsFromArray:[legibleGroup options]];
1218
    for (AVMediaSelectionOptionType *option in legibleOptions) {
1220
    for (AVMediaSelectionOptionType *option in legibleOptions) {
Lines 1228-1240 void MediaPlayerPrivateAVFoundationObjC: Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm_sec7
1228
        if (!newTrack)
1230
        if (!newTrack)
1229
            continue;
1231
            continue;
1230
1232
1231
        if ([[option mediaType] isEqualToString:AVMediaTypeSubtitle]) {
1233
        if ([[option mediaType] isEqualToString:AVMediaTypeSubtitle] && [option hasMediaCharacteristic:AVMediaCharacteristicContainsOnlyForcedSubtitles])
1232
            if (![option hasMediaCharacteristic:AVMediaCharacteristicContainsOnlyForcedSubtitles]) {
1234
            continue;
1233
                AVMediaSelectionOptionType *forcedOnlyOption = [option associatedMediaSelectionOptionInMediaSelectionGroup:legibleGroup];
1234
                if (forcedOnlyOption)
1235
                    continue;
1236
            }
1237
        }
1238
1235
1239
        m_textTracks.append(InbandTextTrackPrivateAVFObjC::create(this, option));
1236
        m_textTracks.append(InbandTextTrackPrivateAVFObjC::create(this, option));
1240
    }
1237
    }
Lines 1275-1280 void MediaPlayerPrivateAVFoundationObjC: Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm_sec8
1275
void MediaPlayerPrivateAVFoundationObjC::setCurrentTrack(InbandTextTrackPrivateAVF *track)
1272
void MediaPlayerPrivateAVFoundationObjC::setCurrentTrack(InbandTextTrackPrivateAVF *track)
1276
{
1273
{
1277
    InbandTextTrackPrivateAVFObjC* trackPrivate = static_cast<InbandTextTrackPrivateAVFObjC*>(track);
1274
    InbandTextTrackPrivateAVFObjC* trackPrivate = static_cast<InbandTextTrackPrivateAVFObjC*>(track);
1275
    if (m_currentTrack == trackPrivate)
1276
        return;
1277
1278
    AVMediaSelectionOptionType *mediaSelectionOption = trackPrivate ? trackPrivate->mediaSelectionOption() : 0;
1278
    AVMediaSelectionOptionType *mediaSelectionOption = trackPrivate ? trackPrivate->mediaSelectionOption() : 0;
1279
1279
1280
    LOG(Media, "MediaPlayerPrivateAVFoundationObjC::setCurrentTrack(%p) - selecting media option %p", this, mediaSelectionOption);
1280
    LOG(Media, "MediaPlayerPrivateAVFoundationObjC::setCurrentTrack(%p) - selecting media option %p", this, mediaSelectionOption);
Lines 1424-1429 - (void)legibleOutput:(id)output didOutp Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm_sec9
1424
        return;
1424
        return;
1425
1425
1426
    dispatch_async(dispatch_get_main_queue(), ^{
1426
    dispatch_async(dispatch_get_main_queue(), ^{
1427
        if (!m_callback)
1428
            return;
1427
        m_callback->processCue(strings, CMTimeGetSeconds(itemTime));
1429
        m_callback->processCue(strings, CMTimeGetSeconds(itemTime));
1428
    });
1430
    });
1429
}
1431
}

Return to Bug 107046