OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/glue/webthemeengine_impl_win.h" | 5 #include "webkit/glue/webthemeengine_impl_win.h" |
6 | 6 |
7 #include "skia/ext/platform_canvas.h" | 7 #include "skia/ext/platform_canvas.h" |
8 #include "skia/ext/skia_utils_win.h" | 8 #include "skia/ext/skia_utils_win.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" |
10 #include "ui/gfx/native_theme_win.h" | 10 #include "ui/gfx/native_theme_win.h" |
11 | 11 |
12 using WebKit::WebCanvas; | 12 using WebKit::WebCanvas; |
13 using WebKit::WebColor; | 13 using WebKit::WebColor; |
14 using WebKit::WebRect; | 14 using WebKit::WebRect; |
15 | 15 |
16 namespace webkit_glue { | 16 namespace webkit_glue { |
17 | 17 |
18 static RECT WebRectToRECT(const WebRect& rect) { | 18 static RECT WebRectToRECT(const WebRect& rect) { |
19 RECT result; | 19 RECT result; |
20 result.left = rect.x; | 20 result.left = rect.x; |
21 result.top = rect.y; | 21 result.top = rect.y; |
22 result.right = rect.x + rect.width; | 22 result.right = rect.x + rect.width; |
23 result.bottom = rect.y + rect.height; | 23 result.bottom = rect.y + rect.height; |
24 return result; | 24 return result; |
25 } | 25 } |
26 | 26 |
27 static skia::PlatformCanvas* ToPlatformCanvas(WebCanvas* canvas) { | |
28 return static_cast<skia::PlatformCanvas*>(canvas); | |
29 } | |
30 | |
reed1
2011/04/01 17:44:42
In preparation for the future, is it clear to crea
alokp
2011/04/01 19:57:38
Done.
| |
27 void WebThemeEngineImpl::paintButton( | 31 void WebThemeEngineImpl::paintButton( |
28 WebCanvas* canvas, int part, int state, int classic_state, | 32 WebCanvas* canvas, int part, int state, int classic_state, |
29 const WebRect& rect) { | 33 const WebRect& rect) { |
30 HDC hdc = canvas->beginPlatformPaint(); | 34 skia::PlatformCanvas* platform_canvas = ToPlatformCanvas(canvas); |
35 HDC hdc = platform_canvas->beginPlatformPaint(); | |
31 | 36 |
32 RECT native_rect = WebRectToRECT(rect); | 37 RECT native_rect = WebRectToRECT(rect); |
33 gfx::NativeThemeWin::instance()->PaintButton( | 38 gfx::NativeThemeWin::instance()->PaintButton( |
34 hdc, part, state, classic_state, &native_rect); | 39 hdc, part, state, classic_state, &native_rect); |
35 | 40 |
36 canvas->endPlatformPaint(); | 41 platform_canvas->endPlatformPaint(); |
37 } | 42 } |
38 | 43 |
39 void WebThemeEngineImpl::paintMenuList( | 44 void WebThemeEngineImpl::paintMenuList( |
40 WebCanvas* canvas, int part, int state, int classic_state, | 45 WebCanvas* canvas, int part, int state, int classic_state, |
41 const WebRect& rect) { | 46 const WebRect& rect) { |
42 HDC hdc = canvas->beginPlatformPaint(); | 47 skia::PlatformCanvas* platform_canvas = ToPlatformCanvas(canvas); |
48 HDC hdc = platform_canvas->beginPlatformPaint(); | |
43 | 49 |
44 RECT native_rect = WebRectToRECT(rect); | 50 RECT native_rect = WebRectToRECT(rect); |
45 gfx::NativeThemeWin::instance()->PaintMenuList( | 51 gfx::NativeThemeWin::instance()->PaintMenuList( |
46 hdc, part, state, classic_state, &native_rect); | 52 hdc, part, state, classic_state, &native_rect); |
47 | 53 |
48 canvas->endPlatformPaint(); | 54 platform_canvas->endPlatformPaint(); |
49 } | 55 } |
50 | 56 |
51 void WebThemeEngineImpl::paintScrollbarArrow( | 57 void WebThemeEngineImpl::paintScrollbarArrow( |
52 WebCanvas* canvas, int state, int classic_state, | 58 WebCanvas* canvas, int state, int classic_state, |
53 const WebRect& rect) { | 59 const WebRect& rect) { |
54 HDC hdc = canvas->beginPlatformPaint(); | 60 skia::PlatformCanvas* platform_canvas = ToPlatformCanvas(canvas); |
61 HDC hdc = platform_canvas->beginPlatformPaint(); | |
55 | 62 |
56 RECT native_rect = WebRectToRECT(rect); | 63 RECT native_rect = WebRectToRECT(rect); |
57 gfx::NativeThemeWin::instance()->PaintScrollbarArrow( | 64 gfx::NativeThemeWin::instance()->PaintScrollbarArrow( |
58 hdc, state, classic_state, &native_rect); | 65 hdc, state, classic_state, &native_rect); |
59 | 66 |
60 canvas->endPlatformPaint(); | 67 platform_canvas->endPlatformPaint(); |
61 } | 68 } |
62 | 69 |
63 void WebThemeEngineImpl::paintScrollbarThumb( | 70 void WebThemeEngineImpl::paintScrollbarThumb( |
64 WebCanvas* canvas, int part, int state, int classic_state, | 71 WebCanvas* canvas, int part, int state, int classic_state, |
65 const WebRect& rect) { | 72 const WebRect& rect) { |
66 HDC hdc = canvas->beginPlatformPaint(); | 73 skia::PlatformCanvas* platform_canvas = ToPlatformCanvas(canvas); |
74 HDC hdc = platform_canvas->beginPlatformPaint(); | |
67 | 75 |
68 RECT native_rect = WebRectToRECT(rect); | 76 RECT native_rect = WebRectToRECT(rect); |
69 gfx::NativeThemeWin::instance()->PaintScrollbarThumb( | 77 gfx::NativeThemeWin::instance()->PaintScrollbarThumb( |
70 hdc, part, state, classic_state, &native_rect); | 78 hdc, part, state, classic_state, &native_rect); |
71 | 79 |
72 canvas->endPlatformPaint(); | 80 platform_canvas->endPlatformPaint(); |
73 } | 81 } |
74 | 82 |
75 void WebThemeEngineImpl::paintScrollbarTrack( | 83 void WebThemeEngineImpl::paintScrollbarTrack( |
76 WebCanvas* canvas, int part, int state, int classic_state, | 84 WebCanvas* canvas, int part, int state, int classic_state, |
77 const WebRect& rect, const WebRect& align_rect) { | 85 const WebRect& rect, const WebRect& align_rect) { |
78 HDC hdc = canvas->beginPlatformPaint(); | 86 skia::PlatformCanvas* platform_canvas = ToPlatformCanvas(canvas); |
87 HDC hdc = platform_canvas->beginPlatformPaint(); | |
79 | 88 |
80 RECT native_rect = WebRectToRECT(rect); | 89 RECT native_rect = WebRectToRECT(rect); |
81 RECT native_align_rect = WebRectToRECT(align_rect); | 90 RECT native_align_rect = WebRectToRECT(align_rect); |
82 gfx::NativeThemeWin::instance()->PaintScrollbarTrack( | 91 gfx::NativeThemeWin::instance()->PaintScrollbarTrack( |
83 hdc, part, state, classic_state, &native_rect, &native_align_rect, | 92 hdc, part, state, classic_state, &native_rect, &native_align_rect, |
84 canvas); | 93 canvas); |
85 | 94 |
86 canvas->endPlatformPaint(); | 95 platform_canvas->endPlatformPaint(); |
87 } | 96 } |
88 | 97 |
89 void WebThemeEngineImpl::paintSpinButton( | 98 void WebThemeEngineImpl::paintSpinButton( |
90 WebCanvas* canvas, int part, int state, int classic_state, | 99 WebCanvas* canvas, int part, int state, int classic_state, |
91 const WebRect& rect) { | 100 const WebRect& rect) { |
92 HDC hdc = canvas->beginPlatformPaint(); | 101 skia::PlatformCanvas* platform_canvas = ToPlatformCanvas(canvas); |
102 HDC hdc = platform_canvas->beginPlatformPaint(); | |
93 | 103 |
94 RECT native_rect = WebRectToRECT(rect); | 104 RECT native_rect = WebRectToRECT(rect); |
95 gfx::NativeThemeWin::instance()->PaintSpinButton( | 105 gfx::NativeThemeWin::instance()->PaintSpinButton( |
96 hdc, part, state, classic_state, &native_rect); | 106 hdc, part, state, classic_state, &native_rect); |
97 | 107 |
98 canvas->endPlatformPaint(); | 108 platform_canvas->endPlatformPaint(); |
99 } | 109 } |
100 | 110 |
101 void WebThemeEngineImpl::paintTextField( | 111 void WebThemeEngineImpl::paintTextField( |
102 WebCanvas* canvas, int part, int state, int classic_state, | 112 WebCanvas* canvas, int part, int state, int classic_state, |
103 const WebRect& rect, WebColor color, bool fill_content_area, | 113 const WebRect& rect, WebColor color, bool fill_content_area, |
104 bool draw_edges) { | 114 bool draw_edges) { |
105 HDC hdc = canvas->beginPlatformPaint(); | 115 skia::PlatformCanvas* platform_canvas = ToPlatformCanvas(canvas); |
116 HDC hdc = platform_canvas->beginPlatformPaint(); | |
106 | 117 |
107 RECT native_rect = WebRectToRECT(rect); | 118 RECT native_rect = WebRectToRECT(rect); |
108 COLORREF c = skia::SkColorToCOLORREF(color); | 119 COLORREF c = skia::SkColorToCOLORREF(color); |
109 | 120 |
110 gfx::NativeThemeWin::instance()->PaintTextField( | 121 gfx::NativeThemeWin::instance()->PaintTextField( |
111 hdc, part, state, classic_state, &native_rect, c, fill_content_area, | 122 hdc, part, state, classic_state, &native_rect, c, fill_content_area, |
112 draw_edges); | 123 draw_edges); |
113 | 124 |
114 canvas->endPlatformPaint(); | 125 platform_canvas->endPlatformPaint(); |
115 } | 126 } |
116 | 127 |
117 void WebThemeEngineImpl::paintTrackbar( | 128 void WebThemeEngineImpl::paintTrackbar( |
118 WebCanvas* canvas, int part, int state, int classic_state, | 129 WebCanvas* canvas, int part, int state, int classic_state, |
119 const WebRect& rect) { | 130 const WebRect& rect) { |
120 HDC hdc = canvas->beginPlatformPaint(); | 131 skia::PlatformCanvas* platform_canvas = ToPlatformCanvas(canvas); |
132 HDC hdc = platform_canvas->beginPlatformPaint(); | |
121 | 133 |
122 RECT native_rect = WebRectToRECT(rect); | 134 RECT native_rect = WebRectToRECT(rect); |
123 gfx::NativeThemeWin::instance()->PaintTrackbar( | 135 gfx::NativeThemeWin::instance()->PaintTrackbar( |
124 hdc, part, state, classic_state, &native_rect, canvas); | 136 hdc, part, state, classic_state, &native_rect, canvas); |
125 | 137 |
126 canvas->endPlatformPaint(); | 138 platform_canvas->endPlatformPaint(); |
127 } | 139 } |
128 | 140 |
129 void WebThemeEngineImpl::paintProgressBar( | 141 void WebThemeEngineImpl::paintProgressBar( |
130 WebCanvas* canvas, const WebRect& barRect, const WebRect& valueRect, | 142 WebCanvas* canvas, const WebRect& barRect, const WebRect& valueRect, |
131 bool determinate, double animatedSeconds) | 143 bool determinate, double animatedSeconds) |
132 { | 144 { |
133 HDC hdc = canvas->beginPlatformPaint(); | 145 skia::PlatformCanvas* platform_canvas = ToPlatformCanvas(canvas); |
146 HDC hdc = platform_canvas->beginPlatformPaint(); | |
147 | |
134 RECT native_bar_rect = WebRectToRECT(barRect); | 148 RECT native_bar_rect = WebRectToRECT(barRect); |
135 RECT native_value_rect = WebRectToRECT(valueRect); | 149 RECT native_value_rect = WebRectToRECT(valueRect); |
136 gfx::NativeThemeWin::instance()->PaintProgressBar( | 150 gfx::NativeThemeWin::instance()->PaintProgressBar( |
137 hdc, &native_bar_rect, | 151 hdc, &native_bar_rect, |
138 &native_value_rect, determinate, animatedSeconds, canvas); | 152 &native_value_rect, determinate, animatedSeconds, canvas); |
139 canvas->endPlatformPaint(); | 153 |
154 platform_canvas->endPlatformPaint(); | |
140 } | 155 } |
141 | 156 |
142 } // namespace webkit_glue | 157 } // namespace webkit_glue |
OLD | NEW |