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 void WebThemeEngineImpl::paintButton( | 27 void WebThemeEngineImpl::paintButton( |
28 WebCanvas* canvas, int part, int state, int classic_state, | 28 WebCanvas* canvas, int part, int state, int classic_state, |
29 const WebRect& rect) { | 29 const WebRect& rect) { |
30 HDC hdc = canvas->beginPlatformPaint(); | 30 HDC hdc = skia::BeginPlatformPaint(canvas); |
31 | 31 |
32 RECT native_rect = WebRectToRECT(rect); | 32 RECT native_rect = WebRectToRECT(rect); |
33 gfx::NativeThemeWin::instance()->PaintButton( | 33 gfx::NativeThemeWin::instance()->PaintButton( |
34 hdc, part, state, classic_state, &native_rect); | 34 hdc, part, state, classic_state, &native_rect); |
35 | 35 |
36 canvas->endPlatformPaint(); | 36 skia::EndPlatformPaint(canvas); |
37 } | 37 } |
38 | 38 |
39 void WebThemeEngineImpl::paintMenuList( | 39 void WebThemeEngineImpl::paintMenuList( |
40 WebCanvas* canvas, int part, int state, int classic_state, | 40 WebCanvas* canvas, int part, int state, int classic_state, |
41 const WebRect& rect) { | 41 const WebRect& rect) { |
42 HDC hdc = canvas->beginPlatformPaint(); | 42 HDC hdc = skia::BeginPlatformPaint(canvas); |
43 | 43 |
44 RECT native_rect = WebRectToRECT(rect); | 44 RECT native_rect = WebRectToRECT(rect); |
45 gfx::NativeThemeWin::instance()->PaintMenuList( | 45 gfx::NativeThemeWin::instance()->PaintMenuList( |
46 hdc, part, state, classic_state, &native_rect); | 46 hdc, part, state, classic_state, &native_rect); |
47 | 47 |
48 canvas->endPlatformPaint(); | 48 skia::EndPlatformPaint(canvas); |
49 } | 49 } |
50 | 50 |
51 void WebThemeEngineImpl::paintScrollbarArrow( | 51 void WebThemeEngineImpl::paintScrollbarArrow( |
52 WebCanvas* canvas, int state, int classic_state, | 52 WebCanvas* canvas, int state, int classic_state, |
53 const WebRect& rect) { | 53 const WebRect& rect) { |
54 HDC hdc = canvas->beginPlatformPaint(); | 54 HDC hdc = skia::BeginPlatformPaint(canvas); |
55 | 55 |
56 RECT native_rect = WebRectToRECT(rect); | 56 RECT native_rect = WebRectToRECT(rect); |
57 gfx::NativeThemeWin::instance()->PaintScrollbarArrow( | 57 gfx::NativeThemeWin::instance()->PaintScrollbarArrow( |
58 hdc, state, classic_state, &native_rect); | 58 hdc, state, classic_state, &native_rect); |
59 | 59 |
60 canvas->endPlatformPaint(); | 60 skia::EndPlatformPaint(canvas); |
61 } | 61 } |
62 | 62 |
63 void WebThemeEngineImpl::paintScrollbarThumb( | 63 void WebThemeEngineImpl::paintScrollbarThumb( |
64 WebCanvas* canvas, int part, int state, int classic_state, | 64 WebCanvas* canvas, int part, int state, int classic_state, |
65 const WebRect& rect) { | 65 const WebRect& rect) { |
66 HDC hdc = canvas->beginPlatformPaint(); | 66 HDC hdc = skia::BeginPlatformPaint(canvas); |
67 | 67 |
68 RECT native_rect = WebRectToRECT(rect); | 68 RECT native_rect = WebRectToRECT(rect); |
69 gfx::NativeThemeWin::instance()->PaintScrollbarThumb( | 69 gfx::NativeThemeWin::instance()->PaintScrollbarThumb( |
70 hdc, part, state, classic_state, &native_rect); | 70 hdc, part, state, classic_state, &native_rect); |
71 | 71 |
72 canvas->endPlatformPaint(); | 72 skia::EndPlatformPaint(canvas); |
73 } | 73 } |
74 | 74 |
75 void WebThemeEngineImpl::paintScrollbarTrack( | 75 void WebThemeEngineImpl::paintScrollbarTrack( |
76 WebCanvas* canvas, int part, int state, int classic_state, | 76 WebCanvas* canvas, int part, int state, int classic_state, |
77 const WebRect& rect, const WebRect& align_rect) { | 77 const WebRect& rect, const WebRect& align_rect) { |
78 HDC hdc = canvas->beginPlatformPaint(); | 78 HDC hdc = skia::BeginPlatformPaint(canvas); |
79 | 79 |
80 RECT native_rect = WebRectToRECT(rect); | 80 RECT native_rect = WebRectToRECT(rect); |
81 RECT native_align_rect = WebRectToRECT(align_rect); | 81 RECT native_align_rect = WebRectToRECT(align_rect); |
82 gfx::NativeThemeWin::instance()->PaintScrollbarTrack( | 82 gfx::NativeThemeWin::instance()->PaintScrollbarTrack( |
83 hdc, part, state, classic_state, &native_rect, &native_align_rect, | 83 hdc, part, state, classic_state, &native_rect, &native_align_rect, |
84 canvas); | 84 canvas); |
85 | 85 |
86 canvas->endPlatformPaint(); | 86 skia::EndPlatformPaint(canvas); |
87 } | 87 } |
88 | 88 |
89 void WebThemeEngineImpl::paintSpinButton( | 89 void WebThemeEngineImpl::paintSpinButton( |
90 WebCanvas* canvas, int part, int state, int classic_state, | 90 WebCanvas* canvas, int part, int state, int classic_state, |
91 const WebRect& rect) { | 91 const WebRect& rect) { |
92 HDC hdc = canvas->beginPlatformPaint(); | 92 HDC hdc = skia::BeginPlatformPaint(canvas); |
93 | 93 |
94 RECT native_rect = WebRectToRECT(rect); | 94 RECT native_rect = WebRectToRECT(rect); |
95 gfx::NativeThemeWin::instance()->PaintSpinButton( | 95 gfx::NativeThemeWin::instance()->PaintSpinButton( |
96 hdc, part, state, classic_state, &native_rect); | 96 hdc, part, state, classic_state, &native_rect); |
97 | 97 |
98 canvas->endPlatformPaint(); | 98 skia::EndPlatformPaint(canvas); |
99 } | 99 } |
100 | 100 |
101 void WebThemeEngineImpl::paintTextField( | 101 void WebThemeEngineImpl::paintTextField( |
102 WebCanvas* canvas, int part, int state, int classic_state, | 102 WebCanvas* canvas, int part, int state, int classic_state, |
103 const WebRect& rect, WebColor color, bool fill_content_area, | 103 const WebRect& rect, WebColor color, bool fill_content_area, |
104 bool draw_edges) { | 104 bool draw_edges) { |
105 HDC hdc = canvas->beginPlatformPaint(); | 105 HDC hdc = skia::BeginPlatformPaint(canvas); |
106 | 106 |
107 RECT native_rect = WebRectToRECT(rect); | 107 RECT native_rect = WebRectToRECT(rect); |
108 COLORREF c = skia::SkColorToCOLORREF(color); | 108 COLORREF c = skia::SkColorToCOLORREF(color); |
109 | 109 |
110 gfx::NativeThemeWin::instance()->PaintTextField( | 110 gfx::NativeThemeWin::instance()->PaintTextField( |
111 hdc, part, state, classic_state, &native_rect, c, fill_content_area, | 111 hdc, part, state, classic_state, &native_rect, c, fill_content_area, |
112 draw_edges); | 112 draw_edges); |
113 | 113 |
114 canvas->endPlatformPaint(); | 114 skia::EndPlatformPaint(canvas); |
115 } | 115 } |
116 | 116 |
117 void WebThemeEngineImpl::paintTrackbar( | 117 void WebThemeEngineImpl::paintTrackbar( |
118 WebCanvas* canvas, int part, int state, int classic_state, | 118 WebCanvas* canvas, int part, int state, int classic_state, |
119 const WebRect& rect) { | 119 const WebRect& rect) { |
120 HDC hdc = canvas->beginPlatformPaint(); | 120 HDC hdc = skia::BeginPlatformPaint(canvas); |
121 | 121 |
122 RECT native_rect = WebRectToRECT(rect); | 122 RECT native_rect = WebRectToRECT(rect); |
123 gfx::NativeThemeWin::instance()->PaintTrackbar( | 123 gfx::NativeThemeWin::instance()->PaintTrackbar( |
124 hdc, part, state, classic_state, &native_rect, canvas); | 124 hdc, part, state, classic_state, &native_rect, canvas); |
125 | 125 |
126 canvas->endPlatformPaint(); | 126 skia::EndPlatformPaint(canvas); |
127 } | 127 } |
128 | 128 |
129 void WebThemeEngineImpl::paintProgressBar( | 129 void WebThemeEngineImpl::paintProgressBar( |
130 WebCanvas* canvas, const WebRect& barRect, const WebRect& valueRect, | 130 WebCanvas* canvas, const WebRect& barRect, const WebRect& valueRect, |
131 bool determinate, double animatedSeconds) | 131 bool determinate, double animatedSeconds) |
132 { | 132 { |
133 HDC hdc = canvas->beginPlatformPaint(); | 133 HDC hdc = skia::BeginPlatformPaint(canvas); |
| 134 |
134 RECT native_bar_rect = WebRectToRECT(barRect); | 135 RECT native_bar_rect = WebRectToRECT(barRect); |
135 RECT native_value_rect = WebRectToRECT(valueRect); | 136 RECT native_value_rect = WebRectToRECT(valueRect); |
136 gfx::NativeThemeWin::instance()->PaintProgressBar( | 137 gfx::NativeThemeWin::instance()->PaintProgressBar( |
137 hdc, &native_bar_rect, | 138 hdc, &native_bar_rect, |
138 &native_value_rect, determinate, animatedSeconds, canvas); | 139 &native_value_rect, determinate, animatedSeconds, canvas); |
139 canvas->endPlatformPaint(); | 140 |
| 141 skia::EndPlatformPaint(canvas); |
140 } | 142 } |
141 | 143 |
142 } // namespace webkit_glue | 144 } // namespace webkit_glue |
OLD | NEW |