| 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_android.h" | 5 #include "content/child/webthemeengine_impl_android.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
| 9 #include "skia/ext/platform_canvas.h" | 9 #include "skia/ext/platform_canvas.h" |
| 10 #include "third_party/WebKit/public/platform/WebRect.h" | 10 #include "third_party/WebKit/public/platform/WebRect.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 switch (part) { | 32 switch (part) { |
| 33 case WebThemeEngine::PartScrollbarDownArrow: | 33 case WebThemeEngine::PartScrollbarDownArrow: |
| 34 return ui::NativeTheme::kScrollbarDownArrow; | 34 return ui::NativeTheme::kScrollbarDownArrow; |
| 35 case WebThemeEngine::PartScrollbarLeftArrow: | 35 case WebThemeEngine::PartScrollbarLeftArrow: |
| 36 return ui::NativeTheme::kScrollbarLeftArrow; | 36 return ui::NativeTheme::kScrollbarLeftArrow; |
| 37 case WebThemeEngine::PartScrollbarRightArrow: | 37 case WebThemeEngine::PartScrollbarRightArrow: |
| 38 return ui::NativeTheme::kScrollbarRightArrow; | 38 return ui::NativeTheme::kScrollbarRightArrow; |
| 39 case WebThemeEngine::PartScrollbarUpArrow: | 39 case WebThemeEngine::PartScrollbarUpArrow: |
| 40 return ui::NativeTheme::kScrollbarUpArrow; | 40 return ui::NativeTheme::kScrollbarUpArrow; |
| 41 case WebThemeEngine::PartScrollbarHorizontalThumb: | 41 case WebThemeEngine::PartScrollbarHorizontalThumb: |
| 42 return ui::NativeTheme::kScrollbarHorizontalThumb; |
| 42 case WebThemeEngine::PartScrollbarVerticalThumb: | 43 case WebThemeEngine::PartScrollbarVerticalThumb: |
| 44 return ui::NativeTheme::kScrollbarVerticalThumb; |
| 43 case WebThemeEngine::PartScrollbarHorizontalTrack: | 45 case WebThemeEngine::PartScrollbarHorizontalTrack: |
| 46 return ui::NativeTheme::kScrollbarHorizontalTrack; |
| 44 case WebThemeEngine::PartScrollbarVerticalTrack: | 47 case WebThemeEngine::PartScrollbarVerticalTrack: |
| 48 return ui::NativeTheme::kScrollbarVerticalTrack; |
| 45 case WebThemeEngine::PartScrollbarCorner: | 49 case WebThemeEngine::PartScrollbarCorner: |
| 46 // Android doesn't draw scrollbars. | 50 return ui::NativeTheme::kScrollbarCorner; |
| 47 NOTREACHED(); | |
| 48 return static_cast<ui::NativeTheme::Part>(0); | |
| 49 case WebThemeEngine::PartCheckbox: | 51 case WebThemeEngine::PartCheckbox: |
| 50 return ui::NativeTheme::kCheckbox; | 52 return ui::NativeTheme::kCheckbox; |
| 51 case WebThemeEngine::PartRadio: | 53 case WebThemeEngine::PartRadio: |
| 52 return ui::NativeTheme::kRadio; | 54 return ui::NativeTheme::kRadio; |
| 53 case WebThemeEngine::PartButton: | 55 case WebThemeEngine::PartButton: |
| 54 return ui::NativeTheme::kPushButton; | 56 return ui::NativeTheme::kPushButton; |
| 55 case WebThemeEngine::PartTextField: | 57 case WebThemeEngine::PartTextField: |
| 56 return ui::NativeTheme::kTextField; | 58 return ui::NativeTheme::kTextField; |
| 57 case WebThemeEngine::PartMenuList: | 59 case WebThemeEngine::PartMenuList: |
| 58 return ui::NativeTheme::kMenuList; | 60 return ui::NativeTheme::kMenuList; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 extra_params->progressBar.valueRectWidth; | 162 extra_params->progressBar.valueRectWidth; |
| 161 native_theme_extra_params->progress_bar.value_rect_height = | 163 native_theme_extra_params->progress_bar.value_rect_height = |
| 162 extra_params->progressBar.valueRectHeight; | 164 extra_params->progressBar.valueRectHeight; |
| 163 break; | 165 break; |
| 164 default: | 166 default: |
| 165 break; // Parts that have no extra params get here. | 167 break; // Parts that have no extra params get here. |
| 166 } | 168 } |
| 167 } | 169 } |
| 168 | 170 |
| 169 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { | 171 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { |
| 170 ui::NativeTheme::ExtraParams extra; | 172 switch (part) { |
| 171 return ui::NativeTheme::GetInstanceForWeb()->GetPartSize( | 173 case ui::NativeTheme::kScrollbarHorizontalThumb: |
| 172 NativeThemePart(part), ui::NativeTheme::kNormal, extra); | 174 case ui::NativeTheme::kScrollbarVerticalThumb: { |
| 175 // Minimum length for scrollbar thumb is the scrollbar thickness. |
| 176 ScrollbarStyle style; |
| 177 getOverlayScrollbarStyle(&style); |
| 178 int scrollbarThickness = style.thumbThickness + style.scrollbarMargin; |
| 179 return gfx::Size(scrollbarThickness, scrollbarThickness); |
| 180 } |
| 181 default: { |
| 182 ui::NativeTheme::ExtraParams extra; |
| 183 return ui::NativeTheme::GetInstanceForWeb()->GetPartSize( |
| 184 NativeThemePart(part), ui::NativeTheme::kNormal, extra); |
| 185 } |
| 186 } |
| 173 } | 187 } |
| 174 | 188 |
| 175 void WebThemeEngineImpl::getOverlayScrollbarStyle(ScrollbarStyle* style) { | 189 void WebThemeEngineImpl::getOverlayScrollbarStyle(ScrollbarStyle* style) { |
| 176 // TODO(bokan): Android scrollbars on non-composited scrollers don't | 190 // TODO(bokan): Android scrollbars on non-composited scrollers don't |
| 177 // currently fade out so the fadeOutDuration and Delay Now that this has | 191 // currently fade out so the fadeOutDuration and Delay Now that this has |
| 178 // been added into Blink for other platforms we should plumb that through for | 192 // been added into Blink for other platforms we should plumb that through for |
| 179 // Android as well. | 193 // Android as well. |
| 180 style->fadeOutDelaySeconds = 0; | 194 style->fadeOutDelaySeconds = 0; |
| 181 style->fadeOutDurationSeconds = 0; | 195 style->fadeOutDurationSeconds = 0; |
| 182 if (getMajorVersion() >= kVersionLollipop) { | 196 if (getMajorVersion() >= kVersionLollipop) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 197 const blink::WebRect& rect, | 211 const blink::WebRect& rect, |
| 198 const WebThemeEngine::ExtraParams* extra_params) { | 212 const WebThemeEngine::ExtraParams* extra_params) { |
| 199 ui::NativeTheme::ExtraParams native_theme_extra_params; | 213 ui::NativeTheme::ExtraParams native_theme_extra_params; |
| 200 GetNativeThemeExtraParams( | 214 GetNativeThemeExtraParams( |
| 201 part, state, extra_params, &native_theme_extra_params); | 215 part, state, extra_params, &native_theme_extra_params); |
| 202 ui::NativeTheme::GetInstanceForWeb()->Paint( | 216 ui::NativeTheme::GetInstanceForWeb()->Paint( |
| 203 canvas, NativeThemePart(part), NativeThemeState(state), gfx::Rect(rect), | 217 canvas, NativeThemePart(part), NativeThemeState(state), gfx::Rect(rect), |
| 204 native_theme_extra_params); | 218 native_theme_extra_params); |
| 205 } | 219 } |
| 206 } // namespace content | 220 } // namespace content |
| OLD | NEW |