| 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; | |
| 43 case WebThemeEngine::PartScrollbarVerticalThumb: | 42 case WebThemeEngine::PartScrollbarVerticalThumb: |
| 44 return ui::NativeTheme::kScrollbarVerticalThumb; | |
| 45 case WebThemeEngine::PartScrollbarHorizontalTrack: | 43 case WebThemeEngine::PartScrollbarHorizontalTrack: |
| 46 return ui::NativeTheme::kScrollbarHorizontalTrack; | |
| 47 case WebThemeEngine::PartScrollbarVerticalTrack: | 44 case WebThemeEngine::PartScrollbarVerticalTrack: |
| 48 return ui::NativeTheme::kScrollbarVerticalTrack; | |
| 49 case WebThemeEngine::PartScrollbarCorner: | 45 case WebThemeEngine::PartScrollbarCorner: |
| 50 return ui::NativeTheme::kScrollbarCorner; | 46 // Android doesn't draw scrollbars. |
| 47 NOTREACHED(); |
| 48 return static_cast<ui::NativeTheme::Part>(0); |
| 51 case WebThemeEngine::PartCheckbox: | 49 case WebThemeEngine::PartCheckbox: |
| 52 return ui::NativeTheme::kCheckbox; | 50 return ui::NativeTheme::kCheckbox; |
| 53 case WebThemeEngine::PartRadio: | 51 case WebThemeEngine::PartRadio: |
| 54 return ui::NativeTheme::kRadio; | 52 return ui::NativeTheme::kRadio; |
| 55 case WebThemeEngine::PartButton: | 53 case WebThemeEngine::PartButton: |
| 56 return ui::NativeTheme::kPushButton; | 54 return ui::NativeTheme::kPushButton; |
| 57 case WebThemeEngine::PartTextField: | 55 case WebThemeEngine::PartTextField: |
| 58 return ui::NativeTheme::kTextField; | 56 return ui::NativeTheme::kTextField; |
| 59 case WebThemeEngine::PartMenuList: | 57 case WebThemeEngine::PartMenuList: |
| 60 return ui::NativeTheme::kMenuList; | 58 return ui::NativeTheme::kMenuList; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 extra_params->progressBar.valueRectWidth; | 160 extra_params->progressBar.valueRectWidth; |
| 163 native_theme_extra_params->progress_bar.value_rect_height = | 161 native_theme_extra_params->progress_bar.value_rect_height = |
| 164 extra_params->progressBar.valueRectHeight; | 162 extra_params->progressBar.valueRectHeight; |
| 165 break; | 163 break; |
| 166 default: | 164 default: |
| 167 break; // Parts that have no extra params get here. | 165 break; // Parts that have no extra params get here. |
| 168 } | 166 } |
| 169 } | 167 } |
| 170 | 168 |
| 171 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { | 169 blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) { |
| 172 switch (part) { | 170 ui::NativeTheme::ExtraParams extra; |
| 173 case ui::NativeTheme::kScrollbarHorizontalThumb: | 171 return ui::NativeTheme::GetInstanceForWeb()->GetPartSize( |
| 174 case ui::NativeTheme::kScrollbarVerticalThumb: { | 172 NativeThemePart(part), ui::NativeTheme::kNormal, extra); |
| 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 } | |
| 187 } | 173 } |
| 188 | 174 |
| 189 void WebThemeEngineImpl::getOverlayScrollbarStyle(ScrollbarStyle* style) { | 175 void WebThemeEngineImpl::getOverlayScrollbarStyle(ScrollbarStyle* style) { |
| 190 // TODO(bokan): Android scrollbars on non-composited scrollers don't | 176 // TODO(bokan): Android scrollbars on non-composited scrollers don't |
| 191 // currently fade out so the fadeOutDuration and Delay Now that this has | 177 // currently fade out so the fadeOutDuration and Delay Now that this has |
| 192 // been added into Blink for other platforms we should plumb that through for | 178 // been added into Blink for other platforms we should plumb that through for |
| 193 // Android as well. | 179 // Android as well. |
| 194 style->fadeOutDelaySeconds = 0; | 180 style->fadeOutDelaySeconds = 0; |
| 195 style->fadeOutDurationSeconds = 0; | 181 style->fadeOutDurationSeconds = 0; |
| 196 if (getMajorVersion() >= kVersionLollipop) { | 182 if (getMajorVersion() >= kVersionLollipop) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 211 const blink::WebRect& rect, | 197 const blink::WebRect& rect, |
| 212 const WebThemeEngine::ExtraParams* extra_params) { | 198 const WebThemeEngine::ExtraParams* extra_params) { |
| 213 ui::NativeTheme::ExtraParams native_theme_extra_params; | 199 ui::NativeTheme::ExtraParams native_theme_extra_params; |
| 214 GetNativeThemeExtraParams( | 200 GetNativeThemeExtraParams( |
| 215 part, state, extra_params, &native_theme_extra_params); | 201 part, state, extra_params, &native_theme_extra_params); |
| 216 ui::NativeTheme::GetInstanceForWeb()->Paint( | 202 ui::NativeTheme::GetInstanceForWeb()->Paint( |
| 217 canvas, NativeThemePart(part), NativeThemeState(state), gfx::Rect(rect), | 203 canvas, NativeThemePart(part), NativeThemeState(state), gfx::Rect(rect), |
| 218 native_theme_extra_params); | 204 native_theme_extra_params); |
| 219 } | 205 } |
| 220 } // namespace content | 206 } // namespace content |
| OLD | NEW |