OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/native_theme/native_theme_aura.h" | 5 #include "ui/native_theme/native_theme_aura.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 namespace ui { | 29 namespace ui { |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 // Constants for painting overlay scrollbars. Other properties needed outside | 33 // Constants for painting overlay scrollbars. Other properties needed outside |
34 // this painting code are defined in overlay_scrollbar_constants_aura.h. | 34 // this painting code are defined in overlay_scrollbar_constants_aura.h. |
35 constexpr int kOverlayScrollbarStrokeWidth = 1; | 35 constexpr int kOverlayScrollbarStrokeWidth = 1; |
36 constexpr int kOverlayScrollbarMinimumLength = 12; | 36 constexpr int kOverlayScrollbarMinimumLength = 12; |
37 | 37 |
| 38 // 2 pixel border with 1 pixel center patch. The border is 2 pixels despite the |
| 39 // stroke width being 1 so that the inner pixel can match the center tile |
| 40 // color. This prevents color interpolation between the patches. |
| 41 constexpr int kOverlayScrollbarBorderPatchWidth = 2; |
| 42 constexpr int kOverlayScrollbarCenterPatchSize = 1; |
| 43 |
38 const SkColor kTrackColor = SkColorSetRGB(0xF1, 0xF1, 0xF1); | 44 const SkColor kTrackColor = SkColorSetRGB(0xF1, 0xF1, 0xF1); |
39 | 45 |
40 } // namespace | 46 } // namespace |
41 | 47 |
42 //////////////////////////////////////////////////////////////////////////////// | 48 //////////////////////////////////////////////////////////////////////////////// |
43 // NativeTheme: | 49 // NativeTheme: |
44 | 50 |
45 // static | 51 // static |
46 NativeTheme* NativeTheme::GetInstanceForWeb() { | 52 NativeTheme* NativeTheme::GetInstanceForWeb() { |
47 return NativeThemeAura::web_instance(); | 53 return NativeThemeAura::web_instance(); |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 // TODO(bokan): We should probably make sure code using overlay | 316 // TODO(bokan): We should probably make sure code using overlay |
311 // scrollbars isn't asking for part sizes that don't exist. | 317 // scrollbars isn't asking for part sizes that don't exist. |
312 // crbug.com/657159. | 318 // crbug.com/657159. |
313 break; | 319 break; |
314 } | 320 } |
315 } | 321 } |
316 | 322 |
317 return NativeThemeBase::GetPartSize(part, state, extra); | 323 return NativeThemeBase::GetPartSize(part, state, extra); |
318 } | 324 } |
319 | 325 |
| 326 bool NativeThemeAura::SupportsNinePatch(Part part) const { |
| 327 if (!IsOverlayScrollbarEnabled()) |
| 328 return false; |
| 329 |
| 330 return part == kScrollbarHorizontalThumb || part == kScrollbarVerticalThumb; |
| 331 } |
| 332 |
| 333 gfx::Size NativeThemeAura::GetNinePatchCanvasSize(Part part) const { |
| 334 DCHECK(SupportsNinePatch(part)); |
| 335 |
| 336 return gfx::Size( |
| 337 kOverlayScrollbarBorderPatchWidth * 2 + kOverlayScrollbarCenterPatchSize, |
| 338 kOverlayScrollbarBorderPatchWidth * 2 + kOverlayScrollbarCenterPatchSize); |
| 339 } |
| 340 |
| 341 gfx::Rect NativeThemeAura::GetNinePatchAperture(Part part) const { |
| 342 DCHECK(SupportsNinePatch(part)); |
| 343 |
| 344 return gfx::Rect( |
| 345 kOverlayScrollbarBorderPatchWidth, kOverlayScrollbarBorderPatchWidth, |
| 346 kOverlayScrollbarCenterPatchSize, kOverlayScrollbarCenterPatchSize); |
| 347 } |
| 348 |
320 } // namespace ui | 349 } // namespace ui |
OLD | NEW |