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

Side by Side Diff: chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc

Issue 2388093004: Explicitly show and hide accessible rings rather than using offscreen coords. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 "ash/shell.h" 5 #include "ash/shell.h"
6 #include "chrome/browser/chromeos/accessibility/accessibility_highlight_manager. h" 6 #include "chrome/browser/chromeos/accessibility/accessibility_highlight_manager. h"
7 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" 7 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h"
8 #include "content/public/browser/focused_node_details.h" 8 #include "content/public/browser/focused_node_details.h"
9 #include "content/public/browser/notification_service.h" 9 #include "content/public/browser/notification_service.h"
10 #include "content/public/browser/notification_types.h" 10 #include "content/public/browser/notification_types.h"
11 #include "ui/aura/window_tree_host.h" 11 #include "ui/aura/window_tree_host.h"
12 #include "ui/wm/core/cursor_manager.h" 12 #include "ui/wm/core/cursor_manager.h"
13 13
14 namespace chromeos { 14 namespace chromeos {
15 15
16 namespace { 16 namespace {
17 17
18 const gfx::Rect& OffscreenRect() {
19 CR_DEFINE_STATIC_LOCAL(const gfx::Rect, r, (INT_MIN, INT_MIN, 0, 0));
20 return r;
21 }
22
23 const gfx::Point& OffscreenPoint() {
24 CR_DEFINE_STATIC_LOCAL(const gfx::Point, p, (INT_MIN, INT_MIN));
25 return p;
26 }
27
28 ui::InputMethod* GetInputMethod(aura::Window* root_window) { 18 ui::InputMethod* GetInputMethod(aura::Window* root_window) {
29 if (root_window->GetHost()) 19 if (root_window->GetHost())
30 return root_window->GetHost()->GetInputMethod(); 20 return root_window->GetHost()->GetInputMethod();
31 return nullptr; 21 return nullptr;
32 } 22 }
33 23
34 } // namespace 24 } // namespace
35 25
36 AccessibilityHighlightManager::AccessibilityHighlightManager() { 26 AccessibilityHighlightManager::AccessibilityHighlightManager() {
37 focus_rect_ = OffscreenRect();
38 cursor_point_ = OffscreenPoint();
39 caret_point_ = OffscreenPoint();
40 } 27 }
41 28
42 AccessibilityHighlightManager::~AccessibilityHighlightManager() { 29 AccessibilityHighlightManager::~AccessibilityHighlightManager() {
43 // No need to do anything during shutdown 30 // No need to do anything during shutdown
44 if (!ash::Shell::HasInstance()) 31 if (!ash::Shell::HasInstance())
45 return; 32 return;
46 33
47 AccessibilityFocusRingController::GetInstance()->SetFocusRing( 34 AccessibilityFocusRingController::GetInstance()->SetFocusRing(
48 std::vector<gfx::Rect>(), 35 std::vector<gfx::Rect>(),
49 AccessibilityFocusRingController::FADE_OUT_FOCUS_RING); 36 AccessibilityFocusRingController::FADE_OUT_FOCUS_RING);
50 AccessibilityFocusRingController::GetInstance()->SetCaretRing( 37 AccessibilityFocusRingController::GetInstance()->HideCaretRing();
51 OffscreenPoint()); 38 AccessibilityFocusRingController::GetInstance()->HideCursorRing();
52 AccessibilityFocusRingController::GetInstance()->SetCursorRing(
53 OffscreenPoint());
54 39
55 ash::Shell* shell = ash::Shell::GetInstance(); 40 ash::Shell* shell = ash::Shell::GetInstance();
56 if (shell && registered_observers_) { 41 if (shell && registered_observers_) {
57 shell->RemovePreTargetHandler(this); 42 shell->RemovePreTargetHandler(this);
58 shell->cursor_manager()->RemoveObserver(this); 43 shell->cursor_manager()->RemoveObserver(this);
59 44
60 aura::Window* root_window = shell->GetPrimaryRootWindow(); 45 aura::Window* root_window = shell->GetPrimaryRootWindow();
61 ui::InputMethod* input_method = GetInputMethod(root_window); 46 ui::InputMethod* input_method = GetInputMethod(root_window);
62 input_method->RemoveObserver(this); 47 input_method->RemoveObserver(this);
63 } 48 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 auto* controller = AccessibilityFocusRingController::GetInstance(); 127 auto* controller = AccessibilityFocusRingController::GetInstance();
143 128
144 // The caret highlight takes precedence over the focus highlight if 129 // The caret highlight takes precedence over the focus highlight if
145 // both are visible. 130 // both are visible.
146 if (caret_ && caret_visible_) { 131 if (caret_ && caret_visible_) {
147 controller->SetCaretRing(caret_point_); 132 controller->SetCaretRing(caret_point_);
148 controller->SetFocusRing( 133 controller->SetFocusRing(
149 std::vector<gfx::Rect>(), 134 std::vector<gfx::Rect>(),
150 AccessibilityFocusRingController::FADE_OUT_FOCUS_RING); 135 AccessibilityFocusRingController::FADE_OUT_FOCUS_RING);
151 } else if (focus_) { 136 } else if (focus_) {
152 controller->SetCaretRing(OffscreenPoint()); 137 controller->HideCaretRing();
153 std::vector<gfx::Rect> rects; 138 std::vector<gfx::Rect> rects;
154 if (!focus_rect_.IsEmpty()) 139 if (!focus_rect_.IsEmpty())
155 rects.push_back(focus_rect_); 140 rects.push_back(focus_rect_);
156 controller->SetFocusRing( 141 controller->SetFocusRing(
157 rects, AccessibilityFocusRingController::FADE_OUT_FOCUS_RING); 142 rects, AccessibilityFocusRingController::FADE_OUT_FOCUS_RING);
158 } else { 143 } else {
159 controller->SetCaretRing(OffscreenPoint()); 144 controller->HideCaretRing();
160 controller->SetFocusRing( 145 controller->SetFocusRing(
161 std::vector<gfx::Rect>(), 146 std::vector<gfx::Rect>(),
162 AccessibilityFocusRingController::FADE_OUT_FOCUS_RING); 147 AccessibilityFocusRingController::FADE_OUT_FOCUS_RING);
163 } 148 }
164 } 149 }
165 150
166 void AccessibilityHighlightManager::UpdateCursorHighlight() { 151 void AccessibilityHighlightManager::UpdateCursorHighlight() {
167 gfx::Point point = cursor_point_; 152 if (cursor_ && IsCursorVisible()) {
168 153 AccessibilityFocusRingController::GetInstance()->SetCursorRing(
169 if (!cursor_) 154 cursor_point_);
170 point = OffscreenPoint(); 155 } else {
171 156 AccessibilityFocusRingController::GetInstance()->HideCursorRing();
172 if (!IsCursorVisible()) 157 }
173 point = OffscreenPoint();
174
175 AccessibilityFocusRingController::GetInstance()->SetCursorRing(point);
176 } 158 }
177 159
178 } // namespace chromeos 160 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698