Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: Source/core/html/track/TextTrackCue.h

Issue 77853002: Move VTT functionality from TextTrackCue.* to VTTCue.* (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 * Copyright (C) 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
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 21 matching lines...) Expand all
32 #ifndef TextTrackCue_h 32 #ifndef TextTrackCue_h
33 #define TextTrackCue_h 33 #define TextTrackCue_h
34 34
35 #include "core/events/EventTarget.h" 35 #include "core/events/EventTarget.h"
36 #include "core/html/HTMLDivElement.h" 36 #include "core/html/HTMLDivElement.h"
37 #include "wtf/RefCounted.h" 37 #include "wtf/RefCounted.h"
38 38
39 namespace WebCore { 39 namespace WebCore {
40 40
41 class Document; 41 class Document;
42 class DocumentFragment;
43 class ExceptionState; 42 class ExceptionState;
44 class ExecutionContext;
45 class TextTrack;
46 class TextTrackCue; 43 class TextTrackCue;
47 44
48 // ---------------------------- 45 // ----------------------------
49 46
50 class TextTrackCueBox FINAL : public HTMLDivElement { 47 class TextTrackCueBox : public HTMLDivElement {
51 public: 48 public:
52 static PassRefPtr<TextTrackCueBox> create(Document& document, TextTrackCue* cue) 49 static const AtomicString& textTrackCueBoxShadowPseudoId()
53 { 50 {
54 return adoptRef(new TextTrackCueBox(document, cue)); 51 DEFINE_STATIC_LOCAL(const AtomicString, trackDisplayBoxShadowPseudoId, ( "-webkit-media-text-track-display", AtomicString::ConstructFromLiteral));
52 return trackDisplayBoxShadowPseudoId;
55 } 53 }
56 54
57 TextTrackCue* getCue() const;
58 void applyCSSProperties(const IntSize& videoSize);
59
60 static const AtomicString& textTrackCueBoxShadowPseudoId();
61
62 protected: 55 protected:
63 TextTrackCueBox(Document&, TextTrackCue*); 56 TextTrackCueBox(Document&);
64
65 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
66
67 TextTrackCue* m_cue;
68 }; 57 };
69 58
70 // ---------------------------- 59 // ----------------------------
71 60
72 class TextTrackCue : public RefCounted<TextTrackCue>, public EventTargetWithInli neData { 61 class TextTrackCue : public RefCounted<TextTrackCue>, public EventTargetWithInli neData {
73 REFCOUNTED_EVENT_TARGET(TextTrackCue); 62 REFCOUNTED_EVENT_TARGET(TextTrackCue);
74 public: 63 public:
75 static const AtomicString& cueShadowPseudoId() 64 static const AtomicString& cueShadowPseudoId()
76 { 65 {
77 DEFINE_STATIC_LOCAL(const AtomicString, cue, ("cue", AtomicString::Const ructFromLiteral)); 66 DEFINE_STATIC_LOCAL(const AtomicString, cue, ("cue", AtomicString::Const ructFromLiteral));
78 return cue; 67 return cue;
79 } 68 }
80 69
81 virtual ~TextTrackCue(); 70 virtual ~TextTrackCue() { }
82 71
83 TextTrack* track() const; 72 TextTrack* track() const;
84 void setTrack(TextTrack*); 73 void setTrack(TextTrack*);
85 74
86 const String& id() const { return m_id; } 75 const String& id() const { return m_id; }
87 void setId(const String&); 76 void setId(const String&);
88 77
89 double startTime() const { return m_startTime; } 78 double startTime() const { return m_startTime; }
90 void setStartTime(double, ExceptionState&); 79 void setStartTime(double, ExceptionState&);
91 80
92 double endTime() const { return m_endTime; } 81 double endTime() const { return m_endTime; }
93 void setEndTime(double, ExceptionState&); 82 void setEndTime(double, ExceptionState&);
94 83
95 bool pauseOnExit() const { return m_pauseOnExit; } 84 bool pauseOnExit() const { return m_pauseOnExit; }
96 void setPauseOnExit(bool); 85 void setPauseOnExit(bool);
97 86
98 const String& vertical() const;
99 void setVertical(const String&, ExceptionState&);
100
101 bool snapToLines() const { return m_snapToLines; }
102 void setSnapToLines(bool);
103
104 int line() const { return m_linePosition; }
105 void setLine(int, ExceptionState&);
106
107 int position() const { return m_textPosition; }
108 void setPosition(int, ExceptionState&);
109
110 int size() const { return m_cueSize; }
111 void setSize(int, ExceptionState&);
112
113 const String& align() const;
114 void setAlign(const String&, ExceptionState&);
115
116 const String& text() const { return m_content; }
117 void setText(const String&);
118
119 void parseSettings(const String&);
120
121 int cueIndex(); 87 int cueIndex();
122 void invalidateCueIndex(); 88 void invalidateCueIndex();
123 89
124 PassRefPtr<DocumentFragment> getCueAsHTML();
125 PassRefPtr<DocumentFragment> createCueRenderingTree();
126
127 using EventTarget::dispatchEvent; 90 using EventTarget::dispatchEvent;
128 virtual bool dispatchEvent(PassRefPtr<Event>) OVERRIDE; 91 virtual bool dispatchEvent(PassRefPtr<Event>) OVERRIDE;
129 92
130 const String& regionId() const { return m_regionId; }
131 void setRegionId(const String&);
132 void notifyRegionWhenRemovingDisplayTree(bool);
133
134 bool isActive(); 93 bool isActive();
135 void setIsActive(bool); 94 void setIsActive(bool);
136 95
137 bool hasDisplayTree() const { return m_displayTree; } 96 virtual bool hasDisplayTree() const { return false; }
acolwell GONE FROM CHROMIUM 2013/11/20 18:38:45 Do we really need to make all these virtual? If we
gasubic 2013/11/21 03:07:38 Eliminated three: hasDisplayTree, getDisplayTree,
138 PassRefPtr<TextTrackCueBox> getDisplayTree(const IntSize& videoSize); 97 virtual PassRefPtr<TextTrackCueBox> getDisplayTree(const IntSize& videoSize) { return 0; }
139 PassRefPtr<HTMLDivElement> element() const { return m_cueBackgroundBox; } 98 virtual PassRefPtr<HTMLDivElement> element() const { return 0; }
140 99
141 void updateDisplayTree(double); 100 virtual void updateDisplayTree(double) { }
142 void removeDisplayTree(); 101 virtual void removeDisplayTree() { }
143 void markFutureAndPastNodes(ContainerNode*, double, double); 102 virtual void notifyRegionWhenRemovingDisplayTree(bool) { }
144
145 int calculateComputedLinePosition();
146 103
147 virtual const AtomicString& interfaceName() const OVERRIDE; 104 virtual const AtomicString& interfaceName() const OVERRIDE;
148 virtual ExecutionContext* executionContext() const OVERRIDE;
149
150 std::pair<double, double> getCSSPosition() const;
151
152 CSSValueID getCSSAlignment() const;
153 int getCSSSize() const;
154 CSSValueID getCSSWritingDirection() const;
155 CSSValueID getCSSWritingMode() const;
156
157 enum WritingDirection {
158 Horizontal = 0,
159 VerticalGrowingLeft,
160 VerticalGrowingRight,
161 NumberOfWritingDirections
162 };
163 WritingDirection getWritingDirection() const { return m_writingDirection; }
164
165 enum CueAlignment {
166 Start = 0,
167 Middle,
168 End,
169 Left,
170 Right,
171 NumberOfAlignments
172 };
173 CueAlignment getAlignment() const { return m_cueAlignment; }
174 105
175 DEFINE_ATTRIBUTE_EVENT_LISTENER(enter); 106 DEFINE_ATTRIBUTE_EVENT_LISTENER(enter);
176 DEFINE_ATTRIBUTE_EVENT_LISTENER(exit); 107 DEFINE_ATTRIBUTE_EVENT_LISTENER(exit);
177 108
109 virtual bool isVTTCue() const { return false; }
110
178 protected: 111 protected:
179 TextTrackCue(Document&, double start, double end, const String& content); 112 TextTrackCue(double start, double end);
113
114 void cueWillChange();
115 virtual void cueDidChange();
180 116
181 private: 117 private:
182 Document& document() const;
183
184 PassRefPtr<TextTrackCueBox> displayTreeInternal();
185
186 void createVTTNodeTree();
187 void copyVTTNodeToDOMTree(ContainerNode* VTTNode, ContainerNode* root);
188
189 std::pair<double, double> getPositionCoordinates() const;
190
191 void determineTextDirection();
192 void calculateDisplayParameters();
193
194 void cueWillChange();
195 void cueDidChange();
196
197 enum CueSetting {
198 None,
199 Vertical,
200 Line,
201 Position,
202 Size,
203 Align,
204 RegionId
205 };
206 CueSetting settingName(const String&);
207
208 String m_id; 118 String m_id;
209 double m_startTime; 119 double m_startTime;
210 double m_endTime; 120 double m_endTime;
211 String m_content;
212 int m_linePosition;
213 int m_computedLinePosition;
214 int m_textPosition;
215 int m_cueSize;
216 int m_cueIndex; 121 int m_cueIndex;
217 122
218 WritingDirection m_writingDirection;
219
220 CueAlignment m_cueAlignment;
221
222 RefPtr<DocumentFragment> m_webVTTNodeTree;
223 TextTrack* m_track; 123 TextTrack* m_track;
224 124
225 bool m_isActive; 125 bool m_isActive;
226 bool m_pauseOnExit; 126 bool m_pauseOnExit;
227 bool m_snapToLines;
228
229 RefPtr<HTMLDivElement> m_cueBackgroundBox;
230
231 bool m_displayTreeShouldChange;
232 RefPtr<TextTrackCueBox> m_displayTree;
233
234 CSSValueID m_displayDirection;
235
236 int m_displaySize;
237
238 std::pair<float, float> m_displayPosition;
239 String m_regionId;
240 bool m_notifyRegion;
241 }; 127 };
242 128
243 } // namespace WebCore 129 } // namespace WebCore
244 130
245 #endif 131 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698