summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderMediaControls.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/RenderMediaControls.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/RenderMediaControls.cpp')
-rw-r--r--Source/WebCore/rendering/RenderMediaControls.cpp93
1 files changed, 44 insertions, 49 deletions
diff --git a/Source/WebCore/rendering/RenderMediaControls.cpp b/Source/WebCore/rendering/RenderMediaControls.cpp
index cafd0c0e7..248a2a567 100644
--- a/Source/WebCore/rendering/RenderMediaControls.cpp
+++ b/Source/WebCore/rendering/RenderMediaControls.cpp
@@ -32,6 +32,7 @@
#include "GraphicsContext.h"
#include "HTMLMediaElement.h"
#include "HTMLNames.h"
+#include "NotImplemented.h"
#include "PaintInfo.h"
#include "RenderTheme.h"
@@ -70,10 +71,10 @@ namespace WebCore {
#if PLATFORM(WIN) && USE(CG)
-static WKMediaControllerThemeState determineState(RenderObject* o)
+static WKMediaControllerThemeState determineState(const RenderObject& o)
{
int result = 0;
- const RenderTheme& theme = o->theme();
+ const RenderTheme& theme = o.theme();
if (!theme.isEnabled(o) || theme.isReadOnlyControl(o))
result |= WKMediaControllerFlagDisabled;
if (theme.isPressed(o))
@@ -84,16 +85,16 @@ static WKMediaControllerThemeState determineState(RenderObject* o)
}
// Utility to scale when the UI part are not scaled by wkDrawMediaUIPart
-static FloatRect getUnzoomedRectAndAdjustCurrentContext(RenderObject* o, const PaintInfo& paintInfo, const IntRect &originalRect)
+static FloatRect getUnzoomedRectAndAdjustCurrentContext(const RenderObject& o, const PaintInfo& paintInfo, const IntRect &originalRect)
{
- float zoomLevel = o->style().effectiveZoom();
+ float zoomLevel = o.style().effectiveZoom();
FloatRect unzoomedRect(originalRect);
if (zoomLevel != 1.0f) {
unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
- paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y());
- paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel));
- paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
+ paintInfo.context().translate(unzoomedRect.x(), unzoomedRect.y());
+ paintInfo.context().scale(zoomLevel);
+ paintInfo.context().translate(-unzoomedRect.x(), -unzoomedRect.y());
}
return unzoomedRect;
}
@@ -101,10 +102,10 @@ static FloatRect getUnzoomedRectAndAdjustCurrentContext(RenderObject* o, const P
static const int mediaSliderThumbWidth = 13;
static const int mediaSliderThumbHeight = 14;
-void RenderMediaControls::adjustMediaSliderThumbSize(RenderStyle* style)
+void RenderMediaControls::adjustMediaSliderThumbSize(RenderStyle& style)
{
int part;
- switch (style->appearance()) {
+ switch (style.appearance()) {
case MediaSliderThumbPart:
part = MediaSliderThumb;
break;
@@ -121,83 +122,90 @@ void RenderMediaControls::adjustMediaSliderThumbSize(RenderStyle* style)
CGSize size;
wkMeasureMediaUIPart(part, 0, &size);
- float zoomLevel = style->effectiveZoom();
- style->setWidth(Length(static_cast<int>(size.width * zoomLevel), Fixed));
- style->setHeight(Length(static_cast<int>(size.height * zoomLevel), Fixed));
+ float zoomLevel = style.effectiveZoom();
+ style.setWidth(Length(static_cast<int>(size.width * zoomLevel), Fixed));
+ style.setHeight(Length(static_cast<int>(size.height * zoomLevel), Fixed));
}
-bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, const RenderObject& o, const PaintInfo& paintInfo, const IntRect& r)
{
- GraphicsContextStateSaver stateSaver(*paintInfo.context);
+#if USE(DIRECT2D)
+ UNUSED_PARAM(part);
+ UNUSED_PARAM(o);
+ UNUSED_PARAM(paintInfo);
+ UNUSED_PARAM(r);
+ notImplemented();
+#else
+ GraphicsContextStateSaver stateSaver(paintInfo.context());
switch (part) {
case MediaEnterFullscreenButton:
case MediaExitFullscreenButton:
- if (MediaControlFullscreenButtonElement* btn = static_cast<MediaControlFullscreenButtonElement*>(o->node())) {
+ if (MediaControlFullscreenButtonElement* btn = static_cast<MediaControlFullscreenButtonElement*>(o.node())) {
bool enterButton = btn->displayType() == MediaEnterFullscreenButton;
- wkDrawMediaUIPart(enterButton ? WKMediaUIPartFullscreenButton : WKMediaUIPartExitFullscreenButton, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(enterButton ? WKMediaUIPartFullscreenButton : WKMediaUIPartExitFullscreenButton, paintInfo.context().platformContext(), r, determineState(o));
}
break;
case MediaShowClosedCaptionsButton:
case MediaHideClosedCaptionsButton:
- if (MediaControlToggleClosedCaptionsButtonElement* btn = static_cast<MediaControlToggleClosedCaptionsButtonElement*>(o->node())) {
+ if (MediaControlToggleClosedCaptionsButtonElement* btn = static_cast<MediaControlToggleClosedCaptionsButtonElement*>(o.node())) {
bool captionsVisible = btn->displayType() == MediaHideClosedCaptionsButton;
- wkDrawMediaUIPart(captionsVisible ? WKMediaUIPartHideClosedCaptionsButton : WKMediaUIPartShowClosedCaptionsButton, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(captionsVisible ? WKMediaUIPartHideClosedCaptionsButton : WKMediaUIPartShowClosedCaptionsButton, paintInfo.context().platformContext(), r, determineState(o));
}
break;
case MediaMuteButton:
case MediaUnMuteButton:
- if (MediaControlMuteButtonElement* btn = static_cast<MediaControlMuteButtonElement*>(o->node())) {
+ if (MediaControlMuteButtonElement* btn = static_cast<MediaControlMuteButtonElement*>(o.node())) {
bool audioEnabled = btn->displayType() == MediaMuteButton;
- wkDrawMediaUIPart(audioEnabled ? WKMediaUIPartMuteButton : WKMediaUIPartUnMuteButton, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(audioEnabled ? WKMediaUIPartMuteButton : WKMediaUIPartUnMuteButton, paintInfo.context().platformContext(), r, determineState(o));
}
break;
case MediaPauseButton:
case MediaPlayButton:
- if (MediaControlPlayButtonElement* btn = static_cast<MediaControlPlayButtonElement*>(o->node())) {
+ if (MediaControlPlayButtonElement* btn = static_cast<MediaControlPlayButtonElement*>(o.node())) {
bool canPlay = btn->displayType() == MediaPlayButton;
- wkDrawMediaUIPart(canPlay ? WKMediaUIPartPlayButton : WKMediaUIPartPauseButton, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(canPlay ? WKMediaUIPartPlayButton : WKMediaUIPartPauseButton, paintInfo.context().platformContext(), r, determineState(o));
}
break;
case MediaRewindButton:
- wkDrawMediaUIPart(WKMediaUIPartRewindButton, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(WKMediaUIPartRewindButton, paintInfo.context().platformContext(), r, determineState(o));
break;
case MediaReturnToRealtimeButton:
- wkDrawMediaUIPart(WKMediaUIPartSeekToRealtimeButton, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(WKMediaUIPartSeekToRealtimeButton, paintInfo.context().platformContext(), r, determineState(o));
break;
case MediaSeekBackButton:
- wkDrawMediaUIPart(WKMediaUIPartSeekBackButton, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(WKMediaUIPartSeekBackButton, paintInfo.context().platformContext(), r, determineState(o));
break;
case MediaSeekForwardButton:
- wkDrawMediaUIPart(WKMediaUIPartSeekForwardButton, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(WKMediaUIPartSeekForwardButton, paintInfo.context().platformContext(), r, determineState(o));
break;
case MediaSlider: {
- if (HTMLMediaElement* mediaElement = parentMediaElement(*o)) {
+ if (HTMLMediaElement* mediaElement = parentMediaElement(o)) {
FloatRect unzoomedRect = getUnzoomedRectAndAdjustCurrentContext(o, paintInfo, r);
- wkDrawMediaSliderTrack(paintInfo.context->platformContext(), unzoomedRect, mediaElement->percentLoaded() * mediaElement->duration(), mediaElement->currentTime(), mediaElement->duration(), determineState(o));
+ wkDrawMediaSliderTrack(paintInfo.context().platformContext(), unzoomedRect, mediaElement->percentLoaded() * mediaElement->duration(), mediaElement->currentTime(), mediaElement->duration(), determineState(o));
}
break;
}
case MediaSliderThumb:
- wkDrawMediaUIPart(WKMediaUIPartTimelineSliderThumb, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(WKMediaUIPartTimelineSliderThumb, paintInfo.context().platformContext(), r, determineState(o));
break;
case MediaVolumeSliderContainer:
- wkDrawMediaUIPart(WKMediaUIPartVolumeSliderContainer, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(WKMediaUIPartVolumeSliderContainer, paintInfo.context().platformContext(), r, determineState(o));
break;
case MediaVolumeSlider:
- wkDrawMediaUIPart(WKMediaUIPartVolumeSlider, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(WKMediaUIPartVolumeSlider, paintInfo.context().platformContext(), r, determineState(o));
break;
case MediaVolumeSliderThumb:
- wkDrawMediaUIPart(WKMediaUIPartVolumeSliderThumb, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(WKMediaUIPartVolumeSliderThumb, paintInfo.context().platformContext(), r, determineState(o));
break;
case MediaFullScreenVolumeSlider:
- wkDrawMediaUIPart(WKMediaUIPartFullScreenVolumeSlider, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(WKMediaUIPartFullScreenVolumeSlider, paintInfo.context().platformContext(), r, determineState(o));
break;
case MediaFullScreenVolumeSliderThumb:
- wkDrawMediaUIPart(WKMediaUIPartFullScreenVolumeSliderThumb, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(WKMediaUIPartFullScreenVolumeSliderThumb, paintInfo.context().platformContext(), r, determineState(o));
break;
case MediaTimelineContainer:
- wkDrawMediaUIPart(WKMediaUIPartBackground, paintInfo.context->platformContext(), r, determineState(o));
+ wkDrawMediaUIPart(WKMediaUIPartBackground, paintInfo.context().platformContext(), r, determineState(o));
break;
case MediaCurrentTimeDisplay:
ASSERT_NOT_REACHED();
@@ -214,25 +222,12 @@ bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, R
ASSERT_NOT_REACHED();
break;
}
-
+#endif
return false;
}
#endif
-IntPoint RenderMediaControls::volumeSliderOffsetFromMuteButton(RenderBox* muteButtonBox, const IntSize& size)
-{
- static const int xOffset = -4;
- static const int yOffset = 5;
-
- float zoomLevel = muteButtonBox->style().effectiveZoom();
- int y = yOffset * zoomLevel + muteButtonBox->pixelSnappedOffsetHeight() - size.height();
- FloatPoint absPoint = muteButtonBox->localToAbsolute(FloatPoint(muteButtonBox->pixelSnappedOffsetLeft(), y), IsFixed | UseTransforms);
- if (absPoint.y() < 0)
- y = muteButtonBox->pixelSnappedHeight();
- return IntPoint(xOffset * zoomLevel, y);
-}
-
}
#endif