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