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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 } | 295 } |
296 | 296 |
297 HTMLInputElement::defaultEventHandler(event); | 297 HTMLInputElement::defaultEventHandler(event); |
298 } | 298 } |
299 | 299 |
300 void MediaControlMuteButtonElement::updateDisplayType() | 300 void MediaControlMuteButtonElement::updateDisplayType() |
301 { | 301 { |
302 setDisplayType(mediaElement().muted() ? MediaUnMuteButton : MediaMuteButton) ; | 302 setDisplayType(mediaElement().muted() ? MediaUnMuteButton : MediaMuteButton) ; |
303 } | 303 } |
304 | 304 |
305 WebLocalizedString::Name MediaControlMuteButtonElement::getOverflowStringName() | |
306 { | |
307 if (mediaElement().muted()) | |
308 return WebLocalizedString::OverflowMenuUnmute; | |
309 return WebLocalizedString::OverflowMenuMute; | |
310 } | |
311 | |
312 MediaControlInputElement* MediaControlMuteButtonElement::createOverflowButton(Me diaControls& mediaControls) | |
313 { | |
314 return MediaControlMuteButtonElement::create(mediaControls); | |
liberato (no reviews please)
2016/08/30 16:42:07
now that we've successfully reduced this to one li
kdsilva
2016/08/31 00:17:05
Done.
| |
315 } | |
316 | |
305 // ---------------------------- | 317 // ---------------------------- |
306 | 318 |
307 MediaControlPlayButtonElement::MediaControlPlayButtonElement(MediaControls& medi aControls) | 319 MediaControlPlayButtonElement::MediaControlPlayButtonElement(MediaControls& medi aControls) |
308 : MediaControlInputElement(mediaControls, MediaPlayButton) | 320 : MediaControlInputElement(mediaControls, MediaPlayButton) |
309 { | 321 { |
310 } | 322 } |
311 | 323 |
312 MediaControlPlayButtonElement* MediaControlPlayButtonElement::create(MediaContro ls& mediaControls) | 324 MediaControlPlayButtonElement* MediaControlPlayButtonElement::create(MediaContro ls& mediaControls) |
313 { | 325 { |
314 MediaControlPlayButtonElement* button = new MediaControlPlayButtonElement(me diaControls); | 326 MediaControlPlayButtonElement* button = new MediaControlPlayButtonElement(me diaControls); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 | 412 |
401 void MediaControlToggleClosedCaptionsButtonElement::updateDisplayType() | 413 void MediaControlToggleClosedCaptionsButtonElement::updateDisplayType() |
402 { | 414 { |
403 bool captionsVisible = mediaElement().textTracksVisible(); | 415 bool captionsVisible = mediaElement().textTracksVisible(); |
404 setDisplayType(captionsVisible ? MediaHideClosedCaptionsButton : MediaShowCl osedCaptionsButton); | 416 setDisplayType(captionsVisible ? MediaHideClosedCaptionsButton : MediaShowCl osedCaptionsButton); |
405 } | 417 } |
406 | 418 |
407 void MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler(Event* e vent) | 419 void MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler(Event* e vent) |
408 { | 420 { |
409 if (event->type() == EventTypeNames::click) { | 421 if (event->type() == EventTypeNames::click) { |
422 if (mediaControls().overflowMenuVisible()) | |
423 mediaControls().toggleOverflowMenu(); | |
410 mediaControls().toggleTextTrackList(); | 424 mediaControls().toggleTextTrackList(); |
411 updateDisplayType(); | 425 updateDisplayType(); |
412 event->setDefaultHandled(); | 426 event->setDefaultHandled(); |
413 } | 427 } |
414 | 428 |
415 HTMLInputElement::defaultEventHandler(event); | 429 HTMLInputElement::defaultEventHandler(event); |
416 } | 430 } |
417 | 431 |
432 WebLocalizedString::Name MediaControlToggleClosedCaptionsButtonElement::getOverf lowStringName() | |
433 { | |
434 return WebLocalizedString::OverflowMenuCaptions; | |
435 } | |
436 | |
437 MediaControlInputElement* MediaControlToggleClosedCaptionsButtonElement::createO verflowButton(MediaControls& mediaControls) | |
438 { | |
439 return MediaControlToggleClosedCaptionsButtonElement::create(mediaControls); | |
440 } | |
441 | |
418 // ---------------------------- | 442 // ---------------------------- |
419 | 443 |
420 MediaControlTextTrackListElement::MediaControlTextTrackListElement(MediaControls & mediaControls) | 444 MediaControlTextTrackListElement::MediaControlTextTrackListElement(MediaControls & mediaControls) |
421 : MediaControlDivElement(mediaControls, MediaTextTrackList) | 445 : MediaControlDivElement(mediaControls, MediaTextTrackList) |
422 { | 446 { |
423 } | 447 } |
424 | 448 |
425 MediaControlTextTrackListElement* MediaControlTextTrackListElement::create(Media Controls& mediaControls) | 449 MediaControlTextTrackListElement* MediaControlTextTrackListElement::create(Media Controls& mediaControls) |
426 { | 450 { |
427 MediaControlTextTrackListElement* element = new MediaControlTextTrackListEle ment(mediaControls); | 451 MediaControlTextTrackListElement* element = new MediaControlTextTrackListEle ment(mediaControls); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 TextTrackList* trackList = mediaElement().textTracks(); | 571 TextTrackList* trackList = mediaElement().textTracks(); |
548 for (unsigned i = 0; i < trackList->length(); i++) { | 572 for (unsigned i = 0; i < trackList->length(); i++) { |
549 TextTrack* track = trackList->anonymousIndexedGetter(i); | 573 TextTrack* track = trackList->anonymousIndexedGetter(i); |
550 if (!track->canBeRendered()) | 574 if (!track->canBeRendered()) |
551 continue; | 575 continue; |
552 appendChild(createTextTrackListItem(track)); | 576 appendChild(createTextTrackListItem(track)); |
553 } | 577 } |
554 } | 578 } |
555 | 579 |
556 // ---------------------------- | 580 // ---------------------------- |
581 MediaControlOverflowMenuButtonElement::MediaControlOverflowMenuButtonElement(Med iaControls& mediaControls) | |
582 : MediaControlInputElement(mediaControls, MediaShowClosedCaptionsButton) | |
583 { | |
584 } | |
585 | |
586 MediaControlOverflowMenuButtonElement* MediaControlOverflowMenuButtonElement::cr eate(MediaControls& mediaControls) | |
587 { | |
588 MediaControlOverflowMenuButtonElement* button = new MediaControlOverflowMenu ButtonElement(mediaControls); | |
589 button->ensureUserAgentShadowRoot(); | |
590 button->setType(InputTypeNames::button); | |
591 button->setShadowPseudoId(AtomicString("-internal-overflow-menu-button")); | |
592 button->setIsWanted(false); | |
593 return button; | |
594 } | |
595 | |
596 void MediaControlOverflowMenuButtonElement::defaultEventHandler(Event* event) | |
597 { | |
598 if (event->type() == EventTypeNames::click) { | |
599 mediaControls().toggleOverflowMenu(); | |
600 event->setDefaultHandled(); | |
601 } | |
602 | |
603 HTMLInputElement::defaultEventHandler(event); | |
604 } | |
605 | |
606 // ---------------------------- | |
607 MediaControlOverflowMenuListElement::MediaControlOverflowMenuListElement(MediaCo ntrols& mediaControls) | |
608 : MediaControlDivElement(mediaControls, MediaShowClosedCaptionsButton) | |
609 { | |
610 } | |
611 | |
612 MediaControlOverflowMenuListElement* MediaControlOverflowMenuListElement::create (MediaControls& mediaControls) | |
613 { | |
614 MediaControlOverflowMenuListElement* element = new MediaControlOverflowMenuL istElement(mediaControls); | |
615 element->setIsWanted(false); | |
616 element->setShadowPseudoId(AtomicString("-internal-media-controls-overflow-m enu-list")); | |
617 return element; | |
618 } | |
619 | |
620 void MediaControlOverflowMenuListElement::showOverflowMenu(bool visible) | |
621 { | |
622 setIsWanted(visible); | |
623 } | |
624 | |
625 void MediaControlOverflowMenuListElement::defaultEventHandler(Event* event) | |
626 { | |
627 if (event->type() == EventTypeNames::click) | |
628 event->setDefaultHandled(); | |
629 | |
630 MediaControlDivElement::defaultEventHandler(event); | |
631 } | |
632 | |
633 // ---------------------------- | |
557 | 634 |
558 MediaControlTimelineElement::MediaControlTimelineElement(MediaControls& mediaCon trols) | 635 MediaControlTimelineElement::MediaControlTimelineElement(MediaControls& mediaCon trols) |
559 : MediaControlInputElement(mediaControls, MediaSlider) | 636 : MediaControlInputElement(mediaControls, MediaSlider) |
560 { | 637 { |
561 } | 638 } |
562 | 639 |
563 MediaControlTimelineElement* MediaControlTimelineElement::create(MediaControls& mediaControls) | 640 MediaControlTimelineElement* MediaControlTimelineElement::create(MediaControls& mediaControls) |
564 { | 641 { |
565 MediaControlTimelineElement* timeline = new MediaControlTimelineElement(medi aControls); | 642 MediaControlTimelineElement* timeline = new MediaControlTimelineElement(medi aControls); |
566 timeline->ensureUserAgentShadowRoot(); | 643 timeline->ensureUserAgentShadowRoot(); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
731 event->setDefaultHandled(); | 808 event->setDefaultHandled(); |
732 } | 809 } |
733 HTMLInputElement::defaultEventHandler(event); | 810 HTMLInputElement::defaultEventHandler(event); |
734 } | 811 } |
735 | 812 |
736 void MediaControlFullscreenButtonElement::setIsFullscreen(bool isFullscreen) | 813 void MediaControlFullscreenButtonElement::setIsFullscreen(bool isFullscreen) |
737 { | 814 { |
738 setDisplayType(isFullscreen ? MediaExitFullscreenButton : MediaEnterFullscre enButton); | 815 setDisplayType(isFullscreen ? MediaExitFullscreenButton : MediaEnterFullscre enButton); |
739 } | 816 } |
740 | 817 |
818 WebLocalizedString::Name MediaControlFullscreenButtonElement::getOverflowStringN ame() | |
819 { | |
820 return WebLocalizedString::OverflowMenuFullscreen; | |
821 } | |
822 MediaControlInputElement* MediaControlFullscreenButtonElement::createOverflowBut ton(MediaControls& mediaControls) | |
823 { | |
824 return MediaControlFullscreenButtonElement::create(mediaControls); | |
825 } | |
826 | |
741 // ---------------------------- | 827 // ---------------------------- |
742 | 828 |
743 MediaControlCastButtonElement::MediaControlCastButtonElement(MediaControls& medi aControls, bool isOverlayButton) | 829 MediaControlCastButtonElement::MediaControlCastButtonElement(MediaControls& medi aControls, bool isOverlayButton) |
744 : MediaControlInputElement(mediaControls, MediaCastOnButton), m_isOverlayBut ton(isOverlayButton) | 830 : MediaControlInputElement(mediaControls, MediaCastOnButton), m_isOverlayBut ton(isOverlayButton) |
745 { | 831 { |
746 if (m_isOverlayButton) | 832 if (m_isOverlayButton) |
747 recordMetrics(CastOverlayMetrics::Created); | 833 recordMetrics(CastOverlayMetrics::Created); |
748 setIsPlayingRemotely(false); | 834 setIsPlayingRemotely(false); |
749 } | 835 } |
750 | 836 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
794 } | 880 } |
795 } else { | 881 } else { |
796 if (m_isOverlayButton) { | 882 if (m_isOverlayButton) { |
797 setDisplayType(MediaOverlayCastOffButton); | 883 setDisplayType(MediaOverlayCastOffButton); |
798 } else { | 884 } else { |
799 setDisplayType(MediaCastOffButton); | 885 setDisplayType(MediaCastOffButton); |
800 } | 886 } |
801 } | 887 } |
802 } | 888 } |
803 | 889 |
890 WebLocalizedString::Name MediaControlCastButtonElement::getOverflowStringName() | |
891 { | |
892 if (mediaElement().isPlayingRemotely()) | |
893 return WebLocalizedString::OverflowMenuStopCast; | |
894 return WebLocalizedString::OverflowMenuCast; | |
895 } | |
896 | |
804 void MediaControlCastButtonElement::tryShowOverlay() | 897 void MediaControlCastButtonElement::tryShowOverlay() |
805 { | 898 { |
806 DCHECK(m_isOverlayButton); | 899 DCHECK(m_isOverlayButton); |
807 | 900 |
808 setIsWanted(true); | 901 setIsWanted(true); |
809 if (elementFromCenter(*this) != &mediaElement()) { | 902 if (elementFromCenter(*this) != &mediaElement()) { |
810 setIsWanted(false); | 903 setIsWanted(false); |
811 return; | 904 return; |
812 } | 905 } |
813 | 906 |
814 DCHECK(isWanted()); | 907 DCHECK(isWanted()); |
815 if (!m_showUseCounted) { | 908 if (!m_showUseCounted) { |
816 m_showUseCounted = true; | 909 m_showUseCounted = true; |
817 recordMetrics(CastOverlayMetrics::Shown); | 910 recordMetrics(CastOverlayMetrics::Shown); |
818 } | 911 } |
819 } | 912 } |
820 | 913 |
821 bool MediaControlCastButtonElement::keepEventInNode(Event* event) | 914 bool MediaControlCastButtonElement::keepEventInNode(Event* event) |
822 { | 915 { |
823 return isUserInteractionEvent(event); | 916 return isUserInteractionEvent(event); |
824 } | 917 } |
825 | 918 |
826 void MediaControlCastButtonElement::recordMetrics(CastOverlayMetrics metric) | 919 void MediaControlCastButtonElement::recordMetrics(CastOverlayMetrics metric) |
827 { | 920 { |
828 DCHECK(m_isOverlayButton); | 921 DCHECK(m_isOverlayButton); |
829 DEFINE_STATIC_LOCAL(EnumerationHistogram, overlayHistogram, ("Cast.Sender.Ov erlay", static_cast<int>(CastOverlayMetrics::Count))); | 922 DEFINE_STATIC_LOCAL(EnumerationHistogram, overlayHistogram, ("Cast.Sender.Ov erlay", static_cast<int>(CastOverlayMetrics::Count))); |
830 overlayHistogram.count(static_cast<int>(metric)); | 923 overlayHistogram.count(static_cast<int>(metric)); |
831 } | 924 } |
832 | 925 |
926 MediaControlInputElement* MediaControlCastButtonElement::createOverflowButton(Me diaControls& mediaControls) | |
927 { | |
928 return MediaControlCastButtonElement::create(mediaControls, false); | |
929 } | |
930 | |
833 // ---------------------------- | 931 // ---------------------------- |
834 | 932 |
835 MediaControlTimeRemainingDisplayElement::MediaControlTimeRemainingDisplayElement (MediaControls& mediaControls) | 933 MediaControlTimeRemainingDisplayElement::MediaControlTimeRemainingDisplayElement (MediaControls& mediaControls) |
836 : MediaControlTimeDisplayElement(mediaControls, MediaTimeRemainingDisplay) | 934 : MediaControlTimeDisplayElement(mediaControls, MediaTimeRemainingDisplay) |
837 { | 935 { |
838 } | 936 } |
839 | 937 |
840 MediaControlTimeRemainingDisplayElement* MediaControlTimeRemainingDisplayElement ::create(MediaControls& mediaControls) | 938 MediaControlTimeRemainingDisplayElement* MediaControlTimeRemainingDisplayElement ::create(MediaControls& mediaControls) |
841 { | 939 { |
842 MediaControlTimeRemainingDisplayElement* element = new MediaControlTimeRemai ningDisplayElement(mediaControls); | 940 MediaControlTimeRemainingDisplayElement* element = new MediaControlTimeRemai ningDisplayElement(mediaControls); |
843 element->setShadowPseudoId(AtomicString("-webkit-media-controls-time-remaini ng-display")); | 941 element->setShadowPseudoId(AtomicString("-webkit-media-controls-time-remaini ng-display")); |
844 return element; | 942 return element; |
845 } | 943 } |
846 | 944 |
847 // ---------------------------- | 945 // ---------------------------- |
848 | 946 |
849 MediaControlCurrentTimeDisplayElement::MediaControlCurrentTimeDisplayElement(Med iaControls& mediaControls) | 947 MediaControlCurrentTimeDisplayElement::MediaControlCurrentTimeDisplayElement(Med iaControls& mediaControls) |
850 : MediaControlTimeDisplayElement(mediaControls, MediaCurrentTimeDisplay) | 948 : MediaControlTimeDisplayElement(mediaControls, MediaCurrentTimeDisplay) |
851 { | 949 { |
852 } | 950 } |
853 | 951 |
854 MediaControlCurrentTimeDisplayElement* MediaControlCurrentTimeDisplayElement::cr eate(MediaControls& mediaControls) | 952 MediaControlCurrentTimeDisplayElement* MediaControlCurrentTimeDisplayElement::cr eate(MediaControls& mediaControls) |
855 { | 953 { |
856 MediaControlCurrentTimeDisplayElement* element = new MediaControlCurrentTime DisplayElement(mediaControls); | 954 MediaControlCurrentTimeDisplayElement* element = new MediaControlCurrentTime DisplayElement(mediaControls); |
857 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time -display")); | 955 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time -display")); |
858 return element; | 956 return element; |
859 } | 957 } |
860 | 958 |
861 } // namespace blink | 959 } // namespace blink |
OLD | NEW |