OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 #include "ui/native_theme/native_theme_aurawin.h" | |
6 | |
7 #include "third_party/skia/include/core/SkCanvas.h" | |
8 #include "ui/native_theme/common_theme.h" | |
9 #include "ui/native_theme/native_theme_win.h" | |
10 | |
11 namespace ui { | |
12 | |
13 namespace { | |
14 | |
15 bool IsScrollbarPart(NativeTheme::Part part) { | |
16 switch (part) { | |
17 case NativeTheme::kScrollbarDownArrow: | |
18 case NativeTheme::kScrollbarLeftArrow: | |
19 case NativeTheme::kScrollbarRightArrow: | |
20 case NativeTheme::kScrollbarUpArrow: | |
21 case NativeTheme::kScrollbarHorizontalThumb: | |
22 case NativeTheme::kScrollbarVerticalThumb: | |
23 case NativeTheme::kScrollbarHorizontalTrack: | |
24 case NativeTheme::kScrollbarVerticalTrack: | |
25 case NativeTheme::kScrollbarHorizontalGripper: | |
26 case NativeTheme::kScrollbarVerticalGripper: | |
27 case NativeTheme::kScrollbarCorner: | |
28 return true; | |
29 default: | |
30 return false; | |
31 } | |
32 } | |
33 | |
34 } // namespace | |
35 | |
36 // static | |
37 NativeTheme* NativeTheme::GetInstanceForWeb() { | |
38 return NativeThemeAuraWin::instance(); | |
39 } | |
40 | |
41 // static | |
42 NativeThemeAura* NativeThemeAura::instance() { | |
43 return NativeThemeAuraWin::instance(); | |
44 } | |
45 | |
46 // static | |
47 NativeThemeAuraWin* NativeThemeAuraWin::instance() { | |
48 CR_DEFINE_STATIC_LOCAL(NativeThemeAuraWin, s_native_theme, ()); | |
49 return &s_native_theme; | |
50 } | |
51 | |
52 NativeThemeAuraWin::NativeThemeAuraWin() { | |
53 } | |
54 | |
55 NativeThemeAuraWin::~NativeThemeAuraWin() { | |
56 } | |
57 | |
58 void NativeThemeAuraWin::Paint(SkCanvas* canvas, | |
59 Part part, | |
60 State state, | |
61 const gfx::Rect& rect, | |
62 const ExtraParams& extra) const { | |
63 if (IsScrollbarPart(part) && | |
64 NativeThemeWin::instance()->IsUsingHighContrastTheme()) { | |
65 NativeThemeWin::instance()->Paint(canvas, part, state, rect, extra); | |
66 return; | |
67 } | |
68 | |
69 NativeThemeAura::Paint(canvas, part, state, rect, extra); | |
70 } | |
71 | |
72 gfx::Size NativeThemeAuraWin::GetPartSize(Part part, | |
73 State state, | |
74 const ExtraParams& extra) const { | |
75 // We want aura on windows to use the same size for scrollbars as we would in | |
76 // the native theme. | |
77 if (IsScrollbarPart(part)) | |
78 return NativeThemeWin::instance()->GetPartSize(part, state, extra); | |
79 | |
80 return NativeThemeAura::GetPartSize(part, state, extra); | |
81 } | |
82 | |
83 } // namespace ui | |
OLD | NEW |