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 16 matching lines...) Expand all Loading... | |
27 #include "ui/native_theme/overlay_scrollbar_constants_aura.h" | 27 #include "ui/native_theme/overlay_scrollbar_constants_aura.h" |
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 const gfx::Size kOverlayScrollbarNinePatchCanvasSize(5, 5); | |
Evan Stade
2017/03/02 02:32:01
sorry, what I actually meant here was something li
bokan
2017/03/02 13:55:36
Ah, that does sound better. Done (names slightly a
| |
38 const gfx::Rect kOverlayScrollbarNinePatchAperture(2, 2, 1, 1); | |
37 | 39 |
38 const SkColor kTrackColor = SkColorSetRGB(0xF1, 0xF1, 0xF1); | 40 const SkColor kTrackColor = SkColorSetRGB(0xF1, 0xF1, 0xF1); |
39 | 41 |
40 } // namespace | 42 } // namespace |
41 | 43 |
42 //////////////////////////////////////////////////////////////////////////////// | 44 //////////////////////////////////////////////////////////////////////////////// |
43 // NativeTheme: | 45 // NativeTheme: |
44 | 46 |
45 // static | 47 // static |
46 NativeTheme* NativeTheme::GetInstanceForWeb() { | 48 NativeTheme* NativeTheme::GetInstanceForWeb() { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 // TODO(bokan): We should probably make sure code using overlay | 312 // TODO(bokan): We should probably make sure code using overlay |
311 // scrollbars isn't asking for part sizes that don't exist. | 313 // scrollbars isn't asking for part sizes that don't exist. |
312 // crbug.com/657159. | 314 // crbug.com/657159. |
313 break; | 315 break; |
314 } | 316 } |
315 } | 317 } |
316 | 318 |
317 return NativeThemeBase::GetPartSize(part, state, extra); | 319 return NativeThemeBase::GetPartSize(part, state, extra); |
318 } | 320 } |
319 | 321 |
322 bool NativeThemeAura::SupportsNinePatch(Part part) const { | |
323 if (!IsOverlayScrollbarEnabled()) | |
324 return false; | |
325 | |
326 return part == kScrollbarHorizontalThumb || part == kScrollbarVerticalThumb; | |
327 } | |
328 | |
329 gfx::Size NativeThemeAura::GetNinePatchCanvasSize(Part part) const { | |
330 DCHECK(SupportsNinePatch(part)); | |
331 | |
332 // 2 pixel border with 1 pixel center patch. The border is 2 pixels so that | |
333 // the inner pixel can match the center tile color. This prevents color | |
334 // interpolation between the patches. | |
335 return kOverlayScrollbarNinePatchCanvasSize; | |
336 } | |
337 | |
338 gfx::Rect NativeThemeAura::GetNinePatchAperture(Part part) const { | |
339 DCHECK(SupportsNinePatch(part)); | |
340 | |
341 // The aperture is a single pixel surrounded by a non-resizing 2 pixel border. | |
342 // The stroke is actually only 1 pixel wide but we need to use 2 pixels so | |
343 // that the center patch doesn't try to blend colors between patches. | |
344 return kOverlayScrollbarNinePatchAperture; | |
345 } | |
346 | |
320 } // namespace ui | 347 } // namespace ui |
OLD | NEW |