Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: webkit/tools/test_shell/test_shell_webthemecontrol.cc

Issue 1988012: Added support for HTML5 progress element. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: took the feedback Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file implements a simple generic version of the WebKitThemeEngine, 5 // This file implements a simple generic version of the WebKitThemeEngine,
6 // which is used to draw all the native controls on a web page. We use this 6 // which is used to draw all the native controls on a web page. We use this
7 // file when running in layout test mode in order to remove any 7 // file when running in layout test mode in order to remove any
8 // platform-specific rendering differences due to themes, colors, etc. 8 // platform-specific rendering differences due to themes, colors, etc.
9 // 9 //
10 10
11 #include "webkit/tools/test_shell/test_shell_webthemecontrol.h" 11 #include "webkit/tools/test_shell/test_shell_webthemecontrol.h"
(...skipping 11 matching lines...) Expand all
23 const SkColor kFgColor = SK_ColorBLACK; 23 const SkColor kFgColor = SK_ColorBLACK;
24 24
25 const SkColor kBgColors[] = { 25 const SkColor kBgColors[] = {
26 SK_ColorBLACK, // Unknown 26 SK_ColorBLACK, // Unknown
27 SkColorSetRGB(0xc9, 0xc9, 0xc9), // Disabled 27 SkColorSetRGB(0xc9, 0xc9, 0xc9), // Disabled
28 SkColorSetRGB(0xf3, 0xe0, 0xd0), // Readonly 28 SkColorSetRGB(0xf3, 0xe0, 0xd0), // Readonly
29 SkColorSetRGB(0x89, 0xc4, 0xff), // Normal 29 SkColorSetRGB(0x89, 0xc4, 0xff), // Normal
30 SkColorSetRGB(0x43, 0xf9, 0xff), // Hot 30 SkColorSetRGB(0x43, 0xf9, 0xff), // Hot
31 SkColorSetRGB(0x20, 0xf6, 0xcc), // Focused 31 SkColorSetRGB(0x20, 0xf6, 0xcc), // Focused
32 SkColorSetRGB(0x00, 0xf3, 0xac), // Hover 32 SkColorSetRGB(0x00, 0xf3, 0xac), // Hover
33 SkColorSetRGB(0xa9, 0xff, 0x12) // Pressed 33 SkColorSetRGB(0xa9, 0xff, 0x12), // Pressed
34 SkColorSetRGB(0xcc, 0xcc, 0xcc) // Indeterminate
34 }; 35 };
35 36
36 SkIRect Validate(const SkIRect& rect, Control::Type ctype) { 37 SkIRect Validate(const SkIRect& rect, Control::Type ctype) {
37 SkIRect retval = rect; 38 SkIRect retval = rect;
38 if (ctype == Control::kUncheckedBox_Type || 39 if (ctype == Control::kUncheckedBox_Type ||
39 ctype == Control::kCheckedBox_Type || 40 ctype == Control::kCheckedBox_Type ||
40 ctype == Control::kUncheckedRadio_Type || 41 ctype == Control::kUncheckedRadio_Type ||
41 ctype == Control::kCheckedRadio_Type) { 42 ctype == Control::kCheckedRadio_Type) {
42 // The maximum width and height is 13. Center the square in the passed 43 // The maximum width and height is 13. Center the square in the passed
43 // rectangle. 44 // rectangle.
44 const int kMaxControlSize = 13; 45 const int kMaxControlSize = 13;
45 int control_size = std::min(rect.width(), rect.height()); 46 int control_size = std::min(rect.width(), rect.height());
46 control_size = std::min(control_size, kMaxControlSize); 47 control_size = std::min(control_size, kMaxControlSize);
47 48
48 retval.fLeft = rect.fLeft + (rect.width() / 2) - (control_size / 2); 49 retval.fLeft = rect.fLeft + (rect.width() / 2) - (control_size / 2);
49 retval.fRight = retval.fLeft + control_size - 1; 50 retval.fRight = retval.fLeft + control_size - 1;
50 retval.fTop = rect.fTop + (rect.height() / 2) - (control_size / 2); 51 retval.fTop = rect.fTop + (rect.height() / 2) - (control_size / 2);
51 retval.fBottom = retval.fTop + control_size - 1; 52 retval.fBottom = retval.fTop + control_size - 1;
52 } 53 }
53 return retval; 54 return retval;
54 } 55 }
55 56
56 Control::Control(skia::PlatformCanvas *canvas, const SkIRect &irect, 57 Control::Control(skia::PlatformCanvas* canvas, const SkIRect& irect,
57 Type ctype, State cstate) 58 Type ctype, State cstate)
58 : canvas_(canvas), 59 : canvas_(canvas),
59 irect_(Validate(irect, ctype)), 60 irect_(Validate(irect, ctype)),
60 type_(ctype), 61 type_(ctype),
61 state_(cstate), 62 state_(cstate),
62 left_(irect_.fLeft), 63 left_(irect_.fLeft),
63 right_(irect_.fRight), 64 right_(irect_.fRight),
64 top_(irect_.fTop), 65 top_(irect_.fTop),
65 bottom_(irect_.fBottom), 66 bottom_(irect_.fBottom),
66 height_(irect_.height()), 67 height_(irect_.height()),
67 width_(irect_.width()), 68 width_(irect_.width()),
68 edge_color_(kEdgeColor), 69 edge_color_(kEdgeColor),
69 bg_color_(kBgColors[cstate]), 70 bg_color_(kBgColors[cstate]),
70 fg_color_(kFgColor) { 71 fg_color_(kFgColor) {
71 } 72 }
72 73
73 Control::~Control() { 74 Control::~Control() {
74 } 75 }
75 76
76 void Control::box(const SkIRect &rect, SkColor fill_color) { 77 void Control::box(const SkIRect& rect, SkColor fill_color) {
77 SkPaint paint; 78 SkPaint paint;
78 79
79 paint.setStyle(SkPaint::kFill_Style); 80 paint.setStyle(SkPaint::kFill_Style);
80 paint.setColor(fill_color); 81 paint.setColor(fill_color);
81 canvas_->drawIRect(rect, paint); 82 canvas_->drawIRect(rect, paint);
82 83
83 paint.setColor(edge_color_); 84 paint.setColor(edge_color_);
84 paint.setStyle(SkPaint::kStroke_Style); 85 paint.setStyle(SkPaint::kStroke_Style);
85 canvas_->drawIRect(rect, paint); 86 canvas_->drawIRect(rect, paint);
86 } 87 }
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 if (draw_edges) { 405 if (draw_edges) {
405 paint.setColor(edge_color_); 406 paint.setColor(edge_color_);
406 paint.setStyle(SkPaint::kStroke_Style); 407 paint.setStyle(SkPaint::kStroke_Style);
407 canvas_->drawIRect(irect_, paint); 408 canvas_->drawIRect(irect_, paint);
408 } 409 }
409 410
410 markState(); 411 markState();
411 canvas_->endPlatformPaint(); 412 canvas_->endPlatformPaint();
412 } 413 }
413 414
415 void
416 Control::drawProgressBar(const SkIRect& fill_rect) {
417 SkPaint paint;
418
419 canvas_->beginPlatformPaint();
420 paint.setColor(bg_color_);
421 paint.setStyle(SkPaint::kFill_Style);
422 canvas_->drawIRect(irect_, paint);
423
424 // Emulate clipping
425 SkIRect tofill;
426 tofill.intersect(irect_, fill_rect);
427 paint.setColor(fg_color_);
428 paint.setStyle(SkPaint::kFill_Style);
429 canvas_->drawIRect(tofill, paint);
430
431 markState();
432 canvas_->endPlatformPaint();
433 }
434
414 } // namespace TestShellWebTheme 435 } // namespace TestShellWebTheme
415 436
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698