Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "chrome/browser/chromeos/ui/accessibility_cursor_ring_layer.h" | 15 #include "chrome/browser/chromeos/ui/accessibility_cursor_ring_layer.h" |
| 16 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_layer.h" | 16 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_layer.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
| 18 | 18 |
| 19 namespace chromeos { | 19 namespace chromeos { |
| 20 | 20 |
| 21 // AccessibilityFocusRingController handles drawing custom rings around | 21 // AccessibilityFocusRingController handles drawing custom rings around |
| 22 // the focused object, cursor, and/or caret for accessibility. | 22 // the focused object, cursor, and/or caret for accessibility. |
| 23 class AccessibilityFocusRingController : public FocusRingLayerDelegate { | 23 class AccessibilityFocusRingController : public FocusRingLayerDelegate { |
| 24 public: | 24 public: |
| 25 // Get the single instance of this class. | 25 // Get the single instance of this class. |
| 26 static AccessibilityFocusRingController* GetInstance(); | 26 static AccessibilityFocusRingController* GetInstance(); |
| 27 | 27 |
| 28 enum FocusRingBehavior { FADE_OUT_FOCUS_RING, PERSIST_FOCUS_RING }; | 28 enum FocusRingBehavior { FADE_OUT_FOCUS_RING, PERSIST_FOCUS_RING }; |
| 29 | 29 |
| 30 // Set the focus ring color, or reset it back to the default. | |
| 31 void SetFocusRingColor(SkColor color); | |
|
xiyuan
2017/03/30 21:27:38
nit: #include "third_party/skia/include/core/SkCol
dmazzoni
2017/03/30 21:34:52
Done.
| |
| 32 void ResetFocusRingColor(); | |
| 33 | |
| 30 // Draw a focus ring around the given set of rects, in global screen | 34 // Draw a focus ring around the given set of rects, in global screen |
| 31 // coordinates. Use |focus_ring_behavior| to specify whether the focus | 35 // coordinates. Use |focus_ring_behavior| to specify whether the focus |
| 32 // ring should persist or fade out. | 36 // ring should persist or fade out. |
| 33 void SetFocusRing(const std::vector<gfx::Rect>& rects, | 37 void SetFocusRing(const std::vector<gfx::Rect>& rects, |
| 34 FocusRingBehavior focus_ring_behavior); | 38 FocusRingBehavior focus_ring_behavior); |
| 35 void HideFocusRing(); | 39 void HideFocusRing(); |
| 36 | 40 |
| 37 // Draw a ring around the mouse cursor. It fades out automatically. | 41 // Draw a ring around the mouse cursor. It fades out automatically. |
| 38 void SetCursorRing(const gfx::Point& location); | 42 void SetCursorRing(const gfx::Point& location); |
| 39 void HideCursorRing(); | 43 void HideCursorRing(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 void OnLayerChange(LayerAnimationInfo* animation_info); | 97 void OnLayerChange(LayerAnimationInfo* animation_info); |
| 94 void ComputeOpacity(LayerAnimationInfo* animation_info, | 98 void ComputeOpacity(LayerAnimationInfo* animation_info, |
| 95 base::TimeTicks timestamp); | 99 base::TimeTicks timestamp); |
| 96 | 100 |
| 97 LayerAnimationInfo focus_animation_info_; | 101 LayerAnimationInfo focus_animation_info_; |
| 98 std::vector<gfx::Rect> focus_rects_; | 102 std::vector<gfx::Rect> focus_rects_; |
| 99 std::vector<AccessibilityFocusRing> previous_focus_rings_; | 103 std::vector<AccessibilityFocusRing> previous_focus_rings_; |
| 100 std::vector<AccessibilityFocusRing> focus_rings_; | 104 std::vector<AccessibilityFocusRing> focus_rings_; |
| 101 std::vector<std::unique_ptr<AccessibilityFocusRingLayer>> focus_layers_; | 105 std::vector<std::unique_ptr<AccessibilityFocusRingLayer>> focus_layers_; |
| 102 FocusRingBehavior focus_ring_behavior_ = FADE_OUT_FOCUS_RING; | 106 FocusRingBehavior focus_ring_behavior_ = FADE_OUT_FOCUS_RING; |
| 107 bool has_focus_ring_color_ = false; | |
| 108 SkColor focus_ring_color_ = SK_ColorBLACK; | |
| 103 | 109 |
| 104 LayerAnimationInfo cursor_animation_info_; | 110 LayerAnimationInfo cursor_animation_info_; |
| 105 gfx::Point cursor_location_; | 111 gfx::Point cursor_location_; |
| 106 std::unique_ptr<AccessibilityCursorRingLayer> cursor_layer_; | 112 std::unique_ptr<AccessibilityCursorRingLayer> cursor_layer_; |
| 107 | 113 |
| 108 LayerAnimationInfo caret_animation_info_; | 114 LayerAnimationInfo caret_animation_info_; |
| 109 gfx::Point caret_location_; | 115 gfx::Point caret_location_; |
| 110 std::unique_ptr<AccessibilityCursorRingLayer> caret_layer_; | 116 std::unique_ptr<AccessibilityCursorRingLayer> caret_layer_; |
| 111 | 117 |
| 112 friend struct base::DefaultSingletonTraits<AccessibilityFocusRingController>; | 118 friend struct base::DefaultSingletonTraits<AccessibilityFocusRingController>; |
| 113 | 119 |
| 114 DISALLOW_COPY_AND_ASSIGN(AccessibilityFocusRingController); | 120 DISALLOW_COPY_AND_ASSIGN(AccessibilityFocusRingController); |
| 115 }; | 121 }; |
| 116 | 122 |
| 117 } // namespace chromeos | 123 } // namespace chromeos |
| 118 | 124 |
| 119 #endif // CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ | 125 #endif // CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ |
| OLD | NEW |