Home | History | Annotate | Download | only in chromium
      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 "WebThemeEngineDRTWin.h"
     33 
     34 #include "WebRect.h"
     35 #include "WebThemeControlDRTWin.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                         WebThemeControlDRTWin::Type ctype,
     61                         WebThemeControlDRTWin::State cstate)
     62 {
     63     WebThemeControlDRTWin control(canvas, webRectToSkIRect(rect), ctype, cstate);
     64     control.draw();
     65 }
     66 
     67 static void drawTextField(WebCanvas* canvas,
     68                           const WebRect& rect,
     69                           WebThemeControlDRTWin::Type ctype,
     70                           WebThemeControlDRTWin::State cstate,
     71                           bool drawEdges,
     72                           bool fillContentArea,
     73                           WebColor color)
     74 {
     75     WebThemeControlDRTWin control(canvas, webRectToSkIRect(rect), ctype, cstate);
     76     control.drawTextField(drawEdges, fillContentArea, color);
     77 }
     78 
     79 static void drawProgressBar(WebCanvas* canvas,
     80                             WebThemeControlDRTWin::Type ctype,
     81                             WebThemeControlDRTWin::State cstate,
     82                             const WebRect& barRect,
     83                             const WebRect& fillRect)
     84 {
     85     WebThemeControlDRTWin control(canvas, webRectToSkIRect(barRect), ctype, cstate);
     86     control.drawProgressBar(webRectToSkIRect(fillRect));
     87 }
     88 
     89 // WebThemeEngineDRTWin
     90 
     91 void WebThemeEngineDRTWin::paintButton(WebCanvas* canvas,
     92                                        int part,
     93                                        int state,
     94                                        int classicState,
     95                                        const WebRect& rect)
     96 {
     97     WebThemeControlDRTWin::Type ctype = WebThemeControlDRTWin::UnknownType;
     98     WebThemeControlDRTWin::State cstate = WebThemeControlDRTWin::UnknownState;
     99 
    100     if (part == BP_CHECKBOX) {
    101         switch (state) {
    102         case CBS_UNCHECKEDNORMAL:
    103             ASSERT(classicState == dfcsNormal);
    104             ctype = WebThemeControlDRTWin::UncheckedBoxType;
    105             cstate = WebThemeControlDRTWin::NormalState;
    106             break;
    107 
    108         case CBS_UNCHECKEDHOT:
    109             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_HOT));
    110             ctype = WebThemeControlDRTWin::UncheckedBoxType;
    111             cstate = WebThemeControlDRTWin::HotState;
    112             break;
    113 
    114         case CBS_UNCHECKEDPRESSED:
    115             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_PUSHED));
    116             ctype = WebThemeControlDRTWin::UncheckedBoxType;
    117             cstate = WebThemeControlDRTWin::PressedState;
    118             break;
    119 
    120         case CBS_UNCHECKEDDISABLED:
    121             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_INACTIVE));
    122             ctype = WebThemeControlDRTWin::UncheckedBoxType;
    123             cstate = WebThemeControlDRTWin::DisabledState;
    124             break;
    125 
    126         case CBS_CHECKEDNORMAL:
    127             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_CHECKED));
    128             ctype = WebThemeControlDRTWin::CheckedBoxType;
    129             cstate = WebThemeControlDRTWin::NormalState;
    130             break;
    131 
    132         case CBS_CHECKEDHOT:
    133             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_HOT));
    134             ctype = WebThemeControlDRTWin::CheckedBoxType;
    135             cstate = WebThemeControlDRTWin::HotState;
    136             break;
    137 
    138         case CBS_CHECKEDPRESSED:
    139             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_PUSHED));
    140             ctype = WebThemeControlDRTWin::CheckedBoxType;
    141             cstate = WebThemeControlDRTWin::PressedState;
    142             break;
    143 
    144         case CBS_CHECKEDDISABLED:
    145             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE));
    146             ctype = WebThemeControlDRTWin::CheckedBoxType;
    147             cstate = WebThemeControlDRTWin::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 = WebThemeControlDRTWin::IndeterminateCheckboxType;
    155             cstate = WebThemeControlDRTWin::NormalState;
    156             break;
    157 
    158         case CBS_MIXEDHOT:
    159             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_HOT));
    160             ctype = WebThemeControlDRTWin::IndeterminateCheckboxType;
    161             cstate = WebThemeControlDRTWin::HotState;
    162             break;
    163 
    164         case CBS_MIXEDPRESSED:
    165             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_PUSHED));
    166             ctype = WebThemeControlDRTWin::IndeterminateCheckboxType;
    167             cstate = WebThemeControlDRTWin::PressedState;
    168             break;
    169 
    170         case CBS_MIXEDDISABLED:
    171             ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_INACTIVE));
    172             ctype = WebThemeControlDRTWin::IndeterminateCheckboxType;
    173             cstate = WebThemeControlDRTWin::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 = WebThemeControlDRTWin::UncheckedRadioType;
    185             cstate = WebThemeControlDRTWin::NormalState;
    186             break;
    187 
    188         case RBS_UNCHECKEDHOT:
    189             ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_HOT));
    190             ctype = WebThemeControlDRTWin::UncheckedRadioType;
    191             cstate = WebThemeControlDRTWin::HotState;
    192             break;
    193 
    194         case RBS_UNCHECKEDPRESSED:
    195             ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_PUSHED));
    196             ctype = WebThemeControlDRTWin::UncheckedRadioType;
    197             cstate = WebThemeControlDRTWin::PressedState;
    198             break;
    199 
    200         case RBS_UNCHECKEDDISABLED:
    201             ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_INACTIVE));
    202             ctype = WebThemeControlDRTWin::UncheckedRadioType;
    203             cstate = WebThemeControlDRTWin::DisabledState;
    204             break;
    205 
    206         case RBS_CHECKEDNORMAL:
    207             ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_CHECKED));
    208             ctype = WebThemeControlDRTWin::CheckedRadioType;
    209             cstate = WebThemeControlDRTWin::NormalState;
    210             break;
    211 
    212         case RBS_CHECKEDHOT:
    213             ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_HOT));
    214             ctype = WebThemeControlDRTWin::CheckedRadioType;
    215             cstate = WebThemeControlDRTWin::HotState;
    216             break;
    217 
    218         case RBS_CHECKEDPRESSED:
    219             ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_PUSHED));
    220             ctype = WebThemeControlDRTWin::CheckedRadioType;
    221             cstate = WebThemeControlDRTWin::PressedState;
    222             break;
    223 
    224         case RBS_CHECKEDDISABLED:
    225             ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_INACTIVE));
    226             ctype = WebThemeControlDRTWin::CheckedRadioType;
    227             cstate = WebThemeControlDRTWin::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 = WebThemeControlDRTWin::PushButtonType;
    239             cstate = WebThemeControlDRTWin::NormalState;
    240             break;
    241 
    242         case PBS_HOT:
    243             ASSERT(classicState == (DFCS_BUTTONPUSH | DFCS_HOT));
    244             ctype = WebThemeControlDRTWin::PushButtonType;
    245             cstate = WebThemeControlDRTWin::HotState;
    246             break;
    247 
    248         case PBS_PRESSED:
    249             ASSERT(classicState == (DFCS_BUTTONPUSH | DFCS_PUSHED));
    250             ctype = WebThemeControlDRTWin::PushButtonType;
    251             cstate = WebThemeControlDRTWin::PressedState;
    252             break;
    253 
    254         case PBS_DISABLED:
    255             ASSERT(classicState == (DFCS_BUTTONPUSH | DFCS_INACTIVE));
    256             ctype = WebThemeControlDRTWin::PushButtonType;
    257             cstate = WebThemeControlDRTWin::DisabledState;
    258             break;
    259 
    260         case PBS_DEFAULTED:
    261             ASSERT(classicState == DFCS_BUTTONPUSH);
    262             ctype = WebThemeControlDRTWin::PushButtonType;
    263             cstate = WebThemeControlDRTWin::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 WebThemeEngineDRTWin::paintMenuList(WebCanvas* canvas,
    279                                          int part,
    280                                          int state,
    281                                          int classicState,
    282                                          const WebRect& rect)
    283 {
    284     WebThemeControlDRTWin::Type ctype = WebThemeControlDRTWin::UnknownType;
    285     WebThemeControlDRTWin::State cstate = WebThemeControlDRTWin::UnknownState;
    286 
    287     if (CP_DROPDOWNBUTTON == part) {
    288         ctype = WebThemeControlDRTWin::DropDownButtonType;
    289         switch (state) {
    290         case CBXS_NORMAL:
    291             ASSERT(classicState == DFCS_MENUARROW);
    292             cstate = WebThemeControlDRTWin::NormalState;
    293             break;
    294 
    295         case CBXS_HOT:
    296             ASSERT(classicState == (DFCS_MENUARROW | DFCS_HOT));
    297             cstate = WebThemeControlDRTWin::HoverState;
    298             break;
    299 
    300         case CBXS_PRESSED:
    301             ASSERT(classicState == (DFCS_MENUARROW | DFCS_PUSHED));
    302             cstate = WebThemeControlDRTWin::PressedState;
    303             break;
    304 
    305         case CBXS_DISABLED:
    306             ASSERT(classicState == (DFCS_MENUARROW | DFCS_INACTIVE));
    307             cstate = WebThemeControlDRTWin::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 WebThemeEngineDRTWin::paintScrollbarArrow(WebCanvas* canvas,
    322                                                int state,
    323                                                int classicState,
    324                                                const WebRect& rect)
    325 {
    326     WebThemeControlDRTWin::Type ctype = WebThemeControlDRTWin::UnknownType;
    327     WebThemeControlDRTWin::State cstate = WebThemeControlDRTWin::UnknownState;
    328 
    329     switch (state) {
    330     case ABS_UPNORMAL:
    331         ASSERT(classicState == DFCS_SCROLLUP);
    332         ctype = WebThemeControlDRTWin::UpArrowType;
    333         cstate = WebThemeControlDRTWin::NormalState;
    334         break;
    335 
    336     case ABS_DOWNNORMAL:
    337         ASSERT(classicState == DFCS_SCROLLDOWN);
    338         ctype = WebThemeControlDRTWin::DownArrowType;
    339         cstate = WebThemeControlDRTWin::NormalState;
    340         break;
    341 
    342     case ABS_LEFTNORMAL:
    343         ASSERT(classicState == DFCS_SCROLLLEFT);
    344         ctype = WebThemeControlDRTWin::LeftArrowType;
    345         cstate = WebThemeControlDRTWin::NormalState;
    346         break;
    347 
    348     case ABS_RIGHTNORMAL:
    349         ASSERT(classicState == DFCS_SCROLLRIGHT);
    350         ctype = WebThemeControlDRTWin::RightArrowType;
    351         cstate = WebThemeControlDRTWin::NormalState;
    352         break;
    353 
    354     case ABS_UPHOT:
    355         ASSERT(classicState == (DFCS_SCROLLUP | DFCS_HOT));
    356         ctype = WebThemeControlDRTWin::UpArrowType;
    357         cstate = WebThemeControlDRTWin::HotState;
    358         break;
    359 
    360     case ABS_DOWNHOT:
    361         ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_HOT));
    362         ctype = WebThemeControlDRTWin::DownArrowType;
    363         cstate = WebThemeControlDRTWin::HotState;
    364         break;
    365 
    366     case ABS_LEFTHOT:
    367         ASSERT(classicState == (DFCS_SCROLLLEFT | DFCS_HOT));
    368         ctype = WebThemeControlDRTWin::LeftArrowType;
    369         cstate = WebThemeControlDRTWin::HotState;
    370         break;
    371 
    372     case ABS_RIGHTHOT:
    373         ASSERT(classicState == (DFCS_SCROLLRIGHT | DFCS_HOT));
    374         ctype = WebThemeControlDRTWin::RightArrowType;
    375         cstate = WebThemeControlDRTWin::HotState;
    376         break;
    377 
    378     case ABS_UPHOVER:
    379         ASSERT(classicState == DFCS_SCROLLUP);
    380         ctype = WebThemeControlDRTWin::UpArrowType;
    381         cstate = WebThemeControlDRTWin::HoverState;
    382         break;
    383 
    384     case ABS_DOWNHOVER:
    385         ASSERT(classicState == DFCS_SCROLLDOWN);
    386         ctype = WebThemeControlDRTWin::DownArrowType;
    387         cstate = WebThemeControlDRTWin::HoverState;
    388         break;
    389 
    390     case ABS_LEFTHOVER:
    391         ASSERT(classicState == DFCS_SCROLLLEFT);
    392         ctype = WebThemeControlDRTWin::LeftArrowType;
    393         cstate = WebThemeControlDRTWin::HoverState;
    394         break;
    395 
    396     case ABS_RIGHTHOVER:
    397         ASSERT(classicState == DFCS_SCROLLRIGHT);
    398         ctype = WebThemeControlDRTWin::RightArrowType;
    399         cstate = WebThemeControlDRTWin::HoverState;
    400         break;
    401 
    402     case ABS_UPPRESSED:
    403         ASSERT(classicState == (DFCS_SCROLLUP | DFCS_PUSHED | DFCS_FLAT));
    404         ctype = WebThemeControlDRTWin::UpArrowType;
    405         cstate = WebThemeControlDRTWin::PressedState;
    406         break;
    407 
    408     case ABS_DOWNPRESSED:
    409         ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_PUSHED | DFCS_FLAT));
    410         ctype = WebThemeControlDRTWin::DownArrowType;
    411         cstate = WebThemeControlDRTWin::PressedState;
    412         break;
    413 
    414     case ABS_LEFTPRESSED:
    415         ASSERT(classicState == (DFCS_SCROLLLEFT | DFCS_PUSHED | DFCS_FLAT));
    416         ctype = WebThemeControlDRTWin::LeftArrowType;
    417         cstate = WebThemeControlDRTWin::PressedState;
    418         break;
    419 
    420     case ABS_RIGHTPRESSED:
    421         ASSERT(classicState == (DFCS_SCROLLRIGHT | DFCS_PUSHED | DFCS_FLAT));
    422         ctype = WebThemeControlDRTWin::RightArrowType;
    423         cstate = WebThemeControlDRTWin::PressedState;
    424         break;
    425 
    426     case ABS_UPDISABLED:
    427         ASSERT(classicState == (DFCS_SCROLLUP | DFCS_INACTIVE));
    428         ctype = WebThemeControlDRTWin::UpArrowType;
    429         cstate = WebThemeControlDRTWin::DisabledState;
    430         break;
    431 
    432     case ABS_DOWNDISABLED:
    433         ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_INACTIVE));
    434         ctype = WebThemeControlDRTWin::DownArrowType;
    435         cstate = WebThemeControlDRTWin::DisabledState;
    436         break;
    437 
    438     case ABS_LEFTDISABLED:
    439         ASSERT(classicState == (DFCS_SCROLLLEFT | DFCS_INACTIVE));
    440         ctype = WebThemeControlDRTWin::LeftArrowType;
    441         cstate = WebThemeControlDRTWin::DisabledState;
    442         break;
    443 
    444     case ABS_RIGHTDISABLED:
    445         ASSERT(classicState == (DFCS_SCROLLRIGHT | DFCS_INACTIVE));
    446         ctype = WebThemeControlDRTWin::RightArrowType;
    447         cstate = WebThemeControlDRTWin::DisabledState;
    448         break;
    449 
    450     default:
    451         ASSERT_NOT_REACHED();
    452         break;
    453     }
    454 
    455     drawControl(canvas, rect, ctype, cstate);
    456 }
    457 
    458 void WebThemeEngineDRTWin::paintScrollbarThumb(WebCanvas* canvas,
    459                                                int part,
    460                                                int state,
    461                                                int classicState,
    462                                                const WebRect& rect)
    463 {
    464     WebThemeControlDRTWin::Type ctype = WebThemeControlDRTWin::UnknownType;
    465     WebThemeControlDRTWin::State cstate = WebThemeControlDRTWin::UnknownState;
    466 
    467     switch (part) {
    468     case SBP_THUMBBTNHORZ:
    469         ctype = WebThemeControlDRTWin::HorizontalScrollThumbType;
    470         break;
    471 
    472     case SBP_THUMBBTNVERT:
    473         ctype = WebThemeControlDRTWin::VerticalScrollThumbType;
    474         break;
    475 
    476     case SBP_GRIPPERHORZ:
    477         ctype = WebThemeControlDRTWin::HorizontalScrollGripType;
    478         break;
    479 
    480     case SBP_GRIPPERVERT:
    481         ctype = WebThemeControlDRTWin::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 = WebThemeControlDRTWin::NormalState;
    493         break;
    494 
    495     case SCRBS_HOT:
    496         ASSERT(classicState == DFCS_HOT);
    497         cstate = WebThemeControlDRTWin::HotState;
    498         break;
    499 
    500     case SCRBS_HOVER:
    501         ASSERT(classicState == dfcsNormal);
    502         cstate = WebThemeControlDRTWin::HoverState;
    503         break;
    504 
    505     case SCRBS_PRESSED:
    506         ASSERT(classicState == dfcsNormal);
    507         cstate = WebThemeControlDRTWin::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 WebThemeEngineDRTWin::paintScrollbarTrack(WebCanvas* canvas,
    523                                                int part,
    524                                                int state,
    525                                                int classicState,
    526                                                const WebRect& rect,
    527                                                const WebRect& alignRect)
    528 {
    529     WebThemeControlDRTWin::Type ctype = WebThemeControlDRTWin::UnknownType;
    530     WebThemeControlDRTWin::State cstate = WebThemeControlDRTWin::UnknownState;
    531 
    532     switch (part) {
    533     case SBP_UPPERTRACKHORZ:
    534         ctype = WebThemeControlDRTWin::HorizontalScrollTrackBackType;
    535         break;
    536 
    537     case SBP_LOWERTRACKHORZ:
    538         ctype = WebThemeControlDRTWin::HorizontalScrollTrackForwardType;
    539         break;
    540 
    541     case SBP_UPPERTRACKVERT:
    542         ctype = WebThemeControlDRTWin::VerticalScrollTrackBackType;
    543         break;
    544 
    545     case SBP_LOWERTRACKVERT:
    546         ctype = WebThemeControlDRTWin::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 = WebThemeControlDRTWin::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 = WebThemeControlDRTWin::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 = WebThemeControlDRTWin::DisabledState;
    576         break;
    577 
    578     default:
    579         CRASH();
    580         break;
    581     }
    582 
    583     drawControl(canvas, rect, ctype, cstate);
    584 }
    585 
    586 void WebThemeEngineDRTWin::paintSpinButton(WebCanvas* canvas,
    587                                            int part,
    588                                            int state,
    589                                            int classicState,
    590                                            const WebRect& rect)
    591 {
    592     WebThemeControlDRTWin::Type ctype = WebThemeControlDRTWin::UnknownType;
    593     WebThemeControlDRTWin::State cstate = WebThemeControlDRTWin::UnknownState;
    594 
    595     if (part == SPNP_UP) {
    596         ctype = WebThemeControlDRTWin::UpArrowType;
    597         switch (state) {
    598         case UPS_NORMAL:
    599             ASSERT(classicState == DFCS_SCROLLUP);
    600             cstate = WebThemeControlDRTWin::NormalState;
    601             break;
    602         case UPS_DISABLED:
    603             ASSERT(classicState == (DFCS_SCROLLUP | DFCS_INACTIVE));
    604             cstate = WebThemeControlDRTWin::DisabledState;
    605             break;
    606         case UPS_PRESSED:
    607             ASSERT(classicState == (DFCS_SCROLLUP | DFCS_PUSHED));
    608             cstate = WebThemeControlDRTWin::PressedState;
    609             break;
    610         case UPS_HOT:
    611             ASSERT(classicState == (DFCS_SCROLLUP | DFCS_HOT));
    612             cstate = WebThemeControlDRTWin::HoverState;
    613             break;
    614         default:
    615             ASSERT_NOT_REACHED();
    616         }
    617     } else if (part == SPNP_DOWN) {
    618         ctype = WebThemeControlDRTWin::DownArrowType;
    619         switch (state) {
    620         case DNS_NORMAL:
    621             ASSERT(classicState == DFCS_SCROLLDOWN);
    622             cstate = WebThemeControlDRTWin::NormalState;
    623             break;
    624         case DNS_DISABLED:
    625             ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_INACTIVE));
    626             cstate = WebThemeControlDRTWin::DisabledState;
    627             break;
    628         case DNS_PRESSED:
    629             ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_PUSHED));
    630             cstate = WebThemeControlDRTWin::PressedState;
    631             break;
    632         case DNS_HOT:
    633             ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_HOT));
    634             cstate = WebThemeControlDRTWin::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 WebThemeEngineDRTWin::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     WebThemeControlDRTWin::Type ctype = WebThemeControlDRTWin::UnknownType;
    654     WebThemeControlDRTWin::State cstate = WebThemeControlDRTWin::UnknownState;
    655 
    656     ASSERT(EP_EDITTEXT == part);
    657     ctype = WebThemeControlDRTWin::TextFieldType;
    658 
    659     switch (state) {
    660     case ETS_NORMAL:
    661         ASSERT(classicState == dfcsNormal);
    662         cstate = WebThemeControlDRTWin::NormalState;
    663         break;
    664 
    665     case ETS_HOT:
    666         ASSERT(classicState == DFCS_HOT);
    667         cstate = WebThemeControlDRTWin::HotState;
    668         break;
    669 
    670     case ETS_DISABLED:
    671         ASSERT(classicState == DFCS_INACTIVE);
    672         cstate = WebThemeControlDRTWin::DisabledState;
    673         break;
    674 
    675     case ETS_SELECTED:
    676         ASSERT(classicState == DFCS_PUSHED);
    677         cstate = WebThemeControlDRTWin::PressedState;
    678         break;
    679 
    680     case ETS_FOCUSED:
    681         ASSERT(classicState == dfcsNormal);
    682         cstate = WebThemeControlDRTWin::FocusedState;
    683         break;
    684 
    685     case ETS_READONLY:
    686         ASSERT(classicState == dfcsNormal);
    687         cstate = WebThemeControlDRTWin::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 WebThemeEngineDRTWin::paintTrackbar(WebCanvas* canvas,
    699                                          int part,
    700                                          int state,
    701                                          int classicState,
    702                                          const WebRect& rect)
    703 {
    704     WebThemeControlDRTWin::Type ctype = WebThemeControlDRTWin::UnknownType;
    705     WebThemeControlDRTWin::State cstate = WebThemeControlDRTWin::UnknownState;
    706 
    707     if (TKP_THUMBBOTTOM == part) {
    708         ctype = WebThemeControlDRTWin::HorizontalSliderThumbType;
    709         switch (state) {
    710         case TUS_NORMAL:
    711             ASSERT(classicState == dfcsNormal);
    712             cstate = WebThemeControlDRTWin::NormalState;
    713             break;
    714 
    715         case TUS_HOT:
    716             ASSERT(classicState == DFCS_HOT);
    717             cstate = WebThemeControlDRTWin::HotState;
    718             break;
    719 
    720         case TUS_DISABLED:
    721             ASSERT(classicState == DFCS_INACTIVE);
    722             cstate = WebThemeControlDRTWin::DisabledState;
    723             break;
    724 
    725         case TUS_PRESSED:
    726             ASSERT(classicState == DFCS_PUSHED);
    727             cstate = WebThemeControlDRTWin::PressedState;
    728             break;
    729 
    730         default:
    731             ASSERT_NOT_REACHED();
    732             break;
    733         }
    734     } else if (TKP_TRACK == part) {
    735         ctype = WebThemeControlDRTWin::HorizontalSliderTrackType;
    736         ASSERT(part == TUS_NORMAL);
    737         ASSERT(classicState == dfcsNormal);
    738         cstate = WebThemeControlDRTWin::NormalState;
    739     } else {
    740         ASSERT_NOT_REACHED();
    741     }
    742 
    743     drawControl(canvas, rect, ctype, cstate);
    744 }
    745 
    746 
    747 void WebThemeEngineDRTWin::paintProgressBar(WebKit::WebCanvas* canvas,
    748                                             const WebKit::WebRect& barRect,
    749                                             const WebKit::WebRect& valueRect,
    750                                             bool determinate,
    751                                             double)
    752 {
    753     WebThemeControlDRTWin::Type ctype = WebThemeControlDRTWin::ProgressBarType;
    754     WebThemeControlDRTWin::State cstate = determinate ? WebThemeControlDRTWin::NormalState
    755                                                       : WebThemeControlDRTWin::IndeterminateState;
    756     drawProgressBar(canvas, ctype, cstate, barRect, valueRect);
    757 }
    758 
    759