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

Unified Diff: chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc

Issue 2945143002: Modify the accessibility highlight manager to account for the text caret being drawn outside of the… (Closed)
Patch Set: Rebase Created 3 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 side-by-side diff with in-line comments
Download patch
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..f2131dac14eec3db912e1374fc61beee43a96eef 100644
--- a/chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc
+++ b/chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc
@@ -2,8 +2,9 @@
// 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"
+
+#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 +12,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 +26,7 @@ ui::InputMethod* GetInputMethod(aura::Window* root_window) {
} // namespace
-AccessibilityHighlightManager::AccessibilityHighlightManager() {
-}
+AccessibilityHighlightManager::AccessibilityHighlightManager() {}
AccessibilityHighlightManager::~AccessibilityHighlightManager() {
// No need to do anything during shutdown
@@ -119,10 +120,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 +143,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();

Powered by Google App Engine
This is Rietveld 408576698