Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: Source/core/rendering/RenderMediaControls.cpp

Issue 894393003: Constify and use reference for RenderStyle in LayoutTheme (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix Mac take I. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderMediaControls.h ('k') | Source/core/rendering/RenderMenuList.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 static Image* mediaOverlayPlay = platformResource("mediaplayerOverlayPlay"); 122 static Image* mediaOverlayPlay = platformResource("mediaplayerOverlayPlay");
123 return paintMediaButton(paintInfo.context, rect, mediaOverlayPlay); 123 return paintMediaButton(paintInfo.context, rect, mediaOverlayPlay);
124 } 124 }
125 125
126 static Image* getMediaSliderThumb() 126 static Image* getMediaSliderThumb()
127 { 127 {
128 static Image* mediaSliderThumb = platformResource("mediaplayerSliderThumb"); 128 static Image* mediaSliderThumb = platformResource("mediaplayerSliderThumb");
129 return mediaSliderThumb; 129 return mediaSliderThumb;
130 } 130 }
131 131
132 static void paintRoundedSliderBackground(const IntRect& rect, const RenderStyle* style, GraphicsContext* context) 132 static void paintRoundedSliderBackground(const IntRect& rect, const RenderStyle& , GraphicsContext* context)
133 { 133 {
134 int borderRadius = rect.height() / 2; 134 int borderRadius = rect.height() / 2;
135 IntSize radii(borderRadius, borderRadius); 135 IntSize radii(borderRadius, borderRadius);
136 Color sliderBackgroundColor = Color(11, 11, 11); 136 Color sliderBackgroundColor = Color(11, 11, 11);
137 context->fillRoundedRect(rect, radii, radii, radii, radii, sliderBackgroundC olor); 137 context->fillRoundedRect(rect, radii, radii, radii, radii, sliderBackgroundC olor);
138 } 138 }
139 139
140 static void paintSliderRangeHighlight(const IntRect& rect, const RenderStyle* st yle, GraphicsContext* context, int startPosition, int endPosition, Color startCo lor, Color endColor) 140 static void paintSliderRangeHighlight(const IntRect& rect, const RenderStyle& st yle, GraphicsContext* context, int startPosition, int endPosition, Color startCo lor, Color endColor)
141 { 141 {
142 // Calculate border radius; need to avoid being smaller than half the slider height 142 // Calculate border radius; need to avoid being smaller than half the slider height
143 // because of https://bugs.webkit.org/show_bug.cgi?id=30143. 143 // because of https://bugs.webkit.org/show_bug.cgi?id=30143.
144 int borderRadius = rect.height() / 2; 144 int borderRadius = rect.height() / 2;
145 IntSize radii(borderRadius, borderRadius); 145 IntSize radii(borderRadius, borderRadius);
146 146
147 // Calculate highlight rectangle and edge dimensions. 147 // Calculate highlight rectangle and edge dimensions.
148 int startOffset = startPosition; 148 int startOffset = startPosition;
149 int endOffset = rect.width() - endPosition; 149 int endOffset = rect.width() - endPosition;
150 int rangeWidth = endPosition - startPosition; 150 int rangeWidth = endPosition - startPosition;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 193
194 const int mediaSliderThumbWidth = 32; 194 const int mediaSliderThumbWidth = 32;
195 195
196 static bool paintMediaSlider(RenderObject* object, const PaintInfo& paintInfo, c onst IntRect& rect) 196 static bool paintMediaSlider(RenderObject* object, const PaintInfo& paintInfo, c onst IntRect& rect)
197 { 197 {
198 HTMLMediaElement* mediaElement = toParentMediaElement(object); 198 HTMLMediaElement* mediaElement = toParentMediaElement(object);
199 if (!mediaElement) 199 if (!mediaElement)
200 return false; 200 return false;
201 201
202 RenderStyle* style = object->style(); 202 const RenderStyle& style = object->styleRef();
203 GraphicsContext* context = paintInfo.context; 203 GraphicsContext* context = paintInfo.context;
204 204
205 paintRoundedSliderBackground(rect, style, context); 205 paintRoundedSliderBackground(rect, style, context);
206 206
207 // Draw the buffered range. Since the element may have multiple buffered ran ges and it'd be 207 // Draw the buffered range. Since the element may have multiple buffered ran ges and it'd be
208 // distracting/'busy' to show all of them, show only the buffered range cont aining the current play head. 208 // distracting/'busy' to show all of them, show only the buffered range cont aining the current play head.
209 RefPtrWillBeRawPtr<TimeRanges> bufferedTimeRanges = mediaElement->buffered() ; 209 RefPtrWillBeRawPtr<TimeRanges> bufferedTimeRanges = mediaElement->buffered() ;
210 float duration = mediaElement->duration(); 210 float duration = mediaElement->duration();
211 float currentTime = mediaElement->currentTime(); 211 float currentTime = mediaElement->currentTime();
212 if (std::isnan(duration) || std::isinf(duration) || !duration || std::isnan( currentTime)) 212 if (std::isnan(duration) || std::isinf(duration) || !duration || std::isnan( currentTime))
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 const int mediaVolumeSliderThumbWidth = 24; 264 const int mediaVolumeSliderThumbWidth = 24;
265 265
266 static bool paintMediaVolumeSlider(RenderObject* object, const PaintInfo& paintI nfo, const IntRect& rect) 266 static bool paintMediaVolumeSlider(RenderObject* object, const PaintInfo& paintI nfo, const IntRect& rect)
267 { 267 {
268 HTMLMediaElement* mediaElement = toParentMediaElement(object); 268 HTMLMediaElement* mediaElement = toParentMediaElement(object);
269 if (!mediaElement) 269 if (!mediaElement)
270 return false; 270 return false;
271 271
272 GraphicsContext* context = paintInfo.context; 272 GraphicsContext* context = paintInfo.context;
273 RenderStyle* style = object->style(); 273 const RenderStyle& style = object->styleRef();
274 274
275 paintRoundedSliderBackground(rect, style, context); 275 paintRoundedSliderBackground(rect, style, context);
276 276
277 // Calculate volume position for white background rectangle. 277 // Calculate volume position for white background rectangle.
278 float volume = mediaElement->volume(); 278 float volume = mediaElement->volume();
279 if (std::isnan(volume) || volume < 0) 279 if (std::isnan(volume) || volume < 0)
280 return true; 280 return true;
281 if (volume > 1) 281 if (volume > 1)
282 volume = 1; 282 volume = 1;
283 if (!hasSource(mediaElement) || !mediaElement->hasAudio() || mediaElement->m uted()) 283 if (!hasSource(mediaElement) || !mediaElement->hasAudio() || mediaElement->m uted())
284 volume = 0; 284 volume = 0;
285 285
286 // Calculate the position relative to the center of the thumb. 286 // Calculate the position relative to the center of the thumb.
287 float fillWidth = 0; 287 float fillWidth = 0;
288 if (volume > 0) { 288 if (volume > 0) {
289 float thumbCenter = mediaVolumeSliderThumbWidth / 2; 289 float thumbCenter = mediaVolumeSliderThumbWidth / 2;
290 float zoomLevel = style->effectiveZoom(); 290 float zoomLevel = style.effectiveZoom();
291 float positionWidth = volume * (rect.width() - (zoomLevel * thumbCenter) ); 291 float positionWidth = volume * (rect.width() - (zoomLevel * thumbCenter) );
292 fillWidth = positionWidth + (zoomLevel * thumbCenter / 2); 292 fillWidth = positionWidth + (zoomLevel * thumbCenter / 2);
293 } 293 }
294 294
295 Color startColor = Color(195, 195, 195); 295 Color startColor = Color(195, 195, 195);
296 Color endColor = Color(217, 217, 217); 296 Color endColor = Color(217, 217, 217);
297 297
298 paintSliderRangeHighlight(rect, style, context, 0.0, fillWidth, startColor, endColor); 298 paintSliderRangeHighlight(rect, style, context, 0.0, fillWidth, startColor, endColor);
299 299
300 return true; 300 return true;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 case MediaFullScreenVolumeSliderThumb: 408 case MediaFullScreenVolumeSliderThumb:
409 ASSERT_NOT_REACHED(); 409 ASSERT_NOT_REACHED();
410 break; 410 break;
411 } 411 }
412 return false; 412 return false;
413 } 413 }
414 414
415 const int mediaSliderThumbHeight = 24; 415 const int mediaSliderThumbHeight = 24;
416 const int mediaVolumeSliderThumbHeight = 24; 416 const int mediaVolumeSliderThumbHeight = 24;
417 417
418 void RenderMediaControls::adjustMediaSliderThumbSize(RenderStyle* style) 418 void RenderMediaControls::adjustMediaSliderThumbSize(RenderStyle& style)
419 { 419 {
420 static Image* mediaSliderThumb = platformResource("mediaplayerSliderThumb"); 420 static Image* mediaSliderThumb = platformResource("mediaplayerSliderThumb");
421 static Image* mediaVolumeSliderThumb = platformResource("mediaplayerVolumeSl iderThumb"); 421 static Image* mediaVolumeSliderThumb = platformResource("mediaplayerVolumeSl iderThumb");
422 int width = 0; 422 int width = 0;
423 int height = 0; 423 int height = 0;
424 424
425 Image* thumbImage = 0; 425 Image* thumbImage = 0;
426 if (style->appearance() == MediaSliderThumbPart) { 426 if (style.appearance() == MediaSliderThumbPart) {
427 thumbImage = mediaSliderThumb; 427 thumbImage = mediaSliderThumb;
428 width = mediaSliderThumbWidth; 428 width = mediaSliderThumbWidth;
429 height = mediaSliderThumbHeight; 429 height = mediaSliderThumbHeight;
430 } else if (style->appearance() == MediaVolumeSliderThumbPart) { 430 } else if (style.appearance() == MediaVolumeSliderThumbPart) {
431 thumbImage = mediaVolumeSliderThumb; 431 thumbImage = mediaVolumeSliderThumb;
432 width = mediaVolumeSliderThumbWidth; 432 width = mediaVolumeSliderThumbWidth;
433 height = mediaVolumeSliderThumbHeight; 433 height = mediaVolumeSliderThumbHeight;
434 } 434 }
435 435
436 float zoomLevel = style->effectiveZoom(); 436 float zoomLevel = style.effectiveZoom();
437 if (thumbImage) { 437 if (thumbImage) {
438 style->setWidth(Length(static_cast<int>(width * zoomLevel), Fixed)); 438 style.setWidth(Length(static_cast<int>(width * zoomLevel), Fixed));
439 style->setHeight(Length(static_cast<int>(height * zoomLevel), Fixed)); 439 style.setHeight(Length(static_cast<int>(height * zoomLevel), Fixed));
440 } 440 }
441 } 441 }
442 442
443 static String formatChromiumMediaControlsTime(float time, float duration) 443 static String formatChromiumMediaControlsTime(float time, float duration)
444 { 444 {
445 if (!std::isfinite(time)) 445 if (!std::isfinite(time))
446 time = 0; 446 time = 0;
447 if (!std::isfinite(duration)) 447 if (!std::isfinite(duration))
448 duration = 0; 448 duration = 0;
449 int seconds = static_cast<int>(fabsf(time)); 449 int seconds = static_cast<int>(fabsf(time));
(...skipping 18 matching lines...) Expand all
468 { 468 {
469 return formatChromiumMediaControlsTime(time, time); 469 return formatChromiumMediaControlsTime(time, time);
470 } 470 }
471 471
472 String RenderMediaControls::formatMediaControlsCurrentTime(float currentTime, fl oat duration) 472 String RenderMediaControls::formatMediaControlsCurrentTime(float currentTime, fl oat duration)
473 { 473 {
474 return formatChromiumMediaControlsTime(currentTime, duration); 474 return formatChromiumMediaControlsTime(currentTime, duration);
475 } 475 }
476 476
477 } // namespace blink 477 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderMediaControls.h ('k') | Source/core/rendering/RenderMenuList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698