Chromium Code Reviews| 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 if (mouse_lock_dispatcher_ && | 479 if (mouse_lock_dispatcher_ && |
| 480 mouse_lock_dispatcher_->OnMessageReceived(message)) | 480 mouse_lock_dispatcher_->OnMessageReceived(message)) |
| 481 return true; | 481 return true; |
| 482 | 482 |
| 483 bool handled = true; | 483 bool handled = true; |
| 484 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) | 484 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) |
| 485 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) | 485 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) |
| 486 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, | 486 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, |
| 487 OnCursorVisibilityChange) | 487 OnCursorVisibilityChange) |
| 488 IPC_MESSAGE_HANDLER(InputMsg_ImeSetComposition, OnImeSetComposition) | 488 IPC_MESSAGE_HANDLER(InputMsg_ImeSetComposition, OnImeSetComposition) |
| 489 IPC_MESSAGE_HANDLER(InputMsg_ImeConfirmComposition, OnImeConfirmComposition) | 489 IPC_MESSAGE_HANDLER(InputMsg_ImeCommitText, OnImeCommitText) |
| 490 IPC_MESSAGE_HANDLER(InputMsg_ImeFinishComposingText, | |
| 491 OnImeFinishComposingText) | |
| 490 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) | 492 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) |
| 491 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) | 493 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) |
| 492 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted, | 494 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted, |
| 493 OnSyntheticGestureCompleted) | 495 OnSyntheticGestureCompleted) |
| 494 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) | 496 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
| 495 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) | 497 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) |
| 496 IPC_MESSAGE_HANDLER(ViewMsg_EnableDeviceEmulation, | 498 IPC_MESSAGE_HANDLER(ViewMsg_EnableDeviceEmulation, |
| 497 OnEnableDeviceEmulation) | 499 OnEnableDeviceEmulation) |
| 498 IPC_MESSAGE_HANDLER(ViewMsg_DisableDeviceEmulation, | 500 IPC_MESSAGE_HANDLER(ViewMsg_DisableDeviceEmulation, |
| 499 OnDisableDeviceEmulation) | 501 OnDisableDeviceEmulation) |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1392 text, WebVector<WebCompositionUnderline>(underlines), | 1394 text, WebVector<WebCompositionUnderline>(underlines), |
| 1393 selection_start, selection_end)) { | 1395 selection_start, selection_end)) { |
| 1394 // If we failed to set the composition text, then we need to let the browser | 1396 // If we failed to set the composition text, then we need to let the browser |
| 1395 // process to cancel the input method's ongoing composition session, to make | 1397 // process to cancel the input method's ongoing composition session, to make |
| 1396 // sure we are in a consistent state. | 1398 // sure we are in a consistent state. |
| 1397 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 1399 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
| 1398 } | 1400 } |
| 1399 UpdateCompositionInfo(false /* not an immediate request */); | 1401 UpdateCompositionInfo(false /* not an immediate request */); |
| 1400 } | 1402 } |
| 1401 | 1403 |
| 1402 void RenderWidget::OnImeConfirmComposition(const base::string16& text, | 1404 void RenderWidget::OnImeCommitText(const base::string16& text, |
| 1403 const gfx::Range& replacement_range, | 1405 const gfx::Range& replacement_range, |
| 1404 bool keep_selection) { | 1406 int relative_cursor_pos) { |
| 1405 #if defined(ENABLE_PLUGINS) | 1407 #if defined(ENABLE_PLUGINS) |
| 1406 if (focused_pepper_plugin_) { | 1408 if (focused_pepper_plugin_) { |
| 1407 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition( | 1409 focused_pepper_plugin_->render_frame()->OnImeCommitText( |
| 1408 text, replacement_range, keep_selection); | 1410 text, replacement_range, relative_cursor_pos); |
| 1409 return; | 1411 return; |
| 1410 } | 1412 } |
| 1411 #endif | 1413 #endif |
| 1412 if (replacement_range.IsValid()) { | 1414 if (replacement_range.IsValid()) { |
| 1413 webwidget_->applyReplacementRange( | 1415 webwidget_->applyReplacementRange( |
| 1414 WebRange(replacement_range.start(), replacement_range.length())); | 1416 WebRange(replacement_range.start(), replacement_range.length())); |
| 1415 } | 1417 } |
| 1416 | 1418 |
| 1417 if (!ShouldHandleImeEvent()) | 1419 if (!ShouldHandleImeEvent()) |
| 1418 return; | 1420 return; |
| 1419 ImeEventGuard guard(this); | 1421 ImeEventGuard guard(this); |
| 1420 input_handler_->set_handling_input_event(true); | 1422 input_handler_->set_handling_input_event(true); |
| 1421 if (text.length()) | 1423 webwidget_->commitText(text, relative_cursor_pos); |
| 1422 webwidget_->confirmComposition(text); | |
| 1423 else if (keep_selection) | |
| 1424 webwidget_->confirmComposition(WebWidget::KeepSelection); | |
| 1425 else | |
| 1426 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection); | |
| 1427 input_handler_->set_handling_input_event(false); | 1424 input_handler_->set_handling_input_event(false); |
| 1428 UpdateCompositionInfo(false /* not an immediate request */); | 1425 UpdateCompositionInfo(false /* not an immediate request */); |
| 1429 } | 1426 } |
| 1427 | |
| 1428 void RenderWidget::OnImeFinishComposingText(bool keep_selection) { | |
| 1429 #if defined(ENABLE_PLUGINS) | |
| 1430 if (focused_pepper_plugin_) { | |
| 1431 focused_pepper_plugin_->render_frame()->OnImeFinishComposingText( | |
| 1432 keep_selection); | |
| 1433 return; | |
| 1434 } | |
| 1435 #endif | |
| 1436 | |
| 1437 if (!ShouldHandleImeEvent()) | |
| 1438 return; | |
| 1439 ImeEventGuard guard(this); | |
| 1440 input_handler_->set_handling_input_event(true); | |
| 1441 webwidget_->finishComposingText(keep_selection | |
| 1442 ? WebWidget::KeepSelection | |
| 1443 : WebWidget::DoNotKeepSelection); | |
| 1444 input_handler_->set_handling_input_event(false); | |
| 1445 UpdateCompositionInfo(false /* not an immediate request */); | |
| 1446 } | |
| 1430 | 1447 |
| 1431 void RenderWidget::OnDeviceScaleFactorChanged() { | 1448 void RenderWidget::OnDeviceScaleFactorChanged() { |
| 1432 if (!compositor_) | 1449 if (!compositor_) |
| 1433 return; | 1450 return; |
| 1434 if (IsUseZoomForDSFEnabled()) | 1451 if (IsUseZoomForDSFEnabled()) |
| 1435 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor()); | 1452 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor()); |
| 1436 else | 1453 else |
| 1437 compositor_->setDeviceScaleFactor(device_scale_factor_); | 1454 compositor_->setDeviceScaleFactor(device_scale_factor_); |
| 1438 } | 1455 } |
| 1439 | 1456 |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1915 return screen_info_; | 1932 return screen_info_; |
| 1916 } | 1933 } |
| 1917 | 1934 |
| 1918 void RenderWidget::resetInputMethod() { | 1935 void RenderWidget::resetInputMethod() { |
| 1919 ImeEventGuard guard(this); | 1936 ImeEventGuard guard(this); |
| 1920 // If the last text input type is not None, then we should finish any | 1937 // If the last text input type is not None, then we should finish any |
| 1921 // ongoing composition regardless of the new text input type. | 1938 // ongoing composition regardless of the new text input type. |
| 1922 if (text_input_info_.type != blink::WebTextInputTypeNone) { | 1939 if (text_input_info_.type != blink::WebTextInputTypeNone) { |
| 1923 // If a composition text exists, then we need to let the browser process | 1940 // If a composition text exists, then we need to let the browser process |
| 1924 // to cancel the input method's ongoing composition session. | 1941 // to cancel the input method's ongoing composition session. |
| 1925 if (webwidget_->confirmComposition()) | 1942 if (webwidget_->finishComposingText(WebWidget::KeepSelection)) |
|
aelias_OOO_until_Jul13
2016/09/07 05:02:40
Please use DoNotKeepSelection to avoid unnecessary
yabinh
2016/09/07 10:27:14
Done.
| |
| 1926 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 1943 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
| 1927 } | 1944 } |
| 1928 | 1945 |
| 1929 UpdateCompositionInfo(false /* not an immediate request */); | 1946 UpdateCompositionInfo(false /* not an immediate request */); |
| 1930 } | 1947 } |
| 1931 | 1948 |
| 1932 #if defined(OS_ANDROID) | 1949 #if defined(OS_ANDROID) |
| 1933 void RenderWidget::showUnhandledTapUIIfNeeded( | 1950 void RenderWidget::showUnhandledTapUIIfNeeded( |
| 1934 const WebPoint& tapped_position, | 1951 const WebPoint& tapped_position, |
| 1935 const WebNode& tapped_node, | 1952 const WebNode& tapped_node, |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2087 void RenderWidget::requestPointerUnlock() { | 2104 void RenderWidget::requestPointerUnlock() { |
| 2088 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); | 2105 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); |
| 2089 } | 2106 } |
| 2090 | 2107 |
| 2091 bool RenderWidget::isPointerLocked() { | 2108 bool RenderWidget::isPointerLocked() { |
| 2092 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2109 return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 2093 webwidget_mouse_lock_target_.get()); | 2110 webwidget_mouse_lock_target_.get()); |
| 2094 } | 2111 } |
| 2095 | 2112 |
| 2096 } // namespace content | 2113 } // namespace content |
| OLD | NEW |