OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/services/html_viewer/webthemeengine_impl.h" | 5 #include "mojo/services/html_viewer/webthemeengine_impl.h" |
6 | 6 |
7 #include "skia/ext/platform_canvas.h" | 7 #include "skia/ext/platform_canvas.h" |
8 #include "third_party/WebKit/public/platform/WebRect.h" | 8 #include "third_party/WebKit/public/platform/WebRect.h" |
9 #include "third_party/WebKit/public/platform/WebSize.h" | 9 #include "third_party/WebKit/public/platform/WebSize.h" |
10 #include "ui/native_theme/native_theme.h" | 10 #include "ui/native_theme/native_theme.h" |
11 | 11 |
12 using blink::WebCanvas; | 12 using blink::WebCanvas; |
13 using blink::WebColor; | 13 using blink::WebColor; |
14 using blink::WebRect; | 14 using blink::WebRect; |
15 using blink::WebThemeEngine; | 15 using blink::WebThemeEngine; |
16 | 16 |
17 namespace mojo { | 17 namespace html_viewer { |
| 18 namespace { |
18 | 19 |
19 static ui::NativeTheme::Part NativeThemePart( | 20 ui::NativeTheme::Part NativeThemePart(WebThemeEngine::Part part) { |
20 WebThemeEngine::Part part) { | |
21 switch (part) { | 21 switch (part) { |
22 case WebThemeEngine::PartScrollbarDownArrow: | 22 case WebThemeEngine::PartScrollbarDownArrow: |
23 return ui::NativeTheme::kScrollbarDownArrow; | 23 return ui::NativeTheme::kScrollbarDownArrow; |
24 case WebThemeEngine::PartScrollbarLeftArrow: | 24 case WebThemeEngine::PartScrollbarLeftArrow: |
25 return ui::NativeTheme::kScrollbarLeftArrow; | 25 return ui::NativeTheme::kScrollbarLeftArrow; |
26 case WebThemeEngine::PartScrollbarRightArrow: | 26 case WebThemeEngine::PartScrollbarRightArrow: |
27 return ui::NativeTheme::kScrollbarRightArrow; | 27 return ui::NativeTheme::kScrollbarRightArrow; |
28 case WebThemeEngine::PartScrollbarUpArrow: | 28 case WebThemeEngine::PartScrollbarUpArrow: |
29 return ui::NativeTheme::kScrollbarUpArrow; | 29 return ui::NativeTheme::kScrollbarUpArrow; |
30 case WebThemeEngine::PartScrollbarHorizontalThumb: | 30 case WebThemeEngine::PartScrollbarHorizontalThumb: |
(...skipping 22 matching lines...) Expand all Loading... |
53 return ui::NativeTheme::kSliderThumb; | 53 return ui::NativeTheme::kSliderThumb; |
54 case WebThemeEngine::PartInnerSpinButton: | 54 case WebThemeEngine::PartInnerSpinButton: |
55 return ui::NativeTheme::kInnerSpinButton; | 55 return ui::NativeTheme::kInnerSpinButton; |
56 case WebThemeEngine::PartProgressBar: | 56 case WebThemeEngine::PartProgressBar: |
57 return ui::NativeTheme::kProgressBar; | 57 return ui::NativeTheme::kProgressBar; |
58 default: | 58 default: |
59 return ui::NativeTheme::kScrollbarDownArrow; | 59 return ui::NativeTheme::kScrollbarDownArrow; |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 static ui::NativeTheme::State NativeThemeState( | 63 ui::NativeTheme::State NativeThemeState(WebThemeEngine::State state) { |
64 WebThemeEngine::State state) { | |
65 switch (state) { | 64 switch (state) { |
66 case WebThemeEngine::StateDisabled: | 65 case WebThemeEngine::StateDisabled: |
67 return ui::NativeTheme::kDisabled; | 66 return ui::NativeTheme::kDisabled; |
68 case WebThemeEngine::StateHover: | 67 case WebThemeEngine::StateHover: |
69 return ui::NativeTheme::kHovered; | 68 return ui::NativeTheme::kHovered; |
70 case WebThemeEngine::StateNormal: | 69 case WebThemeEngine::StateNormal: |
71 return ui::NativeTheme::kNormal; | 70 return ui::NativeTheme::kNormal; |
72 case WebThemeEngine::StatePressed: | 71 case WebThemeEngine::StatePressed: |
73 return ui::NativeTheme::kPressed; | 72 return ui::NativeTheme::kPressed; |
74 default: | 73 default: |
75 return ui::NativeTheme::kDisabled; | 74 return ui::NativeTheme::kDisabled; |
76 } | 75 } |
77 } | 76 } |
78 | 77 |
79 static void GetNativeThemeExtraParams( | 78 void GetNativeThemeExtraParams( |
80 WebThemeEngine::Part part, | 79 WebThemeEngine::Part part, |
81 WebThemeEngine::State state, | 80 WebThemeEngine::State state, |
82 const WebThemeEngine::ExtraParams* extra_params, | 81 const WebThemeEngine::ExtraParams* extra_params, |
83 ui::NativeTheme::ExtraParams* native_theme_extra_params) { | 82 ui::NativeTheme::ExtraParams* native_theme_extra_params) { |
84 switch (part) { | 83 switch (part) { |
85 case WebThemeEngine::PartScrollbarHorizontalTrack: | 84 case WebThemeEngine::PartScrollbarHorizontalTrack: |
86 case WebThemeEngine::PartScrollbarVerticalTrack: | 85 case WebThemeEngine::PartScrollbarVerticalTrack: |
87 native_theme_extra_params->scrollbar_track.track_x = | 86 native_theme_extra_params->scrollbar_track.track_x = |
88 extra_params->scrollbarTrack.trackX; | 87 extra_params->scrollbarTrack.trackX; |
89 native_theme_extra_params->scrollbar_track.track_y = | 88 native_theme_extra_params->scrollbar_track.track_y = |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 native_theme_extra_params->progress_bar.value_rect_width = | 152 native_theme_extra_params->progress_bar.value_rect_width = |
154 extra_params->progressBar.valueRectWidth; | 153 extra_params->progressBar.valueRectWidth; |
155 native_theme_extra_params->progress_bar.value_rect_height = | 154 native_theme_extra_params->progress_bar.value_rect_height = |
156 extra_params->progressBar.valueRectHeight; | 155 extra_params->progressBar.valueRectHeight; |
157 break; | 156 break; |
158 default: | 157 default: |
159 break; // Parts that have no extra params get here. | 158 break; // Parts that have no extra params get here. |
160 } | 159 } |
161 } | 160 } |
162 | 161 |
| 162 } // namespace |
| 163 |
163 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { | 164 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { |
164 ui::NativeTheme::ExtraParams extra; | 165 ui::NativeTheme::ExtraParams extra; |
165 return ui::NativeTheme::instance()->GetPartSize(NativeThemePart(part), | 166 return ui::NativeTheme::instance()->GetPartSize(NativeThemePart(part), |
166 ui::NativeTheme::kNormal, | 167 ui::NativeTheme::kNormal, |
167 extra); | 168 extra); |
168 } | 169 } |
169 | 170 |
170 void WebThemeEngineImpl::paint( | 171 void WebThemeEngineImpl::paint( |
171 blink::WebCanvas* canvas, | 172 blink::WebCanvas* canvas, |
172 WebThemeEngine::Part part, | 173 WebThemeEngine::Part part, |
(...skipping 19 matching lines...) Expand all Loading... |
192 const blink::WebRect& rect) { | 193 const blink::WebRect& rect) { |
193 ui::NativeTheme::instance()->PaintStateTransition( | 194 ui::NativeTheme::instance()->PaintStateTransition( |
194 canvas, | 195 canvas, |
195 NativeThemePart(part), | 196 NativeThemePart(part), |
196 NativeThemeState(startState), | 197 NativeThemeState(startState), |
197 NativeThemeState(endState), | 198 NativeThemeState(endState), |
198 progress, | 199 progress, |
199 gfx::Rect(rect)); | 200 gfx::Rect(rect)); |
200 } | 201 } |
201 | 202 |
202 } // namespace mojo | 203 } // namespace html_viewer |
OLD | NEW |