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 |
44 typedef WTF::HashMap<const char*, Image*> MediaControlImageMap; | 45 typedef WTF::HashMap<const char*, Image*> MediaControlImageMap; |
45 static MediaControlImageMap* gMediaControlImageMap = 0; | 46 static MediaControlImageMap* gMediaControlImageMap = 0; |
46 | 47 |
47 // Slider thumb sizes, shard between time and volume. | 48 // Slider thumb sizes, shard between time and volume. |
48 static const int mediaSliderThumbTouchWidth = 36; // Touch zone size. | 49 static const int mediaSliderThumbTouchWidth = 36; // Touch zone size. |
49 static const int mediaSliderThumbTouchHeight = 48; | 50 static const int mediaSliderThumbTouchHeight = 48; |
50 static const int mediaSliderThumbPaintWidth = 12; // Painted area. | 51 static const int mediaSliderThumbPaintWidth = 12; // Painted area. |
51 static const int mediaSliderThumbPaintHeight = 12; | 52 static const int mediaSliderThumbPaintHeight = 12; |
52 | 53 |
53 // Overlay play button size. | 54 // Overlay play button size. If this changes, it must also be changed in |
| 55 // core/html/shadow/MediaControls.cpp. |
54 static const int mediaOverlayPlayButtonWidth = 48; | 56 static const int mediaOverlayPlayButtonWidth = 48; |
55 static const int mediaOverlayPlayButtonHeight = 48; | 57 static const int mediaOverlayPlayButtonHeight = 48; |
56 | 58 |
57 // Alpha for disabled elements. | 59 // Alpha for disabled elements. |
58 static const float kDisabledAlpha = 0.4; | 60 static const float kDisabledAlpha = 0.4; |
59 | 61 |
60 static Image* platformResource(const char* name) { | 62 static Image* platformResource(const char* name) { |
61 if (!gMediaControlImageMap) | 63 if (!gMediaControlImageMap) |
62 gMediaControlImageMap = new MediaControlImageMap(); | 64 gMediaControlImageMap = new MediaControlImageMap(); |
63 if (Image* image = gMediaControlImageMap->at(name)) | 65 if (Image* image = gMediaControlImageMap->at(name)) |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 const LayoutObject& object, | 171 const LayoutObject& object, |
170 const PaintInfo& paintInfo, | 172 const PaintInfo& paintInfo, |
171 const IntRect& rect) { | 173 const IntRect& rect) { |
172 const HTMLMediaElement* mediaElement = toParentMediaElement(object); | 174 const HTMLMediaElement* mediaElement = toParentMediaElement(object); |
173 if (!mediaElement) | 175 if (!mediaElement) |
174 return false; | 176 return false; |
175 | 177 |
176 if (!hasSource(mediaElement) || !mediaElement->paused()) | 178 if (!hasSource(mediaElement) || !mediaElement->paused()) |
177 return false; | 179 return false; |
178 | 180 |
| 181 MediaControlPanelElement* panelElement = nullptr; |
| 182 if (mediaElement->mediaControls()) |
| 183 panelElement = mediaElement->mediaControls()->panelElement(); |
| 184 |
179 static Image* mediaOverlayPlay = platformResource("mediaplayerOverlayPlay"); | 185 static Image* mediaOverlayPlay = platformResource("mediaplayerOverlayPlay"); |
180 | 186 |
181 IntRect buttonRect(rect); | 187 IntRect buttonRect(rect); |
182 | 188 |
183 // Overlay play button covers the entire player, so center and draw a | 189 // Overlay play button covers the entire player, so center and draw a |
184 // smaller button. Center in the entire element. | 190 // smaller button. Center in the entire element. |
185 // TODO(liberato): object.enclosingBox()? | 191 // TODO(liberato): object.enclosingBox()? |
186 const LayoutBox* box = mediaElement->layoutObject()->enclosingBox(); | 192 const LayoutBox* box = mediaElement->layoutObject()->enclosingBox(); |
187 if (!box) | 193 if (!box) |
188 return false; | 194 return false; |
189 int mediaHeight = box->pixelSnappedHeight(); | 195 int mediaHeight = box->pixelSnappedHeight(); |
| 196 int mediaPanelHeight = panelElement ? panelElement->clientHeight() : 0; |
190 buttonRect.setX(rect.center().x() - mediaOverlayPlayButtonWidth / 2); | 197 buttonRect.setX(rect.center().x() - mediaOverlayPlayButtonWidth / 2); |
191 buttonRect.setY(rect.center().y() - mediaOverlayPlayButtonHeight / 2 + | 198 buttonRect.setY(rect.center().y() - mediaOverlayPlayButtonHeight / 2 + |
192 (mediaHeight - rect.height()) / 2); | 199 (mediaHeight - rect.height() - mediaPanelHeight) / 2); |
193 buttonRect.setWidth(mediaOverlayPlayButtonWidth); | 200 buttonRect.setWidth(mediaOverlayPlayButtonWidth); |
194 buttonRect.setHeight(mediaOverlayPlayButtonHeight); | 201 buttonRect.setHeight(mediaOverlayPlayButtonHeight); |
195 | 202 |
196 return paintMediaButton(paintInfo.context, buttonRect, mediaOverlayPlay); | 203 return paintMediaButton(paintInfo.context, buttonRect, mediaOverlayPlay); |
197 } | 204 } |
198 | 205 |
199 static void paintRoundedSliderBackground(const IntRect& rect, | 206 static void paintRoundedSliderBackground(const IntRect& rect, |
200 const ComputedStyle& style, | 207 const ComputedStyle& style, |
201 GraphicsContext& context, | 208 GraphicsContext& context, |
202 Color sliderBackgroundColor) { | 209 Color sliderBackgroundColor) { |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 void MediaControlsPainter::adjustMediaSliderThumbSize(ComputedStyle& style) { | 603 void MediaControlsPainter::adjustMediaSliderThumbSize(ComputedStyle& style) { |
597 const float zoomLevel = style.effectiveZoom(); | 604 const float zoomLevel = style.effectiveZoom(); |
598 | 605 |
599 style.setWidth( | 606 style.setWidth( |
600 Length(static_cast<int>(mediaSliderThumbTouchWidth * zoomLevel), Fixed)); | 607 Length(static_cast<int>(mediaSliderThumbTouchWidth * zoomLevel), Fixed)); |
601 style.setHeight( | 608 style.setHeight( |
602 Length(static_cast<int>(mediaSliderThumbTouchHeight * zoomLevel), Fixed)); | 609 Length(static_cast<int>(mediaSliderThumbTouchHeight * zoomLevel), Fixed)); |
603 } | 610 } |
604 | 611 |
605 } // namespace blink | 612 } // namespace blink |
OLD | NEW |