Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: content/child/webthemeengine_impl_default.cc

Issue 2290743002: Partial revert of https://codereview.chromium.org/1911973002/ (Closed)
Patch Set: comment in header Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 width of a vertical scroll bar in dips.
23 int32_t g_vertical_scroll_bar_width;
24
25 // The height of a horizontal scroll bar in dips.
26 int32_t g_horizontal_scroll_bar_height;
27
28 // The height of the arrow bitmap on a vertical scroll bar in dips.
29 int32_t g_vertical_arrow_bitmap_height;
30
31 // The width of the arrow bitmap on a horizontal scroll bar in dips.
32 int32_t g_horizontal_arrow_bitmap_width;
33 #endif
34
35 } // namespace
19 36
20 static ui::NativeTheme::Part NativeThemePart( 37 static ui::NativeTheme::Part NativeThemePart(
21 WebThemeEngine::Part part) { 38 WebThemeEngine::Part part) {
22 switch (part) { 39 switch (part) {
23 case WebThemeEngine::PartScrollbarDownArrow: 40 case WebThemeEngine::PartScrollbarDownArrow:
24 return ui::NativeTheme::kScrollbarDownArrow; 41 return ui::NativeTheme::kScrollbarDownArrow;
25 case WebThemeEngine::PartScrollbarLeftArrow: 42 case WebThemeEngine::PartScrollbarLeftArrow:
26 return ui::NativeTheme::kScrollbarLeftArrow; 43 return ui::NativeTheme::kScrollbarLeftArrow;
27 case WebThemeEngine::PartScrollbarRightArrow: 44 case WebThemeEngine::PartScrollbarRightArrow:
28 return ui::NativeTheme::kScrollbarRightArrow; 45 return ui::NativeTheme::kScrollbarRightArrow;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 native_theme_extra_params->progress_bar.value_rect_height = 177 native_theme_extra_params->progress_bar.value_rect_height =
161 extra_params->progressBar.valueRectHeight; 178 extra_params->progressBar.valueRectHeight;
162 break; 179 break;
163 default: 180 default:
164 break; // Parts that have no extra params get here. 181 break; // Parts that have no extra params get here.
165 } 182 }
166 } 183 }
167 184
168 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { 185 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) {
169 ui::NativeTheme::ExtraParams extra; 186 ui::NativeTheme::ExtraParams extra;
187 ui::NativeTheme::Part native_theme_part = NativeThemePart(part);
188 #if defined(OS_WIN)
189 switch (native_theme_part) {
190 case ui::NativeTheme::kScrollbarDownArrow:
191 case ui::NativeTheme::kScrollbarLeftArrow:
192 case ui::NativeTheme::kScrollbarRightArrow:
193 case ui::NativeTheme::kScrollbarUpArrow:
194 case ui::NativeTheme::kScrollbarHorizontalThumb:
195 case ui::NativeTheme::kScrollbarVerticalThumb:
196 case ui::NativeTheme::kScrollbarHorizontalTrack:
197 case ui::NativeTheme::kScrollbarVerticalTrack: {
198 return gfx::Size(g_vertical_scroll_bar_width,
199 g_vertical_scroll_bar_width);
200 }
201
202 default:
203 break;
204 }
205 #endif
170 return ui::NativeTheme::GetInstanceForWeb()->GetPartSize( 206 return ui::NativeTheme::GetInstanceForWeb()->GetPartSize(
171 NativeThemePart(part), ui::NativeTheme::kNormal, extra); 207 native_theme_part, ui::NativeTheme::kNormal, extra);
172 } 208 }
173 209
174 void WebThemeEngineImpl::paint( 210 void WebThemeEngineImpl::paint(
175 blink::WebCanvas* canvas, 211 blink::WebCanvas* canvas,
176 WebThemeEngine::Part part, 212 WebThemeEngine::Part part,
177 WebThemeEngine::State state, 213 WebThemeEngine::State state,
178 const blink::WebRect& rect, 214 const blink::WebRect& rect,
179 const WebThemeEngine::ExtraParams* extra_params) { 215 const WebThemeEngine::ExtraParams* extra_params) {
180 ui::NativeTheme::ExtraParams native_theme_extra_params; 216 ui::NativeTheme::ExtraParams native_theme_extra_params;
181 GetNativeThemeExtraParams( 217 GetNativeThemeExtraParams(
182 part, state, extra_params, &native_theme_extra_params); 218 part, state, extra_params, &native_theme_extra_params);
183 ui::NativeTheme::GetInstanceForWeb()->Paint( 219 ui::NativeTheme::GetInstanceForWeb()->Paint(
184 canvas, NativeThemePart(part), NativeThemeState(state), gfx::Rect(rect), 220 canvas, NativeThemePart(part), NativeThemeState(state), gfx::Rect(rect),
185 native_theme_extra_params); 221 native_theme_extra_params);
186 } 222 }
187 223
188 void WebThemeEngineImpl::paintStateTransition(blink::WebCanvas* canvas, 224 void WebThemeEngineImpl::paintStateTransition(blink::WebCanvas* canvas,
189 WebThemeEngine::Part part, 225 WebThemeEngine::Part part,
190 WebThemeEngine::State startState, 226 WebThemeEngine::State startState,
191 WebThemeEngine::State endState, 227 WebThemeEngine::State endState,
192 double progress, 228 double progress,
193 const blink::WebRect& rect) { 229 const blink::WebRect& rect) {
194 ui::NativeTheme::GetInstanceForWeb()->PaintStateTransition( 230 ui::NativeTheme::GetInstanceForWeb()->PaintStateTransition(
195 canvas, NativeThemePart(part), NativeThemeState(startState), 231 canvas, NativeThemePart(part), NativeThemeState(startState),
196 NativeThemeState(endState), progress, gfx::Rect(rect)); 232 NativeThemeState(endState), progress, gfx::Rect(rect));
197 } 233 }
198 234
235 #if defined(OS_WIN)
236 // static
237 void WebThemeEngineImpl::cacheScrollBarMetrics(
238 int32_t vertical_scroll_bar_width,
239 int32_t horizontal_scroll_bar_height,
240 int32_t vertical_arrow_bitmap_height,
241 int32_t horizontal_arrow_bitmap_width) {
242 g_vertical_scroll_bar_width = vertical_scroll_bar_width;
243 g_horizontal_scroll_bar_height = horizontal_scroll_bar_height;
244 g_vertical_arrow_bitmap_height = vertical_arrow_bitmap_height;
245 g_horizontal_arrow_bitmap_width = horizontal_arrow_bitmap_width;
246 }
247 #endif
248
199 } // namespace content 249 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698