1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "webkit/glue/webthemeengine_impl_win.h"
7 #include <vsstyle.h> // To convert to ui::NativeTheme::State
9 #include "base/logging.h"
10 #include "skia/ext/platform_canvas.h"
11 #include "skia/ext/skia_utils_win.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
13 #include "ui/base/native_theme/native_theme.h"
15 using WebKit::WebCanvas
;
16 using WebKit::WebColor
;
17 using WebKit::WebRect
;
18 using WebKit::WebSize
;
20 namespace webkit_glue
{
22 static RECT
WebRectToRECT(const WebRect
& rect
) {
26 result
.right
= rect
.x
+ rect
.width
;
27 result
.bottom
= rect
.y
+ rect
.height
;
31 static ui::NativeTheme::State
WebButtonStateToGfx(
32 int part
, int state
, ui::NativeTheme::ButtonExtraParams
* extra
) {
33 ui::NativeTheme::State gfx_state
= ui::NativeTheme::kNormal
;
34 // Native buttons have a different focus style.
35 extra
->is_focused
= false;
37 if (part
== BP_PUSHBUTTON
) {
40 gfx_state
= ui::NativeTheme::kNormal
;
41 extra
->checked
= false;
42 extra
->indeterminate
= false;
43 extra
->is_default
= false;
46 gfx_state
= ui::NativeTheme::kHovered
;
47 extra
->checked
= false;
48 extra
->indeterminate
= false;
49 extra
->is_default
= false;
52 gfx_state
= ui::NativeTheme::kPressed
;
53 extra
->checked
= false;
54 extra
->indeterminate
= false;
55 extra
->is_default
= false;
58 gfx_state
= ui::NativeTheme::kDisabled
;
59 extra
->checked
= false;
60 extra
->indeterminate
= false;
61 extra
->is_default
= false;
64 gfx_state
= ui::NativeTheme::kNormal
;
65 extra
->checked
= false;
66 extra
->indeterminate
= false;
67 extra
->is_default
= true;
69 case PBS_DEFAULTED_ANIMATING
:
70 gfx_state
= ui::NativeTheme::kNormal
;
71 extra
->checked
= false;
72 extra
->indeterminate
= false;
73 extra
->is_default
= true;
76 NOTREACHED() << "Invalid state: " << state
;
78 } else if (part
== BP_RADIOBUTTON
) {
80 case RBS_UNCHECKEDNORMAL
:
81 gfx_state
= ui::NativeTheme::kNormal
;
82 extra
->checked
= false;
83 extra
->indeterminate
= false;
84 extra
->is_default
= false;
86 case RBS_UNCHECKEDHOT
:
87 gfx_state
= ui::NativeTheme::kHovered
;
88 extra
->checked
= false;
89 extra
->indeterminate
= false;
90 extra
->is_default
= false;
92 case RBS_UNCHECKEDPRESSED
:
93 gfx_state
= ui::NativeTheme::kPressed
;
94 extra
->checked
= false;
95 extra
->indeterminate
= false;
96 extra
->is_default
= false;
98 case RBS_UNCHECKEDDISABLED
:
99 gfx_state
= ui::NativeTheme::kDisabled
;
100 extra
->checked
= false;
101 extra
->indeterminate
= false;
102 extra
->is_default
= false;
104 case RBS_CHECKEDNORMAL
:
105 gfx_state
= ui::NativeTheme::kNormal
;
106 extra
->checked
= true;
107 extra
->indeterminate
= false;
108 extra
->is_default
= false;
111 gfx_state
= ui::NativeTheme::kHovered
;
112 extra
->checked
= true;
113 extra
->indeterminate
= false;
114 extra
->is_default
= false;
116 case RBS_CHECKEDPRESSED
:
117 gfx_state
= ui::NativeTheme::kPressed
;
118 extra
->checked
= true;
119 extra
->indeterminate
= false;
120 extra
->is_default
= false;
122 case RBS_CHECKEDDISABLED
:
123 gfx_state
= ui::NativeTheme::kDisabled
;
124 extra
->checked
= true;
125 extra
->indeterminate
= false;
126 extra
->is_default
= false;
129 NOTREACHED() << "Invalid state: " << state
;
132 } else if (part
== BP_CHECKBOX
) {
134 case CBS_UNCHECKEDNORMAL
:
135 gfx_state
= ui::NativeTheme::kNormal
;
136 extra
->checked
= false;
137 extra
->indeterminate
= false;
138 extra
->is_default
= false;
140 case CBS_UNCHECKEDHOT
:
141 gfx_state
= ui::NativeTheme::kHovered
;
142 extra
->checked
= false;
143 extra
->indeterminate
= false;
144 extra
->is_default
= false;
146 case CBS_UNCHECKEDPRESSED
:
147 gfx_state
= ui::NativeTheme::kPressed
;
148 extra
->checked
= false;
149 extra
->indeterminate
= false;
150 extra
->is_default
= false;
152 case CBS_UNCHECKEDDISABLED
:
153 gfx_state
= ui::NativeTheme::kDisabled
;
154 extra
->checked
= false;
155 extra
->indeterminate
= false;
156 extra
->is_default
= false;
158 case CBS_CHECKEDNORMAL
:
159 gfx_state
= ui::NativeTheme::kNormal
;
160 extra
->checked
= true;
161 extra
->indeterminate
= false;
162 extra
->is_default
= false;
165 gfx_state
= ui::NativeTheme::kHovered
;
166 extra
->checked
= true;
167 extra
->indeterminate
= false;
168 extra
->is_default
= false;
170 case CBS_CHECKEDPRESSED
:
171 gfx_state
= ui::NativeTheme::kPressed
;
172 extra
->checked
= true;
173 extra
->indeterminate
= false;
174 extra
->is_default
= false;
176 case CBS_CHECKEDDISABLED
:
177 gfx_state
= ui::NativeTheme::kDisabled
;
178 extra
->checked
= true;
179 extra
->indeterminate
= false;
180 extra
->is_default
= false;
182 case CBS_MIXEDNORMAL
:
183 gfx_state
= ui::NativeTheme::kNormal
;
184 extra
->checked
= false;
185 extra
->indeterminate
= true;
186 extra
->is_default
= false;
189 gfx_state
= ui::NativeTheme::kHovered
;
190 extra
->checked
= false;
191 extra
->indeterminate
= true;
192 extra
->is_default
= false;
194 case CBS_MIXEDPRESSED
:
195 gfx_state
= ui::NativeTheme::kPressed
;
196 extra
->checked
= false;
197 extra
->indeterminate
= true;
198 extra
->is_default
= false;
200 case CBS_MIXEDDISABLED
:
201 gfx_state
= ui::NativeTheme::kDisabled
;
202 extra
->checked
= false;
203 extra
->indeterminate
= true;
204 extra
->is_default
= false;
206 case CBS_IMPLICITNORMAL
:
207 gfx_state
= ui::NativeTheme::kNormal
;
208 extra
->checked
= false;
209 extra
->indeterminate
= false;
210 extra
->is_default
= false;
212 case CBS_IMPLICITHOT
:
213 gfx_state
= ui::NativeTheme::kHovered
;
214 extra
->checked
= false;
215 extra
->indeterminate
= false;
216 extra
->is_default
= false;
218 case CBS_IMPLICITPRESSED
:
219 gfx_state
= ui::NativeTheme::kPressed
;
220 extra
->checked
= false;
221 extra
->indeterminate
= false;
222 extra
->is_default
= false;
224 case CBS_IMPLICITDISABLED
:
225 gfx_state
= ui::NativeTheme::kDisabled
;
226 extra
->checked
= false;
227 extra
->indeterminate
= false;
228 extra
->is_default
= false;
230 case CBS_EXCLUDEDNORMAL
:
231 gfx_state
= ui::NativeTheme::kNormal
;
232 extra
->checked
= false;
233 extra
->indeterminate
= false;
234 extra
->is_default
= false;
236 case CBS_EXCLUDEDHOT
:
237 gfx_state
= ui::NativeTheme::kHovered
;
238 extra
->checked
= false;
239 extra
->indeterminate
= false;
240 extra
->is_default
= false;
242 case CBS_EXCLUDEDPRESSED
:
243 gfx_state
= ui::NativeTheme::kPressed
;
244 extra
->checked
= false;
245 extra
->indeterminate
= false;
246 extra
->is_default
= false;
248 case CBS_EXCLUDEDDISABLED
:
249 gfx_state
= ui::NativeTheme::kDisabled
;
250 extra
->checked
= false;
251 extra
->indeterminate
= false;
252 extra
->is_default
= false;
255 NOTREACHED() << "Invalid state: " << state
;
258 } else if (part
== BP_GROUPBOX
) {
261 gfx_state
= ui::NativeTheme::kNormal
;
262 extra
->checked
= false;
263 extra
->indeterminate
= false;
264 extra
->is_default
= false;
267 gfx_state
= ui::NativeTheme::kDisabled
;
268 extra
->checked
= false;
269 extra
->indeterminate
= false;
270 extra
->is_default
= false;
273 NOTREACHED() << "Invalid state: " << state
;
276 } else if (part
== BP_COMMANDLINK
) {
279 gfx_state
= ui::NativeTheme::kNormal
;
280 extra
->checked
= false;
281 extra
->indeterminate
= false;
282 extra
->is_default
= false;
285 gfx_state
= ui::NativeTheme::kHovered
;
286 extra
->checked
= false;
287 extra
->indeterminate
= false;
288 extra
->is_default
= false;
291 gfx_state
= ui::NativeTheme::kPressed
;
292 extra
->checked
= false;
293 extra
->indeterminate
= false;
294 extra
->is_default
= false;
297 gfx_state
= ui::NativeTheme::kDisabled
;
298 extra
->checked
= false;
299 extra
->indeterminate
= false;
300 extra
->is_default
= false;
302 case CMDLS_DEFAULTED
:
303 gfx_state
= ui::NativeTheme::kNormal
;
304 extra
->checked
= false;
305 extra
->indeterminate
= false;
306 extra
->is_default
= true;
308 case CMDLS_DEFAULTED_ANIMATING
:
309 gfx_state
= ui::NativeTheme::kNormal
;
310 extra
->checked
= false;
311 extra
->indeterminate
= false;
312 extra
->is_default
= true;
315 NOTREACHED() << "Invalid state: " << state
;
318 } else if (part
== BP_COMMANDLINKGLYPH
) {
321 gfx_state
= ui::NativeTheme::kNormal
;
322 extra
->checked
= false;
323 extra
->indeterminate
= false;
324 extra
->is_default
= false;
327 gfx_state
= ui::NativeTheme::kHovered
;
328 extra
->checked
= false;
329 extra
->indeterminate
= false;
330 extra
->is_default
= false;
333 gfx_state
= ui::NativeTheme::kPressed
;
334 extra
->checked
= false;
335 extra
->indeterminate
= false;
336 extra
->is_default
= false;
338 case CMDLGS_DISABLED
:
339 gfx_state
= ui::NativeTheme::kDisabled
;
340 extra
->checked
= false;
341 extra
->indeterminate
= false;
342 extra
->is_default
= false;
344 case CMDLGS_DEFAULTED
:
345 gfx_state
= ui::NativeTheme::kNormal
;
346 extra
->checked
= false;
347 extra
->indeterminate
= false;
348 extra
->is_default
= true;
351 NOTREACHED() << "Invalid state: " << state
;
358 void WebThemeEngineImpl::paintButton(
359 WebCanvas
* canvas
, int part
, int state
, int classic_state
,
360 const WebRect
& rect
) {
361 ui::NativeTheme::Part native_part
= ui::NativeTheme::kPushButton
;
364 native_part
= ui::NativeTheme::kPushButton
;
367 native_part
= ui::NativeTheme::kCheckbox
;
370 native_part
= ui::NativeTheme::kRadio
;
373 NOTREACHED() << "Invalid part: " << part
;
376 ui::NativeTheme::ExtraParams extra
;
377 ui::NativeTheme::State native_state
= WebButtonStateToGfx(part
, state
,
379 extra
.button
.classic_state
= classic_state
;
380 gfx::Rect
gfx_rect(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
381 ui::NativeTheme::instance()->Paint(canvas
, native_part
,
382 native_state
, gfx_rect
, extra
);
385 static ui::NativeTheme::State
WebListMenuStateToGfx(int part
, int state
) {
386 ui::NativeTheme::State gfx_state
= ui::NativeTheme::kNormal
;
389 case CP_DROPDOWNBUTTON
:
392 gfx_state
= ui::NativeTheme::kNormal
;
395 gfx_state
= ui::NativeTheme::kHovered
;
398 gfx_state
= ui::NativeTheme::kPressed
;
401 gfx_state
= ui::NativeTheme::kDisabled
;
404 NOTREACHED() << "Invalid state: " << state
;
409 NOTREACHED() << "Invalid part: " << part
;
415 void WebThemeEngineImpl::paintMenuList(
416 WebCanvas
* canvas
, int part
, int state
, int classic_state
,
417 const WebRect
& rect
) {
418 ui::NativeTheme::Part native_part
= ui::NativeTheme::kMenuList
;
420 case CP_DROPDOWNBUTTON
:
421 native_part
= ui::NativeTheme::kMenuList
;
424 NOTREACHED() << "Invalid part: " << part
;
427 ui::NativeTheme::State native_state
= WebListMenuStateToGfx(part
, state
);
428 gfx::Rect
gfx_rect(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
429 ui::NativeTheme::ExtraParams extra
;
430 extra
.menu_list
.classic_state
= classic_state
;
431 ui::NativeTheme::instance()->Paint(canvas
, native_part
,
432 native_state
, gfx_rect
, extra
);
435 static ui::NativeTheme::State
WebScrollbarArrowStateToGfx(
436 int state
, ui::NativeTheme::Part
* part
,
437 ui::NativeTheme::ScrollbarArrowExtraParams
* extra
) {
438 ui::NativeTheme::State gfx_state
= ui::NativeTheme::kNormal
;
441 gfx_state
= ui::NativeTheme::kNormal
;
442 *part
= ui::NativeTheme::kScrollbarUpArrow
;
443 extra
->is_hovering
= false;
446 gfx_state
= ui::NativeTheme::kHovered
;
447 *part
= ui::NativeTheme::kScrollbarUpArrow
;
448 extra
->is_hovering
= false;
451 gfx_state
= ui::NativeTheme::kPressed
;
452 *part
= ui::NativeTheme::kScrollbarUpArrow
;
453 extra
->is_hovering
= false;
456 gfx_state
= ui::NativeTheme::kDisabled
;
457 *part
= ui::NativeTheme::kScrollbarUpArrow
;
458 extra
->is_hovering
= false;
461 gfx_state
= ui::NativeTheme::kNormal
;
462 *part
= ui::NativeTheme::kScrollbarDownArrow
;
463 extra
->is_hovering
= false;
466 gfx_state
= ui::NativeTheme::kHovered
;
467 *part
= ui::NativeTheme::kScrollbarDownArrow
;
468 extra
->is_hovering
= false;
470 case ABS_DOWNPRESSED
:
471 gfx_state
= ui::NativeTheme::kPressed
;
472 *part
= ui::NativeTheme::kScrollbarDownArrow
;
473 extra
->is_hovering
= false;
475 case ABS_DOWNDISABLED
:
476 gfx_state
= ui::NativeTheme::kDisabled
;
477 *part
= ui::NativeTheme::kScrollbarDownArrow
;
478 extra
->is_hovering
= false;
481 gfx_state
= ui::NativeTheme::kNormal
;
482 *part
= ui::NativeTheme::kScrollbarLeftArrow
;
483 extra
->is_hovering
= false;
486 gfx_state
= ui::NativeTheme::kHovered
;
487 *part
= ui::NativeTheme::kScrollbarLeftArrow
;
488 extra
->is_hovering
= false;
490 case ABS_LEFTPRESSED
:
491 gfx_state
= ui::NativeTheme::kPressed
;
492 *part
= ui::NativeTheme::kScrollbarLeftArrow
;
493 extra
->is_hovering
= false;
495 case ABS_LEFTDISABLED
:
496 gfx_state
= ui::NativeTheme::kDisabled
;
497 *part
= ui::NativeTheme::kScrollbarLeftArrow
;
498 extra
->is_hovering
= false;
500 case ABS_RIGHTNORMAL
:
501 gfx_state
= ui::NativeTheme::kNormal
;
502 *part
= ui::NativeTheme::kScrollbarRightArrow
;
503 extra
->is_hovering
= false;
506 gfx_state
= ui::NativeTheme::kHovered
;
507 *part
= ui::NativeTheme::kScrollbarRightArrow
;
508 extra
->is_hovering
= false;
510 case ABS_RIGHTPRESSED
:
511 gfx_state
= ui::NativeTheme::kPressed
;
512 *part
= ui::NativeTheme::kScrollbarRightArrow
;
513 extra
->is_hovering
= false;
515 case ABS_RIGHTDISABLED
:
516 gfx_state
= ui::NativeTheme::kDisabled
;
517 *part
= ui::NativeTheme::kScrollbarRightArrow
;
518 extra
->is_hovering
= false;
521 gfx_state
= ui::NativeTheme::kHovered
;
522 *part
= ui::NativeTheme::kScrollbarUpArrow
;
523 extra
->is_hovering
= true;
526 gfx_state
= ui::NativeTheme::kHovered
;
527 *part
= ui::NativeTheme::kScrollbarDownArrow
;
528 extra
->is_hovering
= true;
531 gfx_state
= ui::NativeTheme::kHovered
;
532 *part
= ui::NativeTheme::kScrollbarLeftArrow
;
533 extra
->is_hovering
= true;
536 gfx_state
= ui::NativeTheme::kHovered
;
537 *part
= ui::NativeTheme::kScrollbarRightArrow
;
538 extra
->is_hovering
= true;
541 NOTREACHED() << "Invalid state: " << state
;
547 void WebThemeEngineImpl::paintScrollbarArrow(
548 WebCanvas
* canvas
, int state
, int classic_state
, const WebRect
& rect
) {
549 ui::NativeTheme::Part native_part
;
550 ui::NativeTheme::ExtraParams extra
;
551 ui::NativeTheme::State native_state
= WebScrollbarArrowStateToGfx(
552 state
, &native_part
, &extra
.scrollbar_arrow
);
553 gfx::Rect
gfx_rect(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
554 ui::NativeTheme::instance()->Paint(canvas
, native_part
,
555 native_state
, gfx_rect
, extra
);
558 static ui::NativeTheme::State
WebScrollbarThumbStateToGfx(
559 int state
, ui::NativeTheme::ScrollbarThumbExtraParams
* extra
) {
560 ui::NativeTheme::State gfx_state
= ui::NativeTheme::kNormal
;
563 gfx_state
= ui::NativeTheme::kNormal
;
564 extra
->is_hovering
= false;
567 gfx_state
= ui::NativeTheme::kHovered
;
568 extra
->is_hovering
= true;
571 gfx_state
= ui::NativeTheme::kHovered
;
572 extra
->is_hovering
= false;
575 gfx_state
= ui::NativeTheme::kPressed
;
576 extra
->is_hovering
= false;
579 gfx_state
= ui::NativeTheme::kDisabled
;
580 extra
->is_hovering
= false;
583 NOTREACHED() << "Invalid state: " << state
;
589 void WebThemeEngineImpl::paintScrollbarThumb(
590 WebCanvas
* canvas
, int part
, int state
, int classic_state
,
591 const WebRect
& rect
) {
592 ui::NativeTheme::Part native_part
;
593 if (part
== SBP_THUMBBTNHORZ
) {
594 native_part
= ui::NativeTheme::kScrollbarHorizontalThumb
;
595 } else if (part
== SBP_THUMBBTNVERT
) {
596 native_part
= ui::NativeTheme::kScrollbarVerticalThumb
;
597 } else if (part
== SBP_GRIPPERHORZ
) {
598 native_part
= ui::NativeTheme::kScrollbarHorizontalGripper
;
599 } else if (part
== SBP_GRIPPERVERT
) {
600 native_part
= ui::NativeTheme::kScrollbarVerticalGripper
;
602 NOTREACHED() << "Invalid part: " << part
;
605 ui::NativeTheme::ExtraParams extra
;
606 ui::NativeTheme::State native_state
= WebScrollbarThumbStateToGfx(
607 state
, &extra
.scrollbar_thumb
);
609 gfx::Rect
gfx_rect(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
610 ui::NativeTheme::instance()->Paint(canvas
, native_part
,
611 native_state
, gfx_rect
, extra
);
614 static ui::NativeTheme::State
WebScrollbarTrackStateToGfx(
615 int part
, int state
, ui::NativeTheme::Part
* gfx_part
,
616 ui::NativeTheme::ScrollbarTrackExtraParams
* extra
) {
617 ui::NativeTheme::State gfx_state
= ui::NativeTheme::kNormal
;
619 case SBP_LOWERTRACKHORZ
:
622 gfx_state
= ui::NativeTheme::kNormal
;
623 *gfx_part
= ui::NativeTheme::kScrollbarHorizontalTrack
;
624 extra
->is_upper
= false;
628 gfx_state
= ui::NativeTheme::kHovered
;
629 *gfx_part
= ui::NativeTheme::kScrollbarHorizontalTrack
;
630 extra
->is_upper
= false;
633 gfx_state
= ui::NativeTheme::kPressed
;
634 *gfx_part
= ui::NativeTheme::kScrollbarHorizontalTrack
;
635 extra
->is_upper
= false;
638 gfx_state
= ui::NativeTheme::kDisabled
;
639 *gfx_part
= ui::NativeTheme::kScrollbarHorizontalTrack
;
640 extra
->is_upper
= false;
643 NOTREACHED() << "Invalid state: " << state
;
647 case SBP_UPPERTRACKHORZ
:
650 gfx_state
= ui::NativeTheme::kNormal
;
651 *gfx_part
= ui::NativeTheme::kScrollbarHorizontalTrack
;
652 extra
->is_upper
= true;
656 gfx_state
= ui::NativeTheme::kHovered
;
657 *gfx_part
= ui::NativeTheme::kScrollbarHorizontalTrack
;
658 extra
->is_upper
= true;
661 gfx_state
= ui::NativeTheme::kPressed
;
662 *gfx_part
= ui::NativeTheme::kScrollbarHorizontalTrack
;
663 extra
->is_upper
= true;
666 gfx_state
= ui::NativeTheme::kDisabled
;
667 *gfx_part
= ui::NativeTheme::kScrollbarHorizontalTrack
;
668 extra
->is_upper
= true;
671 NOTREACHED() << "Invalid state: " << state
;
675 case SBP_LOWERTRACKVERT
:
678 gfx_state
= ui::NativeTheme::kNormal
;
679 *gfx_part
= ui::NativeTheme::kScrollbarVerticalTrack
;
680 extra
->is_upper
= false;
684 gfx_state
= ui::NativeTheme::kHovered
;
685 *gfx_part
= ui::NativeTheme::kScrollbarVerticalTrack
;
686 extra
->is_upper
= false;
689 gfx_state
= ui::NativeTheme::kPressed
;
690 *gfx_part
= ui::NativeTheme::kScrollbarVerticalTrack
;
691 extra
->is_upper
= false;
694 gfx_state
= ui::NativeTheme::kDisabled
;
695 *gfx_part
= ui::NativeTheme::kScrollbarVerticalTrack
;
696 extra
->is_upper
= false;
699 NOTREACHED() << "Invalid state: " << state
;
703 case SBP_UPPERTRACKVERT
:
706 gfx_state
= ui::NativeTheme::kNormal
;
707 *gfx_part
= ui::NativeTheme::kScrollbarVerticalTrack
;
708 extra
->is_upper
= true;
712 gfx_state
= ui::NativeTheme::kHovered
;
713 *gfx_part
= ui::NativeTheme::kScrollbarVerticalTrack
;
714 extra
->is_upper
= true;
717 gfx_state
= ui::NativeTheme::kPressed
;
718 *gfx_part
= ui::NativeTheme::kScrollbarVerticalTrack
;
719 extra
->is_upper
= true;
722 gfx_state
= ui::NativeTheme::kDisabled
;
723 *gfx_part
= ui::NativeTheme::kScrollbarVerticalTrack
;
724 extra
->is_upper
= true;
727 NOTREACHED() << "Invalid state: " << state
;
732 NOTREACHED() << "Invalid part: " << part
;
738 void WebThemeEngineImpl::paintScrollbarTrack(
739 WebCanvas
* canvas
, int part
, int state
, int classic_state
,
740 const WebRect
& rect
, const WebRect
& align_rect
) {
741 ui::NativeTheme::Part native_part
;
742 ui::NativeTheme::ExtraParams extra
;
743 ui::NativeTheme::State native_state
= WebScrollbarTrackStateToGfx(
744 part
, state
, &native_part
, &extra
.scrollbar_track
);
745 extra
.scrollbar_track
.classic_state
= classic_state
;
746 extra
.scrollbar_track
.track_x
= align_rect
.x
;
747 extra
.scrollbar_track
.track_y
= align_rect
.y
;
748 extra
.scrollbar_track
.track_width
= align_rect
.width
;
749 extra
.scrollbar_track
.track_height
= align_rect
.height
;
751 gfx::Rect
gfx_rect(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
752 ui::NativeTheme::instance()->Paint(canvas
, native_part
,
753 native_state
, gfx_rect
, extra
);
756 static ui::NativeTheme::State
WebSpinButtonStateToGfx(
757 int part
, int state
, ui::NativeTheme::InnerSpinButtonExtraParams
* extra
) {
758 ui::NativeTheme::State gfx_state
= ui::NativeTheme::kNormal
;
763 gfx_state
= ui::NativeTheme::kNormal
;
764 extra
->spin_up
= true;
765 extra
->read_only
= false;
768 gfx_state
= ui::NativeTheme::kHovered
;
769 extra
->spin_up
= true;
770 extra
->read_only
= false;
773 gfx_state
= ui::NativeTheme::kPressed
;
774 extra
->spin_up
= true;
775 extra
->read_only
= false;
778 gfx_state
= ui::NativeTheme::kDisabled
;
779 extra
->spin_up
= true;
780 extra
->read_only
= false;
783 NOTREACHED() << "Invalid state: " << state
;
790 gfx_state
= ui::NativeTheme::kNormal
;
791 extra
->spin_up
= false;
792 extra
->read_only
= false;
795 gfx_state
= ui::NativeTheme::kHovered
;
796 extra
->spin_up
= false;
797 extra
->read_only
= false;
800 gfx_state
= ui::NativeTheme::kPressed
;
801 extra
->spin_up
= false;
802 extra
->read_only
= false;
805 gfx_state
= ui::NativeTheme::kDisabled
;
806 extra
->spin_up
= false;
807 extra
->read_only
= false;
810 NOTREACHED() << "Invalid state: " << state
;
815 NOTREACHED() << "Invalid part: " << part
;
821 void WebThemeEngineImpl::paintSpinButton(
822 WebCanvas
* canvas
, int part
, int state
, int classic_state
,
823 const WebRect
& rect
) {
824 ui::NativeTheme::ExtraParams extra
;
825 ui::NativeTheme::State native_state
= WebSpinButtonStateToGfx(
826 part
, state
, &extra
.inner_spin
);
827 extra
.inner_spin
.classic_state
= classic_state
;
828 gfx::Rect
gfx_rect(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
829 ui::NativeTheme::instance()->Paint(canvas
,
830 ui::NativeTheme::kInnerSpinButton
,
836 static ui::NativeTheme::State
WebTextFieldStateToGfx(
837 int part
, int state
, ui::NativeTheme::TextFieldExtraParams
* extra
) {
838 ui::NativeTheme::State gfx_state
= ui::NativeTheme::kNormal
;
843 gfx_state
= ui::NativeTheme::kNormal
;
844 extra
->is_read_only
= false;
845 extra
->is_focused
= false;
848 gfx_state
= ui::NativeTheme::kHovered
;
849 extra
->is_read_only
= false;
850 extra
->is_focused
= false;
853 gfx_state
= ui::NativeTheme::kPressed
;
854 extra
->is_read_only
= false;
855 extra
->is_focused
= false;
858 gfx_state
= ui::NativeTheme::kDisabled
;
859 extra
->is_read_only
= false;
860 extra
->is_focused
= false;
863 gfx_state
= ui::NativeTheme::kNormal
;
864 extra
->is_read_only
= false;
865 extra
->is_focused
= true;
868 gfx_state
= ui::NativeTheme::kNormal
;
869 extra
->is_read_only
= true;
870 extra
->is_focused
= false;
873 NOTREACHED() << "Invalid state: " << state
;
878 NOTREACHED() << "Invalid part: " << part
;
884 void WebThemeEngineImpl::paintTextField(
885 WebCanvas
* canvas
, int part
, int state
, int classic_state
,
886 const WebRect
& rect
, WebColor color
, bool fill_content_area
,
888 ui::NativeTheme::ExtraParams extra
;
889 ui::NativeTheme::State native_state
= WebTextFieldStateToGfx(
890 part
, state
, &extra
.text_field
);
891 extra
.text_field
.fill_content_area
= fill_content_area
;
892 extra
.text_field
.draw_edges
= draw_edges
;
893 extra
.text_field
.background_color
= color
;
894 extra
.text_field
.classic_state
= classic_state
;
895 gfx::Rect
gfx_rect(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
897 ui::NativeTheme::instance()->Paint(canvas
,
898 ui::NativeTheme::kTextField
, native_state
, gfx_rect
, extra
);
901 static ui::NativeTheme::State
WebTrackbarStateToGfx(
904 ui::NativeTheme::TrackbarExtraParams
* extra
) {
905 ui::NativeTheme::State gfx_state
= ui::NativeTheme::kNormal
;
908 gfx_state
= ui::NativeTheme::kNormal
;
911 gfx_state
= ui::NativeTheme::kHovered
;
914 gfx_state
= ui::NativeTheme::kPressed
;
917 gfx_state
= ui::NativeTheme::kDisabled
;
920 NOTREACHED() << "Invalid state: " << state
;
926 case TKP_THUMBBOTTOM
:
927 extra
->vertical
= false;
931 extra
->vertical
= true;
934 NOTREACHED() << "Invalid part: " << part
;
941 void WebThemeEngineImpl::paintTrackbar(
942 WebCanvas
* canvas
, int part
, int state
, int classic_state
,
943 const WebRect
& rect
) {
944 ui::NativeTheme::Part native_part
= ui::NativeTheme::kTrackbarTrack
;
948 native_part
= ui::NativeTheme::kTrackbarTrack
;
950 case TKP_THUMBBOTTOM
:
952 native_part
= ui::NativeTheme::kTrackbarThumb
;
955 NOTREACHED() << "Invalid part: " << part
;
959 ui::NativeTheme::ExtraParams extra
;
960 ui::NativeTheme::State native_state
= WebTrackbarStateToGfx(part
, state
,
962 gfx::Rect
gfx_rect(rect
.x
, rect
.y
, rect
.width
, rect
.height
);
963 extra
.trackbar
.classic_state
= classic_state
;
964 ui::NativeTheme::instance()->Paint(canvas
, native_part
,
965 native_state
, gfx_rect
, extra
);
968 void WebThemeEngineImpl::paintProgressBar(
969 WebCanvas
* canvas
, const WebRect
& barRect
, const WebRect
& valueRect
,
970 bool determinate
, double animatedSeconds
)
972 gfx::Rect
gfx_rect(barRect
.x
, barRect
.y
, barRect
.width
, barRect
.height
);
973 ui::NativeTheme::ExtraParams extra
;
974 extra
.progress_bar
.animated_seconds
= animatedSeconds
;
975 extra
.progress_bar
.determinate
= determinate
;
976 extra
.progress_bar
.value_rect_x
= valueRect
.x
;
977 extra
.progress_bar
.value_rect_y
= valueRect
.y
;
978 extra
.progress_bar
.value_rect_width
= valueRect
.width
;
979 extra
.progress_bar
.value_rect_height
= valueRect
.height
;
980 ui::NativeTheme::instance()->Paint(canvas
, ui::NativeTheme::kProgressBar
,
981 ui::NativeTheme::kNormal
, gfx_rect
,
985 WebSize
WebThemeEngineImpl::getSize(int part
) {
988 gfx::Size size
= ui::NativeTheme::instance()->GetPartSize(
989 ui::NativeTheme::kScrollbarUpArrow
,
990 ui::NativeTheme::kNormal
,
991 ui::NativeTheme::ExtraParams());
992 return WebSize(size
.width(), size
.height());
995 NOTREACHED() << "Unhandled part: " << part
;
1000 } // namespace webkit_glue