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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 if (mouse_lock_dispatcher_ && | 478 if (mouse_lock_dispatcher_ && |
479 mouse_lock_dispatcher_->OnMessageReceived(message)) | 479 mouse_lock_dispatcher_->OnMessageReceived(message)) |
480 return true; | 480 return true; |
481 | 481 |
482 bool handled = true; | 482 bool handled = true; |
483 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) | 483 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) |
484 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) | 484 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) |
485 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, | 485 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, |
486 OnCursorVisibilityChange) | 486 OnCursorVisibilityChange) |
487 IPC_MESSAGE_HANDLER(InputMsg_ImeSetComposition, OnImeSetComposition) | 487 IPC_MESSAGE_HANDLER(InputMsg_ImeSetComposition, OnImeSetComposition) |
488 IPC_MESSAGE_HANDLER(InputMsg_ImeConfirmComposition, OnImeConfirmComposition) | 488 IPC_MESSAGE_HANDLER(InputMsg_ImeCommitText, OnImeCommitText) |
| 489 IPC_MESSAGE_HANDLER(InputMsg_ImeFinishComposingText, |
| 490 OnImeFinishComposingText) |
489 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) | 491 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) |
490 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, | 492 IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, |
491 OnSetEditCommandsForNextKeyEvent) | 493 OnSetEditCommandsForNextKeyEvent) |
492 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) | 494 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) |
493 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted, | 495 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted, |
494 OnSyntheticGestureCompleted) | 496 OnSyntheticGestureCompleted) |
495 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) | 497 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
496 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) | 498 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) |
497 IPC_MESSAGE_HANDLER(ViewMsg_EnableDeviceEmulation, | 499 IPC_MESSAGE_HANDLER(ViewMsg_EnableDeviceEmulation, |
498 OnEnableDeviceEmulation) | 500 OnEnableDeviceEmulation) |
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 text, WebVector<WebCompositionUnderline>(underlines), selection_start, | 1404 text, WebVector<WebCompositionUnderline>(underlines), selection_start, |
1403 selection_end)) { | 1405 selection_end)) { |
1404 // If we failed to set the composition text, then we need to let the browser | 1406 // If we failed to set the composition text, then we need to let the browser |
1405 // process to cancel the input method's ongoing composition session, to make | 1407 // process to cancel the input method's ongoing composition session, to make |
1406 // sure we are in a consistent state. | 1408 // sure we are in a consistent state. |
1407 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 1409 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
1408 } | 1410 } |
1409 UpdateCompositionInfo(false /* not an immediate request */); | 1411 UpdateCompositionInfo(false /* not an immediate request */); |
1410 } | 1412 } |
1411 | 1413 |
1412 void RenderWidget::OnImeConfirmComposition(const base::string16& text, | 1414 void RenderWidget::OnImeCommitText(const base::string16& text, |
1413 const gfx::Range& replacement_range, | 1415 const gfx::Range& replacement_range, |
1414 bool keep_selection) { | 1416 int relative_cursor_pos) { |
1415 #if defined(ENABLE_PLUGINS) | 1417 #if defined(ENABLE_PLUGINS) |
1416 if (focused_pepper_plugin_) { | 1418 if (focused_pepper_plugin_) { |
1417 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition( | 1419 focused_pepper_plugin_->render_frame()->OnImeCommitText( |
1418 text, replacement_range, keep_selection); | 1420 text, replacement_range, relative_cursor_pos); |
1419 return; | 1421 return; |
1420 } | 1422 } |
1421 #endif | 1423 #endif |
1422 if (replacement_range.IsValid()) { | 1424 if (replacement_range.IsValid()) { |
1423 GetWebWidget()->applyReplacementRange( | 1425 GetWebWidget()->applyReplacementRange( |
1424 WebRange(replacement_range.start(), replacement_range.length())); | 1426 WebRange(replacement_range.start(), replacement_range.length())); |
1425 } | 1427 } |
1426 | 1428 |
1427 if (!ShouldHandleImeEvent()) | 1429 if (!ShouldHandleImeEvent()) |
1428 return; | 1430 return; |
1429 ImeEventGuard guard(this); | 1431 ImeEventGuard guard(this); |
1430 input_handler_->set_handling_input_event(true); | 1432 input_handler_->set_handling_input_event(true); |
1431 if (text.length()) | 1433 GetWebWidget()->commitText(text, relative_cursor_pos); |
1432 GetWebWidget()->confirmComposition(text); | |
1433 else if (keep_selection) | |
1434 GetWebWidget()->confirmComposition(WebWidget::KeepSelection); | |
1435 else | |
1436 GetWebWidget()->confirmComposition(WebWidget::DoNotKeepSelection); | |
1437 input_handler_->set_handling_input_event(false); | 1434 input_handler_->set_handling_input_event(false); |
1438 UpdateCompositionInfo(false /* not an immediate request */); | 1435 UpdateCompositionInfo(false /* not an immediate request */); |
1439 } | 1436 } |
| 1437 |
| 1438 void RenderWidget::OnImeFinishComposingText(bool keep_selection) { |
| 1439 #if defined(ENABLE_PLUGINS) |
| 1440 if (focused_pepper_plugin_) { |
| 1441 focused_pepper_plugin_->render_frame()->OnImeFinishComposingText( |
| 1442 keep_selection); |
| 1443 return; |
| 1444 } |
| 1445 #endif |
| 1446 |
| 1447 if (!ShouldHandleImeEvent()) |
| 1448 return; |
| 1449 ImeEventGuard guard(this); |
| 1450 input_handler_->set_handling_input_event(true); |
| 1451 GetWebWidget()->finishComposingText(keep_selection |
| 1452 ? WebWidget::KeepSelection |
| 1453 : WebWidget::DoNotKeepSelection); |
| 1454 input_handler_->set_handling_input_event(false); |
| 1455 UpdateCompositionInfo(false /* not an immediate request */); |
| 1456 } |
1440 | 1457 |
1441 void RenderWidget::OnDeviceScaleFactorChanged() { | 1458 void RenderWidget::OnDeviceScaleFactorChanged() { |
1442 if (!compositor_) | 1459 if (!compositor_) |
1443 return; | 1460 return; |
1444 if (IsUseZoomForDSFEnabled()) | 1461 if (IsUseZoomForDSFEnabled()) |
1445 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor()); | 1462 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor()); |
1446 else | 1463 else |
1447 compositor_->setDeviceScaleFactor(device_scale_factor_); | 1464 compositor_->setDeviceScaleFactor(device_scale_factor_); |
1448 } | 1465 } |
1449 | 1466 |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1956 return web_screen_info; | 1973 return web_screen_info; |
1957 } | 1974 } |
1958 | 1975 |
1959 void RenderWidget::resetInputMethod() { | 1976 void RenderWidget::resetInputMethod() { |
1960 ImeEventGuard guard(this); | 1977 ImeEventGuard guard(this); |
1961 // If the last text input type is not None, then we should finish any | 1978 // If the last text input type is not None, then we should finish any |
1962 // ongoing composition regardless of the new text input type. | 1979 // ongoing composition regardless of the new text input type. |
1963 if (text_input_info_.type != blink::WebTextInputTypeNone) { | 1980 if (text_input_info_.type != blink::WebTextInputTypeNone) { |
1964 // If a composition text exists, then we need to let the browser process | 1981 // If a composition text exists, then we need to let the browser process |
1965 // to cancel the input method's ongoing composition session. | 1982 // to cancel the input method's ongoing composition session. |
1966 if (GetWebWidget()->confirmComposition()) | 1983 if (GetWebWidget()->finishComposingText(WebWidget::DoNotKeepSelection)) |
1967 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 1984 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
1968 } | 1985 } |
1969 | 1986 |
1970 UpdateCompositionInfo(false /* not an immediate request */); | 1987 UpdateCompositionInfo(false /* not an immediate request */); |
1971 } | 1988 } |
1972 | 1989 |
1973 #if defined(OS_ANDROID) | 1990 #if defined(OS_ANDROID) |
1974 void RenderWidget::showUnhandledTapUIIfNeeded( | 1991 void RenderWidget::showUnhandledTapUIIfNeeded( |
1975 const WebPoint& tapped_position, | 1992 const WebPoint& tapped_position, |
1976 const WebNode& tapped_node, | 1993 const WebNode& tapped_node, |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2132 bool RenderWidget::isPointerLocked() { | 2149 bool RenderWidget::isPointerLocked() { |
2133 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2150 return mouse_lock_dispatcher_->IsMouseLockedTo( |
2134 webwidget_mouse_lock_target_.get()); | 2151 webwidget_mouse_lock_target_.get()); |
2135 } | 2152 } |
2136 | 2153 |
2137 blink::WebWidget* RenderWidget::GetWebWidget() const { | 2154 blink::WebWidget* RenderWidget::GetWebWidget() const { |
2138 return webwidget_internal_; | 2155 return webwidget_internal_; |
2139 } | 2156 } |
2140 | 2157 |
2141 } // namespace content | 2158 } // namespace content |
OLD | NEW |