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

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: Address nits. 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:
64 static bool isInfiniteOrNonNumber(double value, const char* method, Exceptio nState&);
65
75 static const AtomicString& cueShadowPseudoId() 66 static const AtomicString& cueShadowPseudoId()
76 { 67 {
77 DEFINE_STATIC_LOCAL(const AtomicString, cue, ("cue", AtomicString::Const ructFromLiteral)); 68 DEFINE_STATIC_LOCAL(const AtomicString, cue, ("cue", AtomicString::Const ructFromLiteral));
78 return cue; 69 return cue;
79 } 70 }
80 71
81 virtual ~TextTrackCue(); 72 virtual ~TextTrackCue() { }
82 73
83 TextTrack* track() const; 74 TextTrack* track() const;
84 void setTrack(TextTrack*); 75 void setTrack(TextTrack*);
85 76
86 const String& id() const { return m_id; } 77 const String& id() const { return m_id; }
87 void setId(const String&); 78 void setId(const String&);
88 79
89 double startTime() const { return m_startTime; } 80 double startTime() const { return m_startTime; }
90 void setStartTime(double, ExceptionState&); 81 void setStartTime(double, ExceptionState&);
91 82
92 double endTime() const { return m_endTime; } 83 double endTime() const { return m_endTime; }
93 void setEndTime(double, ExceptionState&); 84 void setEndTime(double, ExceptionState&);
94 85
95 bool pauseOnExit() const { return m_pauseOnExit; } 86 bool pauseOnExit() const { return m_pauseOnExit; }
96 void setPauseOnExit(bool); 87 void setPauseOnExit(bool);
97 88
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(); 89 int cueIndex();
122 void invalidateCueIndex(); 90 void invalidateCueIndex();
123 91
124 PassRefPtr<DocumentFragment> getCueAsHTML();
125 PassRefPtr<DocumentFragment> createCueRenderingTree();
126
127 using EventTarget::dispatchEvent; 92 using EventTarget::dispatchEvent;
128 virtual bool dispatchEvent(PassRefPtr<Event>) OVERRIDE; 93 virtual bool dispatchEvent(PassRefPtr<Event>) OVERRIDE;
129 94
130 const String& regionId() const { return m_regionId; }
131 void setRegionId(const String&);
132 void notifyRegionWhenRemovingDisplayTree(bool);
133
134 bool isActive(); 95 bool isActive();
135 void setIsActive(bool); 96 void setIsActive(bool);
136 97
137 bool hasDisplayTree() const { return m_displayTree; } 98 virtual void updateDisplay(const IntSize& videoSize, HTMLDivElement& contain er) = 0;
138 PassRefPtr<TextTrackCueBox> getDisplayTree(const IntSize& videoSize);
139 PassRefPtr<HTMLDivElement> element() const { return m_cueBackgroundBox; }
140 99
141 void updateDisplayTree(double); 100 // FIXME: Consider refactoring to eliminate or merge the following three mem bers.
142 void removeDisplayTree(); 101 // https://code.google.com/p/chromium/issues/detail?id=322434
143 void markFutureAndPastNodes(ContainerNode*, double, double); 102 virtual void updateDisplayTree(double movieTime) { }
144 103 virtual void removeDisplayTree() { }
145 int calculateComputedLinePosition(); 104 virtual void notifyRegionWhenRemovingDisplayTree(bool notifyRegion) { }
146 105
147 virtual const AtomicString& interfaceName() const OVERRIDE; 106 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 107
175 DEFINE_ATTRIBUTE_EVENT_LISTENER(enter); 108 DEFINE_ATTRIBUTE_EVENT_LISTENER(enter);
176 DEFINE_ATTRIBUTE_EVENT_LISTENER(exit); 109 DEFINE_ATTRIBUTE_EVENT_LISTENER(exit);
177 110
111 virtual bool isVTTCue() const { return false; }
112
113 virtual String toString() const;
114
178 protected: 115 protected:
179 TextTrackCue(Document&, double start, double end, const String& content); 116 TextTrackCue(double start, double end);
117
118 void cueWillChange();
119 virtual void cueDidChange();
180 120
181 private: 121 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; 122 String m_id;
209 double m_startTime; 123 double m_startTime;
210 double m_endTime; 124 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; 125 int m_cueIndex;
217 126
218 WritingDirection m_writingDirection;
219
220 CueAlignment m_cueAlignment;
221
222 RefPtr<DocumentFragment> m_webVTTNodeTree;
223 TextTrack* m_track; 127 TextTrack* m_track;
224 128
225 bool m_isActive; 129 bool m_isActive;
226 bool m_pauseOnExit; 130 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 }; 131 };
242 132
243 } // namespace WebCore 133 } // namespace WebCore
244 134
245 #endif 135 #endif
OLDNEW
« no previous file with comments | « Source/core/html/shadow/MediaControlElements.cpp ('k') | Source/core/html/track/TextTrackCue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698