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 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 ime_event_guard_->set_show_ime(true); | 1026 ime_event_guard_->set_show_ime(true); |
1027 } | 1027 } |
1028 return; | 1028 return; |
1029 } | 1029 } |
1030 | 1030 |
1031 ui::TextInputType new_type = GetTextInputType(); | 1031 ui::TextInputType new_type = GetTextInputType(); |
1032 if (IsDateTimeInput(new_type)) | 1032 if (IsDateTimeInput(new_type)) |
1033 return; // Not considered as a text input field in WebKit/Chromium. | 1033 return; // Not considered as a text input field in WebKit/Chromium. |
1034 | 1034 |
1035 blink::WebTextInputInfo new_info; | 1035 blink::WebTextInputInfo new_info; |
1036 if (GetWebWidget()) | 1036 if (auto* controller = GetInputMethodController()) |
1037 new_info = GetWebWidget()->textInputInfo(); | 1037 new_info = controller->textInputInfo(); |
1038 const ui::TextInputMode new_mode = | 1038 const ui::TextInputMode new_mode = |
1039 ConvertWebTextInputMode(new_info.inputMode); | 1039 ConvertWebTextInputMode(new_info.inputMode); |
1040 | 1040 |
1041 bool new_can_compose_inline = CanComposeInline(); | 1041 bool new_can_compose_inline = CanComposeInline(); |
1042 | 1042 |
1043 // Only sends text input params if they are changed or if the ime should be | 1043 // Only sends text input params if they are changed or if the ime should be |
1044 // shown. | 1044 // shown. |
1045 if (show_ime == ShowIme::IF_NEEDED || | 1045 if (show_ime == ShowIme::IF_NEEDED || |
1046 change_source == ChangeSource::FROM_IME || | 1046 change_source == ChangeSource::FROM_IME || |
1047 text_input_type_ != new_type || text_input_mode_ != new_mode || | 1047 text_input_type_ != new_type || text_input_mode_ != new_mode || |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1721 #if !defined(OS_ANDROID) | 1721 #if !defined(OS_ANDROID) |
1722 FocusChangeComplete(); | 1722 FocusChangeComplete(); |
1723 #endif | 1723 #endif |
1724 } | 1724 } |
1725 | 1725 |
1726 ui::TextInputType RenderWidget::GetTextInputType() { | 1726 ui::TextInputType RenderWidget::GetTextInputType() { |
1727 #if BUILDFLAG(ENABLE_PLUGINS) | 1727 #if BUILDFLAG(ENABLE_PLUGINS) |
1728 if (focused_pepper_plugin_) | 1728 if (focused_pepper_plugin_) |
1729 return focused_pepper_plugin_->text_input_type(); | 1729 return focused_pepper_plugin_->text_input_type(); |
1730 #endif | 1730 #endif |
1731 if (GetWebWidget()) | 1731 if (auto* controller = GetInputMethodController()) |
1732 return ConvertWebTextInputType(GetWebWidget()->textInputType()); | 1732 return ConvertWebTextInputType(controller->textInputType()); |
1733 return ui::TEXT_INPUT_TYPE_NONE; | 1733 return ui::TEXT_INPUT_TYPE_NONE; |
1734 } | 1734 } |
1735 | 1735 |
1736 void RenderWidget::UpdateCompositionInfo(bool immediate_request) { | 1736 void RenderWidget::UpdateCompositionInfo(bool immediate_request) { |
1737 if (!monitor_composition_info_ && !immediate_request) | 1737 if (!monitor_composition_info_ && !immediate_request) |
1738 return; // Do not calculate composition info if not requested. | 1738 return; // Do not calculate composition info if not requested. |
1739 | 1739 |
1740 TRACE_EVENT0("renderer", "RenderWidget::UpdateCompositionInfo"); | 1740 TRACE_EVENT0("renderer", "RenderWidget::UpdateCompositionInfo"); |
1741 gfx::Range range; | 1741 gfx::Range range; |
1742 std::vector<gfx::Rect> character_bounds; | 1742 std::vector<gfx::Rect> character_bounds; |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2103 void RenderWidget::didHandleGestureEvent( | 2103 void RenderWidget::didHandleGestureEvent( |
2104 const WebGestureEvent& event, | 2104 const WebGestureEvent& event, |
2105 bool event_cancelled) { | 2105 bool event_cancelled) { |
2106 #if defined(OS_ANDROID) || defined(USE_AURA) | 2106 #if defined(OS_ANDROID) || defined(USE_AURA) |
2107 if (event_cancelled) | 2107 if (event_cancelled) |
2108 return; | 2108 return; |
2109 if (event.type == WebInputEvent::GestureTap) { | 2109 if (event.type == WebInputEvent::GestureTap) { |
2110 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); | 2110 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); |
2111 } else if (event.type == WebInputEvent::GestureLongPress) { | 2111 } else if (event.type == WebInputEvent::GestureLongPress) { |
2112 DCHECK(GetWebWidget()); | 2112 DCHECK(GetWebWidget()); |
2113 if (GetWebWidget()->textInputInfo().value.isEmpty()) | 2113 blink::WebInputMethodController* controller = GetInputMethodController(); |
| 2114 if (!controller || controller->textInputInfo().value.isEmpty()) |
2114 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); | 2115 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); |
2115 else | 2116 else |
2116 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); | 2117 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); |
2117 } | 2118 } |
2118 #endif | 2119 #endif |
2119 } | 2120 } |
2120 | 2121 |
2121 void RenderWidget::didOverscroll( | 2122 void RenderWidget::didOverscroll( |
2122 const blink::WebFloatSize& overscrollDelta, | 2123 const blink::WebFloatSize& overscrollDelta, |
2123 const blink::WebFloatSize& accumulatedOverscroll, | 2124 const blink::WebFloatSize& accumulatedOverscroll, |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2241 // browser side (https://crbug.com/669219). | 2242 // browser side (https://crbug.com/669219). |
2242 // If there is no WebFrameWidget, then there will be no | 2243 // If there is no WebFrameWidget, then there will be no |
2243 // InputMethodControllers for a WebLocalFrame. | 2244 // InputMethodControllers for a WebLocalFrame. |
2244 return nullptr; | 2245 return nullptr; |
2245 } | 2246 } |
2246 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) | 2247 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) |
2247 ->getActiveWebInputMethodController(); | 2248 ->getActiveWebInputMethodController(); |
2248 } | 2249 } |
2249 | 2250 |
2250 } // namespace content | 2251 } // namespace content |
OLD | NEW |