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

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

Issue 2596193002: Clean up names and remove unnecessary parameter (Closed)
Patch Set: rebase 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 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 void RenderWidget::UpdateVisualState() { 925 void RenderWidget::UpdateVisualState() {
926 GetWebWidget()->updateAllLifecyclePhases(); 926 GetWebWidget()->updateAllLifecyclePhases();
927 } 927 }
928 928
929 void RenderWidget::WillBeginCompositorFrame() { 929 void RenderWidget::WillBeginCompositorFrame() {
930 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); 930 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame");
931 931
932 // The UpdateTextInputState can result in further layout and possibly 932 // The UpdateTextInputState can result in further layout and possibly
933 // enable GPU acceleration so they need to be called before any painting 933 // enable GPU acceleration so they need to be called before any painting
934 // is done. 934 // is done.
935 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); 935 UpdateTextInputState();
936 UpdateSelectionBounds(); 936 UpdateSelectionBounds();
937 937
938 for (auto& observer : render_frame_proxies_) 938 for (auto& observer : render_frame_proxies_)
939 observer.WillBeginCompositorFrame(); 939 observer.WillBeginCompositorFrame();
940 } 940 }
941 941
942 std::unique_ptr<cc::SwapPromise> RenderWidget::RequestCopyOfOutputForLayoutTest( 942 std::unique_ptr<cc::SwapPromise> RenderWidget::RequestCopyOfOutputForLayoutTest(
943 std::unique_ptr<cc::CopyOutputRequest> request) { 943 std::unique_ptr<cc::CopyOutputRequest> request) {
944 return RenderThreadImpl::current()->RequestCopyOfOutputForLayoutTest( 944 return RenderThreadImpl::current()->RequestCopyOfOutputForLayoutTest(
945 routing_id_, std::move(request)); 945 routing_id_, std::move(request));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 } 1017 }
1018 } 1018 }
1019 1019
1020 void RenderWidget::SetInputHandler(RenderWidgetInputHandler* input_handler) { 1020 void RenderWidget::SetInputHandler(RenderWidgetInputHandler* input_handler) {
1021 // Nothing to do here. RenderWidget created the |input_handler| and will take 1021 // Nothing to do here. RenderWidget created the |input_handler| and will take
1022 // ownership of it. We just verify here that we don't already have an input 1022 // ownership of it. We just verify here that we don't already have an input
1023 // handler. 1023 // handler.
1024 DCHECK(!input_handler_); 1024 DCHECK(!input_handler_);
1025 } 1025 }
1026 1026
1027 void RenderWidget::UpdateTextInputState(ShowIme show_ime, 1027 void RenderWidget::ShowVirtualKeyboard() {
1028 ChangeSource change_source) { 1028 UpdateTextInputStateInternal(true, false);
1029 }
1030
1031 void RenderWidget::UpdateTextInputState() {
1032 UpdateTextInputStateInternal(false, false);
1033 }
1034
1035 void RenderWidget::UpdateTextInputStateInternal(bool show_virtual_keyboard,
1036 bool reply_to_request) {
1029 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState"); 1037 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState");
1038
1030 if (ime_event_guard_) { 1039 if (ime_event_guard_) {
1031 // show_ime should still be effective even if it was set inside the IME 1040 DCHECK(!reply_to_request);
1041 // show_virtual_keyboard should still be effective even if it was set inside
1042 // the IME
1032 // event guard. 1043 // event guard.
1033 if (show_ime == ShowIme::IF_NEEDED) { 1044 if (show_virtual_keyboard)
1034 ime_event_guard_->set_show_ime(true); 1045 ime_event_guard_->set_show_virtual_keyboard(true);
1035 }
1036 return; 1046 return;
1037 } 1047 }
1038 1048
1039 ui::TextInputType new_type = GetTextInputType(); 1049 ui::TextInputType new_type = GetTextInputType();
1040 if (IsDateTimeInput(new_type)) 1050 if (IsDateTimeInput(new_type))
1041 return; // Not considered as a text input field in WebKit/Chromium. 1051 return; // Not considered as a text input field in WebKit/Chromium.
1042 1052
1043 blink::WebTextInputInfo new_info; 1053 blink::WebTextInputInfo new_info;
1044 if (auto* controller = GetInputMethodController()) 1054 if (auto* controller = GetInputMethodController())
1045 new_info = controller->textInputInfo(); 1055 new_info = controller->textInputInfo();
1046 const ui::TextInputMode new_mode = 1056 const ui::TextInputMode new_mode =
1047 ConvertWebTextInputMode(new_info.inputMode); 1057 ConvertWebTextInputMode(new_info.inputMode);
1048 1058
1049 bool new_can_compose_inline = CanComposeInline(); 1059 bool new_can_compose_inline = CanComposeInline();
1050 1060
1051 // Only sends text input params if they are changed or if the ime should be 1061 // Only sends text input params if they are changed or if the ime should be
1052 // shown. 1062 // shown.
1053 if (show_ime == ShowIme::IF_NEEDED || 1063 if (show_virtual_keyboard || reply_to_request ||
1054 change_source == ChangeSource::FROM_IME ||
1055 text_input_type_ != new_type || text_input_mode_ != new_mode || 1064 text_input_type_ != new_type || text_input_mode_ != new_mode ||
1056 text_input_info_ != new_info || 1065 text_input_info_ != new_info ||
1057 can_compose_inline_ != new_can_compose_inline) { 1066 can_compose_inline_ != new_can_compose_inline) {
1058 TextInputState params; 1067 TextInputState params;
1059 params.type = new_type; 1068 params.type = new_type;
1060 params.mode = new_mode; 1069 params.mode = new_mode;
1061 params.flags = new_info.flags; 1070 params.flags = new_info.flags;
1062 params.value = new_info.value.utf8(); 1071 params.value = new_info.value.utf8();
1063 params.selection_start = new_info.selectionStart; 1072 params.selection_start = new_info.selectionStart;
1064 params.selection_end = new_info.selectionEnd; 1073 params.selection_end = new_info.selectionEnd;
1065 params.composition_start = new_info.compositionStart; 1074 params.composition_start = new_info.compositionStart;
1066 params.composition_end = new_info.compositionEnd; 1075 params.composition_end = new_info.compositionEnd;
1067 params.can_compose_inline = new_can_compose_inline; 1076 params.can_compose_inline = new_can_compose_inline;
1068 params.show_ime_if_needed = (show_ime == ShowIme::IF_NEEDED); 1077 // TODO(changwan): change instances of show_ime_if_needed to
1069 #if defined(OS_ANDROID) || defined(USE_AURA) 1078 // show_virtual_keyboard.
1070 params.is_non_ime_change = (change_source == ChangeSource::FROM_NON_IME); 1079 params.show_ime_if_needed = show_virtual_keyboard;
1071 #endif 1080 params.reply_to_request = reply_to_request;
1072 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), params)); 1081 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), params));
1073 1082
1074 text_input_info_ = new_info; 1083 text_input_info_ = new_info;
1075 text_input_type_ = new_type; 1084 text_input_type_ = new_type;
1076 text_input_mode_ = new_mode; 1085 text_input_mode_ = new_mode;
1077 can_compose_inline_ = new_can_compose_inline; 1086 can_compose_inline_ = new_can_compose_inline;
1078 text_input_flags_ = new_info.flags; 1087 text_input_flags_ = new_info.flags;
1079 } 1088 }
1080 } 1089 }
1081 1090
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 ConvertWindowPointToViewport(client_point), screen_point, op); 1741 ConvertWindowPointToViewport(client_point), screen_point, op);
1733 } 1742 }
1734 1743
1735 void RenderWidget::OnDragSourceSystemDragEnded() { 1744 void RenderWidget::OnDragSourceSystemDragEnded() {
1736 if (!GetWebWidget()) 1745 if (!GetWebWidget())
1737 return; 1746 return;
1738 1747
1739 static_cast<WebFrameWidget*>(GetWebWidget())->dragSourceSystemDragEnded(); 1748 static_cast<WebFrameWidget*>(GetWebWidget())->dragSourceSystemDragEnded();
1740 } 1749 }
1741 1750
1742 void RenderWidget::showImeIfNeeded() { 1751 void RenderWidget::showVirtualKeyboard() {
1743 #if defined(OS_ANDROID) || defined(USE_AURA) 1752 ShowVirtualKeyboard();
1744 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME);
1745 #endif
1746 1753
1747 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with 1754 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with
1748 // virtual keyboard. 1755 // virtual keyboard.
1749 #if !defined(OS_ANDROID) 1756 #if !defined(OS_ANDROID)
1750 FocusChangeComplete(); 1757 FocusChangeComplete();
1751 #endif 1758 #endif
1752 } 1759 }
1753 1760
1754 ui::TextInputType RenderWidget::GetTextInputType() { 1761 ui::TextInputType RenderWidget::GetTextInputType() {
1755 #if BUILDFLAG(ENABLE_PLUGINS) 1762 #if BUILDFLAG(ENABLE_PLUGINS)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 rect->y *= GetOriginalDeviceScaleFactor(); 1814 rect->y *= GetOriginalDeviceScaleFactor();
1808 rect->width *= GetOriginalDeviceScaleFactor(); 1815 rect->width *= GetOriginalDeviceScaleFactor();
1809 rect->height *= GetOriginalDeviceScaleFactor(); 1816 rect->height *= GetOriginalDeviceScaleFactor();
1810 } 1817 }
1811 } 1818 }
1812 1819
1813 #if defined(OS_ANDROID) 1820 #if defined(OS_ANDROID)
1814 void RenderWidget::OnRequestTextInputStateUpdate() { 1821 void RenderWidget::OnRequestTextInputStateUpdate() {
1815 DCHECK(!ime_event_guard_); 1822 DCHECK(!ime_event_guard_);
1816 UpdateSelectionBounds(); 1823 UpdateSelectionBounds();
1817 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME); 1824 UpdateTextInputStateInternal(false, true /* reply_to_request */);
1818 } 1825 }
1819 #endif 1826 #endif
1820 1827
1821 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request, 1828 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request,
1822 bool monitor_request) { 1829 bool monitor_request) {
1823 monitor_composition_info_ = monitor_request; 1830 monitor_composition_info_ = monitor_request;
1824 if (!immediate_request) 1831 if (!immediate_request)
1825 return; 1832 return;
1826 UpdateCompositionInfo(true /* immediate request */); 1833 UpdateCompositionInfo(true /* immediate request */);
1827 } 1834 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; 1888 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK;
1882 } 1889 }
1883 1890
1884 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) { 1891 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) {
1885 if (!ime_event_guard_) 1892 if (!ime_event_guard_)
1886 ime_event_guard_ = guard; 1893 ime_event_guard_ = guard;
1887 } 1894 }
1888 1895
1889 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) { 1896 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) {
1890 if (ime_event_guard_ != guard) { 1897 if (ime_event_guard_ != guard) {
1891 #if defined(OS_ANDROID) 1898 DCHECK(!ime_event_guard_->reply_to_request());
1892 // In case a from-IME event (e.g. touch) ends up in not-from-IME event
1893 // (e.g. long press gesture), we want to treat it as not-from-IME event
1894 // so that ReplicaInputConnection can make changes to its Editable model.
1895 // Therefore, we want to mark this text state update as 'from IME' only
1896 // when all the nested events are all originating from IME.
1897 ime_event_guard_->set_from_ime(
1898 ime_event_guard_->from_ime() && guard->from_ime());
1899 #endif
1900 return; 1899 return;
1901 } 1900 }
1902 ime_event_guard_ = nullptr; 1901 ime_event_guard_ = nullptr;
1903 1902
1904 // While handling an ime event, text input state and selection bounds updates 1903 // While handling an ime event, text input state and selection bounds updates
1905 // are ignored. These must explicitly be updated once finished handling the 1904 // are ignored. These must explicitly be updated once finished handling the
1906 // ime event. 1905 // ime event.
1907 UpdateSelectionBounds(); 1906 UpdateSelectionBounds();
1908 #if defined(OS_ANDROID) 1907 #if defined(OS_ANDROID)
1909 UpdateTextInputState( 1908 if (guard->show_virtual_keyboard())
1910 guard->show_ime() ? ShowIme::IF_NEEDED : ShowIme::HIDE_IME, 1909 ShowVirtualKeyboard();
1911 guard->from_ime() ? ChangeSource::FROM_IME : ChangeSource::FROM_NON_IME); 1910 else
1911 UpdateTextInputState();
1912 #endif 1912 #endif
1913 } 1913 }
1914 1914
1915 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { 1915 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) {
1916 #if BUILDFLAG(ENABLE_PLUGINS) 1916 #if BUILDFLAG(ENABLE_PLUGINS)
1917 if (focused_pepper_plugin_) { 1917 if (focused_pepper_plugin_) {
1918 // TODO(kinaba) http://crbug.com/101101 1918 // TODO(kinaba) http://crbug.com/101101
1919 // Current Pepper IME API does not handle selection bounds. So we simply 1919 // Current Pepper IME API does not handle selection bounds. So we simply
1920 // use the caret position as an empty range for now. It will be updated 1920 // use the caret position as an empty range for now. It will be updated
1921 // after Pepper API equips features related to surrounding text retrieval. 1921 // after Pepper API equips features related to surrounding text retrieval.
(...skipping 194 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