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 Element* MediaControlMuteButtonElement::initOverflowButton(MediaControls& mediaC ontrols) | |
313 { | |
314 MediaControlMuteButtonElement* button = MediaControlMuteButtonElement::creat e(mediaControls); | |
315 button->setShadowPseudoId(AtomicString("-internal-media-controls-overflow-me nu-list-item-element")); | |
liberato (no reviews please)
2016/08/29 17:38:38
this and setIsWanted seem to be everywhere -- can
kdsilva
2016/08/29 20:44:13
Done.
| |
316 button->setIsWanted(true); | |
317 | |
318 m_overflowMenuElement = createOverflowMenuElement(mediaControls, button); | |
319 return m_overflowMenuElement; | |
320 } | |
321 | |
305 // ---------------------------- | 322 // ---------------------------- |
306 | 323 |
307 MediaControlPlayButtonElement::MediaControlPlayButtonElement(MediaControls& medi aControls) | 324 MediaControlPlayButtonElement::MediaControlPlayButtonElement(MediaControls& medi aControls) |
308 : MediaControlInputElement(mediaControls, MediaPlayButton) | 325 : MediaControlInputElement(mediaControls, MediaPlayButton) |
309 { | 326 { |
310 } | 327 } |
311 | 328 |
312 MediaControlPlayButtonElement* MediaControlPlayButtonElement::create(MediaContro ls& mediaControls) | 329 MediaControlPlayButtonElement* MediaControlPlayButtonElement::create(MediaContro ls& mediaControls) |
313 { | 330 { |
314 MediaControlPlayButtonElement* button = new MediaControlPlayButtonElement(me diaControls); | 331 MediaControlPlayButtonElement* button = new MediaControlPlayButtonElement(me diaControls); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 | 417 |
401 void MediaControlToggleClosedCaptionsButtonElement::updateDisplayType() | 418 void MediaControlToggleClosedCaptionsButtonElement::updateDisplayType() |
402 { | 419 { |
403 bool captionsVisible = mediaElement().textTracksVisible(); | 420 bool captionsVisible = mediaElement().textTracksVisible(); |
404 setDisplayType(captionsVisible ? MediaHideClosedCaptionsButton : MediaShowCl osedCaptionsButton); | 421 setDisplayType(captionsVisible ? MediaHideClosedCaptionsButton : MediaShowCl osedCaptionsButton); |
405 } | 422 } |
406 | 423 |
407 void MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler(Event* e vent) | 424 void MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler(Event* e vent) |
408 { | 425 { |
409 if (event->type() == EventTypeNames::click) { | 426 if (event->type() == EventTypeNames::click) { |
427 if (mediaControls().overflowMenuVisible()) | |
428 mediaControls().toggleOverflowMenu(); | |
410 mediaControls().toggleTextTrackList(); | 429 mediaControls().toggleTextTrackList(); |
411 updateDisplayType(); | 430 updateDisplayType(); |
412 event->setDefaultHandled(); | 431 event->setDefaultHandled(); |
413 } | 432 } |
414 | 433 |
415 HTMLInputElement::defaultEventHandler(event); | 434 HTMLInputElement::defaultEventHandler(event); |
416 } | 435 } |
417 | 436 |
437 WebLocalizedString::Name MediaControlToggleClosedCaptionsButtonElement::getOverf lowStringName() | |
438 { | |
439 return WebLocalizedString::OverflowMenuCaptions; | |
440 } | |
441 | |
442 Element* MediaControlToggleClosedCaptionsButtonElement::initOverflowButton(Media Controls& mediaControls) | |
443 { | |
444 MediaControlToggleClosedCaptionsButtonElement* button = MediaControlToggleCl osedCaptionsButtonElement::create(mediaControls); | |
445 button->setShadowPseudoId(AtomicString("-internal-media-controls-overflow-me nu-list-item-element")); | |
446 button->setIsWanted(true); | |
447 | |
448 m_overflowMenuElement = createOverflowMenuElement(mediaControls, button); | |
449 return m_overflowMenuElement; | |
450 } | |
451 | |
418 // ---------------------------- | 452 // ---------------------------- |
419 | 453 |
420 MediaControlTextTrackListElement::MediaControlTextTrackListElement(MediaControls & mediaControls) | 454 MediaControlTextTrackListElement::MediaControlTextTrackListElement(MediaControls & mediaControls) |
421 : MediaControlDivElement(mediaControls, MediaTextTrackList) | 455 : MediaControlDivElement(mediaControls, MediaTextTrackList) |
422 { | 456 { |
423 } | 457 } |
424 | 458 |
425 MediaControlTextTrackListElement* MediaControlTextTrackListElement::create(Media Controls& mediaControls) | 459 MediaControlTextTrackListElement* MediaControlTextTrackListElement::create(Media Controls& mediaControls) |
426 { | 460 { |
427 MediaControlTextTrackListElement* element = new MediaControlTextTrackListEle ment(mediaControls); | 461 MediaControlTextTrackListElement* element = new MediaControlTextTrackListEle ment(mediaControls); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 TextTrackList* trackList = mediaElement().textTracks(); | 581 TextTrackList* trackList = mediaElement().textTracks(); |
548 for (unsigned i = 0; i < trackList->length(); i++) { | 582 for (unsigned i = 0; i < trackList->length(); i++) { |
549 TextTrack* track = trackList->anonymousIndexedGetter(i); | 583 TextTrack* track = trackList->anonymousIndexedGetter(i); |
550 if (!track->canBeRendered()) | 584 if (!track->canBeRendered()) |
551 continue; | 585 continue; |
552 appendChild(createTextTrackListItem(track)); | 586 appendChild(createTextTrackListItem(track)); |
553 } | 587 } |
554 } | 588 } |
555 | 589 |
556 // ---------------------------- | 590 // ---------------------------- |
591 MediaControlOverflowMenuButtonElement::MediaControlOverflowMenuButtonElement(Med iaControls& mediaControls) | |
592 : MediaControlInputElement(mediaControls, MediaShowClosedCaptionsButton) | |
593 { | |
594 } | |
595 | |
596 MediaControlOverflowMenuButtonElement* MediaControlOverflowMenuButtonElement::cr eate(MediaControls& mediaControls) | |
597 { | |
598 MediaControlOverflowMenuButtonElement* button = new MediaControlOverflowMenu ButtonElement(mediaControls); | |
599 button->ensureUserAgentShadowRoot(); | |
600 button->setType(InputTypeNames::button); | |
601 button->setShadowPseudoId(AtomicString("-internal-overflow-menu-button")); | |
602 button->setIsWanted(false); | |
603 return button; | |
604 } | |
605 | |
606 void MediaControlOverflowMenuButtonElement::defaultEventHandler(Event* event) | |
607 { | |
608 if (event->type() == EventTypeNames::click) { | |
609 mediaControls().toggleOverflowMenu(); | |
610 event->setDefaultHandled(); | |
611 } | |
612 | |
613 HTMLInputElement::defaultEventHandler(event); | |
614 } | |
615 | |
616 // ---------------------------- | |
617 MediaControlOverflowMenuListElement::MediaControlOverflowMenuListElement(MediaCo ntrols& mediaControls) | |
618 : MediaControlDivElement(mediaControls, MediaShowClosedCaptionsButton) | |
619 { | |
620 } | |
621 | |
622 MediaControlOverflowMenuListElement* MediaControlOverflowMenuListElement::create (MediaControls& mediaControls) | |
623 { | |
624 MediaControlOverflowMenuListElement* element = new MediaControlOverflowMenuL istElement(mediaControls); | |
625 element->setIsWanted(false); | |
626 element->setShadowPseudoId(AtomicString("-internal-media-controls-overflow-m enu-list")); | |
627 return element; | |
628 } | |
629 | |
630 void MediaControlOverflowMenuListElement::showOverflowMenu(bool visible) | |
631 { | |
632 setIsWanted(visible); | |
633 } | |
634 | |
635 void MediaControlOverflowMenuListElement::defaultEventHandler(Event* event) | |
636 { | |
637 if (event->type() == EventTypeNames::click) | |
638 event->setDefaultHandled(); | |
639 | |
640 MediaControlDivElement::defaultEventHandler(event); | |
641 } | |
642 | |
643 // ---------------------------- | |
557 | 644 |
558 MediaControlTimelineElement::MediaControlTimelineElement(MediaControls& mediaCon trols) | 645 MediaControlTimelineElement::MediaControlTimelineElement(MediaControls& mediaCon trols) |
559 : MediaControlInputElement(mediaControls, MediaSlider) | 646 : MediaControlInputElement(mediaControls, MediaSlider) |
560 { | 647 { |
561 } | 648 } |
562 | 649 |
563 MediaControlTimelineElement* MediaControlTimelineElement::create(MediaControls& mediaControls) | 650 MediaControlTimelineElement* MediaControlTimelineElement::create(MediaControls& mediaControls) |
564 { | 651 { |
565 MediaControlTimelineElement* timeline = new MediaControlTimelineElement(medi aControls); | 652 MediaControlTimelineElement* timeline = new MediaControlTimelineElement(medi aControls); |
566 timeline->ensureUserAgentShadowRoot(); | 653 timeline->ensureUserAgentShadowRoot(); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
731 event->setDefaultHandled(); | 818 event->setDefaultHandled(); |
732 } | 819 } |
733 HTMLInputElement::defaultEventHandler(event); | 820 HTMLInputElement::defaultEventHandler(event); |
734 } | 821 } |
735 | 822 |
736 void MediaControlFullscreenButtonElement::setIsFullscreen(bool isFullscreen) | 823 void MediaControlFullscreenButtonElement::setIsFullscreen(bool isFullscreen) |
737 { | 824 { |
738 setDisplayType(isFullscreen ? MediaExitFullscreenButton : MediaEnterFullscre enButton); | 825 setDisplayType(isFullscreen ? MediaExitFullscreenButton : MediaEnterFullscre enButton); |
739 } | 826 } |
740 | 827 |
828 WebLocalizedString::Name MediaControlFullscreenButtonElement::getOverflowStringN ame() | |
829 { | |
830 return WebLocalizedString::OverflowMenuFullscreen; | |
831 } | |
832 | |
833 Element* MediaControlFullscreenButtonElement::initOverflowButton(MediaControls& mediaControls) | |
834 { | |
835 MediaControlFullscreenButtonElement* button = MediaControlFullscreenButtonEl ement::create(mediaControls); | |
836 button->setShadowPseudoId(AtomicString("-internal-media-controls-overflow-me nu-list-item-element")); | |
837 button->setIsWanted(true); | |
838 | |
839 m_overflowMenuElement = createOverflowMenuElement(mediaControls, button); | |
liberato (no reviews please)
2016/08/29 17:38:38
can createoverflowMenuElement set |m_overflowMenuE
kdsilva
2016/08/29 20:44:13
Done.
| |
840 return m_overflowMenuElement; | |
841 } | |
842 | |
741 // ---------------------------- | 843 // ---------------------------- |
742 | 844 |
743 MediaControlCastButtonElement::MediaControlCastButtonElement(MediaControls& medi aControls, bool isOverlayButton) | 845 MediaControlCastButtonElement::MediaControlCastButtonElement(MediaControls& medi aControls, bool isOverlayButton) |
744 : MediaControlInputElement(mediaControls, MediaCastOnButton), m_isOverlayBut ton(isOverlayButton) | 846 : MediaControlInputElement(mediaControls, MediaCastOnButton), m_isOverlayBut ton(isOverlayButton) |
745 { | 847 { |
746 if (m_isOverlayButton) | 848 if (m_isOverlayButton) |
747 recordMetrics(CastOverlayMetrics::Created); | 849 recordMetrics(CastOverlayMetrics::Created); |
748 setIsPlayingRemotely(false); | 850 setIsPlayingRemotely(false); |
749 } | 851 } |
750 | 852 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
794 } | 896 } |
795 } else { | 897 } else { |
796 if (m_isOverlayButton) { | 898 if (m_isOverlayButton) { |
797 setDisplayType(MediaOverlayCastOffButton); | 899 setDisplayType(MediaOverlayCastOffButton); |
798 } else { | 900 } else { |
799 setDisplayType(MediaCastOffButton); | 901 setDisplayType(MediaCastOffButton); |
800 } | 902 } |
801 } | 903 } |
802 } | 904 } |
803 | 905 |
906 WebLocalizedString::Name MediaControlCastButtonElement::getOverflowStringName() | |
907 { | |
908 if (mediaElement().isPlayingRemotely()) | |
909 return WebLocalizedString::OverflowMenuStopCast; | |
910 return WebLocalizedString::OverflowMenuCast; | |
911 } | |
912 | |
804 void MediaControlCastButtonElement::tryShowOverlay() | 913 void MediaControlCastButtonElement::tryShowOverlay() |
805 { | 914 { |
806 DCHECK(m_isOverlayButton); | 915 DCHECK(m_isOverlayButton); |
807 | 916 |
808 setIsWanted(true); | 917 setIsWanted(true); |
809 if (elementFromCenter(*this) != &mediaElement()) { | 918 if (elementFromCenter(*this) != &mediaElement()) { |
810 setIsWanted(false); | 919 setIsWanted(false); |
811 return; | 920 return; |
812 } | 921 } |
813 | 922 |
814 DCHECK(isWanted()); | 923 DCHECK(isWanted()); |
815 if (!m_showUseCounted) { | 924 if (!m_showUseCounted) { |
816 m_showUseCounted = true; | 925 m_showUseCounted = true; |
817 recordMetrics(CastOverlayMetrics::Shown); | 926 recordMetrics(CastOverlayMetrics::Shown); |
818 } | 927 } |
819 } | 928 } |
820 | 929 |
821 bool MediaControlCastButtonElement::keepEventInNode(Event* event) | 930 bool MediaControlCastButtonElement::keepEventInNode(Event* event) |
822 { | 931 { |
823 return isUserInteractionEvent(event); | 932 return isUserInteractionEvent(event); |
824 } | 933 } |
825 | 934 |
826 void MediaControlCastButtonElement::recordMetrics(CastOverlayMetrics metric) | 935 void MediaControlCastButtonElement::recordMetrics(CastOverlayMetrics metric) |
827 { | 936 { |
828 DCHECK(m_isOverlayButton); | 937 DCHECK(m_isOverlayButton); |
829 DEFINE_STATIC_LOCAL(EnumerationHistogram, overlayHistogram, ("Cast.Sender.Ov erlay", static_cast<int>(CastOverlayMetrics::Count))); | 938 DEFINE_STATIC_LOCAL(EnumerationHistogram, overlayHistogram, ("Cast.Sender.Ov erlay", static_cast<int>(CastOverlayMetrics::Count))); |
830 overlayHistogram.count(static_cast<int>(metric)); | 939 overlayHistogram.count(static_cast<int>(metric)); |
831 } | 940 } |
832 | 941 |
942 Element* MediaControlCastButtonElement::initOverflowButton(MediaControls& mediaC ontrols) | |
943 { | |
944 MediaControlCastButtonElement* button = MediaControlCastButtonElement::creat e(mediaControls, false); | |
945 button->setShadowPseudoId(AtomicString("-internal-media-controls-overflow-me nu-list-item-element")); | |
946 button->setIsWanted(true); | |
947 | |
948 m_overflowMenuElement = createOverflowMenuElement(mediaControls, button); | |
949 return m_overflowMenuElement; | |
950 } | |
951 | |
833 // ---------------------------- | 952 // ---------------------------- |
834 | 953 |
835 MediaControlTimeRemainingDisplayElement::MediaControlTimeRemainingDisplayElement (MediaControls& mediaControls) | 954 MediaControlTimeRemainingDisplayElement::MediaControlTimeRemainingDisplayElement (MediaControls& mediaControls) |
836 : MediaControlTimeDisplayElement(mediaControls, MediaTimeRemainingDisplay) | 955 : MediaControlTimeDisplayElement(mediaControls, MediaTimeRemainingDisplay) |
837 { | 956 { |
838 } | 957 } |
839 | 958 |
840 MediaControlTimeRemainingDisplayElement* MediaControlTimeRemainingDisplayElement ::create(MediaControls& mediaControls) | 959 MediaControlTimeRemainingDisplayElement* MediaControlTimeRemainingDisplayElement ::create(MediaControls& mediaControls) |
841 { | 960 { |
842 MediaControlTimeRemainingDisplayElement* element = new MediaControlTimeRemai ningDisplayElement(mediaControls); | 961 MediaControlTimeRemainingDisplayElement* element = new MediaControlTimeRemai ningDisplayElement(mediaControls); |
843 element->setShadowPseudoId(AtomicString("-webkit-media-controls-time-remaini ng-display")); | 962 element->setShadowPseudoId(AtomicString("-webkit-media-controls-time-remaini ng-display")); |
844 return element; | 963 return element; |
845 } | 964 } |
846 | 965 |
847 // ---------------------------- | 966 // ---------------------------- |
848 | 967 |
849 MediaControlCurrentTimeDisplayElement::MediaControlCurrentTimeDisplayElement(Med iaControls& mediaControls) | 968 MediaControlCurrentTimeDisplayElement::MediaControlCurrentTimeDisplayElement(Med iaControls& mediaControls) |
850 : MediaControlTimeDisplayElement(mediaControls, MediaCurrentTimeDisplay) | 969 : MediaControlTimeDisplayElement(mediaControls, MediaCurrentTimeDisplay) |
851 { | 970 { |
852 } | 971 } |
853 | 972 |
854 MediaControlCurrentTimeDisplayElement* MediaControlCurrentTimeDisplayElement::cr eate(MediaControls& mediaControls) | 973 MediaControlCurrentTimeDisplayElement* MediaControlCurrentTimeDisplayElement::cr eate(MediaControls& mediaControls) |
855 { | 974 { |
856 MediaControlCurrentTimeDisplayElement* element = new MediaControlCurrentTime DisplayElement(mediaControls); | 975 MediaControlCurrentTimeDisplayElement* element = new MediaControlCurrentTime DisplayElement(mediaControls); |
857 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time -display")); | 976 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time -display")); |
858 return element; | 977 return element; |
859 } | 978 } |
860 | 979 |
861 } // namespace blink | 980 } // namespace blink |
OLD | NEW |