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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) | 706 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) |
| 707 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) | 707 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) |
| 708 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) | 708 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) |
| 709 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) | 709 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) |
| 710 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) | 710 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) |
| 711 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) | 711 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) |
| 712 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) | 712 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) |
| 713 IPC_MESSAGE_HANDLER(ViewMsg_SetSurfaceIdNamespace, OnSetSurfaceIdNamespace) | 713 IPC_MESSAGE_HANDLER(ViewMsg_SetSurfaceIdNamespace, OnSetSurfaceIdNamespace) |
| 714 #if defined(OS_ANDROID) | 714 #if defined(OS_ANDROID) |
| 715 IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck) | 715 IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck) |
| 716 IPC_MESSAGE_HANDLER(InputMsg_RequestTextInputStateUpdate, | |
| 717 OnRequestTextInputStateUpdate) | |
| 716 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) | 718 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) |
| 717 #endif | 719 #endif |
| 718 IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto) | 720 IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto) |
| 719 IPC_MESSAGE_UNHANDLED(handled = false) | 721 IPC_MESSAGE_UNHANDLED(handled = false) |
| 720 IPC_END_MESSAGE_MAP() | 722 IPC_END_MESSAGE_MAP() |
| 721 return handled; | 723 return handled; |
| 722 } | 724 } |
| 723 | 725 |
| 724 bool RenderWidget::Send(IPC::Message* message) { | 726 bool RenderWidget::Send(IPC::Message* message) { |
| 725 // Don't send any messages after the browser has told us to close, and filter | 727 // Don't send any messages after the browser has told us to close, and filter |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1157 if (IsDateTimeInput(new_type)) | 1159 if (IsDateTimeInput(new_type)) |
| 1158 return; // Not considered as a text input field in WebKit/Chromium. | 1160 return; // Not considered as a text input field in WebKit/Chromium. |
| 1159 | 1161 |
| 1160 blink::WebTextInputInfo new_info; | 1162 blink::WebTextInputInfo new_info; |
| 1161 if (webwidget_) | 1163 if (webwidget_) |
| 1162 new_info = webwidget_->textInputInfo(); | 1164 new_info = webwidget_->textInputInfo(); |
| 1163 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); | 1165 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); |
| 1164 | 1166 |
| 1165 bool new_can_compose_inline = CanComposeInline(); | 1167 bool new_can_compose_inline = CanComposeInline(); |
| 1166 | 1168 |
| 1169 bool use_ime_thread = false; | |
| 1170 #if defined(OS_ANDROID) | |
| 1171 use_ime_thread = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1172 switches::kUseImeThread); | |
| 1173 #endif | |
| 1174 | |
| 1167 // Only sends text input params if they are changed or if the ime should be | 1175 // Only sends text input params if they are changed or if the ime should be |
| 1168 // shown. | 1176 // shown. |
| 1169 if (show_ime == ShowIme::IF_NEEDED || | 1177 if (show_ime == ShowIme::IF_NEEDED || |
| 1178 (use_ime_thread && change_source == ChangeSource::FROM_IME) || | |
| 1170 (text_input_type_ != new_type || text_input_mode_ != new_mode || | 1179 (text_input_type_ != new_type || text_input_mode_ != new_mode || |
| 1171 text_input_info_ != new_info || | 1180 text_input_info_ != new_info || |
| 1172 can_compose_inline_ != new_can_compose_inline) | 1181 can_compose_inline_ != new_can_compose_inline) |
| 1173 #if defined(OS_ANDROID) | 1182 #if defined(OS_ANDROID) |
| 1174 || text_field_is_dirty_ | 1183 || text_field_is_dirty_ |
| 1175 #endif | 1184 #endif |
| 1176 ) { | 1185 ) { |
| 1177 ViewHostMsg_TextInputState_Params params; | 1186 ViewHostMsg_TextInputState_Params params; |
| 1178 params.type = new_type; | 1187 params.type = new_type; |
| 1179 params.mode = new_mode; | 1188 params.mode = new_mode; |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1708 | 1717 |
| 1709 #if defined(OS_ANDROID) | 1718 #if defined(OS_ANDROID) |
| 1710 void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) { | 1719 void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) { |
| 1711 text_input_info_history_.push_back(info); | 1720 text_input_info_history_.push_back(info); |
| 1712 } | 1721 } |
| 1713 | 1722 |
| 1714 void RenderWidget::OnImeEventAck() { | 1723 void RenderWidget::OnImeEventAck() { |
| 1715 DCHECK_GE(text_input_info_history_.size(), 1u); | 1724 DCHECK_GE(text_input_info_history_.size(), 1u); |
| 1716 text_input_info_history_.pop_front(); | 1725 text_input_info_history_.pop_front(); |
| 1717 } | 1726 } |
| 1727 | |
| 1728 void RenderWidget::OnRequestTextInputStateUpdate() { | |
| 1729 ImeEventGuard guard(this); | |
|
aelias_OOO_until_Jul13
2016/01/21 07:43:05
I don't like that there's nothing to distinguish t
Changwan Ryu
2016/01/22 10:22:17
That's a great idea. Done.
| |
| 1730 } | |
| 1718 #endif | 1731 #endif |
| 1719 | 1732 |
| 1720 bool RenderWidget::ShouldHandleImeEvent() { | 1733 bool RenderWidget::ShouldHandleImeEvent() { |
| 1721 #if defined(OS_ANDROID) | 1734 #if defined(OS_ANDROID) |
| 1722 if (!webwidget_) | 1735 if (!webwidget_) |
| 1723 return false; | 1736 return false; |
| 1737 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1738 switches::kUseImeThread)) | |
| 1739 return true; | |
| 1724 | 1740 |
| 1725 // We cannot handle IME events if there is any chance that the event we are | 1741 // We cannot handle IME events if there is any chance that the event we are |
| 1726 // receiving here from the browser is based on the state that is different | 1742 // receiving here from the browser is based on the state that is different |
| 1727 // from our current one as indicated by |text_input_info_|. | 1743 // from our current one as indicated by |text_input_info_|. |
| 1728 // The states the browser might be in are: | 1744 // The states the browser might be in are: |
| 1729 // text_input_info_history_[0] - current state ack'd by browser | 1745 // text_input_info_history_[0] - current state ack'd by browser |
| 1730 // text_input_info_history_[1...N] - pending state changes | 1746 // text_input_info_history_[1...N] - pending state changes |
| 1731 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) { | 1747 for (size_t i = 0u; i < text_input_info_history_.size() - 1u; ++i) { |
| 1732 if (text_input_info_history_[i] != text_input_info_) | 1748 if (text_input_info_history_[i] != text_input_info_) |
| 1733 return false; | 1749 return false; |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2106 STATIC_ASSERT_WTI_ENUM_MATCH(DoubleTapZoom, DOUBLE_TAP_ZOOM); | 2122 STATIC_ASSERT_WTI_ENUM_MATCH(DoubleTapZoom, DOUBLE_TAP_ZOOM); |
| 2107 STATIC_ASSERT_WTI_ENUM_MATCH(Auto, AUTO); | 2123 STATIC_ASSERT_WTI_ENUM_MATCH(Auto, AUTO); |
| 2108 | 2124 |
| 2109 content::TouchAction content_touch_action = | 2125 content::TouchAction content_touch_action = |
| 2110 static_cast<content::TouchAction>(web_touch_action); | 2126 static_cast<content::TouchAction>(web_touch_action); |
| 2111 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); | 2127 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); |
| 2112 } | 2128 } |
| 2113 | 2129 |
| 2114 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() { | 2130 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() { |
| 2115 #if defined(OS_ANDROID) | 2131 #if defined(OS_ANDROID) |
| 2116 text_field_is_dirty_ = true; | 2132 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2133 switches::kUseImeThread)) | |
| 2134 text_field_is_dirty_ = true; | |
| 2117 #endif | 2135 #endif |
| 2118 } | 2136 } |
| 2119 | 2137 |
| 2120 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 2138 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
| 2121 RenderWidget::CreateGraphicsContext3D(GpuChannelHost* gpu_channel_host) { | 2139 RenderWidget::CreateGraphicsContext3D(GpuChannelHost* gpu_channel_host) { |
| 2122 // Explicitly disable antialiasing for the compositor. As of the time of | 2140 // Explicitly disable antialiasing for the compositor. As of the time of |
| 2123 // this writing, the only platform that supported antialiasing for the | 2141 // this writing, the only platform that supported antialiasing for the |
| 2124 // compositor was Mac OS X, because the on-screen OpenGL context creation | 2142 // compositor was Mac OS X, because the on-screen OpenGL context creation |
| 2125 // code paths on Windows and Linux didn't yet have multisampling support. | 2143 // code paths on Windows and Linux didn't yet have multisampling support. |
| 2126 // Mac OS X essentially always behaves as though it's rendering offscreen. | 2144 // 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... | |
| 2195 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2213 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2196 video_hole_frames_.AddObserver(frame); | 2214 video_hole_frames_.AddObserver(frame); |
| 2197 } | 2215 } |
| 2198 | 2216 |
| 2199 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2217 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2200 video_hole_frames_.RemoveObserver(frame); | 2218 video_hole_frames_.RemoveObserver(frame); |
| 2201 } | 2219 } |
| 2202 #endif // defined(VIDEO_HOLE) | 2220 #endif // defined(VIDEO_HOLE) |
| 2203 | 2221 |
| 2204 } // namespace content | 2222 } // namespace content |
| OLD | NEW |