| 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1801 | 1810 |
| 1802 #if defined(OS_ANDROID) | 1811 #if defined(OS_ANDROID) |
| 1803 void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) { | 1812 void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) { |
| 1804 text_input_info_history_.push_back(info); | 1813 text_input_info_history_.push_back(info); |
| 1805 } | 1814 } |
| 1806 | 1815 |
| 1807 void RenderWidget::OnImeEventAck() { | 1816 void RenderWidget::OnImeEventAck() { |
| 1808 DCHECK_GE(text_input_info_history_.size(), 1u); | 1817 DCHECK_GE(text_input_info_history_.size(), 1u); |
| 1809 text_input_info_history_.pop_front(); | 1818 text_input_info_history_.pop_front(); |
| 1810 } | 1819 } |
| 1820 |
| 1821 void RenderWidget::OnRequestTextInputStateUpdate() { |
| 1822 DCHECK(!ime_event_guard_); |
| 1823 UpdateSelectionBounds(); |
| 1824 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME); |
| 1825 } |
| 1811 #endif | 1826 #endif |
| 1812 | 1827 |
| 1813 bool RenderWidget::ShouldHandleImeEvent() { | 1828 bool RenderWidget::ShouldHandleImeEvent() { |
| 1814 #if defined(OS_ANDROID) | 1829 #if defined(OS_ANDROID) |
| 1815 if (!webwidget_) | 1830 if (!webwidget_) |
| 1816 return false; | 1831 return false; |
| 1832 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1833 switches::kUseImeThread)) |
| 1834 return true; |
| 1817 | 1835 |
| 1818 // We cannot handle IME events if there is any chance that the event we are | 1836 // We cannot handle IME events if there is any chance that the event we are |
| 1819 // receiving here from the browser is based on the state that is different | 1837 // receiving here from the browser is based on the state that is different |
| 1820 // from our current one as indicated by |text_input_info_|. | 1838 // from our current one as indicated by |text_input_info_|. |
| 1821 // The states the browser might be in are: | 1839 // The states the browser might be in are: |
| 1822 // text_input_info_history_[0] - current state ack'd by browser | 1840 // text_input_info_history_[0] - current state ack'd by browser |
| 1823 // text_input_info_history_[1...N] - pending state changes | 1841 // text_input_info_history_[1...N] - pending state changes |
| 1824 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) { | 1842 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) { |
| 1825 if (text_input_info_history_[i] != text_input_info_) | 1843 if (text_input_info_history_[i] != text_input_info_) |
| 1826 return false; | 1844 return false; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1899 } | 1917 } |
| 1900 | 1918 |
| 1901 void RenderWidget::set_next_paint_is_resize_ack() { | 1919 void RenderWidget::set_next_paint_is_resize_ack() { |
| 1902 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK; | 1920 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK; |
| 1903 } | 1921 } |
| 1904 | 1922 |
| 1905 void RenderWidget::set_next_paint_is_repaint_ack() { | 1923 void RenderWidget::set_next_paint_is_repaint_ack() { |
| 1906 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; | 1924 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; |
| 1907 } | 1925 } |
| 1908 | 1926 |
| 1927 bool RenderWidget::IsFromImeDefault() { |
| 1928 #if defined(OS_ANDROID) |
| 1929 // When ChromiumInputConnection is used, we want to make sure that FROM_IME |
| 1930 // is set only for OnRequestTextInputStateUpdate() so that we can distinguish |
| 1931 // it from other updates so that we can wait for it safely. |
| 1932 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1933 switches::kUseImeThread); |
| 1934 #else |
| 1935 return false; |
| 1936 #endif |
| 1937 } |
| 1938 |
| 1909 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) { | 1939 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) { |
| 1910 if (!ime_event_guard_) | 1940 if (!ime_event_guard_) |
| 1911 ime_event_guard_ = guard; | 1941 ime_event_guard_ = guard; |
| 1912 } | 1942 } |
| 1913 | 1943 |
| 1914 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) { | 1944 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) { |
| 1915 if (ime_event_guard_ != guard) { | 1945 if (ime_event_guard_ != guard) { |
| 1916 #if defined(OS_ANDROID) | 1946 #if defined(OS_ANDROID) |
| 1917 // In case a from-IME event (e.g. touch) ends up in not-from-IME event | 1947 // In case a from-IME event (e.g. touch) ends up in not-from-IME event |
| 1918 // (e.g. long press gesture), we want to treat it as not-from-IME event | 1948 // (e.g. long press gesture), we want to treat it as not-from-IME event |
| 1919 // so that AdapterInputConnection can make changes to its Editable model. | 1949 // so that ReplicaInputConnection can make changes to its Editable model. |
| 1920 // Therefore, we want to mark this text state update as 'from IME' only | 1950 // Therefore, we want to mark this text state update as 'from IME' only |
| 1921 // when all the nested events are all originating from IME. | 1951 // when all the nested events are all originating from IME. |
| 1922 ime_event_guard_->set_from_ime( | 1952 ime_event_guard_->set_from_ime( |
| 1923 ime_event_guard_->from_ime() && guard->from_ime()); | 1953 ime_event_guard_->from_ime() && guard->from_ime()); |
| 1924 #endif | 1954 #endif |
| 1925 return; | 1955 return; |
| 1926 } | 1956 } |
| 1927 ime_event_guard_ = nullptr; | 1957 ime_event_guard_ = nullptr; |
| 1928 | 1958 |
| 1929 // While handling an ime event, text input state and selection bounds updates | 1959 // 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... |
| 2195 STATIC_ASSERT_WTI_ENUM_MATCH(DoubleTapZoom, DOUBLE_TAP_ZOOM); | 2225 STATIC_ASSERT_WTI_ENUM_MATCH(DoubleTapZoom, DOUBLE_TAP_ZOOM); |
| 2196 STATIC_ASSERT_WTI_ENUM_MATCH(Auto, AUTO); | 2226 STATIC_ASSERT_WTI_ENUM_MATCH(Auto, AUTO); |
| 2197 | 2227 |
| 2198 content::TouchAction content_touch_action = | 2228 content::TouchAction content_touch_action = |
| 2199 static_cast<content::TouchAction>(web_touch_action); | 2229 static_cast<content::TouchAction>(web_touch_action); |
| 2200 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); | 2230 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); |
| 2201 } | 2231 } |
| 2202 | 2232 |
| 2203 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() { | 2233 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() { |
| 2204 #if defined(OS_ANDROID) | 2234 #if defined(OS_ANDROID) |
| 2205 text_field_is_dirty_ = true; | 2235 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2236 switches::kUseImeThread)) |
| 2237 text_field_is_dirty_ = true; |
| 2206 #endif | 2238 #endif |
| 2207 } | 2239 } |
| 2208 | 2240 |
| 2209 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 2241 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
| 2210 RenderWidget::CreateGraphicsContext3D(GpuChannelHost* gpu_channel_host) { | 2242 RenderWidget::CreateGraphicsContext3D(GpuChannelHost* gpu_channel_host) { |
| 2211 // Explicitly disable antialiasing for the compositor. As of the time of | 2243 // Explicitly disable antialiasing for the compositor. As of the time of |
| 2212 // this writing, the only platform that supported antialiasing for the | 2244 // this writing, the only platform that supported antialiasing for the |
| 2213 // compositor was Mac OS X, because the on-screen OpenGL context creation | 2245 // compositor was Mac OS X, because the on-screen OpenGL context creation |
| 2214 // code paths on Windows and Linux didn't yet have multisampling support. | 2246 // code paths on Windows and Linux didn't yet have multisampling support. |
| 2215 // Mac OS X essentially always behaves as though it's rendering offscreen. | 2247 // 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... |
| 2284 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2316 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2285 video_hole_frames_.AddObserver(frame); | 2317 video_hole_frames_.AddObserver(frame); |
| 2286 } | 2318 } |
| 2287 | 2319 |
| 2288 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2320 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2289 video_hole_frames_.RemoveObserver(frame); | 2321 video_hole_frames_.RemoveObserver(frame); |
| 2290 } | 2322 } |
| 2291 #endif // defined(VIDEO_HOLE) | 2323 #endif // defined(VIDEO_HOLE) |
| 2292 | 2324 |
| 2293 } // namespace content | 2325 } // namespace content |
| OLD | NEW |