| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 PassRefPtr<HTMLDivElement> VTTRegion::getDisplayTree(Document& document) | 330 PassRefPtr<HTMLDivElement> VTTRegion::getDisplayTree(Document& document) |
| 331 { | 331 { |
| 332 if (!m_regionDisplayTree) { | 332 if (!m_regionDisplayTree) { |
| 333 m_regionDisplayTree = HTMLDivElement::create(document); | 333 m_regionDisplayTree = HTMLDivElement::create(document); |
| 334 prepareRegionDisplayTree(); | 334 prepareRegionDisplayTree(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 return m_regionDisplayTree; | 337 return m_regionDisplayTree; |
| 338 } | 338 } |
| 339 | 339 |
| 340 void VTTRegion::willRemoveTextTrackCueBox(TextTrackCueBox* box) | 340 void VTTRegion::willRemoveVTTCueBox(VTTCueBox* box) |
| 341 { | 341 { |
| 342 WTF_LOG(Media, "VTTRegion::willRemoveTextTrackCueBox"); | 342 WTF_LOG(Media, "VTTRegion::willRemoveVTTCueBox"); |
| 343 ASSERT(m_cueContainer->contains(box)); | 343 ASSERT(m_cueContainer->contains(box)); |
| 344 | 344 |
| 345 double boxHeight = box->getBoundingClientRect()->bottom() - box->getBounding
ClientRect()->top(); | 345 double boxHeight = box->getBoundingClientRect()->bottom() - box->getBounding
ClientRect()->top(); |
| 346 | 346 |
| 347 m_cueContainer->classList()->remove(textTrackCueContainerScrollingClass(), A
SSERT_NO_EXCEPTION); | 347 m_cueContainer->classList()->remove(textTrackCueContainerScrollingClass(), A
SSERT_NO_EXCEPTION); |
| 348 | 348 |
| 349 m_currentTop += boxHeight; | 349 m_currentTop += boxHeight; |
| 350 m_cueContainer->setInlineStyleProperty(CSSPropertyTop, m_currentTop, CSSPrim
itiveValue::CSS_PX); | 350 m_cueContainer->setInlineStyleProperty(CSSPropertyTop, m_currentTop, CSSPrim
itiveValue::CSS_PX); |
| 351 } | 351 } |
| 352 | 352 |
| 353 | 353 void VTTRegion::appendVTTCueBox(PassRefPtr<VTTCueBox> displayBox) |
| 354 void VTTRegion::appendTextTrackCueBox(PassRefPtr<TextTrackCueBox> displayBox) | |
| 355 { | 354 { |
| 356 ASSERT(m_cueContainer); | 355 ASSERT(m_cueContainer); |
| 357 | 356 |
| 358 if (m_cueContainer->contains(displayBox.get())) | 357 if (m_cueContainer->contains(displayBox.get())) |
| 359 return; | 358 return; |
| 360 | 359 |
| 361 m_cueContainer->appendChild(displayBox); | 360 m_cueContainer->appendChild(displayBox); |
| 362 displayLastTextTrackCueBox(); | 361 displayLastVTTCueBox(); |
| 363 } | 362 } |
| 364 | 363 |
| 365 void VTTRegion::displayLastTextTrackCueBox() | 364 void VTTRegion::displayLastVTTCueBox() |
| 366 { | 365 { |
| 367 WTF_LOG(Media, "VTTRegion::displayLastTextTrackCueBox"); | 366 WTF_LOG(Media, "VTTRegion::displayLastVTTCueBox"); |
| 368 ASSERT(m_cueContainer); | 367 ASSERT(m_cueContainer); |
| 369 | 368 |
| 370 // FIXME: This should not be causing recalc styles in a loop to set the "top
" css | 369 // FIXME: This should not be causing recalc styles in a loop to set the "top
" css |
| 371 // property to move elements. We should just scroll the text track cues on t
he | 370 // property to move elements. We should just scroll the text track cues on t
he |
| 372 // compositor with an animation. | 371 // compositor with an animation. |
| 373 | 372 |
| 374 if (m_scrollTimer.isActive()) | 373 if (m_scrollTimer.isActive()) |
| 375 return; | 374 return; |
| 376 | 375 |
| 377 // If it's a scrolling region, add the scrolling class. | 376 // If it's a scrolling region, add the scrolling class. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 428 |
| 430 // Let viewportAnchorY be the y dimension of the text track region viewport | 429 // Let viewportAnchorY be the y dimension of the text track region viewport |
| 431 // anchor and regionAnchorY be the y dimension of the text track region | 430 // anchor and regionAnchorY be the y dimension of the text track region |
| 432 // anchor. Let topOffset be regionAnchorY multiplied by height divided by | 431 // anchor. Let topOffset be regionAnchorY multiplied by height divided by |
| 433 // 100.0. Let top be topOffset subtracted from 'viewportAnchorY vh'. | 432 // 100.0. Let top be topOffset subtracted from 'viewportAnchorY vh'. |
| 434 double topOffset = m_regionAnchor.y() * height / 100; | 433 double topOffset = m_regionAnchor.y() * height / 100; |
| 435 m_regionDisplayTree->setInlineStyleProperty(CSSPropertyTop, | 434 m_regionDisplayTree->setInlineStyleProperty(CSSPropertyTop, |
| 436 m_viewportAnchor.y() - topOffset, | 435 m_viewportAnchor.y() - topOffset, |
| 437 CSSPrimitiveValue::CSS_PERCENTAGE); | 436 CSSPrimitiveValue::CSS_PERCENTAGE); |
| 438 | 437 |
| 439 | |
| 440 // The cue container is used to wrap the cues and it is the object which is | 438 // The cue container is used to wrap the cues and it is the object which is |
| 441 // gradually scrolled out as multiple cues are appended to the region. | 439 // gradually scrolled out as multiple cues are appended to the region. |
| 442 m_cueContainer = HTMLDivElement::create(m_regionDisplayTree->document()); | 440 m_cueContainer = HTMLDivElement::create(m_regionDisplayTree->document()); |
| 443 m_cueContainer->setInlineStyleProperty(CSSPropertyTop, | 441 m_cueContainer->setInlineStyleProperty(CSSPropertyTop, |
| 444 0.0, | 442 0.0, |
| 445 CSSPrimitiveValue::CSS_PX); | 443 CSSPrimitiveValue::CSS_PX); |
| 446 | 444 |
| 447 m_cueContainer->setPseudo(textTrackCueContainerShadowPseudoId()); | 445 m_cueContainer->setPseudo(textTrackCueContainerShadowPseudoId()); |
| 448 m_regionDisplayTree->appendChild(m_cueContainer); | 446 m_regionDisplayTree->appendChild(m_cueContainer); |
| 449 | 447 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 468 | 466 |
| 469 if (m_scrollTimer.isActive()) | 467 if (m_scrollTimer.isActive()) |
| 470 m_scrollTimer.stop(); | 468 m_scrollTimer.stop(); |
| 471 } | 469 } |
| 472 | 470 |
| 473 void VTTRegion::scrollTimerFired(Timer<VTTRegion>*) | 471 void VTTRegion::scrollTimerFired(Timer<VTTRegion>*) |
| 474 { | 472 { |
| 475 WTF_LOG(Media, "VTTRegion::scrollTimerFired"); | 473 WTF_LOG(Media, "VTTRegion::scrollTimerFired"); |
| 476 | 474 |
| 477 stopTimer(); | 475 stopTimer(); |
| 478 displayLastTextTrackCueBox(); | 476 displayLastVTTCueBox(); |
| 479 } | 477 } |
| 480 | 478 |
| 481 } // namespace WebCore | 479 } // namespace WebCore |
| OLD | NEW |