| 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" | |
| 12 | 11 |
| 13 using blink::WebCanvas; | 12 using blink::WebCanvas; |
| 14 using blink::WebColor; | 13 using blink::WebColor; |
| 15 using blink::WebRect; | 14 using blink::WebRect; |
| 16 using blink::WebThemeEngine; | 15 using blink::WebThemeEngine; |
| 16 using blink::WebScrollbarOverlayColorTheme; |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| 22 // The width of a vertical scroll bar in dips. | 22 // The width of a vertical scroll bar in dips. |
| 23 int32_t g_vertical_scroll_bar_width; | 23 int32_t g_vertical_scroll_bar_width; |
| 24 | 24 |
| 25 // The height of a horizontal scroll bar in dips. | 25 // The height of a horizontal scroll bar in dips. |
| 26 int32_t g_horizontal_scroll_bar_height; | 26 int32_t g_horizontal_scroll_bar_height; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 return ui::NativeTheme::kSliderThumb; | 71 return ui::NativeTheme::kSliderThumb; |
| 72 case WebThemeEngine::PartInnerSpinButton: | 72 case WebThemeEngine::PartInnerSpinButton: |
| 73 return ui::NativeTheme::kInnerSpinButton; | 73 return ui::NativeTheme::kInnerSpinButton; |
| 74 case WebThemeEngine::PartProgressBar: | 74 case WebThemeEngine::PartProgressBar: |
| 75 return ui::NativeTheme::kProgressBar; | 75 return ui::NativeTheme::kProgressBar; |
| 76 default: | 76 default: |
| 77 return ui::NativeTheme::kScrollbarDownArrow; | 77 return ui::NativeTheme::kScrollbarDownArrow; |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 static ui::NativeTheme::ScrollbarOverlayColorTheme |
| 82 NativeThemeScrollbarOverlayColorTheme(WebScrollbarOverlayColorTheme theme) { |
| 83 switch (theme) { |
| 84 case WebScrollbarOverlayColorTheme::WebScrollbarOverlayColorThemeDefault: |
| 85 return ui::NativeTheme::ScrollbarOverlayColorThemeDefault; |
| 86 case WebScrollbarOverlayColorTheme::WebScrollbarOverlayColorThemeLight: |
| 87 return ui::NativeTheme::ScrollbarOverlayColorThemeLight; |
| 88 case WebScrollbarOverlayColorTheme::WebScrollbarOverlayColorThemeDark: |
| 89 return ui::NativeTheme::ScrollbarOverlayColorThemeDark; |
| 90 default: |
| 91 return ui::NativeTheme::ScrollbarOverlayColorThemeDefault; |
| 92 } |
| 93 } |
| 94 |
| 81 static ui::NativeTheme::State NativeThemeState( | 95 static ui::NativeTheme::State NativeThemeState( |
| 82 WebThemeEngine::State state) { | 96 WebThemeEngine::State state) { |
| 83 switch (state) { | 97 switch (state) { |
| 84 case WebThemeEngine::StateDisabled: | 98 case WebThemeEngine::StateDisabled: |
| 85 return ui::NativeTheme::kDisabled; | 99 return ui::NativeTheme::kDisabled; |
| 86 case WebThemeEngine::StateHover: | 100 case WebThemeEngine::StateHover: |
| 87 return ui::NativeTheme::kHovered; | 101 return ui::NativeTheme::kHovered; |
| 88 case WebThemeEngine::StateNormal: | 102 case WebThemeEngine::StateNormal: |
| 89 return ui::NativeTheme::kNormal; | 103 return ui::NativeTheme::kNormal; |
| 90 case WebThemeEngine::StatePressed: | 104 case WebThemeEngine::StatePressed: |
| 91 return ui::NativeTheme::kPressed; | 105 return ui::NativeTheme::kPressed; |
| 92 default: | 106 default: |
| 93 return ui::NativeTheme::kDisabled; | 107 return ui::NativeTheme::kDisabled; |
| 94 } | 108 } |
| 95 } | 109 } |
| 96 | 110 |
| 97 static void GetNativeThemeExtraParams( | 111 static void GetNativeThemeExtraParams( |
| 98 WebThemeEngine::Part part, | 112 WebThemeEngine::Part part, |
| 99 WebThemeEngine::State state, | 113 WebThemeEngine::State state, |
| 100 const WebThemeEngine::ExtraParams* extra_params, | 114 const WebThemeEngine::ExtraParams* extra_params, |
| 101 ui::NativeTheme::ExtraParams* native_theme_extra_params) { | 115 ui::NativeTheme::ExtraParams* native_theme_extra_params) { |
| 116 if (!extra_params) |
| 117 return; |
| 118 |
| 102 switch (part) { | 119 switch (part) { |
| 103 case WebThemeEngine::PartScrollbarHorizontalTrack: | 120 case WebThemeEngine::PartScrollbarHorizontalTrack: |
| 104 case WebThemeEngine::PartScrollbarVerticalTrack: | 121 case WebThemeEngine::PartScrollbarVerticalTrack: |
| 105 native_theme_extra_params->scrollbar_track.track_x = | 122 native_theme_extra_params->scrollbar_track.track_x = |
| 106 extra_params->scrollbarTrack.trackX; | 123 extra_params->scrollbarTrack.trackX; |
| 107 native_theme_extra_params->scrollbar_track.track_y = | 124 native_theme_extra_params->scrollbar_track.track_y = |
| 108 extra_params->scrollbarTrack.trackY; | 125 extra_params->scrollbarTrack.trackY; |
| 109 native_theme_extra_params->scrollbar_track.track_width = | 126 native_theme_extra_params->scrollbar_track.track_width = |
| 110 extra_params->scrollbarTrack.trackWidth; | 127 extra_params->scrollbarTrack.trackWidth; |
| 111 native_theme_extra_params->scrollbar_track.track_height = | 128 native_theme_extra_params->scrollbar_track.track_height = |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 extra_params->progressBar.determinate; | 187 extra_params->progressBar.determinate; |
| 171 native_theme_extra_params->progress_bar.value_rect_x = | 188 native_theme_extra_params->progress_bar.value_rect_x = |
| 172 extra_params->progressBar.valueRectX; | 189 extra_params->progressBar.valueRectX; |
| 173 native_theme_extra_params->progress_bar.value_rect_y = | 190 native_theme_extra_params->progress_bar.value_rect_y = |
| 174 extra_params->progressBar.valueRectY; | 191 extra_params->progressBar.valueRectY; |
| 175 native_theme_extra_params->progress_bar.value_rect_width = | 192 native_theme_extra_params->progress_bar.value_rect_width = |
| 176 extra_params->progressBar.valueRectWidth; | 193 extra_params->progressBar.valueRectWidth; |
| 177 native_theme_extra_params->progress_bar.value_rect_height = | 194 native_theme_extra_params->progress_bar.value_rect_height = |
| 178 extra_params->progressBar.valueRectHeight; | 195 extra_params->progressBar.valueRectHeight; |
| 179 break; | 196 break; |
| 197 case WebThemeEngine::PartScrollbarHorizontalThumb: |
| 198 case WebThemeEngine::PartScrollbarVerticalThumb: |
| 199 native_theme_extra_params->scrollbar_thumb.scrollbar_theme = |
| 200 NativeThemeScrollbarOverlayColorTheme( |
| 201 extra_params->scrollbarThumb.scrollbarTheme); |
| 202 break; |
| 180 default: | 203 default: |
| 181 break; // Parts that have no extra params get here. | 204 break; // Parts that have no extra params get here. |
| 182 } | 205 } |
| 183 } | 206 } |
| 184 | 207 |
| 185 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { | 208 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { |
| 186 ui::NativeTheme::ExtraParams extra; | 209 ui::NativeTheme::ExtraParams extra; |
| 187 ui::NativeTheme::Part native_theme_part = NativeThemePart(part); | 210 ui::NativeTheme::Part native_theme_part = NativeThemePart(part); |
| 188 #if defined(OS_WIN) | 211 #if defined(OS_WIN) |
| 189 switch (native_theme_part) { | 212 switch (native_theme_part) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 214 const blink::WebRect& rect, | 237 const blink::WebRect& rect, |
| 215 const WebThemeEngine::ExtraParams* extra_params) { | 238 const WebThemeEngine::ExtraParams* extra_params) { |
| 216 ui::NativeTheme::ExtraParams native_theme_extra_params; | 239 ui::NativeTheme::ExtraParams native_theme_extra_params; |
| 217 GetNativeThemeExtraParams( | 240 GetNativeThemeExtraParams( |
| 218 part, state, extra_params, &native_theme_extra_params); | 241 part, state, extra_params, &native_theme_extra_params); |
| 219 ui::NativeTheme::GetInstanceForWeb()->Paint( | 242 ui::NativeTheme::GetInstanceForWeb()->Paint( |
| 220 canvas, NativeThemePart(part), NativeThemeState(state), gfx::Rect(rect), | 243 canvas, NativeThemePart(part), NativeThemeState(state), gfx::Rect(rect), |
| 221 native_theme_extra_params); | 244 native_theme_extra_params); |
| 222 } | 245 } |
| 223 | 246 |
| 224 void WebThemeEngineImpl::paintStateTransition(blink::WebCanvas* canvas, | 247 void WebThemeEngineImpl::paintStateTransition( |
| 225 WebThemeEngine::Part part, | 248 blink::WebCanvas* canvas, |
| 226 WebThemeEngine::State startState, | 249 WebThemeEngine::Part part, |
| 227 WebThemeEngine::State endState, | 250 WebThemeEngine::State startState, |
| 228 double progress, | 251 WebThemeEngine::State endState, |
| 229 const blink::WebRect& rect) { | 252 double progress, |
| 253 const blink::WebRect& rect, |
| 254 WebScrollbarOverlayColorTheme theme) { |
| 230 ui::NativeTheme::GetInstanceForWeb()->PaintStateTransition( | 255 ui::NativeTheme::GetInstanceForWeb()->PaintStateTransition( |
| 231 canvas, NativeThemePart(part), NativeThemeState(startState), | 256 canvas, NativeThemePart(part), NativeThemeState(startState), |
| 232 NativeThemeState(endState), progress, gfx::Rect(rect)); | 257 NativeThemeState(endState), progress, gfx::Rect(rect), |
| 258 NativeThemeScrollbarOverlayColorTheme(theme)); |
| 233 } | 259 } |
| 234 | 260 |
| 235 #if defined(OS_WIN) | 261 #if defined(OS_WIN) |
| 236 // static | 262 // static |
| 237 void WebThemeEngineImpl::cacheScrollBarMetrics( | 263 void WebThemeEngineImpl::cacheScrollBarMetrics( |
| 238 int32_t vertical_scroll_bar_width, | 264 int32_t vertical_scroll_bar_width, |
| 239 int32_t horizontal_scroll_bar_height, | 265 int32_t horizontal_scroll_bar_height, |
| 240 int32_t vertical_arrow_bitmap_height, | 266 int32_t vertical_arrow_bitmap_height, |
| 241 int32_t horizontal_arrow_bitmap_width) { | 267 int32_t horizontal_arrow_bitmap_width) { |
| 242 g_vertical_scroll_bar_width = vertical_scroll_bar_width; | 268 g_vertical_scroll_bar_width = vertical_scroll_bar_width; |
| 243 g_horizontal_scroll_bar_height = horizontal_scroll_bar_height; | 269 g_horizontal_scroll_bar_height = horizontal_scroll_bar_height; |
| 244 g_vertical_arrow_bitmap_height = vertical_arrow_bitmap_height; | 270 g_vertical_arrow_bitmap_height = vertical_arrow_bitmap_height; |
| 245 g_horizontal_arrow_bitmap_width = horizontal_arrow_bitmap_width; | 271 g_horizontal_arrow_bitmap_width = horizontal_arrow_bitmap_width; |
| 246 } | 272 } |
| 247 #endif | 273 #endif |
| 248 | 274 |
| 249 } // namespace content | 275 } // namespace content |
| OLD | NEW |