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

Unified Diff: ui/base/win/accessibility_misc_utils.cc

Issue 61923005: Make NativeTextfieldViews update the win system caret. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix typo and style issue Created 7 years, 1 month 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: ui/base/win/accessibility_misc_utils.cc
diff --git a/ui/base/win/accessibility_misc_utils.cc b/ui/base/win/accessibility_misc_utils.cc
index 5074ce372a7999676e33c31c61a97dd09e8de279..c3a76002cecf9505690abf9f293a1c3d1151d9e1 100644
--- a/ui/base/win/accessibility_misc_utils.cc
+++ b/ui/base/win/accessibility_misc_utils.cc
@@ -9,6 +9,23 @@
namespace base {
namespace win {
+void SetInvisibleSystemCaretRect(HWND hwnd, gfx::Rect caret_rect) {
+ // Create an invisible bitmap.
+ HBITMAP caret_bitmap = CreateBitmap(1, caret_rect.height(), 1, 1, NULL);
+
+ // This destroys the previous caret (no matter what window it belonged to)
+ // and creates a new one owned by this window.
+ if (!CreateCaret(hwnd, caret_bitmap, 1, caret_rect.height()))
+ return;
+
+ ShowCaret(hwnd);
+ RECT window_rect;
+ GetWindowRect(hwnd, &window_rect);
+ SetCaretPos(caret_rect.x() - window_rect.left + 2,
+ caret_rect.y() - window_rect.top + 2);
+ DeleteObject(caret_bitmap);
sky 2013/11/07 01:34:42 Does caret_bitmap leak if CreateCaret returns fals
dmazzoni 2013/11/07 20:07:14 Good catch, done.
+}
+
// UIA TextProvider implementation.
UIATextProvider::UIATextProvider()
: editable_(false) {}

Powered by Google App Engine
This is Rietveld 408576698