summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authorrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-12 16:18:18 +0000
committerrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-12 16:18:18 +0000
commit44ddaa4757178992da4f9a1398d96438e76e26d0 (patch)
treedd3d37e8d5f115843a85caee7bc275b058cbe1f8 /webkit/glue
parenta61c46f2a26bbe421345c48aaf2635bbf204a0d8 (diff)
downloadchromium_src-44ddaa4757178992da4f9a1398d96438e76e26d0.zip
chromium_src-44ddaa4757178992da4f9a1398d96438e76e26d0.tar.gz
chromium_src-44ddaa4757178992da4f9a1398d96438e76e26d0.tar.bz2
step 3 of native theme refactoring
Moved all calls to old menu drawing api to new NativeTheme::Paint(). Moved all calls to old push/radio/check button api to new NativePaint::Paint(). BUG=None TEST=Affects windows platform only. All menus in chrome, such as wrench menu, should look and behave as before, with no change. All pushbuttons, radiobuttons, and checkbox in web page forms should look and behave as before. Review URL: http://codereview.chromium.org/6825007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81257 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/webthemeengine_impl_win.cc358
1 files changed, 351 insertions, 7 deletions
diff --git a/webkit/glue/webthemeengine_impl_win.cc b/webkit/glue/webthemeengine_impl_win.cc
index 61e78ca..5f5d089b 100644
--- a/webkit/glue/webthemeengine_impl_win.cc
+++ b/webkit/glue/webthemeengine_impl_win.cc
@@ -4,6 +4,9 @@
#include "webkit/glue/webthemeengine_impl_win.h"
+#include <vsstyle.h> // To convert to gfx::NativeTheme::State
+
+#include "base/logging.h"
#include "skia/ext/platform_canvas.h"
#include "skia/ext/skia_utils_win.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
@@ -24,16 +27,357 @@ static RECT WebRectToRECT(const WebRect& rect) {
return result;
}
+static gfx::NativeTheme::State WebButtonStateToGfx(
+ int part,
+ int state,
+ gfx::NativeTheme::ButtonExtraParams* extra) {
+ gfx::NativeTheme::State gfx_state = gfx::NativeTheme::kNormal;
+
+ if (part == BP_PUSHBUTTON) {
+ switch(state) {
+ case PBS_NORMAL:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case PBS_HOT:
+ gfx_state = gfx::NativeTheme::kHovered;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case PBS_PRESSED:
+ gfx_state = gfx::NativeTheme::kPressed;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case PBS_DISABLED:
+ gfx_state = gfx::NativeTheme::kDisabled;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case PBS_DEFAULTED:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = true;
+ break;
+ case PBS_DEFAULTED_ANIMATING:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = true;
+ break;
+ default:
+ NOTREACHED() << "Invalid state: " << state;
+ }
+ } else if (part == BP_RADIOBUTTON) {
+ switch(state) {
+ case RBS_UNCHECKEDNORMAL:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case RBS_UNCHECKEDHOT:
+ gfx_state = gfx::NativeTheme::kHovered;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case RBS_UNCHECKEDPRESSED:
+ gfx_state = gfx::NativeTheme::kPressed;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case RBS_UNCHECKEDDISABLED:
+ gfx_state = gfx::NativeTheme::kDisabled;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case RBS_CHECKEDNORMAL:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = true;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case RBS_CHECKEDHOT:
+ gfx_state = gfx::NativeTheme::kHovered;
+ extra->checked = true;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case RBS_CHECKEDPRESSED:
+ gfx_state = gfx::NativeTheme::kPressed;
+ extra->checked = true;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case RBS_CHECKEDDISABLED:
+ gfx_state = gfx::NativeTheme::kDisabled;
+ extra->checked = true;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ default:
+ NOTREACHED() << "Invalid state: " << state;
+ break;
+ }
+ } else if (part == BP_CHECKBOX) {
+ switch(state) {
+ case CBS_UNCHECKEDNORMAL:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_UNCHECKEDHOT:
+ gfx_state = gfx::NativeTheme::kHovered;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_UNCHECKEDPRESSED:
+ gfx_state = gfx::NativeTheme::kPressed;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_UNCHECKEDDISABLED:
+ gfx_state = gfx::NativeTheme::kDisabled;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_CHECKEDNORMAL:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = true;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_CHECKEDHOT:
+ gfx_state = gfx::NativeTheme::kHovered;
+ extra->checked = true;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_CHECKEDPRESSED:
+ gfx_state = gfx::NativeTheme::kPressed;
+ extra->checked = true;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_CHECKEDDISABLED:
+ gfx_state = gfx::NativeTheme::kDisabled;
+ extra->checked = true;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_MIXEDNORMAL:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = false;
+ extra->indeterminate = true;
+ extra->is_default = false;
+ break;
+ case CBS_MIXEDHOT:
+ gfx_state = gfx::NativeTheme::kHovered;
+ extra->checked = false;
+ extra->indeterminate = true;
+ extra->is_default = false;
+ break;
+ case CBS_MIXEDPRESSED:
+ gfx_state = gfx::NativeTheme::kPressed;
+ extra->checked = false;
+ extra->indeterminate = true;
+ extra->is_default = false;
+ break;
+ case CBS_MIXEDDISABLED:
+ gfx_state = gfx::NativeTheme::kDisabled;
+ extra->checked = false;
+ extra->indeterminate = true;
+ extra->is_default = false;
+ break;
+ case CBS_IMPLICITNORMAL:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_IMPLICITHOT:
+ gfx_state = gfx::NativeTheme::kHovered;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_IMPLICITPRESSED:
+ gfx_state = gfx::NativeTheme::kPressed;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_IMPLICITDISABLED:
+ gfx_state = gfx::NativeTheme::kDisabled;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_EXCLUDEDNORMAL:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_EXCLUDEDHOT:
+ gfx_state = gfx::NativeTheme::kHovered;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_EXCLUDEDPRESSED:
+ gfx_state = gfx::NativeTheme::kPressed;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CBS_EXCLUDEDDISABLED:
+ gfx_state = gfx::NativeTheme::kDisabled;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ default:
+ NOTREACHED() << "Invalid state: " << state;
+ break;
+ }
+ } else if (part == BP_GROUPBOX) {
+ switch(state) {
+ case GBS_NORMAL:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case GBS_DISABLED:
+ gfx_state = gfx::NativeTheme::kDisabled;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ default:
+ NOTREACHED() << "Invalid state: " << state;
+ break;
+ }
+ } else if (part == BP_COMMANDLINK) {
+ switch(state) {
+ case CMDLS_NORMAL:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CMDLS_HOT:
+ gfx_state = gfx::NativeTheme::kHovered;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CMDLS_PRESSED:
+ gfx_state = gfx::NativeTheme::kPressed;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CMDLS_DISABLED:
+ gfx_state = gfx::NativeTheme::kDisabled;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CMDLS_DEFAULTED:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = true;
+ break;
+ case CMDLS_DEFAULTED_ANIMATING:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = true;
+ break;
+ default:
+ NOTREACHED() << "Invalid state: " << state;
+ break;
+ }
+ } else if (part == BP_COMMANDLINKGLYPH) {
+ switch(state) {
+ case CMDLGS_NORMAL:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CMDLGS_HOT:
+ gfx_state = gfx::NativeTheme::kHovered;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CMDLGS_PRESSED:
+ gfx_state = gfx::NativeTheme::kPressed;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CMDLGS_DISABLED:
+ gfx_state = gfx::NativeTheme::kDisabled;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = false;
+ break;
+ case CMDLGS_DEFAULTED:
+ gfx_state = gfx::NativeTheme::kNormal;
+ extra->checked = false;
+ extra->indeterminate = false;
+ extra->is_default = true;
+ break;
+ default:
+ NOTREACHED() << "Invalid state: " << state;
+ break;
+ }
+ }
+ return gfx_state;
+}
+
void WebThemeEngineImpl::paintButton(
WebCanvas* canvas, int part, int state, int classic_state,
const WebRect& rect) {
- HDC hdc = skia::BeginPlatformPaint(canvas);
-
- RECT native_rect = WebRectToRECT(rect);
- gfx::NativeThemeWin::instance()->PaintButton(
- hdc, part, state, classic_state, &native_rect);
-
- skia::EndPlatformPaint(canvas);
+ gfx::NativeTheme::Part native_part = gfx::NativeTheme::kPushButton;
+ switch(part) {
+ case BP_PUSHBUTTON:
+ native_part = gfx::NativeTheme::kPushButton;
+ break;
+ case BP_CHECKBOX:
+ native_part = gfx::NativeTheme::kCheckbox;
+ break;
+ case BP_RADIOBUTTON:
+ native_part = gfx::NativeTheme::kRadio;
+ break;
+ default:
+ break;
+ }
+ gfx::NativeTheme::ExtraParams extra;
+ gfx::NativeTheme::State native_state = WebButtonStateToGfx(part, state,
+ &extra.button);
+ extra.button.classic_state = classic_state;
+ gfx::Rect gfx_rect(rect.x, rect.y, rect.width, rect.height);
+ gfx::NativeTheme::instance()->Paint(canvas, native_part,
+ native_state, gfx_rect, extra);
}
void WebThemeEngineImpl::paintMenuList(