| 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 mouse_lock_dispatcher_->OnMessageReceived(message)) | 478 mouse_lock_dispatcher_->OnMessageReceived(message)) |
| 479 return true; | 479 return true; |
| 480 | 480 |
| 481 bool handled = true; | 481 bool handled = true; |
| 482 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) | 482 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) |
| 483 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) | 483 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) |
| 484 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, | 484 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, |
| 485 OnCursorVisibilityChange) | 485 OnCursorVisibilityChange) |
| 486 IPC_MESSAGE_HANDLER(InputMsg_ImeSetComposition, OnImeSetComposition) | 486 IPC_MESSAGE_HANDLER(InputMsg_ImeSetComposition, OnImeSetComposition) |
| 487 IPC_MESSAGE_HANDLER(InputMsg_ImeConfirmComposition, OnImeConfirmComposition) | 487 IPC_MESSAGE_HANDLER(InputMsg_ImeConfirmComposition, OnImeConfirmComposition) |
| 488 IPC_MESSAGE_HANDLER(InputMsg_ImeExtendSelectionAndDelete, |
| 489 OnImeExtendSelectionAndDelete) |
| 490 IPC_MESSAGE_HANDLER(InputMsg_ImeSetCompositionFromExistingText, |
| 491 OnImeSetCompositionFromExistingText) |
| 492 IPC_MESSAGE_HANDLER(InputMsg_ImeSetEditableSelectionOffsets, |
| 493 OnImeSetEditableSelectionOffsets) |
| 494 IPC_MESSAGE_HANDLER(InputMsg_ImeBatchEdit, OnImeBatchEdit) |
| 495 IPC_MESSAGE_HANDLER(InputMsg_ImeRequestCompositionUpdate, |
| 496 OnImeRequestCompositionUpdate) |
| 488 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) | 497 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) |
| 489 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) | 498 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) |
| 490 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted, | 499 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted, |
| 491 OnSyntheticGestureCompleted) | 500 OnSyntheticGestureCompleted) |
| 492 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) | 501 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
| 493 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) | 502 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) |
| 494 IPC_MESSAGE_HANDLER(ViewMsg_EnableDeviceEmulation, | 503 IPC_MESSAGE_HANDLER(ViewMsg_EnableDeviceEmulation, |
| 495 OnEnableDeviceEmulation) | 504 OnEnableDeviceEmulation) |
| 496 IPC_MESSAGE_HANDLER(ViewMsg_DisableDeviceEmulation, | 505 IPC_MESSAGE_HANDLER(ViewMsg_DisableDeviceEmulation, |
| 497 OnDisableDeviceEmulation) | 506 OnDisableDeviceEmulation) |
| 498 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) | 507 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) |
| 499 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) | 508 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) |
| 500 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) | 509 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) |
| 501 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) | 510 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) |
| 502 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) | 511 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) |
| 503 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) | 512 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) |
| 504 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) | 513 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) |
| 505 IPC_MESSAGE_HANDLER(ViewMsg_SetSurfaceClientId, OnSetSurfaceClientId) | 514 IPC_MESSAGE_HANDLER(ViewMsg_SetSurfaceClientId, OnSetSurfaceClientId) |
| 506 IPC_MESSAGE_HANDLER(ViewMsg_WaitForNextFrameForTests, | 515 IPC_MESSAGE_HANDLER(ViewMsg_WaitForNextFrameForTests, |
| 507 OnWaitNextFrameForTests) | 516 OnWaitNextFrameForTests) |
| 508 IPC_MESSAGE_HANDLER(InputMsg_RequestCompositionUpdate, | |
| 509 OnRequestCompositionUpdate) | |
| 510 #if defined(OS_ANDROID) | 517 #if defined(OS_ANDROID) |
| 511 IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck) | 518 IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck) |
| 512 IPC_MESSAGE_HANDLER(InputMsg_RequestTextInputStateUpdate, | 519 IPC_MESSAGE_HANDLER(InputMsg_ImeRequestTextInputStateUpdate, |
| 513 OnRequestTextInputStateUpdate) | 520 OnImeRequestTextInputStateUpdate) |
| 514 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) | 521 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) |
| 515 #endif | 522 #endif |
| 516 IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto) | 523 IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto) |
| 517 IPC_MESSAGE_UNHANDLED(handled = false) | 524 IPC_MESSAGE_UNHANDLED(handled = false) |
| 518 IPC_END_MESSAGE_MAP() | 525 IPC_END_MESSAGE_MAP() |
| 519 return handled; | 526 return handled; |
| 520 } | 527 } |
| 521 | 528 |
| 522 bool RenderWidget::Send(IPC::Message* message) { | 529 bool RenderWidget::Send(IPC::Message* message) { |
| 523 // Don't send any messages after the browser has told us to close, and filter | 530 // Don't send any messages after the browser has told us to close, and filter |
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 if (text.length()) | 1426 if (text.length()) |
| 1420 webwidget_->confirmComposition(text); | 1427 webwidget_->confirmComposition(text); |
| 1421 else if (keep_selection) | 1428 else if (keep_selection) |
| 1422 webwidget_->confirmComposition(WebWidget::KeepSelection); | 1429 webwidget_->confirmComposition(WebWidget::KeepSelection); |
| 1423 else | 1430 else |
| 1424 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection); | 1431 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection); |
| 1425 input_handler_->set_handling_input_event(false); | 1432 input_handler_->set_handling_input_event(false); |
| 1426 UpdateCompositionInfo(false /* not an immediate request */); | 1433 UpdateCompositionInfo(false /* not an immediate request */); |
| 1427 } | 1434 } |
| 1428 | 1435 |
| 1436 void RenderWidget::OnImeExtendSelectionAndDelete(int before, int after) { |
| 1437 if (!ShouldHandleImeEvent()) |
| 1438 return; |
| 1439 |
| 1440 ImeEventGuard guard(this); |
| 1441 webwidget_->extendSelectionAndDelete(before, after); |
| 1442 } |
| 1443 |
| 1444 void RenderWidget::OnImeSetEditableSelectionOffsets(int start, int end) { |
| 1445 if (!ShouldHandleImeEvent()) |
| 1446 return; |
| 1447 ImeEventGuard guard(this); |
| 1448 webwidget_->setEditableSelectionOffsets(start, end); |
| 1449 } |
| 1450 |
| 1451 void RenderWidget::OnImeSetCompositionFromExistingText( |
| 1452 int start, int end, |
| 1453 const std::vector<blink::WebCompositionUnderline>& underlines) { |
| 1454 if (!ShouldHandleImeEvent()) |
| 1455 return; |
| 1456 ImeEventGuard guard(this); |
| 1457 webwidget_->setCompositionFromExistingText(start, end, underlines); |
| 1458 } |
| 1459 |
| 1460 void RenderWidget::OnImeBatchEdit(const std::vector<IPC::Message>& messages) { |
| 1461 ImeEventGuard guard(this); |
| 1462 for (auto message : messages) |
| 1463 OnMessageReceived(message); |
| 1464 } |
| 1465 |
| 1429 void RenderWidget::OnDeviceScaleFactorChanged() { | 1466 void RenderWidget::OnDeviceScaleFactorChanged() { |
| 1430 if (!compositor_) | 1467 if (!compositor_) |
| 1431 return; | 1468 return; |
| 1432 if (IsUseZoomForDSFEnabled()) | 1469 if (IsUseZoomForDSFEnabled()) |
| 1433 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor()); | 1470 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor()); |
| 1434 else | 1471 else |
| 1435 compositor_->setDeviceScaleFactor(device_scale_factor_); | 1472 compositor_->setDeviceScaleFactor(device_scale_factor_); |
| 1436 } | 1473 } |
| 1437 | 1474 |
| 1438 void RenderWidget::OnRepaint(gfx::Size size_to_paint) { | 1475 void RenderWidget::OnRepaint(gfx::Size size_to_paint) { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 #if defined(OS_ANDROID) | 1609 #if defined(OS_ANDROID) |
| 1573 void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) { | 1610 void RenderWidget::OnImeEventSentForAck(const blink::WebTextInputInfo& info) { |
| 1574 text_input_info_history_.push_back(info); | 1611 text_input_info_history_.push_back(info); |
| 1575 } | 1612 } |
| 1576 | 1613 |
| 1577 void RenderWidget::OnImeEventAck() { | 1614 void RenderWidget::OnImeEventAck() { |
| 1578 DCHECK_GE(text_input_info_history_.size(), 1u); | 1615 DCHECK_GE(text_input_info_history_.size(), 1u); |
| 1579 text_input_info_history_.pop_front(); | 1616 text_input_info_history_.pop_front(); |
| 1580 } | 1617 } |
| 1581 | 1618 |
| 1582 void RenderWidget::OnRequestTextInputStateUpdate() { | 1619 void RenderWidget::OnImeRequestTextInputStateUpdate() { |
| 1583 DCHECK(!ime_event_guard_); | |
| 1584 UpdateSelectionBounds(); | 1620 UpdateSelectionBounds(); |
| 1585 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME); | 1621 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME); |
| 1586 } | 1622 } |
| 1587 #endif | 1623 #endif |
| 1588 | 1624 |
| 1589 void RenderWidget::OnRequestCompositionUpdate(bool immediate_request, | 1625 void RenderWidget::OnImeRequestCompositionUpdate(bool immediate_request, |
| 1590 bool monitor_request) { | 1626 bool monitor_request) { |
| 1591 monitor_composition_info_ = monitor_request; | 1627 monitor_composition_info_ = monitor_request; |
| 1592 if (!immediate_request) | 1628 if (!immediate_request) |
| 1593 return; | 1629 return; |
| 1594 UpdateCompositionInfo(true /* immediate request */); | 1630 UpdateCompositionInfo(true /* immediate request */); |
| 1595 } | 1631 } |
| 1596 | 1632 |
| 1597 bool RenderWidget::ShouldHandleImeEvent() { | 1633 bool RenderWidget::ShouldHandleImeEvent() { |
| 1598 #if defined(OS_ANDROID) | 1634 #if defined(OS_ANDROID) |
| 1599 if (!webwidget_) | 1635 if (!webwidget_) |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2115 void RenderWidget::requestPointerUnlock() { | 2151 void RenderWidget::requestPointerUnlock() { |
| 2116 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); | 2152 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); |
| 2117 } | 2153 } |
| 2118 | 2154 |
| 2119 bool RenderWidget::isPointerLocked() { | 2155 bool RenderWidget::isPointerLocked() { |
| 2120 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2156 return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 2121 webwidget_mouse_lock_target_.get()); | 2157 webwidget_mouse_lock_target_.get()); |
| 2122 } | 2158 } |
| 2123 | 2159 |
| 2124 } // namespace content | 2160 } // namespace content |
| OLD | NEW |