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

Side by Side Diff: content/shell/renderer/test_runner/WebTestThemeControlWin.h

Issue 110533009: Import TestRunner library into chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // WebTestThemeControlWin implements the generic rendering of controls
6 // needed by WebThemeEngineDRTWin. See the comments in that class
7 // header file for why this class is needed and used.
8 //
9 // This class implements a generic set of widgets using Skia. The widgets
10 // are optimized for testability, not a pleasing appearance.
11 //
12
13 #ifndef WebTestThemeControlWin_h
14 #define WebTestThemeControlWin_h
15
16 #include "third_party/WebKit/public/platform/WebNonCopyable.h"
17 #include "third_party/skia/include/core/SkColor.h"
18 #include "third_party/skia/include/core/SkRect.h"
19
20 // Skia forward declarations
21 class SkCanvas;
22
23 namespace WebTestRunner {
24
25 class WebTestThemeControlWin : public blink::WebNonCopyable {
26 public:
27 // This list of states mostly mirrors the list in WebCore/platform/ThemeType s.h
28 // but is maintained separately since that isn't public and also to minimize
29 // dependencies.
30 // Note that the WebKit ThemeTypes seem to imply that a control can be
31 // in multiple states simultaneously but WebThemeEngine only allows for
32 // a single state at a time.
33 //
34 // Some definitions for the various states:
35 // Disabled - indicates that a control can't be modified or selected
36 // (corresponds to HTML 'disabled' attribute)
37 // ReadOnly - indicates that a control can't be modified but can be
38 // selected
39 // Normal - the normal state of control on the page when it isn't
40 // focused or otherwise active
41 // Hot - when the mouse is hovering over a part of the control,
42 // all the other parts are considered "hot"
43 // Hover - when the mouse is directly over a control (the CSS
44 // :hover pseudo-class)
45 // Focused - when the control has the keyboard focus
46 // Pressed - when the control is being triggered (by a mousedown or
47 // a key event).
48 // Indeterminate - when set to indeterminate (only for progress bar)
49 enum State {
50 UnknownState = 0,
51 DisabledState,
52 ReadOnlyState,
53 NormalState,
54 HotState,
55 HoverState,
56 FocusedState,
57 PressedState,
58 IndeterminateState
59 };
60
61 // This list of types mostly mirrors the list in
62 // WebCore/platform/ThemeTypes.h but is maintained
63 // separately since that isn't public and also to minimize dependencies.
64 //
65 // Note that what the user might think of as a single control can be
66 // made up of multiple parts. For example, a single scroll bar contains
67 // six clickable parts - two arrows, the "thumb" indicating the current
68 // position on the bar, the other two parts of the bar (before and after
69 // the thumb) and the "gripper" on the thumb itself.
70 //
71 enum Type {
72 UnknownType = 0,
73 TextFieldType,
74 PushButtonType,
75 UncheckedBoxType,
76 CheckedBoxType,
77 IndeterminateCheckboxType,
78 UncheckedRadioType,
79 CheckedRadioType,
80 HorizontalScrollTrackBackType,
81 HorizontalScrollTrackForwardType,
82 HorizontalScrollThumbType,
83 HorizontalScrollGripType,
84 VerticalScrollTrackBackType,
85 VerticalScrollTrackForwardType,
86 VerticalScrollThumbType,
87 VerticalScrollGripType,
88 LeftArrowType,
89 RightArrowType,
90 UpArrowType,
91 DownArrowType,
92 HorizontalSliderTrackType,
93 HorizontalSliderThumbType,
94 VerticalSliderTrackType,
95 VerticalSliderThumbType,
96 DropDownButtonType,
97 ProgressBarType
98 };
99
100 // Constructs a control of the given size, type and state to draw
101 // on to the given canvas.
102 WebTestThemeControlWin(SkCanvas*, const SkIRect&, Type, State);
103 ~WebTestThemeControlWin();
104
105 // Draws the control.
106 void draw();
107
108 // Use this for TextField controls instead, because the logic
109 // for drawing them is dependent on what WebKit tells us to do.
110 // If drawEdges is true, draw an edge around the control. If
111 // fillContentArea is true, fill the content area with the given color.
112 void drawTextField(bool drawEdges, bool fillContentArea, SkColor);
113
114 // Use this for drawing ProgressBar controls instead, since we
115 // need to know the rect to fill inside the bar.
116 void drawProgressBar(const SkIRect& fillRect);
117
118 private:
119 // Draws a box of size specified by irect, filled with the given color.
120 // The box will have a border drawn in the default edge color.
121 void box(const SkIRect& irect, SkColor);
122
123
124 // Draws a triangle of size specified by the three pairs of coordinates,
125 // filled with the given color. The box will have an edge drawn in the
126 // default edge color.
127 void triangle(int x0, int y0, int x1, int y1, int x2, int y2, SkColor);
128
129 // Draws a rectangle the size of the control with rounded corners, filled
130 // with the specified color (and with a border in the default edge color).
131 void roundRect(SkColor);
132
133 // Draws an oval the size of the control, filled with the specified color
134 // and with a border in the default edge color.
135 void oval(SkColor);
136
137 // Draws a circle centered in the control with the specified radius,
138 // filled with the specified color, and with a border draw in the
139 // default edge color.
140 void circle(SkScalar radius, SkColor);
141
142 // Draws a box the size of the control, filled with the outerColor and
143 // with a border in the default edge color, and then draws another box
144 // indented on all four sides by the specified amounts, filled with the
145 // inner color and with a border in the default edge color.
146 void nestedBoxes(int indentLeft, int indentTop, int indentRight, int indentB ottom, SkColor outerColor, SkColor innerColor);
147
148 // Draws a line between the two points in the given color.
149 void line(int x0, int y0, int x1, int y1, SkColor);
150
151 // Draws a distinctive mark on the control for each state, so that the
152 // state of the control can be determined without needing to know which
153 // color is which.
154 void markState();
155
156 SkCanvas* m_canvas;
157 const SkIRect m_irect;
158 const Type m_type;
159 const State m_state;
160 const SkColor m_edgeColor;
161 const SkColor m_bgColor;
162 const SkColor m_fgColor;
163
164 // The following are convenience accessors for m_irect.
165 const int m_left;
166 const int m_right;
167 const int m_top;
168 const int m_bottom;
169 const int m_width;
170 const int m_height;
171 };
172
173 }
174
175 #endif // WebTestThemeControlWin_h
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/WebTestRunner.h ('k') | content/shell/renderer/test_runner/WebTestThemeControlWin.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698