| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. | 2 * Copyright (C) 2007 Apple Inc. |
| 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 4 * Copyright (C) 2008 Collabora Ltd. | 4 * Copyright (C) 2008 Collabora Ltd. |
| 5 * Copyright (C) 2008, 2009 Google Inc. | 5 * Copyright (C) 2008, 2009 Google Inc. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // Compute an offset between the part renderer and the input renderer. | 216 // Compute an offset between the part renderer and the input renderer. |
| 217 LayoutSize offsetFromInputRenderer = -partRenderer->offsetFromAncestorContai
ner(inputRenderer); | 217 LayoutSize offsetFromInputRenderer = -partRenderer->offsetFromAncestorContai
ner(inputRenderer); |
| 218 // Move the rect into partRenderer's coords. | 218 // Move the rect into partRenderer's coords. |
| 219 partRect.move(offsetFromInputRenderer); | 219 partRect.move(offsetFromInputRenderer); |
| 220 // Account for the local drawing offset. | 220 // Account for the local drawing offset. |
| 221 partRect.move(localOffset.x(), localOffset.y()); | 221 partRect.move(localOffset.x(), localOffset.y()); |
| 222 | 222 |
| 223 return pixelSnappedIntRect(partRect); | 223 return pixelSnappedIntRect(partRect); |
| 224 } | 224 } |
| 225 | 225 |
| 226 bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* cancelB
uttonObject, const PaintInfo& paintInfo, const IntRect& r) | 226 bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* cancelB
uttonObject, PaintInfo& paintInfo, const IntRect& r) |
| 227 { | 227 { |
| 228 // Get the renderer of <input> element. | 228 // Get the renderer of <input> element. |
| 229 Node* input = cancelButtonObject->node()->shadowHost(); | 229 Node* input = cancelButtonObject->node()->shadowHost(); |
| 230 RenderObject* baseRenderer = input ? input->renderer() : cancelButtonObject; | 230 RenderObject* baseRenderer = input ? input->renderer() : cancelButtonObject; |
| 231 if (!baseRenderer->isBox()) | 231 if (!baseRenderer->isBox()) |
| 232 return false; | 232 return false; |
| 233 RenderBox* inputRenderBox = toRenderBox(baseRenderer); | 233 RenderBox* inputRenderBox = toRenderBox(baseRenderer); |
| 234 LayoutRect inputContentBox = inputRenderBox->contentBoxRect(); | 234 LayoutRect inputContentBox = inputRenderBox->contentBoxRect(); |
| 235 | 235 |
| 236 // Make sure the scaled button stays square and will fit in its parent's box
. | 236 // Make sure the scaled button stays square and will fit in its parent's box
. |
| 237 LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min<Lay
outUnit>(inputContentBox.height(), r.height())); | 237 LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min<Lay
outUnit>(inputContentBox.height(), r.height())); |
| 238 // Calculate cancel button's coordinates relative to the input element. | 238 // Calculate cancel button's coordinates relative to the input element. |
| 239 // Center the button vertically. Round up though, so if it has to be one pi
xel off-center, it will | 239 // Center the button vertically. Round up though, so if it has to be one pi
xel off-center, it will |
| 240 // be one pixel closer to the bottom of the field. This tends to look bette
r with the text. | 240 // be one pixel closer to the bottom of the field. This tends to look bette
r with the text. |
| 241 LayoutRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(
inputRenderBox).width(), | 241 LayoutRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(
inputRenderBox).width(), |
| 242 inputContentBox.y() + (inputContentBox.height()
- cancelButtonSize + 1) / 2, | 242 inputContentBox.y() + (inputContentBox.height()
- cancelButtonSize + 1) / 2, |
| 243 cancelButtonSize, cancelButtonSize); | 243 cancelButtonSize, cancelButtonSize); |
| 244 IntRect paintingRect = convertToPaintingRect(inputRenderBox, cancelButtonObj
ect, cancelButtonRect, r); | 244 IntRect paintingRect = convertToPaintingRect(inputRenderBox, cancelButtonObj
ect, cancelButtonRect, r); |
| 245 | 245 |
| 246 static Image* cancelImage = Image::loadPlatformResource("searchCancel").leak
Ref(); | 246 static Image* cancelImage = Image::loadPlatformResource("searchCancel").leak
Ref(); |
| 247 static Image* cancelPressedImage = Image::loadPlatformResource("searchCancel
Pressed").leakRef(); | 247 static Image* cancelPressedImage = Image::loadPlatformResource("searchCancel
Pressed").leakRef(); |
| 248 paintInfo.context->drawImage(isPressed(cancelButtonObject) ? cancelPressedIm
age : cancelImage, paintingRect); | 248 paintInfo.getContext()->drawImage(isPressed(cancelButtonObject) ? cancelPres
sedImage : cancelImage, paintingRect); |
| 249 return false; | 249 return false; |
| 250 } | 250 } |
| 251 | 251 |
| 252 void RenderThemeChromiumSkia::adjustSearchFieldDecorationStyle(RenderStyle* styl
e, Element*) const | 252 void RenderThemeChromiumSkia::adjustSearchFieldDecorationStyle(RenderStyle* styl
e, Element*) const |
| 253 { | 253 { |
| 254 IntSize emptySize(1, 11); | 254 IntSize emptySize(1, 11); |
| 255 style->setWidth(Length(emptySize.width(), Fixed)); | 255 style->setWidth(Length(emptySize.width(), Fixed)); |
| 256 style->setHeight(Length(emptySize.height(), Fixed)); | 256 style->setHeight(Length(emptySize.height(), Fixed)); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void RenderThemeChromiumSkia::adjustSearchFieldResultsDecorationStyle(RenderStyl
e* style, Element*) const | 259 void RenderThemeChromiumSkia::adjustSearchFieldResultsDecorationStyle(RenderStyl
e* style, Element*) const |
| 260 { | 260 { |
| 261 // Scale the decoration size based on the font size | 261 // Scale the decoration size based on the font size |
| 262 float fontScale = style->fontSize() / defaultControlFontPixelSize; | 262 float fontScale = style->fontSize() / defaultControlFontPixelSize; |
| 263 int magnifierSize = lroundf(std::min(std::max(minSearchFieldResultsDecoratio
nSize, defaultSearchFieldResultsDecorationSize * fontScale), | 263 int magnifierSize = lroundf(std::min(std::max(minSearchFieldResultsDecoratio
nSize, defaultSearchFieldResultsDecorationSize * fontScale), |
| 264 maxSearchFieldResultsDecorationSize)); | 264 maxSearchFieldResultsDecorationSize)); |
| 265 style->setWidth(Length(magnifierSize, Fixed)); | 265 style->setWidth(Length(magnifierSize, Fixed)); |
| 266 style->setHeight(Length(magnifierSize, Fixed)); | 266 style->setHeight(Length(magnifierSize, Fixed)); |
| 267 } | 267 } |
| 268 | 268 |
| 269 bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* ma
gnifierObject, const PaintInfo& paintInfo, const IntRect& r) | 269 bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* ma
gnifierObject, PaintInfo& paintInfo, const IntRect& r) |
| 270 { | 270 { |
| 271 // Get the renderer of <input> element. | 271 // Get the renderer of <input> element. |
| 272 Node* input = magnifierObject->node()->shadowHost(); | 272 Node* input = magnifierObject->node()->shadowHost(); |
| 273 RenderObject* baseRenderer = input ? input->renderer() : magnifierObject; | 273 RenderObject* baseRenderer = input ? input->renderer() : magnifierObject; |
| 274 if (!baseRenderer->isBox()) | 274 if (!baseRenderer->isBox()) |
| 275 return false; | 275 return false; |
| 276 RenderBox* inputRenderBox = toRenderBox(baseRenderer); | 276 RenderBox* inputRenderBox = toRenderBox(baseRenderer); |
| 277 LayoutRect inputContentBox = inputRenderBox->contentBoxRect(); | 277 LayoutRect inputContentBox = inputRenderBox->contentBoxRect(); |
| 278 | 278 |
| 279 // Make sure the scaled decoration stays square and will fit in its parent's
box. | 279 // Make sure the scaled decoration stays square and will fit in its parent's
box. |
| 280 LayoutUnit magnifierSize = std::min(inputContentBox.width(), std::min<Layout
Unit>(inputContentBox.height(), r.height())); | 280 LayoutUnit magnifierSize = std::min(inputContentBox.width(), std::min<Layout
Unit>(inputContentBox.height(), r.height())); |
| 281 // Calculate decoration's coordinates relative to the input element. | 281 // Calculate decoration's coordinates relative to the input element. |
| 282 // Center the decoration vertically. Round up though, so if it has to be on
e pixel off-center, it will | 282 // Center the decoration vertically. Round up though, so if it has to be on
e pixel off-center, it will |
| 283 // be one pixel closer to the bottom of the field. This tends to look bette
r with the text. | 283 // be one pixel closer to the bottom of the field. This tends to look bette
r with the text. |
| 284 LayoutRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputR
enderBox).width(), | 284 LayoutRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputR
enderBox).width(), |
| 285 inputContentBox.y() + (inputContentBox.height() - m
agnifierSize + 1) / 2, | 285 inputContentBox.y() + (inputContentBox.height() - m
agnifierSize + 1) / 2, |
| 286 magnifierSize, magnifierSize); | 286 magnifierSize, magnifierSize); |
| 287 IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject
, magnifierRect, r); | 287 IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject
, magnifierRect, r); |
| 288 | 288 |
| 289 static Image* magnifierImage = Image::loadPlatformResource("searchMagnifier"
).leakRef(); | 289 static Image* magnifierImage = Image::loadPlatformResource("searchMagnifier"
).leakRef(); |
| 290 paintInfo.context->drawImage(magnifierImage, paintingRect); | 290 paintInfo.getContext()->drawImage(magnifierImage, paintingRect); |
| 291 return false; | 291 return false; |
| 292 } | 292 } |
| 293 | 293 |
| 294 bool RenderThemeChromiumSkia::paintMediaSliderTrack(RenderObject* object, const
PaintInfo& paintInfo, const IntRect& rect) | 294 bool RenderThemeChromiumSkia::paintMediaSliderTrack(RenderObject* object, PaintI
nfo& paintInfo, const IntRect& rect) |
| 295 { | 295 { |
| 296 return RenderMediaControlsChromium::paintMediaControlsPart(MediaSlider, obje
ct, paintInfo, rect); | 296 return RenderMediaControlsChromium::paintMediaControlsPart(MediaSlider, obje
ct, paintInfo, rect); |
| 297 } | 297 } |
| 298 | 298 |
| 299 bool RenderThemeChromiumSkia::paintMediaVolumeSliderTrack(RenderObject* object,
const PaintInfo& paintInfo, const IntRect& rect) | 299 bool RenderThemeChromiumSkia::paintMediaVolumeSliderTrack(RenderObject* object,
PaintInfo& paintInfo, const IntRect& rect) |
| 300 { | 300 { |
| 301 return RenderMediaControlsChromium::paintMediaControlsPart(MediaVolumeSlider
, object, paintInfo, rect); | 301 return RenderMediaControlsChromium::paintMediaControlsPart(MediaVolumeSlider
, object, paintInfo, rect); |
| 302 } | 302 } |
| 303 | 303 |
| 304 void RenderThemeChromiumSkia::adjustSliderThumbSize(RenderStyle* style, Element*
) const | 304 void RenderThemeChromiumSkia::adjustSliderThumbSize(RenderStyle* style, Element*
) const |
| 305 { | 305 { |
| 306 RenderMediaControlsChromium::adjustMediaSliderThumbSize(style); | 306 RenderMediaControlsChromium::adjustMediaSliderThumbSize(style); |
| 307 } | 307 } |
| 308 | 308 |
| 309 bool RenderThemeChromiumSkia::paintMediaSliderThumb(RenderObject* object, const
PaintInfo& paintInfo, const IntRect& rect) | 309 bool RenderThemeChromiumSkia::paintMediaSliderThumb(RenderObject* object, PaintI
nfo& paintInfo, const IntRect& rect) |
| 310 { | 310 { |
| 311 return RenderMediaControlsChromium::paintMediaControlsPart(MediaSliderThumb,
object, paintInfo, rect); | 311 return RenderMediaControlsChromium::paintMediaControlsPart(MediaSliderThumb,
object, paintInfo, rect); |
| 312 } | 312 } |
| 313 | 313 |
| 314 bool RenderThemeChromiumSkia::paintMediaToggleClosedCaptionsButton(RenderObject*
o, const PaintInfo& paintInfo, const IntRect& r) | 314 bool RenderThemeChromiumSkia::paintMediaToggleClosedCaptionsButton(RenderObject*
o, PaintInfo& paintInfo, const IntRect& r) |
| 315 { | 315 { |
| 316 return RenderMediaControlsChromium::paintMediaControlsPart(MediaShowClosedCa
ptionsButton, o, paintInfo, r); | 316 return RenderMediaControlsChromium::paintMediaControlsPart(MediaShowClosedCa
ptionsButton, o, paintInfo, r); |
| 317 } | 317 } |
| 318 | 318 |
| 319 bool RenderThemeChromiumSkia::paintMediaVolumeSliderThumb(RenderObject* object,
const PaintInfo& paintInfo, const IntRect& rect) | 319 bool RenderThemeChromiumSkia::paintMediaVolumeSliderThumb(RenderObject* object,
PaintInfo& paintInfo, const IntRect& rect) |
| 320 { | 320 { |
| 321 return RenderMediaControlsChromium::paintMediaControlsPart(MediaVolumeSlider
Thumb, object, paintInfo, rect); | 321 return RenderMediaControlsChromium::paintMediaControlsPart(MediaVolumeSlider
Thumb, object, paintInfo, rect); |
| 322 } | 322 } |
| 323 | 323 |
| 324 bool RenderThemeChromiumSkia::paintMediaPlayButton(RenderObject* object, const P
aintInfo& paintInfo, const IntRect& rect) | 324 bool RenderThemeChromiumSkia::paintMediaPlayButton(RenderObject* object, PaintIn
fo& paintInfo, const IntRect& rect) |
| 325 { | 325 { |
| 326 return RenderMediaControlsChromium::paintMediaControlsPart(MediaPlayButton,
object, paintInfo, rect); | 326 return RenderMediaControlsChromium::paintMediaControlsPart(MediaPlayButton,
object, paintInfo, rect); |
| 327 } | 327 } |
| 328 | 328 |
| 329 bool RenderThemeChromiumSkia::paintMediaMuteButton(RenderObject* object, const P
aintInfo& paintInfo, const IntRect& rect) | 329 bool RenderThemeChromiumSkia::paintMediaMuteButton(RenderObject* object, PaintIn
fo& paintInfo, const IntRect& rect) |
| 330 { | 330 { |
| 331 return RenderMediaControlsChromium::paintMediaControlsPart(MediaMuteButton,
object, paintInfo, rect); | 331 return RenderMediaControlsChromium::paintMediaControlsPart(MediaMuteButton,
object, paintInfo, rect); |
| 332 } | 332 } |
| 333 | 333 |
| 334 String RenderThemeChromiumSkia::formatMediaControlsTime(float time) const | 334 String RenderThemeChromiumSkia::formatMediaControlsTime(float time) const |
| 335 { | 335 { |
| 336 return RenderMediaControlsChromium::formatMediaControlsTime(time); | 336 return RenderMediaControlsChromium::formatMediaControlsTime(time); |
| 337 } | 337 } |
| 338 | 338 |
| 339 String RenderThemeChromiumSkia::formatMediaControlsCurrentTime(float currentTime
, float duration) const | 339 String RenderThemeChromiumSkia::formatMediaControlsCurrentTime(float currentTime
, float duration) const |
| 340 { | 340 { |
| 341 return RenderMediaControlsChromium::formatMediaControlsCurrentTime(currentTi
me, duration); | 341 return RenderMediaControlsChromium::formatMediaControlsCurrentTime(currentTi
me, duration); |
| 342 } | 342 } |
| 343 | 343 |
| 344 bool RenderThemeChromiumSkia::paintMediaFullscreenButton(RenderObject* object, c
onst PaintInfo& paintInfo, const IntRect& rect) | 344 bool RenderThemeChromiumSkia::paintMediaFullscreenButton(RenderObject* object, P
aintInfo& paintInfo, const IntRect& rect) |
| 345 { | 345 { |
| 346 return RenderMediaControlsChromium::paintMediaControlsPart(MediaEnterFullscr
eenButton, object, paintInfo, rect); | 346 return RenderMediaControlsChromium::paintMediaControlsPart(MediaEnterFullscr
eenButton, object, paintInfo, rect); |
| 347 } | 347 } |
| 348 | 348 |
| 349 void RenderThemeChromiumSkia::adjustMenuListStyle(RenderStyle* style, WebCore::E
lement*) const | 349 void RenderThemeChromiumSkia::adjustMenuListStyle(RenderStyle* style, WebCore::E
lement*) const |
| 350 { | 350 { |
| 351 // Height is locked to auto on all browsers. | 351 // Height is locked to auto on all browsers. |
| 352 style->setLineHeight(RenderStyle::initialLineHeight()); | 352 style->setLineHeight(RenderStyle::initialLineHeight()); |
| 353 } | 353 } |
| 354 | 354 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 double RenderThemeChromiumSkia::animationDurationForProgressBar(RenderProgress*
renderProgress) const | 458 double RenderThemeChromiumSkia::animationDurationForProgressBar(RenderProgress*
renderProgress) const |
| 459 { | 459 { |
| 460 return progressAnimationInterval * progressAnimationFrmaes * 2; // "2" for b
ack and forth | 460 return progressAnimationInterval * progressAnimationFrmaes * 2; // "2" for b
ack and forth |
| 461 } | 461 } |
| 462 | 462 |
| 463 IntRect RenderThemeChromiumSkia::progressValueRectFor(RenderProgress* renderProg
ress, const IntRect& rect) const | 463 IntRect RenderThemeChromiumSkia::progressValueRectFor(RenderProgress* renderProg
ress, const IntRect& rect) const |
| 464 { | 464 { |
| 465 return renderProgress->isDeterminate() ? determinateProgressValueRectFor(ren
derProgress, rect) : indeterminateProgressValueRectFor(renderProgress, rect); | 465 return renderProgress->isDeterminate() ? determinateProgressValueRectFor(ren
derProgress, rect) : indeterminateProgressValueRectFor(renderProgress, rect); |
| 466 } | 466 } |
| 467 | 467 |
| 468 RenderThemeChromiumSkia::DirectionFlippingScope::DirectionFlippingScope(RenderOb
ject* renderer, const PaintInfo& paintInfo, const IntRect& rect) | 468 RenderThemeChromiumSkia::DirectionFlippingScope::DirectionFlippingScope(RenderOb
ject* renderer, PaintInfo& paintInfo, const IntRect& rect) |
| 469 : m_needsFlipping(!renderer->style()->isLeftToRightDirection()) | 469 : m_needsFlipping(!renderer->style()->isLeftToRightDirection()) |
| 470 , m_paintInfo(paintInfo) | 470 , m_paintInfo(paintInfo) |
| 471 { | 471 { |
| 472 if (!m_needsFlipping) | 472 if (!m_needsFlipping) |
| 473 return; | 473 return; |
| 474 m_paintInfo.context->save(); | 474 m_paintInfo.getContext()->save(); |
| 475 m_paintInfo.context->translate(2 * rect.x() + rect.width(), 0); | 475 m_paintInfo.getContext()->translate(2 * rect.x() + rect.width(), 0); |
| 476 m_paintInfo.context->scale(FloatSize(-1, 1)); | 476 m_paintInfo.getContext()->scale(FloatSize(-1, 1)); |
| 477 } | 477 } |
| 478 | 478 |
| 479 RenderThemeChromiumSkia::DirectionFlippingScope::~DirectionFlippingScope() | 479 RenderThemeChromiumSkia::DirectionFlippingScope::~DirectionFlippingScope() |
| 480 { | 480 { |
| 481 if (!m_needsFlipping) | 481 if (!m_needsFlipping) |
| 482 return; | 482 return; |
| 483 m_paintInfo.context->restore(); | 483 m_paintInfo.getContext()->restore(); |
| 484 } | 484 } |
| 485 | 485 |
| 486 } // namespace WebCore | 486 } // namespace WebCore |
| OLD | NEW |