| 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 "webkit/plugins/npapi/webplugin_ime_win.h" | 5 #include "webkit/plugins/npapi/webplugin_ime_win.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 it != events_.end(); ++it) { | 140 it != events_.end(); ++it) { |
| 141 if (!instance->NPP_HandleEvent(&(*it))) | 141 if (!instance->NPP_HandleEvent(&(*it))) |
| 142 ret = false; | 142 ret = false; |
| 143 } | 143 } |
| 144 | 144 |
| 145 events_.clear(); | 145 events_.clear(); |
| 146 return ret; | 146 return ret; |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool WebPluginIMEWin::GetStatus(int* input_type, gfx::Rect* caret_rect) { | 149 bool WebPluginIMEWin::GetStatus(int* input_type, gfx::Rect* caret_rect) { |
| 150 bool status_updated = status_updated_; | 150 *input_type = input_type_; |
| 151 if (status_updated) { | 151 *caret_rect = caret_rect_; |
| 152 *input_type = input_type_; | 152 return true; |
| 153 *caret_rect = caret_rect_; | |
| 154 status_updated_ = false; | |
| 155 } | |
| 156 return status_updated; | |
| 157 } | 153 } |
| 158 | 154 |
| 159 // static | 155 // static |
| 160 FARPROC WebPluginIMEWin::GetProcAddress(LPCSTR name) { | 156 FARPROC WebPluginIMEWin::GetProcAddress(LPCSTR name) { |
| 161 static const struct { | 157 static const struct { |
| 162 const char* name; | 158 const char* name; |
| 163 FARPROC function; | 159 FARPROC function; |
| 164 } kImm32Functions[] = { | 160 } kImm32Functions[] = { |
| 165 { "ImmAssociateContextEx", | 161 { "ImmAssociateContextEx", |
| 166 reinterpret_cast<FARPROC>(ImmAssociateContextEx) }, | 162 reinterpret_cast<FARPROC>(ImmAssociateContextEx) }, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 192 // static | 188 // static |
| 193 WebPluginIMEWin* WebPluginIMEWin::GetInstance(HIMC context) { | 189 WebPluginIMEWin* WebPluginIMEWin::GetInstance(HIMC context) { |
| 194 return instance_ && context == reinterpret_cast<HIMC>(instance_) ? | 190 return instance_ && context == reinterpret_cast<HIMC>(instance_) ? |
| 195 instance_ : NULL; | 191 instance_ : NULL; |
| 196 } | 192 } |
| 197 | 193 |
| 198 // static | 194 // static |
| 199 BOOL WINAPI WebPluginIMEWin::ImmAssociateContextEx(HWND window, | 195 BOOL WINAPI WebPluginIMEWin::ImmAssociateContextEx(HWND window, |
| 200 HIMC context, | 196 HIMC context, |
| 201 DWORD flags) { | 197 DWORD flags) { |
| 198 WebPluginIMEWin* instance = GetInstance(context); |
| 199 if (!instance) |
| 200 return ::ImmAssociateContextEx(window, context, flags); |
| 201 |
| 202 int input_type = !context && !flags; |
| 203 instance->input_type_ = input_type; |
| 204 instance->status_updated_ = true; |
| 202 return TRUE; | 205 return TRUE; |
| 203 } | 206 } |
| 204 | 207 |
| 205 // static | 208 // static |
| 206 LONG WINAPI WebPluginIMEWin::ImmGetCompositionStringW(HIMC context, | 209 LONG WINAPI WebPluginIMEWin::ImmGetCompositionStringW(HIMC context, |
| 207 DWORD index, | 210 DWORD index, |
| 208 LPVOID dst_data, | 211 LPVOID dst_data, |
| 209 DWORD dst_size) { | 212 DWORD dst_size) { |
| 210 WebPluginIMEWin* instance = GetInstance(context); | 213 WebPluginIMEWin* instance = GetInstance(context); |
| 211 if (!instance) | 214 if (!instance) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 if (instance->input_type_ != input_type) { | 314 if (instance->input_type_ != input_type) { |
| 312 instance->input_type_ = input_type; | 315 instance->input_type_ = input_type; |
| 313 instance->status_updated_ = true; | 316 instance->status_updated_ = true; |
| 314 } | 317 } |
| 315 | 318 |
| 316 return TRUE; | 319 return TRUE; |
| 317 } | 320 } |
| 318 | 321 |
| 319 } // namespace npapi | 322 } // namespace npapi |
| 320 } // namespace webkit | 323 } // namespace webkit |
| OLD | NEW |