OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/renderer_host/render_widget_host_view_win.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 case WM_MBUTTONDOWN: | 202 case WM_MBUTTONDOWN: |
203 ::SendMessage(GetParent(window), message, wparam, lparam); | 203 ::SendMessage(GetParent(window), message, wparam, lparam); |
204 return 0; | 204 return 0; |
205 default: | 205 default: |
206 break; | 206 break; |
207 } | 207 } |
208 } | 208 } |
209 return ::DefWindowProc(window, message, wparam, lparam); | 209 return ::DefWindowProc(window, message, wparam, lparam); |
210 } | 210 } |
211 | 211 |
| 212 bool ShouldEnableIME(ui::TextInputType type) { |
| 213 return type != ui::TEXT_INPUT_TYPE_NONE && |
| 214 type != ui::TEXT_INPUT_TYPE_PASSWORD; |
| 215 } |
| 216 |
212 } // namespace | 217 } // namespace |
213 | 218 |
214 // RenderWidgetHostView -------------------------------------------------------- | 219 // RenderWidgetHostView -------------------------------------------------------- |
215 | 220 |
216 // static | 221 // static |
217 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( | 222 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( |
218 RenderWidgetHost* widget) { | 223 RenderWidgetHost* widget) { |
219 if (views::Widget::IsPureViews()) | 224 if (views::Widget::IsPureViews()) |
220 return new RenderWidgetHostViewViews(widget); | 225 return new RenderWidgetHostViewViews(widget); |
221 return new RenderWidgetHostViewWin(widget); | 226 return new RenderWidgetHostViewWin(widget); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 } | 285 } |
281 | 286 |
282 void RenderWidgetHostViewWin::DidBecomeSelected() { | 287 void RenderWidgetHostViewWin::DidBecomeSelected() { |
283 if (!is_hidden_) | 288 if (!is_hidden_) |
284 return; | 289 return; |
285 | 290 |
286 if (tab_switch_paint_time_.is_null()) | 291 if (tab_switch_paint_time_.is_null()) |
287 tab_switch_paint_time_ = TimeTicks::Now(); | 292 tab_switch_paint_time_ = TimeTicks::Now(); |
288 is_hidden_ = false; | 293 is_hidden_ = false; |
289 EnsureTooltip(); | 294 EnsureTooltip(); |
| 295 if (ShouldEnableIME(text_input_type_)) |
| 296 ime_input_.EnableIME(m_hWnd); |
| 297 else |
| 298 ime_input_.DisableIME(m_hWnd); |
290 render_widget_host_->WasRestored(); | 299 render_widget_host_->WasRestored(); |
291 } | 300 } |
292 | 301 |
293 void RenderWidgetHostViewWin::WasHidden() { | 302 void RenderWidgetHostViewWin::WasHidden() { |
294 if (is_hidden_) | 303 if (is_hidden_) |
295 return; | 304 return; |
296 | 305 |
297 // If we receive any more paint messages while we are hidden, we want to | 306 // If we receive any more paint messages while we are hidden, we want to |
298 // ignore them so we don't re-allocate the backing store. We will paint | 307 // ignore them so we don't re-allocate the backing store. We will paint |
299 // everything again when we become selected again. | 308 // everything again when we become selected again. |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 } | 598 } |
590 | 599 |
591 void RenderWidgetHostViewWin::ImeUpdateTextInputState( | 600 void RenderWidgetHostViewWin::ImeUpdateTextInputState( |
592 ui::TextInputType type, | 601 ui::TextInputType type, |
593 bool can_compose_inline, | 602 bool can_compose_inline, |
594 const gfx::Rect& caret_rect) { | 603 const gfx::Rect& caret_rect) { |
595 // TODO(kinaba): currently, can_compose_inline is ignored and always treated | 604 // TODO(kinaba): currently, can_compose_inline is ignored and always treated |
596 // as true. We need to support "can_compose_inline=false" for PPAPI plugins | 605 // as true. We need to support "can_compose_inline=false" for PPAPI plugins |
597 // that may want to avoid drawing composition-text by themselves and pass | 606 // that may want to avoid drawing composition-text by themselves and pass |
598 // the responsibility to the browser. | 607 // the responsibility to the browser. |
599 bool is_enabled = (type != ui::TEXT_INPUT_TYPE_NONE && | 608 bool is_enabled = ShouldEnableIME(type); |
600 type != ui::TEXT_INPUT_TYPE_PASSWORD); | |
601 if (text_input_type_ != type) { | 609 if (text_input_type_ != type) { |
602 text_input_type_ = type; | 610 text_input_type_ = type; |
603 if (is_enabled) | 611 if (is_enabled) |
604 ime_input_.EnableIME(m_hWnd); | 612 ime_input_.EnableIME(m_hWnd); |
605 else | 613 else |
606 ime_input_.DisableIME(m_hWnd); | 614 ime_input_.DisableIME(m_hWnd); |
607 } | 615 } |
608 | 616 |
609 // Only update caret position if the input method is enabled. | 617 // Only update caret position if the input method is enabled. |
610 if (is_enabled) | 618 if (is_enabled) |
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 DWORD ex_style) { | 1837 DWORD ex_style) { |
1830 parent_hwnd_ = parent_hwnd; | 1838 parent_hwnd_ = parent_hwnd; |
1831 Create(parent_hwnd_, NULL, NULL, WS_POPUP, ex_style); | 1839 Create(parent_hwnd_, NULL, NULL, WS_POPUP, ex_style); |
1832 MoveWindow(pos.x(), pos.y(), pos.width(), pos.height(), TRUE); | 1840 MoveWindow(pos.x(), pos.y(), pos.width(), pos.height(), TRUE); |
1833 // To show tooltip on popup window.(e.g. title in <select>) | 1841 // To show tooltip on popup window.(e.g. title in <select>) |
1834 // Popups default to showing, which means |DidBecomeSelected()| isn't invoked. | 1842 // Popups default to showing, which means |DidBecomeSelected()| isn't invoked. |
1835 // Ensure the tooltip is created otherwise tooltips are never shown. | 1843 // Ensure the tooltip is created otherwise tooltips are never shown. |
1836 EnsureTooltip(); | 1844 EnsureTooltip(); |
1837 ShowWindow(IsActivatable() ? SW_SHOW : SW_SHOWNA); | 1845 ShowWindow(IsActivatable() ? SW_SHOW : SW_SHOWNA); |
1838 } | 1846 } |
OLD | NEW |