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 "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 content { | 17 namespace content { |
| 18 namespace { |
| 19 |
| 20 #if defined(OS_WIN) |
| 21 // The scrollbar metrics default to 17 dips which is the default value on |
| 22 // Windows in most cases. |
| 23 int32 g_vertical_scroll_bar_width = 17; |
| 24 |
| 25 // The height of a horizontal scroll bar in dips. |
| 26 int32 g_horizontal_scroll_bar_height = 17; |
| 27 |
| 28 // The height of the arrow bitmap on a vertical scroll bar in dips. |
| 29 int32 g_vertical_arrow_bitmap_height = 17; |
| 30 |
| 31 // The width of the arrow bitmap on a horizontal scroll bar in dips. |
| 32 int32 g_horizontal_arrow_bitmap_width = 17; |
| 33 #endif |
| 34 |
| 35 } // namespace |
18 | 36 |
19 static ui::NativeTheme::Part NativeThemePart( | 37 static ui::NativeTheme::Part NativeThemePart( |
20 WebThemeEngine::Part part) { | 38 WebThemeEngine::Part part) { |
21 switch (part) { | 39 switch (part) { |
22 case WebThemeEngine::PartScrollbarDownArrow: | 40 case WebThemeEngine::PartScrollbarDownArrow: |
23 return ui::NativeTheme::kScrollbarDownArrow; | 41 return ui::NativeTheme::kScrollbarDownArrow; |
24 case WebThemeEngine::PartScrollbarLeftArrow: | 42 case WebThemeEngine::PartScrollbarLeftArrow: |
25 return ui::NativeTheme::kScrollbarLeftArrow; | 43 return ui::NativeTheme::kScrollbarLeftArrow; |
26 case WebThemeEngine::PartScrollbarRightArrow: | 44 case WebThemeEngine::PartScrollbarRightArrow: |
27 return ui::NativeTheme::kScrollbarRightArrow; | 45 return ui::NativeTheme::kScrollbarRightArrow; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 native_theme_extra_params->progress_bar.value_rect_height = | 173 native_theme_extra_params->progress_bar.value_rect_height = |
156 extra_params->progressBar.valueRectHeight; | 174 extra_params->progressBar.valueRectHeight; |
157 break; | 175 break; |
158 default: | 176 default: |
159 break; // Parts that have no extra params get here. | 177 break; // Parts that have no extra params get here. |
160 } | 178 } |
161 } | 179 } |
162 | 180 |
163 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { | 181 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { |
164 ui::NativeTheme::ExtraParams extra; | 182 ui::NativeTheme::ExtraParams extra; |
165 return ui::NativeTheme::instance()->GetPartSize(NativeThemePart(part), | 183 ui::NativeTheme::Part native_theme_part = NativeThemePart(part); |
166 ui::NativeTheme::kNormal, | 184 #if defined(OS_WIN) |
167 extra); | 185 switch (native_theme_part) { |
| 186 case ui::NativeTheme::kScrollbarDownArrow: |
| 187 case ui::NativeTheme::kScrollbarLeftArrow: |
| 188 case ui::NativeTheme::kScrollbarRightArrow: |
| 189 case ui::NativeTheme::kScrollbarUpArrow: |
| 190 case ui::NativeTheme::kScrollbarHorizontalThumb: |
| 191 case ui::NativeTheme::kScrollbarVerticalThumb: |
| 192 case ui::NativeTheme::kScrollbarHorizontalTrack: |
| 193 case ui::NativeTheme::kScrollbarVerticalTrack: { |
| 194 return gfx::Size(g_vertical_scroll_bar_width, |
| 195 g_vertical_scroll_bar_width); |
| 196 } |
| 197 |
| 198 default: |
| 199 break; |
| 200 } |
| 201 #endif |
| 202 return ui::NativeTheme::instance()->GetPartSize(native_theme_part, |
| 203 ui::NativeTheme::kNormal, |
| 204 extra); |
168 } | 205 } |
169 | 206 |
170 void WebThemeEngineImpl::paint( | 207 void WebThemeEngineImpl::paint( |
171 blink::WebCanvas* canvas, | 208 blink::WebCanvas* canvas, |
172 WebThemeEngine::Part part, | 209 WebThemeEngine::Part part, |
173 WebThemeEngine::State state, | 210 WebThemeEngine::State state, |
174 const blink::WebRect& rect, | 211 const blink::WebRect& rect, |
175 const WebThemeEngine::ExtraParams* extra_params) { | 212 const WebThemeEngine::ExtraParams* extra_params) { |
176 ui::NativeTheme::ExtraParams native_theme_extra_params; | 213 ui::NativeTheme::ExtraParams native_theme_extra_params; |
177 GetNativeThemeExtraParams( | 214 GetNativeThemeExtraParams( |
(...skipping 14 matching lines...) Expand all Loading... |
192 const blink::WebRect& rect) { | 229 const blink::WebRect& rect) { |
193 ui::NativeTheme::instance()->PaintStateTransition( | 230 ui::NativeTheme::instance()->PaintStateTransition( |
194 canvas, | 231 canvas, |
195 NativeThemePart(part), | 232 NativeThemePart(part), |
196 NativeThemeState(startState), | 233 NativeThemeState(startState), |
197 NativeThemeState(endState), | 234 NativeThemeState(endState), |
198 progress, | 235 progress, |
199 gfx::Rect(rect)); | 236 gfx::Rect(rect)); |
200 } | 237 } |
201 | 238 |
| 239 // static |
| 240 void WebThemeEngineImpl::CacheScrollBarMetrics( |
| 241 int32 vertical_scroll_bar_width, |
| 242 int32 horizontal_scroll_bar_height, |
| 243 int32 vertical_arrow_bitmap_height, |
| 244 int32 horizontal_arrow_bitmap_width) { |
| 245 g_vertical_scroll_bar_width = vertical_scroll_bar_width; |
| 246 g_horizontal_scroll_bar_height = horizontal_scroll_bar_height; |
| 247 g_vertical_arrow_bitmap_height = vertical_arrow_bitmap_height; |
| 248 g_horizontal_arrow_bitmap_width = horizontal_arrow_bitmap_width; |
| 249 } |
| 250 |
202 } // namespace content | 251 } // namespace content |
OLD | NEW |