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 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 | |
| 305 // ---------------------------- | 312 // ---------------------------- |
| 306 | 313 |
| 307 MediaControlPlayButtonElement::MediaControlPlayButtonElement(MediaControls& medi aControls) | 314 MediaControlPlayButtonElement::MediaControlPlayButtonElement(MediaControls& medi aControls) |
| 308 : MediaControlInputElement(mediaControls, MediaPlayButton) | 315 : MediaControlInputElement(mediaControls, MediaPlayButton) |
| 309 { | 316 { |
| 310 } | 317 } |
| 311 | 318 |
| 312 MediaControlPlayButtonElement* MediaControlPlayButtonElement::create(MediaContro ls& mediaControls) | 319 MediaControlPlayButtonElement* MediaControlPlayButtonElement::create(MediaContro ls& mediaControls) |
| 313 { | 320 { |
| 314 MediaControlPlayButtonElement* button = new MediaControlPlayButtonElement(me diaControls); | 321 MediaControlPlayButtonElement* button = new MediaControlPlayButtonElement(me diaControls); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 337 event->setDefaultHandled(); | 344 event->setDefaultHandled(); |
| 338 } | 345 } |
| 339 HTMLInputElement::defaultEventHandler(event); | 346 HTMLInputElement::defaultEventHandler(event); |
| 340 } | 347 } |
| 341 | 348 |
| 342 void MediaControlPlayButtonElement::updateDisplayType() | 349 void MediaControlPlayButtonElement::updateDisplayType() |
| 343 { | 350 { |
| 344 setDisplayType(mediaElement().paused() ? MediaPlayButton : MediaPauseButton) ; | 351 setDisplayType(mediaElement().paused() ? MediaPlayButton : MediaPauseButton) ; |
| 345 } | 352 } |
| 346 | 353 |
| 354 WebLocalizedString::Name MediaControlPlayButtonElement::getOverflowStringName() | |
| 355 { | |
| 356 if (mediaElement().paused()) | |
| 357 return WebLocalizedString::OverflowMenuPlay; | |
| 358 return WebLocalizedString::OverflowMenuPause; | |
| 359 } | |
| 360 | |
| 347 // ---------------------------- | 361 // ---------------------------- |
| 348 | 362 |
| 349 MediaControlOverlayPlayButtonElement::MediaControlOverlayPlayButtonElement(Media Controls& mediaControls) | 363 MediaControlOverlayPlayButtonElement::MediaControlOverlayPlayButtonElement(Media Controls& mediaControls) |
| 350 : MediaControlInputElement(mediaControls, MediaOverlayPlayButton) | 364 : MediaControlInputElement(mediaControls, MediaOverlayPlayButton) |
| 351 { | 365 { |
| 352 } | 366 } |
| 353 | 367 |
| 354 MediaControlOverlayPlayButtonElement* MediaControlOverlayPlayButtonElement::crea te(MediaControls& mediaControls) | 368 MediaControlOverlayPlayButtonElement* MediaControlOverlayPlayButtonElement::crea te(MediaControls& mediaControls) |
| 355 { | 369 { |
| 356 MediaControlOverlayPlayButtonElement* button = new MediaControlOverlayPlayBu ttonElement(mediaControls); | 370 MediaControlOverlayPlayButtonElement* button = new MediaControlOverlayPlayBu ttonElement(mediaControls); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 | 414 |
| 401 void MediaControlToggleClosedCaptionsButtonElement::updateDisplayType() | 415 void MediaControlToggleClosedCaptionsButtonElement::updateDisplayType() |
| 402 { | 416 { |
| 403 bool captionsVisible = mediaElement().textTracksVisible(); | 417 bool captionsVisible = mediaElement().textTracksVisible(); |
| 404 setDisplayType(captionsVisible ? MediaHideClosedCaptionsButton : MediaShowCl osedCaptionsButton); | 418 setDisplayType(captionsVisible ? MediaHideClosedCaptionsButton : MediaShowCl osedCaptionsButton); |
| 405 } | 419 } |
| 406 | 420 |
| 407 void MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler(Event* e vent) | 421 void MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler(Event* e vent) |
| 408 { | 422 { |
| 409 if (event->type() == EventTypeNames::click) { | 423 if (event->type() == EventTypeNames::click) { |
| 424 // If the user opens up the closed captions menu from the overfow menu, | |
| 425 // the overflow menu should no longer be visible. | |
| 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 | |
| 418 // ---------------------------- | 441 // ---------------------------- |
| 419 | 442 |
| 420 MediaControlTextTrackListElement::MediaControlTextTrackListElement(MediaControls & mediaControls) | 443 MediaControlTextTrackListElement::MediaControlTextTrackListElement(MediaControls & mediaControls) |
| 421 : MediaControlDivElement(mediaControls, MediaTextTrackList) | 444 : MediaControlDivElement(mediaControls, MediaTextTrackList) |
| 422 { | 445 { |
| 423 } | 446 } |
| 424 | 447 |
| 425 MediaControlTextTrackListElement* MediaControlTextTrackListElement::create(Media Controls& mediaControls) | 448 MediaControlTextTrackListElement* MediaControlTextTrackListElement::create(Media Controls& mediaControls) |
| 426 { | 449 { |
| 427 MediaControlTextTrackListElement* element = new MediaControlTextTrackListEle ment(mediaControls); | 450 MediaControlTextTrackListElement* element = new MediaControlTextTrackListEle ment(mediaControls); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 TextTrackList* trackList = mediaElement().textTracks(); | 570 TextTrackList* trackList = mediaElement().textTracks(); |
| 548 for (unsigned i = 0; i < trackList->length(); i++) { | 571 for (unsigned i = 0; i < trackList->length(); i++) { |
| 549 TextTrack* track = trackList->anonymousIndexedGetter(i); | 572 TextTrack* track = trackList->anonymousIndexedGetter(i); |
| 550 if (!track->canBeRendered()) | 573 if (!track->canBeRendered()) |
| 551 continue; | 574 continue; |
| 552 appendChild(createTextTrackListItem(track)); | 575 appendChild(createTextTrackListItem(track)); |
| 553 } | 576 } |
| 554 } | 577 } |
| 555 | 578 |
| 556 // ---------------------------- | 579 // ---------------------------- |
| 580 MediaControlOverflowMenuButtonElement::MediaControlOverflowMenuButtonElement(Med iaControls& mediaControls) | |
| 581 : MediaControlInputElement(mediaControls, MediaOverflowButton) | |
| 582 { | |
| 583 } | |
| 584 | |
| 585 MediaControlOverflowMenuButtonElement* MediaControlOverflowMenuButtonElement::cr eate(MediaControls& mediaControls) | |
| 586 { | |
| 587 MediaControlOverflowMenuButtonElement* button = new MediaControlOverflowMenu ButtonElement(mediaControls); | |
| 588 button->ensureUserAgentShadowRoot(); | |
| 589 button->setType(InputTypeNames::button); | |
| 590 button->setShadowPseudoId(AtomicString("-internal-overflow-menu-button")); | |
| 591 button->setIsWanted(false); | |
| 592 return button; | |
| 593 } | |
| 594 | |
| 595 void MediaControlOverflowMenuButtonElement::defaultEventHandler(Event* event) | |
| 596 { | |
| 597 if (event->type() == EventTypeNames::click) { | |
| 598 mediaControls().toggleOverflowMenu(); | |
| 599 event->setDefaultHandled(); | |
| 600 } | |
| 601 | |
| 602 HTMLInputElement::defaultEventHandler(event); | |
| 603 } | |
| 604 | |
| 605 // ---------------------------- | |
| 606 MediaControlOverflowMenuListElement::MediaControlOverflowMenuListElement(MediaCo ntrols& mediaControls) | |
| 607 : MediaControlDivElement(mediaControls, MediaOverflowList) | |
| 608 { | |
| 609 } | |
| 610 | |
| 611 MediaControlOverflowMenuListElement* MediaControlOverflowMenuListElement::create (MediaControls& mediaControls) | |
| 612 { | |
| 613 MediaControlOverflowMenuListElement* element = new MediaControlOverflowMenuL istElement(mediaControls); | |
| 614 element->setIsWanted(false); | |
| 615 element->setShadowPseudoId(AtomicString("-internal-media-controls-overflow-m enu-list")); | |
| 616 return element; | |
| 617 } | |
| 618 | |
| 619 void MediaControlOverflowMenuListElement::showOverflowMenu(bool visible) | |
| 620 { | |
| 621 setIsWanted(visible); | |
|
mlamouri (slow - plz ping)
2016/09/06 10:25:45
nit: I'm not entirely convinced we need to wrap se
kdsilva
2016/09/06 17:32:46
Done.
| |
| 622 } | |
| 623 | |
| 624 void MediaControlOverflowMenuListElement::defaultEventHandler(Event* event) | |
| 625 { | |
| 626 if (event->type() == EventTypeNames::click) | |
| 627 event->setDefaultHandled(); | |
| 628 | |
| 629 MediaControlDivElement::defaultEventHandler(event); | |
| 630 } | |
| 631 | |
| 632 // ---------------------------- | |
| 557 | 633 |
| 558 MediaControlTimelineElement::MediaControlTimelineElement(MediaControls& mediaCon trols) | 634 MediaControlTimelineElement::MediaControlTimelineElement(MediaControls& mediaCon trols) |
| 559 : MediaControlInputElement(mediaControls, MediaSlider) | 635 : MediaControlInputElement(mediaControls, MediaSlider) |
| 560 { | 636 { |
| 561 } | 637 } |
| 562 | 638 |
| 563 MediaControlTimelineElement* MediaControlTimelineElement::create(MediaControls& mediaControls) | 639 MediaControlTimelineElement* MediaControlTimelineElement::create(MediaControls& mediaControls) |
| 564 { | 640 { |
| 565 MediaControlTimelineElement* timeline = new MediaControlTimelineElement(medi aControls); | 641 MediaControlTimelineElement* timeline = new MediaControlTimelineElement(medi aControls); |
| 566 timeline->ensureUserAgentShadowRoot(); | 642 timeline->ensureUserAgentShadowRoot(); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 731 event->setDefaultHandled(); | 807 event->setDefaultHandled(); |
| 732 } | 808 } |
| 733 HTMLInputElement::defaultEventHandler(event); | 809 HTMLInputElement::defaultEventHandler(event); |
| 734 } | 810 } |
| 735 | 811 |
| 736 void MediaControlFullscreenButtonElement::setIsFullscreen(bool isFullscreen) | 812 void MediaControlFullscreenButtonElement::setIsFullscreen(bool isFullscreen) |
| 737 { | 813 { |
| 738 setDisplayType(isFullscreen ? MediaExitFullscreenButton : MediaEnterFullscre enButton); | 814 setDisplayType(isFullscreen ? MediaExitFullscreenButton : MediaEnterFullscre enButton); |
| 739 } | 815 } |
| 740 | 816 |
| 817 WebLocalizedString::Name MediaControlFullscreenButtonElement::getOverflowStringN ame() | |
| 818 { | |
| 819 return WebLocalizedString::OverflowMenuFullscreen; | |
|
mlamouri (slow - plz ping)
2016/09/06 10:25:45
Should there be an enter and exit fullscreen versi
kdsilva
2016/09/06 17:32:46
Done.
| |
| 820 } | |
| 821 | |
| 741 // ---------------------------- | 822 // ---------------------------- |
| 742 | 823 |
| 743 MediaControlCastButtonElement::MediaControlCastButtonElement(MediaControls& medi aControls, bool isOverlayButton) | 824 MediaControlCastButtonElement::MediaControlCastButtonElement(MediaControls& medi aControls, bool isOverlayButton) |
| 744 : MediaControlInputElement(mediaControls, MediaCastOnButton), m_isOverlayBut ton(isOverlayButton) | 825 : MediaControlInputElement(mediaControls, MediaCastOnButton), m_isOverlayBut ton(isOverlayButton) |
| 745 { | 826 { |
| 746 if (m_isOverlayButton) | 827 if (m_isOverlayButton) |
| 747 recordMetrics(CastOverlayMetrics::Created); | 828 recordMetrics(CastOverlayMetrics::Created); |
| 748 setIsPlayingRemotely(false); | 829 setIsPlayingRemotely(false); |
| 749 } | 830 } |
| 750 | 831 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 794 } | 875 } |
| 795 } else { | 876 } else { |
| 796 if (m_isOverlayButton) { | 877 if (m_isOverlayButton) { |
| 797 setDisplayType(MediaOverlayCastOffButton); | 878 setDisplayType(MediaOverlayCastOffButton); |
| 798 } else { | 879 } else { |
| 799 setDisplayType(MediaCastOffButton); | 880 setDisplayType(MediaCastOffButton); |
| 800 } | 881 } |
| 801 } | 882 } |
| 802 } | 883 } |
| 803 | 884 |
| 885 WebLocalizedString::Name MediaControlCastButtonElement::getOverflowStringName() | |
| 886 { | |
| 887 if (mediaElement().isPlayingRemotely()) | |
| 888 return WebLocalizedString::OverflowMenuStopCast; | |
| 889 return WebLocalizedString::OverflowMenuCast; | |
| 890 } | |
| 891 | |
| 804 void MediaControlCastButtonElement::tryShowOverlay() | 892 void MediaControlCastButtonElement::tryShowOverlay() |
| 805 { | 893 { |
| 806 DCHECK(m_isOverlayButton); | 894 DCHECK(m_isOverlayButton); |
| 807 | 895 |
| 808 setIsWanted(true); | 896 setIsWanted(true); |
| 809 if (elementFromCenter(*this) != &mediaElement()) { | 897 if (elementFromCenter(*this) != &mediaElement()) { |
| 810 setIsWanted(false); | 898 setIsWanted(false); |
| 811 return; | 899 return; |
| 812 } | 900 } |
| 813 | 901 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 852 } | 940 } |
| 853 | 941 |
| 854 MediaControlCurrentTimeDisplayElement* MediaControlCurrentTimeDisplayElement::cr eate(MediaControls& mediaControls) | 942 MediaControlCurrentTimeDisplayElement* MediaControlCurrentTimeDisplayElement::cr eate(MediaControls& mediaControls) |
| 855 { | 943 { |
| 856 MediaControlCurrentTimeDisplayElement* element = new MediaControlCurrentTime DisplayElement(mediaControls); | 944 MediaControlCurrentTimeDisplayElement* element = new MediaControlCurrentTime DisplayElement(mediaControls); |
| 857 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time -display")); | 945 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time -display")); |
| 858 return element; | 946 return element; |
| 859 } | 947 } |
| 860 | 948 |
| 861 } // namespace blink | 949 } // namespace blink |
| OLD | NEW |