diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-08 01:45:44 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-08 01:45:44 +0000 |
commit | ac9314f25b3fd13ae0fd688a2d1ecc7d271b8bf0 (patch) | |
tree | 0de3b75f710e2f8ecb056a404e453ac05ba0cb0b /ui/base/win | |
parent | f25825017486fdd2d6c7745c56e32cfd69041446 (diff) | |
download | chromium_src-ac9314f25b3fd13ae0fd688a2d1ecc7d271b8bf0.zip chromium_src-ac9314f25b3fd13ae0fd688a2d1ecc7d271b8bf0.tar.gz chromium_src-ac9314f25b3fd13ae0fd688a2d1ecc7d271b8bf0.tar.bz2 |
Make NativeTextfieldViews update the win system caret.
Added a helper function to ui/base/win because we're
going to need to do the same thing from content/browser.
BUG=142133
Review URL: https://codereview.chromium.org/61923005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233759 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/win')
-rw-r--r-- | ui/base/win/accessibility_misc_utils.cc | 18 | ||||
-rw-r--r-- | ui/base/win/accessibility_misc_utils.h | 11 |
2 files changed, 28 insertions, 1 deletions
diff --git a/ui/base/win/accessibility_misc_utils.cc b/ui/base/win/accessibility_misc_utils.cc index 5074ce3..391482b 100644 --- a/ui/base/win/accessibility_misc_utils.cc +++ b/ui/base/win/accessibility_misc_utils.cc @@ -4,11 +4,29 @@ #include "ui/base/win/accessibility_misc_utils.h" #include "base/logging.h" +#include "base/win/scoped_gdi_object.h" #include "ui/base/win/atl_module.h" namespace base { namespace win { +void SetInvisibleSystemCaretRect(HWND hwnd, const gfx::Rect& caret_rect) { + // Create an invisible bitmap. + base::win::ScopedGDIObject<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); +} + // UIA TextProvider implementation. UIATextProvider::UIATextProvider() : editable_(false) {} diff --git a/ui/base/win/accessibility_misc_utils.h b/ui/base/win/accessibility_misc_utils.h index 3789efb..dfee14f 100644 --- a/ui/base/win/accessibility_misc_utils.h +++ b/ui/base/win/accessibility_misc_utils.h @@ -10,11 +10,20 @@ #include "base/compiler_specific.h" #include "ui/base/ui_export.h" +#include "ui/gfx/rect.h" namespace base { namespace win { - // UIA Text provider implementation for edit controls. +// This is used when we draw our own caret. Updates the system caret rect +// to the given bounding rectangle but makes it invisible. This allows +// utilities that help the user find the system caret to continue to work. +// |hwnd| should be the owning window, and |caret_rect| is in global +// screen coordinates. +UI_EXPORT void SetInvisibleSystemCaretRect(HWND hwnd, + const gfx::Rect& caret_rect); + +// UIA Text provider implementation for edit controls. class UI_EXPORT UIATextProvider : public NON_EXPORTED_BASE(CComObjectRootEx<CComMultiThreadModel>), public IValueProvider, |