summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/webthemeengine_impl_win.cc17
-rw-r--r--webkit/glue/webthemeengine_impl_win.h4
-rw-r--r--webkit/tools/test_shell/test_shell_webthemecontrol.cc29
-rw-r--r--webkit/tools/test_shell/test_shell_webthemecontrol.h17
-rw-r--r--webkit/tools/test_shell/test_shell_webthemeengine.cc25
-rw-r--r--webkit/tools/test_shell/test_shell_webthemeengine.h6
6 files changed, 83 insertions, 15 deletions
diff --git a/webkit/glue/webthemeengine_impl_win.cc b/webkit/glue/webthemeengine_impl_win.cc
index 78d7cf3614..0d2b563 100644
--- a/webkit/glue/webthemeengine_impl_win.cc
+++ b/webkit/glue/webthemeengine_impl_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// Copyright (c) 2010 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.
@@ -114,4 +114,19 @@ void WebThemeEngineImpl::paintTrackbar(
canvas->endPlatformPaint();
}
+void WebThemeEngineImpl::paintProgressBar(
+ WebKit::WebCanvas* canvas,
+ const WebKit::WebRect& barRect,
+ int valuePart, const WebKit::WebRect& valueRect)
+
+{
+ HDC hdc = canvas->beginPlatformPaint();
+ RECT native_bar_rect = WebRectToRECT(barRect);
+ RECT native_value_rect = WebRectToRECT(valueRect);
+ gfx::NativeTheme::instance()->PaintProgressBar(
+ hdc, &native_bar_rect,
+ valuePart, &native_value_rect, canvas);
+ canvas->endPlatformPaint();
+}
+
} // namespace webkit_glue
diff --git a/webkit/glue/webthemeengine_impl_win.h b/webkit/glue/webthemeengine_impl_win.h
index ae9152b..73cb42d 100644
--- a/webkit/glue/webthemeengine_impl_win.h
+++ b/webkit/glue/webthemeengine_impl_win.h
@@ -34,6 +34,10 @@ class WebThemeEngineImpl : public WebKit::WebThemeEngine {
virtual void paintTrackbar(
WebKit::WebCanvas*, int part, int state, int classic_state,
const WebKit::WebRect&);
+ virtual void paintProgressBar(
+ WebKit::WebCanvas*,
+ const WebKit::WebRect& barRect,
+ int valuePart, const WebKit::WebRect& valueRect);
};
} // namespace webkit_glue
diff --git a/webkit/tools/test_shell/test_shell_webthemecontrol.cc b/webkit/tools/test_shell/test_shell_webthemecontrol.cc
index 742a295..96045f3 100644
--- a/webkit/tools/test_shell/test_shell_webthemecontrol.cc
+++ b/webkit/tools/test_shell/test_shell_webthemecontrol.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -30,7 +30,8 @@ const SkColor kBgColors[] = {
SkColorSetRGB(0x43, 0xf9, 0xff), // Hot
SkColorSetRGB(0x20, 0xf6, 0xcc), // Focused
SkColorSetRGB(0x00, 0xf3, 0xac), // Hover
- SkColorSetRGB(0xa9, 0xff, 0x12) // Pressed
+ SkColorSetRGB(0xa9, 0xff, 0x12), // Pressed
+ SkColorSetRGB(0xcc, 0xcc, 0xcc) // Indeterminate
};
SkIRect Validate(const SkIRect& rect, Control::Type ctype) {
@@ -53,7 +54,7 @@ SkIRect Validate(const SkIRect& rect, Control::Type ctype) {
return retval;
}
-Control::Control(skia::PlatformCanvas *canvas, const SkIRect &irect,
+Control::Control(skia::PlatformCanvas* canvas, const SkIRect& irect,
Type ctype, State cstate)
: canvas_(canvas),
irect_(Validate(irect, ctype)),
@@ -73,7 +74,7 @@ Control::Control(skia::PlatformCanvas *canvas, const SkIRect &irect,
Control::~Control() {
}
-void Control::box(const SkIRect &rect, SkColor fill_color) {
+void Control::box(const SkIRect& rect, SkColor fill_color) {
SkPaint paint;
paint.setStyle(SkPaint::kFill_Style);
@@ -411,5 +412,25 @@ void Control::drawTextField(bool draw_edges, bool fill_content_area,
canvas_->endPlatformPaint();
}
+void
+Control::drawProgressBar(const SkIRect& fill_rect) {
+ SkPaint paint;
+
+ canvas_->beginPlatformPaint();
+ paint.setColor(bg_color_);
+ paint.setStyle(SkPaint::kFill_Style);
+ canvas_->drawIRect(irect_, paint);
+
+ // Emulate clipping
+ SkIRect tofill;
+ tofill.intersect(irect_, fill_rect);
+ paint.setColor(fg_color_);
+ paint.setStyle(SkPaint::kFill_Style);
+ canvas_->drawIRect(tofill, paint);
+
+ markState();
+ canvas_->endPlatformPaint();
+}
+
} // namespace TestShellWebTheme
diff --git a/webkit/tools/test_shell/test_shell_webthemecontrol.h b/webkit/tools/test_shell/test_shell_webthemecontrol.h
index bb439af..ddb8633 100644
--- a/webkit/tools/test_shell/test_shell_webthemecontrol.h
+++ b/webkit/tools/test_shell/test_shell_webthemecontrol.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -43,6 +43,7 @@ class Control {
// Focused - when the control has the keyboard focus
// Pressed - when the control is being triggered (by a mousedown or
// a key event).
+ // Indeterminate - when set to indeterminate (only for progress bar)
enum State {
kUnknown_State = 0,
kDisabled_State,
@@ -51,7 +52,8 @@ class Control {
kHot_State,
kHover_State,
kFocused_State,
- kPressed_State
+ kPressed_State,
+ kIndeterminate_State
};
// This list of types mostly mirrors the list in
@@ -86,12 +88,13 @@ class Control {
kDownArrow_Type,
kHorizontalSliderTrack_Type,
kHorizontalSliderThumb_Type,
- kDropDownButton_Type
+ kDropDownButton_Type,
+ kProgressBar_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,
+ Control(skia::PlatformCanvas* canvas, const SkIRect& rect,
Type ctype, State cstate);
~Control();
@@ -104,10 +107,14 @@ class Control {
// fill_content_area is true, fill the content area with the given color.
void drawTextField(bool draw_edges, bool fill_content_area, SkColor color);
+ // Use this for drawing ProgressBar controls instead, since we
+ // need to know the rect to fill inside the bar.
+ void drawProgressBar(const SkIRect& fill_rect);
+
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);
+ void box(const SkIRect& irect, SkColor color);
// Draws a triangle of size specified by the three pairs of coordinates,
diff --git a/webkit/tools/test_shell/test_shell_webthemeengine.cc b/webkit/tools/test_shell/test_shell_webthemeengine.cc
index b9e0308..8c457a8 100644
--- a/webkit/tools/test_shell/test_shell_webthemeengine.cc
+++ b/webkit/tools/test_shell/test_shell_webthemeengine.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -40,26 +40,33 @@ using WebKit::WebRect;
namespace TestShellWebTheme {
-SkIRect webRectToSkIRect(const WebRect &web_rect) {
+SkIRect webRectToSkIRect(const WebRect& web_rect) {
SkIRect irect;
irect.set(web_rect.x, web_rect.y, web_rect.x + web_rect.width,
web_rect.y + web_rect.height);
return irect;
}
-void drawControl(WebCanvas *canvas, const WebRect &rect, Control::Type ctype,
+void drawControl(WebCanvas* canvas, const WebRect& rect, Control::Type ctype,
Control::State cstate) {
Control control(canvas, webRectToSkIRect(rect), ctype, cstate);
control.draw();
}
-void drawTextField(WebCanvas *canvas, const WebRect &rect,
+void drawTextField(WebCanvas* canvas, const WebRect& rect,
Control::Type ctype, Control::State cstate,
bool draw_edges, bool fill_content_area, WebColor color) {
Control control(canvas, webRectToSkIRect(rect), ctype, cstate);
control.drawTextField(draw_edges, fill_content_area, color);
}
+void drawProgressBar(WebCanvas* canvas,
+ Control::Type ctype, Control::State cstate,
+ const WebRect& bar_rect, const WebRect& fill_rect) {
+ Control control(canvas, webRectToSkIRect(bar_rect), ctype, cstate);
+ control.drawProgressBar(webRectToSkIRect(fill_rect));
+}
+
void Engine::paintButton(WebCanvas* canvas, int part, int state,
int classic_state, const WebRect& rect) {
Control::Type ctype = Control::kUnknown_Type;
@@ -533,4 +540,14 @@ void Engine::paintTrackbar(WebCanvas* canvas, int part, int state,
drawControl(canvas, rect, ctype, cstate);
}
+
+void Engine::paintProgressBar(WebKit::WebCanvas* canvas,
+ const WebKit::WebRect& barRect,
+ int valuePart, const WebKit::WebRect& valueRect) {
+ Control::Type ctype = Control::kProgressBar_Type;
+ Control::State cstate = valuePart == PP_FILL ?
+ Control::kNormal_State : Control::kIndeterminate_State;
+ drawProgressBar(canvas, ctype, cstate, barRect, valueRect);
+}
+
} // namespace TestShellWebTheme
diff --git a/webkit/tools/test_shell/test_shell_webthemeengine.h b/webkit/tools/test_shell/test_shell_webthemeengine.h
index 6983b01..2d4223d 100644
--- a/webkit/tools/test_shell/test_shell_webthemeengine.h
+++ b/webkit/tools/test_shell/test_shell_webthemeengine.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -53,6 +53,10 @@ class Engine : public WebKit::WebThemeEngine {
virtual void paintTrackbar(
WebKit::WebCanvas*, int part, int state, int classic_state,
const WebKit::WebRect&);
+ virtual void paintProgressBar(
+ WebKit::WebCanvas*,
+ const WebKit::WebRect& barRect,
+ int valuePart, const WebKit::WebRect& valueRect);
private:
DISALLOW_COPY_AND_ASSIGN(Engine);