Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: content/renderer/render_widget.cc

Issue 2596193002: Clean up names and remove unnecessary parameter (Closed)
Patch Set: change show_ime to show_virtual_keyboard in the renderer Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/test/layouttest_support.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 void RenderWidget::UpdateVisualState() { 923 void RenderWidget::UpdateVisualState() {
924 GetWebWidget()->updateAllLifecyclePhases(); 924 GetWebWidget()->updateAllLifecyclePhases();
925 } 925 }
926 926
927 void RenderWidget::WillBeginCompositorFrame() { 927 void RenderWidget::WillBeginCompositorFrame() {
928 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); 928 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame");
929 929
930 // The UpdateTextInputState can result in further layout and possibly 930 // The UpdateTextInputState can result in further layout and possibly
931 // enable GPU acceleration so they need to be called before any painting 931 // enable GPU acceleration so they need to be called before any painting
932 // is done. 932 // is done.
933 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); 933 UpdateTextInputState();
934 UpdateSelectionBounds(); 934 UpdateSelectionBounds();
935 935
936 for (auto& observer : render_frame_proxies_) 936 for (auto& observer : render_frame_proxies_)
937 observer.WillBeginCompositorFrame(); 937 observer.WillBeginCompositorFrame();
938 } 938 }
939 939
940 std::unique_ptr<cc::SwapPromise> RenderWidget::RequestCopyOfOutputForLayoutTest( 940 std::unique_ptr<cc::SwapPromise> RenderWidget::RequestCopyOfOutputForLayoutTest(
941 std::unique_ptr<cc::CopyOutputRequest> request) { 941 std::unique_ptr<cc::CopyOutputRequest> request) {
942 return RenderThreadImpl::current()->RequestCopyOfOutputForLayoutTest( 942 return RenderThreadImpl::current()->RequestCopyOfOutputForLayoutTest(
943 routing_id_, std::move(request)); 943 routing_id_, std::move(request));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 } 1015 }
1016 } 1016 }
1017 1017
1018 void RenderWidget::SetInputHandler(RenderWidgetInputHandler* input_handler) { 1018 void RenderWidget::SetInputHandler(RenderWidgetInputHandler* input_handler) {
1019 // Nothing to do here. RenderWidget created the |input_handler| and will take 1019 // Nothing to do here. RenderWidget created the |input_handler| and will take
1020 // ownership of it. We just verify here that we don't already have an input 1020 // ownership of it. We just verify here that we don't already have an input
1021 // handler. 1021 // handler.
1022 DCHECK(!input_handler_); 1022 DCHECK(!input_handler_);
1023 } 1023 }
1024 1024
1025 void RenderWidget::UpdateTextInputState(ShowIme show_ime, 1025 void RenderWidget::ShowVirtualKeyboard() {
aelias_OOO_until_Jul13 2017/01/10 01:49:55 Could you avoid introducing the capitalized one an
Changwan Ryu 2017/01/12 04:53:09 As we talked offline, RenderWidget::ShowVirtualKey
1026 ChangeSource change_source) { 1026 UpdateTextInputStateInternal(true, false);
1027 }
1028
1029 void RenderWidget::UpdateTextInputState() {
1030 UpdateTextInputStateInternal(false, false);
1031 }
1032
1033 void RenderWidget::UpdateTextInputStateInternal(bool show_virtual_keyboard,
1034 bool reply_to_request) {
1027 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState"); 1035 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState");
1036
1028 if (ime_event_guard_) { 1037 if (ime_event_guard_) {
1029 // show_ime should still be effective even if it was set inside the IME 1038 DCHECK(!reply_to_request);
1039 // show_virtual_keyboard should still be effective even if it was set inside
1040 // the IME
1030 // event guard. 1041 // event guard.
1031 if (show_ime == ShowIme::IF_NEEDED) { 1042 if (show_virtual_keyboard)
1032 ime_event_guard_->set_show_ime(true); 1043 ime_event_guard_->set_show_virtual_keyboard(true);
1033 }
1034 return; 1044 return;
1035 } 1045 }
1036 1046
1037 ui::TextInputType new_type = GetTextInputType(); 1047 ui::TextInputType new_type = GetTextInputType();
1038 if (IsDateTimeInput(new_type)) 1048 if (IsDateTimeInput(new_type))
1039 return; // Not considered as a text input field in WebKit/Chromium. 1049 return; // Not considered as a text input field in WebKit/Chromium.
1040 1050
1041 blink::WebTextInputInfo new_info; 1051 blink::WebTextInputInfo new_info;
1042 if (auto* controller = GetInputMethodController()) 1052 if (auto* controller = GetInputMethodController())
1043 new_info = controller->textInputInfo(); 1053 new_info = controller->textInputInfo();
1044 const ui::TextInputMode new_mode = 1054 const ui::TextInputMode new_mode =
1045 ConvertWebTextInputMode(new_info.inputMode); 1055 ConvertWebTextInputMode(new_info.inputMode);
1046 1056
1047 bool new_can_compose_inline = CanComposeInline(); 1057 bool new_can_compose_inline = CanComposeInline();
1048 1058
1049 // Only sends text input params if they are changed or if the ime should be 1059 // Only sends text input params if they are changed or if the ime should be
1050 // shown. 1060 // shown.
1051 if (show_ime == ShowIme::IF_NEEDED || 1061 if (show_virtual_keyboard || reply_to_request ||
1052 change_source == ChangeSource::FROM_IME ||
1053 text_input_type_ != new_type || text_input_mode_ != new_mode || 1062 text_input_type_ != new_type || text_input_mode_ != new_mode ||
1054 text_input_info_ != new_info || 1063 text_input_info_ != new_info ||
1055 can_compose_inline_ != new_can_compose_inline) { 1064 can_compose_inline_ != new_can_compose_inline) {
1056 TextInputState params; 1065 TextInputState params;
1057 params.type = new_type; 1066 params.type = new_type;
1058 params.mode = new_mode; 1067 params.mode = new_mode;
1059 params.flags = new_info.flags; 1068 params.flags = new_info.flags;
1060 params.value = new_info.value.utf8(); 1069 params.value = new_info.value.utf8();
1061 params.selection_start = new_info.selectionStart; 1070 params.selection_start = new_info.selectionStart;
1062 params.selection_end = new_info.selectionEnd; 1071 params.selection_end = new_info.selectionEnd;
1063 params.composition_start = new_info.compositionStart; 1072 params.composition_start = new_info.compositionStart;
1064 params.composition_end = new_info.compositionEnd; 1073 params.composition_end = new_info.compositionEnd;
1065 params.can_compose_inline = new_can_compose_inline; 1074 params.can_compose_inline = new_can_compose_inline;
1066 params.show_ime_if_needed = (show_ime == ShowIme::IF_NEEDED); 1075 // TODO(changwan): change instances of show_ime_if_needed to
1067 #if defined(OS_ANDROID) || defined(USE_AURA) 1076 // show_virtual_keyboard.
1068 params.is_non_ime_change = (change_source == ChangeSource::FROM_NON_IME); 1077 params.show_ime_if_needed = show_virtual_keyboard;
1069 #endif 1078 params.reply_to_request = reply_to_request;
1070 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), params)); 1079 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), params));
1071 1080
1072 text_input_info_ = new_info; 1081 text_input_info_ = new_info;
1073 text_input_type_ = new_type; 1082 text_input_type_ = new_type;
1074 text_input_mode_ = new_mode; 1083 text_input_mode_ = new_mode;
1075 can_compose_inline_ = new_can_compose_inline; 1084 can_compose_inline_ = new_can_compose_inline;
1076 text_input_flags_ = new_info.flags; 1085 text_input_flags_ = new_info.flags;
1077 } 1086 }
1078 } 1087 }
1079 1088
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 ConvertWindowPointToViewport(client_point), screen_point, op); 1729 ConvertWindowPointToViewport(client_point), screen_point, op);
1721 } 1730 }
1722 1731
1723 void RenderWidget::OnDragSourceSystemDragEnded() { 1732 void RenderWidget::OnDragSourceSystemDragEnded() {
1724 if (!GetWebWidget()) 1733 if (!GetWebWidget())
1725 return; 1734 return;
1726 1735
1727 static_cast<WebFrameWidget*>(GetWebWidget())->dragSourceSystemDragEnded(); 1736 static_cast<WebFrameWidget*>(GetWebWidget())->dragSourceSystemDragEnded();
1728 } 1737 }
1729 1738
1730 void RenderWidget::showImeIfNeeded() { 1739 void RenderWidget::showVirtualKeyboard() {
1731 #if defined(OS_ANDROID) || defined(USE_AURA) 1740 ShowVirtualKeyboard();
1732 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME);
1733 #endif
1734 1741
1735 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with 1742 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with
1736 // virtual keyboard. 1743 // virtual keyboard.
1737 #if !defined(OS_ANDROID) 1744 #if !defined(OS_ANDROID)
1738 FocusChangeComplete(); 1745 FocusChangeComplete();
1739 #endif 1746 #endif
1740 } 1747 }
1741 1748
1742 ui::TextInputType RenderWidget::GetTextInputType() { 1749 ui::TextInputType RenderWidget::GetTextInputType() {
1743 #if BUILDFLAG(ENABLE_PLUGINS) 1750 #if BUILDFLAG(ENABLE_PLUGINS)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 rect->y *= GetOriginalDeviceScaleFactor(); 1802 rect->y *= GetOriginalDeviceScaleFactor();
1796 rect->width *= GetOriginalDeviceScaleFactor(); 1803 rect->width *= GetOriginalDeviceScaleFactor();
1797 rect->height *= GetOriginalDeviceScaleFactor(); 1804 rect->height *= GetOriginalDeviceScaleFactor();
1798 } 1805 }
1799 } 1806 }
1800 1807
1801 #if defined(OS_ANDROID) 1808 #if defined(OS_ANDROID)
1802 void RenderWidget::OnRequestTextInputStateUpdate() { 1809 void RenderWidget::OnRequestTextInputStateUpdate() {
1803 DCHECK(!ime_event_guard_); 1810 DCHECK(!ime_event_guard_);
1804 UpdateSelectionBounds(); 1811 UpdateSelectionBounds();
1805 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME); 1812 UpdateTextInputStateInternal(false, true /* reply_to_request */);
1806 } 1813 }
1807 #endif 1814 #endif
1808 1815
1809 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request, 1816 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request,
1810 bool monitor_request) { 1817 bool monitor_request) {
1811 monitor_composition_info_ = monitor_request; 1818 monitor_composition_info_ = monitor_request;
1812 if (!immediate_request) 1819 if (!immediate_request)
1813 return; 1820 return;
1814 UpdateCompositionInfo(true /* immediate request */); 1821 UpdateCompositionInfo(true /* immediate request */);
1815 } 1822 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; 1889 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK;
1883 } 1890 }
1884 1891
1885 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) { 1892 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) {
1886 if (!ime_event_guard_) 1893 if (!ime_event_guard_)
1887 ime_event_guard_ = guard; 1894 ime_event_guard_ = guard;
1888 } 1895 }
1889 1896
1890 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) { 1897 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) {
1891 if (ime_event_guard_ != guard) { 1898 if (ime_event_guard_ != guard) {
1892 #if defined(OS_ANDROID) 1899 DCHECK(!ime_event_guard_->reply_to_request());
1893 // In case a from-IME event (e.g. touch) ends up in not-from-IME event
1894 // (e.g. long press gesture), we want to treat it as not-from-IME event
1895 // so that ReplicaInputConnection can make changes to its Editable model.
1896 // Therefore, we want to mark this text state update as 'from IME' only
1897 // when all the nested events are all originating from IME.
1898 ime_event_guard_->set_from_ime(
1899 ime_event_guard_->from_ime() && guard->from_ime());
1900 #endif
1901 return; 1900 return;
1902 } 1901 }
1903 ime_event_guard_ = nullptr; 1902 ime_event_guard_ = nullptr;
1904 1903
1905 // While handling an ime event, text input state and selection bounds updates 1904 // While handling an ime event, text input state and selection bounds updates
1906 // are ignored. These must explicitly be updated once finished handling the 1905 // are ignored. These must explicitly be updated once finished handling the
1907 // ime event. 1906 // ime event.
1908 UpdateSelectionBounds(); 1907 UpdateSelectionBounds();
1909 #if defined(OS_ANDROID) 1908 #if defined(OS_ANDROID)
1910 UpdateTextInputState( 1909 if (guard->show_virtual_keyboard())
1911 guard->show_ime() ? ShowIme::IF_NEEDED : ShowIme::HIDE_IME, 1910 ShowVirtualKeyboard();
1912 guard->from_ime() ? ChangeSource::FROM_IME : ChangeSource::FROM_NON_IME); 1911 else
1912 UpdateTextInputState();
1913 #endif 1913 #endif
1914 } 1914 }
1915 1915
1916 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { 1916 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) {
1917 #if BUILDFLAG(ENABLE_PLUGINS) 1917 #if BUILDFLAG(ENABLE_PLUGINS)
1918 if (focused_pepper_plugin_) { 1918 if (focused_pepper_plugin_) {
1919 // TODO(kinaba) http://crbug.com/101101 1919 // TODO(kinaba) http://crbug.com/101101
1920 // Current Pepper IME API does not handle selection bounds. So we simply 1920 // Current Pepper IME API does not handle selection bounds. So we simply
1921 // use the caret position as an empty range for now. It will be updated 1921 // use the caret position as an empty range for now. It will be updated
1922 // after Pepper API equips features related to surrounding text retrieval. 1922 // after Pepper API equips features related to surrounding text retrieval.
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2116 } 2116 }
2117 #endif 2117 #endif
2118 2118
2119 void RenderWidget::didHandleGestureEvent( 2119 void RenderWidget::didHandleGestureEvent(
2120 const WebGestureEvent& event, 2120 const WebGestureEvent& event,
2121 bool event_cancelled) { 2121 bool event_cancelled) {
2122 #if defined(OS_ANDROID) || defined(USE_AURA) 2122 #if defined(OS_ANDROID) || defined(USE_AURA)
2123 if (event_cancelled) 2123 if (event_cancelled)
2124 return; 2124 return;
2125 if (event.type == WebInputEvent::GestureTap) { 2125 if (event.type == WebInputEvent::GestureTap) {
2126 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); 2126 ShowVirtualKeyboard();
2127 } else if (event.type == WebInputEvent::GestureLongPress) { 2127 } else if (event.type == WebInputEvent::GestureLongPress) {
2128 DCHECK(GetWebWidget()); 2128 DCHECK(GetWebWidget());
2129 blink::WebInputMethodController* controller = GetInputMethodController(); 2129 blink::WebInputMethodController* controller = GetInputMethodController();
2130 if (!controller || controller->textInputInfo().value.isEmpty()) 2130 if (!controller || controller->textInputInfo().value.isEmpty())
2131 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); 2131 UpdateTextInputState();
2132 else 2132 else
2133 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); 2133 ShowVirtualKeyboard();
2134 } 2134 }
2135 // TODO(ananta): Piggyback off existing IPCs to communicate this information, 2135 // TODO(ananta): Piggyback off existing IPCs to communicate this information,
2136 // crbug/420130. 2136 // crbug/420130.
2137 #if defined(OS_WIN) 2137 #if defined(OS_WIN)
2138 if (event.type != blink::WebGestureEvent::GestureTap) 2138 if (event.type != blink::WebGestureEvent::GestureTap)
2139 return; 2139 return;
2140 2140
2141 // TODO(estade): hit test the event against focused node to make sure 2141 // TODO(estade): hit test the event against focused node to make sure
2142 // the tap actually hit the focused node. 2142 // the tap actually hit the focused node.
2143 blink::WebInputMethodController* controller = GetInputMethodController(); 2143 blink::WebInputMethodController* controller = GetInputMethodController();
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2273 // browser side (https://crbug.com/669219). 2273 // browser side (https://crbug.com/669219).
2274 // If there is no WebFrameWidget, then there will be no 2274 // If there is no WebFrameWidget, then there will be no
2275 // InputMethodControllers for a WebLocalFrame. 2275 // InputMethodControllers for a WebLocalFrame.
2276 return nullptr; 2276 return nullptr;
2277 } 2277 }
2278 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) 2278 return static_cast<blink::WebFrameWidget*>(GetWebWidget())
2279 ->getActiveWebInputMethodController(); 2279 ->getActiveWebInputMethodController();
2280 } 2280 }
2281 2281
2282 } // namespace content 2282 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/test/layouttest_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698