| 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 | |
| 33 #if ENABLE(WEBVTT_REGIONS) | |
| 34 | |
| 35 #include "core/html/track/TextTrackRegion.h" | 32 #include "core/html/track/TextTrackRegion.h" |
| 36 | 33 |
| 37 #include "bindings/v8/ExceptionState.h" | 34 #include "bindings/v8/ExceptionState.h" |
| 38 #include "bindings/v8/ExceptionStatePlaceholder.h" | 35 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 39 #include "core/dom/ClientRect.h" | 36 #include "core/dom/ClientRect.h" |
| 40 #include "core/dom/DOMTokenList.h" | 37 #include "core/dom/DOMTokenList.h" |
| 41 #include "core/html/HTMLDivElement.h" | 38 #include "core/html/HTMLDivElement.h" |
| 42 #include "core/html/track/WebVTTParser.h" | 39 #include "core/html/track/WebVTTParser.h" |
| 43 #include "platform/Logging.h" | 40 #include "platform/Logging.h" |
| 44 #include "core/rendering/RenderInline.h" | 41 #include "core/rendering/RenderInline.h" |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 { | 348 { |
| 352 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionShadowPseudoId, | 349 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionShadowPseudoId, |
| 353 ("-webkit-media-text-track-region", AtomicString::ConstructFromLiteral))
; | 350 ("-webkit-media-text-track-region", AtomicString::ConstructFromLiteral))
; |
| 354 | 351 |
| 355 return trackRegionShadowPseudoId; | 352 return trackRegionShadowPseudoId; |
| 356 } | 353 } |
| 357 | 354 |
| 358 PassRefPtr<HTMLDivElement> TextTrackRegion::getDisplayTree() | 355 PassRefPtr<HTMLDivElement> TextTrackRegion::getDisplayTree() |
| 359 { | 356 { |
| 360 if (!m_regionDisplayTree) { | 357 if (!m_regionDisplayTree) { |
| 361 m_regionDisplayTree = HTMLDivElement::create(ownerDocument()); | 358 m_regionDisplayTree = HTMLDivElement::create(*ownerDocument()); |
| 362 prepareRegionDisplayTree(); | 359 prepareRegionDisplayTree(); |
| 363 } | 360 } |
| 364 | 361 |
| 365 return m_regionDisplayTree; | 362 return m_regionDisplayTree; |
| 366 } | 363 } |
| 367 | 364 |
| 368 void TextTrackRegion::willRemoveTextTrackCueBox(TextTrackCueBox* box) | 365 void TextTrackRegion::willRemoveTextTrackCueBox(TextTrackCueBox* box) |
| 369 { | 366 { |
| 370 LOG(Media, "TextTrackRegion::willRemoveTextTrackCueBox"); | 367 LOG(Media, "TextTrackRegion::willRemoveTextTrackCueBox"); |
| 371 ASSERT(m_cueContainer->contains(box)); | 368 ASSERT(m_cueContainer->contains(box)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 391 | 388 |
| 392 void TextTrackRegion::displayLastTextTrackCueBox() | 389 void TextTrackRegion::displayLastTextTrackCueBox() |
| 393 { | 390 { |
| 394 LOG(Media, "TextTrackRegion::displayLastTextTrackCueBox"); | 391 LOG(Media, "TextTrackRegion::displayLastTextTrackCueBox"); |
| 395 ASSERT(m_cueContainer); | 392 ASSERT(m_cueContainer); |
| 396 | 393 |
| 397 // FIXME: This should not be causing recalc styles in a loop to set the "top
" css | 394 // FIXME: This should not be causing recalc styles in a loop to set the "top
" css |
| 398 // property to move elements. We should just scroll the text track cues on t
he | 395 // property to move elements. We should just scroll the text track cues on t
he |
| 399 // compositor with an animation. | 396 // compositor with an animation. |
| 400 | 397 |
| 401 if (!m_scrollTimer.isActive()) | 398 if (m_scrollTimer.isActive()) |
| 402 return; | 399 return; |
| 403 | 400 |
| 404 // If it's a scrolling region, add the scrolling class. | 401 // If it's a scrolling region, add the scrolling class. |
| 405 if (isScrollingRegion()) | 402 if (isScrollingRegion()) |
| 406 m_cueContainer->classList()->add(textTrackCueContainerScrollingClass(),
ASSERT_NO_EXCEPTION); | 403 m_cueContainer->classList()->add(textTrackCueContainerScrollingClass(),
ASSERT_NO_EXCEPTION); |
| 407 | 404 |
| 408 float regionBottom = m_regionDisplayTree->getBoundingClientRect()->bottom(); | 405 float regionBottom = m_regionDisplayTree->getBoundingClientRect()->bottom(); |
| 409 | 406 |
| 410 // Find first cue that is not entirely displayed and scroll it upwards. | 407 // Find first cue that is not entirely displayed and scroll it upwards. |
| 411 for (int i = 0; i < m_cueContainer->childNodeCount() && !m_scrollTimer.isAct
ive(); ++i) { | 408 for (int i = 0; i < m_cueContainer->childNodeCount() && !m_scrollTimer.isAct
ive(); ++i) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 // anchor. Let topOffset be regionAnchorY multiplied by height divided by | 456 // anchor. Let topOffset be regionAnchorY multiplied by height divided by |
| 460 // 100.0. Let top be topOffset subtracted from 'viewportAnchorY vh'. | 457 // 100.0. Let top be topOffset subtracted from 'viewportAnchorY vh'. |
| 461 double topOffset = m_regionAnchor.y() * height / 100; | 458 double topOffset = m_regionAnchor.y() * height / 100; |
| 462 m_regionDisplayTree->setInlineStyleProperty(CSSPropertyTop, | 459 m_regionDisplayTree->setInlineStyleProperty(CSSPropertyTop, |
| 463 m_viewportAnchor.y() - topOffset, | 460 m_viewportAnchor.y() - topOffset, |
| 464 CSSPrimitiveValue::CSS_PERCENTAGE); | 461 CSSPrimitiveValue::CSS_PERCENTAGE); |
| 465 | 462 |
| 466 | 463 |
| 467 // The cue container is used to wrap the cues and it is the object which is | 464 // The cue container is used to wrap the cues and it is the object which is |
| 468 // gradually scrolled out as multiple cues are appended to the region. | 465 // gradually scrolled out as multiple cues are appended to the region. |
| 469 m_cueContainer = HTMLDivElement::create(ownerDocument()); | 466 m_cueContainer = HTMLDivElement::create(*ownerDocument()); |
| 470 m_cueContainer->setInlineStyleProperty(CSSPropertyTop, | 467 m_cueContainer->setInlineStyleProperty(CSSPropertyTop, |
| 471 0.0, | 468 0.0, |
| 472 CSSPrimitiveValue::CSS_PX); | 469 CSSPrimitiveValue::CSS_PX); |
| 473 | 470 |
| 474 m_cueContainer->setPart(textTrackCueContainerShadowPseudoId()); | 471 m_cueContainer->setPart(textTrackCueContainerShadowPseudoId()); |
| 475 m_regionDisplayTree->appendChild(m_cueContainer); | 472 m_regionDisplayTree->appendChild(m_cueContainer); |
| 476 | 473 |
| 477 // 7.5 Every WebVTT region object is initialised with the following CSS | 474 // 7.5 Every WebVTT region object is initialised with the following CSS |
| 478 m_regionDisplayTree->setPart(textTrackRegionShadowPseudoId()); | 475 m_regionDisplayTree->setPart(textTrackRegionShadowPseudoId()); |
| 479 } | 476 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 499 | 496 |
| 500 void TextTrackRegion::scrollTimerFired(Timer<TextTrackRegion>*) | 497 void TextTrackRegion::scrollTimerFired(Timer<TextTrackRegion>*) |
| 501 { | 498 { |
| 502 LOG(Media, "TextTrackRegion::scrollTimerFired"); | 499 LOG(Media, "TextTrackRegion::scrollTimerFired"); |
| 503 | 500 |
| 504 stopTimer(); | 501 stopTimer(); |
| 505 displayLastTextTrackCueBox(); | 502 displayLastTextTrackCueBox(); |
| 506 } | 503 } |
| 507 | 504 |
| 508 } // namespace WebCore | 505 } // namespace WebCore |
| 509 | |
| 510 #endif | |
| OLD | NEW |