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 "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
11 #include "ui/native_theme/native_theme.h" | 12 #include "ui/native_theme/native_theme.h" |
12 #include "ui/native_theme/overlay_scrollbar_constants_aura.h" | 13 #include "ui/native_theme/overlay_scrollbar_constants_aura.h" |
13 | 14 |
14 using blink::WebCanvas; | 15 using blink::WebCanvas; |
15 using blink::WebColor; | 16 using blink::WebColor; |
16 using blink::WebRect; | 17 using blink::WebRect; |
17 using blink::WebThemeEngine; | 18 using blink::WebThemeEngine; |
18 using blink::WebScrollbarOverlayColorTheme; | 19 using blink::WebScrollbarOverlayColorTheme; |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 namespace { | 22 namespace { |
22 | 23 |
23 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
24 // The width of a vertical scroll bar in dips. | 25 // The width of a vertical scroll bar in dips. |
25 int32_t g_vertical_scroll_bar_width; | 26 int32_t g_vertical_scroll_bar_width; |
26 | 27 |
27 // The height of a horizontal scroll bar in dips. | 28 // The height of a horizontal scroll bar in dips. |
28 int32_t g_horizontal_scroll_bar_height; | 29 int32_t g_horizontal_scroll_bar_height; |
29 | 30 |
30 // The height of the arrow bitmap on a vertical scroll bar in dips. | 31 // The height of the arrow bitmap on a vertical scroll bar in dips. |
31 int32_t g_vertical_arrow_bitmap_height; | 32 int32_t g_vertical_arrow_bitmap_height; |
32 | 33 |
33 // The width of the arrow bitmap on a horizontal scroll bar in dips. | 34 // The width of the arrow bitmap on a horizontal scroll bar in dips. |
34 int32_t g_horizontal_arrow_bitmap_width; | 35 int32_t g_horizontal_arrow_bitmap_width; |
35 #endif | 36 #endif |
36 | 37 |
| 38 ui::NativeTheme* nativeThemeInstance() { |
| 39 return ui::NativeTheme::GetInstanceForWeb( |
| 40 blink::WebRuntimeFeatures::isOverlayScrollbarsEnabled()); |
| 41 } |
| 42 |
37 } // namespace | 43 } // namespace |
38 | 44 |
39 static ui::NativeTheme::Part NativeThemePart( | 45 static ui::NativeTheme::Part NativeThemePart( |
40 WebThemeEngine::Part part) { | 46 WebThemeEngine::Part part) { |
41 switch (part) { | 47 switch (part) { |
42 case WebThemeEngine::PartScrollbarDownArrow: | 48 case WebThemeEngine::PartScrollbarDownArrow: |
43 return ui::NativeTheme::kScrollbarDownArrow; | 49 return ui::NativeTheme::kScrollbarDownArrow; |
44 case WebThemeEngine::PartScrollbarLeftArrow: | 50 case WebThemeEngine::PartScrollbarLeftArrow: |
45 return ui::NativeTheme::kScrollbarLeftArrow; | 51 return ui::NativeTheme::kScrollbarLeftArrow; |
46 case WebThemeEngine::PartScrollbarRightArrow: | 52 case WebThemeEngine::PartScrollbarRightArrow: |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 case ui::NativeTheme::kScrollbarHorizontalTrack: | 225 case ui::NativeTheme::kScrollbarHorizontalTrack: |
220 case ui::NativeTheme::kScrollbarVerticalTrack: { | 226 case ui::NativeTheme::kScrollbarVerticalTrack: { |
221 return gfx::Size(g_vertical_scroll_bar_width, | 227 return gfx::Size(g_vertical_scroll_bar_width, |
222 g_vertical_scroll_bar_width); | 228 g_vertical_scroll_bar_width); |
223 } | 229 } |
224 | 230 |
225 default: | 231 default: |
226 break; | 232 break; |
227 } | 233 } |
228 #endif | 234 #endif |
229 return ui::NativeTheme::GetInstanceForWeb()->GetPartSize( | 235 return nativeThemeInstance()->GetPartSize( |
230 native_theme_part, ui::NativeTheme::kNormal, extra); | 236 native_theme_part, ui::NativeTheme::kNormal, extra); |
231 } | 237 } |
232 | 238 |
233 void WebThemeEngineImpl::paint( | 239 void WebThemeEngineImpl::paint( |
234 blink::WebCanvas* canvas, | 240 blink::WebCanvas* canvas, |
235 WebThemeEngine::Part part, | 241 WebThemeEngine::Part part, |
236 WebThemeEngine::State state, | 242 WebThemeEngine::State state, |
237 const blink::WebRect& rect, | 243 const blink::WebRect& rect, |
238 const WebThemeEngine::ExtraParams* extra_params) { | 244 const WebThemeEngine::ExtraParams* extra_params) { |
239 ui::NativeTheme::ExtraParams native_theme_extra_params; | 245 ui::NativeTheme::ExtraParams native_theme_extra_params; |
240 GetNativeThemeExtraParams( | 246 GetNativeThemeExtraParams( |
241 part, state, extra_params, &native_theme_extra_params); | 247 part, state, extra_params, &native_theme_extra_params); |
242 ui::NativeTheme::GetInstanceForWeb()->Paint( | 248 nativeThemeInstance()->Paint( |
243 canvas, NativeThemePart(part), NativeThemeState(state), gfx::Rect(rect), | 249 canvas, NativeThemePart(part), NativeThemeState(state), gfx::Rect(rect), |
244 native_theme_extra_params); | 250 native_theme_extra_params); |
245 } | 251 } |
246 | 252 |
247 void WebThemeEngineImpl::getOverlayScrollbarStyle(ScrollbarStyle* style) { | 253 void WebThemeEngineImpl::getOverlayScrollbarStyle(ScrollbarStyle* style) { |
248 style->fadeOutDelaySeconds = ui::kOverlayScrollbarFadeOutDelay.InSecondsF(); | 254 style->fadeOutDelaySeconds = ui::kOverlayScrollbarFadeOutDelay.InSecondsF(); |
249 style->fadeOutDurationSeconds = | 255 style->fadeOutDurationSeconds = |
250 ui::kOverlayScrollbarFadeOutDuration.InSecondsF(); | 256 ui::kOverlayScrollbarFadeOutDuration.InSecondsF(); |
251 // The other fields in this struct are used only on Android to draw solid | 257 // The other fields in this struct are used only on Android to draw solid |
252 // color scrollbars. On other platforms the scrollbars are painted in | 258 // color scrollbars. On other platforms the scrollbars are painted in |
253 // NativeTheme so these fields are unused. | 259 // NativeTheme so these fields are unused. |
254 } | 260 } |
255 | 261 |
256 #if defined(OS_WIN) | 262 #if defined(OS_WIN) |
257 // static | 263 // static |
258 void WebThemeEngineImpl::cacheScrollBarMetrics( | 264 void WebThemeEngineImpl::cacheScrollBarMetrics( |
259 int32_t vertical_scroll_bar_width, | 265 int32_t vertical_scroll_bar_width, |
260 int32_t horizontal_scroll_bar_height, | 266 int32_t horizontal_scroll_bar_height, |
261 int32_t vertical_arrow_bitmap_height, | 267 int32_t vertical_arrow_bitmap_height, |
262 int32_t horizontal_arrow_bitmap_width) { | 268 int32_t horizontal_arrow_bitmap_width) { |
263 g_vertical_scroll_bar_width = vertical_scroll_bar_width; | 269 g_vertical_scroll_bar_width = vertical_scroll_bar_width; |
264 g_horizontal_scroll_bar_height = horizontal_scroll_bar_height; | 270 g_horizontal_scroll_bar_height = horizontal_scroll_bar_height; |
265 g_vertical_arrow_bitmap_height = vertical_arrow_bitmap_height; | 271 g_vertical_arrow_bitmap_height = vertical_arrow_bitmap_height; |
266 g_horizontal_arrow_bitmap_width = horizontal_arrow_bitmap_width; | 272 g_horizontal_arrow_bitmap_width = horizontal_arrow_bitmap_width; |
267 } | 273 } |
268 #endif | 274 #endif |
269 | 275 |
270 } // namespace content | 276 } // namespace content |
OLD | NEW |