Chromium Code Reviews| Index: Source/core/html/shadow/MediaControlElements.cpp |
| diff --git a/Source/core/html/shadow/MediaControlElements.cpp b/Source/core/html/shadow/MediaControlElements.cpp |
| index 170b04b70f88b11f5c73c640e6d03362ecf3708f..82f9d44afa463213bd465eac846b597ef0977878 100644 |
| --- a/Source/core/html/shadow/MediaControlElements.cpp |
| +++ b/Source/core/html/shadow/MediaControlElements.cpp |
| @@ -210,6 +210,17 @@ const AtomicString& MediaControlOverlayEnclosureElement::shadowPseudoId() const |
| return id; |
| } |
| +void* MediaControlOverlayEnclosureElement::preDispatchEventHandler(Event* event) |
| +{ |
| + // When the media element is touched we want to make the overlay cast button visible |
| + // (if the other requirements are right) even if JavaScript is doing its own handling of the event. |
| + // Doing it in preDispatchEventHandler prevents any interference from JavaScript. |
| + if (event && (event->type() == EventTypeNames::click || event->type() == EventTypeNames::touchstart) && mediaElement().hasRemoteRoutes() && !mediaElement().shouldShowControls()) |
| + mediaControls().showOverlayCastButton(); |
| + return MediaControlDivElement::preDispatchEventHandler(event); |
| +} |
| + |
| + |
| // ---------------------------- |
| MediaControlMuteButtonElement::MediaControlMuteButtonElement(MediaControls& mediaControls) |
| @@ -552,6 +563,50 @@ void MediaControlFullscreenButtonElement::setIsFullscreen(bool isFullscreen) |
| // ---------------------------- |
| +MediaControlCastButtonElement::MediaControlCastButtonElement(MediaControls& mediaControls, bool isOverlayButton) |
| + : MediaControlInputElement(mediaControls, MediaCastOnButton), m_isOverlayButton(isOverlayButton) |
| +{ |
| +} |
| + |
| +PassRefPtrWillBeRawPtr<MediaControlCastButtonElement> MediaControlCastButtonElement::create(MediaControls& mediaControls, bool isOverlayButton) |
| +{ |
| + RefPtrWillBeRawPtr<MediaControlCastButtonElement> button = adoptRefWillBeRefCountedGarbageCollected(new MediaControlCastButtonElement(mediaControls, isOverlayButton)); |
| + button->ensureUserAgentShadowRoot(); |
| + button->setType("button"); |
| + return button.release(); |
| +} |
| + |
| +void MediaControlCastButtonElement::defaultEventHandler(Event* event) |
| +{ |
| + if (event->type() == EventTypeNames::click) { |
| + if (mediaElement().isPlayingRemotely()) { |
| + mediaElement().requestRemotePlaybackControl(); |
| + } else { |
| + mediaElement().requestRemotePlayback(); |
| + } |
| + } |
| + HTMLInputElement::defaultEventHandler(event); |
| +} |
| + |
| +const AtomicString& MediaControlCastButtonElement::shadowPseudoId() const |
| +{ |
| + DEFINE_STATIC_LOCAL(AtomicString, id_nonOverlay, ("-webkit-media-controls-cast-button", AtomicString::ConstructFromLiteral)); |
| + DEFINE_STATIC_LOCAL(AtomicString, id_overlay, ("-webkit-media-controls-overlay-cast-button", AtomicString::ConstructFromLiteral)); |
|
abarth-chromium
2014/08/23 05:53:15
Please do not add any more -webkit- prefixed names
aberent
2014/09/09 18:35:30
Done. Note that I had to add the new names to CSSS
|
| + return m_isOverlayButton ? id_overlay : id_nonOverlay; |
| +} |
| + |
| +void MediaControlCastButtonElement::setIsPlayingRemotely(bool isPlayingRemotely) |
| +{ |
| + setDisplayType(isPlayingRemotely ? MediaCastOnButton : MediaCastOffButton); |
| +} |
| + |
| +bool MediaControlCastButtonElement::keepEventInNode(Event* event) |
| +{ |
| + return isUserInteractionEvent(event); |
| +} |
| + |
| +// ---------------------------- |
| + |
| MediaControlTimeRemainingDisplayElement::MediaControlTimeRemainingDisplayElement(MediaControls& mediaControls) |
| : MediaControlTimeDisplayElement(mediaControls, MediaTimeRemainingDisplay) |
| { |