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 "content/child/webthemeengine_impl_default.h" | 5 #include "content/child/webthemeengine_impl_default.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "skia/ext/platform_canvas.h" | 8 #include "skia/ext/platform_canvas.h" |
9 #include "third_party/WebKit/public/platform/WebRect.h" | 9 #include "third_party/WebKit/public/platform/WebRect.h" |
10 #include "third_party/WebKit/public/platform/WebSize.h" | 10 #include "third_party/WebKit/public/platform/WebSize.h" |
11 #include "ui/native_theme/native_theme.h" | |
12 | 11 |
13 using blink::WebCanvas; | 12 using blink::WebCanvas; |
14 using blink::WebColor; | 13 using blink::WebColor; |
15 using blink::WebRect; | 14 using blink::WebRect; |
16 using blink::WebThemeEngine; | 15 using blink::WebThemeEngine; |
16 using blink::WebScrollbarOverlayColorTheme; | |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 namespace { | 19 namespace { |
20 | 20 |
21 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
22 // The width of a vertical scroll bar in dips. | 22 // The width of a vertical scroll bar in dips. |
23 int32_t g_vertical_scroll_bar_width; | 23 int32_t g_vertical_scroll_bar_width; |
24 | 24 |
25 // The height of a horizontal scroll bar in dips. | 25 // The height of a horizontal scroll bar in dips. |
26 int32_t g_horizontal_scroll_bar_height; | 26 int32_t g_horizontal_scroll_bar_height; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 return ui::NativeTheme::kSliderThumb; | 71 return ui::NativeTheme::kSliderThumb; |
72 case WebThemeEngine::PartInnerSpinButton: | 72 case WebThemeEngine::PartInnerSpinButton: |
73 return ui::NativeTheme::kInnerSpinButton; | 73 return ui::NativeTheme::kInnerSpinButton; |
74 case WebThemeEngine::PartProgressBar: | 74 case WebThemeEngine::PartProgressBar: |
75 return ui::NativeTheme::kProgressBar; | 75 return ui::NativeTheme::kProgressBar; |
76 default: | 76 default: |
77 return ui::NativeTheme::kScrollbarDownArrow; | 77 return ui::NativeTheme::kScrollbarDownArrow; |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 static ui::NativeTheme::ScrollbarOverlayColorTheme | |
82 NativeThemeScrollbarOverlayColorTheme(WebScrollbarOverlayColorTheme theme) { | |
83 switch (theme) { | |
84 case WebScrollbarOverlayColorTheme::WebScrollbarOverlayColorThemeDefault: | |
85 return ui::NativeTheme::ScrollbarOverlayColorThemeDefault; | |
86 case WebScrollbarOverlayColorTheme::WebScrollbarOverlayColorThemeLight: | |
87 return ui::NativeTheme::ScrollbarOverlayColorThemeLight; | |
88 case WebScrollbarOverlayColorTheme::WebScrollbarOverlayColorThemeDark: | |
89 return ui::NativeTheme::ScrollbarOverlayColorThemeDark; | |
90 default: | |
91 return ui::NativeTheme::ScrollbarOverlayColorThemeDefault; | |
92 } | |
93 } | |
94 | |
81 static ui::NativeTheme::State NativeThemeState( | 95 static ui::NativeTheme::State NativeThemeState( |
82 WebThemeEngine::State state) { | 96 WebThemeEngine::State state) { |
83 switch (state) { | 97 switch (state) { |
84 case WebThemeEngine::StateDisabled: | 98 case WebThemeEngine::StateDisabled: |
85 return ui::NativeTheme::kDisabled; | 99 return ui::NativeTheme::kDisabled; |
86 case WebThemeEngine::StateHover: | 100 case WebThemeEngine::StateHover: |
87 return ui::NativeTheme::kHovered; | 101 return ui::NativeTheme::kHovered; |
88 case WebThemeEngine::StateNormal: | 102 case WebThemeEngine::StateNormal: |
89 return ui::NativeTheme::kNormal; | 103 return ui::NativeTheme::kNormal; |
90 case WebThemeEngine::StatePressed: | 104 case WebThemeEngine::StatePressed: |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 extra_params->progressBar.determinate; | 184 extra_params->progressBar.determinate; |
171 native_theme_extra_params->progress_bar.value_rect_x = | 185 native_theme_extra_params->progress_bar.value_rect_x = |
172 extra_params->progressBar.valueRectX; | 186 extra_params->progressBar.valueRectX; |
173 native_theme_extra_params->progress_bar.value_rect_y = | 187 native_theme_extra_params->progress_bar.value_rect_y = |
174 extra_params->progressBar.valueRectY; | 188 extra_params->progressBar.valueRectY; |
175 native_theme_extra_params->progress_bar.value_rect_width = | 189 native_theme_extra_params->progress_bar.value_rect_width = |
176 extra_params->progressBar.valueRectWidth; | 190 extra_params->progressBar.valueRectWidth; |
177 native_theme_extra_params->progress_bar.value_rect_height = | 191 native_theme_extra_params->progress_bar.value_rect_height = |
178 extra_params->progressBar.valueRectHeight; | 192 extra_params->progressBar.valueRectHeight; |
179 break; | 193 break; |
194 case WebThemeEngine::PartScrollbarHorizontalThumb: | |
195 case WebThemeEngine::PartScrollbarVerticalThumb: | |
196 native_theme_extra_params->scrollbar_thumb.scrollbar_theme = | |
197 static_cast<ui::NativeTheme::ScrollbarOverlayColorTheme>( | |
bokan
2016/10/21 20:11:38
use the NativeThemeScrollbarOverlayColorTheme func
| |
198 extra_params->scrollbarThumb.scrollbarTheme); | |
199 break; | |
180 default: | 200 default: |
181 break; // Parts that have no extra params get here. | 201 break; // Parts that have no extra params get here. |
182 } | 202 } |
183 } | 203 } |
184 | 204 |
185 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { | 205 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { |
186 ui::NativeTheme::ExtraParams extra; | 206 ui::NativeTheme::ExtraParams extra; |
187 ui::NativeTheme::Part native_theme_part = NativeThemePart(part); | 207 ui::NativeTheme::Part native_theme_part = NativeThemePart(part); |
188 #if defined(OS_WIN) | 208 #if defined(OS_WIN) |
189 switch (native_theme_part) { | 209 switch (native_theme_part) { |
(...skipping 24 matching lines...) Expand all Loading... | |
214 const blink::WebRect& rect, | 234 const blink::WebRect& rect, |
215 const WebThemeEngine::ExtraParams* extra_params) { | 235 const WebThemeEngine::ExtraParams* extra_params) { |
216 ui::NativeTheme::ExtraParams native_theme_extra_params; | 236 ui::NativeTheme::ExtraParams native_theme_extra_params; |
217 GetNativeThemeExtraParams( | 237 GetNativeThemeExtraParams( |
218 part, state, extra_params, &native_theme_extra_params); | 238 part, state, extra_params, &native_theme_extra_params); |
219 ui::NativeTheme::GetInstanceForWeb()->Paint( | 239 ui::NativeTheme::GetInstanceForWeb()->Paint( |
220 canvas, NativeThemePart(part), NativeThemeState(state), gfx::Rect(rect), | 240 canvas, NativeThemePart(part), NativeThemeState(state), gfx::Rect(rect), |
221 native_theme_extra_params); | 241 native_theme_extra_params); |
222 } | 242 } |
223 | 243 |
224 void WebThemeEngineImpl::paintStateTransition(blink::WebCanvas* canvas, | 244 void WebThemeEngineImpl::paintStateTransition( |
225 WebThemeEngine::Part part, | 245 blink::WebCanvas* canvas, |
226 WebThemeEngine::State startState, | 246 WebThemeEngine::Part part, |
227 WebThemeEngine::State endState, | 247 WebThemeEngine::State startState, |
228 double progress, | 248 WebThemeEngine::State endState, |
229 const blink::WebRect& rect) { | 249 double progress, |
250 const blink::WebRect& rect, | |
251 WebScrollbarOverlayColorTheme theme) { | |
230 ui::NativeTheme::GetInstanceForWeb()->PaintStateTransition( | 252 ui::NativeTheme::GetInstanceForWeb()->PaintStateTransition( |
231 canvas, NativeThemePart(part), NativeThemeState(startState), | 253 canvas, NativeThemePart(part), NativeThemeState(startState), |
232 NativeThemeState(endState), progress, gfx::Rect(rect)); | 254 NativeThemeState(endState), progress, gfx::Rect(rect), |
255 NativeThemeScrollbarOverlayColorTheme(theme)); | |
233 } | 256 } |
234 | 257 |
235 #if defined(OS_WIN) | 258 #if defined(OS_WIN) |
236 // static | 259 // static |
237 void WebThemeEngineImpl::cacheScrollBarMetrics( | 260 void WebThemeEngineImpl::cacheScrollBarMetrics( |
238 int32_t vertical_scroll_bar_width, | 261 int32_t vertical_scroll_bar_width, |
239 int32_t horizontal_scroll_bar_height, | 262 int32_t horizontal_scroll_bar_height, |
240 int32_t vertical_arrow_bitmap_height, | 263 int32_t vertical_arrow_bitmap_height, |
241 int32_t horizontal_arrow_bitmap_width) { | 264 int32_t horizontal_arrow_bitmap_width) { |
242 g_vertical_scroll_bar_width = vertical_scroll_bar_width; | 265 g_vertical_scroll_bar_width = vertical_scroll_bar_width; |
243 g_horizontal_scroll_bar_height = horizontal_scroll_bar_height; | 266 g_horizontal_scroll_bar_height = horizontal_scroll_bar_height; |
244 g_vertical_arrow_bitmap_height = vertical_arrow_bitmap_height; | 267 g_vertical_arrow_bitmap_height = vertical_arrow_bitmap_height; |
245 g_horizontal_arrow_bitmap_width = horizontal_arrow_bitmap_width; | 268 g_horizontal_arrow_bitmap_width = horizontal_arrow_bitmap_width; |
246 } | 269 } |
247 #endif | 270 #endif |
248 | 271 |
249 } // namespace content | 272 } // namespace content |
OLD | NEW |