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

Side by Side Diff: Source/core/html/track/vtt/VTTRegion.cpp

Issue 140503004: Make VTTRegion::setRegionSettings use VTTScanner (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « Source/core/html/track/vtt/VTTRegion.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 { 184 {
185 m_heightInLines = region->height(); 185 m_heightInLines = region->height();
186 m_width = region->width(); 186 m_width = region->width();
187 187
188 m_regionAnchor = FloatPoint(region->regionAnchorX(), region->regionAnchorY() ); 188 m_regionAnchor = FloatPoint(region->regionAnchorX(), region->regionAnchorY() );
189 m_viewportAnchor = FloatPoint(region->viewportAnchorX(), region->viewportAnc horY()); 189 m_viewportAnchor = FloatPoint(region->viewportAnchorX(), region->viewportAnc horY());
190 190
191 setScroll(region->scroll(), ASSERT_NO_EXCEPTION); 191 setScroll(region->scroll(), ASSERT_NO_EXCEPTION);
192 } 192 }
193 193
194 void VTTRegion::setRegionSettings(const String& input) 194 void VTTRegion::setRegionSettings(const String& inputString)
195 { 195 {
196 m_settings = input; 196 m_settings = inputString;
197 unsigned position = 0;
198 197
199 while (position < input.length()) { 198 VTTScanner input(inputString);
200 while (position < input.length() && VTTParser::isValidSettingDelimiter(i nput[position]))
201 position++;
202 199
203 if (position >= input.length()) 200 while (!input.isAtEnd()) {
201 input.skipWhile<VTTParser::isValidSettingDelimiter>();
202
203 if (input.isAtEnd())
204 break; 204 break;
205 205
206 parseSetting(input, &position); 206 // Scan the name part.
207 RegionSetting name = scanSettingName(input);
208
209 // Verify that we're looking at a '='.
210 if (name == None || !input.scan('=')) {
211 input.skipUntil<VTTParser::isASpace>();
212 continue;
213 }
214
215 // Scan the value part.
216 VTTScanner::Run valueRun = input.collectUntil<VTTParser::isASpace>();
217 parseSettingValue(name, input.extractString(valueRun));
218 input.skipRun(valueRun);
207 } 219 }
208 } 220 }
209 221
210 VTTRegion::RegionSetting VTTRegion::scanSettingName(VTTScanner& input) 222 VTTRegion::RegionSetting VTTRegion::scanSettingName(VTTScanner& input)
211 { 223 {
212 if (input.scan("id")) 224 if (input.scan("id"))
213 return Id; 225 return Id;
214 if (input.scan("height")) 226 if (input.scan("height"))
215 return Height; 227 return Height;
216 if (input.scan("width")) 228 if (input.scan("width"))
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 if (value == scrollUpValueKeyword) 275 if (value == scrollUpValueKeyword)
264 m_scroll = true; 276 m_scroll = true;
265 else 277 else
266 WTF_LOG(Media, "VTTRegion::parseSettingValue, invalid Scroll"); 278 WTF_LOG(Media, "VTTRegion::parseSettingValue, invalid Scroll");
267 break; 279 break;
268 case None: 280 case None:
269 break; 281 break;
270 } 282 }
271 } 283 }
272 284
273 void VTTRegion::parseSetting(const String& inputString, unsigned* position)
274 {
275 VTTLegacyScanner input(inputString, position);
276
277 // Scan the name part.
278 RegionSetting name = scanSettingName(input);
279
280 // Verify that we're looking at a '='.
281 if (!input.scan('=')) {
282 input.skipUntil<VTTParser::isASpace>();
283 return;
284 }
285
286 // Scan the value part.
287 VTTScanner::Run valueRun = input.collectUntil<VTTParser::isASpace>();
288 parseSettingValue(name, input.extractString(valueRun));
289 input.skipRun(valueRun);
290 }
291
292 const AtomicString& VTTRegion::textTrackCueContainerShadowPseudoId() 285 const AtomicString& VTTRegion::textTrackCueContainerShadowPseudoId()
293 { 286 {
294 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionCueContainerPseudoId, 287 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionCueContainerPseudoId,
295 ("-webkit-media-text-track-region-container", AtomicString::ConstructFro mLiteral)); 288 ("-webkit-media-text-track-region-container", AtomicString::ConstructFro mLiteral));
296 289
297 return trackRegionCueContainerPseudoId; 290 return trackRegionCueContainerPseudoId;
298 } 291 }
299 292
300 const AtomicString& VTTRegion::textTrackCueContainerScrollingClass() 293 const AtomicString& VTTRegion::textTrackCueContainerScrollingClass()
301 { 294 {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 449
457 void VTTRegion::scrollTimerFired(Timer<VTTRegion>*) 450 void VTTRegion::scrollTimerFired(Timer<VTTRegion>*)
458 { 451 {
459 WTF_LOG(Media, "VTTRegion::scrollTimerFired"); 452 WTF_LOG(Media, "VTTRegion::scrollTimerFired");
460 453
461 stopTimer(); 454 stopTimer();
462 displayLastVTTCueBox(); 455 displayLastVTTCueBox();
463 } 456 }
464 457
465 } // namespace WebCore 458 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/track/vtt/VTTRegion.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698