OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/render_widget_host_view_win.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <peninputpanel_i.c> | 9 #include <peninputpanel_i.c> |
10 #include <stack> | 10 #include <stack> |
(...skipping 3006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3017 // According to Microsft API document, IMR_RECONVERTSTRING and | 3017 // According to Microsft API document, IMR_RECONVERTSTRING and |
3018 // IMR_DOCUMENTFEED should return reconv, but some applications return | 3018 // IMR_DOCUMENTFEED should return reconv, but some applications return |
3019 // need_size. | 3019 // need_size. |
3020 return reinterpret_cast<LRESULT>(reconv); | 3020 return reinterpret_cast<LRESULT>(reconv); |
3021 } | 3021 } |
3022 | 3022 |
3023 LRESULT RenderWidgetHostViewWin::OnQueryCharPosition( | 3023 LRESULT RenderWidgetHostViewWin::OnQueryCharPosition( |
3024 IMECHARPOSITION* position) { | 3024 IMECHARPOSITION* position) { |
3025 DCHECK(position); | 3025 DCHECK(position); |
3026 | 3026 |
3027 if (!ime_input_.is_composing() || composition_range_.is_empty() || | 3027 if (position->dwSize < sizeof(IMECHARPOSITION)) |
3028 position->dwSize < sizeof(IMECHARPOSITION) || | 3028 return 0; |
3029 position->dwCharPos >= composition_character_bounds_.size()) { | 3029 |
| 3030 RECT target_rect = {}; |
| 3031 if (ime_input_.is_composing() && !composition_range_.is_empty() && |
| 3032 position->dwCharPos < composition_character_bounds_.size()) { |
| 3033 target_rect = |
| 3034 composition_character_bounds_[position->dwCharPos].ToRECT(); |
| 3035 } else if (position->dwCharPos == 0) { |
| 3036 // When there is no on-going composition but |position->dwCharPos| is 0, |
| 3037 // use the caret rect. This behavior is the same to RichEdit. In fact, |
| 3038 // CUAS (Cicero Unaware Application Support) relies on this behavior to |
| 3039 // implement ITfContextView::GetTextExt on top of IMM32-based applications. |
| 3040 target_rect = caret_rect_.ToRECT(); |
| 3041 } else { |
3030 return 0; | 3042 return 0; |
3031 } | 3043 } |
3032 | |
3033 RECT target_rect = | |
3034 composition_character_bounds_[position->dwCharPos].ToRECT(); | |
3035 ClientToScreen(&target_rect); | 3044 ClientToScreen(&target_rect); |
3036 | 3045 |
3037 RECT document_rect = GetViewBounds().ToRECT(); | 3046 RECT document_rect = GetViewBounds().ToRECT(); |
3038 ClientToScreen(&document_rect); | 3047 ClientToScreen(&document_rect); |
3039 | 3048 |
3040 position->pt.x = target_rect.left; | 3049 position->pt.x = target_rect.left; |
3041 position->pt.y = target_rect.top; | 3050 position->pt.y = target_rect.top; |
3042 position->cLineHeight = target_rect.bottom - target_rect.top; | 3051 position->cLineHeight = target_rect.bottom - target_rect.top; |
3043 position->rcDocument = document_rect; | 3052 position->rcDocument = document_rect; |
3044 return 1; | 3053 return 1; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3082 // receive a focus change in the context of a pointer down message, it means | 3091 // receive a focus change in the context of a pointer down message, it means |
3083 // that the pointer down message occurred on the edit field and we should | 3092 // that the pointer down message occurred on the edit field and we should |
3084 // display the on screen keyboard | 3093 // display the on screen keyboard |
3085 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) | 3094 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) |
3086 DisplayOnScreenKeyboardIfNeeded(); | 3095 DisplayOnScreenKeyboardIfNeeded(); |
3087 received_focus_change_after_pointer_down_ = false; | 3096 received_focus_change_after_pointer_down_ = false; |
3088 pointer_down_context_ = false; | 3097 pointer_down_context_ = false; |
3089 } | 3098 } |
3090 | 3099 |
3091 } // namespace content | 3100 } // namespace content |
OLD | NEW |