Index: third_party/WebKit/Source/core/paint/MediaControlsPainter.cpp |
diff --git a/third_party/WebKit/Source/core/paint/MediaControlsPainter.cpp b/third_party/WebKit/Source/core/paint/MediaControlsPainter.cpp |
index aa055f19b066f2a093872b23056e8f683f5dbe48..81385187bd6847e6af890db6a387552fab46fe44 100644 |
--- a/third_party/WebKit/Source/core/paint/MediaControlsPainter.cpp |
+++ b/third_party/WebKit/Source/core/paint/MediaControlsPainter.cpp |
@@ -89,15 +89,40 @@ static bool hasSource(const HTMLMediaElement* mediaElement) |
&& mediaElement->networkState() != HTMLMediaElement::NETWORK_NO_SOURCE; |
} |
-static bool paintMediaButton(GraphicsContext* context, const IntRect& rect, Image* image, bool isEnabled = true) |
+static FloatRect adjustRectForPadding(IntRect rect, const LayoutObject* object) |
philipj_slow
2015/10/28 12:38:07
It's surprising that it would be necessary to writ
|
{ |
- if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) |
- isEnabled = true; // New UI only. |
+ FloatRect adjustedRect(rect); |
+ |
+ if (!object) |
+ return adjustedRect; |
+ |
+ if (const ComputedStyle* style = object->style()) { |
+ const float paddingLeft = style->paddingLeft().getFloatValue(); |
+ const float paddingTop = style->paddingTop().getFloatValue(); |
+ const float paddingRight = style->paddingRight().getFloatValue(); |
+ const float paddingBottom = style->paddingBottom().getFloatValue(); |
+ adjustedRect = FloatRect(rect.x() + paddingLeft, |
+ rect.y() + paddingTop, |
+ rect.width() - paddingLeft - paddingRight, |
+ rect.height() - paddingTop - paddingBottom); |
+ } |
+ |
+ return adjustedRect; |
+} |
+ |
+static bool paintMediaButton(GraphicsContext* context, const IntRect& rect, Image* image, const LayoutObject* object, bool isEnabled) |
+{ |
+ if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) { |
+ context->drawImage(image, rect); |
+ return true; |
+ } |
+ |
+ FloatRect drawRect = adjustRectForPadding(rect, object); |
if (!isEnabled) |
context->beginLayer(kDisabledAlpha); |
- context->drawImage(image, rect); |
+ context->drawImage(image, drawRect, FloatRect(FloatPoint(), FloatSize(image->size()))); |
if (!isEnabled) |
context->endLayer(); |
@@ -105,6 +130,11 @@ static bool paintMediaButton(GraphicsContext* context, const IntRect& rect, Imag |
return true; |
} |
+static bool paintMediaButton(GraphicsContext* context, const IntRect& rect, Image* image, bool isEnabled = true) |
+{ |
+ return paintMediaButton(context, rect, image, 0, isEnabled); |
+} |
+ |
bool MediaControlsPainter::paintMediaMuteButton(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) |
{ |
const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
@@ -151,10 +181,10 @@ bool MediaControlsPainter::paintMediaPlayButton(const LayoutObject& object, cons |
static Image* mediaPlayDisabled = platformResource("mediaplayerPlayDisabled", "mediaplayerPlayNew"); |
if (!hasSource(mediaElement)) |
- return paintMediaButton(paintInfo.context, rect, mediaPlayDisabled, false); |
+ return paintMediaButton(paintInfo.context, rect, mediaPlayDisabled, &object, false); |
Image * image = !object.node()->isMediaControlElement() || mediaControlElementType(object.node()) == MediaPlayButton ? mediaPlay : mediaPause; |
- return paintMediaButton(paintInfo.context, rect, image); |
+ return paintMediaButton(paintInfo.context, rect, image, &object, true); |
} |
bool MediaControlsPainter::paintMediaOverlayPlayButton(const LayoutObject& object, const PaintInfo& paintInfo, const IntRect& rect) |