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

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

Issue 2333813002: Introduce WebInputMethodController to blink (Closed)
Patch Set: Updated a comment Created 4 years, 2 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/renderer/render_widget_browsertest.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "skia/ext/platform_canvas.h" 57 #include "skia/ext/platform_canvas.h"
58 #include "third_party/WebKit/public/platform/WebCursorInfo.h" 58 #include "third_party/WebKit/public/platform/WebCursorInfo.h"
59 #include "third_party/WebKit/public/platform/WebPoint.h" 59 #include "third_party/WebKit/public/platform/WebPoint.h"
60 #include "third_party/WebKit/public/platform/WebRect.h" 60 #include "third_party/WebKit/public/platform/WebRect.h"
61 #include "third_party/WebKit/public/platform/WebSize.h" 61 #include "third_party/WebKit/public/platform/WebSize.h"
62 #include "third_party/WebKit/public/platform/WebString.h" 62 #include "third_party/WebKit/public/platform/WebString.h"
63 #include "third_party/WebKit/public/platform/scheduler/renderer/render_widget_sc heduling_state.h" 63 #include "third_party/WebKit/public/platform/scheduler/renderer/render_widget_sc heduling_state.h"
64 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul er.h" 64 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul er.h"
65 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" 65 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
66 #include "third_party/WebKit/public/web/WebFrameWidget.h" 66 #include "third_party/WebKit/public/web/WebFrameWidget.h"
67 #include "third_party/WebKit/public/web/WebInputMethodController.h"
67 #include "third_party/WebKit/public/web/WebLocalFrame.h" 68 #include "third_party/WebKit/public/web/WebLocalFrame.h"
68 #include "third_party/WebKit/public/web/WebNode.h" 69 #include "third_party/WebKit/public/web/WebNode.h"
69 #include "third_party/WebKit/public/web/WebPagePopup.h" 70 #include "third_party/WebKit/public/web/WebPagePopup.h"
70 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" 71 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h"
71 #include "third_party/WebKit/public/web/WebRange.h" 72 #include "third_party/WebKit/public/web/WebRange.h"
72 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 73 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
73 #include "third_party/WebKit/public/web/WebView.h" 74 #include "third_party/WebKit/public/web/WebView.h"
74 #include "third_party/WebKit/public/web/WebWidget.h" 75 #include "third_party/WebKit/public/web/WebWidget.h"
75 #include "third_party/skia/include/core/SkShader.h" 76 #include "third_party/skia/include/core/SkShader.h"
76 #include "ui/base/ui_base_switches.h" 77 #include "ui/base/ui_base_switches.h"
(...skipping 22 matching lines...) Expand all
99 #if defined(OS_MACOSX) 100 #if defined(OS_MACOSX)
100 #include "content/renderer/text_input_client_observer.h" 101 #include "content/renderer/text_input_client_observer.h"
101 #endif 102 #endif
102 103
103 using blink::WebCompositionUnderline; 104 using blink::WebCompositionUnderline;
104 using blink::WebCursorInfo; 105 using blink::WebCursorInfo;
105 using blink::WebDeviceEmulationParams; 106 using blink::WebDeviceEmulationParams;
106 using blink::WebGestureEvent; 107 using blink::WebGestureEvent;
107 using blink::WebInputEvent; 108 using blink::WebInputEvent;
108 using blink::WebInputEventResult; 109 using blink::WebInputEventResult;
110 using blink::WebInputMethodController;
109 using blink::WebKeyboardEvent; 111 using blink::WebKeyboardEvent;
110 using blink::WebMouseEvent; 112 using blink::WebMouseEvent;
111 using blink::WebMouseWheelEvent; 113 using blink::WebMouseWheelEvent;
112 using blink::WebNavigationPolicy; 114 using blink::WebNavigationPolicy;
113 using blink::WebNode; 115 using blink::WebNode;
114 using blink::WebPagePopup; 116 using blink::WebPagePopup;
115 using blink::WebPoint; 117 using blink::WebPoint;
116 using blink::WebPopupType; 118 using blink::WebPopupType;
117 using blink::WebRange; 119 using blink::WebRange;
118 using blink::WebRect; 120 using blink::WebRect;
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 } 1409 }
1408 #endif 1410 #endif
1409 if (replacement_range.IsValid()) { 1411 if (replacement_range.IsValid()) {
1410 GetWebWidget()->applyReplacementRange( 1412 GetWebWidget()->applyReplacementRange(
1411 WebRange(replacement_range.start(), replacement_range.length())); 1413 WebRange(replacement_range.start(), replacement_range.length()));
1412 } 1414 }
1413 1415
1414 if (!ShouldHandleImeEvent()) 1416 if (!ShouldHandleImeEvent())
1415 return; 1417 return;
1416 ImeEventGuard guard(this); 1418 ImeEventGuard guard(this);
1417 if (!GetWebWidget()->setComposition( 1419 DCHECK(GetInputMethodController());
1420 if (!GetInputMethodController() ||
dglazkov 2016/10/06 22:18:58 this can be inverted and done the same way as I su
EhsanK 2016/11/01 15:46:04 Acknowledged.
1421 !GetInputMethodController()->setComposition(
1418 text, WebVector<WebCompositionUnderline>(underlines), selection_start, 1422 text, WebVector<WebCompositionUnderline>(underlines), selection_start,
1419 selection_end)) { 1423 selection_end)) {
1420 // If we failed to set the composition text, then we need to let the browser 1424 // If we failed to set the composition text, then we need to let the browser
1421 // process to cancel the input method's ongoing composition session, to make 1425 // process to cancel the input method's ongoing composition session, to make
1422 // sure we are in a consistent state. 1426 // sure we are in a consistent state.
1423 Send(new InputHostMsg_ImeCancelComposition(routing_id())); 1427 Send(new InputHostMsg_ImeCancelComposition(routing_id()));
1424 } 1428 }
1425 UpdateCompositionInfo(false /* not an immediate request */); 1429 UpdateCompositionInfo(false /* not an immediate request */);
1426 } 1430 }
1427 1431
1428 void RenderWidget::OnImeCommitText(const base::string16& text, 1432 void RenderWidget::OnImeCommitText(const base::string16& text,
1429 const gfx::Range& replacement_range, 1433 const gfx::Range& replacement_range,
1430 int relative_cursor_pos) { 1434 int relative_cursor_pos) {
1431 #if defined(ENABLE_PLUGINS) 1435 #if defined(ENABLE_PLUGINS)
1432 if (focused_pepper_plugin_) { 1436 if (focused_pepper_plugin_) {
1433 focused_pepper_plugin_->render_frame()->OnImeCommitText( 1437 focused_pepper_plugin_->render_frame()->OnImeCommitText(
1434 text, replacement_range, relative_cursor_pos); 1438 text, replacement_range, relative_cursor_pos);
1435 return; 1439 return;
1436 } 1440 }
1437 #endif 1441 #endif
1438 if (replacement_range.IsValid()) { 1442 if (replacement_range.IsValid()) {
1439 GetWebWidget()->applyReplacementRange( 1443 GetWebWidget()->applyReplacementRange(
1440 WebRange(replacement_range.start(), replacement_range.length())); 1444 WebRange(replacement_range.start(), replacement_range.length()));
1441 } 1445 }
1442 1446
1443 if (!ShouldHandleImeEvent()) 1447 if (!ShouldHandleImeEvent())
1444 return; 1448 return;
1445 ImeEventGuard guard(this); 1449 ImeEventGuard guard(this);
1446 input_handler_->set_handling_input_event(true); 1450 input_handler_->set_handling_input_event(true);
1447 GetWebWidget()->commitText(text, relative_cursor_pos); 1451 if (GetInputMethodController())
1452 GetInputMethodController()->commitText(text, relative_cursor_pos);
dglazkov 2016/10/06 22:18:58 if (auto* controller = GetInputMethodController())
EhsanK 2016/11/01 15:46:04 Acknowledged.
1448 input_handler_->set_handling_input_event(false); 1453 input_handler_->set_handling_input_event(false);
1449 UpdateCompositionInfo(false /* not an immediate request */); 1454 UpdateCompositionInfo(false /* not an immediate request */);
1450 } 1455 }
1451 1456
1452 void RenderWidget::OnImeFinishComposingText(bool keep_selection) { 1457 void RenderWidget::OnImeFinishComposingText(bool keep_selection) {
1453 #if defined(ENABLE_PLUGINS) 1458 #if defined(ENABLE_PLUGINS)
1454 if (focused_pepper_plugin_) { 1459 if (focused_pepper_plugin_) {
1455 focused_pepper_plugin_->render_frame()->OnImeFinishComposingText( 1460 focused_pepper_plugin_->render_frame()->OnImeFinishComposingText(
1456 keep_selection); 1461 keep_selection);
1457 return; 1462 return;
1458 } 1463 }
1459 #endif 1464 #endif
1460 1465
1461 if (!ShouldHandleImeEvent()) 1466 if (!ShouldHandleImeEvent())
1462 return; 1467 return;
1463 ImeEventGuard guard(this); 1468 ImeEventGuard guard(this);
1464 input_handler_->set_handling_input_event(true); 1469 input_handler_->set_handling_input_event(true);
1465 GetWebWidget()->finishComposingText(keep_selection 1470 if (GetInputMethodController()) {
dglazkov 2016/10/06 22:18:58 same here.
EhsanK 2016/11/01 15:46:04 Done.
1466 ? WebWidget::KeepSelection 1471 GetInputMethodController()->finishComposingText(
1467 : WebWidget::DoNotKeepSelection); 1472 keep_selection ? WebInputMethodController::KeepSelection
1473 : WebInputMethodController::DoNotKeepSelection);
1474 }
1468 input_handler_->set_handling_input_event(false); 1475 input_handler_->set_handling_input_event(false);
1469 UpdateCompositionInfo(false /* not an immediate request */); 1476 UpdateCompositionInfo(false /* not an immediate request */);
1470 } 1477 }
1471 1478
1472 void RenderWidget::OnDeviceScaleFactorChanged() { 1479 void RenderWidget::OnDeviceScaleFactorChanged() {
1473 if (!compositor_) 1480 if (!compositor_)
1474 return; 1481 return;
1475 if (IsUseZoomForDSFEnabled()) 1482 if (IsUseZoomForDSFEnabled())
1476 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor()); 1483 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor());
1477 else 1484 else
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 return web_screen_info; 2007 return web_screen_info;
2001 } 2008 }
2002 2009
2003 void RenderWidget::resetInputMethod() { 2010 void RenderWidget::resetInputMethod() {
2004 ImeEventGuard guard(this); 2011 ImeEventGuard guard(this);
2005 // If the last text input type is not None, then we should finish any 2012 // If the last text input type is not None, then we should finish any
2006 // ongoing composition regardless of the new text input type. 2013 // ongoing composition regardless of the new text input type.
2007 if (text_input_info_.type != blink::WebTextInputTypeNone) { 2014 if (text_input_info_.type != blink::WebTextInputTypeNone) {
2008 // If a composition text exists, then we need to let the browser process 2015 // If a composition text exists, then we need to let the browser process
2009 // to cancel the input method's ongoing composition session. 2016 // to cancel the input method's ongoing composition session.
2010 if (GetWebWidget()->finishComposingText(WebWidget::DoNotKeepSelection)) 2017 if (GetInputMethodController() &&
dglazkov 2016/10/06 22:18:58 same here.
EhsanK 2016/11/01 15:46:04 Acknowledged.
2018 GetInputMethodController()->finishComposingText(
2019 WebInputMethodController::DoNotKeepSelection))
2011 Send(new InputHostMsg_ImeCancelComposition(routing_id())); 2020 Send(new InputHostMsg_ImeCancelComposition(routing_id()));
2012 } 2021 }
2013 2022
2014 UpdateCompositionInfo(false /* not an immediate request */); 2023 UpdateCompositionInfo(false /* not an immediate request */);
2015 } 2024 }
2016 2025
2017 #if defined(OS_ANDROID) 2026 #if defined(OS_ANDROID)
2018 void RenderWidget::showUnhandledTapUIIfNeeded( 2027 void RenderWidget::showUnhandledTapUIIfNeeded(
2019 const WebPoint& tapped_position, 2028 const WebPoint& tapped_position,
2020 const WebNode& tapped_node, 2029 const WebNode& tapped_node,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 2174
2166 bool RenderWidget::isPointerLocked() { 2175 bool RenderWidget::isPointerLocked() {
2167 return mouse_lock_dispatcher_->IsMouseLockedTo( 2176 return mouse_lock_dispatcher_->IsMouseLockedTo(
2168 webwidget_mouse_lock_target_.get()); 2177 webwidget_mouse_lock_target_.get());
2169 } 2178 }
2170 2179
2171 blink::WebWidget* RenderWidget::GetWebWidget() const { 2180 blink::WebWidget* RenderWidget::GetWebWidget() const {
2172 return webwidget_internal_; 2181 return webwidget_internal_;
2173 } 2182 }
2174 2183
2184 blink::WebInputMethodController* RenderWidget::GetInputMethodController()
2185 const {
2186 // TODO(ekaramad): Will this DCHECK ever fire? Remove when GetWebWidget() is
2187 // always a WebFrameWidget.
2188 DCHECK(GetWebWidget()->isWebFrameWidget());
2189 return static_cast<blink::WebFrameWidget*>(GetWebWidget())
2190 ->getActiveWebInputMethodController();
2191 }
2192
2175 } // namespace content 2193 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/renderer/render_widget_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698