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

Side by Side Diff: content/test/layout_tests/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 /*
6 * Copyright (C) 2010 Google Inc. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following disclaimer
16 * in the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Google Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived from
20 * this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 // WebTestThemeControlWin implements the generic rendering of controls
36 // needed by WebThemeEngineDRTWin. See the comments in that class
37 // header file for why this class is needed and used.
38 //
39 // This class implements a generic set of widgets using Skia. The widgets
40 // are optimized for testability, not a pleasing appearance.
41 //
42
43 #ifndef WebTestThemeControlWin_h
44 #define WebTestThemeControlWin_h
45
46 #include "third_party/WebKit/public/platform/WebNonCopyable.h"
47 #include "third_party/skia/include/core/SkColor.h"
48 #include "third_party/skia/include/core/SkRect.h"
49
50 // Skia forward declarations
51 class SkCanvas;
52
53 namespace WebTestRunner {
54
55 class WebTestThemeControlWin : public blink::WebNonCopyable {
56 public:
57 // This list of states mostly mirrors the list in WebCore/platform/ThemeType s.h
58 // but is maintained separately since that isn't public and also to minimize
59 // dependencies.
60 // Note that the WebKit ThemeTypes seem to imply that a control can be
61 // in multiple states simultaneously but WebThemeEngine only allows for
62 // a single state at a time.
63 //
64 // Some definitions for the various states:
65 // Disabled - indicates that a control can't be modified or selected
66 // (corresponds to HTML 'disabled' attribute)
67 // ReadOnly - indicates that a control can't be modified but can be
68 // selected
69 // Normal - the normal state of control on the page when it isn't
70 // focused or otherwise active
71 // Hot - when the mouse is hovering over a part of the control,
72 // all the other parts are considered "hot"
73 // Hover - when the mouse is directly over a control (the CSS
74 // :hover pseudo-class)
75 // Focused - when the control has the keyboard focus
76 // Pressed - when the control is being triggered (by a mousedown or
77 // a key event).
78 // Indeterminate - when set to indeterminate (only for progress bar)
79 enum State {
80 UnknownState = 0,
81 DisabledState,
82 ReadOnlyState,
83 NormalState,
84 HotState,
85 HoverState,
86 FocusedState,
87 PressedState,
88 IndeterminateState
89 };
90
91 // This list of types mostly mirrors the list in
92 // WebCore/platform/ThemeTypes.h but is maintained
93 // separately since that isn't public and also to minimize dependencies.
94 //
95 // Note that what the user might think of as a single control can be
96 // made up of multiple parts. For example, a single scroll bar contains
97 // six clickable parts - two arrows, the "thumb" indicating the current
98 // position on the bar, the other two parts of the bar (before and after
99 // the thumb) and the "gripper" on the thumb itself.
100 //
101 enum Type {
102 UnknownType = 0,
103 TextFieldType,
104 PushButtonType,
105 UncheckedBoxType,
106 CheckedBoxType,
107 IndeterminateCheckboxType,
108 UncheckedRadioType,
109 CheckedRadioType,
110 HorizontalScrollTrackBackType,
111 HorizontalScrollTrackForwardType,
112 HorizontalScrollThumbType,
113 HorizontalScrollGripType,
114 VerticalScrollTrackBackType,
115 VerticalScrollTrackForwardType,
116 VerticalScrollThumbType,
117 VerticalScrollGripType,
118 LeftArrowType,
119 RightArrowType,
120 UpArrowType,
121 DownArrowType,
122 HorizontalSliderTrackType,
123 HorizontalSliderThumbType,
124 VerticalSliderTrackType,
125 VerticalSliderThumbType,
126 DropDownButtonType,
127 ProgressBarType
128 };
129
130 // Constructs a control of the given size, type and state to draw
131 // on to the given canvas.
132 WebTestThemeControlWin(SkCanvas*, const SkIRect&, Type, State);
133 ~WebTestThemeControlWin();
134
135 // Draws the control.
136 void draw();
137
138 // Use this for TextField controls instead, because the logic
139 // for drawing them is dependent on what WebKit tells us to do.
140 // If drawEdges is true, draw an edge around the control. If
141 // fillContentArea is true, fill the content area with the given color.
142 void drawTextField(bool drawEdges, bool fillContentArea, SkColor);
143
144 // Use this for drawing ProgressBar controls instead, since we
145 // need to know the rect to fill inside the bar.
146 void drawProgressBar(const SkIRect& fillRect);
147
148 private:
149 // Draws a box of size specified by irect, filled with the given color.
150 // The box will have a border drawn in the default edge color.
151 void box(const SkIRect& irect, SkColor);
152
153
154 // Draws a triangle of size specified by the three pairs of coordinates,
155 // filled with the given color. The box will have an edge drawn in the
156 // default edge color.
157 void triangle(int x0, int y0, int x1, int y1, int x2, int y2, SkColor);
158
159 // Draws a rectangle the size of the control with rounded corners, filled
160 // with the specified color (and with a border in the default edge color).
161 void roundRect(SkColor);
162
163 // Draws an oval the size of the control, filled with the specified color
164 // and with a border in the default edge color.
165 void oval(SkColor);
166
167 // Draws a circle centered in the control with the specified radius,
168 // filled with the specified color, and with a border draw in the
169 // default edge color.
170 void circle(SkScalar radius, SkColor);
171
172 // Draws a box the size of the control, filled with the outerColor and
173 // with a border in the default edge color, and then draws another box
174 // indented on all four sides by the specified amounts, filled with the
175 // inner color and with a border in the default edge color.
176 void nestedBoxes(int indentLeft, int indentTop, int indentRight, int indentB ottom, SkColor outerColor, SkColor innerColor);
177
178 // Draws a line between the two points in the given color.
179 void line(int x0, int y0, int x1, int y1, SkColor);
180
181 // Draws a distinctive mark on the control for each state, so that the
182 // state of the control can be determined without needing to know which
183 // color is which.
184 void markState();
185
186 SkCanvas* m_canvas;
187 const SkIRect m_irect;
188 const Type m_type;
189 const State m_state;
190 const SkColor m_edgeColor;
191 const SkColor m_bgColor;
192 const SkColor m_fgColor;
193
194 // The following are convenience accessors for m_irect.
195 const int m_left;
196 const int m_right;
197 const int m_top;
198 const int m_bottom;
199 const int m_width;
200 const int m_height;
201 };
202
203 }
204
205 #endif // WebTestThemeControlWin_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698