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

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

Issue 2038093003: Refactor accessible focus ring code so the layers are animation observers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@improve_highlights
Patch Set: Created 4 years, 6 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/time/time.h"
12 #include "ui/compositor/compositor_animation_observer.h"
11 #include "ui/compositor/layer_delegate.h" 13 #include "ui/compositor/layer_delegate.h"
12 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
13 15
14 namespace aura { 16 namespace aura {
15 class Window; 17 class Window;
16 } 18 }
17 19
18 namespace ui { 20 namespace ui {
21 class Compositor;
19 class Layer; 22 class Layer;
20 } 23 }
21 24
22 namespace chromeos { 25 namespace chromeos {
23 26
24 // A delegate interface implemented by the object that owns a FocusRingLayer. 27 // A delegate interface implemented by the object that owns a FocusRingLayer.
25 class FocusRingLayerDelegate { 28 class FocusRingLayerDelegate {
26 public: 29 public:
27 virtual void OnDeviceScaleFactorChanged() = 0; 30 virtual void OnDeviceScaleFactorChanged() = 0;
31 virtual void OnAnimationStep(base::TimeTicks timestamp) = 0;
28 32
29 protected: 33 protected:
30 virtual ~FocusRingLayerDelegate(); 34 virtual ~FocusRingLayerDelegate();
31 }; 35 };
32 36
33 // FocusRingLayer draws a focus ring at a given global rectangle. 37 // FocusRingLayer draws a focus ring at a given global rectangle.
34 class FocusRingLayer : public ui::LayerDelegate { 38 class FocusRingLayer : public ui::LayerDelegate,
39 public ui::CompositorAnimationObserver {
35 public: 40 public:
36 explicit FocusRingLayer(FocusRingLayerDelegate* delegate); 41 explicit FocusRingLayer(FocusRingLayerDelegate* delegate);
37 ~FocusRingLayer() override; 42 ~FocusRingLayer() override;
38 43
39 // Move the focus ring layer to the given bounds in the coordinates of 44 // Move the focus ring layer to the given bounds in the coordinates of
40 // the given root window. 45 // the given root window.
41 void Set(aura::Window* root_window, const gfx::Rect& bounds); 46 void Set(aura::Window* root_window, const gfx::Rect& bounds);
42 47
48 // Returns true if this layer is in a composited window with an
49 // animation observer.
50 bool CanAnimate() const;
51
43 ui::Layer* layer() { return layer_.get(); } 52 ui::Layer* layer() { return layer_.get(); }
44 aura::Window* root_window() { return root_window_; } 53 aura::Window* root_window() { return root_window_; }
45 54
46 protected: 55 protected:
47 // Updates |root_window_| and creates |layer_| if it doesn't exist, 56 // Updates |root_window_| and creates |layer_| if it doesn't exist,
48 // or if the root window has changed. Moves the layer to the top if 57 // or if the root window has changed. Moves the layer to the top if
49 // it wasn't there already. 58 // it wasn't there already.
50 void CreateOrUpdateLayer(aura::Window* root_window, const char* layer_name); 59 void CreateOrUpdateLayer(aura::Window* root_window,
60 const char* layer_name,
61 const gfx::Rect& bounds);
51 62
52 private: 63 private:
53 // ui::LayerDelegate overrides: 64 // ui::LayerDelegate overrides:
54 void OnPaintLayer(const ui::PaintContext& context) override; 65 void OnPaintLayer(const ui::PaintContext& context) override;
55 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override; 66 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override;
56 void OnDeviceScaleFactorChanged(float device_scale_factor) override; 67 void OnDeviceScaleFactorChanged(float device_scale_factor) override;
57 base::Closure PrepareForLayerBoundsChange() override; 68 base::Closure PrepareForLayerBoundsChange() override;
58 69
70 // CompositorAnimationObserver overrides:
71 void OnAnimationStep(base::TimeTicks timestamp) override;
72 void OnCompositingShuttingDown(ui::Compositor* compositor) override;
73
59 // The object that owns this layer. 74 // The object that owns this layer.
60 FocusRingLayerDelegate* delegate_; 75 FocusRingLayerDelegate* delegate_;
61 76
62 // The current root window containing the focused object. 77 // The current root window containing the focused object.
63 aura::Window* root_window_; 78 aura::Window* root_window_;
64 79
65 // The current layer. 80 // The current layer.
66 std::unique_ptr<ui::Layer> layer_; 81 std::unique_ptr<ui::Layer> layer_;
67 82
68 // The bounding rectangle of the focused object, in |root_window_| 83 // The bounding rectangle of the focused object, in |root_window_|
69 // coordinates. 84 // coordinates.
70 gfx::Rect focus_ring_; 85 gfx::Rect focus_ring_;
71 86
87 // The compositor associated with this layer.
88 ui::Compositor* compositor_;
89
72 DISALLOW_COPY_AND_ASSIGN(FocusRingLayer); 90 DISALLOW_COPY_AND_ASSIGN(FocusRingLayer);
73 }; 91 };
74 92
75 } // namespace chromeos 93 } // namespace chromeos
76 94
77 #endif // CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_ 95 #endif // CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_LAYER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/ui/focus_ring_controller.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