summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell/test_shell_webthemecontrol.h
diff options
context:
space:
mode:
authordpranke@google.com <dpranke@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 21:19:21 +0000
committerdpranke@google.com <dpranke@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 21:19:21 +0000
commitcf37da383867e81a5998fb06f5bca52dc92552c7 (patch)
treef5cd435729061d74f739cadd0d51a09019c849c2 /webkit/tools/test_shell/test_shell_webthemecontrol.h
parenta1b9f5d1be682acc27767c121e282b2353510b48 (diff)
downloadchromium_src-cf37da383867e81a5998fb06f5bca52dc92552c7.zip
chromium_src-cf37da383867e81a5998fb06f5bca52dc92552c7.tar.gz
chromium_src-cf37da383867e81a5998fb06f5bca52dc92552c7.tar.bz2
This change adds a new "generic" theme to the Windows implementation of
test_shell, so that we can render controls in a platform-verion-independent manner, allowing us to use (almost) a single set of baselines for all versions of Windows. test_shell is modified to accept three new switches: --ux-theme (for the default or "new" XP/Vista theming engine), --classic-theme (for the older "Classic" theming engine), and --generic-theme (for the new Skia-based test theme). Specifying --layout-tests will default to --classic-theme, otherwise --ux-theme is the default (this is compatible with existing test_shell behavior). Once the new version-independent baselines are checked in, we will flip this behavior so --layout-tests defaults to --generic-theme as well. This change adds test_shell_webtheme{engine,control}.{cc,h} as Windows-only build files, and adds documentation to webkit/api/public/win/WebThemeEngine. It also adds a chromium-win-xp platform baseline directory (currently empty) and modifies the layout_test/layout_package/platform_utils_win.py baseline search path to confirm to WebKit's directory search logic (vista and win7 look just in chromium-win, but XP looks in chromium-win-xp first, followed by chromium-win). BUG=none R=darin,pkasting TEST=none Review URL: http://codereview.chromium.org/192021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26161 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell/test_shell_webthemecontrol.h')
-rw-r--r--webkit/tools/test_shell/test_shell_webthemecontrol.h170
1 files changed, 170 insertions, 0 deletions
diff --git a/webkit/tools/test_shell/test_shell_webthemecontrol.h b/webkit/tools/test_shell/test_shell_webthemecontrol.h
new file mode 100644
index 0000000..bb439af
--- /dev/null
+++ b/webkit/tools/test_shell/test_shell_webthemecontrol.h
@@ -0,0 +1,170 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// TestShellWebTheme::Control implements the generic rendering of controls
+// needed by TestShellWebTheme::Engine. See the comments in that class
+// header file for why this class is needed and used.
+//
+// This class implements a generic set of widgets using Skia. The widgets
+// are optimized for testability, not a pleasing appearance.
+//
+
+#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBTHEMECONTROL_H_
+#define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBTHEMECONTROL_H_
+
+#include "base/basictypes.h"
+#include "skia/ext/platform_canvas.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "third_party/skia/include/core/SkRect.h"
+
+namespace TestShellWebTheme {
+
+class Control {
+ public:
+ // This list of states mostly mirrors the list in
+ // third_party/WebKit/WebCore/platform/ThemeTypes.h but is maintained
+ // separately since that isn't public and also to minimize dependencies.
+ // Note that the WebKit ThemeTypes seem to imply that a control can be
+ // in multiple states simultaneously but WebThemeEngine only allows for
+ // a single state at a time.
+ //
+ // Some definitions for the various states:
+ // Disabled - indicates that a control can't be modified or selected
+ // (corresponds to HTML 'disabled' attribute)
+ // ReadOnly - indicates that a control can't be modified but can be
+ // selected
+ // Normal - the normal state of control on the page when it isn't
+ // focused or otherwise active
+ // Hot - when the mouse is hovering over a part of the control,
+ // all the other parts are considered "hot"
+ // Hover - when the mouse is directly over a control (the CSS
+ // :hover pseudo-class)
+ // Focused - when the control has the keyboard focus
+ // Pressed - when the control is being triggered (by a mousedown or
+ // a key event).
+ enum State {
+ kUnknown_State = 0,
+ kDisabled_State,
+ kReadOnly_State,
+ kNormal_State,
+ kHot_State,
+ kHover_State,
+ kFocused_State,
+ kPressed_State
+ };
+
+ // This list of types mostly mirrors the list in
+ // third_party/WebKit/WebCore/platform/ThemeTypes.h but is maintained
+ // separately since that isn't public and also to minimize dependencies.
+ //
+ // Note that what the user might think of as a single control can be
+ // made up of multiple parts. For example, a single scroll bar contains
+ // six clickable parts - two arrows, the "thumb" indicating the current
+ // position on the bar, the other two parts of the bar (before and after
+ // the thumb) and the "gripper" on the thumb itself.
+ //
+ enum Type {
+ kUnknown_Type = 0,
+ kTextField_Type,
+ kPushButton_Type,
+ kUncheckedBox_Type,
+ kCheckedBox_Type,
+ kUncheckedRadio_Type,
+ kCheckedRadio_Type,
+ kHorizontalScrollTrackBack_Type,
+ kHorizontalScrollTrackForward_Type,
+ kHorizontalScrollThumb_Type,
+ kHorizontalScrollGrip_Type,
+ kVerticalScrollTrackBack_Type,
+ kVerticalScrollTrackForward_Type,
+ kVerticalScrollThumb_Type,
+ kVerticalScrollGrip_Type,
+ kLeftArrow_Type,
+ kRightArrow_Type,
+ kUpArrow_Type,
+ kDownArrow_Type,
+ kHorizontalSliderTrack_Type,
+ kHorizontalSliderThumb_Type,
+ kDropDownButton_Type
+ };
+
+ // canvas is the canvas to draw onto, and rect gives the size of the
+ // control. ctype and cstate specify the type and state of the control.
+ Control(skia::PlatformCanvas *canvas, const SkIRect &rect,
+ Type ctype, State cstate);
+ ~Control();
+
+ // Draws the control.
+ void draw();
+
+ // Use this for TextField controls instead, because the logic
+ // for drawing them is dependent on what WebKit tells us to do.
+ // If draw_edges is true, draw an edge around the control. If
+ // fill_content_area is true, fill the content area with the given color.
+ void drawTextField(bool draw_edges, bool fill_content_area, SkColor color);
+
+ private:
+ // Draws a box of size specified by irect, filled with the given color.
+ // The box will have a border drawn in the default edge color.
+ void box(const SkIRect &irect, SkColor color);
+
+
+ // Draws a triangle of size specified by the three pairs of coordinates,
+ // filled with the given color. The box will have an edge drawn in the
+ // default edge color.
+ void triangle(int x0, int y0, int x1, int y1, int x2, int y2,
+ SkColor color);
+
+ // Draws a rectangle the size of the control with rounded corners, filled
+ // with the specified color (and with a border in the default edge color).
+ void roundRect(SkColor color);
+
+ // Draws an oval the size of the control, filled with the specified color
+ // and with a border in the default edge color.
+ void oval(SkColor color);
+
+ // Draws a circle centered in the control with the specified radius,
+ // filled with the specified color, and with a border draw in the
+ // default edge color.
+ void circle(SkScalar radius, SkColor color);
+
+ // Draws a box the size of the control, filled with the outer_color and
+ // with a border in the default edge color, and then draws another box
+ // indented on all four sides by the specified amounts, filled with the
+ // inner color and with a border in the default edge color.
+ void nested_boxes(int indent_left, int indent_top,
+ int indent_right, int indent_bottom,
+ SkColor outer_color, SkColor inner_color);
+
+ // Draws a line between the two points in the given color.
+ void line(int x0, int y0, int x1, int y1, SkColor color);
+
+ // Draws a distinctive mark on the control for each state, so that the
+ // state of the control can be determined without needing to know which
+ // color is which.
+ void markState();
+
+ skia::PlatformCanvas* canvas_;
+ const SkIRect irect_;
+ const Type type_;
+ const State state_;
+ const SkColor edge_color_;
+ const SkColor bg_color_;
+ const SkColor fg_color_;
+
+ // The following are convenience accessors for irect_.
+ const int left_;
+ const int right_;
+ const int top_;
+ const int bottom_;
+ const int width_;
+ const int height_;
+
+ DISALLOW_COPY_AND_ASSIGN(Control);
+};
+
+} // namespace TestShellWebTheme
+
+#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBTHEMECONTROL_H_
+