Clean up ChunkedUpdateDrawingAreaProxy
[WebKit-https.git] / Tools / DumpRenderTree / chromium / WebThemeEngineDRT.cpp
1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #include "config.h"
32 #include "WebThemeEngineDRT.h"
33
34 #include "WebRect.h"
35 #include "WebThemeControlDRT.h"
36 #include "third_party/skia/include/core/SkRect.h"
37
38 // Although all this code is generic, we include these headers
39 // to pull in the Windows #defines for the parts and states of
40 // the controls.
41 #include <vsstyle.h>
42 #include <windows.h>
43
44 #include <wtf/Assertions.h>
45
46 using namespace WebKit;
47
48 // We define this for clarity, although there really should be a DFCS_NORMAL in winuser.h.
49 static const int dfcsNormal = 0x0000;
50
51 static SkIRect webRectToSkIRect(const WebRect& webRect)
52 {
53     SkIRect irect;
54     irect.set(webRect.x, webRect.y, webRect.x + webRect.width, webRect.y + webRect.height);
55     return irect;
56 }
57
58 static void drawControl(WebCanvas* canvas,
59                         const WebRect& rect,
60                         WebThemeControlDRT::Type ctype,
61                         WebThemeControlDRT::State cstate)
62 {
63     WebThemeControlDRT control(canvas, webRectToSkIRect(rect), ctype, cstate);
64     control.draw();
65 }
66
67 static void drawTextField(WebCanvas* canvas,
68                           const WebRect& rect,
69                           WebThemeControlDRT::Type ctype,
70                           WebThemeControlDRT::State cstate,
71                           bool drawEdges,
72                           bool fillContentArea,
73                           WebColor color)
74 {
75     WebThemeControlDRT control(canvas, webRectToSkIRect(rect), ctype, cstate);
76     control.drawTextField(drawEdges, fillContentArea, color);
77 }
78
79 static void drawProgressBar(WebCanvas* canvas,
80                             WebThemeControlDRT::Type ctype,
81                             WebThemeControlDRT::State cstate,
82                             const WebRect& barRect,
83                             const WebRect& fillRect)
84 {
85     WebThemeControlDRT control(canvas, webRectToSkIRect(barRect), ctype, cstate);
86     control.drawProgressBar(webRectToSkIRect(fillRect));
87 }
88
89 // WebThemeEngineDRT
90
91 void WebThemeEngineDRT::paintButton(WebCanvas* canvas,
92                                     int part,
93                                     int state,
94                                     int classicState,
95                                     const WebRect& rect)
96 {
97     WebThemeControlDRT::Type ctype = WebThemeControlDRT::UnknownType;
98     WebThemeControlDRT::State cstate = WebThemeControlDRT::UnknownState;
99
100     if (part == BP_CHECKBOX) {
101         switch (state) {
102         case CBS_UNCHECKEDNORMAL:
103             ASSERT(classicState == dfcsNormal);
104             ctype = WebThemeControlDRT::UncheckedBoxType;
105             cstate = WebThemeControlDRT::NormalState;
106             break;
107
108         case CBS_UNCHECKEDHOT:
109             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_HOT));
110             ctype = WebThemeControlDRT::UncheckedBoxType;
111             cstate = WebThemeControlDRT::HotState;
112             break;
113
114         case CBS_UNCHECKEDPRESSED:
115             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_PUSHED));
116             ctype = WebThemeControlDRT::UncheckedBoxType;
117             cstate = WebThemeControlDRT::PressedState;
118             break;
119
120         case CBS_UNCHECKEDDISABLED:
121             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_INACTIVE));
122             ctype = WebThemeControlDRT::UncheckedBoxType;
123             cstate = WebThemeControlDRT::DisabledState;
124             break;
125
126         case CBS_CHECKEDNORMAL:
127             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_CHECKED));
128             ctype = WebThemeControlDRT::CheckedBoxType;
129             cstate = WebThemeControlDRT::NormalState;
130             break;
131
132         case CBS_CHECKEDHOT:
133             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_HOT));
134             ctype = WebThemeControlDRT::CheckedBoxType;
135             cstate = WebThemeControlDRT::HotState;
136             break;
137
138         case CBS_CHECKEDPRESSED:
139             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_PUSHED));
140             ctype = WebThemeControlDRT::CheckedBoxType;
141             cstate = WebThemeControlDRT::PressedState;
142             break;
143
144         case CBS_CHECKEDDISABLED:
145             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE));
146             ctype = WebThemeControlDRT::CheckedBoxType;
147             cstate = WebThemeControlDRT::DisabledState;
148             break;
149
150         case CBS_MIXEDNORMAL:
151             // Classic theme can't represent mixed state checkbox. We assume
152             // it's equivalent to unchecked.
153             ASSERT(classicState == DFCS_BUTTONCHECK);
154             ctype = WebThemeControlDRT::IndeterminateCheckboxType;
155             cstate = WebThemeControlDRT::NormalState;
156             break;
157
158         case CBS_MIXEDHOT:
159             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_HOT));
160             ctype = WebThemeControlDRT::IndeterminateCheckboxType;
161             cstate = WebThemeControlDRT::HotState;
162             break;
163
164         case CBS_MIXEDPRESSED:
165             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_PUSHED));
166             ctype = WebThemeControlDRT::IndeterminateCheckboxType;
167             cstate = WebThemeControlDRT::PressedState;
168             break;
169
170         case CBS_MIXEDDISABLED:
171             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_INACTIVE));
172             ctype = WebThemeControlDRT::IndeterminateCheckboxType;
173             cstate = WebThemeControlDRT::DisabledState;
174             break;
175
176         default:
177             ASSERT_NOT_REACHED();
178             break;
179         }
180     } else if (BP_RADIOBUTTON == part) {
181         switch (state) {
182         case RBS_UNCHECKEDNORMAL:
183             ASSERT(classicState == DFCS_BUTTONRADIO);
184             ctype = WebThemeControlDRT::UncheckedRadioType;
185             cstate = WebThemeControlDRT::NormalState;
186             break;
187
188         case RBS_UNCHECKEDHOT:
189             ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_HOT));
190             ctype = WebThemeControlDRT::UncheckedRadioType;
191             cstate = WebThemeControlDRT::HotState;
192             break;
193
194         case RBS_UNCHECKEDPRESSED:
195             ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_PUSHED));
196             ctype = WebThemeControlDRT::UncheckedRadioType;
197             cstate = WebThemeControlDRT::PressedState;
198             break;
199
200         case RBS_UNCHECKEDDISABLED:
201             ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_INACTIVE));
202             ctype = WebThemeControlDRT::UncheckedRadioType;
203             cstate = WebThemeControlDRT::DisabledState;
204             break;
205
206         case RBS_CHECKEDNORMAL:
207             ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_CHECKED));
208             ctype = WebThemeControlDRT::CheckedRadioType;
209             cstate = WebThemeControlDRT::NormalState;
210             break;
211
212         case RBS_CHECKEDHOT:
213             ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_HOT));
214             ctype = WebThemeControlDRT::CheckedRadioType;
215             cstate = WebThemeControlDRT::HotState;
216             break;
217
218         case RBS_CHECKEDPRESSED:
219             ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_PUSHED));
220             ctype = WebThemeControlDRT::CheckedRadioType;
221             cstate = WebThemeControlDRT::PressedState;
222             break;
223
224         case RBS_CHECKEDDISABLED:
225             ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_INACTIVE));
226             ctype = WebThemeControlDRT::CheckedRadioType;
227             cstate = WebThemeControlDRT::DisabledState;
228             break;
229
230         default:
231             ASSERT_NOT_REACHED();
232             break;
233         }
234     } else if (BP_PUSHBUTTON == part) {
235         switch (state) {
236         case PBS_NORMAL:
237             ASSERT(classicState == DFCS_BUTTONPUSH);
238             ctype = WebThemeControlDRT::PushButtonType;
239             cstate = WebThemeControlDRT::NormalState;
240             break;
241
242         case PBS_HOT:
243             ASSERT(classicState == (DFCS_BUTTONPUSH | DFCS_HOT));
244             ctype = WebThemeControlDRT::PushButtonType;
245             cstate = WebThemeControlDRT::HotState;
246             break;
247
248         case PBS_PRESSED:
249             ASSERT(classicState == (DFCS_BUTTONPUSH | DFCS_PUSHED));
250             ctype = WebThemeControlDRT::PushButtonType;
251             cstate = WebThemeControlDRT::PressedState;
252             break;
253
254         case PBS_DISABLED:
255             ASSERT(classicState == (DFCS_BUTTONPUSH | DFCS_INACTIVE));
256             ctype = WebThemeControlDRT::PushButtonType;
257             cstate = WebThemeControlDRT::DisabledState;
258             break;
259
260         case PBS_DEFAULTED:
261             ASSERT(classicState == DFCS_BUTTONPUSH);
262             ctype = WebThemeControlDRT::PushButtonType;
263             cstate = WebThemeControlDRT::FocusedState;
264             break;
265
266         default:
267             ASSERT_NOT_REACHED();
268             break;
269         }
270     } else {
271         ASSERT_NOT_REACHED();
272     }
273
274     drawControl(canvas, rect, ctype, cstate);
275 }
276
277
278 void WebThemeEngineDRT::paintMenuList(WebCanvas* canvas,
279                                       int part,
280                                       int state,
281                                       int classicState,
282                                       const WebRect& rect)
283 {
284     WebThemeControlDRT::Type ctype = WebThemeControlDRT::UnknownType;
285     WebThemeControlDRT::State cstate = WebThemeControlDRT::UnknownState;
286
287     if (CP_DROPDOWNBUTTON == part) {
288         ctype = WebThemeControlDRT::DropDownButtonType;
289         switch (state) {
290         case CBXS_NORMAL:
291             ASSERT(classicState == DFCS_MENUARROW);
292             cstate = WebThemeControlDRT::NormalState;
293             break;
294
295         case CBXS_HOT:
296             ASSERT(classicState == (DFCS_MENUARROW | DFCS_HOT));
297             cstate = WebThemeControlDRT::HoverState;
298             break;
299
300         case CBXS_PRESSED:
301             ASSERT(classicState == (DFCS_MENUARROW | DFCS_PUSHED));
302             cstate = WebThemeControlDRT::PressedState;
303             break;
304
305         case CBXS_DISABLED:
306             ASSERT(classicState == (DFCS_MENUARROW | DFCS_INACTIVE));
307             cstate = WebThemeControlDRT::DisabledState;
308             break;
309
310         default:
311             CRASH();
312             break;
313         }
314     } else {
315         CRASH();
316     }
317
318     drawControl(canvas, rect, ctype, cstate);
319 }
320
321 void WebThemeEngineDRT::paintScrollbarArrow(WebCanvas* canvas,
322                                             int state,
323                                             int classicState,
324                                             const WebRect& rect)
325 {
326     WebThemeControlDRT::Type ctype = WebThemeControlDRT::UnknownType;
327     WebThemeControlDRT::State cstate = WebThemeControlDRT::UnknownState;
328
329     switch (state) {
330     case ABS_UPNORMAL:
331         ASSERT(classicState == DFCS_SCROLLUP);
332         ctype = WebThemeControlDRT::UpArrowType;
333         cstate = WebThemeControlDRT::NormalState;
334         break;
335
336     case ABS_DOWNNORMAL:
337         ASSERT(classicState == DFCS_SCROLLDOWN);
338         ctype = WebThemeControlDRT::DownArrowType;
339         cstate = WebThemeControlDRT::NormalState;
340         break;
341
342     case ABS_LEFTNORMAL:
343         ASSERT(classicState == DFCS_SCROLLLEFT);
344         ctype = WebThemeControlDRT::LeftArrowType;
345         cstate = WebThemeControlDRT::NormalState;
346         break;
347
348     case ABS_RIGHTNORMAL:
349         ASSERT(classicState == DFCS_SCROLLRIGHT);
350         ctype = WebThemeControlDRT::RightArrowType;
351         cstate = WebThemeControlDRT::NormalState;
352         break;
353
354     case ABS_UPHOT:
355         ASSERT(classicState == (DFCS_SCROLLUP | DFCS_HOT));
356         ctype = WebThemeControlDRT::UpArrowType;
357         cstate = WebThemeControlDRT::HotState;
358         break;
359
360     case ABS_DOWNHOT:
361         ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_HOT));
362         ctype = WebThemeControlDRT::DownArrowType;
363         cstate = WebThemeControlDRT::HotState;
364         break;
365
366     case ABS_LEFTHOT:
367         ASSERT(classicState == (DFCS_SCROLLLEFT | DFCS_HOT));
368         ctype = WebThemeControlDRT::LeftArrowType;
369         cstate = WebThemeControlDRT::HotState;
370         break;
371
372     case ABS_RIGHTHOT:
373         ASSERT(classicState == (DFCS_SCROLLRIGHT | DFCS_HOT));
374         ctype = WebThemeControlDRT::RightArrowType;
375         cstate = WebThemeControlDRT::HotState;
376         break;
377
378     case ABS_UPHOVER:
379         ASSERT(classicState == DFCS_SCROLLUP);
380         ctype = WebThemeControlDRT::UpArrowType;
381         cstate = WebThemeControlDRT::HoverState;
382         break;
383
384     case ABS_DOWNHOVER:
385         ASSERT(classicState == DFCS_SCROLLDOWN);
386         ctype = WebThemeControlDRT::DownArrowType;
387         cstate = WebThemeControlDRT::HoverState;
388         break;
389
390     case ABS_LEFTHOVER:
391         ASSERT(classicState == DFCS_SCROLLLEFT);
392         ctype = WebThemeControlDRT::LeftArrowType;
393         cstate = WebThemeControlDRT::HoverState;
394         break;
395
396     case ABS_RIGHTHOVER:
397         ASSERT(classicState == DFCS_SCROLLRIGHT);
398         ctype = WebThemeControlDRT::RightArrowType;
399         cstate = WebThemeControlDRT::HoverState;
400         break;
401
402     case ABS_UPPRESSED:
403         ASSERT(classicState == (DFCS_SCROLLUP | DFCS_PUSHED | DFCS_FLAT));
404         ctype = WebThemeControlDRT::UpArrowType;
405         cstate = WebThemeControlDRT::PressedState;
406         break;
407
408     case ABS_DOWNPRESSED:
409         ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_PUSHED | DFCS_FLAT));
410         ctype = WebThemeControlDRT::DownArrowType;
411         cstate = WebThemeControlDRT::PressedState;
412         break;
413
414     case ABS_LEFTPRESSED:
415         ASSERT(classicState == (DFCS_SCROLLLEFT | DFCS_PUSHED | DFCS_FLAT));
416         ctype = WebThemeControlDRT::LeftArrowType;
417         cstate = WebThemeControlDRT::PressedState;
418         break;
419
420     case ABS_RIGHTPRESSED:
421         ASSERT(classicState == (DFCS_SCROLLRIGHT | DFCS_PUSHED | DFCS_FLAT));
422         ctype = WebThemeControlDRT::RightArrowType;
423         cstate = WebThemeControlDRT::PressedState;
424         break;
425
426     case ABS_UPDISABLED:
427         ASSERT(classicState == (DFCS_SCROLLUP | DFCS_INACTIVE));
428         ctype = WebThemeControlDRT::UpArrowType;
429         cstate = WebThemeControlDRT::DisabledState;
430         break;
431
432     case ABS_DOWNDISABLED:
433         ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_INACTIVE));
434         ctype = WebThemeControlDRT::DownArrowType;
435         cstate = WebThemeControlDRT::DisabledState;
436         break;
437
438     case ABS_LEFTDISABLED:
439         ASSERT(classicState == (DFCS_SCROLLLEFT | DFCS_INACTIVE));
440         ctype = WebThemeControlDRT::LeftArrowType;
441         cstate = WebThemeControlDRT::DisabledState;
442         break;
443
444     case ABS_RIGHTDISABLED:
445         ASSERT(classicState == (DFCS_SCROLLRIGHT | DFCS_INACTIVE));
446         ctype = WebThemeControlDRT::RightArrowType;
447         cstate = WebThemeControlDRT::DisabledState;
448         break;
449
450     default:
451         ASSERT_NOT_REACHED();
452         break;
453     }
454
455     drawControl(canvas, rect, ctype, cstate);
456 }
457
458 void WebThemeEngineDRT::paintScrollbarThumb(WebCanvas* canvas,
459                                             int part,
460                                             int state,
461                                             int classicState,
462                                             const WebRect& rect)
463 {
464     WebThemeControlDRT::Type ctype = WebThemeControlDRT::UnknownType;
465     WebThemeControlDRT::State cstate = WebThemeControlDRT::UnknownState;
466
467     switch (part) {
468     case SBP_THUMBBTNHORZ:
469         ctype = WebThemeControlDRT::HorizontalScrollThumbType;
470         break;
471
472     case SBP_THUMBBTNVERT:
473         ctype = WebThemeControlDRT::VerticalScrollThumbType;
474         break;
475
476     case SBP_GRIPPERHORZ:
477         ctype = WebThemeControlDRT::HorizontalScrollGripType;
478         break;
479
480     case SBP_GRIPPERVERT:
481         ctype = WebThemeControlDRT::VerticalScrollGripType;
482         break;
483
484     default:
485         ASSERT_NOT_REACHED();
486         break;
487     }
488
489     switch (state) {
490     case SCRBS_NORMAL:
491         ASSERT(classicState == dfcsNormal);
492         cstate = WebThemeControlDRT::NormalState;
493         break;
494
495     case SCRBS_HOT:
496         ASSERT(classicState == DFCS_HOT);
497         cstate = WebThemeControlDRT::HotState;
498         break;
499
500     case SCRBS_HOVER:
501         ASSERT(classicState == dfcsNormal);
502         cstate = WebThemeControlDRT::HoverState;
503         break;
504
505     case SCRBS_PRESSED:
506         ASSERT(classicState == dfcsNormal);
507         cstate = WebThemeControlDRT::PressedState;
508         break;
509
510     case SCRBS_DISABLED:
511         ASSERT_NOT_REACHED(); // This should never happen in practice.
512         break;
513
514     default:
515         ASSERT_NOT_REACHED();
516         break;
517     }
518
519     drawControl(canvas, rect, ctype, cstate);
520 }
521
522 void WebThemeEngineDRT::paintScrollbarTrack(WebCanvas* canvas,
523                                             int part,
524                                             int state,
525                                             int classicState,
526                                             const WebRect& rect,
527                                             const WebRect& alignRect)
528 {
529     WebThemeControlDRT::Type ctype = WebThemeControlDRT::UnknownType;
530     WebThemeControlDRT::State cstate = WebThemeControlDRT::UnknownState;
531
532     switch (part) {
533     case SBP_UPPERTRACKHORZ:
534         ctype = WebThemeControlDRT::HorizontalScrollTrackBackType;
535         break;
536
537     case SBP_LOWERTRACKHORZ:
538         ctype = WebThemeControlDRT::HorizontalScrollTrackForwardType;
539         break;
540
541     case SBP_UPPERTRACKVERT:
542         ctype = WebThemeControlDRT::VerticalScrollTrackBackType;
543         break;
544
545     case SBP_LOWERTRACKVERT:
546         ctype = WebThemeControlDRT::VerticalScrollTrackForwardType;
547         break;
548
549     default:
550         ASSERT_NOT_REACHED();
551         break;
552     }
553
554     switch (state) {
555     case SCRBS_NORMAL:
556         ASSERT(classicState == dfcsNormal);
557         cstate = WebThemeControlDRT::NormalState;
558         break;
559
560     case SCRBS_HOT:
561         ASSERT_NOT_REACHED(); // This should never happen in practice.
562         break;
563
564     case SCRBS_HOVER:
565         ASSERT(classicState == dfcsNormal);
566         cstate = WebThemeControlDRT::HoverState;
567         break;
568
569     case SCRBS_PRESSED:
570         ASSERT_NOT_REACHED(); // This should never happen in practice.
571         break;
572
573     case SCRBS_DISABLED:
574         ASSERT(classicState == DFCS_INACTIVE);
575         cstate = WebThemeControlDRT::DisabledState;
576         break;
577
578     default:
579         CRASH();
580         break;
581     }
582
583     drawControl(canvas, rect, ctype, cstate);
584 }
585
586 void WebThemeEngineDRT::paintSpinButton(WebCanvas* canvas,
587                                         int part,
588                                         int state,
589                                         int classicState,
590                                         const WebRect& rect)
591 {
592     WebThemeControlDRT::Type ctype = WebThemeControlDRT::UnknownType;
593     WebThemeControlDRT::State cstate = WebThemeControlDRT::UnknownState;
594
595     if (part == SPNP_UP) {
596         ctype = WebThemeControlDRT::UpArrowType;
597         switch (state) {
598         case UPS_NORMAL:
599             ASSERT(classicState == DFCS_SCROLLUP);
600             cstate = WebThemeControlDRT::NormalState;
601             break;
602         case UPS_DISABLED:
603             ASSERT(classicState == (DFCS_SCROLLUP | DFCS_INACTIVE));
604             cstate = WebThemeControlDRT::DisabledState;
605             break;
606         case UPS_PRESSED:
607             ASSERT(classicState == (DFCS_SCROLLUP | DFCS_PUSHED));
608             cstate = WebThemeControlDRT::PressedState;
609             break;
610         case UPS_HOT:
611             ASSERT(classicState == (DFCS_SCROLLUP | DFCS_HOT));
612             cstate = WebThemeControlDRT::HoverState;
613             break;
614         default:
615             ASSERT_NOT_REACHED();
616         }
617     } else if (part == SPNP_DOWN) {
618         ctype = WebThemeControlDRT::DownArrowType;
619         switch (state) {
620         case DNS_NORMAL:
621             ASSERT(classicState == DFCS_SCROLLDOWN);
622             cstate = WebThemeControlDRT::NormalState;
623             break;
624         case DNS_DISABLED:
625             ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_INACTIVE));
626             cstate = WebThemeControlDRT::DisabledState;
627             break;
628         case DNS_PRESSED:
629             ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_PUSHED));
630             cstate = WebThemeControlDRT::PressedState;
631             break;
632         case DNS_HOT:
633             ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_HOT));
634             cstate = WebThemeControlDRT::HoverState;
635             break;
636         default:
637             ASSERT_NOT_REACHED();
638         }
639     } else
640         ASSERT_NOT_REACHED();
641     drawControl(canvas, rect, ctype, cstate);
642 }
643
644 void WebThemeEngineDRT::paintTextField(WebCanvas* canvas,
645                                        int part,
646                                        int state,
647                                        int classicState,
648                                        const WebRect& rect,
649                                        WebColor color,
650                                        bool fillContentArea,
651                                        bool drawEdges)
652 {
653     WebThemeControlDRT::Type ctype = WebThemeControlDRT::UnknownType;
654     WebThemeControlDRT::State cstate = WebThemeControlDRT::UnknownState;
655
656     ASSERT(EP_EDITTEXT == part);
657     ctype = WebThemeControlDRT::TextFieldType;
658
659     switch (state) {
660     case ETS_NORMAL:
661         ASSERT(classicState == dfcsNormal);
662         cstate = WebThemeControlDRT::NormalState;
663         break;
664
665     case ETS_HOT:
666         ASSERT(classicState == DFCS_HOT);
667         cstate = WebThemeControlDRT::HotState;
668         break;
669
670     case ETS_DISABLED:
671         ASSERT(classicState == DFCS_INACTIVE);
672         cstate = WebThemeControlDRT::DisabledState;
673         break;
674
675     case ETS_SELECTED:
676         ASSERT(classicState == DFCS_PUSHED);
677         cstate = WebThemeControlDRT::PressedState;
678         break;
679
680     case ETS_FOCUSED:
681         ASSERT(classicState == dfcsNormal);
682         cstate = WebThemeControlDRT::FocusedState;
683         break;
684
685     case ETS_READONLY:
686         ASSERT(classicState == dfcsNormal);
687         cstate = WebThemeControlDRT::ReadOnlyState;
688         break;
689
690     default:
691         ASSERT_NOT_REACHED();
692         break;
693     }
694
695     drawTextField(canvas, rect, ctype, cstate, drawEdges, fillContentArea, color);
696 }
697
698 void WebThemeEngineDRT::paintTrackbar(WebCanvas* canvas,
699                                       int part,
700                                       int state,
701                                       int classicState,
702                                       const WebRect& rect)
703 {
704     WebThemeControlDRT::Type ctype = WebThemeControlDRT::UnknownType;
705     WebThemeControlDRT::State cstate = WebThemeControlDRT::UnknownState;
706
707     if (TKP_THUMBBOTTOM == part) {
708         ctype = WebThemeControlDRT::HorizontalSliderThumbType;
709         switch (state) {
710         case TUS_NORMAL:
711             ASSERT(classicState == dfcsNormal);
712             cstate = WebThemeControlDRT::NormalState;
713             break;
714
715         case TUS_HOT:
716             ASSERT(classicState == DFCS_HOT);
717             cstate = WebThemeControlDRT::HotState;
718             break;
719
720         case TUS_DISABLED:
721             ASSERT(classicState == DFCS_INACTIVE);
722             cstate = WebThemeControlDRT::DisabledState;
723             break;
724
725         case TUS_PRESSED:
726             ASSERT(classicState == DFCS_PUSHED);
727             cstate = WebThemeControlDRT::PressedState;
728             break;
729
730         default:
731             ASSERT_NOT_REACHED();
732             break;
733         }
734     } else if (TKP_TRACK == part) {
735         ctype = WebThemeControlDRT::HorizontalSliderTrackType;
736         ASSERT(part == TUS_NORMAL);
737         ASSERT(classicState == dfcsNormal);
738         cstate = WebThemeControlDRT::NormalState;
739     } else {
740         ASSERT_NOT_REACHED();
741     }
742
743     drawControl(canvas, rect, ctype, cstate);
744 }
745
746
747 void WebThemeEngineDRT::paintProgressBar(WebKit::WebCanvas* canvas,
748                                          const WebKit::WebRect& barRect,
749                                          const WebKit::WebRect& valueRect,
750                                          bool determinate,
751                                          double)
752 {
753     WebThemeControlDRT::Type ctype = WebThemeControlDRT::ProgressBarType;
754     WebThemeControlDRT::State cstate = determinate ? WebThemeControlDRT::NormalState 
755                                                    : WebThemeControlDRT::IndeterminateState;
756     drawProgressBar(canvas, ctype, cstate, barRect, valueRect);
757 }
758