Chromium Code Reviews| 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" |
| 11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "cc/paint/paint_canvas.h" | 13 #include "cc/paint/paint_canvas.h" |
| 14 #include "cc/paint/paint_flags.h" | 14 #include "cc/paint/paint_flags.h" |
| 15 #include "ui/base/layout.h" | 15 #include "ui/base/layout.h" |
| 16 #include "ui/base/material_design/material_design_controller.h" | 16 #include "ui/base/material_design/material_design_controller.h" |
| 17 #include "ui/gfx/animation/tween.h" | 17 #include "ui/gfx/animation/tween.h" |
| 18 #include "ui/gfx/canvas.h" | 18 #include "ui/gfx/canvas.h" |
| 19 #include "ui/gfx/color_palette.h" | 19 #include "ui/gfx/color_palette.h" |
| 20 #include "ui/gfx/geometry/insets.h" | |
| 20 #include "ui/gfx/geometry/rect.h" | 21 #include "ui/gfx/geometry/rect.h" |
| 21 #include "ui/gfx/geometry/size.h" | 22 #include "ui/gfx/geometry/size.h" |
| 22 #include "ui/gfx/image/image_skia.h" | 23 #include "ui/gfx/image/image_skia.h" |
| 23 #include "ui/gfx/path.h" | 24 #include "ui/gfx/path.h" |
| 24 #include "ui/gfx/skia_util.h" | 25 #include "ui/gfx/skia_util.h" |
| 25 #include "ui/native_theme/common_theme.h" | 26 #include "ui/native_theme/common_theme.h" |
| 26 #include "ui/native_theme/native_theme_switches.h" | 27 #include "ui/native_theme/native_theme_switches.h" |
| 27 #include "ui/native_theme/overlay_scrollbar_constants_aura.h" | 28 #include "ui/native_theme/overlay_scrollbar_constants_aura.h" |
| 28 | 29 |
| 29 namespace ui { | 30 namespace ui { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 SkColorSetA(kOverlayScrollbarStrokeColor[theme], stroke_alpha)); | 245 SkColorSetA(kOverlayScrollbarStrokeColor[theme], stroke_alpha)); |
| 245 flags.setStyle(cc::PaintFlags::kStroke_Style); | 246 flags.setStyle(cc::PaintFlags::kStroke_Style); |
| 246 flags.setStrokeWidth(kStrokeWidth); | 247 flags.setStrokeWidth(kStrokeWidth); |
| 247 | 248 |
| 248 gfx::RectF stroke_rect(thumb_rect); | 249 gfx::RectF stroke_rect(thumb_rect); |
| 249 constexpr float kHalfStrokeWidth = kStrokeWidth / 2.f; | 250 constexpr float kHalfStrokeWidth = kStrokeWidth / 2.f; |
| 250 stroke_rect.Inset(kHalfStrokeWidth, kHalfStrokeWidth); | 251 stroke_rect.Inset(kHalfStrokeWidth, kHalfStrokeWidth); |
| 251 canvas->drawRect(gfx::RectFToSkRect(stroke_rect), flags); | 252 canvas->drawRect(gfx::RectFToSkRect(stroke_rect), flags); |
| 252 | 253 |
| 253 // Inset the all the edges edges so we fill-in the stroke below. | 254 // Inset the all the edges edges so we fill-in the stroke below. |
| 254 thumb_rect.Inset(kStrokeWidth, kStrokeWidth); | 255 // The edge to which the scrollbar is attached shouldn't have a border. |
| 256 // For left vertical scrollbar, we will filp the canvas in | |
|
bokan
2017/03/29 18:41:48
Nit: same typo here.
| |
| 257 // ScrollbarThemeOverlay::paintThumb. | |
| 258 gfx::Insets insets(kStrokeWidth); | |
| 259 if (part == NativeTheme::kScrollbarHorizontalThumb) | |
| 260 insets -= gfx::Insets(0, 0, kStrokeWidth, 0); | |
| 261 else | |
| 262 insets -= gfx::Insets(0, 0, 0, kStrokeWidth); | |
| 263 | |
| 264 thumb_rect.Inset(insets); | |
| 255 } else { | 265 } else { |
| 256 switch (state) { | 266 switch (state) { |
| 257 case NativeTheme::kDisabled: | 267 case NativeTheme::kDisabled: |
| 258 thumb_alpha = SK_AlphaTRANSPARENT; | 268 thumb_alpha = SK_AlphaTRANSPARENT; |
| 259 break; | 269 break; |
| 260 case NativeTheme::kHovered: | 270 case NativeTheme::kHovered: |
| 261 thumb_alpha = 0x4D; | 271 thumb_alpha = 0x4D; |
| 262 break; | 272 break; |
| 263 case NativeTheme::kNormal: | 273 case NativeTheme::kNormal: |
| 264 thumb_alpha = 0x33; | 274 thumb_alpha = 0x33; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 | 350 |
| 341 gfx::Rect NativeThemeAura::GetNinePatchAperture(Part part) const { | 351 gfx::Rect NativeThemeAura::GetNinePatchAperture(Part part) const { |
| 342 DCHECK(SupportsNinePatch(part)); | 352 DCHECK(SupportsNinePatch(part)); |
| 343 | 353 |
| 344 return gfx::Rect( | 354 return gfx::Rect( |
| 345 kOverlayScrollbarBorderPatchWidth, kOverlayScrollbarBorderPatchWidth, | 355 kOverlayScrollbarBorderPatchWidth, kOverlayScrollbarBorderPatchWidth, |
| 346 kOverlayScrollbarCenterPatchSize, kOverlayScrollbarCenterPatchSize); | 356 kOverlayScrollbarCenterPatchSize, kOverlayScrollbarCenterPatchSize); |
| 347 } | 357 } |
| 348 | 358 |
| 349 } // namespace ui | 359 } // namespace ui |
| OLD | NEW |