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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) | 707 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) |
708 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) | 708 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) |
709 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) | 709 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) |
710 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) | 710 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) |
711 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) | 711 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) |
712 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) | 712 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) |
713 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) | 713 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) |
714 IPC_MESSAGE_HANDLER(ViewMsg_SetSurfaceIdNamespace, OnSetSurfaceIdNamespace) | 714 IPC_MESSAGE_HANDLER(ViewMsg_SetSurfaceIdNamespace, OnSetSurfaceIdNamespace) |
715 #if defined(OS_ANDROID) | 715 #if defined(OS_ANDROID) |
716 IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck) | 716 IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck) |
| 717 IPC_MESSAGE_HANDLER(InputMsg_RequestTextInputStateUpdate, |
| 718 OnRequestTextInputStateUpdate) |
717 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) | 719 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) |
718 #endif | 720 #endif |
719 IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto) | 721 IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto) |
720 IPC_MESSAGE_UNHANDLED(handled = false) | 722 IPC_MESSAGE_UNHANDLED(handled = false) |
721 IPC_END_MESSAGE_MAP() | 723 IPC_END_MESSAGE_MAP() |
722 return handled; | 724 return handled; |
723 } | 725 } |
724 | 726 |
725 bool RenderWidget::Send(IPC::Message* message) { | 727 bool RenderWidget::Send(IPC::Message* message) { |
726 // Don't send any messages after the browser has told us to close, and filter | 728 // Don't send any messages after the browser has told us to close, and filter |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 if (IsDateTimeInput(new_type)) | 1293 if (IsDateTimeInput(new_type)) |
1292 return; // Not considered as a text input field in WebKit/Chromium. | 1294 return; // Not considered as a text input field in WebKit/Chromium. |
1293 | 1295 |
1294 blink::WebTextInputInfo new_info; | 1296 blink::WebTextInputInfo new_info; |
1295 if (webwidget_) | 1297 if (webwidget_) |
1296 new_info = webwidget_->textInputInfo(); | 1298 new_info = webwidget_->textInputInfo(); |
1297 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); | 1299 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); |
1298 | 1300 |
1299 bool new_can_compose_inline = CanComposeInline(); | 1301 bool new_can_compose_inline = CanComposeInline(); |
1300 | 1302 |
| 1303 bool use_ime_thread = true; |
| 1304 #if defined(OS_ANDROID) |
| 1305 use_ime_thread = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1306 switches::kUseImeThread); |
| 1307 #endif |
| 1308 |
1301 // Only sends text input params if they are changed or if the ime should be | 1309 // Only sends text input params if they are changed or if the ime should be |
1302 // shown. | 1310 // shown. |
1303 if (show_ime == ShowIme::IF_NEEDED || | 1311 if (show_ime == ShowIme::IF_NEEDED || |
| 1312 (use_ime_thread && change_source == ChangeSource::FROM_IME) || |
1304 (text_input_type_ != new_type || text_input_mode_ != new_mode || | 1313 (text_input_type_ != new_type || text_input_mode_ != new_mode || |
1305 text_input_info_ != new_info || | 1314 text_input_info_ != new_info || |
1306 can_compose_inline_ != new_can_compose_inline) | 1315 can_compose_inline_ != new_can_compose_inline) |
1307 #if defined(OS_ANDROID) | 1316 #if defined(OS_ANDROID) |
1308 || text_field_is_dirty_ | 1317 || text_field_is_dirty_ |
1309 #endif | 1318 #endif |
1310 ) { | 1319 ) { |
1311 ViewHostMsg_TextInputState_Params params; | 1320 ViewHostMsg_TextInputState_Params params; |
1312 params.type = new_type; | 1321 params.type = new_type; |
1313 params.mode = new_mode; | 1322 params.mode = new_mode; |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 | 1800 |
1792 #if defined(OS_ANDROID) | 1801 #if defined(OS_ANDROID) |
1793 void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) { | 1802 void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) { |
1794 text_input_info_history_.push_back(info); | 1803 text_input_info_history_.push_back(info); |
1795 } | 1804 } |
1796 | 1805 |
1797 void RenderWidget::OnImeEventAck() { | 1806 void RenderWidget::OnImeEventAck() { |
1798 DCHECK_GE(text_input_info_history_.size(), 1u); | 1807 DCHECK_GE(text_input_info_history_.size(), 1u); |
1799 text_input_info_history_.pop_front(); | 1808 text_input_info_history_.pop_front(); |
1800 } | 1809 } |
| 1810 |
| 1811 void RenderWidget::OnRequestTextInputStateUpdate() { |
| 1812 DCHECK(!ime_event_guard_); |
| 1813 UpdateSelectionBounds(); |
| 1814 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME); |
| 1815 } |
1801 #endif | 1816 #endif |
1802 | 1817 |
1803 bool RenderWidget::ShouldHandleImeEvent() { | 1818 bool RenderWidget::ShouldHandleImeEvent() { |
1804 #if defined(OS_ANDROID) | 1819 #if defined(OS_ANDROID) |
1805 if (!webwidget_) | 1820 if (!webwidget_) |
1806 return false; | 1821 return false; |
| 1822 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1823 switches::kUseImeThread)) |
| 1824 return true; |
1807 | 1825 |
1808 // We cannot handle IME events if there is any chance that the event we are | 1826 // We cannot handle IME events if there is any chance that the event we are |
1809 // receiving here from the browser is based on the state that is different | 1827 // receiving here from the browser is based on the state that is different |
1810 // from our current one as indicated by |text_input_info_|. | 1828 // from our current one as indicated by |text_input_info_|. |
1811 // The states the browser might be in are: | 1829 // The states the browser might be in are: |
1812 // text_input_info_history_[0] - current state ack'd by browser | 1830 // text_input_info_history_[0] - current state ack'd by browser |
1813 // text_input_info_history_[1...N] - pending state changes | 1831 // text_input_info_history_[1...N] - pending state changes |
1814 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) { | 1832 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) { |
1815 if (text_input_info_history_[i] != text_input_info_) | 1833 if (text_input_info_history_[i] != text_input_info_) |
1816 return false; | 1834 return false; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 } | 1907 } |
1890 | 1908 |
1891 void RenderWidget::set_next_paint_is_resize_ack() { | 1909 void RenderWidget::set_next_paint_is_resize_ack() { |
1892 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK; | 1910 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK; |
1893 } | 1911 } |
1894 | 1912 |
1895 void RenderWidget::set_next_paint_is_repaint_ack() { | 1913 void RenderWidget::set_next_paint_is_repaint_ack() { |
1896 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; | 1914 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; |
1897 } | 1915 } |
1898 | 1916 |
| 1917 bool RenderWidget::IsFromImeDefault() { |
| 1918 #if defined(OS_ANDROID) |
| 1919 // When ChromiumInputConnection is used, we want to make sure that FROM_IME |
| 1920 // is set only for OnRequestTextInputStateUpdate() so that we can distinguish |
| 1921 // it from other updates so that we can wait for it safely. |
| 1922 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1923 switches::kUseImeThread); |
| 1924 #else |
| 1925 return false; |
| 1926 #endif |
| 1927 } |
| 1928 |
1899 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) { | 1929 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) { |
1900 if (!ime_event_guard_) | 1930 if (!ime_event_guard_) |
1901 ime_event_guard_ = guard; | 1931 ime_event_guard_ = guard; |
1902 } | 1932 } |
1903 | 1933 |
1904 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) { | 1934 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) { |
1905 if (ime_event_guard_ != guard) { | 1935 if (ime_event_guard_ != guard) { |
1906 #if defined(OS_ANDROID) | 1936 #if defined(OS_ANDROID) |
1907 // In case a from-IME event (e.g. touch) ends up in not-from-IME event | 1937 // In case a from-IME event (e.g. touch) ends up in not-from-IME event |
1908 // (e.g. long press gesture), we want to treat it as not-from-IME event | 1938 // (e.g. long press gesture), we want to treat it as not-from-IME event |
1909 // so that AdapterInputConnection can make changes to its Editable model. | 1939 // so that ReplicaInputConnection can make changes to its Editable model. |
1910 // Therefore, we want to mark this text state update as 'from IME' only | 1940 // Therefore, we want to mark this text state update as 'from IME' only |
1911 // when all the nested events are all originating from IME. | 1941 // when all the nested events are all originating from IME. |
1912 ime_event_guard_->set_from_ime( | 1942 ime_event_guard_->set_from_ime( |
1913 ime_event_guard_->from_ime() && guard->from_ime()); | 1943 ime_event_guard_->from_ime() && guard->from_ime()); |
1914 #endif | 1944 #endif |
1915 return; | 1945 return; |
1916 } | 1946 } |
1917 ime_event_guard_ = nullptr; | 1947 ime_event_guard_ = nullptr; |
1918 | 1948 |
1919 // While handling an ime event, text input state and selection bounds updates | 1949 // While handling an ime event, text input state and selection bounds updates |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2185 STATIC_ASSERT_WTI_ENUM_MATCH(DoubleTapZoom, DOUBLE_TAP_ZOOM); | 2215 STATIC_ASSERT_WTI_ENUM_MATCH(DoubleTapZoom, DOUBLE_TAP_ZOOM); |
2186 STATIC_ASSERT_WTI_ENUM_MATCH(Auto, AUTO); | 2216 STATIC_ASSERT_WTI_ENUM_MATCH(Auto, AUTO); |
2187 | 2217 |
2188 content::TouchAction content_touch_action = | 2218 content::TouchAction content_touch_action = |
2189 static_cast<content::TouchAction>(web_touch_action); | 2219 static_cast<content::TouchAction>(web_touch_action); |
2190 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); | 2220 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); |
2191 } | 2221 } |
2192 | 2222 |
2193 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() { | 2223 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() { |
2194 #if defined(OS_ANDROID) | 2224 #if defined(OS_ANDROID) |
2195 text_field_is_dirty_ = true; | 2225 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2226 switches::kUseImeThread)) |
| 2227 text_field_is_dirty_ = true; |
2196 #endif | 2228 #endif |
2197 } | 2229 } |
2198 | 2230 |
2199 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 2231 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
2200 RenderWidget::CreateGraphicsContext3D(GpuChannelHost* gpu_channel_host) { | 2232 RenderWidget::CreateGraphicsContext3D(GpuChannelHost* gpu_channel_host) { |
2201 // Explicitly disable antialiasing for the compositor. As of the time of | 2233 // Explicitly disable antialiasing for the compositor. As of the time of |
2202 // this writing, the only platform that supported antialiasing for the | 2234 // this writing, the only platform that supported antialiasing for the |
2203 // compositor was Mac OS X, because the on-screen OpenGL context creation | 2235 // compositor was Mac OS X, because the on-screen OpenGL context creation |
2204 // code paths on Windows and Linux didn't yet have multisampling support. | 2236 // code paths on Windows and Linux didn't yet have multisampling support. |
2205 // Mac OS X essentially always behaves as though it's rendering offscreen. | 2237 // Mac OS X essentially always behaves as though it's rendering offscreen. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2274 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2306 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2275 video_hole_frames_.AddObserver(frame); | 2307 video_hole_frames_.AddObserver(frame); |
2276 } | 2308 } |
2277 | 2309 |
2278 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2310 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2279 video_hole_frames_.RemoveObserver(frame); | 2311 video_hole_frames_.RemoveObserver(frame); |
2280 } | 2312 } |
2281 #endif // defined(VIDEO_HOLE) | 2313 #endif // defined(VIDEO_HOLE) |
2282 | 2314 |
2283 } // namespace content | 2315 } // namespace content |
OLD | NEW |