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 "WebTestThemeEngineWin.h" 32 33 #include "TestCommon.h" 34 #include "WebTestThemeControlWin.h" 35 #include "third_party/skia/include/core/SkRect.h" 36 #include "public/platform/WebRect.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 using namespace blink; 45 46 namespace WebTestRunner { 47 48 namespace { 49 50 // We define this for clarity, although there really should be a DFCS_NORMAL in winuser.h. 51 const int dfcsNormal = 0x0000; 52 53 SkIRect webRectToSkIRect(const WebRect& webRect) 54 { 55 SkIRect irect; 56 irect.set(webRect.x, webRect.y, webRect.x + webRect.width - 1, webRect.y + webRect.height - 1); 57 return irect; 58 } 59 60 void drawControl(WebCanvas* canvas, const WebRect& rect, WebTestThemeControlWin::Type ctype, WebTestThemeControlWin::State cstate) 61 { 62 WebTestThemeControlWin control(canvas, webRectToSkIRect(rect), ctype, cstate); 63 control.draw(); 64 } 65 66 void drawTextField(WebCanvas* canvas, const WebRect& rect, WebTestThemeControlWin::Type ctype, WebTestThemeControlWin::State cstate, bool drawEdges, bool fillContentArea, WebColor color) 67 { 68 WebTestThemeControlWin control(canvas, webRectToSkIRect(rect), ctype, cstate); 69 control.drawTextField(drawEdges, fillContentArea, color); 70 } 71 72 void drawProgressBar(WebCanvas* canvas, WebTestThemeControlWin::Type ctype, WebTestThemeControlWin::State cstate, const WebRect& barRect, const WebRect& fillRect) 73 { 74 WebTestThemeControlWin control(canvas, webRectToSkIRect(barRect), ctype, cstate); 75 control.drawProgressBar(webRectToSkIRect(fillRect)); 76 } 77 78 } 79 80 void WebTestThemeEngineWin::paintButton(WebCanvas* canvas, int part, int state, int classicState, const WebRect& rect) 81 { 82 WebTestThemeControlWin::Type ctype = WebTestThemeControlWin::UnknownType; 83 WebTestThemeControlWin::State cstate = WebTestThemeControlWin::UnknownState; 84 85 if (part == BP_CHECKBOX) { 86 switch (state) { 87 case CBS_UNCHECKEDNORMAL: 88 BLINK_ASSERT(classicState == dfcsNormal); 89 ctype = WebTestThemeControlWin::UncheckedBoxType; 90 cstate = WebTestThemeControlWin::NormalState; 91 break; 92 93 case CBS_UNCHECKEDHOT: 94 BLINK_ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_HOT)); 95 ctype = WebTestThemeControlWin::UncheckedBoxType; 96 cstate = WebTestThemeControlWin::HotState; 97 break; 98 99 case CBS_UNCHECKEDPRESSED: 100 BLINK_ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_PUSHED)); 101 ctype = WebTestThemeControlWin::UncheckedBoxType; 102 cstate = WebTestThemeControlWin::PressedState; 103 break; 104 105 case CBS_UNCHECKEDDISABLED: 106 BLINK_ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_INACTIVE)); 107 ctype = WebTestThemeControlWin::UncheckedBoxType; 108 cstate = WebTestThemeControlWin::DisabledState; 109 break; 110 111 case CBS_CHECKEDNORMAL: 112 BLINK_ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_CHECKED)); 113 ctype = WebTestThemeControlWin::CheckedBoxType; 114 cstate = WebTestThemeControlWin::NormalState; 115 break; 116 117 case CBS_CHECKEDHOT: 118 BLINK_ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_HOT)); 119 ctype = WebTestThemeControlWin::CheckedBoxType; 120 cstate = WebTestThemeControlWin::HotState; 121 break; 122 123 case CBS_CHECKEDPRESSED: 124 BLINK_ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_PUSHED)); 125 ctype = WebTestThemeControlWin::CheckedBoxType; 126 cstate = WebTestThemeControlWin::PressedState; 127 break; 128 129 case CBS_CHECKEDDISABLED: 130 BLINK_ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE)); 131 ctype = WebTestThemeControlWin::CheckedBoxType; 132 cstate = WebTestThemeControlWin::DisabledState; 133 break; 134 135 case CBS_MIXEDNORMAL: 136 // Classic theme can't represent mixed state checkbox. We assume 137 // it's equivalent to unchecked. 138 BLINK_ASSERT(classicState == DFCS_BUTTONCHECK); 139 ctype = WebTestThemeControlWin::IndeterminateCheckboxType; 140 cstate = WebTestThemeControlWin::NormalState; 141 break; 142 143 case CBS_MIXEDHOT: 144 BLINK_ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_HOT)); 145 ctype = WebTestThemeControlWin::IndeterminateCheckboxType; 146 cstate = WebTestThemeControlWin::HotState; 147 break; 148 149 case CBS_MIXEDPRESSED: 150 BLINK_ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_PUSHED)); 151 ctype = WebTestThemeControlWin::IndeterminateCheckboxType; 152 cstate = WebTestThemeControlWin::PressedState; 153 break; 154 155 case CBS_MIXEDDISABLED: 156 BLINK_ASSERT(classicState == (DFCS_BUTTONCHECK | DFCS_INACTIVE)); 157 ctype = WebTestThemeControlWin::IndeterminateCheckboxType; 158 cstate = WebTestThemeControlWin::DisabledState; 159 break; 160 161 default: 162 BLINK_ASSERT_NOT_REACHED(); 163 break; 164 } 165 } else if (BP_RADIOBUTTON == part) { 166 switch (state) { 167 case RBS_UNCHECKEDNORMAL: 168 BLINK_ASSERT(classicState == DFCS_BUTTONRADIO); 169 ctype = WebTestThemeControlWin::UncheckedRadioType; 170 cstate = WebTestThemeControlWin::NormalState; 171 break; 172 173 case RBS_UNCHECKEDHOT: 174 BLINK_ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_HOT)); 175 ctype = WebTestThemeControlWin::UncheckedRadioType; 176 cstate = WebTestThemeControlWin::HotState; 177 break; 178 179 case RBS_UNCHECKEDPRESSED: 180 BLINK_ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_PUSHED)); 181 ctype = WebTestThemeControlWin::UncheckedRadioType; 182 cstate = WebTestThemeControlWin::PressedState; 183 break; 184 185 case RBS_UNCHECKEDDISABLED: 186 BLINK_ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_INACTIVE)); 187 ctype = WebTestThemeControlWin::UncheckedRadioType; 188 cstate = WebTestThemeControlWin::DisabledState; 189 break; 190 191 case RBS_CHECKEDNORMAL: 192 BLINK_ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_CHECKED)); 193 ctype = WebTestThemeControlWin::CheckedRadioType; 194 cstate = WebTestThemeControlWin::NormalState; 195 break; 196 197 case RBS_CHECKEDHOT: 198 BLINK_ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_HOT)); 199 ctype = WebTestThemeControlWin::CheckedRadioType; 200 cstate = WebTestThemeControlWin::HotState; 201 break; 202 203 case RBS_CHECKEDPRESSED: 204 BLINK_ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_PUSHED)); 205 ctype = WebTestThemeControlWin::CheckedRadioType; 206 cstate = WebTestThemeControlWin::PressedState; 207 break; 208 209 case RBS_CHECKEDDISABLED: 210 BLINK_ASSERT(classicState == (DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_INACTIVE)); 211 ctype = WebTestThemeControlWin::CheckedRadioType; 212 cstate = WebTestThemeControlWin::DisabledState; 213 break; 214 215 default: 216 BLINK_ASSERT_NOT_REACHED(); 217 break; 218 } 219 } else if (BP_PUSHBUTTON == part) { 220 switch (state) { 221 case PBS_NORMAL: 222 BLINK_ASSERT(classicState == DFCS_BUTTONPUSH); 223 ctype = WebTestThemeControlWin::PushButtonType; 224 cstate = WebTestThemeControlWin::NormalState; 225 break; 226 227 case PBS_HOT: 228 BLINK_ASSERT(classicState == (DFCS_BUTTONPUSH | DFCS_HOT)); 229 ctype = WebTestThemeControlWin::PushButtonType; 230 cstate = WebTestThemeControlWin::HotState; 231 break; 232 233 case PBS_PRESSED: 234 BLINK_ASSERT(classicState == (DFCS_BUTTONPUSH | DFCS_PUSHED)); 235 ctype = WebTestThemeControlWin::PushButtonType; 236 cstate = WebTestThemeControlWin::PressedState; 237 break; 238 239 case PBS_DISABLED: 240 BLINK_ASSERT(classicState == (DFCS_BUTTONPUSH | DFCS_INACTIVE)); 241 ctype = WebTestThemeControlWin::PushButtonType; 242 cstate = WebTestThemeControlWin::DisabledState; 243 break; 244 245 case PBS_DEFAULTED: 246 BLINK_ASSERT(classicState == DFCS_BUTTONPUSH); 247 ctype = WebTestThemeControlWin::PushButtonType; 248 cstate = WebTestThemeControlWin::FocusedState; 249 break; 250 251 default: 252 BLINK_ASSERT_NOT_REACHED(); 253 break; 254 } 255 } else 256 BLINK_ASSERT_NOT_REACHED(); 257 258 drawControl(canvas, rect, ctype, cstate); 259 } 260 261 void WebTestThemeEngineWin::paintMenuList(WebCanvas* canvas, int part, int state, int classicState, const WebRect& rect) 262 { 263 WebTestThemeControlWin::Type ctype = WebTestThemeControlWin::UnknownType; 264 WebTestThemeControlWin::State cstate = WebTestThemeControlWin::UnknownState; 265 266 if (CP_DROPDOWNBUTTON == part) { 267 ctype = WebTestThemeControlWin::DropDownButtonType; 268 switch (state) { 269 case CBXS_NORMAL: 270 BLINK_ASSERT(classicState == DFCS_MENUARROW); 271 cstate = WebTestThemeControlWin::NormalState; 272 break; 273 274 case CBXS_HOT: 275 BLINK_ASSERT(classicState == (DFCS_MENUARROW | DFCS_HOT)); 276 cstate = WebTestThemeControlWin::HoverState; 277 break; 278 279 case CBXS_PRESSED: 280 BLINK_ASSERT(classicState == (DFCS_MENUARROW | DFCS_PUSHED)); 281 cstate = WebTestThemeControlWin::PressedState; 282 break; 283 284 case CBXS_DISABLED: 285 BLINK_ASSERT(classicState == (DFCS_MENUARROW | DFCS_INACTIVE)); 286 cstate = WebTestThemeControlWin::DisabledState; 287 break; 288 289 default: 290 BLINK_ASSERT_NOT_REACHED(); 291 break; 292 } 293 } else 294 BLINK_ASSERT_NOT_REACHED(); 295 296 drawControl(canvas, rect, ctype, cstate); 297 } 298 299 void WebTestThemeEngineWin::paintScrollbarArrow(WebCanvas* canvas, int state, int classicState, const WebRect& rect) 300 { 301 WebTestThemeControlWin::Type ctype = WebTestThemeControlWin::UnknownType; 302 WebTestThemeControlWin::State cstate = WebTestThemeControlWin::UnknownState; 303 304 switch (state) { 305 case ABS_UPNORMAL: 306 BLINK_ASSERT(classicState == DFCS_SCROLLUP); 307 ctype = WebTestThemeControlWin::UpArrowType; 308 cstate = WebTestThemeControlWin::NormalState; 309 break; 310 311 case ABS_DOWNNORMAL: 312 BLINK_ASSERT(classicState == DFCS_SCROLLDOWN); 313 ctype = WebTestThemeControlWin::DownArrowType; 314 cstate = WebTestThemeControlWin::NormalState; 315 break; 316 317 case ABS_LEFTNORMAL: 318 BLINK_ASSERT(classicState == DFCS_SCROLLLEFT); 319 ctype = WebTestThemeControlWin::LeftArrowType; 320 cstate = WebTestThemeControlWin::NormalState; 321 break; 322 323 case ABS_RIGHTNORMAL: 324 BLINK_ASSERT(classicState == DFCS_SCROLLRIGHT); 325 ctype = WebTestThemeControlWin::RightArrowType; 326 cstate = WebTestThemeControlWin::NormalState; 327 break; 328 329 case ABS_UPHOT: 330 BLINK_ASSERT(classicState == (DFCS_SCROLLUP | DFCS_HOT)); 331 ctype = WebTestThemeControlWin::UpArrowType; 332 cstate = WebTestThemeControlWin::HotState; 333 break; 334 335 case ABS_DOWNHOT: 336 BLINK_ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_HOT)); 337 ctype = WebTestThemeControlWin::DownArrowType; 338 cstate = WebTestThemeControlWin::HotState; 339 break; 340 341 case ABS_LEFTHOT: 342 BLINK_ASSERT(classicState == (DFCS_SCROLLLEFT | DFCS_HOT)); 343 ctype = WebTestThemeControlWin::LeftArrowType; 344 cstate = WebTestThemeControlWin::HotState; 345 break; 346 347 case ABS_RIGHTHOT: 348 BLINK_ASSERT(classicState == (DFCS_SCROLLRIGHT | DFCS_HOT)); 349 ctype = WebTestThemeControlWin::RightArrowType; 350 cstate = WebTestThemeControlWin::HotState; 351 break; 352 353 case ABS_UPHOVER: 354 BLINK_ASSERT(classicState == DFCS_SCROLLUP); 355 ctype = WebTestThemeControlWin::UpArrowType; 356 cstate = WebTestThemeControlWin::HoverState; 357 break; 358 359 case ABS_DOWNHOVER: 360 BLINK_ASSERT(classicState == DFCS_SCROLLDOWN); 361 ctype = WebTestThemeControlWin::DownArrowType; 362 cstate = WebTestThemeControlWin::HoverState; 363 break; 364 365 case ABS_LEFTHOVER: 366 BLINK_ASSERT(classicState == DFCS_SCROLLLEFT); 367 ctype = WebTestThemeControlWin::LeftArrowType; 368 cstate = WebTestThemeControlWin::HoverState; 369 break; 370 371 case ABS_RIGHTHOVER: 372 BLINK_ASSERT(classicState == DFCS_SCROLLRIGHT); 373 ctype = WebTestThemeControlWin::RightArrowType; 374 cstate = WebTestThemeControlWin::HoverState; 375 break; 376 377 case ABS_UPPRESSED: 378 BLINK_ASSERT(classicState == (DFCS_SCROLLUP | DFCS_PUSHED | DFCS_FLAT)); 379 ctype = WebTestThemeControlWin::UpArrowType; 380 cstate = WebTestThemeControlWin::PressedState; 381 break; 382 383 case ABS_DOWNPRESSED: 384 BLINK_ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_PUSHED | DFCS_FLAT)); 385 ctype = WebTestThemeControlWin::DownArrowType; 386 cstate = WebTestThemeControlWin::PressedState; 387 break; 388 389 case ABS_LEFTPRESSED: 390 BLINK_ASSERT(classicState == (DFCS_SCROLLLEFT | DFCS_PUSHED | DFCS_FLAT)); 391 ctype = WebTestThemeControlWin::LeftArrowType; 392 cstate = WebTestThemeControlWin::PressedState; 393 break; 394 395 case ABS_RIGHTPRESSED: 396 BLINK_ASSERT(classicState == (DFCS_SCROLLRIGHT | DFCS_PUSHED | DFCS_FLAT)); 397 ctype = WebTestThemeControlWin::RightArrowType; 398 cstate = WebTestThemeControlWin::PressedState; 399 break; 400 401 case ABS_UPDISABLED: 402 BLINK_ASSERT(classicState == (DFCS_SCROLLUP | DFCS_INACTIVE)); 403 ctype = WebTestThemeControlWin::UpArrowType; 404 cstate = WebTestThemeControlWin::DisabledState; 405 break; 406 407 case ABS_DOWNDISABLED: 408 BLINK_ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_INACTIVE)); 409 ctype = WebTestThemeControlWin::DownArrowType; 410 cstate = WebTestThemeControlWin::DisabledState; 411 break; 412 413 case ABS_LEFTDISABLED: 414 BLINK_ASSERT(classicState == (DFCS_SCROLLLEFT | DFCS_INACTIVE)); 415 ctype = WebTestThemeControlWin::LeftArrowType; 416 cstate = WebTestThemeControlWin::DisabledState; 417 break; 418 419 case ABS_RIGHTDISABLED: 420 BLINK_ASSERT(classicState == (DFCS_SCROLLRIGHT | DFCS_INACTIVE)); 421 ctype = WebTestThemeControlWin::RightArrowType; 422 cstate = WebTestThemeControlWin::DisabledState; 423 break; 424 425 default: 426 BLINK_ASSERT_NOT_REACHED(); 427 break; 428 } 429 430 drawControl(canvas, rect, ctype, cstate); 431 } 432 433 void WebTestThemeEngineWin::paintScrollbarThumb(WebCanvas* canvas, int part, int state, int classicState, const WebRect& rect) 434 { 435 WebTestThemeControlWin::Type ctype = WebTestThemeControlWin::UnknownType; 436 WebTestThemeControlWin::State cstate = WebTestThemeControlWin::UnknownState; 437 438 switch (part) { 439 case SBP_THUMBBTNHORZ: 440 ctype = WebTestThemeControlWin::HorizontalScrollThumbType; 441 break; 442 443 case SBP_THUMBBTNVERT: 444 ctype = WebTestThemeControlWin::VerticalScrollThumbType; 445 break; 446 447 case SBP_GRIPPERHORZ: 448 ctype = WebTestThemeControlWin::HorizontalScrollGripType; 449 break; 450 451 case SBP_GRIPPERVERT: 452 ctype = WebTestThemeControlWin::VerticalScrollGripType; 453 break; 454 455 default: 456 BLINK_ASSERT_NOT_REACHED(); 457 break; 458 } 459 460 switch (state) { 461 case SCRBS_NORMAL: 462 BLINK_ASSERT(classicState == dfcsNormal); 463 cstate = WebTestThemeControlWin::NormalState; 464 break; 465 466 case SCRBS_HOT: 467 BLINK_ASSERT(classicState == DFCS_HOT); 468 cstate = WebTestThemeControlWin::HotState; 469 break; 470 471 case SCRBS_HOVER: 472 BLINK_ASSERT(classicState == dfcsNormal); 473 cstate = WebTestThemeControlWin::HoverState; 474 break; 475 476 case SCRBS_PRESSED: 477 BLINK_ASSERT(classicState == dfcsNormal); 478 cstate = WebTestThemeControlWin::PressedState; 479 break; 480 481 case SCRBS_DISABLED: 482 BLINK_ASSERT_NOT_REACHED(); // This should never happen in practice. 483 break; 484 485 default: 486 BLINK_ASSERT_NOT_REACHED(); 487 break; 488 } 489 490 drawControl(canvas, rect, ctype, cstate); 491 } 492 493 void WebTestThemeEngineWin::paintScrollbarTrack(WebCanvas* canvas, int part, int state, int classicState, const WebRect& rect, const WebRect& alignRect) 494 { 495 WebTestThemeControlWin::Type ctype = WebTestThemeControlWin::UnknownType; 496 WebTestThemeControlWin::State cstate = WebTestThemeControlWin::UnknownState; 497 498 switch (part) { 499 case SBP_UPPERTRACKHORZ: 500 ctype = WebTestThemeControlWin::HorizontalScrollTrackBackType; 501 break; 502 503 case SBP_LOWERTRACKHORZ: 504 ctype = WebTestThemeControlWin::HorizontalScrollTrackForwardType; 505 break; 506 507 case SBP_UPPERTRACKVERT: 508 ctype = WebTestThemeControlWin::VerticalScrollTrackBackType; 509 break; 510 511 case SBP_LOWERTRACKVERT: 512 ctype = WebTestThemeControlWin::VerticalScrollTrackForwardType; 513 break; 514 515 default: 516 BLINK_ASSERT_NOT_REACHED(); 517 break; 518 } 519 520 switch (state) { 521 case SCRBS_NORMAL: 522 BLINK_ASSERT(classicState == dfcsNormal); 523 cstate = WebTestThemeControlWin::NormalState; 524 break; 525 526 case SCRBS_HOT: 527 BLINK_ASSERT_NOT_REACHED(); // This should never happen in practice. 528 break; 529 530 case SCRBS_HOVER: 531 BLINK_ASSERT(classicState == dfcsNormal); 532 cstate = WebTestThemeControlWin::HoverState; 533 break; 534 535 case SCRBS_PRESSED: 536 BLINK_ASSERT_NOT_REACHED(); // This should never happen in practice. 537 break; 538 539 case SCRBS_DISABLED: 540 BLINK_ASSERT(classicState == DFCS_INACTIVE); 541 cstate = WebTestThemeControlWin::DisabledState; 542 break; 543 544 default: 545 BLINK_ASSERT_NOT_REACHED(); 546 break; 547 } 548 549 drawControl(canvas, rect, ctype, cstate); 550 } 551 552 void WebTestThemeEngineWin::paintSpinButton(WebCanvas* canvas, int part, int state, int classicState, const WebRect& rect) 553 { 554 WebTestThemeControlWin::Type ctype = WebTestThemeControlWin::UnknownType; 555 WebTestThemeControlWin::State cstate = WebTestThemeControlWin::UnknownState; 556 557 if (part == SPNP_UP) { 558 ctype = WebTestThemeControlWin::UpArrowType; 559 switch (state) { 560 case UPS_NORMAL: 561 BLINK_ASSERT(classicState == DFCS_SCROLLUP); 562 cstate = WebTestThemeControlWin::NormalState; 563 break; 564 case UPS_DISABLED: 565 BLINK_ASSERT(classicState == (DFCS_SCROLLUP | DFCS_INACTIVE)); 566 cstate = WebTestThemeControlWin::DisabledState; 567 break; 568 case UPS_PRESSED: 569 BLINK_ASSERT(classicState == (DFCS_SCROLLUP | DFCS_PUSHED)); 570 cstate = WebTestThemeControlWin::PressedState; 571 break; 572 case UPS_HOT: 573 BLINK_ASSERT(classicState == (DFCS_SCROLLUP | DFCS_HOT)); 574 cstate = WebTestThemeControlWin::HoverState; 575 break; 576 default: 577 BLINK_ASSERT_NOT_REACHED(); 578 } 579 } else if (part == SPNP_DOWN) { 580 ctype = WebTestThemeControlWin::DownArrowType; 581 switch (state) { 582 case DNS_NORMAL: 583 BLINK_ASSERT(classicState == DFCS_SCROLLDOWN); 584 cstate = WebTestThemeControlWin::NormalState; 585 break; 586 case DNS_DISABLED: 587 BLINK_ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_INACTIVE)); 588 cstate = WebTestThemeControlWin::DisabledState; 589 break; 590 case DNS_PRESSED: 591 BLINK_ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_PUSHED)); 592 cstate = WebTestThemeControlWin::PressedState; 593 break; 594 case DNS_HOT: 595 BLINK_ASSERT(classicState == (DFCS_SCROLLDOWN | DFCS_HOT)); 596 cstate = WebTestThemeControlWin::HoverState; 597 break; 598 default: 599 BLINK_ASSERT_NOT_REACHED(); 600 } 601 } else 602 BLINK_ASSERT_NOT_REACHED(); 603 drawControl(canvas, rect, ctype, cstate); 604 } 605 606 void WebTestThemeEngineWin::paintTextField(WebCanvas* canvas, int part, int state, int classicState, const WebRect& rect, WebColor color, bool fillContentArea, bool drawEdges) 607 { 608 WebTestThemeControlWin::Type ctype = WebTestThemeControlWin::UnknownType; 609 WebTestThemeControlWin::State cstate = WebTestThemeControlWin::UnknownState; 610 611 BLINK_ASSERT(EP_EDITTEXT == part); 612 ctype = WebTestThemeControlWin::TextFieldType; 613 614 switch (state) { 615 case ETS_NORMAL: 616 BLINK_ASSERT(classicState == dfcsNormal); 617 cstate = WebTestThemeControlWin::NormalState; 618 break; 619 620 case ETS_HOT: 621 BLINK_ASSERT(classicState == DFCS_HOT); 622 cstate = WebTestThemeControlWin::HotState; 623 break; 624 625 case ETS_DISABLED: 626 BLINK_ASSERT(classicState == DFCS_INACTIVE); 627 cstate = WebTestThemeControlWin::DisabledState; 628 break; 629 630 case ETS_SELECTED: 631 BLINK_ASSERT(classicState == DFCS_PUSHED); 632 cstate = WebTestThemeControlWin::PressedState; 633 break; 634 635 case ETS_FOCUSED: 636 BLINK_ASSERT(classicState == dfcsNormal); 637 cstate = WebTestThemeControlWin::FocusedState; 638 break; 639 640 case ETS_READONLY: 641 BLINK_ASSERT(classicState == dfcsNormal); 642 cstate = WebTestThemeControlWin::ReadOnlyState; 643 break; 644 645 default: 646 BLINK_ASSERT_NOT_REACHED(); 647 break; 648 } 649 650 drawTextField(canvas, rect, ctype, cstate, drawEdges, fillContentArea, color); 651 } 652 653 void WebTestThemeEngineWin::paintTrackbar(WebCanvas* canvas, int part, int state, int classicState, const WebRect& rect) 654 { 655 WebTestThemeControlWin::Type ctype = WebTestThemeControlWin::UnknownType; 656 WebTestThemeControlWin::State cstate = WebTestThemeControlWin::UnknownState; 657 658 if (TKP_THUMBBOTTOM == part) { 659 ctype = WebTestThemeControlWin::HorizontalSliderThumbType; 660 switch (state) { 661 case TUS_NORMAL: 662 BLINK_ASSERT(classicState == dfcsNormal); 663 cstate = WebTestThemeControlWin::NormalState; 664 break; 665 666 case TUS_HOT: 667 BLINK_ASSERT(classicState == DFCS_HOT); 668 cstate = WebTestThemeControlWin::HotState; 669 break; 670 671 case TUS_DISABLED: 672 BLINK_ASSERT(classicState == DFCS_INACTIVE); 673 cstate = WebTestThemeControlWin::DisabledState; 674 break; 675 676 case TUS_PRESSED: 677 BLINK_ASSERT(classicState == DFCS_PUSHED); 678 cstate = WebTestThemeControlWin::PressedState; 679 break; 680 681 default: 682 BLINK_ASSERT_NOT_REACHED(); 683 break; 684 } 685 } else if (TKP_THUMBVERT == part) { 686 ctype = WebTestThemeControlWin::VerticalSliderThumbType; 687 switch (state) { 688 case TUS_NORMAL: 689 BLINK_ASSERT(classicState == dfcsNormal); 690 cstate = WebTestThemeControlWin::NormalState; 691 break; 692 693 case TUS_HOT: 694 BLINK_ASSERT(classicState == DFCS_HOT); 695 cstate = WebTestThemeControlWin::HotState; 696 break; 697 698 case TUS_DISABLED: 699 BLINK_ASSERT(classicState == DFCS_INACTIVE); 700 cstate = WebTestThemeControlWin::DisabledState; 701 break; 702 703 case TUS_PRESSED: 704 BLINK_ASSERT(classicState == DFCS_PUSHED); 705 cstate = WebTestThemeControlWin::PressedState; 706 break; 707 708 default: 709 BLINK_ASSERT_NOT_REACHED(); 710 break; 711 } 712 } else if (TKP_TRACK == part) { 713 ctype = WebTestThemeControlWin::HorizontalSliderTrackType; 714 BLINK_ASSERT(state == TRS_NORMAL); 715 BLINK_ASSERT(classicState == dfcsNormal); 716 cstate = WebTestThemeControlWin::NormalState; 717 } else if (TKP_TRACKVERT == part) { 718 ctype = WebTestThemeControlWin::VerticalSliderTrackType; 719 BLINK_ASSERT(state == TRVS_NORMAL); 720 BLINK_ASSERT(classicState == dfcsNormal); 721 cstate = WebTestThemeControlWin::NormalState; 722 } else 723 BLINK_ASSERT_NOT_REACHED(); 724 725 drawControl(canvas, rect, ctype, cstate); 726 } 727 728 729 void WebTestThemeEngineWin::paintProgressBar(blink::WebCanvas* canvas, const blink::WebRect& barRect, const blink::WebRect& valueRect, bool determinate, double) 730 { 731 WebTestThemeControlWin::Type ctype = WebTestThemeControlWin::ProgressBarType; 732 WebTestThemeControlWin::State cstate = determinate ? WebTestThemeControlWin::NormalState : WebTestThemeControlWin::IndeterminateState; 733 drawProgressBar(canvas, ctype, cstate, barRect, valueRect); 734 } 735 736 737 blink::WebSize WebTestThemeEngineWin::getSize(int part) 738 { 739 return blink::WebSize(); 740 } 741 742 } 743