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