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

Side by Side Diff: Source/core/html/track/vtt/VTTCue.h

Issue 869623002: VTTCue: Refactor display parameter handling (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 11 months 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) 2013, Opera Software ASA. All rights reserved. 2 * Copyright (c) 2013, Opera Software ASA. 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
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 23 matching lines...) Expand all
34 #include "platform/heap/Handle.h" 34 #include "platform/heap/Handle.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 class Document; 38 class Document;
39 class DoubleOrAutoKeyword; 39 class DoubleOrAutoKeyword;
40 class ExecutionContext; 40 class ExecutionContext;
41 class VTTCue; 41 class VTTCue;
42 class VTTScanner; 42 class VTTScanner;
43 43
44 struct VTTDisplayParameters {
45 VTTDisplayParameters();
46
47 FloatPoint position;
48 float size;
49 CSSValueID direction;
50 CSSValueID writingMode;
51 };
52
44 class VTTCueBox final : public HTMLDivElement { 53 class VTTCueBox final : public HTMLDivElement {
45 public: 54 public:
46 static PassRefPtrWillBeRawPtr<VTTCueBox> create(Document& document, VTTCue* cue) 55 static PassRefPtrWillBeRawPtr<VTTCueBox> create(Document& document, VTTCue* cue)
47 { 56 {
48 return adoptRefWillBeNoop(new VTTCueBox(document, cue)); 57 return adoptRefWillBeNoop(new VTTCueBox(document, cue));
49 } 58 }
50 59
51 VTTCue* getCue() const { return m_cue; } 60 VTTCue* getCue() const { return m_cue; }
52 void applyCSSProperties(const IntSize& videoSize); 61 void applyCSSProperties(const VTTDisplayParameters&);
53 62
54 virtual void trace(Visitor*) override; 63 virtual void trace(Visitor*) override;
55 64
56 private: 65 private:
57 VTTCueBox(Document&, VTTCue*); 66 VTTCueBox(Document&, VTTCue*);
58 67
59 virtual RenderObject* createRenderer(RenderStyle*) override; 68 virtual RenderObject* createRenderer(RenderStyle*) override;
60 69
61 RawPtrWillBeMember<VTTCue> m_cue; 70 RawPtrWillBeMember<VTTCue> m_cue;
62 }; 71 };
(...skipping 30 matching lines...) Expand all
93 void setText(const String&); 102 void setText(const String&);
94 103
95 void parseSettings(const String&); 104 void parseSettings(const String&);
96 105
97 PassRefPtrWillBeRawPtr<DocumentFragment> getCueAsHTML(); 106 PassRefPtrWillBeRawPtr<DocumentFragment> getCueAsHTML();
98 PassRefPtrWillBeRawPtr<DocumentFragment> createCueRenderingTree(); 107 PassRefPtrWillBeRawPtr<DocumentFragment> createCueRenderingTree();
99 108
100 const String& regionId() const { return m_regionId; } 109 const String& regionId() const { return m_regionId; }
101 void setRegionId(const String&); 110 void setRegionId(const String&);
102 111
103 virtual void updateDisplay(const IntSize& videoSize, HTMLDivElement& contain er) override; 112 virtual void updateDisplay(HTMLDivElement& container) override;
104 113
105 virtual void updateDisplayTree(double movieTime) override; 114 virtual void updateDisplayTree(double movieTime) override;
106 virtual void removeDisplayTree() override; 115 virtual void removeDisplayTree() override;
107 virtual void notifyRegionWhenRemovingDisplayTree(bool notifyRegion) override ; 116 virtual void notifyRegionWhenRemovingDisplayTree(bool notifyRegion) override ;
108 117
109 void markFutureAndPastNodes(ContainerNode*, double previousTimestamp, double movieTime); 118 void markFutureAndPastNodes(ContainerNode*, double previousTimestamp, double movieTime);
110 119
111 float calculateComputedLinePosition(); 120 float calculateComputedLinePosition() const;
112
113 FloatPoint getCSSPosition() const;
114
115 CSSValueID getCSSAlignment() const;
116 float getCSSSize() const;
117 CSSValueID getCSSWritingDirection() const;
118 CSSValueID getCSSWritingMode() const;
119 121
120 enum WritingDirection { 122 enum WritingDirection {
121 Horizontal = 0, 123 Horizontal = 0,
122 VerticalGrowingLeft, 124 VerticalGrowingLeft,
123 VerticalGrowingRight, 125 VerticalGrowingRight,
124 NumberOfWritingDirections 126 NumberOfWritingDirections
125 }; 127 };
126 WritingDirection getWritingDirection() const { return m_writingDirection; } 128 WritingDirection getWritingDirection() const { return m_writingDirection; }
127 129
128 enum CueAlignment { 130 enum CueAlignment {
129 Start = 0, 131 Start = 0,
130 Middle, 132 Middle,
131 End, 133 End,
132 Left, 134 Left,
133 Right, 135 Right,
134 NumberOfAlignments 136 NumberOfAlignments
135 }; 137 };
136 CueAlignment getAlignment() const { return m_cueAlignment; } 138 CueAlignment cueAlignment() const { return m_cueAlignment; }
137 139
138 virtual ExecutionContext* executionContext() const override; 140 virtual ExecutionContext* executionContext() const override;
139 141
140 #ifndef NDEBUG 142 #ifndef NDEBUG
141 virtual String toString() const override; 143 virtual String toString() const override;
142 #endif 144 #endif
143 145
144 virtual void trace(Visitor*) override; 146 virtual void trace(Visitor*) override;
145 147
146 private: 148 private:
147 VTTCue(Document&, double startTime, double endTime, const String& text); 149 VTTCue(Document&, double startTime, double endTime, const String& text);
148 150
149 Document& document() const; 151 Document& document() const;
150 152
151 VTTCueBox& ensureDisplayTree(); 153 VTTCueBox& ensureDisplayTree();
152 PassRefPtrWillBeRawPtr<VTTCueBox> getDisplayTree(const IntSize& videoSize); 154 PassRefPtrWillBeRawPtr<VTTCueBox> getDisplayTree();
153 155
154 virtual void cueDidChange() override; 156 virtual void cueDidChange() override;
155 157
156 void createVTTNodeTree(); 158 void createVTTNodeTree();
157 void copyVTTNodeToDOMTree(ContainerNode* vttNode, ContainerNode* root); 159 void copyVTTNodeToDOMTree(ContainerNode* vttNode, ContainerNode* root);
158 160
159 FloatPoint getPositionCoordinates() const;
160 bool lineIsAuto() const; 161 bool lineIsAuto() const;
162 bool textPositionIsAuto() const;
161 163
162 void calculateDisplayParameters(); 164 VTTDisplayParameters calculateDisplayParameters() const;
163 float calculateComputedTextPosition() const; 165 float calculateComputedTextPosition() const;
164 bool textPositionIsAuto() const;
165 CueAlignment calculateComputedCueAlignment() const; 166 CueAlignment calculateComputedCueAlignment() const;
166 167
167 enum CueSetting { 168 enum CueSetting {
168 None, 169 None,
169 Vertical, 170 Vertical,
170 Line, 171 Line,
171 Position, 172 Position,
172 Size, 173 Size,
173 Align, 174 Align,
174 RegionId 175 RegionId
175 }; 176 };
176 CueSetting settingName(VTTScanner&); 177 CueSetting settingName(VTTScanner&) const;
177 178
178 String m_text; 179 String m_text;
179 float m_linePosition; 180 float m_linePosition;
180 float m_computedLinePosition;
181 float m_textPosition; 181 float m_textPosition;
182 float m_cueSize; 182 float m_cueSize;
183 WritingDirection m_writingDirection; 183 WritingDirection m_writingDirection;
184 CueAlignment m_cueAlignment; 184 CueAlignment m_cueAlignment;
185 String m_regionId; 185 String m_regionId;
186 186
187 RefPtrWillBeMember<DocumentFragment> m_vttNodeTree; 187 RefPtrWillBeMember<DocumentFragment> m_vttNodeTree;
188 RefPtrWillBeMember<HTMLDivElement> m_cueBackgroundBox; 188 RefPtrWillBeMember<HTMLDivElement> m_cueBackgroundBox;
189 RefPtrWillBeMember<VTTCueBox> m_displayTree; 189 RefPtrWillBeMember<VTTCueBox> m_displayTree;
190 190
191 CSSValueID m_displayDirection;
192 float m_displaySize;
193 FloatPoint m_displayPosition;
194
195 bool m_snapToLines : 1; 191 bool m_snapToLines : 1;
196 bool m_displayTreeShouldChange : 1; 192 bool m_displayTreeShouldChange : 1;
197 bool m_notifyRegion : 1; 193 bool m_notifyRegion : 1;
198 }; 194 };
199 195
200 // VTTCue is currently the only TextTrackCue subclass. 196 // VTTCue is currently the only TextTrackCue subclass.
201 DEFINE_TYPE_CASTS(VTTCue, TextTrackCue, cue, true, true); 197 DEFINE_TYPE_CASTS(VTTCue, TextTrackCue, cue, true, true);
202 198
203 } // namespace blink 199 } // namespace blink
204 200
205 #endif // VTTCue_h 201 #endif // VTTCue_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698