OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 22 matching lines...) Loading... |
33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
34 #include "core/InputTypeNames.h" | 34 #include "core/InputTypeNames.h" |
35 #include "core/dom/DOMTokenList.h" | 35 #include "core/dom/DOMTokenList.h" |
36 #include "core/dom/shadow/ShadowRoot.h" | 36 #include "core/dom/shadow/ShadowRoot.h" |
37 #include "core/events/MouseEvent.h" | 37 #include "core/events/MouseEvent.h" |
38 #include "core/frame/LocalFrame.h" | 38 #include "core/frame/LocalFrame.h" |
39 #include "core/html/HTMLVideoElement.h" | 39 #include "core/html/HTMLVideoElement.h" |
40 #include "core/html/MediaController.h" | 40 #include "core/html/MediaController.h" |
41 #include "core/html/TimeRanges.h" | 41 #include "core/html/TimeRanges.h" |
42 #include "core/html/shadow/MediaControls.h" | 42 #include "core/html/shadow/MediaControls.h" |
43 #include "core/html/track/CueTimeline.h" | |
44 #include "core/html/track/TextTrack.h" | |
45 #include "core/html/track/TextTrackCue.h" | |
46 #include "core/html/track/vtt/VTTRegionList.h" | |
47 #include "core/layout/LayoutSlider.h" | 43 #include "core/layout/LayoutSlider.h" |
48 #include "core/layout/LayoutTextTrackContainerElement.h" | |
49 #include "core/layout/LayoutTheme.h" | 44 #include "core/layout/LayoutTheme.h" |
50 #include "core/layout/LayoutVideo.h" | 45 #include "core/layout/LayoutVideo.h" |
51 #include "core/page/EventHandler.h" | 46 #include "core/page/EventHandler.h" |
52 #include "platform/RuntimeEnabledFeatures.h" | 47 #include "platform/RuntimeEnabledFeatures.h" |
53 | 48 |
54 namespace blink { | 49 namespace blink { |
55 | 50 |
56 using namespace HTMLNames; | 51 using namespace HTMLNames; |
57 | 52 |
58 // This is the duration from mediaControls.css | 53 // This is the duration from mediaControls.css |
(...skipping 537 matching lines...) Loading... |
596 { | 591 { |
597 } | 592 } |
598 | 593 |
599 PassRefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> MediaControlCurren
tTimeDisplayElement::create(MediaControls& mediaControls) | 594 PassRefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> MediaControlCurren
tTimeDisplayElement::create(MediaControls& mediaControls) |
600 { | 595 { |
601 RefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> element = adoptRef
WillBeNoop(new MediaControlCurrentTimeDisplayElement(mediaControls)); | 596 RefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> element = adoptRef
WillBeNoop(new MediaControlCurrentTimeDisplayElement(mediaControls)); |
602 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time
-display", AtomicString::ConstructFromLiteral)); | 597 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time
-display", AtomicString::ConstructFromLiteral)); |
603 return element.release(); | 598 return element.release(); |
604 } | 599 } |
605 | 600 |
606 // ---------------------------- | |
607 | |
608 MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement(Med
iaControls& mediaControls) | |
609 : MediaControlDivElement(mediaControls, MediaTextTrackDisplayContainer) | |
610 , m_fontSize(0) | |
611 { | |
612 } | |
613 | |
614 PassRefPtrWillBeRawPtr<MediaControlTextTrackContainerElement> MediaControlTextTr
ackContainerElement::create(MediaControls& mediaControls) | |
615 { | |
616 RefPtrWillBeRawPtr<MediaControlTextTrackContainerElement> element = adoptRef
WillBeNoop(new MediaControlTextTrackContainerElement(mediaControls)); | |
617 element->setShadowPseudoId(AtomicString("-webkit-media-text-track-container"
, AtomicString::ConstructFromLiteral)); | |
618 element->hide(); | |
619 return element.release(); | |
620 } | |
621 | |
622 LayoutObject* MediaControlTextTrackContainerElement::createRenderer(const Layout
Style&) | |
623 { | |
624 return new LayoutTextTrackContainerElement(this); | |
625 } | |
626 | |
627 void MediaControlTextTrackContainerElement::updateDisplay() | |
628 { | |
629 if (!mediaElement().closedCaptionsVisible()) { | |
630 removeChildren(); | |
631 return; | |
632 } | |
633 | |
634 // 1. If the media element is an audio element, or is another playback | |
635 // mechanism with no rendering area, abort these steps. There is nothing to | |
636 // render. | |
637 if (isHTMLAudioElement(mediaElement())) | |
638 return; | |
639 | |
640 // 2. Let video be the media element or other playback mechanism. | |
641 HTMLVideoElement& video = toHTMLVideoElement(mediaElement()); | |
642 | |
643 // 3. Let output be an empty list of absolutely positioned CSS block boxes. | |
644 | |
645 // 4. If the user agent is exposing a user interface for video, add to | |
646 // output one or more completely transparent positioned CSS block boxes that | |
647 // cover the same region as the user interface. | |
648 | |
649 // 5. If the last time these rules were run, the user agent was not exposing | |
650 // a user interface for video, but now it is, let reset be true. Otherwise, | |
651 // let reset be false. | |
652 | |
653 // There is nothing to be done explicitly for 4th and 5th steps, as | |
654 // everything is handled through CSS. The caption box is on top of the | |
655 // controls box, in a container set with the -webkit-box display property. | |
656 | |
657 // 6. Let tracks be the subset of video's list of text tracks that have as | |
658 // their rules for updating the text track rendering these rules for | |
659 // updating the display of WebVTT text tracks, and whose text track mode is | |
660 // showing or showing by default. | |
661 // 7. Let cues be an empty list of text track cues. | |
662 // 8. For each track track in tracks, append to cues all the cues from | |
663 // track's list of cues that have their text track cue active flag set. | |
664 CueList activeCues = video.cueTimeline().currentlyActiveCues(); | |
665 | |
666 // 9. If reset is false, then, for each text track cue cue in cues: if cue's | |
667 // text track cue display state has a set of CSS boxes, then add those boxes | |
668 // to output, and remove cue from cues. | |
669 | |
670 // There is nothing explicitly to be done here, as all the caching occurs | |
671 // within the TextTrackCue instance itself. If parameters of the cue change, | |
672 // the display tree is cleared. | |
673 | |
674 // 10. For each text track cue cue in cues that has not yet had | |
675 // corresponding CSS boxes added to output, in text track cue order, run the | |
676 // following substeps: | |
677 for (size_t i = 0; i < activeCues.size(); ++i) { | |
678 TextTrackCue* cue = activeCues[i].data(); | |
679 | |
680 ASSERT(cue->isActive()); | |
681 if (!cue->track() || !cue->track()->isRendered() || !cue->isActive()) | |
682 continue; | |
683 | |
684 cue->updateDisplay(*this); | |
685 } | |
686 | |
687 // 11. Return output. | |
688 if (hasChildren()) | |
689 show(); | |
690 else | |
691 hide(); | |
692 } | |
693 | |
694 void MediaControlTextTrackContainerElement::updateSizes() | |
695 { | |
696 if (!document().isActive()) | |
697 return; | |
698 | |
699 IntRect videoBox; | |
700 | |
701 if (!mediaElement().renderer() || !mediaElement().renderer()->isVideo()) | |
702 return; | |
703 videoBox = toLayoutVideo(mediaElement().renderer())->videoBox(); | |
704 | |
705 if (m_videoDisplaySize == videoBox) | |
706 return; | |
707 m_videoDisplaySize = videoBox; | |
708 | |
709 float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_vid
eoDisplaySize.size().width()); | |
710 | |
711 float fontSize = smallestDimension * 0.05f; | |
712 if (fontSize != m_fontSize) { | |
713 m_fontSize = fontSize; | |
714 setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue:
:CSS_PX); | |
715 } | |
716 } | |
717 | |
718 // ---------------------------- | |
719 | |
720 } // namespace blink | 601 } // namespace blink |
OLD | NEW |