Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. | 2 * Copyright (C) 2009 Apple Inc. |
| 3 * Copyright (C) 2009 Google Inc. | 3 * Copyright (C) 2009 Google Inc. |
| 4 * All rights reserved. | 4 * All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 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 13 matching lines...) Expand all Loading... | |
| 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include "core/paint/MediaControlsPainter.h" | 28 #include "core/paint/MediaControlsPainter.h" |
| 29 | 29 |
| 30 #include "bindings/core/v8/ExceptionState.h" | 30 #include "bindings/core/v8/ExceptionState.h" |
| 31 #include "core/html/HTMLMediaElement.h" | 31 #include "core/html/HTMLMediaElement.h" |
| 32 #include "core/html/TimeRanges.h" | 32 #include "core/html/TimeRanges.h" |
| 33 #include "core/html/shadow/MediaControlElementTypes.h" | 33 #include "core/html/shadow/MediaControlElementTypes.h" |
| 34 #include "core/html/shadow/MediaControls.h" | |
| 34 #include "core/layout/LayoutBox.h" | 35 #include "core/layout/LayoutBox.h" |
| 35 #include "core/paint/PaintInfo.h" | 36 #include "core/paint/PaintInfo.h" |
| 36 #include "core/style/ComputedStyle.h" | 37 #include "core/style/ComputedStyle.h" |
| 37 #include "platform/graphics/Gradient.h" | 38 #include "platform/graphics/Gradient.h" |
| 38 #include "platform/graphics/GraphicsContext.h" | 39 #include "platform/graphics/GraphicsContext.h" |
| 39 | 40 |
| 40 namespace blink { | 41 namespace blink { |
| 41 | 42 |
| 42 static const double kCurrentTimeBufferedDelta = 1.0; | 43 static const double kCurrentTimeBufferedDelta = 1.0; |
| 43 | 44 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 const LayoutObject& object, | 170 const LayoutObject& object, |
| 170 const PaintInfo& paintInfo, | 171 const PaintInfo& paintInfo, |
| 171 const IntRect& rect) { | 172 const IntRect& rect) { |
| 172 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 173 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
| 173 if (!mediaElement) | 174 if (!mediaElement) |
| 174 return false; | 175 return false; |
| 175 | 176 |
| 176 if (!hasSource(mediaElement) || !mediaElement->paused()) | 177 if (!hasSource(mediaElement) || !mediaElement->paused()) |
| 177 return false; | 178 return false; |
| 178 | 179 |
| 180 MediaControlPanelElement* panelElement = nullptr; | |
| 181 if (mediaElement->mediaControls()) | |
| 182 panelElement = mediaElement->mediaControls()->panelElement(); | |
| 183 | |
| 179 static Image* mediaOverlayPlay = platformResource("mediaplayerOverlayPlay"); | 184 static Image* mediaOverlayPlay = platformResource("mediaplayerOverlayPlay"); |
| 180 | 185 |
| 181 IntRect buttonRect(rect); | 186 IntRect buttonRect(rect); |
| 182 | 187 |
| 183 // Overlay play button covers the entire player, so center and draw a | 188 // Overlay play button covers the entire player, so center and draw a |
| 184 // smaller button. Center in the entire element. | 189 // smaller button. Center in the entire element. |
| 185 // TODO(liberato): object.enclosingBox()? | 190 // TODO(liberato): object.enclosingBox()? |
| 186 const LayoutBox* box = mediaElement->layoutObject()->enclosingBox(); | 191 const LayoutBox* box = mediaElement->layoutObject()->enclosingBox(); |
| 187 if (!box) | 192 if (!box) |
| 188 return false; | 193 return false; |
| 189 int mediaHeight = box->pixelSnappedHeight(); | 194 int mediaHeight = box->pixelSnappedHeight(); |
| 195 int mediaPanelHeight = 0; | |
| 196 if (panelElement) | |
| 197 mediaPanelHeight = panelElement->clientHeight(); | |
|
mlamouri (slow - plz ping)
2017/03/08 19:13:04
I'm a huge fan of ternary operator and I would obv
steimel
2017/03/09 16:42:24
Done.
| |
| 190 buttonRect.setX(rect.center().x() - mediaOverlayPlayButtonWidth / 2); | 198 buttonRect.setX(rect.center().x() - mediaOverlayPlayButtonWidth / 2); |
| 191 buttonRect.setY(rect.center().y() - mediaOverlayPlayButtonHeight / 2 + | 199 buttonRect.setY(rect.center().y() - mediaOverlayPlayButtonHeight / 2 + |
| 192 (mediaHeight - rect.height()) / 2); | 200 (mediaHeight - rect.height() - mediaPanelHeight) / 2); |
| 193 buttonRect.setWidth(mediaOverlayPlayButtonWidth); | 201 buttonRect.setWidth(mediaOverlayPlayButtonWidth); |
| 194 buttonRect.setHeight(mediaOverlayPlayButtonHeight); | 202 buttonRect.setHeight(mediaOverlayPlayButtonHeight); |
| 195 | 203 |
| 196 return paintMediaButton(paintInfo.context, buttonRect, mediaOverlayPlay); | 204 return paintMediaButton(paintInfo.context, buttonRect, mediaOverlayPlay); |
| 197 } | 205 } |
| 198 | 206 |
| 199 static void paintRoundedSliderBackground(const IntRect& rect, | 207 static void paintRoundedSliderBackground(const IntRect& rect, |
| 200 const ComputedStyle& style, | 208 const ComputedStyle& style, |
| 201 GraphicsContext& context, | 209 GraphicsContext& context, |
| 202 Color sliderBackgroundColor) { | 210 Color sliderBackgroundColor) { |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 void MediaControlsPainter::adjustMediaSliderThumbSize(ComputedStyle& style) { | 604 void MediaControlsPainter::adjustMediaSliderThumbSize(ComputedStyle& style) { |
| 597 const float zoomLevel = style.effectiveZoom(); | 605 const float zoomLevel = style.effectiveZoom(); |
| 598 | 606 |
| 599 style.setWidth( | 607 style.setWidth( |
| 600 Length(static_cast<int>(mediaSliderThumbTouchWidth * zoomLevel), Fixed)); | 608 Length(static_cast<int>(mediaSliderThumbTouchWidth * zoomLevel), Fixed)); |
| 601 style.setHeight( | 609 style.setHeight( |
| 602 Length(static_cast<int>(mediaSliderThumbTouchHeight * zoomLevel), Fixed)); | 610 Length(static_cast<int>(mediaSliderThumbTouchHeight * zoomLevel), Fixed)); |
| 603 } | 611 } |
| 604 | 612 |
| 605 } // namespace blink | 613 } // namespace blink |
| OLD | NEW |