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