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

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

Issue 2036343003: Chrome OS highlighting: show only focus or caret, never both. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/accessibility/accessibility_highlight_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e63d3e66ab81364d7b2cb0bd43daeadd6f49f84f..786de38d8aa069692678c318866dc4722e772ae8 100644
--- a/chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc
+++ b/chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc
@@ -68,10 +68,7 @@ AccessibilityHighlightManager::~AccessibilityHighlightManager() {
void AccessibilityHighlightManager::HighlightFocus(bool focus) {
focus_ = focus;
-
- std::vector<gfx::Rect> rects;
- rects.push_back(focus_ ? focus_rect_ : OffscreenRect());
- AccessibilityFocusRingController::GetInstance()->SetFocusRing(rects);
+ UpdateFocusAndCaretHighlights();
}
void AccessibilityHighlightManager::HighlightCursor(bool cursor) {
@@ -83,9 +80,7 @@ void AccessibilityHighlightManager::HighlightCursor(bool cursor) {
void AccessibilityHighlightManager::HighlightCaret(bool caret) {
caret_ = caret;
-
- AccessibilityFocusRingController::GetInstance()->SetCaretRing(
- caret_ ? caret_point_ : OffscreenPoint());
+ UpdateFocusAndCaretHighlights();
}
void AccessibilityHighlightManager::OnMouseEvent(ui::MouseEvent* event) {
@@ -104,34 +99,44 @@ void AccessibilityHighlightManager::Observe(
content::FocusedNodeDetails* node_details =
content::Details<content::FocusedNodeDetails>(details).ptr();
focus_rect_ = node_details->node_bounds_in_screen;
-
- if (focus_) {
- std::vector<gfx::Rect> rects;
- rects.push_back(focus_rect_);
- AccessibilityFocusRingController::GetInstance()->SetFocusRing(rects);
- }
+ UpdateFocusAndCaretHighlights();
}
void AccessibilityHighlightManager::OnTextInputStateChanged(
const ui::TextInputClient* client) {
if (!client || client->GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) {
- caret_point_ = OffscreenPoint();
- if (caret_) {
- AccessibilityFocusRingController::GetInstance()->SetCaretRing(
- caret_point_);
- }
+ caret_visible_ = false;
+ UpdateFocusAndCaretHighlights();
}
}
void AccessibilityHighlightManager::OnCaretBoundsChanged(
const ui::TextInputClient* client) {
gfx::Rect caret_bounds = client->GetCaretBounds();
- if (caret_bounds.width() == 0 && caret_bounds.height() == 0)
- caret_bounds = OffscreenRect();
caret_point_ = caret_bounds.CenterPoint();
+ caret_visible_ = client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE &&
+ (caret_bounds.width() || caret_bounds.height());
+ UpdateFocusAndCaretHighlights();
+}
+
+void AccessibilityHighlightManager::UpdateFocusAndCaretHighlights() {
+ auto controller = AccessibilityFocusRingController::GetInstance();
- if (caret_)
- AccessibilityFocusRingController::GetInstance()->SetCaretRing(caret_point_);
+ // The caret highlight takes precedence over the focus highlight if
+ // both are visible.
+ if (caret_ && caret_visible_) {
+ controller->SetCaretRing(caret_point_);
+ controller->SetFocusRing(std::vector<gfx::Rect>());
+ } else if (focus_) {
+ controller->SetCaretRing(OffscreenPoint());
+ std::vector<gfx::Rect> rects;
+ if (!focus_rect_.IsEmpty())
+ rects.push_back(focus_rect_);
+ controller->SetFocusRing(rects);
+ } else {
+ controller->SetCaretRing(OffscreenPoint());
+ controller->SetFocusRing(std::vector<gfx::Rect>());
+ }
}
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/accessibility/accessibility_highlight_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698