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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1031 ime_event_guard_->set_show_ime(true); | 1031 ime_event_guard_->set_show_ime(true); |
1032 } | 1032 } |
1033 return; | 1033 return; |
1034 } | 1034 } |
1035 | 1035 |
1036 ui::TextInputType new_type = GetTextInputType(); | 1036 ui::TextInputType new_type = GetTextInputType(); |
1037 if (IsDateTimeInput(new_type)) | 1037 if (IsDateTimeInput(new_type)) |
1038 return; // Not considered as a text input field in WebKit/Chromium. | 1038 return; // Not considered as a text input field in WebKit/Chromium. |
1039 | 1039 |
1040 blink::WebTextInputInfo new_info; | 1040 blink::WebTextInputInfo new_info; |
1041 if (GetWebWidget()) | 1041 if (auto* controller = GetInputMethodController()) |
1042 new_info = GetWebWidget()->textInputInfo(); | 1042 new_info = controller->textInputInfo(); |
1043 const ui::TextInputMode new_mode = | 1043 const ui::TextInputMode new_mode = |
1044 ConvertWebTextInputMode(new_info.inputMode); | 1044 ConvertWebTextInputMode(new_info.inputMode); |
1045 | 1045 |
1046 bool new_can_compose_inline = CanComposeInline(); | 1046 bool new_can_compose_inline = CanComposeInline(); |
1047 | 1047 |
1048 // Only sends text input params if they are changed or if the ime should be | 1048 // Only sends text input params if they are changed or if the ime should be |
1049 // shown. | 1049 // shown. |
1050 if (show_ime == ShowIme::IF_NEEDED || | 1050 if (show_ime == ShowIme::IF_NEEDED || |
1051 (IsUsingImeThread() && change_source == ChangeSource::FROM_IME) || | 1051 (IsUsingImeThread() && change_source == ChangeSource::FROM_IME) || |
1052 (text_input_type_ != new_type || text_input_mode_ != new_mode || | 1052 (text_input_type_ != new_type || text_input_mode_ != new_mode || |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1735 #if !defined(OS_ANDROID) | 1735 #if !defined(OS_ANDROID) |
1736 FocusChangeComplete(); | 1736 FocusChangeComplete(); |
1737 #endif | 1737 #endif |
1738 } | 1738 } |
1739 | 1739 |
1740 ui::TextInputType RenderWidget::GetTextInputType() { | 1740 ui::TextInputType RenderWidget::GetTextInputType() { |
1741 #if defined(ENABLE_PLUGINS) | 1741 #if defined(ENABLE_PLUGINS) |
1742 if (focused_pepper_plugin_) | 1742 if (focused_pepper_plugin_) |
1743 return focused_pepper_plugin_->text_input_type(); | 1743 return focused_pepper_plugin_->text_input_type(); |
1744 #endif | 1744 #endif |
1745 if (GetWebWidget()) | 1745 if (auto* controller = GetInputMethodController()) |
1746 return ConvertWebTextInputType(GetWebWidget()->textInputType()); | 1746 return ConvertWebTextInputType(controller->textInputType()); |
1747 return ui::TEXT_INPUT_TYPE_NONE; | 1747 return ui::TEXT_INPUT_TYPE_NONE; |
1748 } | 1748 } |
1749 | 1749 |
1750 void RenderWidget::UpdateCompositionInfo(bool immediate_request) { | 1750 void RenderWidget::UpdateCompositionInfo(bool immediate_request) { |
1751 if (!monitor_composition_info_ && !immediate_request) | 1751 if (!monitor_composition_info_ && !immediate_request) |
1752 return; // Do not calculate composition info if not requested. | 1752 return; // Do not calculate composition info if not requested. |
1753 | 1753 |
1754 TRACE_EVENT0("renderer", "RenderWidget::UpdateCompositionInfo"); | 1754 TRACE_EVENT0("renderer", "RenderWidget::UpdateCompositionInfo"); |
1755 gfx::Range range; | 1755 gfx::Range range; |
1756 std::vector<gfx::Rect> character_bounds; | 1756 std::vector<gfx::Rect> character_bounds; |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2165 void RenderWidget::didHandleGestureEvent( | 2165 void RenderWidget::didHandleGestureEvent( |
2166 const WebGestureEvent& event, | 2166 const WebGestureEvent& event, |
2167 bool event_cancelled) { | 2167 bool event_cancelled) { |
2168 #if defined(OS_ANDROID) || defined(USE_AURA) | 2168 #if defined(OS_ANDROID) || defined(USE_AURA) |
2169 if (event_cancelled) | 2169 if (event_cancelled) |
2170 return; | 2170 return; |
2171 if (event.type == WebInputEvent::GestureTap) { | 2171 if (event.type == WebInputEvent::GestureTap) { |
2172 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); | 2172 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); |
2173 } else if (event.type == WebInputEvent::GestureLongPress) { | 2173 } else if (event.type == WebInputEvent::GestureLongPress) { |
2174 DCHECK(GetWebWidget()); | 2174 DCHECK(GetWebWidget()); |
2175 if (GetWebWidget()->textInputInfo().value.isEmpty()) | 2175 blink::WebInputMethodController* controller = GetInputMethodController(); |
2176 if (controller && controller->textInputInfo().value.isEmpty()) | |
Charlie Reis
2016/11/23 23:35:09
Is this right? This looks like it's hiding the IM
EhsanK
2016/11/24 02:27:45
Yes. Apparently, this is because we should show a
| |
2176 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); | 2177 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); |
2177 else | 2178 else |
2178 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); | 2179 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); |
2179 } | 2180 } |
2180 #endif | 2181 #endif |
2181 } | 2182 } |
2182 | 2183 |
2183 void RenderWidget::didOverscroll( | 2184 void RenderWidget::didOverscroll( |
2184 const blink::WebFloatSize& overscrollDelta, | 2185 const blink::WebFloatSize& overscrollDelta, |
2185 const blink::WebFloatSize& accumulatedOverscroll, | 2186 const blink::WebFloatSize& accumulatedOverscroll, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2305 blink::WebInputMethodController* RenderWidget::GetInputMethodController() | 2306 blink::WebInputMethodController* RenderWidget::GetInputMethodController() |
2306 const { | 2307 const { |
2307 // TODO(ekaramad): Remove this CHECK when GetWebWidget() is | 2308 // TODO(ekaramad): Remove this CHECK when GetWebWidget() is |
2308 // always a WebFrameWidget. | 2309 // always a WebFrameWidget. |
2309 CHECK(GetWebWidget()->isWebFrameWidget()); | 2310 CHECK(GetWebWidget()->isWebFrameWidget()); |
2310 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) | 2311 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) |
2311 ->getActiveWebInputMethodController(); | 2312 ->getActiveWebInputMethodController(); |
2312 } | 2313 } |
2313 | 2314 |
2314 } // namespace content | 2315 } // namespace content |
OLD | NEW |