| 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 24 matching lines...) Expand all Loading... |
| 35 #include "platform/graphics/GraphicsContextStateSaver.h" | 35 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 36 #include "public/platform/Platform.h" | 36 #include "public/platform/Platform.h" |
| 37 #include "public/platform/WebRect.h" | 37 #include "public/platform/WebRect.h" |
| 38 #include "public/platform/WebThemeEngine.h" | 38 #include "public/platform/WebThemeEngine.h" |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 const unsigned defaultButtonBackgroundColor = 0xffdddddd; | 44 const unsigned defaultButtonBackgroundColor = 0xffdddddd; |
| 45 const unsigned dropdownMenuListArrowPadding = 3; | 45 const unsigned mockDropdownMenuListArrowPadding = 3; |
| 46 // This is equal to the padding provided by the LayoutMenuList which is |
| 47 // calculated based on |menuListArrowPaddingSize| in LayoutThemeDefault. |
| 48 const unsigned mockDropdownMenuListArrowWidth = 18; |
| 46 | 49 |
| 47 bool useMockTheme() | 50 bool useMockTheme() |
| 48 { | 51 { |
| 49 return LayoutTestSupport::isMockThemeEnabledForTest(); | 52 return LayoutTestSupport::isMockThemeEnabledForTest(); |
| 50 } | 53 } |
| 51 | 54 |
| 52 WebThemeEngine::State getWebThemeState(const LayoutObject& o) | 55 WebThemeEngine::State getWebThemeState(const LayoutObject& o) |
| 53 { | 56 { |
| 54 if (!LayoutTheme::isEnabled(o)) | 57 if (!LayoutTheme::isEnabled(o)) |
| 55 return WebThemeEngine::StateDisabled; | 58 return WebThemeEngine::StateDisabled; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 259 |
| 257 void ThemePainterDefault::setupMenuListArrow(const LayoutBox& box, const IntRect
& rect, WebThemeEngine::ExtraParams& extraParams) | 260 void ThemePainterDefault::setupMenuListArrow(const LayoutBox& box, const IntRect
& rect, WebThemeEngine::ExtraParams& extraParams) |
| 258 { | 261 { |
| 259 const int right = rect.x() + rect.width(); | 262 const int right = rect.x() + rect.width(); |
| 260 const int middle = rect.y() + rect.height() / 2; | 263 const int middle = rect.y() + rect.height() / 2; |
| 261 | 264 |
| 262 extraParams.menuList.arrowY = middle; | 265 extraParams.menuList.arrowY = middle; |
| 263 if (useMockTheme()) { | 266 if (useMockTheme()) { |
| 264 // The size and position of the drop-down button is different between | 267 // The size and position of the drop-down button is different between |
| 265 // the mock theme and the regular aura theme. | 268 // the mock theme and the regular aura theme. |
| 266 int extraPadding = dropdownMenuListArrowPadding * box.styleRef().effecti
veZoom(); | 269 int extraPadding = mockDropdownMenuListArrowPadding * box.styleRef().eff
ectiveZoom(); |
| 267 // The width available for the arrow is based on the padding provided | 270 int arrowBoxWidth = mockDropdownMenuListArrowWidth * box.styleRef().effe
ctiveZoom(); |
| 268 // in the child LayoutBox. | |
| 269 int arrowBoxWidth = ((box.styleRef().direction() == RTL) ? box.firstChil
dBox()->paddingLeft() : box.firstChildBox()->paddingRight()).toInt(); | |
| 270 int arrowSize = std::min(arrowBoxWidth, rect.height()) - 2 * extraPaddin
g; | 271 int arrowSize = std::min(arrowBoxWidth, rect.height()) - 2 * extraPaddin
g; |
| 271 extraParams.menuList.arrowX = (box.styleRef().direction() == RTL) ? rect
.x() + extraPadding + (arrowSize / 2) : right - (arrowSize / 2) - extraPadding; | 272 extraParams.menuList.arrowX = (box.styleRef().direction() == RTL) ? rect
.x() + extraPadding + (arrowSize / 2) : right - (arrowSize / 2) - extraPadding; |
| 272 extraParams.menuList.arrowSize = arrowSize; | 273 extraParams.menuList.arrowSize = arrowSize; |
| 273 } else { | 274 } else { |
| 274 const int arrowSize = 6; | 275 const int arrowSize = 6; |
| 275 const int arrowPadding = 6; | 276 const int arrowPadding = 6; |
| 276 extraParams.menuList.arrowX = (box.styleRef().direction() == RTL) | 277 extraParams.menuList.arrowX = (box.styleRef().direction() == RTL) |
| 277 ? rect.x() + arrowPadding * box.styleRef().effectiveZoom() + box.bor
derLeft() | 278 ? rect.x() + arrowPadding * box.styleRef().effectiveZoom() + box.bor
derLeft() |
| 278 : right - (arrowSize + arrowPadding) * box.styleRef().effectiveZoom(
) - box.borderRight(); | 279 : right - (arrowSize + arrowPadding) * box.styleRef().effectiveZoom(
) - box.borderRight(); |
| 279 extraParams.menuList.arrowSize = arrowSize * box.styleRef().effectiveZoo
m(); | 280 extraParams.menuList.arrowSize = arrowSize * box.styleRef().effectiveZoo
m(); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 cancelButtonSize, cancelButtonSize); | 396 cancelButtonSize, cancelButtonSize); |
| 396 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, cancelButtonObj
ect, cancelButtonRect, r); | 397 IntRect paintingRect = convertToPaintingRect(inputLayoutBox, cancelButtonObj
ect, cancelButtonRect, r); |
| 397 | 398 |
| 398 DEFINE_STATIC_REF(Image, cancelImage, (Image::loadPlatformResource("searchCa
ncel"))); | 399 DEFINE_STATIC_REF(Image, cancelImage, (Image::loadPlatformResource("searchCa
ncel"))); |
| 399 DEFINE_STATIC_REF(Image, cancelPressedImage, (Image::loadPlatformResource("s
earchCancelPressed"))); | 400 DEFINE_STATIC_REF(Image, cancelPressedImage, (Image::loadPlatformResource("s
earchCancelPressed"))); |
| 400 paintInfo.context.drawImage(LayoutTheme::isPressed(cancelButtonObject) ? can
celPressedImage : cancelImage, paintingRect); | 401 paintInfo.context.drawImage(LayoutTheme::isPressed(cancelButtonObject) ? can
celPressedImage : cancelImage, paintingRect); |
| 401 return false; | 402 return false; |
| 402 } | 403 } |
| 403 | 404 |
| 404 } // namespace blink | 405 } // namespace blink |
| OLD | NEW |