OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 11 matching lines...) Expand all Loading... |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/html/track/TextTrackRegion.h" | 32 #include "core/html/track/VTTRegion.h" |
33 | 33 |
34 #include "bindings/v8/ExceptionState.h" | 34 #include "bindings/v8/ExceptionState.h" |
35 #include "bindings/v8/ExceptionStatePlaceholder.h" | 35 #include "bindings/v8/ExceptionStatePlaceholder.h" |
36 #include "core/dom/ClientRect.h" | 36 #include "core/dom/ClientRect.h" |
37 #include "core/dom/DOMTokenList.h" | 37 #include "core/dom/DOMTokenList.h" |
38 #include "core/html/HTMLDivElement.h" | 38 #include "core/html/HTMLDivElement.h" |
39 #include "core/html/track/WebVTTParser.h" | 39 #include "core/html/track/WebVTTParser.h" |
40 #include "platform/Logging.h" | |
41 #include "core/rendering/RenderInline.h" | 40 #include "core/rendering/RenderInline.h" |
42 #include "core/rendering/RenderObject.h" | 41 #include "core/rendering/RenderObject.h" |
| 42 #include "platform/Logging.h" |
43 #include "wtf/MathExtras.h" | 43 #include "wtf/MathExtras.h" |
44 #include "wtf/text/StringBuilder.h" | 44 #include "wtf/text/StringBuilder.h" |
45 | 45 |
46 namespace WebCore { | 46 namespace WebCore { |
47 | 47 |
48 // The following values default values are defined within the WebVTT Regions Spe
c. | 48 // The following values default values are defined within the WebVTT Regions Spe
c. |
49 // https://dvcs.w3.org/hg/text-tracks/raw-file/default/608toVTT/region.html | 49 // https://dvcs.w3.org/hg/text-tracks/raw-file/default/608toVTT/region.html |
50 | 50 |
51 // The region occupies by default 100% of the width of the video viewport. | 51 // The region occupies by default 100% of the width of the video viewport. |
52 static const float defaultWidth = 100; | 52 static const float defaultWidth = 100; |
53 | 53 |
54 // The region has, by default, 3 lines of text. | 54 // The region has, by default, 3 lines of text. |
55 static const long defaultHeightInLines = 3; | 55 static const long defaultHeightInLines = 3; |
56 | 56 |
57 // The region and viewport are anchored in the bottom left corner. | 57 // The region and viewport are anchored in the bottom left corner. |
58 static const float defaultAnchorPointX = 0; | 58 static const float defaultAnchorPointX = 0; |
59 static const float defaultAnchorPointY = 100; | 59 static const float defaultAnchorPointY = 100; |
60 | 60 |
61 // The region doesn't have scrolling text, by default. | 61 // The region doesn't have scrolling text, by default. |
62 static const bool defaultScroll = false; | 62 static const bool defaultScroll = false; |
63 | 63 |
64 // Default region line-height (vh units) | 64 // Default region line-height (vh units) |
65 static const float lineHeight = 5.33; | 65 static const float lineHeight = 5.33; |
66 | 66 |
67 // Default scrolling animation time period (s). | 67 // Default scrolling animation time period (s). |
68 static const float scrollTime = 0.433; | 68 static const float scrollTime = 0.433; |
69 | 69 |
70 TextTrackRegion::TextTrackRegion() | 70 VTTRegion::VTTRegion() |
71 : m_id(emptyString()) | 71 : m_id(emptyString()) |
72 , m_width(defaultWidth) | 72 , m_width(defaultWidth) |
73 , m_heightInLines(defaultHeightInLines) | 73 , m_heightInLines(defaultHeightInLines) |
74 , m_regionAnchor(FloatPoint(defaultAnchorPointX, defaultAnchorPointY)) | 74 , m_regionAnchor(FloatPoint(defaultAnchorPointX, defaultAnchorPointY)) |
75 , m_viewportAnchor(FloatPoint(defaultAnchorPointX, defaultAnchorPointY)) | 75 , m_viewportAnchor(FloatPoint(defaultAnchorPointX, defaultAnchorPointY)) |
76 , m_scroll(defaultScroll) | 76 , m_scroll(defaultScroll) |
77 , m_track(0) | 77 , m_track(0) |
78 , m_currentTop(0) | 78 , m_currentTop(0) |
79 , m_scrollTimer(this, &TextTrackRegion::scrollTimerFired) | 79 , m_scrollTimer(this, &VTTRegion::scrollTimerFired) |
80 { | 80 { |
81 } | 81 } |
82 | 82 |
83 TextTrackRegion::~TextTrackRegion() | 83 VTTRegion::~VTTRegion() |
84 { | 84 { |
85 } | 85 } |
86 | 86 |
87 void TextTrackRegion::setTrack(TextTrack* track) | 87 void VTTRegion::setTrack(TextTrack* track) |
88 { | 88 { |
89 m_track = track; | 89 m_track = track; |
90 } | 90 } |
91 | 91 |
92 void TextTrackRegion::setId(const String& id) | 92 void VTTRegion::setId(const String& id) |
93 { | 93 { |
94 m_id = id; | 94 m_id = id; |
95 } | 95 } |
96 | 96 |
97 void TextTrackRegion::setWidth(double value, ExceptionState& es) | 97 void VTTRegion::setWidth(double value, ExceptionState& es) |
98 { | 98 { |
99 if (std::isinf(value) || std::isnan(value)) { | 99 if (std::isinf(value) || std::isnan(value)) { |
100 es.throwUninformativeAndGenericTypeError(); | 100 es.throwUninformativeAndGenericTypeError(); |
101 return; | 101 return; |
102 } | 102 } |
103 | 103 |
104 if (value < 0 || value > 100) { | 104 if (value < 0 || value > 100) { |
105 es.throwUninformativeAndGenericDOMException(IndexSizeError); | 105 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
106 return; | 106 return; |
107 } | 107 } |
108 | 108 |
109 m_width = value; | 109 m_width = value; |
110 } | 110 } |
111 | 111 |
112 void TextTrackRegion::setHeight(long value, ExceptionState& es) | 112 void VTTRegion::setHeight(long value, ExceptionState& es) |
113 { | 113 { |
114 if (value < 0) { | 114 if (value < 0) { |
115 es.throwUninformativeAndGenericDOMException(IndexSizeError); | 115 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
116 return; | 116 return; |
117 } | 117 } |
118 | 118 |
119 m_heightInLines = value; | 119 m_heightInLines = value; |
120 } | 120 } |
121 | 121 |
122 void TextTrackRegion::setRegionAnchorX(double value, ExceptionState& es) | 122 void VTTRegion::setRegionAnchorX(double value, ExceptionState& es) |
123 { | 123 { |
124 if (std::isinf(value) || std::isnan(value)) { | 124 if (std::isinf(value) || std::isnan(value)) { |
125 es.throwUninformativeAndGenericTypeError(); | 125 es.throwUninformativeAndGenericTypeError(); |
126 return; | 126 return; |
127 } | 127 } |
128 | 128 |
129 if (value < 0 || value > 100) { | 129 if (value < 0 || value > 100) { |
130 es.throwUninformativeAndGenericDOMException(IndexSizeError); | 130 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
131 return; | 131 return; |
132 } | 132 } |
133 | 133 |
134 m_regionAnchor.setX(value); | 134 m_regionAnchor.setX(value); |
135 } | 135 } |
136 | 136 |
137 void TextTrackRegion::setRegionAnchorY(double value, ExceptionState& es) | 137 void VTTRegion::setRegionAnchorY(double value, ExceptionState& es) |
138 { | 138 { |
139 if (std::isinf(value) || std::isnan(value)) { | 139 if (std::isinf(value) || std::isnan(value)) { |
140 es.throwUninformativeAndGenericTypeError(); | 140 es.throwUninformativeAndGenericTypeError(); |
141 return; | 141 return; |
142 } | 142 } |
143 | 143 |
144 if (value < 0 || value > 100) { | 144 if (value < 0 || value > 100) { |
145 es.throwUninformativeAndGenericDOMException(IndexSizeError); | 145 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
146 return; | 146 return; |
147 } | 147 } |
148 | 148 |
149 m_regionAnchor.setY(value); | 149 m_regionAnchor.setY(value); |
150 } | 150 } |
151 | 151 |
152 void TextTrackRegion::setViewportAnchorX(double value, ExceptionState& es) | 152 void VTTRegion::setViewportAnchorX(double value, ExceptionState& es) |
153 { | 153 { |
154 if (std::isinf(value) || std::isnan(value)) { | 154 if (std::isinf(value) || std::isnan(value)) { |
155 es.throwUninformativeAndGenericTypeError(); | 155 es.throwUninformativeAndGenericTypeError(); |
156 return; | 156 return; |
157 } | 157 } |
158 | 158 |
159 if (value < 0 || value > 100) { | 159 if (value < 0 || value > 100) { |
160 es.throwUninformativeAndGenericDOMException(IndexSizeError); | 160 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
161 return; | 161 return; |
162 } | 162 } |
163 | 163 |
164 m_viewportAnchor.setX(value); | 164 m_viewportAnchor.setX(value); |
165 } | 165 } |
166 | 166 |
167 void TextTrackRegion::setViewportAnchorY(double value, ExceptionState& es) | 167 void VTTRegion::setViewportAnchorY(double value, ExceptionState& es) |
168 { | 168 { |
169 if (std::isinf(value) || std::isnan(value)) { | 169 if (std::isinf(value) || std::isnan(value)) { |
170 es.throwUninformativeAndGenericTypeError(); | 170 es.throwUninformativeAndGenericTypeError(); |
171 return; | 171 return; |
172 } | 172 } |
173 | 173 |
174 if (value < 0 || value > 100) { | 174 if (value < 0 || value > 100) { |
175 es.throwUninformativeAndGenericDOMException(IndexSizeError); | 175 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
176 return; | 176 return; |
177 } | 177 } |
178 | 178 |
179 m_viewportAnchor.setY(value); | 179 m_viewportAnchor.setY(value); |
180 } | 180 } |
181 | 181 |
182 const AtomicString TextTrackRegion::scroll() const | 182 const AtomicString VTTRegion::scroll() const |
183 { | 183 { |
184 DEFINE_STATIC_LOCAL(const AtomicString, upScrollValueKeyword, ("up", AtomicS
tring::ConstructFromLiteral)); | 184 DEFINE_STATIC_LOCAL(const AtomicString, upScrollValueKeyword, ("up", AtomicS
tring::ConstructFromLiteral)); |
185 | 185 |
186 if (m_scroll) | 186 if (m_scroll) |
187 return upScrollValueKeyword; | 187 return upScrollValueKeyword; |
188 | 188 |
189 return ""; | 189 return ""; |
190 } | 190 } |
191 | 191 |
192 void TextTrackRegion::setScroll(const AtomicString& value, ExceptionState& es) | 192 void VTTRegion::setScroll(const AtomicString& value, ExceptionState& es) |
193 { | 193 { |
194 DEFINE_STATIC_LOCAL(const AtomicString, upScrollValueKeyword, ("up", AtomicS
tring::ConstructFromLiteral)); | 194 DEFINE_STATIC_LOCAL(const AtomicString, upScrollValueKeyword, ("up", AtomicS
tring::ConstructFromLiteral)); |
195 | 195 |
196 if (value != emptyString() && value != upScrollValueKeyword) { | 196 if (value != emptyString() && value != upScrollValueKeyword) { |
197 es.throwUninformativeAndGenericDOMException(SyntaxError); | 197 es.throwUninformativeAndGenericDOMException(SyntaxError); |
198 return; | 198 return; |
199 } | 199 } |
200 | 200 |
201 m_scroll = value == upScrollValueKeyword; | 201 m_scroll = value == upScrollValueKeyword; |
202 } | 202 } |
203 | 203 |
204 void TextTrackRegion::updateParametersFromRegion(TextTrackRegion* region) | 204 void VTTRegion::updateParametersFromRegion(VTTRegion* region) |
205 { | 205 { |
206 m_heightInLines = region->height(); | 206 m_heightInLines = region->height(); |
207 m_width = region->width(); | 207 m_width = region->width(); |
208 | 208 |
209 m_regionAnchor = FloatPoint(region->regionAnchorX(), region->regionAnchorY()
); | 209 m_regionAnchor = FloatPoint(region->regionAnchorX(), region->regionAnchorY()
); |
210 m_viewportAnchor = FloatPoint(region->viewportAnchorX(), region->viewportAnc
horY()); | 210 m_viewportAnchor = FloatPoint(region->viewportAnchorX(), region->viewportAnc
horY()); |
211 | 211 |
212 setScroll(region->scroll(), ASSERT_NO_EXCEPTION); | 212 setScroll(region->scroll(), ASSERT_NO_EXCEPTION); |
213 } | 213 } |
214 | 214 |
215 void TextTrackRegion::setRegionSettings(const String& input) | 215 void VTTRegion::setRegionSettings(const String& input) |
216 { | 216 { |
217 m_settings = input; | 217 m_settings = input; |
218 unsigned position = 0; | 218 unsigned position = 0; |
219 | 219 |
220 while (position < input.length()) { | 220 while (position < input.length()) { |
221 while (position < input.length() && WebVTTParser::isValidSettingDelimite
r(input[position])) | 221 while (position < input.length() && WebVTTParser::isValidSettingDelimite
r(input[position])) |
222 position++; | 222 position++; |
223 | 223 |
224 if (position >= input.length()) | 224 if (position >= input.length()) |
225 break; | 225 break; |
226 | 226 |
227 parseSetting(input, &position); | 227 parseSetting(input, &position); |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 TextTrackRegion::RegionSetting TextTrackRegion::getSettingFromString(const Strin
g& setting) | 231 VTTRegion::RegionSetting VTTRegion::getSettingFromString(const String& setting) |
232 { | 232 { |
233 DEFINE_STATIC_LOCAL(const AtomicString, idKeyword, ("id", AtomicString::Cons
tructFromLiteral)); | 233 DEFINE_STATIC_LOCAL(const AtomicString, idKeyword, ("id", AtomicString::Cons
tructFromLiteral)); |
234 DEFINE_STATIC_LOCAL(const AtomicString, heightKeyword, ("height", AtomicStri
ng::ConstructFromLiteral)); | 234 DEFINE_STATIC_LOCAL(const AtomicString, heightKeyword, ("height", AtomicStri
ng::ConstructFromLiteral)); |
235 DEFINE_STATIC_LOCAL(const AtomicString, widthKeyword, ("width", AtomicString
::ConstructFromLiteral)); | 235 DEFINE_STATIC_LOCAL(const AtomicString, widthKeyword, ("width", AtomicString
::ConstructFromLiteral)); |
236 DEFINE_STATIC_LOCAL(const AtomicString, regionAnchorKeyword, ("regionanchor"
, AtomicString::ConstructFromLiteral)); | 236 DEFINE_STATIC_LOCAL(const AtomicString, regionAnchorKeyword, ("regionanchor"
, AtomicString::ConstructFromLiteral)); |
237 DEFINE_STATIC_LOCAL(const AtomicString, viewportAnchorKeyword, ("viewportanc
hor", AtomicString::ConstructFromLiteral)); | 237 DEFINE_STATIC_LOCAL(const AtomicString, viewportAnchorKeyword, ("viewportanc
hor", AtomicString::ConstructFromLiteral)); |
238 DEFINE_STATIC_LOCAL(const AtomicString, scrollKeyword, ("scroll", AtomicStri
ng::ConstructFromLiteral)); | 238 DEFINE_STATIC_LOCAL(const AtomicString, scrollKeyword, ("scroll", AtomicStri
ng::ConstructFromLiteral)); |
239 | 239 |
240 if (setting == idKeyword) | 240 if (setting == idKeyword) |
241 return Id; | 241 return Id; |
242 if (setting == heightKeyword) | 242 if (setting == heightKeyword) |
243 return Height; | 243 return Height; |
244 if (setting == widthKeyword) | 244 if (setting == widthKeyword) |
245 return Width; | 245 return Width; |
246 if (setting == viewportAnchorKeyword) | 246 if (setting == viewportAnchorKeyword) |
247 return ViewportAnchor; | 247 return ViewportAnchor; |
248 if (setting == regionAnchorKeyword) | 248 if (setting == regionAnchorKeyword) |
249 return RegionAnchor; | 249 return RegionAnchor; |
250 if (setting == scrollKeyword) | 250 if (setting == scrollKeyword) |
251 return Scroll; | 251 return Scroll; |
252 | 252 |
253 return None; | 253 return None; |
254 } | 254 } |
255 | 255 |
256 void TextTrackRegion::parseSettingValue(RegionSetting setting, const String& val
ue) | 256 void VTTRegion::parseSettingValue(RegionSetting setting, const String& value) |
257 { | 257 { |
258 DEFINE_STATIC_LOCAL(const AtomicString, scrollUpValueKeyword, ("up", AtomicS
tring::ConstructFromLiteral)); | 258 DEFINE_STATIC_LOCAL(const AtomicString, scrollUpValueKeyword, ("up", AtomicS
tring::ConstructFromLiteral)); |
259 | 259 |
260 bool isValidSetting; | 260 bool isValidSetting; |
261 String numberAsString; | 261 String numberAsString; |
262 int number; | 262 int number; |
263 unsigned position; | 263 unsigned position; |
264 FloatPoint anchorPosition; | 264 FloatPoint anchorPosition; |
265 | 265 |
266 switch (setting) { | 266 switch (setting) { |
267 case Id: | 267 case Id: |
268 if (value.find("-->") == kNotFound) | 268 if (value.find("-->") == kNotFound) |
269 m_id = value; | 269 m_id = value; |
270 break; | 270 break; |
271 case Width: | 271 case Width: |
272 number = WebVTTParser::parseFloatPercentageValue(value, isValidSetting); | 272 number = WebVTTParser::parseFloatPercentageValue(value, isValidSetting); |
273 if (isValidSetting) | 273 if (isValidSetting) |
274 m_width = number; | 274 m_width = number; |
275 else | 275 else |
276 LOG(Media, "TextTrackRegion::parseSettingValue, invalid Width"); | 276 LOG(Media, "VTTRegion::parseSettingValue, invalid Width"); |
277 break; | 277 break; |
278 case Height: | 278 case Height: |
279 position = 0; | 279 position = 0; |
280 | 280 |
281 numberAsString = WebVTTParser::collectDigits(value, &position); | 281 numberAsString = WebVTTParser::collectDigits(value, &position); |
282 number = value.toInt(&isValidSetting); | 282 number = value.toInt(&isValidSetting); |
283 | 283 |
284 if (isValidSetting && number >= 0) | 284 if (isValidSetting && number >= 0) |
285 m_heightInLines = number; | 285 m_heightInLines = number; |
286 else | 286 else |
287 LOG(Media, "TextTrackRegion::parseSettingValue, invalid Height"); | 287 LOG(Media, "VTTRegion::parseSettingValue, invalid Height"); |
288 break; | 288 break; |
289 case RegionAnchor: | 289 case RegionAnchor: |
290 anchorPosition = WebVTTParser::parseFloatPercentageValuePair(value, ',',
isValidSetting); | 290 anchorPosition = WebVTTParser::parseFloatPercentageValuePair(value, ',',
isValidSetting); |
291 if (isValidSetting) | 291 if (isValidSetting) |
292 m_regionAnchor = anchorPosition; | 292 m_regionAnchor = anchorPosition; |
293 else | 293 else |
294 LOG(Media, "TextTrackRegion::parseSettingValue, invalid RegionAnchor
"); | 294 LOG(Media, "VTTRegion::parseSettingValue, invalid RegionAnchor"); |
295 break; | 295 break; |
296 case ViewportAnchor: | 296 case ViewportAnchor: |
297 anchorPosition = WebVTTParser::parseFloatPercentageValuePair(value, ',',
isValidSetting); | 297 anchorPosition = WebVTTParser::parseFloatPercentageValuePair(value, ',',
isValidSetting); |
298 if (isValidSetting) | 298 if (isValidSetting) |
299 m_viewportAnchor = anchorPosition; | 299 m_viewportAnchor = anchorPosition; |
300 else | 300 else |
301 LOG(Media, "TextTrackRegion::parseSettingValue, invalid ViewportAnch
or"); | 301 LOG(Media, "VTTRegion::parseSettingValue, invalid ViewportAnchor"); |
302 break; | 302 break; |
303 case Scroll: | 303 case Scroll: |
304 if (value == scrollUpValueKeyword) | 304 if (value == scrollUpValueKeyword) |
305 m_scroll = true; | 305 m_scroll = true; |
306 else | 306 else |
307 LOG(Media, "TextTrackRegion::parseSettingValue, invalid Scroll"); | 307 LOG(Media, "VTTRegion::parseSettingValue, invalid Scroll"); |
308 break; | 308 break; |
309 case None: | 309 case None: |
310 break; | 310 break; |
311 } | 311 } |
312 } | 312 } |
313 | 313 |
314 void TextTrackRegion::parseSetting(const String& input, unsigned* position) | 314 void VTTRegion::parseSetting(const String& input, unsigned* position) |
315 { | 315 { |
316 String setting = WebVTTParser::collectWord(input, position); | 316 String setting = WebVTTParser::collectWord(input, position); |
317 | 317 |
318 size_t equalOffset = setting.find('=', 1); | 318 size_t equalOffset = setting.find('=', 1); |
319 if (equalOffset == kNotFound || !equalOffset || equalOffset == setting.lengt
h() - 1) | 319 if (equalOffset == kNotFound || !equalOffset || equalOffset == setting.lengt
h() - 1) |
320 return; | 320 return; |
321 | 321 |
322 RegionSetting name = getSettingFromString(setting.substring(0, equalOffset))
; | 322 RegionSetting name = getSettingFromString(setting.substring(0, equalOffset))
; |
323 String value = setting.substring(equalOffset + 1, setting.length() - 1); | 323 String value = setting.substring(equalOffset + 1, setting.length() - 1); |
324 | 324 |
325 parseSettingValue(name, value); | 325 parseSettingValue(name, value); |
326 } | 326 } |
327 | 327 |
328 const AtomicString& TextTrackRegion::textTrackCueContainerShadowPseudoId() | 328 const AtomicString& VTTRegion::textTrackCueContainerShadowPseudoId() |
329 { | 329 { |
330 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionCueContainerPseudoId, | 330 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionCueContainerPseudoId, |
331 ("-webkit-media-text-track-region-container", AtomicString::ConstructFro
mLiteral)); | 331 ("-webkit-media-text-track-region-container", AtomicString::ConstructFro
mLiteral)); |
332 | 332 |
333 return trackRegionCueContainerPseudoId; | 333 return trackRegionCueContainerPseudoId; |
334 } | 334 } |
335 | 335 |
336 const AtomicString& TextTrackRegion::textTrackCueContainerScrollingClass() | 336 const AtomicString& VTTRegion::textTrackCueContainerScrollingClass() |
337 { | 337 { |
338 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionCueContainerScrollingClas
s, | 338 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionCueContainerScrollingClas
s, |
339 ("scrolling", AtomicString::ConstructFromLiteral)); | 339 ("scrolling", AtomicString::ConstructFromLiteral)); |
340 | 340 |
341 return trackRegionCueContainerScrollingClass; | 341 return trackRegionCueContainerScrollingClass; |
342 } | 342 } |
343 | 343 |
344 const AtomicString& TextTrackRegion::textTrackRegionShadowPseudoId() | 344 const AtomicString& VTTRegion::textTrackRegionShadowPseudoId() |
345 { | 345 { |
346 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionShadowPseudoId, | 346 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionShadowPseudoId, |
347 ("-webkit-media-text-track-region", AtomicString::ConstructFromLiteral))
; | 347 ("-webkit-media-text-track-region", AtomicString::ConstructFromLiteral))
; |
348 | 348 |
349 return trackRegionShadowPseudoId; | 349 return trackRegionShadowPseudoId; |
350 } | 350 } |
351 | 351 |
352 PassRefPtr<HTMLDivElement> TextTrackRegion::getDisplayTree(Document& document) | 352 PassRefPtr<HTMLDivElement> VTTRegion::getDisplayTree(Document& document) |
353 { | 353 { |
354 if (!m_regionDisplayTree) { | 354 if (!m_regionDisplayTree) { |
355 m_regionDisplayTree = HTMLDivElement::create(document); | 355 m_regionDisplayTree = HTMLDivElement::create(document); |
356 prepareRegionDisplayTree(); | 356 prepareRegionDisplayTree(); |
357 } | 357 } |
358 | 358 |
359 return m_regionDisplayTree; | 359 return m_regionDisplayTree; |
360 } | 360 } |
361 | 361 |
362 void TextTrackRegion::willRemoveTextTrackCueBox(TextTrackCueBox* box) | 362 void VTTRegion::willRemoveTextTrackCueBox(TextTrackCueBox* box) |
363 { | 363 { |
364 LOG(Media, "TextTrackRegion::willRemoveTextTrackCueBox"); | 364 LOG(Media, "VTTRegion::willRemoveTextTrackCueBox"); |
365 ASSERT(m_cueContainer->contains(box)); | 365 ASSERT(m_cueContainer->contains(box)); |
366 | 366 |
367 double boxHeight = box->getBoundingClientRect()->bottom() - box->getBounding
ClientRect()->top(); | 367 double boxHeight = box->getBoundingClientRect()->bottom() - box->getBounding
ClientRect()->top(); |
368 | 368 |
369 m_cueContainer->classList()->remove(textTrackCueContainerScrollingClass(), A
SSERT_NO_EXCEPTION); | 369 m_cueContainer->classList()->remove(textTrackCueContainerScrollingClass(), A
SSERT_NO_EXCEPTION); |
370 | 370 |
371 m_currentTop += boxHeight; | 371 m_currentTop += boxHeight; |
372 m_cueContainer->setInlineStyleProperty(CSSPropertyTop, m_currentTop, CSSPrim
itiveValue::CSS_PX); | 372 m_cueContainer->setInlineStyleProperty(CSSPropertyTop, m_currentTop, CSSPrim
itiveValue::CSS_PX); |
373 } | 373 } |
374 | 374 |
375 | 375 |
376 void TextTrackRegion::appendTextTrackCueBox(PassRefPtr<TextTrackCueBox> displayB
ox) | 376 void VTTRegion::appendTextTrackCueBox(PassRefPtr<TextTrackCueBox> displayBox) |
377 { | 377 { |
378 ASSERT(m_cueContainer); | 378 ASSERT(m_cueContainer); |
379 | 379 |
380 if (m_cueContainer->contains(displayBox.get())) | 380 if (m_cueContainer->contains(displayBox.get())) |
381 return; | 381 return; |
382 | 382 |
383 m_cueContainer->appendChild(displayBox); | 383 m_cueContainer->appendChild(displayBox); |
384 displayLastTextTrackCueBox(); | 384 displayLastTextTrackCueBox(); |
385 } | 385 } |
386 | 386 |
387 void TextTrackRegion::displayLastTextTrackCueBox() | 387 void VTTRegion::displayLastTextTrackCueBox() |
388 { | 388 { |
389 LOG(Media, "TextTrackRegion::displayLastTextTrackCueBox"); | 389 LOG(Media, "VTTRegion::displayLastTextTrackCueBox"); |
390 ASSERT(m_cueContainer); | 390 ASSERT(m_cueContainer); |
391 | 391 |
392 // FIXME: This should not be causing recalc styles in a loop to set the "top
" css | 392 // FIXME: This should not be causing recalc styles in a loop to set the "top
" css |
393 // property to move elements. We should just scroll the text track cues on t
he | 393 // property to move elements. We should just scroll the text track cues on t
he |
394 // compositor with an animation. | 394 // compositor with an animation. |
395 | 395 |
396 if (m_scrollTimer.isActive()) | 396 if (m_scrollTimer.isActive()) |
397 return; | 397 return; |
398 | 398 |
399 // If it's a scrolling region, add the scrolling class. | 399 // If it's a scrolling region, add the scrolling class. |
(...skipping 12 matching lines...) Expand all Loading... |
412 | 412 |
413 float height = childBottom - childTop; | 413 float height = childBottom - childTop; |
414 | 414 |
415 m_currentTop -= std::min(height, childBottom - regionBottom); | 415 m_currentTop -= std::min(height, childBottom - regionBottom); |
416 m_cueContainer->setInlineStyleProperty(CSSPropertyTop, m_currentTop, CSS
PrimitiveValue::CSS_PX); | 416 m_cueContainer->setInlineStyleProperty(CSSPropertyTop, m_currentTop, CSS
PrimitiveValue::CSS_PX); |
417 | 417 |
418 startTimer(); | 418 startTimer(); |
419 } | 419 } |
420 } | 420 } |
421 | 421 |
422 void TextTrackRegion::prepareRegionDisplayTree() | 422 void VTTRegion::prepareRegionDisplayTree() |
423 { | 423 { |
424 ASSERT(m_regionDisplayTree); | 424 ASSERT(m_regionDisplayTree); |
425 | 425 |
426 // 7.2 Prepare region CSS boxes | 426 // 7.2 Prepare region CSS boxes |
427 | 427 |
428 // FIXME: Change the code below to use viewport units when | 428 // FIXME: Change the code below to use viewport units when |
429 // http://crbug/244618 is fixed. | 429 // http://crbug/244618 is fixed. |
430 | 430 |
431 // Let regionWidth be the text track region width. | 431 // Let regionWidth be the text track region width. |
432 // Let width be 'regionWidth vw' ('vw' is a CSS unit) | 432 // Let width be 'regionWidth vw' ('vw' is a CSS unit) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 0.0, | 466 0.0, |
467 CSSPrimitiveValue::CSS_PX); | 467 CSSPrimitiveValue::CSS_PX); |
468 | 468 |
469 m_cueContainer->setPart(textTrackCueContainerShadowPseudoId()); | 469 m_cueContainer->setPart(textTrackCueContainerShadowPseudoId()); |
470 m_regionDisplayTree->appendChild(m_cueContainer); | 470 m_regionDisplayTree->appendChild(m_cueContainer); |
471 | 471 |
472 // 7.5 Every WebVTT region object is initialised with the following CSS | 472 // 7.5 Every WebVTT region object is initialised with the following CSS |
473 m_regionDisplayTree->setPart(textTrackRegionShadowPseudoId()); | 473 m_regionDisplayTree->setPart(textTrackRegionShadowPseudoId()); |
474 } | 474 } |
475 | 475 |
476 void TextTrackRegion::startTimer() | 476 void VTTRegion::startTimer() |
477 { | 477 { |
478 LOG(Media, "TextTrackRegion::startTimer"); | 478 LOG(Media, "VTTRegion::startTimer"); |
479 | 479 |
480 if (m_scrollTimer.isActive()) | 480 if (m_scrollTimer.isActive()) |
481 return; | 481 return; |
482 | 482 |
483 double duration = isScrollingRegion() ? scrollTime : 0; | 483 double duration = isScrollingRegion() ? scrollTime : 0; |
484 m_scrollTimer.startOneShot(duration); | 484 m_scrollTimer.startOneShot(duration); |
485 } | 485 } |
486 | 486 |
487 void TextTrackRegion::stopTimer() | 487 void VTTRegion::stopTimer() |
488 { | 488 { |
489 LOG(Media, "TextTrackRegion::stopTimer"); | 489 LOG(Media, "VTTRegion::stopTimer"); |
490 | 490 |
491 if (m_scrollTimer.isActive()) | 491 if (m_scrollTimer.isActive()) |
492 m_scrollTimer.stop(); | 492 m_scrollTimer.stop(); |
493 } | 493 } |
494 | 494 |
495 void TextTrackRegion::scrollTimerFired(Timer<TextTrackRegion>*) | 495 void VTTRegion::scrollTimerFired(Timer<VTTRegion>*) |
496 { | 496 { |
497 LOG(Media, "TextTrackRegion::scrollTimerFired"); | 497 LOG(Media, "VTTRegion::scrollTimerFired"); |
498 | 498 |
499 stopTimer(); | 499 stopTimer(); |
500 displayLastTextTrackCueBox(); | 500 displayLastTextTrackCueBox(); |
501 } | 501 } |
502 | 502 |
503 } // namespace WebCore | 503 } // namespace WebCore |
OLD | NEW |