Chromium Code Reviews| Index: chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc |
| diff --git a/chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc b/chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc |
| index 15ef6cfc20ead35d04e0b9acc06940bfd28d58a7..d5b167303b8cd23ef91c3859b04c240509bbd686 100644 |
| --- a/chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc |
| +++ b/chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc |
| @@ -2,8 +2,8 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "ash/shell.h" |
| #include "chrome/browser/chromeos/accessibility/accessibility_highlight_manager.h" |
|
xiyuan
2017/06/22 17:19:13
nit: insert an empty line after
Maajid
2017/06/27 02:25:16
Done.
|
| +#include "ash/shell.h" |
| #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" |
| #include "content/public/browser/focused_node_details.h" |
| #include "content/public/browser/notification_service.h" |
| @@ -11,6 +11,7 @@ |
| #include "ui/aura/window_tree_host.h" |
| #include "ui/wm/core/coordinate_conversion.h" |
| #include "ui/wm/core/cursor_manager.h" |
| +#include "ui/wm/public/activation_client.h" |
| namespace chromeos { |
| @@ -24,8 +25,7 @@ ui::InputMethod* GetInputMethod(aura::Window* root_window) { |
| } // namespace |
| -AccessibilityHighlightManager::AccessibilityHighlightManager() { |
| -} |
| +AccessibilityHighlightManager::AccessibilityHighlightManager() {} |
| AccessibilityHighlightManager::~AccessibilityHighlightManager() { |
| // No need to do anything during shutdown |
| @@ -119,10 +119,18 @@ void AccessibilityHighlightManager::OnTextInputStateChanged( |
| void AccessibilityHighlightManager::OnCaretBoundsChanged( |
| const ui::TextInputClient* client) { |
| + if (!client || client->GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) { |
| + caret_visible_ = false; |
| + return; |
| + } |
| gfx::Rect caret_bounds = client->GetCaretBounds(); |
| - caret_point_ = caret_bounds.CenterPoint(); |
| - caret_visible_ = client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE && |
| - (caret_bounds.width() || caret_bounds.height()); |
| + gfx::Point new_caret_point = caret_bounds.CenterPoint(); |
| + ::wm::ConvertPointFromScreen(ash::Shell::GetPrimaryRootWindow(), |
| + &new_caret_point); |
| + if (new_caret_point == caret_point_) |
| + return; |
| + caret_point_ = new_caret_point; |
| + caret_visible_ = IsCaretVisible(caret_bounds); |
| UpdateFocusAndCaretHighlights(); |
| } |
| @@ -134,6 +142,17 @@ bool AccessibilityHighlightManager::IsCursorVisible() { |
| return ash::Shell::Get()->cursor_manager()->IsCursorVisible(); |
| } |
| +bool AccessibilityHighlightManager::IsCaretVisible( |
| + const gfx::Rect caret_bounds) { |
| + aura::Window* root_window = ash::Shell::GetPrimaryRootWindow(); |
| + aura::Window* active_window = |
| + ::wm::GetActivationClient(root_window)->GetActiveWindow(); |
| + if (!active_window) |
| + active_window = root_window; |
| + return (caret_bounds.width() || caret_bounds.height()) && |
| + active_window->GetBoundsInScreen().Contains(caret_point_); |
| +} |
| + |
| void AccessibilityHighlightManager::UpdateFocusAndCaretHighlights() { |
| auto* controller = AccessibilityFocusRingController::GetInstance(); |