Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: chrome/browser/chromeos/ui/focus_ring_layer.h

Issue 2789583004: Add a color argument to accessibilityPrivate.setFocusRing (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_FOCUS_RING_LAYER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_
6 #define CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_ 6 #define CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/optional.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "third_party/skia/include/core/SkColor.h"
12 #include "ui/compositor/compositor_animation_observer.h" 14 #include "ui/compositor/compositor_animation_observer.h"
13 #include "ui/compositor/layer_delegate.h" 15 #include "ui/compositor/layer_delegate.h"
14 #include "ui/gfx/geometry/rect.h" 16 #include "ui/gfx/geometry/rect.h"
15 17
16 namespace aura { 18 namespace aura {
17 class Window; 19 class Window;
18 } 20 }
19 21
20 namespace ui { 22 namespace ui {
21 class Compositor; 23 class Compositor;
(...skipping 23 matching lines...) Expand all
45 // the given root window. 47 // the given root window.
46 void Set(aura::Window* root_window, const gfx::Rect& bounds); 48 void Set(aura::Window* root_window, const gfx::Rect& bounds);
47 49
48 // Returns true if this layer is in a composited window with an 50 // Returns true if this layer is in a composited window with an
49 // animation observer. 51 // animation observer.
50 bool CanAnimate() const; 52 bool CanAnimate() const;
51 53
52 // Set the layer's opacity. 54 // Set the layer's opacity.
53 void SetOpacity(float opacity); 55 void SetOpacity(float opacity);
54 56
57 // Set a custom color, or reset to the default.
58 void SetColor(SkColor color);
59 void ResetColor();
60
55 ui::Layer* layer() { return layer_.get(); } 61 ui::Layer* layer() { return layer_.get(); }
56 aura::Window* root_window() { return root_window_; } 62 aura::Window* root_window() { return root_window_; }
57 63
58 protected: 64 protected:
59 // Updates |root_window_| and creates |layer_| if it doesn't exist, 65 // Updates |root_window_| and creates |layer_| if it doesn't exist,
60 // or if the root window has changed. Moves the layer to the top if 66 // or if the root window has changed. Moves the layer to the top if
61 // it wasn't there already. 67 // it wasn't there already.
62 void CreateOrUpdateLayer(aura::Window* root_window, 68 void CreateOrUpdateLayer(aura::Window* root_window,
63 const char* layer_name, 69 const char* layer_name,
64 const gfx::Rect& bounds); 70 const gfx::Rect& bounds);
65 71
72 bool has_custom_color() { return custom_color_.has_value(); }
73 SkColor custom_color() { return *custom_color_; }
74
66 private: 75 private:
67 // ui::LayerDelegate overrides: 76 // ui::LayerDelegate overrides:
68 void OnPaintLayer(const ui::PaintContext& context) override; 77 void OnPaintLayer(const ui::PaintContext& context) override;
69 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override; 78 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override;
70 void OnDeviceScaleFactorChanged(float device_scale_factor) override; 79 void OnDeviceScaleFactorChanged(float device_scale_factor) override;
71 80
72 // CompositorAnimationObserver overrides: 81 // CompositorAnimationObserver overrides:
73 void OnAnimationStep(base::TimeTicks timestamp) override; 82 void OnAnimationStep(base::TimeTicks timestamp) override;
74 void OnCompositingShuttingDown(ui::Compositor* compositor) override; 83 void OnCompositingShuttingDown(ui::Compositor* compositor) override;
75 84
76 // The object that owns this layer. 85 // The object that owns this layer.
77 FocusRingLayerDelegate* delegate_; 86 FocusRingLayerDelegate* delegate_;
78 87
79 // The current root window containing the focused object. 88 // The current root window containing the focused object.
80 aura::Window* root_window_; 89 aura::Window* root_window_ = nullptr;
81 90
82 // The current layer. 91 // The current layer.
83 std::unique_ptr<ui::Layer> layer_; 92 std::unique_ptr<ui::Layer> layer_;
84 93
85 // The bounding rectangle of the focused object, in |root_window_| 94 // The bounding rectangle of the focused object, in |root_window_|
86 // coordinates. 95 // coordinates.
87 gfx::Rect focus_ring_; 96 gfx::Rect focus_ring_;
88 97
98 base::Optional<SkColor> custom_color_;
99
89 // The compositor associated with this layer. 100 // The compositor associated with this layer.
90 ui::Compositor* compositor_; 101 ui::Compositor* compositor_ = nullptr;
91 102
92 DISALLOW_COPY_AND_ASSIGN(FocusRingLayer); 103 DISALLOW_COPY_AND_ASSIGN(FocusRingLayer);
93 }; 104 };
94 105
95 } // namespace chromeos 106 } // namespace chromeos
96 107
97 #endif // CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_ 108 #endif // CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/ui/accessibility_focus_ring_layer.cc ('k') | chrome/browser/chromeos/ui/focus_ring_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698