| 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 |
| 11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
| 12 * | 12 * |
| 13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
| 17 * | 17 * |
| 18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
| 19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
| 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
| 22 * | 22 * |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "core/paint/ThemePainterDefault.h" | 25 #include "core/paint/ThemePainterDefault.h" |
| 26 | 26 |
| 27 #include "core/frame/FrameView.h" |
| 27 #include "core/layout/LayoutObject.h" | 28 #include "core/layout/LayoutObject.h" |
| 28 #include "core/layout/LayoutProgress.h" | 29 #include "core/layout/LayoutProgress.h" |
| 29 #include "core/layout/LayoutTheme.h" | 30 #include "core/layout/LayoutThemeDefault.h" |
| 30 #include "core/paint/MediaControlsPainter.h" | 31 #include "core/paint/MediaControlsPainter.h" |
| 31 #include "core/paint/PaintInfo.h" | 32 #include "core/paint/PaintInfo.h" |
| 32 #include "platform/LayoutTestSupport.h" | 33 #include "platform/LayoutTestSupport.h" |
| 33 #include "platform/graphics/Color.h" | 34 #include "platform/graphics/Color.h" |
| 34 #include "platform/graphics/GraphicsContext.h" | 35 #include "platform/graphics/GraphicsContext.h" |
| 35 #include "platform/graphics/GraphicsContextStateSaver.h" | 36 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 36 #include "public/platform/Platform.h" | 37 #include "public/platform/Platform.h" |
| 37 #include "public/platform/WebRect.h" | 38 #include "public/platform/WebRect.h" |
| 38 #include "public/platform/WebThemeEngine.h" | 39 #include "public/platform/WebThemeEngine.h" |
| 39 | 40 |
| 40 namespace blink { | 41 namespace blink { |
| 41 | 42 |
| 42 namespace { | 43 namespace { |
| 43 | 44 |
| 44 const unsigned defaultButtonBackgroundColor = 0xffdddddd; | 45 const unsigned defaultButtonBackgroundColor = 0xffdddddd; |
| 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; | |
| 49 | 46 |
| 50 bool useMockTheme() { | 47 bool useMockTheme() { |
| 51 return LayoutTestSupport::isMockThemeEnabledForTest(); | 48 return LayoutTestSupport::isMockThemeEnabledForTest(); |
| 52 } | 49 } |
| 53 | 50 |
| 54 WebThemeEngine::State getWebThemeState(const LayoutObject& o) { | 51 WebThemeEngine::State getWebThemeState(const LayoutObject& o) { |
| 55 if (!LayoutTheme::isEnabled(o)) | 52 if (!LayoutTheme::isEnabled(o)) |
| 56 return WebThemeEngine::StateDisabled; | 53 return WebThemeEngine::StateDisabled; |
| 57 if (useMockTheme() && LayoutTheme::isReadOnlyControl(o)) | 54 if (useMockTheme() && LayoutTheme::isReadOnlyControl(o)) |
| 58 return WebThemeEngine::StateReadonly; | 55 return WebThemeEngine::StateReadonly; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // Move the rect into partLayoutObject's coords. | 132 // Move the rect into partLayoutObject's coords. |
| 136 partRect.move(offsetFromInputLayoutObject); | 133 partRect.move(offsetFromInputLayoutObject); |
| 137 // Account for the local drawing offset. | 134 // Account for the local drawing offset. |
| 138 partRect.move(localOffset.x(), localOffset.y()); | 135 partRect.move(localOffset.x(), localOffset.y()); |
| 139 | 136 |
| 140 return pixelSnappedIntRect(partRect); | 137 return pixelSnappedIntRect(partRect); |
| 141 } | 138 } |
| 142 | 139 |
| 143 } // namespace | 140 } // namespace |
| 144 | 141 |
| 145 ThemePainterDefault::ThemePainterDefault() : ThemePainter() {} | 142 ThemePainterDefault::ThemePainterDefault(LayoutThemeDefault& theme) |
| 143 : ThemePainter(), m_theme(theme) {} |
| 146 | 144 |
| 147 bool ThemePainterDefault::paintCheckbox(const LayoutObject& o, | 145 bool ThemePainterDefault::paintCheckbox(const LayoutObject& o, |
| 148 const PaintInfo& i, | 146 const PaintInfo& i, |
| 149 const IntRect& rect) { | 147 const IntRect& rect) { |
| 150 WebThemeEngine::ExtraParams extraParams; | 148 WebThemeEngine::ExtraParams extraParams; |
| 151 WebCanvas* canvas = i.context.canvas(); | 149 WebCanvas* canvas = i.context.canvas(); |
| 152 extraParams.button.checked = LayoutTheme::isChecked(o); | 150 extraParams.button.checked = LayoutTheme::isChecked(o); |
| 153 extraParams.button.indeterminate = LayoutTheme::isIndeterminate(o); | 151 extraParams.button.indeterminate = LayoutTheme::isIndeterminate(o); |
| 154 | 152 |
| 155 float zoomLevel = o.styleRef().effectiveZoom(); | 153 float zoomLevel = o.styleRef().effectiveZoom(); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 Platform::current()->themeEngine()->paint( | 276 Platform::current()->themeEngine()->paint( |
| 279 canvas, WebThemeEngine::PartMenuList, getWebThemeState(o), WebRect(rect), | 277 canvas, WebThemeEngine::PartMenuList, getWebThemeState(o), WebRect(rect), |
| 280 &extraParams); | 278 &extraParams); |
| 281 return false; | 279 return false; |
| 282 } | 280 } |
| 283 | 281 |
| 284 void ThemePainterDefault::setupMenuListArrow( | 282 void ThemePainterDefault::setupMenuListArrow( |
| 285 const LayoutBox& box, | 283 const LayoutBox& box, |
| 286 const IntRect& rect, | 284 const IntRect& rect, |
| 287 WebThemeEngine::ExtraParams& extraParams) { | 285 WebThemeEngine::ExtraParams& extraParams) { |
| 288 const int right = rect.x() + rect.width(); | 286 const int left = rect.x() + box.borderLeft(); |
| 287 const int right = rect.x() + rect.width() - box.borderRight(); |
| 289 const int middle = rect.y() + rect.height() / 2; | 288 const int middle = rect.y() + rect.height() / 2; |
| 290 | 289 |
| 291 extraParams.menuList.arrowY = middle; | 290 extraParams.menuList.arrowY = middle; |
| 291 float arrowBoxWidth = m_theme.clampedMenuListArrowPaddingSize( |
| 292 box.frameView()->getHostWindow(), box.styleRef()); |
| 293 float arrowScaleFactor = arrowBoxWidth / m_theme.scrollbarThicknessInDIP(); |
| 292 if (useMockTheme()) { | 294 if (useMockTheme()) { |
| 293 // The size and position of the drop-down button is different between | 295 // The size and position of the drop-down button is different between |
| 294 // the mock theme and the regular aura theme. | 296 // the mock theme and the regular aura theme. |
| 295 int extraPadding = | 297 |
| 296 mockDropdownMenuListArrowPadding * box.styleRef().effectiveZoom(); | 298 // Padding inside the arrowBox. |
| 297 int arrowBoxWidth = | 299 float extraPadding = 2 * arrowScaleFactor; |
| 298 mockDropdownMenuListArrowWidth * box.styleRef().effectiveZoom(); | 300 float arrowSize = |
| 299 int arrowSize = std::min(arrowBoxWidth, rect.height()) - 2 * extraPadding; | 301 std::min(arrowBoxWidth, |
| 302 static_cast<float>(rect.height() - box.borderTop() - |
| 303 box.borderBottom())) - |
| 304 2 * extraPadding; |
| 305 // |arrowX| is the middle position for mock theme engine. |
| 300 extraParams.menuList.arrowX = | 306 extraParams.menuList.arrowX = |
| 301 (box.styleRef().direction() == RTL) | 307 (box.styleRef().direction() == RTL) |
| 302 ? rect.x() + extraPadding + (arrowSize / 2) | 308 ? rect.x() + extraPadding + (arrowSize / 2) |
| 303 : right - (arrowSize / 2) - extraPadding; | 309 : right - (arrowSize / 2) - extraPadding; |
| 304 extraParams.menuList.arrowSize = arrowSize; | 310 extraParams.menuList.arrowSize = arrowSize; |
| 305 } else { | 311 } else { |
| 306 const int arrowSize = 6; | 312 // TODO(tkent): This should be 7.0 to match scroll bar buttons. |
| 307 const int arrowPadding = 6; | 313 float arrowSize = 6.0 * arrowScaleFactor; |
| 308 extraParams.menuList.arrowX = | 314 // Put the 6px arrow at the center of paddingForArrow area. |
| 309 (box.styleRef().direction() == RTL) | 315 // |arrowX| is the left position for Aura theme engine. |
| 310 ? rect.x() + arrowPadding * box.styleRef().effectiveZoom() + | 316 extraParams.menuList.arrowX = (box.styleRef().direction() == RTL) |
| 311 box.borderLeft() | 317 ? left + (arrowBoxWidth - arrowSize) / 2 |
| 312 : right - | 318 : right - (arrowBoxWidth + arrowSize) / 2; |
| 313 (arrowSize + arrowPadding) * box.styleRef().effectiveZoom() - | 319 extraParams.menuList.arrowSize = arrowSize; |
| 314 box.borderRight(); | |
| 315 extraParams.menuList.arrowSize = arrowSize * box.styleRef().effectiveZoom(); | |
| 316 } | 320 } |
| 317 extraParams.menuList.arrowColor = box.resolveColor(CSSPropertyColor).rgb(); | 321 extraParams.menuList.arrowColor = box.resolveColor(CSSPropertyColor).rgb(); |
| 318 } | 322 } |
| 319 | 323 |
| 320 bool ThemePainterDefault::paintSliderTrack(const LayoutObject& o, | 324 bool ThemePainterDefault::paintSliderTrack(const LayoutObject& o, |
| 321 const PaintInfo& i, | 325 const PaintInfo& i, |
| 322 const IntRect& rect) { | 326 const IntRect& rect) { |
| 323 WebThemeEngine::ExtraParams extraParams; | 327 WebThemeEngine::ExtraParams extraParams; |
| 324 WebCanvas* canvas = i.context.canvas(); | 328 WebCanvas* canvas = i.context.canvas(); |
| 325 extraParams.slider.vertical = o.styleRef().appearance() == SliderVerticalPart; | 329 extraParams.slider.vertical = o.styleRef().appearance() == SliderVerticalPart; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 DEFINE_STATIC_REF(Image, cancelPressedImage, | 465 DEFINE_STATIC_REF(Image, cancelPressedImage, |
| 462 (Image::loadPlatformResource("searchCancelPressed"))); | 466 (Image::loadPlatformResource("searchCancelPressed"))); |
| 463 paintInfo.context.drawImage(LayoutTheme::isPressed(cancelButtonObject) | 467 paintInfo.context.drawImage(LayoutTheme::isPressed(cancelButtonObject) |
| 464 ? cancelPressedImage | 468 ? cancelPressedImage |
| 465 : cancelImage, | 469 : cancelImage, |
| 466 paintingRect); | 470 paintingRect); |
| 467 return false; | 471 return false; |
| 468 } | 472 } |
| 469 | 473 |
| 470 } // namespace blink | 474 } // namespace blink |
| OLD | NEW |