OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/gtest_prod_util.h" | |
xiyuan
2014/09/11 03:33:11
nit: seems not used.
dmazzoni
2014/09/11 21:44:39
Done.
| |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/memory/singleton.h" | |
12 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_layer.h" | |
13 #include "ui/gfx/rect.h" | |
14 | |
15 namespace chromeos { | |
16 | |
17 // AccessibilityFocusRingController manages a custom focus ring (or multiple | |
18 // rings) for accessibility. | |
19 class AccessibilityFocusRingController : public FocusRingLayerDelegate { | |
20 public: | |
21 // Get the single instance of this class. | |
22 static AccessibilityFocusRingController* GetInstance(); | |
23 | |
24 // Draw a focus ring around the given set of rects, in global screen | |
25 // coordinates. | |
26 void SetFocusRing(const std::vector<gfx::Rect>& rects); | |
27 | |
28 protected: | |
29 AccessibilityFocusRingController(); | |
30 virtual ~AccessibilityFocusRingController(); | |
31 | |
32 // Given an unordered vector of bounding rectangles that cover everything | |
33 // that currently has focus, populate a vector of one or more | |
34 // AccessibilityFocusRings that surround the rectangles. Adjacent or | |
35 // overlapping rectangles are combined first. This function is protected | |
36 // so it can be unit-tested. | |
37 void RectsToRings(const std::vector<gfx::Rect>& rects, | |
38 std::vector<AccessibilityFocusRing>* rings) const; | |
39 | |
40 virtual int GetMargin() const; | |
41 | |
42 private: | |
43 // FocusRingLayerDelegate. | |
44 virtual void OnDeviceScaleFactorChanged() OVERRIDE; | |
45 | |
46 void Update(); | |
47 | |
48 AccessibilityFocusRing RingFromSortedRects( | |
49 const std::vector<gfx::Rect>& rects) const; | |
50 void SplitIntoParagraphShape( | |
51 const std::vector<gfx::Rect>& rects, | |
52 gfx::Rect* top, | |
53 gfx::Rect* middle, | |
54 gfx::Rect* bottom) const; | |
55 bool Intersects(const gfx::Rect& r1, const gfx::Rect& r2) const; | |
56 | |
57 std::vector<gfx::Rect> rects_; | |
58 std::vector<AccessibilityFocusRing> rings_; | |
59 scoped_ptr<AccessibilityFocusRingLayer> main_focus_ring_layer_; | |
60 std::vector<scoped_ptr<AccessibilityFocusRingLayer> > extra_layers_; | |
61 | |
62 friend struct DefaultSingletonTraits<AccessibilityFocusRingController>; | |
63 | |
64 DISALLOW_COPY_AND_ASSIGN(AccessibilityFocusRingController); | |
65 }; | |
66 | |
67 } // namespace chromeos | |
68 | |
69 #endif // CHROME_BROWSER_CHROMEOS_UI_ACCESSIBILITY_FOCUS_RING_CONTROLLER_H_ | |
OLD | NEW |