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

Unified Diff: gfx/native_theme_win.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gfx/native_theme_win.h ('k') | webkit/glue/webthemeengine_impl_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gfx/native_theme_win.cc
diff --git a/gfx/native_theme_win.cc b/gfx/native_theme_win.cc
index ec70b2f8504fa5a258ba086316f87b29a742b0d5..07deec1796ed1ba1fef5aa283eb8dba250f703dc 100644
--- a/gfx/native_theme_win.cc
+++ b/gfx/native_theme_win.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.
@@ -478,6 +478,56 @@ HRESULT NativeTheme::PaintTrackbar(HDC hdc,
return S_OK;
}
+// A ScopedRegion wrapper to set/restore clipping region during the scope.
+class ScopedRegionClipping {
Peter Kasting 2010/05/14 18:08:11 Nit: This would be clearer as "ScopedClipRegion"
+ public:
+ explicit ScopedRegionClipping(const HDC hdc)
+ : hdc_(hdc), clip_(NULL) {
+ RECT zero_rect = { 0 };
+ clip_ = CreateRectRgnIndirect(&zero_rect);
+ GetClipRgn(hdc_, clip_);
+ }
+
+ ~ScopedRegionClipping() {
+ SelectClipRgn(hdc_, clip_);
+ }
+
+ private:
+ HDC hdc_;
+ ScopedRegion clip_;
+ DISALLOW_COPY_AND_ASSIGN(ScopedRegionClipping);
+};
+
+HRESULT NativeTheme::PaintProgressBar(HDC hdc,
+ RECT* bar_rect,
+ int value_part_id,
+ RECT* value_rect,
+ skia::PlatformCanvas* canvas) const {
+ // For an indeterminate progress bar, we draw a moving highlight that's animated
Peter Kasting 2010/05/14 18:08:11 Nit: Sorry, I gave you a set of comments that were
+ // (by the caller) across the width of the bar. The highlight part is always
+ // drawn as being as wide as the bar, to scale it properly. Therefore, we need
+ // to clip it against the bar rect, so that as it moves, it doesn't extend past
+ // the ends of the bar. For a normal progress bar, we won't try to draw past
+ // the bar ends, so this clipping is useless, but harmless.
+ ScopedRegionClipping clip(hdc);
+ IntersectClipRect(hdc, bar_rect->left, bar_rect->top,
+ bar_rect->right, bar_rect->bottom);
+
+ HANDLE handle = GetThemeHandle(PROGRESS);
+ if (handle && draw_theme_) {
+ draw_theme_(handle, hdc, PP_BAR, 0, bar_rect, NULL);
+ draw_theme_(handle, hdc, value_part_id, 0, value_rect, NULL);
+ return S_OK;
+ }
+
+ HBRUSH bg_brush = GetSysColorBrush(COLOR_BTNFACE);
+ HBRUSH fg_brush = GetSysColorBrush(COLOR_BTNSHADOW);
+ FillRect(hdc, bar_rect, bg_brush);
+ FillRect(hdc, value_rect, fg_brush);
+ DrawEdge(hdc, bar_rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
+ return S_OK;
+}
+
HRESULT NativeTheme::PaintTextField(HDC hdc,
int part_id,
int state_id,
@@ -707,6 +757,9 @@ HANDLE NativeTheme::GetThemeHandle(ThemeName theme_name) const
case WINDOW:
handle = open_theme_(NULL, L"Window");
break;
+ case PROGRESS:
+ handle = open_theme_(NULL, L"Progress");
+ break;
default:
NOTREACHED();
}
« no previous file with comments | « gfx/native_theme_win.h ('k') | webkit/glue/webthemeengine_impl_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698