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

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

Issue 1998553002: media: Replace wtf/Assertions.h macros in favor of base/logging.h macros (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 7 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
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 26 matching lines...) Expand all
37 #include "core/dom/ElementTraversal.h" 37 #include "core/dom/ElementTraversal.h"
38 #include "core/html/HTMLDivElement.h" 38 #include "core/html/HTMLDivElement.h"
39 #include "core/html/track/vtt/VTTParser.h" 39 #include "core/html/track/vtt/VTTParser.h"
40 #include "core/html/track/vtt/VTTScanner.h" 40 #include "core/html/track/vtt/VTTScanner.h"
41 #include "core/layout/LayoutInline.h" 41 #include "core/layout/LayoutInline.h"
42 #include "core/layout/LayoutObject.h" 42 #include "core/layout/LayoutObject.h"
43 #include "platform/Logging.h" 43 #include "platform/Logging.h"
44 #include "wtf/MathExtras.h" 44 #include "wtf/MathExtras.h"
45 #include "wtf/text/StringBuilder.h" 45 #include "wtf/text/StringBuilder.h"
46 46
47 #define VTT_LOG_LEVEL 3
48
47 namespace blink { 49 namespace blink {
48 50
49 // The following values default values are defined within the WebVTT Regions Spe c. 51 // The following values default values are defined within the WebVTT Regions Spe c.
50 // https://dvcs.w3.org/hg/text-tracks/raw-file/default/608toVTT/region.html 52 // https://dvcs.w3.org/hg/text-tracks/raw-file/default/608toVTT/region.html
51 53
52 // The region occupies by default 100% of the width of the video viewport. 54 // The region occupies by default 100% of the width of the video viewport.
53 static const float defaultWidth = 100; 55 static const float defaultWidth = 100;
54 56
55 // The region has, by default, 3 lines of text. 57 // The region has, by default, 3 lines of text.
56 static const long defaultHeightInLines = 3; 58 static const long defaultHeightInLines = 3;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 String stringValue = input.extractString(valueRun); 249 String stringValue = input.extractString(valueRun);
248 if (stringValue.find("-->") == kNotFound) 250 if (stringValue.find("-->") == kNotFound)
249 m_id = stringValue; 251 m_id = stringValue;
250 break; 252 break;
251 } 253 }
252 case Width: { 254 case Width: {
253 float floatWidth; 255 float floatWidth;
254 if (VTTParser::parseFloatPercentageValue(input, floatWidth) && parsedEnt ireRun(input, valueRun)) 256 if (VTTParser::parseFloatPercentageValue(input, floatWidth) && parsedEnt ireRun(input, valueRun))
255 m_width = floatWidth; 257 m_width = floatWidth;
256 else 258 else
257 WTF_LOG(Media, "VTTRegion::parseSettingValue, invalid Width"); 259 DVLOG(VTT_LOG_LEVEL) << "parseSettingValue, invalid Width";
258 break; 260 break;
259 } 261 }
260 case Height: { 262 case Height: {
261 int number; 263 int number;
262 if (input.scanDigits(number) && parsedEntireRun(input, valueRun)) 264 if (input.scanDigits(number) && parsedEntireRun(input, valueRun))
263 m_heightInLines = number; 265 m_heightInLines = number;
264 else 266 else
265 WTF_LOG(Media, "VTTRegion::parseSettingValue, invalid Height"); 267 DVLOG(VTT_LOG_LEVEL) << "parseSettingValue, invalid Height";
266 break; 268 break;
267 } 269 }
268 case RegionAnchor: { 270 case RegionAnchor: {
269 FloatPoint anchor; 271 FloatPoint anchor;
270 if (VTTParser::parseFloatPercentageValuePair(input, ',', anchor) && pars edEntireRun(input, valueRun)) 272 if (VTTParser::parseFloatPercentageValuePair(input, ',', anchor) && pars edEntireRun(input, valueRun))
271 m_regionAnchor = anchor; 273 m_regionAnchor = anchor;
272 else 274 else
273 WTF_LOG(Media, "VTTRegion::parseSettingValue, invalid RegionAnchor") ; 275 DVLOG(VTT_LOG_LEVEL) << "parseSettingValue, invalid RegionAnchor";
274 break; 276 break;
275 } 277 }
276 case ViewportAnchor: { 278 case ViewportAnchor: {
277 FloatPoint anchor; 279 FloatPoint anchor;
278 if (VTTParser::parseFloatPercentageValuePair(input, ',', anchor) && pars edEntireRun(input, valueRun)) 280 if (VTTParser::parseFloatPercentageValuePair(input, ',', anchor) && pars edEntireRun(input, valueRun))
279 m_viewportAnchor = anchor; 281 m_viewportAnchor = anchor;
280 else 282 else
281 WTF_LOG(Media, "VTTRegion::parseSettingValue, invalid ViewportAnchor "); 283 DVLOG(VTT_LOG_LEVEL) << "parseSettingValue, invalid ViewportAnchor";
282 break; 284 break;
283 } 285 }
284 case Scroll: 286 case Scroll:
285 if (input.scanRun(valueRun, scrollUpValueKeyword)) 287 if (input.scanRun(valueRun, scrollUpValueKeyword))
286 m_scroll = true; 288 m_scroll = true;
287 else 289 else
288 WTF_LOG(Media, "VTTRegion::parseSettingValue, invalid Scroll"); 290 DVLOG(VTT_LOG_LEVEL) << "parseSettingValue, invalid Scroll";
289 break; 291 break;
290 case None: 292 case None:
291 break; 293 break;
292 } 294 }
293 295
294 input.skipRun(valueRun); 296 input.skipRun(valueRun);
295 } 297 }
296 298
297 const AtomicString& VTTRegion::textTrackCueContainerShadowPseudoId() 299 const AtomicString& VTTRegion::textTrackCueContainerShadowPseudoId()
298 { 300 {
(...skipping 24 matching lines...) Expand all
323 if (!m_regionDisplayTree) { 325 if (!m_regionDisplayTree) {
324 m_regionDisplayTree = HTMLDivElement::create(document); 326 m_regionDisplayTree = HTMLDivElement::create(document);
325 prepareRegionDisplayTree(); 327 prepareRegionDisplayTree();
326 } 328 }
327 329
328 return m_regionDisplayTree; 330 return m_regionDisplayTree;
329 } 331 }
330 332
331 void VTTRegion::willRemoveVTTCueBox(VTTCueBox* box) 333 void VTTRegion::willRemoveVTTCueBox(VTTCueBox* box)
332 { 334 {
333 WTF_LOG(Media, "VTTRegion::willRemoveVTTCueBox"); 335 DVLOG(VTT_LOG_LEVEL) << "willRemoveVTTCueBox";
334 ASSERT(m_cueContainer->contains(box)); 336 ASSERT(m_cueContainer->contains(box));
335 337
336 double boxHeight = box->getBoundingClientRect()->bottom() - box->getBounding ClientRect()->top(); 338 double boxHeight = box->getBoundingClientRect()->bottom() - box->getBounding ClientRect()->top();
337 339
338 m_cueContainer->classList().remove(textTrackCueContainerScrollingClass(), AS SERT_NO_EXCEPTION); 340 m_cueContainer->classList().remove(textTrackCueContainerScrollingClass(), AS SERT_NO_EXCEPTION);
339 341
340 m_currentTop += boxHeight; 342 m_currentTop += boxHeight;
341 m_cueContainer->setInlineStyleProperty(CSSPropertyTop, m_currentTop, CSSPrim itiveValue::UnitType::Pixels); 343 m_cueContainer->setInlineStyleProperty(CSSPropertyTop, m_currentTop, CSSPrim itiveValue::UnitType::Pixels);
342 } 344 }
343 345
344 void VTTRegion::appendVTTCueBox(VTTCueBox* displayBox) 346 void VTTRegion::appendVTTCueBox(VTTCueBox* displayBox)
345 { 347 {
346 ASSERT(m_cueContainer); 348 ASSERT(m_cueContainer);
347 349
348 if (m_cueContainer->contains(displayBox)) 350 if (m_cueContainer->contains(displayBox))
349 return; 351 return;
350 352
351 m_cueContainer->appendChild(displayBox); 353 m_cueContainer->appendChild(displayBox);
352 displayLastVTTCueBox(); 354 displayLastVTTCueBox();
353 } 355 }
354 356
355 void VTTRegion::displayLastVTTCueBox() 357 void VTTRegion::displayLastVTTCueBox()
356 { 358 {
357 WTF_LOG(Media, "VTTRegion::displayLastVTTCueBox"); 359 DVLOG(VTT_LOG_LEVEL) << "displayLastVTTCueBox";
358 ASSERT(m_cueContainer); 360 ASSERT(m_cueContainer);
359 361
360 // FIXME: This should not be causing recalc styles in a loop to set the "top " css 362 // FIXME: This should not be causing recalc styles in a loop to set the "top " css
361 // property to move elements. We should just scroll the text track cues on t he 363 // property to move elements. We should just scroll the text track cues on t he
362 // compositor with an animation. 364 // compositor with an animation.
363 365
364 if (m_scrollTimer.isActive()) 366 if (m_scrollTimer.isActive())
365 return; 367 return;
366 368
367 // If it's a scrolling region, add the scrolling class. 369 // If it's a scrolling region, add the scrolling class.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 438
437 m_cueContainer->setShadowPseudoId(textTrackCueContainerShadowPseudoId()); 439 m_cueContainer->setShadowPseudoId(textTrackCueContainerShadowPseudoId());
438 m_regionDisplayTree->appendChild(m_cueContainer); 440 m_regionDisplayTree->appendChild(m_cueContainer);
439 441
440 // 7.5 Every WebVTT region object is initialised with the following CSS 442 // 7.5 Every WebVTT region object is initialised with the following CSS
441 m_regionDisplayTree->setShadowPseudoId(textTrackRegionShadowPseudoId()); 443 m_regionDisplayTree->setShadowPseudoId(textTrackRegionShadowPseudoId());
442 } 444 }
443 445
444 void VTTRegion::startTimer() 446 void VTTRegion::startTimer()
445 { 447 {
446 WTF_LOG(Media, "VTTRegion::startTimer"); 448 DVLOG(VTT_LOG_LEVEL) << "startTimer";
447 449
448 if (m_scrollTimer.isActive()) 450 if (m_scrollTimer.isActive())
449 return; 451 return;
450 452
451 double duration = isScrollingRegion() ? scrollTime : 0; 453 double duration = isScrollingRegion() ? scrollTime : 0;
452 m_scrollTimer.startOneShot(duration, BLINK_FROM_HERE); 454 m_scrollTimer.startOneShot(duration, BLINK_FROM_HERE);
453 } 455 }
454 456
455 void VTTRegion::stopTimer() 457 void VTTRegion::stopTimer()
456 { 458 {
457 WTF_LOG(Media, "VTTRegion::stopTimer"); 459 DVLOG(VTT_LOG_LEVEL) << "stopTimer";
458 460
459 if (m_scrollTimer.isActive()) 461 if (m_scrollTimer.isActive())
460 m_scrollTimer.stop(); 462 m_scrollTimer.stop();
461 } 463 }
462 464
463 void VTTRegion::scrollTimerFired(Timer<VTTRegion>*) 465 void VTTRegion::scrollTimerFired(Timer<VTTRegion>*)
464 { 466 {
465 WTF_LOG(Media, "VTTRegion::scrollTimerFired"); 467 DVLOG(VTT_LOG_LEVEL) << "scrollTimerFired";
466 468
467 stopTimer(); 469 stopTimer();
468 displayLastVTTCueBox(); 470 displayLastVTTCueBox();
469 } 471 }
470 472
471 DEFINE_TRACE(VTTRegion) 473 DEFINE_TRACE(VTTRegion)
472 { 474 {
473 visitor->trace(m_cueContainer); 475 visitor->trace(m_cueContainer);
474 visitor->trace(m_regionDisplayTree); 476 visitor->trace(m_regionDisplayTree);
475 visitor->trace(m_track); 477 visitor->trace(m_track);
476 } 478 }
477 479
478 } // namespace blink 480 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLTrackElement.cpp ('k') | third_party/WebKit/Source/core/loader/TextTrackLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698