| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the WebKit project. | 2 * This file is part of the WebKit project. |
| 3 * | 3 * |
| 4 * Copyright (C) 2006 Apple Computer, Inc. | 4 * Copyright (C) 2006 Apple Computer, Inc. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include <windows.h> | 26 #include <windows.h> |
| 27 #include <uxtheme.h> | 27 #include <uxtheme.h> |
| 28 #include <vssym32.h> | 28 #include <vssym32.h> |
| 29 | 29 |
| 30 #include "CSSValueKeywords.h" | 30 #include "CSSValueKeywords.h" |
| 31 #include "Document.h" | 31 #include "Document.h" |
| 32 #include "FontSelector.h" | 32 #include "FontSelector.h" |
| 33 #include "GraphicsContext.h" | 33 #include "GraphicsContext.h" |
| 34 #include "ScrollbarTheme.h" | 34 #include "ScrollbarTheme.h" |
| 35 #include "SkiaUtils.h" | 35 #include "SkiaUtils.h" |
| 36 #include "ThemeHelperWin.h" |
| 36 | 37 |
| 37 #include "base/gfx/native_theme.h" | 38 #include "base/gfx/native_theme.h" |
| 38 #include "base/gfx/font_utils.h" | 39 #include "base/gfx/font_utils.h" |
| 39 #include "base/gfx/skia_utils.h" | 40 #include "base/gfx/skia_utils.h" |
| 40 #include "base/win_util.h" | 41 #include "base/win_util.h" |
| 41 #include "webkit/glue/webkit_glue.h" | 42 #include "webkit/glue/webkit_glue.h" |
| 42 | 43 |
| 43 // These enums correspond to similarly named values defined by SafariTheme.h | 44 // These enums correspond to similarly named values defined by SafariTheme.h |
| 44 enum ControlSize { | 45 enum ControlSize { |
| 45 RegularControlSize, | 46 RegularControlSize, |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 476 |
| 476 return result; | 477 return result; |
| 477 } | 478 } |
| 478 | 479 |
| 479 bool RenderThemeWin::paintButton(RenderObject* o, | 480 bool RenderThemeWin::paintButton(RenderObject* o, |
| 480 const RenderObject::PaintInfo& i, | 481 const RenderObject::PaintInfo& i, |
| 481 const IntRect& r) | 482 const IntRect& r) |
| 482 { | 483 { |
| 483 const ThemeData& themeData = getThemeData(o); | 484 const ThemeData& themeData = getThemeData(o); |
| 484 | 485 |
| 485 RECT rect; | 486 WebCore::ThemeHelperWin helper(i.context, r); |
| 486 rect.left = r.x(); | 487 gfx::PlatformCanvas* canvas = helper.context()->platformContext()->canvas(); |
| 487 rect.top = r.y(); | |
| 488 rect.right = r.right(); | |
| 489 rect.bottom = r.bottom(); | |
| 490 | 488 |
| 491 HDC hdc = i.context->platformContext()->canvas()->beginPlatformPaint(); | 489 HDC hdc = canvas->beginPlatformPaint(); |
| 492 int state = themeData.m_state; | 490 int state = themeData.m_state; |
| 491 RECT renderRect = helper.rect(); |
| 492 |
| 493 gfx::NativeTheme::instance()->PaintButton(hdc, | 493 gfx::NativeTheme::instance()->PaintButton(hdc, |
| 494 themeData.m_part, | 494 themeData.m_part, |
| 495 state, | 495 state, |
| 496 themeData.m_classicState, | 496 themeData.m_classicState, |
| 497 &rect); | 497 &renderRect); |
| 498 i.context->platformContext()->canvas()->endPlatformPaint(); | 498 canvas->endPlatformPaint(); |
| 499 return false; | 499 return false; |
| 500 } | 500 } |
| 501 | 501 |
| 502 static void setSizeIfAuto(RenderStyle* style, const IntSize& size) | 502 static void setSizeIfAuto(RenderStyle* style, const IntSize& size) |
| 503 { | 503 { |
| 504 if (style->width().isIntrinsicOrAuto()) | 504 if (style->width().isIntrinsicOrAuto()) |
| 505 style->setWidth(Length(size.width(), Fixed)); | 505 style->setWidth(Length(size.width(), Fixed)); |
| 506 if (style->height().isAuto()) | 506 if (style->height().isAuto()) |
| 507 style->setHeight(Length(size.height(), Fixed)); | 507 style->setHeight(Length(size.height(), Fixed)); |
| 508 } | 508 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 // border-radius. Webkit paints elements with border-radius for us. | 567 // border-radius. Webkit paints elements with border-radius for us. |
| 568 // TODO(ojan): Get rid of this if-check once we can properly clip rounded | 568 // TODO(ojan): Get rid of this if-check once we can properly clip rounded |
| 569 // borders: http://b/1112604 and http://b/1108635 | 569 // borders: http://b/1112604 and http://b/1108635 |
| 570 // TODO(ojan): make sure we do the right thing if css background-clip is | 570 // TODO(ojan): make sure we do the right thing if css background-clip is |
| 571 // set. | 571 // set. |
| 572 if (o->style()->hasBorderRadius()) | 572 if (o->style()->hasBorderRadius()) |
| 573 return false; | 573 return false; |
| 574 | 574 |
| 575 const ThemeData& themeData = getThemeData(o); | 575 const ThemeData& themeData = getThemeData(o); |
| 576 | 576 |
| 577 RECT rect; | 577 WebCore::ThemeHelperWin helper(i.context, r); |
| 578 rect.left = r.x(); | 578 gfx::PlatformCanvas* canvas = helper.context()->platformContext()->canvas(); |
| 579 rect.top = r.y(); | |
| 580 rect.right = r.right(); | |
| 581 rect.bottom = r.bottom(); | |
| 582 | 579 |
| 583 HDC hdc = i.context->platformContext()->canvas()->beginPlatformPaint(); | 580 HDC hdc = canvas->beginPlatformPaint(); |
| 584 COLORREF clr = gfx::SkColorToCOLORREF(o->style()->backgroundColor().rgb()); | 581 COLORREF clr = gfx::SkColorToCOLORREF(o->style()->backgroundColor().rgb()); |
| 582 RECT renderRect = helper.rect(); |
| 583 |
| 585 gfx::NativeTheme::instance()->PaintTextField(hdc, | 584 gfx::NativeTheme::instance()->PaintTextField(hdc, |
| 586 themeData.m_part, | 585 themeData.m_part, |
| 587 themeData.m_state, | 586 themeData.m_state, |
| 588 themeData.m_classicState, | 587 themeData.m_classicState, |
| 589 &rect, | 588 &renderRect, |
| 590 clr, | 589 clr, |
| 591 true, | 590 true, |
| 592 drawEdges); | 591 drawEdges); |
| 593 i.context->platformContext()->canvas()->endPlatformPaint(); | 592 canvas->endPlatformPaint(); |
| 594 return false; | 593 return false; |
| 595 } | 594 } |
| 596 | 595 |
| 597 bool RenderThemeWin::paintSearchField(RenderObject* o, const RenderObject::Paint
Info& i, const IntRect& r) | 596 bool RenderThemeWin::paintSearchField(RenderObject* o, const RenderObject::Paint
Info& i, const IntRect& r) |
| 598 { | 597 { |
| 599 return paintTextField(o, i, r); | 598 return paintTextField(o, i, r); |
| 600 } | 599 } |
| 601 | 600 |
| 602 void RenderThemeWin::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle
* style, Element* e) const | 601 void RenderThemeWin::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle
* style, Element* e) const |
| 603 { | 602 { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 int spacingTop = borderTop + o->paddingTop(); | 654 int spacingTop = borderTop + o->paddingTop(); |
| 656 int spacingBottom = borderBottom + o->paddingBottom(); | 655 int spacingBottom = borderBottom + o->paddingBottom(); |
| 657 | 656 |
| 658 int buttonX; | 657 int buttonX; |
| 659 if (r.right() - r.x() < buttonWidth) { | 658 if (r.right() - r.x() < buttonWidth) { |
| 660 buttonX = r.x(); | 659 buttonX = r.x(); |
| 661 } else { | 660 } else { |
| 662 buttonX = o->style()->direction() == LTR ? r.right() - spacingRight - bu
ttonWidth : r.x() + spacingLeft; | 661 buttonX = o->style()->direction() == LTR ? r.right() - spacingRight - bu
ttonWidth : r.x() + spacingLeft; |
| 663 } | 662 } |
| 664 | 663 |
| 665 // Compute the Windows rectangle of the button. | 664 // Compute the rectangle of the button in the destination image. |
| 666 RECT rect; | 665 IntRect rect(buttonX, |
| 667 rect.left = buttonX; | 666 r.y() + spacingTop, |
| 668 rect.top = r.y() + spacingTop; | 667 std::min(buttonWidth, r.right() - r.x()), |
| 669 rect.right = rect.left + std::min(buttonWidth, r.right() - r.x()); | 668 r.height() - (spacingTop + spacingBottom)); |
| 670 rect.bottom = rect.top + r.height() - (spacingTop + spacingBottom); | |
| 671 | 669 |
| 672 // Get the correct theme data for a textfield and paint the menu. | 670 // Get the correct theme data for a textfield and paint the menu. |
| 673 HDC hdc = i.context->platformContext()->canvas()->beginPlatformPaint(); | 671 WebCore::ThemeHelperWin helper(i.context, rect); |
| 672 gfx::PlatformCanvas* canvas = helper.context()->platformContext()->canvas(); |
| 673 HDC hdc = canvas->beginPlatformPaint(); |
| 674 RECT renderRect = helper.rect(); |
| 674 gfx::NativeTheme::instance()->PaintMenuList(hdc, | 675 gfx::NativeTheme::instance()->PaintMenuList(hdc, |
| 675 CP_DROPDOWNBUTTON, | 676 CP_DROPDOWNBUTTON, |
| 676 determineState(o), | 677 determineState(o), |
| 677 determineClassicState(o), | 678 determineClassicState(o), |
| 678 &rect); | 679 &renderRect); |
| 679 i.context->platformContext()->canvas()->endPlatformPaint(); | 680 canvas->endPlatformPaint(); |
| 680 return false; | 681 return false; |
| 681 } | 682 } |
| 682 | 683 |
| 683 // Used to paint styled menulists (i.e. with a non-default border) | 684 // Used to paint styled menulists (i.e. with a non-default border) |
| 684 bool RenderThemeWin::paintMenuListButton(RenderObject* o, const RenderObject::Pa
intInfo& i, const IntRect& r) | 685 bool RenderThemeWin::paintMenuListButton(RenderObject* o, const RenderObject::Pa
intInfo& i, const IntRect& r) |
| 685 { | 686 { |
| 686 return paintMenuList(o, i, r); | 687 return paintMenuList(o, i, r); |
| 687 } | 688 } |
| 688 | 689 |
| 689 int RenderThemeWin::popupInternalPaddingLeft(RenderStyle* style) const | 690 int RenderThemeWin::popupInternalPaddingLeft(RenderStyle* style) const |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 | 899 |
| 899 // static | 900 // static |
| 900 void RenderThemeWin::setDefaultFontSize(int fontSize) { | 901 void RenderThemeWin::setDefaultFontSize(int fontSize) { |
| 901 DefaultFontSize = static_cast<float>(fontSize); | 902 DefaultFontSize = static_cast<float>(fontSize); |
| 902 | 903 |
| 903 // Reset cached fonts. | 904 // Reset cached fonts. |
| 904 SmallSystemFont = MenuFont = LabelFont = FontDescription(); | 905 SmallSystemFont = MenuFont = LabelFont = FontDescription(); |
| 905 } | 906 } |
| 906 | 907 |
| 907 } | 908 } |
| OLD | NEW |