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 <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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1288 if (IsDateTimeInput(new_type)) | 1290 if (IsDateTimeInput(new_type)) |
| 1289 return; // Not considered as a text input field in WebKit/Chromium. | 1291 return; // Not considered as a text input field in WebKit/Chromium. |
| 1290 | 1292 |
| 1291 blink::WebTextInputInfo new_info; | 1293 blink::WebTextInputInfo new_info; |
| 1292 if (webwidget_) | 1294 if (webwidget_) |
| 1293 new_info = webwidget_->textInputInfo(); | 1295 new_info = webwidget_->textInputInfo(); |
| 1294 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); | 1296 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); |
| 1295 | 1297 |
| 1296 bool new_can_compose_inline = CanComposeInline(); | 1298 bool new_can_compose_inline = CanComposeInline(); |
| 1297 | 1299 |
| 1300 bool use_ime_thread = false; | |
|
aelias_OOO_until_Jul13
2016/01/23 03:21:39
Let's make this default true on non-Android so tha
Changwan Ryu
2016/01/26 03:25:29
Hmm... For other platforms if we set this as true
aelias_OOO_until_Jul13
2016/01/26 05:21:18
No, that shouldn't happen because change_source is
| |
| 1301 #if defined(OS_ANDROID) | |
| 1302 use_ime_thread = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1303 switches::kUseImeThread); | |
| 1304 #endif | |
| 1305 | |
| 1298 // Only sends text input params if they are changed or if the ime should be | 1306 // Only sends text input params if they are changed or if the ime should be |
| 1299 // shown. | 1307 // shown. |
| 1300 if (show_ime == ShowIme::IF_NEEDED || | 1308 if (show_ime == ShowIme::IF_NEEDED || |
| 1309 (use_ime_thread && change_source == ChangeSource::FROM_IME) || | |
| 1301 (text_input_type_ != new_type || text_input_mode_ != new_mode || | 1310 (text_input_type_ != new_type || text_input_mode_ != new_mode || |
| 1302 text_input_info_ != new_info || | 1311 text_input_info_ != new_info || |
| 1303 can_compose_inline_ != new_can_compose_inline) | 1312 can_compose_inline_ != new_can_compose_inline) |
| 1304 #if defined(OS_ANDROID) | 1313 #if defined(OS_ANDROID) |
| 1305 || text_field_is_dirty_ | 1314 || text_field_is_dirty_ |
| 1306 #endif | 1315 #endif |
| 1307 ) { | 1316 ) { |
| 1308 ViewHostMsg_TextInputState_Params params; | 1317 ViewHostMsg_TextInputState_Params params; |
| 1309 params.type = new_type; | 1318 params.type = new_type; |
| 1310 params.mode = new_mode; | 1319 params.mode = new_mode; |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1788 | 1797 |
| 1789 #if defined(OS_ANDROID) | 1798 #if defined(OS_ANDROID) |
| 1790 void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) { | 1799 void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) { |
| 1791 text_input_info_history_.push_back(info); | 1800 text_input_info_history_.push_back(info); |
| 1792 } | 1801 } |
| 1793 | 1802 |
| 1794 void RenderWidget::OnImeEventAck() { | 1803 void RenderWidget::OnImeEventAck() { |
| 1795 DCHECK_GE(text_input_info_history_.size(), 1u); | 1804 DCHECK_GE(text_input_info_history_.size(), 1u); |
| 1796 text_input_info_history_.pop_front(); | 1805 text_input_info_history_.pop_front(); |
| 1797 } | 1806 } |
| 1807 | |
| 1808 void RenderWidget::OnRequestTextInputStateUpdate() { | |
| 1809 ImeEventGuard guard(this, false, true); | |
|
aelias_OOO_until_Jul13
2016/01/23 03:21:39
This can't be nested so it seems unnecessarily ind
Changwan Ryu
2016/01/26 03:25:29
Done.
| |
| 1810 } | |
| 1798 #endif | 1811 #endif |
| 1799 | 1812 |
| 1800 bool RenderWidget::ShouldHandleImeEvent() { | 1813 bool RenderWidget::ShouldHandleImeEvent() { |
| 1801 #if defined(OS_ANDROID) | 1814 #if defined(OS_ANDROID) |
| 1802 if (!webwidget_) | 1815 if (!webwidget_) |
| 1803 return false; | 1816 return false; |
| 1817 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1818 switches::kUseImeThread)) | |
| 1819 return true; | |
| 1804 | 1820 |
| 1805 // We cannot handle IME events if there is any chance that the event we are | 1821 // We cannot handle IME events if there is any chance that the event we are |
| 1806 // receiving here from the browser is based on the state that is different | 1822 // receiving here from the browser is based on the state that is different |
| 1807 // from our current one as indicated by |text_input_info_|. | 1823 // from our current one as indicated by |text_input_info_|. |
| 1808 // The states the browser might be in are: | 1824 // The states the browser might be in are: |
| 1809 // text_input_info_history_[0] - current state ack'd by browser | 1825 // text_input_info_history_[0] - current state ack'd by browser |
| 1810 // text_input_info_history_[1...N] - pending state changes | 1826 // text_input_info_history_[1...N] - pending state changes |
| 1811 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) { | 1827 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) { |
| 1812 if (text_input_info_history_[i] != text_input_info_) | 1828 if (text_input_info_history_[i] != text_input_info_) |
| 1813 return false; | 1829 return false; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1886 } | 1902 } |
| 1887 | 1903 |
| 1888 void RenderWidget::set_next_paint_is_resize_ack() { | 1904 void RenderWidget::set_next_paint_is_resize_ack() { |
| 1889 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK; | 1905 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK; |
| 1890 } | 1906 } |
| 1891 | 1907 |
| 1892 void RenderWidget::set_next_paint_is_repaint_ack() { | 1908 void RenderWidget::set_next_paint_is_repaint_ack() { |
| 1893 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; | 1909 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; |
| 1894 } | 1910 } |
| 1895 | 1911 |
| 1912 bool RenderWidget::IsFromImeDefault() { | |
| 1913 #if defined(OS_ANDROID) | |
| 1914 // When ChromiumInputConnection is used, we want to make sure that FROM_IME | |
| 1915 // is set only for OnRequestTextInputStateUpdate() so that we can distinguish | |
| 1916 // it from other updates so that we can wait for it safely. | |
| 1917 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1918 switches::kUseImeThread); | |
| 1919 #else | |
| 1920 return true; | |
|
aelias_OOO_until_Jul13
2016/01/23 03:21:40
Let's make this default false on non-Android. It'
Changwan Ryu
2016/01/26 03:25:29
Done.
| |
| 1921 #endif | |
| 1922 } | |
| 1923 | |
| 1896 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) { | 1924 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) { |
| 1897 if (!ime_event_guard_) | 1925 if (!ime_event_guard_) |
| 1898 ime_event_guard_ = guard; | 1926 ime_event_guard_ = guard; |
| 1899 } | 1927 } |
| 1900 | 1928 |
| 1901 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) { | 1929 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) { |
| 1902 if (ime_event_guard_ != guard) { | 1930 if (ime_event_guard_ != guard) { |
| 1903 #if defined(OS_ANDROID) | 1931 #if defined(OS_ANDROID) |
| 1904 // In case a from-IME event (e.g. touch) ends up in not-from-IME event | 1932 // In case a from-IME event (e.g. touch) ends up in not-from-IME event |
| 1905 // (e.g. long press gesture), we want to treat it as not-from-IME event | 1933 // (e.g. long press gesture), we want to treat it as not-from-IME event |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2182 STATIC_ASSERT_WTI_ENUM_MATCH(DoubleTapZoom, DOUBLE_TAP_ZOOM); | 2210 STATIC_ASSERT_WTI_ENUM_MATCH(DoubleTapZoom, DOUBLE_TAP_ZOOM); |
| 2183 STATIC_ASSERT_WTI_ENUM_MATCH(Auto, AUTO); | 2211 STATIC_ASSERT_WTI_ENUM_MATCH(Auto, AUTO); |
| 2184 | 2212 |
| 2185 content::TouchAction content_touch_action = | 2213 content::TouchAction content_touch_action = |
| 2186 static_cast<content::TouchAction>(web_touch_action); | 2214 static_cast<content::TouchAction>(web_touch_action); |
| 2187 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); | 2215 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); |
| 2188 } | 2216 } |
| 2189 | 2217 |
| 2190 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() { | 2218 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() { |
| 2191 #if defined(OS_ANDROID) | 2219 #if defined(OS_ANDROID) |
| 2192 text_field_is_dirty_ = true; | 2220 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2221 switches::kUseImeThread)) | |
| 2222 text_field_is_dirty_ = true; | |
| 2193 #endif | 2223 #endif |
| 2194 } | 2224 } |
| 2195 | 2225 |
| 2196 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 2226 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
| 2197 RenderWidget::CreateGraphicsContext3D(GpuChannelHost* gpu_channel_host) { | 2227 RenderWidget::CreateGraphicsContext3D(GpuChannelHost* gpu_channel_host) { |
| 2198 // Explicitly disable antialiasing for the compositor. As of the time of | 2228 // Explicitly disable antialiasing for the compositor. As of the time of |
| 2199 // this writing, the only platform that supported antialiasing for the | 2229 // this writing, the only platform that supported antialiasing for the |
| 2200 // compositor was Mac OS X, because the on-screen OpenGL context creation | 2230 // compositor was Mac OS X, because the on-screen OpenGL context creation |
| 2201 // code paths on Windows and Linux didn't yet have multisampling support. | 2231 // code paths on Windows and Linux didn't yet have multisampling support. |
| 2202 // Mac OS X essentially always behaves as though it's rendering offscreen. | 2232 // 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... | |
| 2271 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2301 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2272 video_hole_frames_.AddObserver(frame); | 2302 video_hole_frames_.AddObserver(frame); |
| 2273 } | 2303 } |
| 2274 | 2304 |
| 2275 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2305 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2276 video_hole_frames_.RemoveObserver(frame); | 2306 video_hole_frames_.RemoveObserver(frame); |
| 2277 } | 2307 } |
| 2278 #endif // defined(VIDEO_HOLE) | 2308 #endif // defined(VIDEO_HOLE) |
| 2279 | 2309 |
| 2280 } // namespace content | 2310 } // namespace content |
| OLD | NEW |