OLD | NEW |
---|---|
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 Loading... | |
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 void updateDisplay(const IntSize& videoSize, HTMLDivElement* contain er) { } |
acolwell GONE FROM CHROMIUM
2013/11/21 19:22:00
nit: I think this should this be pure virtual so t
gasubic
2013/11/22 15:27:34
Done.
| |
138 PassRefPtr<TextTrackCueBox> getDisplayTree(const IntSize& videoSize); | |
139 PassRefPtr<HTMLDivElement> element() const { return m_cueBackgroundBox; } | |
140 | 97 |
141 void updateDisplayTree(double); | 98 virtual void updateDisplayTree(double) { } |
acolwell GONE FROM CHROMIUM
2013/11/21 19:22:00
nit: Please file a bug and add a FIXME for the nec
esprehn
2013/11/22 04:52:30
Please add the argument name for the double. What
gasubic
2013/11/22 15:27:34
Done.
gasubic
2013/11/22 15:27:34
Done.
gasubic
2013/11/22 15:27:34
Done.
| |
142 void removeDisplayTree(); | 99 virtual void removeDisplayTree() { } |
143 void markFutureAndPastNodes(ContainerNode*, double, double); | 100 virtual void notifyRegionWhenRemovingDisplayTree(bool) { } |
esprehn
2013/11/22 04:52:30
Same thing, what is this bool? Add argument names
gasubic
2013/11/22 15:27:34
Done.
| |
144 | |
145 int calculateComputedLinePosition(); | |
146 | 101 |
147 virtual const AtomicString& interfaceName() const OVERRIDE; | 102 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 | 103 |
175 DEFINE_ATTRIBUTE_EVENT_LISTENER(enter); | 104 DEFINE_ATTRIBUTE_EVENT_LISTENER(enter); |
176 DEFINE_ATTRIBUTE_EVENT_LISTENER(exit); | 105 DEFINE_ATTRIBUTE_EVENT_LISTENER(exit); |
177 | 106 |
107 virtual bool isVTTCue() const { return false; } | |
108 | |
178 protected: | 109 protected: |
179 TextTrackCue(Document&, double start, double end, const String& content); | 110 TextTrackCue(double start, double end); |
111 | |
112 void cueWillChange(); | |
113 virtual void cueDidChange(); | |
180 | 114 |
181 private: | 115 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; | 116 String m_id; |
209 double m_startTime; | 117 double m_startTime; |
210 double m_endTime; | 118 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; | 119 int m_cueIndex; |
217 | 120 |
218 WritingDirection m_writingDirection; | |
219 | |
220 CueAlignment m_cueAlignment; | |
221 | |
222 RefPtr<DocumentFragment> m_webVTTNodeTree; | |
223 TextTrack* m_track; | 121 TextTrack* m_track; |
224 | 122 |
225 bool m_isActive; | 123 bool m_isActive; |
226 bool m_pauseOnExit; | 124 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 }; | 125 }; |
242 | 126 |
243 } // namespace WebCore | 127 } // namespace WebCore |
244 | 128 |
245 #endif | 129 #endif |
OLD | NEW |