Chromium Code Reviews| 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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 has_focus_(false), | 492 has_focus_(false), |
| 493 handling_input_event_(false), | 493 handling_input_event_(false), |
| 494 handling_event_overscroll_(nullptr), | 494 handling_event_overscroll_(nullptr), |
| 495 handling_ime_event_(false), | 495 handling_ime_event_(false), |
| 496 handling_event_type_(WebInputEvent::Undefined), | 496 handling_event_type_(WebInputEvent::Undefined), |
| 497 ignore_ack_for_mouse_move_from_debugger_(false), | 497 ignore_ack_for_mouse_move_from_debugger_(false), |
| 498 closing_(false), | 498 closing_(false), |
| 499 host_closing_(false), | 499 host_closing_(false), |
| 500 is_swapped_out_(swapped_out), | 500 is_swapped_out_(swapped_out), |
| 501 for_oopif_(false), | 501 for_oopif_(false), |
| 502 input_method_is_active_(false), | |
| 503 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 502 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 504 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 503 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
| 505 text_input_flags_(0), | 504 text_input_flags_(0), |
| 506 can_compose_inline_(true), | 505 can_compose_inline_(true), |
| 507 popup_type_(popup_type), | 506 popup_type_(popup_type), |
| 508 pending_window_rect_count_(0), | 507 pending_window_rect_count_(0), |
| 509 suppress_next_char_events_(false), | 508 suppress_next_char_events_(false), |
| 510 screen_info_(screen_info), | 509 screen_info_(screen_info), |
| 511 device_scale_factor_(screen_info_.deviceScaleFactor), | 510 device_scale_factor_(screen_info_.deviceScaleFactor), |
| 512 current_event_latency_info_(NULL), | 511 current_event_latency_info_(NULL), |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) | 720 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) |
| 722 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) | 721 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) |
| 723 IPC_MESSAGE_HANDLER(ViewMsg_EnableDeviceEmulation, | 722 IPC_MESSAGE_HANDLER(ViewMsg_EnableDeviceEmulation, |
| 724 OnEnableDeviceEmulation) | 723 OnEnableDeviceEmulation) |
| 725 IPC_MESSAGE_HANDLER(ViewMsg_DisableDeviceEmulation, | 724 IPC_MESSAGE_HANDLER(ViewMsg_DisableDeviceEmulation, |
| 726 OnDisableDeviceEmulation) | 725 OnDisableDeviceEmulation) |
| 727 IPC_MESSAGE_HANDLER(ViewMsg_ColorProfile, OnColorProfile) | 726 IPC_MESSAGE_HANDLER(ViewMsg_ColorProfile, OnColorProfile) |
| 728 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) | 727 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) |
| 729 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) | 728 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) |
| 730 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) | 729 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) |
| 731 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive) | |
| 732 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) | 730 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) |
| 733 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) | 731 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) |
| 734 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) | 732 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) |
| 735 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) | 733 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) |
| 736 IPC_MESSAGE_HANDLER(ViewMsg_SetSurfaceIdNamespace, OnSetSurfaceIdNamespace) | 734 IPC_MESSAGE_HANDLER(ViewMsg_SetSurfaceIdNamespace, OnSetSurfaceIdNamespace) |
| 737 #if defined(OS_ANDROID) | 735 #if defined(OS_ANDROID) |
| 738 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) | 736 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) |
| 739 IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck) | 737 IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck) |
| 740 #endif | 738 #endif |
| 741 IPC_MESSAGE_UNHANDLED(handled = false) | 739 IPC_MESSAGE_UNHANDLED(handled = false) |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1655 return pending_window_rect_; | 1653 return pending_window_rect_; |
| 1656 } | 1654 } |
| 1657 | 1655 |
| 1658 return window_screen_rect_; | 1656 return window_screen_rect_; |
| 1659 } | 1657 } |
| 1660 | 1658 |
| 1661 WebRect RenderWidget::windowResizerRect() { | 1659 WebRect RenderWidget::windowResizerRect() { |
| 1662 return resizer_rect_; | 1660 return resizer_rect_; |
| 1663 } | 1661 } |
| 1664 | 1662 |
| 1665 void RenderWidget::OnSetInputMethodActive(bool is_active) { | |
| 1666 // To prevent this renderer process from sending unnecessary IPC messages to | |
| 1667 // a browser process, we permit the renderer process to send IPC messages | |
| 1668 // only during the input method attached to the browser process is active. | |
| 1669 input_method_is_active_ = is_active; | |
| 1670 } | |
| 1671 | |
| 1672 void RenderWidget::OnImeSetComposition( | 1663 void RenderWidget::OnImeSetComposition( |
| 1673 const base::string16& text, | 1664 const base::string16& text, |
| 1674 const std::vector<WebCompositionUnderline>& underlines, | 1665 const std::vector<WebCompositionUnderline>& underlines, |
| 1675 int selection_start, int selection_end) { | 1666 int selection_start, int selection_end) { |
| 1676 if (!ShouldHandleImeEvent()) | 1667 if (!ShouldHandleImeEvent()) |
| 1677 return; | 1668 return; |
| 1678 ImeEventGuard guard(this); | 1669 ImeEventGuard guard(this); |
| 1679 if (!webwidget_->setComposition( | 1670 if (!webwidget_->setComposition( |
| 1680 text, WebVector<WebCompositionUnderline>(underlines), | 1671 text, WebVector<WebCompositionUnderline>(underlines), |
| 1681 selection_start, selection_end)) { | 1672 selection_start, selection_end)) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1903 // While handling an ime event, text input state and selection bounds updates | 1894 // While handling an ime event, text input state and selection bounds updates |
| 1904 // are ignored. These must explicitly be updated once finished handling the | 1895 // are ignored. These must explicitly be updated once finished handling the |
| 1905 // ime event. | 1896 // ime event. |
| 1906 UpdateSelectionBounds(); | 1897 UpdateSelectionBounds(); |
| 1907 #if defined(OS_ANDROID) | 1898 #if defined(OS_ANDROID) |
| 1908 UpdateTextInputState(NO_SHOW_IME, FROM_IME); | 1899 UpdateTextInputState(NO_SHOW_IME, FROM_IME); |
| 1909 #endif | 1900 #endif |
| 1910 } | 1901 } |
| 1911 | 1902 |
| 1912 void RenderWidget::UpdateTextInputType() { | 1903 void RenderWidget::UpdateTextInputType() { |
| 1913 // On Windows, not only an IME but also an on-screen keyboard relies on the | |
| 1914 // latest TextInputType to optimize its layout and functionality. Thus | |
| 1915 // |input_method_is_active_| is no longer an appropriate condition to suppress | |
| 1916 // TextInputTypeChanged IPC on Windows. | |
| 1917 // TODO(yukawa, yoichio): Consider to stop checking |input_method_is_active_| | |
| 1918 // on other platforms as well as Windows if the overhead is acceptable. | |
| 1919 #if !defined(OS_WIN) | |
| 1920 if (!input_method_is_active_) | |
| 1921 return; | |
| 1922 #endif | |
|
jdduke (slow)
2015/07/22 20:40:59
It would be really nice if we could reland your me
Shu Chen
2015/07/23 00:57:46
CL https://codereview.chromium.org/326403002 got r
| |
| 1923 | |
| 1924 ui::TextInputType new_type = GetTextInputType(); | 1904 ui::TextInputType new_type = GetTextInputType(); |
| 1925 if (IsDateTimeInput(new_type)) | 1905 if (IsDateTimeInput(new_type)) |
| 1926 return; // Not considered as a text input field in WebKit/Chromium. | 1906 return; // Not considered as a text input field in WebKit/Chromium. |
| 1927 | 1907 |
| 1928 bool new_can_compose_inline = CanComposeInline(); | 1908 bool new_can_compose_inline = CanComposeInline(); |
| 1929 | 1909 |
| 1930 blink::WebTextInputInfo new_info; | 1910 blink::WebTextInputInfo new_info; |
| 1931 if (webwidget_) | 1911 if (webwidget_) |
| 1932 new_info = webwidget_->textInputInfo(); | 1912 new_info = webwidget_->textInputInfo(); |
| 1933 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); | 1913 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1947 text_input_mode_ = new_mode; | 1927 text_input_mode_ = new_mode; |
| 1948 text_input_flags_ = new_flags; | 1928 text_input_flags_ = new_flags; |
| 1949 } | 1929 } |
| 1950 } | 1930 } |
| 1951 | 1931 |
| 1952 #if defined(OS_ANDROID) || defined(USE_AURA) | 1932 #if defined(OS_ANDROID) || defined(USE_AURA) |
| 1953 void RenderWidget::UpdateTextInputState(ShowIme show_ime, | 1933 void RenderWidget::UpdateTextInputState(ShowIme show_ime, |
| 1954 ChangeSource change_source) { | 1934 ChangeSource change_source) { |
| 1955 if (handling_ime_event_) | 1935 if (handling_ime_event_) |
| 1956 return; | 1936 return; |
| 1957 if (show_ime == NO_SHOW_IME && !input_method_is_active_) | |
| 1958 return; | |
| 1959 ui::TextInputType new_type = GetTextInputType(); | 1937 ui::TextInputType new_type = GetTextInputType(); |
| 1960 if (IsDateTimeInput(new_type)) | 1938 if (IsDateTimeInput(new_type)) |
| 1961 return; // Not considered as a text input field in WebKit/Chromium. | 1939 return; // Not considered as a text input field in WebKit/Chromium. |
| 1962 | 1940 |
| 1963 blink::WebTextInputInfo new_info; | 1941 blink::WebTextInputInfo new_info; |
| 1964 if (webwidget_) | 1942 if (webwidget_) |
| 1965 new_info = webwidget_->textInputInfo(); | 1943 new_info = webwidget_->textInputInfo(); |
| 1966 | 1944 |
| 1967 bool new_can_compose_inline = CanComposeInline(); | 1945 bool new_can_compose_inline = CanComposeInline(); |
| 1968 | 1946 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2173 | 2151 |
| 2174 WebScreenInfo RenderWidget::screenInfo() { | 2152 WebScreenInfo RenderWidget::screenInfo() { |
| 2175 return screen_info_; | 2153 return screen_info_; |
| 2176 } | 2154 } |
| 2177 | 2155 |
| 2178 float RenderWidget::deviceScaleFactor() { | 2156 float RenderWidget::deviceScaleFactor() { |
| 2179 return device_scale_factor_; | 2157 return device_scale_factor_; |
| 2180 } | 2158 } |
| 2181 | 2159 |
| 2182 void RenderWidget::resetInputMethod() { | 2160 void RenderWidget::resetInputMethod() { |
| 2183 if (!input_method_is_active_) | |
| 2184 return; | |
| 2185 | |
| 2186 ImeEventGuard guard(this); | 2161 ImeEventGuard guard(this); |
| 2187 // If the last text input type is not None, then we should finish any | 2162 // If the last text input type is not None, then we should finish any |
| 2188 // ongoing composition regardless of the new text input type. | 2163 // ongoing composition regardless of the new text input type. |
| 2189 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { | 2164 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { |
| 2190 // If a composition text exists, then we need to let the browser process | 2165 // If a composition text exists, then we need to let the browser process |
| 2191 // to cancel the input method's ongoing composition session. | 2166 // to cancel the input method's ongoing composition session. |
| 2192 if (webwidget_->confirmComposition()) | 2167 if (webwidget_->confirmComposition()) |
| 2193 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 2168 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
| 2194 } | 2169 } |
| 2195 | 2170 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2468 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2443 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2469 video_hole_frames_.AddObserver(frame); | 2444 video_hole_frames_.AddObserver(frame); |
| 2470 } | 2445 } |
| 2471 | 2446 |
| 2472 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2447 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2473 video_hole_frames_.RemoveObserver(frame); | 2448 video_hole_frames_.RemoveObserver(frame); |
| 2474 } | 2449 } |
| 2475 #endif // defined(VIDEO_HOLE) | 2450 #endif // defined(VIDEO_HOLE) |
| 2476 | 2451 |
| 2477 } // namespace content | 2452 } // namespace content |
| OLD | NEW |