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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 if (!baseLayoutObject.isBox()) | 438 if (!baseLayoutObject.isBox()) |
439 return false; | 439 return false; |
440 const LayoutBox& inputLayoutBox = toLayoutBox(baseLayoutObject); | 440 const LayoutBox& inputLayoutBox = toLayoutBox(baseLayoutObject); |
441 LayoutRect inputContentBox = inputLayoutBox.contentBoxRect(); | 441 LayoutRect inputContentBox = inputLayoutBox.contentBoxRect(); |
442 | 442 |
443 // Make sure the scaled button stays square and will fit in its parent's box. | 443 // Make sure the scaled button stays square and will fit in its parent's box. |
444 LayoutUnit cancelButtonSize = | 444 LayoutUnit cancelButtonSize = |
445 std::min(inputContentBox.width(), | 445 std::min(inputContentBox.width(), |
446 std::min(inputContentBox.height(), LayoutUnit(r.height()))); | 446 std::min(inputContentBox.height(), LayoutUnit(r.height()))); |
447 // Calculate cancel button's coordinates relative to the input element. | 447 // Calculate cancel button's coordinates relative to the input element. |
448 // Center the button vertically. Round up though, so if it has to be one pixe
l off-center, it will | 448 // Center the button vertically. Round up though, so if it has to be one |
449 // be one pixel closer to the bottom of the field. This tends to look better
with the text. | 449 // pixel off-center, it will be one pixel closer to the bottom of the field. |
| 450 // This tends to look better with the text. |
450 LayoutRect cancelButtonRect( | 451 LayoutRect cancelButtonRect( |
451 cancelButtonObject.offsetFromAncestorContainer(&inputLayoutBox).width(), | 452 cancelButtonObject.offsetFromAncestorContainer(&inputLayoutBox).width(), |
452 inputContentBox.y() + | 453 inputContentBox.y() + |
453 (inputContentBox.height() - cancelButtonSize + 1) / 2, | 454 (inputContentBox.height() - cancelButtonSize + 1) / 2, |
454 cancelButtonSize, cancelButtonSize); | 455 cancelButtonSize, cancelButtonSize); |
455 IntRect paintingRect = convertToPaintingRect( | 456 IntRect paintingRect = convertToPaintingRect( |
456 inputLayoutBox, cancelButtonObject, cancelButtonRect, r); | 457 inputLayoutBox, cancelButtonObject, cancelButtonRect, r); |
457 | 458 |
458 DEFINE_STATIC_REF(Image, cancelImage, | 459 DEFINE_STATIC_REF(Image, cancelImage, |
459 (Image::loadPlatformResource("searchCancel"))); | 460 (Image::loadPlatformResource("searchCancel"))); |
460 DEFINE_STATIC_REF(Image, cancelPressedImage, | 461 DEFINE_STATIC_REF(Image, cancelPressedImage, |
461 (Image::loadPlatformResource("searchCancelPressed"))); | 462 (Image::loadPlatformResource("searchCancelPressed"))); |
462 paintInfo.context.drawImage(LayoutTheme::isPressed(cancelButtonObject) | 463 paintInfo.context.drawImage(LayoutTheme::isPressed(cancelButtonObject) |
463 ? cancelPressedImage | 464 ? cancelPressedImage |
464 : cancelImage, | 465 : cancelImage, |
465 paintingRect); | 466 paintingRect); |
466 return false; | 467 return false; |
467 } | 468 } |
468 | 469 |
469 } // namespace blink | 470 } // namespace blink |
OLD | NEW |