bool MediaControlsPainter::paintMediaMuteButton(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { const HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; // The new UI uses "muted" and "not muted" only. static Image* soundLevel3 = platformResource("mediaplayerSoundLevel3", "mediaplayerSoundLevel3New"); static Image* soundLevel2 = platformResource("mediaplayerSoundLevel2", "mediaplayerSoundLevel3New"); static Image* soundLevel1 = platformResource("mediaplayerSoundLevel1", "mediaplayerSoundLevel3New"); static Image* soundLevel0 = platformResource("mediaplayerSoundLevel0", "mediaplayerSoundLevel0New"); static Image* soundDisabled = platformResource("mediaplayerSoundDisabled", "mediaplayerSoundLevel0New"); if (!hasSource(mediaElement) || !mediaElement->hasAudio()) return paintMediaButton(paintInfo.context, rect, soundDisabled, false); if (mediaElement->muted() || mediaElement->volume() <= 0) return paintMediaButton(paintInfo.context, rect, soundLevel0); if (mediaElement->volume() <= 0.33) return paintMediaButton(paintInfo.context, rect, soundLevel1); if (mediaElement->volume() <= 0.66) return paintMediaButton(paintInfo.context, rect, soundLevel2); return paintMediaButton(paintInfo.context, rect, soundLevel3); }
bool MediaControlsPainter::paintMediaCastButton(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { const HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; static Image* mediaCastOn = platformResource("mediaplayerCastOn", "mediaplayerCastOnNew"); static Image* mediaCastOff = platformResource("mediaplayerCastOff", "mediaplayerCastOffNew"); // To ensure that the overlaid cast button is visible when overlaid on pale videos we use a // different version of it for the overlaid case with a semi-opaque background. static Image* mediaOverlayCastOff = platformResource( "mediaplayerOverlayCastOff", "mediaplayerOverlayCastOffNew"); bool isEnabled = mediaElement->hasRemoteRoutes(); switch (mediaControlElementType(object.node())) { case MediaCastOnButton: return paintMediaButton(paintInfo.context, rect, mediaCastOn, isEnabled); case MediaOverlayCastOnButton: return paintMediaButton(paintInfo.context, rect, mediaCastOn); case MediaCastOffButton: return paintMediaButton(paintInfo.context, rect, mediaCastOff, isEnabled); case MediaOverlayCastOffButton: return paintMediaButton(paintInfo.context, rect, mediaOverlayCastOff); default: ASSERT_NOT_REACHED(); return false; } }
static bool paintMediaMuteButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; static Image* soundLevel3 = platformResource("mediaplayerSoundLevel3"); static Image* soundLevel2 = platformResource("mediaplayerSoundLevel2"); static Image* soundLevel1 = platformResource("mediaplayerSoundLevel1"); static Image* soundLevel0 = platformResource("mediaplayerSoundLevel0"); static Image* soundDisabled = platformResource("mediaplayerSoundDisabled"); if (!hasSource(mediaElement) || !mediaElement->hasAudio()) return paintMediaButton(paintInfo.context, rect, soundDisabled); if (mediaElement->muted() || mediaElement->volume() <= 0) return paintMediaButton(paintInfo.context, rect, soundLevel0); if (mediaElement->volume() <= 0.33) return paintMediaButton(paintInfo.context, rect, soundLevel1); if (mediaElement->volume() <= 0.66) return paintMediaButton(paintInfo.context, rect, soundLevel2); return paintMediaButton(paintInfo.context, rect, soundLevel3); }
static bool paintMediaToggleClosedCaptionsButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; static Image* mediaClosedCaptionButton = platformResource("mediaplayerClosedCaption"); static Image* mediaClosedCaptionButtonDisabled = platformResource("mediaplayerClosedCaptionDisabled"); if (mediaElement->closedCaptionsVisible()) return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButton); return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButtonDisabled); }
static bool paintMediaPlayButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; static Image* mediaPlay = platformResource("mediaPlay"); static Image* mediaPause = platformResource("mediaPause"); static Image* mediaPlayDisabled = platformResource("mediaPlayDisabled"); if (!hasSource(mediaElement)) return paintMediaButton(paintInfo.context, rect, mediaPlayDisabled); return paintMediaButton(paintInfo.context, rect, mediaElement->canPlay() ? mediaPlay : mediaPause); }
static bool paintMediaMuteButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; static Image* soundFull = platformResource("mediaSoundFull"); static Image* soundNone = platformResource("mediaSoundNone"); static Image* soundDisabled = platformResource("mediaSoundDisabled"); if (!hasSource(mediaElement) || !mediaElement->hasAudio()) return paintMediaButton(paintInfo.context, rect, soundDisabled); return paintMediaButton(paintInfo.context, rect, mediaElement->muted() ? soundNone: soundFull); }
bool MediaControlsPainter::paintMediaOverlayPlayButton(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { const HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; if (!hasSource(mediaElement) || !mediaElement->paused()) return false; static Image* mediaOverlayPlay = platformResource("mediaplayerOverlayPlay", "mediaplayerOverlayPlayNew"); IntRect buttonRect(rect); if (RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) { // Overlay play button covers the entire player, so center and draw a // smaller button. Center in the entire element. const LayoutBox* box = mediaElement->layoutObject()->enclosingBox(); if (!box) return false; int mediaHeight = box->pixelSnappedHeight(); buttonRect.setX(rect.center().x() - mediaOverlayPlayButtonWidthNew / 2); buttonRect.setY(rect.center().y() - mediaOverlayPlayButtonHeightNew / 2 + (mediaHeight - rect.height()) / 2); buttonRect.setWidth(mediaOverlayPlayButtonWidthNew); buttonRect.setHeight(mediaOverlayPlayButtonHeightNew); } return paintMediaButton(paintInfo.context, buttonRect, mediaOverlayPlay); }
static bool paintMediaPlayButton(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; static Image* mediaPlay = platformResource("mediaPlay"); static Image* mediaPause = platformResource("mediaPause"); static Image* mediaPlayDisabled = platformResource("mediaPlayDisabled"); if (mediaElement->networkState() == HTMLMediaElement::NETWORK_EMPTY || mediaElement->networkState() == HTMLMediaElement::NETWORK_NO_SOURCE) return paintMediaButton(paintInfo.context, rect, mediaPlayDisabled); return paintMediaButton(paintInfo.context, rect, mediaElement->paused() ? mediaPlay : mediaPause); }
static bool paintMediaVolumeSliderThumb(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { if (!object->parent()->isSlider()) return false; static Image* mediaVolumeSliderThumb = platformResource("mediaVolumeSliderThumb"); return paintMediaButton(paintInfo.context, rect, mediaVolumeSliderThumb); }
static bool paintMediaFullscreenButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; DEFINE_STATIC_LOCAL(Image*, mediaFullscreen, (platformResource("mediaFullscreen"))); return paintMediaButton(paintInfo.context, rect, mediaFullscreen); }
bool MediaControlsPainter::paintMediaPlayButton(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { const HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; static Image* mediaPlay = platformResource("mediaplayerPlay", "mediaplayerPlayNew"); static Image* mediaPause = platformResource("mediaplayerPause", "mediaplayerPauseNew"); // For this case, the new UI draws the normal icon, but the entire panel // grays out. static Image* mediaPlayDisabled = platformResource("mediaplayerPlayDisabled", "mediaplayerPlayNew"); if (!hasSource(mediaElement)) return paintMediaButton(paintInfo.context, rect, mediaPlayDisabled, false); Image * image = !object.node()->isMediaControlElement() || mediaControlElementType(object.node()) == MediaPlayButton ? mediaPlay : mediaPause; return paintMediaButton(paintInfo.context, rect, image); }
static bool paintMediaFullscreenButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; static Image* mediaFullscreenButton = platformResource("mediaplayerFullscreen"); return paintMediaButton(paintInfo.context, rect, mediaFullscreenButton); }
bool MediaControlsPainter::paintMediaToggleClosedCaptionsButton(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { const HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; static Image* mediaClosedCaptionButton = platformResource( "mediaplayerClosedCaption", "mediaplayerClosedCaptionNew"); static Image* mediaClosedCaptionButtonDisabled = platformResource( "mediaplayerClosedCaptionDisabled", "mediaplayerClosedCaptionDisabledNew"); bool isEnabled = mediaElement->hasClosedCaptions(); if (mediaElement->closedCaptionsVisible()) return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButton, isEnabled); return paintMediaButton(paintInfo.context, rect, mediaClosedCaptionButtonDisabled, isEnabled); }
bool RenderThemeGtk::paintMediaMuteButton(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(renderObject); if (!mediaElement) return false; bool muted = mediaElement->muted(); return paintMediaButton(renderObject, paintInfo.context, rect, muted ? "audio-volume-muted-symbolic" : "audio-volume-high-symbolic", muted ? "audio-volume-muted" : "audio-volume-high"); }
bool MediaControlsPainter::paintMediaFullscreenButton(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { const HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; // With the new player UI, we have separate assets for enter / exit // fullscreen mode. static Image* mediaEnterFullscreenButton = platformResource( "mediaplayerFullscreen", "mediaplayerEnterFullscreen"); static Image* mediaExitFullscreenButton = platformResource( "mediaplayerFullscreen", "mediaplayerExitFullscreen"); bool isEnabled = hasSource(mediaElement); if (mediaControlElementType(object.node()) == MediaExitFullscreenButton) return paintMediaButton(paintInfo.context, rect, mediaExitFullscreenButton, isEnabled); return paintMediaButton(paintInfo.context, rect, mediaEnterFullscreenButton, isEnabled); }
static bool paintMediaOverlayPlayButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { HTMLMediaElement* mediaElement = toParentMediaElement(object); if (!mediaElement) return false; if (!hasSource(mediaElement) || !mediaElement->canPlay()) return false; static Image* mediaOverlayPlay = platformResource("mediaplayerOverlayPlay"); return paintMediaButton(paintInfo.context, rect, mediaOverlayPlay); }
static bool paintMediaVolumeSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { ASSERT(object->node()); HTMLMediaElement* mediaElement = toParentMediaElement(object->node()->shadowHost()); if (!mediaElement) return false; if (!hasSource(mediaElement) || !mediaElement->hasAudio()) return true; static Image* mediaVolumeSliderThumb = platformResource("mediaplayerVolumeSliderThumb"); return paintMediaButton(paintInfo.context, rect, mediaVolumeSliderThumb); }
static bool paintMediaSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { ASSERT(object->node()); HTMLMediaElement* mediaElement = toParentMediaElement(object->node()->shadowHost()); if (!mediaElement) return false; if (!hasSource(mediaElement)) return true; Image* mediaSliderThumb = getMediaSliderThumb(); return paintMediaButton(paintInfo.context, rect, mediaSliderThumb); }
bool RenderThemeGtk::paintMediaPlayButton(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect) { Node* node = renderObject.node(); if (!node) return false; if (!nodeHasPseudo(node, "-webkit-media-controls-play-button")) return false; bool showPlayButton = nodeHasClass(node, "paused"); return paintMediaButton(renderObject, paintInfo.context, rect, showPlayButton ? "media-playback-start-symbolic" : "media-playback-pause-symbolic", showPlayButton ? GTK_STOCK_MEDIA_PLAY : GTK_STOCK_MEDIA_PAUSE); }
static bool paintMediaSliderThumb(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) { if (!object->parent()->isSlider()) return false; HTMLMediaElement* mediaElement = toParentMediaElement(object->parent()); if (!mediaElement) return false; if (!hasSource(mediaElement)) return true; static Image* mediaSliderThumb = platformResource("mediaSliderThumb"); return paintMediaButton(paintInfo.context, rect, mediaSliderThumb); }
bool MediaControlsPainter::paintMediaSliderThumb(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { if (!object.node()) return false; const HTMLMediaElement* mediaElement = toParentMediaElement(object.node()->shadowHost()); if (!mediaElement) return false; if (!hasSource(mediaElement)) return true; Image* mediaSliderThumb = getMediaSliderThumb(); IntRect paintRect; const ComputedStyle& style = object.styleRef(); adjustMediaSliderThumbPaintSize(rect, style, paintRect); return paintMediaButton(paintInfo.context, paintRect, mediaSliderThumb); }
bool MediaControlsPainter::paintMediaVolumeSliderThumb(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) { if (!object.node()) return false; const HTMLMediaElement* mediaElement = toParentMediaElement(object.node()->shadowHost()); if (!mediaElement) return false; if (!hasSource(mediaElement) || !mediaElement->hasAudio()) return true; static Image* mediaVolumeSliderThumb = platformResource( "mediaplayerVolumeSliderThumb", "mediaplayerVolumeSliderThumbNew"); IntRect paintRect; const ComputedStyle& style = object.styleRef(); adjustMediaSliderThumbPaintSize(rect, style, paintRect); return paintMediaButton(paintInfo.context, paintRect, mediaVolumeSliderThumb); }
static bool paintMediaVolumeSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) { static Image* mediaVolumeSliderThumb = platformResource("mediaVolumeSliderThumb"); return paintMediaButton(paintInfo.context, rect, mediaVolumeSliderThumb); }
bool RenderThemeGtk::paintMediaFullscreenButton(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect) { return paintMediaButton(renderObject, paintInfo.context, rect, "view-fullscreen-symbolic", GTK_STOCK_FULLSCREEN); }
bool RenderThemeGtk::paintMediaSeekForwardButton(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect) { return paintMediaButton(renderObject, paintInfo.context, rect, "media-seek-forward-symbolic", GTK_STOCK_MEDIA_FORWARD); }
bool RenderThemeGtk::paintMediaSeekBackButton(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect) { return paintMediaButton(renderObject, paintInfo.context, rect, "media-seek-backward-symbolic", GTK_STOCK_MEDIA_REWIND); }