| 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 * Copyright (C) 2009 Kenneth Rohde Christiansen | 6 * Copyright (C) 2009 Kenneth Rohde Christiansen |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 if (!cancelButtonObject.node()) | 371 if (!cancelButtonObject.node()) |
| 372 return false; | 372 return false; |
| 373 Node* input = cancelButtonObject.node()->shadowHost(); | 373 Node* input = cancelButtonObject.node()->shadowHost(); |
| 374 const LayoutObject& baseLayoutObject = input ? *input->layoutObject() : canc
elButtonObject; | 374 const LayoutObject& baseLayoutObject = input ? *input->layoutObject() : canc
elButtonObject; |
| 375 if (!baseLayoutObject.isBox()) | 375 if (!baseLayoutObject.isBox()) |
| 376 return false; | 376 return false; |
| 377 const LayoutBox& inputLayoutBox = toLayoutBox(baseLayoutObject); | 377 const LayoutBox& inputLayoutBox = toLayoutBox(baseLayoutObject); |
| 378 LayoutRect inputContentBox = inputLayoutBox.contentBoxRect(); | 378 LayoutRect inputContentBox = inputLayoutBox.contentBoxRect(); |
| 379 | 379 |
| 380 // Make sure the scaled button stays square and will fit in its parent's box
. | 380 // Make sure the scaled button stays square and will fit in its parent's box
. |
| 381 LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min<Lay
outUnit>(inputContentBox.height(), r.height())); | 381 LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min(inp
utContentBox.height(), LayoutUnit(r.height()))); |
| 382 // Calculate cancel button's coordinates relative to the input element. | 382 // Calculate cancel button's coordinates relative to the input element. |
| 383 // Center the button vertically. Round up though, so if it has to be one pi
xel off-center, it will | 383 // Center the button vertically. Round up though, so if it has to be one pi
xel off-center, it will |
| 384 // be one pixel closer to the bottom of the field. This tends to look bette
r with the text. | 384 // be one pixel closer to the bottom of the field. This tends to look bette
r with the text. |
| 385 LayoutRect cancelButtonRect(cancelButtonObject.offsetFromAncestorContainer(&
inputLayoutBox).width(), | 385 LayoutRect cancelButtonRect(cancelButtonObject.offsetFromAncestorContainer(&
inputLayoutBox).width(), |
| 386 inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1)
/ 2, | 386 inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1)
/ 2, |
| 387 cancelButtonSize, cancelButtonSize); | 387 cancelButtonSize, cancelButtonSize); |
| 388 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, cancelButtonObj
ect, cancelButtonRect, r); | 388 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, cancelButtonObj
ect, cancelButtonRect, r); |
| 389 | 389 |
| 390 DEFINE_STATIC_REF(Image, cancelImage, (Image::loadPlatformResource("searchCa
ncel"))); | 390 DEFINE_STATIC_REF(Image, cancelImage, (Image::loadPlatformResource("searchCa
ncel"))); |
| 391 DEFINE_STATIC_REF(Image, cancelPressedImage, (Image::loadPlatformResource("s
earchCancelPressed"))); | 391 DEFINE_STATIC_REF(Image, cancelPressedImage, (Image::loadPlatformResource("s
earchCancelPressed"))); |
| 392 paintInfo.context.drawImage(LayoutTheme::isPressed(cancelButtonObject) ? can
celPressedImage : cancelImage, paintingRect); | 392 paintInfo.context.drawImage(LayoutTheme::isPressed(cancelButtonObject) ? can
celPressedImage : cancelImage, paintingRect); |
| 393 return false; | 393 return false; |
| 394 } | 394 } |
| 395 | 395 |
| 396 bool ThemePainterDefault::paintSearchFieldResultsDecoration(const LayoutObject&
magnifierObject, const PaintInfo& paintInfo, const IntRect& r) | 396 bool ThemePainterDefault::paintSearchFieldResultsDecoration(const LayoutObject&
magnifierObject, const PaintInfo& paintInfo, const IntRect& r) |
| 397 { | 397 { |
| 398 // Get the layoutObject of <input> element. | 398 // Get the layoutObject of <input> element. |
| 399 if (!magnifierObject.node()) | 399 if (!magnifierObject.node()) |
| 400 return false; | 400 return false; |
| 401 Node* input = magnifierObject.node()->shadowHost(); | 401 Node* input = magnifierObject.node()->shadowHost(); |
| 402 const LayoutObject& baseLayoutObject = input ? *input->layoutObject() : magn
ifierObject; | 402 const LayoutObject& baseLayoutObject = input ? *input->layoutObject() : magn
ifierObject; |
| 403 if (!baseLayoutObject.isBox()) | 403 if (!baseLayoutObject.isBox()) |
| 404 return false; | 404 return false; |
| 405 const LayoutBox& inputLayoutBox = toLayoutBox(baseLayoutObject); | 405 const LayoutBox& inputLayoutBox = toLayoutBox(baseLayoutObject); |
| 406 LayoutRect inputContentBox = inputLayoutBox.contentBoxRect(); | 406 LayoutRect inputContentBox = inputLayoutBox.contentBoxRect(); |
| 407 | 407 |
| 408 // Make sure the scaled decoration stays square and will fit in its parent's
box. | 408 // Make sure the scaled decoration stays square and will fit in its parent's
box. |
| 409 LayoutUnit magnifierSize = std::min(inputContentBox.width(), std::min<Layout
Unit>(inputContentBox.height(), r.height())); | 409 LayoutUnit magnifierSize = std::min(inputContentBox.width(), std::min(inputC
ontentBox.height(), LayoutUnit(r.height()))); |
| 410 // Calculate decoration's coordinates relative to the input element. | 410 // Calculate decoration's coordinates relative to the input element. |
| 411 // Center the decoration vertically. Round up though, so if it has to be on
e pixel off-center, it will | 411 // Center the decoration vertically. Round up though, so if it has to be on
e pixel off-center, it will |
| 412 // be one pixel closer to the bottom of the field. This tends to look bette
r with the text. | 412 // be one pixel closer to the bottom of the field. This tends to look bette
r with the text. |
| 413 LayoutRect magnifierRect(magnifierObject.offsetFromAncestorContainer(&inputL
ayoutBox).width(), | 413 LayoutRect magnifierRect(magnifierObject.offsetFromAncestorContainer(&inputL
ayoutBox).width(), |
| 414 inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2
, | 414 inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2
, |
| 415 magnifierSize, magnifierSize); | 415 magnifierSize, magnifierSize); |
| 416 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, magnifierObject
, magnifierRect, r); | 416 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, magnifierObject
, magnifierRect, r); |
| 417 | 417 |
| 418 DEFINE_STATIC_REF(Image, magnifierImage, (Image::loadPlatformResource("searc
hMagnifier"))); | 418 DEFINE_STATIC_REF(Image, magnifierImage, (Image::loadPlatformResource("searc
hMagnifier"))); |
| 419 paintInfo.context.drawImage(magnifierImage, paintingRect); | 419 paintInfo.context.drawImage(magnifierImage, paintingRect); |
| 420 return false; | 420 return false; |
| 421 } | 421 } |
| 422 | 422 |
| 423 } // namespace blink | 423 } // namespace blink |
| OLD | NEW |