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

Unified Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 2781613003: Added a class acting as a fake caret for accessibility. (Closed)
Patch Set: Activate the fake caret only when Windows is focused. Created 3 years, 8 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: content/browser/renderer_host/render_widget_host_view_aura.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 61b60b05345b9f7bc3b334c2517a143d09559918..d7740c9bdbdc6665d78653371203c0e4cfc226f7 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -103,6 +103,7 @@
#include "content/browser/accessibility/browser_accessibility_manager_win.h"
#include "content/browser/accessibility/browser_accessibility_win.h"
#include "content/browser/renderer_host/legacy_render_widget_host_win.h"
+#include "ui/accessibility/platform/ax_fake_caret_win.h"
#include "ui/base/win/hidden_window.h"
#include "ui/base/win/osk_display_manager.h"
#include "ui/base/win/osk_display_observer.h"
@@ -2333,7 +2334,6 @@ void RenderWidgetHostViewAura::OnSelectionBoundsChanged(
void RenderWidgetHostViewAura::OnTextSelectionChanged(
TextInputManager* text_input_manager,
RenderWidgetHostViewBase* updated_view) {
-#if defined(USE_X11) && !defined(OS_CHROMEOS)
if (!GetTextInputManager())
return;
@@ -2350,6 +2350,7 @@ void RenderWidgetHostViewAura::OnTextSelectionChanged(
if (!focused_view)
return;
+#if defined(USE_X11) && !defined(OS_CHROMEOS)
const TextInputManager::TextSelection* selection =
GetTextInputManager()->GetTextSelection(focused_view);
if (selection->selected_text().length()) {
@@ -2357,7 +2358,24 @@ void RenderWidgetHostViewAura::OnTextSelectionChanged(
ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
clipboard_writer.WriteText(selection->selected_text());
}
-#endif // defined(USE_X11) && !defined(OS_CHROMEOS)
+
+// #endif defined(USE_X11) && !defined(OS_CHROMEOS)
+#elseif defined(OS_WIN)
+ // Some assistive software need to track the location of the caret.
+ if (!GetRenderWidgetHost())
+ return;
+
+ // Not using |GetCaretBounds| because it includes the whole of the selection,
+ // not just the focus.
+ const TextInputManager::SelectionRegion* region =
+ GetTextInputManager()->GetSelectionRegion(focused_view);
+ if (!region)
+ return;
+ gfx::Rect caret_rect = ConvertRectToScreen(gfx::Rect(
+ region->focus.edge_top_rounded().x(),
+ region->focus.edge_top_rounded().y(), 1, region->focus.GetHeight()));
+ ui::AXFakeCaretWin::g_fake_caret->SetBounds(caret_rect);
dmazzoni 2017/04/17 05:07:35 I'd call something like ui::AXFakeCaretWin::Get()
+#endif // defined(OS_WIN)
}
void RenderWidgetHostViewAura::SetPopupChild(

Powered by Google App Engine
This is Rietveld 408576698