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

Unified Diff: gfx/native_theme_win.cc

Issue 1596018: Added support for HTML5 progress element. (Closed)
Patch Set: just sync the change of webkit side. Created 10 years, 8 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 87024d3a68083a0642751c0da5221c90dbee6a37..4a91a6d4571af2848c5192568b01f4837d31a1ac 100644
--- a/gfx/native_theme_win.cc
+++ b/gfx/native_theme_win.cc
@@ -59,7 +59,8 @@ const NativeTheme* NativeTheme::instance() {
}
NativeTheme::NativeTheme()
- : theme_dll_(LoadLibrary(L"uxtheme.dll")),
+ : theme_dll_(LoadLibrary(L"uxtheme.dll")),
+ clip_(NULL),
draw_theme_(NULL),
draw_theme_ex_(NULL),
get_theme_color_(NULL),
@@ -101,6 +102,9 @@ NativeTheme::~NativeTheme() {
// CloseHandles();
FreeLibrary(theme_dll_);
}
+
+ if (clip_)
+ DeleteObject(clip_);
}
HRESULT NativeTheme::PaintButton(HDC hdc,
@@ -478,6 +482,38 @@ HRESULT NativeTheme::PaintTrackbar(HDC hdc,
return S_OK;
}
+HRESULT NativeTheme::PaintProgressBar(HDC hdc,
+ RECT* bar_rect,
+ int value_part_id,
+ RECT* value_rect,
+ skia::PlatformCanvas* canvas) const {
+
+ // We need to clip painting because the value theme
+ // for indeterminate overflows bar rectangle.
+ HRGN clip = GetClipHandle();
+ GetClipRgn(hdc, clip);
+ 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);
+
+ SelectClipRgn(hdc, clip);
+ 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);
+
+ SelectClipRgn(hdc, clip);
+ return S_OK;
+}
+
HRESULT NativeTheme::PaintTextField(HDC hdc,
int part_id,
int state_id,
@@ -659,6 +695,17 @@ void NativeTheme::CloseHandles() const
}
}
+HRGN NativeTheme::GetClipHandle() const {
+ if (!clip_) {
+ RECT dummy_rect;
+ dummy_rect.left = dummy_rect.right = 0;
+ dummy_rect.top = dummy_rect.bottom = 0;
+ clip_ = CreateRectRgnIndirect(&dummy_rect);
+ }
+
+ return clip_;
+}
+
HANDLE NativeTheme::GetThemeHandle(ThemeName theme_name) const
{
if (!open_theme_ || theme_name < 0 || theme_name >= LAST)
@@ -700,6 +747,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