| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 bool ThemePainterDefault::paintSearchField(const LayoutObject& o, const PaintInf
o& i, const IntRect& r) | 368 bool ThemePainterDefault::paintSearchField(const LayoutObject& o, const PaintInf
o& i, const IntRect& r) |
| 369 { | 369 { |
| 370 return paintTextField(o, i, r); | 370 return paintTextField(o, i, r); |
| 371 } | 371 } |
| 372 | 372 |
| 373 bool ThemePainterDefault::paintSearchFieldCancelButton(const LayoutObject& cance
lButtonObject, const PaintInfo& paintInfo, const IntRect& r) | 373 bool ThemePainterDefault::paintSearchFieldCancelButton(const LayoutObject& cance
lButtonObject, const PaintInfo& paintInfo, const IntRect& r) |
| 374 { | 374 { |
| 375 // Get the layoutObject of <input> element. | 375 // Get the layoutObject of <input> element. |
| 376 if (!cancelButtonObject.node()) | 376 if (!cancelButtonObject.node()) |
| 377 return false; | 377 return false; |
| 378 Node* input = cancelButtonObject.node()->shadowHost(); | 378 Node* input = cancelButtonObject.node()->ownerShadowHost(); |
| 379 const LayoutObject& baseLayoutObject = input ? *input->layoutObject() : canc
elButtonObject; | 379 const LayoutObject& baseLayoutObject = input ? *input->layoutObject() : canc
elButtonObject; |
| 380 if (!baseLayoutObject.isBox()) | 380 if (!baseLayoutObject.isBox()) |
| 381 return false; | 381 return false; |
| 382 const LayoutBox& inputLayoutBox = toLayoutBox(baseLayoutObject); | 382 const LayoutBox& inputLayoutBox = toLayoutBox(baseLayoutObject); |
| 383 LayoutRect inputContentBox = inputLayoutBox.contentBoxRect(); | 383 LayoutRect inputContentBox = inputLayoutBox.contentBoxRect(); |
| 384 | 384 |
| 385 // Make sure the scaled button stays square and will fit in its parent's box
. | 385 // Make sure the scaled button stays square and will fit in its parent's box
. |
| 386 LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min(inp
utContentBox.height(), LayoutUnit(r.height()))); | 386 LayoutUnit cancelButtonSize = std::min(inputContentBox.width(), std::min(inp
utContentBox.height(), LayoutUnit(r.height()))); |
| 387 // Calculate cancel button's coordinates relative to the input element. | 387 // Calculate cancel button's coordinates relative to the input element. |
| 388 // Center the button vertically. Round up though, so if it has to be one pi
xel off-center, it will | 388 // Center the button vertically. Round up though, so if it has to be one pi
xel off-center, it will |
| 389 // be one pixel closer to the bottom of the field. This tends to look bette
r with the text. | 389 // be one pixel closer to the bottom of the field. This tends to look bette
r with the text. |
| 390 LayoutRect cancelButtonRect(cancelButtonObject.offsetFromAncestorContainer(&
inputLayoutBox).width(), | 390 LayoutRect cancelButtonRect(cancelButtonObject.offsetFromAncestorContainer(&
inputLayoutBox).width(), |
| 391 inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1)
/ 2, | 391 inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1)
/ 2, |
| 392 cancelButtonSize, cancelButtonSize); | 392 cancelButtonSize, cancelButtonSize); |
| 393 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, cancelButtonObj
ect, cancelButtonRect, r); | 393 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, cancelButtonObj
ect, cancelButtonRect, r); |
| 394 | 394 |
| 395 DEFINE_STATIC_REF(Image, cancelImage, (Image::loadPlatformResource("searchCa
ncel"))); | 395 DEFINE_STATIC_REF(Image, cancelImage, (Image::loadPlatformResource("searchCa
ncel"))); |
| 396 DEFINE_STATIC_REF(Image, cancelPressedImage, (Image::loadPlatformResource("s
earchCancelPressed"))); | 396 DEFINE_STATIC_REF(Image, cancelPressedImage, (Image::loadPlatformResource("s
earchCancelPressed"))); |
| 397 paintInfo.context.drawImage(LayoutTheme::isPressed(cancelButtonObject) ? can
celPressedImage : cancelImage, paintingRect); | 397 paintInfo.context.drawImage(LayoutTheme::isPressed(cancelButtonObject) ? can
celPressedImage : cancelImage, paintingRect); |
| 398 return false; | 398 return false; |
| 399 } | 399 } |
| 400 | 400 |
| 401 } // namespace blink | 401 } // namespace blink |
| OLD | NEW |