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 #include "content/public/common/renderer_preferences.h" | |
6 | 7 |
7 #include "skia/ext/platform_canvas.h" | 8 #include "skia/ext/platform_canvas.h" |
8 #include "third_party/WebKit/public/platform/WebRect.h" | 9 #include "third_party/WebKit/public/platform/WebRect.h" |
9 #include "third_party/WebKit/public/platform/WebSize.h" | 10 #include "third_party/WebKit/public/platform/WebSize.h" |
10 #include "ui/native_theme/native_theme.h" | 11 #include "ui/native_theme/native_theme.h" |
11 | 12 |
12 using blink::WebCanvas; | 13 using blink::WebCanvas; |
13 using blink::WebColor; | 14 using blink::WebColor; |
14 using blink::WebRect; | 15 using blink::WebRect; |
15 using blink::WebThemeEngine; | 16 using blink::WebThemeEngine; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 native_theme_extra_params->progress_bar.value_rect_width = | 154 native_theme_extra_params->progress_bar.value_rect_width = |
154 extra_params->progressBar.valueRectWidth; | 155 extra_params->progressBar.valueRectWidth; |
155 native_theme_extra_params->progress_bar.value_rect_height = | 156 native_theme_extra_params->progress_bar.value_rect_height = |
156 extra_params->progressBar.valueRectHeight; | 157 extra_params->progressBar.valueRectHeight; |
157 break; | 158 break; |
158 default: | 159 default: |
159 break; // Parts that have no extra params get here. | 160 break; // Parts that have no extra params get here. |
160 } | 161 } |
161 } | 162 } |
162 | 163 |
164 int32 WebThemeEngineImpl::vertical_scroll_bar_width_ = 0; | |
165 int32 WebThemeEngineImpl::horizontal_scroll_bar_height_ = 0; | |
brucedawson
2015/04/03 17:00:24
I can't see anywhere where this variable (or the t
ananta
2015/04/03 19:17:03
Caching them on an if needed basis.
| |
166 int32 WebThemeEngineImpl::vertical_arrow_bitmap_height_ = 0; | |
167 int32 WebThemeEngineImpl::horizontal_arrow_bitmap_width_ = 0; | |
168 | |
163 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { | 169 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { |
164 ui::NativeTheme::ExtraParams extra; | 170 ui::NativeTheme::ExtraParams extra; |
165 return ui::NativeTheme::instance()->GetPartSize(NativeThemePart(part), | 171 ui::NativeTheme::Part native_theme_part = NativeThemePart(part); |
166 ui::NativeTheme::kNormal, | 172 #if defined(OS_WIN) |
167 extra); | 173 switch (native_theme_part) { |
174 case ui::NativeTheme::kScrollbarDownArrow: | |
175 case ui::NativeTheme::kScrollbarLeftArrow: | |
176 case ui::NativeTheme::kScrollbarRightArrow: | |
177 case ui::NativeTheme::kScrollbarUpArrow: | |
178 case ui::NativeTheme::kScrollbarHorizontalThumb: | |
179 case ui::NativeTheme::kScrollbarVerticalThumb: | |
180 case ui::NativeTheme::kScrollbarHorizontalTrack: | |
181 case ui::NativeTheme::kScrollbarVerticalTrack: { | |
182 // If we have the scrollbar width cached return it. | |
183 if (WebThemeEngineImpl::vertical_scroll_bar_width_) { | |
brucedawson
2015/04/03 17:00:24
When would we not have the scrollbar width cached?
ananta
2015/04/03 19:17:04
Removed the check. The metrics default to 17
| |
184 return gfx::Size(WebThemeEngineImpl::vertical_scroll_bar_width_, | |
185 WebThemeEngineImpl::vertical_scroll_bar_width_); | |
186 } | |
187 break; | |
188 } | |
189 | |
190 default: | |
191 break; | |
192 } | |
193 #endif | |
194 return ui::NativeTheme::instance()->GetPartSize(native_theme_part, | |
195 ui::NativeTheme::kNormal, | |
196 extra); | |
168 } | 197 } |
169 | 198 |
170 void WebThemeEngineImpl::paint( | 199 void WebThemeEngineImpl::paint( |
171 blink::WebCanvas* canvas, | 200 blink::WebCanvas* canvas, |
172 WebThemeEngine::Part part, | 201 WebThemeEngine::Part part, |
173 WebThemeEngine::State state, | 202 WebThemeEngine::State state, |
174 const blink::WebRect& rect, | 203 const blink::WebRect& rect, |
175 const WebThemeEngine::ExtraParams* extra_params) { | 204 const WebThemeEngine::ExtraParams* extra_params) { |
176 ui::NativeTheme::ExtraParams native_theme_extra_params; | 205 ui::NativeTheme::ExtraParams native_theme_extra_params; |
177 GetNativeThemeExtraParams( | 206 GetNativeThemeExtraParams( |
(...skipping 14 matching lines...) Expand all Loading... | |
192 const blink::WebRect& rect) { | 221 const blink::WebRect& rect) { |
193 ui::NativeTheme::instance()->PaintStateTransition( | 222 ui::NativeTheme::instance()->PaintStateTransition( |
194 canvas, | 223 canvas, |
195 NativeThemePart(part), | 224 NativeThemePart(part), |
196 NativeThemeState(startState), | 225 NativeThemeState(startState), |
197 NativeThemeState(endState), | 226 NativeThemeState(endState), |
198 progress, | 227 progress, |
199 gfx::Rect(rect)); | 228 gfx::Rect(rect)); |
200 } | 229 } |
201 | 230 |
231 // static | |
232 void WebThemeEngineImpl::SetVerticalScrollbarWidth( | |
233 int32 vertical_scroll_bar_width) { | |
234 vertical_scroll_bar_width_ = vertical_scroll_bar_width; | |
235 } | |
236 | |
237 // static | |
238 void WebThemeEngineImpl::SetHorizontalScrollbarHeight( | |
239 int32 horizontal_scroll_bar_height) { | |
240 horizontal_scroll_bar_height_ = horizontal_scroll_bar_height; | |
241 } | |
242 | |
243 // static | |
244 void WebThemeEngineImpl::SetVerticalArrowBitmapHeight( | |
245 int32 vertical_arrow_bitmap_height) { | |
246 vertical_arrow_bitmap_height_ = vertical_arrow_bitmap_height; | |
247 } | |
248 | |
249 // static | |
250 void WebThemeEngineImpl::SetHorizontalArrowBitmapWidth( | |
251 int32 horizontal_arrow_bitmap_width) { | |
252 horizontal_arrow_bitmap_width_ = horizontal_arrow_bitmap_width; | |
253 } | |
254 | |
202 } // namespace content | 255 } // namespace content |
OLD | NEW |