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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 OnSetEditCommandsForNextKeyEvent) | 506 OnSetEditCommandsForNextKeyEvent) |
| 507 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) | 507 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) |
| 508 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted, | 508 IPC_MESSAGE_HANDLER(InputMsg_SyntheticGestureCompleted, |
| 509 OnSyntheticGestureCompleted) | 509 OnSyntheticGestureCompleted) |
| 510 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) | 510 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
| 511 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) | 511 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) |
| 512 IPC_MESSAGE_HANDLER(ViewMsg_EnableDeviceEmulation, | 512 IPC_MESSAGE_HANDLER(ViewMsg_EnableDeviceEmulation, |
| 513 OnEnableDeviceEmulation) | 513 OnEnableDeviceEmulation) |
| 514 IPC_MESSAGE_HANDLER(ViewMsg_DisableDeviceEmulation, | 514 IPC_MESSAGE_HANDLER(ViewMsg_DisableDeviceEmulation, |
| 515 OnDisableDeviceEmulation) | 515 OnDisableDeviceEmulation) |
| 516 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) | |
|
Nico
2016/10/07 17:27:25
Nothing ever sends this after the browser-side pat
| |
| 517 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) | 516 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) |
| 518 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) | 517 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) |
| 519 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) | 518 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) |
| 520 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) | 519 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) |
| 521 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) | 520 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) |
| 522 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) | 521 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) |
| 523 IPC_MESSAGE_HANDLER(ViewMsg_SetFrameSinkId, OnSetFrameSinkId) | 522 IPC_MESSAGE_HANDLER(ViewMsg_SetFrameSinkId, OnSetFrameSinkId) |
| 524 IPC_MESSAGE_HANDLER(ViewMsg_WaitForNextFrameForTests, | 523 IPC_MESSAGE_HANDLER(ViewMsg_WaitForNextFrameForTests, |
| 525 OnWaitNextFrameForTests) | 524 OnWaitNextFrameForTests) |
| 526 IPC_MESSAGE_HANDLER(InputMsg_RequestCompositionUpdate, | 525 IPC_MESSAGE_HANDLER(InputMsg_RequestCompositionUpdate, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 557 } | 556 } |
| 558 | 557 |
| 559 void RenderWidget::SetWindowRectSynchronously( | 558 void RenderWidget::SetWindowRectSynchronously( |
| 560 const gfx::Rect& new_window_rect) { | 559 const gfx::Rect& new_window_rect) { |
| 561 ResizeParams params; | 560 ResizeParams params; |
| 562 params.screen_info = screen_info_; | 561 params.screen_info = screen_info_; |
| 563 params.new_size = new_window_rect.size(); | 562 params.new_size = new_window_rect.size(); |
| 564 params.physical_backing_size = | 563 params.physical_backing_size = |
| 565 gfx::ScaleToCeiledSize(new_window_rect.size(), device_scale_factor_); | 564 gfx::ScaleToCeiledSize(new_window_rect.size(), device_scale_factor_); |
| 566 params.visible_viewport_size = new_window_rect.size(); | 565 params.visible_viewport_size = new_window_rect.size(); |
| 567 params.resizer_rect = gfx::Rect(); | |
| 568 params.is_fullscreen_granted = is_fullscreen_granted_; | 566 params.is_fullscreen_granted = is_fullscreen_granted_; |
| 569 params.display_mode = display_mode_; | 567 params.display_mode = display_mode_; |
| 570 params.needs_resize_ack = false; | 568 params.needs_resize_ack = false; |
| 571 Resize(params); | 569 Resize(params); |
| 572 | 570 |
| 573 view_screen_rect_ = new_window_rect; | 571 view_screen_rect_ = new_window_rect; |
| 574 window_screen_rect_ = new_window_rect; | 572 window_screen_rect_ = new_window_rect; |
| 575 if (!did_show_) | 573 if (!did_show_) |
| 576 initial_rect_ = new_window_rect; | 574 initial_rect_ = new_window_rect; |
| 577 } | 575 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 623 } | 621 } |
| 624 | 622 |
| 625 void RenderWidget::OnEnableDeviceEmulation( | 623 void RenderWidget::OnEnableDeviceEmulation( |
| 626 const blink::WebDeviceEmulationParams& params) { | 624 const blink::WebDeviceEmulationParams& params) { |
| 627 if (!screen_metrics_emulator_) { | 625 if (!screen_metrics_emulator_) { |
| 628 ResizeParams resize_params; | 626 ResizeParams resize_params; |
| 629 resize_params.screen_info = screen_info_; | 627 resize_params.screen_info = screen_info_; |
| 630 resize_params.new_size = size_; | 628 resize_params.new_size = size_; |
| 631 resize_params.physical_backing_size = physical_backing_size_; | 629 resize_params.physical_backing_size = physical_backing_size_; |
| 632 resize_params.visible_viewport_size = visible_viewport_size_; | 630 resize_params.visible_viewport_size = visible_viewport_size_; |
| 633 resize_params.resizer_rect = resizer_rect_; | |
| 634 resize_params.is_fullscreen_granted = is_fullscreen_granted_; | 631 resize_params.is_fullscreen_granted = is_fullscreen_granted_; |
| 635 resize_params.display_mode = display_mode_; | 632 resize_params.display_mode = display_mode_; |
| 636 screen_metrics_emulator_.reset(new RenderWidgetScreenMetricsEmulator( | 633 screen_metrics_emulator_.reset(new RenderWidgetScreenMetricsEmulator( |
| 637 this, params, resize_params, view_screen_rect_, window_screen_rect_)); | 634 this, params, resize_params, view_screen_rect_, window_screen_rect_)); |
| 638 screen_metrics_emulator_->Apply(); | 635 screen_metrics_emulator_->Apply(); |
| 639 } else { | 636 } else { |
| 640 screen_metrics_emulator_->ChangeEmulationParams(params); | 637 screen_metrics_emulator_->ChangeEmulationParams(params); |
| 641 } | 638 } |
| 642 } | 639 } |
| 643 | 640 |
| 644 void RenderWidget::OnDisableDeviceEmulation() { | 641 void RenderWidget::OnDisableDeviceEmulation() { |
| 645 screen_metrics_emulator_.reset(); | 642 screen_metrics_emulator_.reset(); |
| 646 } | 643 } |
| 647 | 644 |
| 648 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { | |
| 649 if (resizer_rect_ == resizer_rect) | |
| 650 return; | |
| 651 resizer_rect_ = resizer_rect; | |
| 652 if (GetWebWidget()) | |
| 653 GetWebWidget()->didChangeWindowResizerRect(); | |
| 654 } | |
| 655 | |
| 656 void RenderWidget::OnWasHidden() { | 645 void RenderWidget::OnWasHidden() { |
| 657 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden"); | 646 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden"); |
| 658 // Go into a mode where we stop generating paint and scrolling events. | 647 // Go into a mode where we stop generating paint and scrolling events. |
| 659 SetHidden(true); | 648 SetHidden(true); |
| 660 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, | 649 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, |
| 661 WasHidden()); | 650 WasHidden()); |
| 662 } | 651 } |
| 663 | 652 |
| 664 void RenderWidget::OnWasShown(bool needs_repainting, | 653 void RenderWidget::OnWasShown(bool needs_repainting, |
| 665 const ui::LatencyInfo& latency_info) { | 654 const ui::LatencyInfo& latency_info) { |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1064 if (!GetWebWidget()) | 1053 if (!GetWebWidget()) |
| 1065 return; | 1054 return; |
| 1066 | 1055 |
| 1067 if (compositor_) { | 1056 if (compositor_) { |
| 1068 compositor_->setViewportSize(params.physical_backing_size); | 1057 compositor_->setViewportSize(params.physical_backing_size); |
| 1069 compositor_->setBottomControlsHeight(params.bottom_controls_height); | 1058 compositor_->setBottomControlsHeight(params.bottom_controls_height); |
| 1070 compositor_->SetDeviceColorSpace(screen_info_.icc_profile.GetColorSpace()); | 1059 compositor_->SetDeviceColorSpace(screen_info_.icc_profile.GetColorSpace()); |
| 1071 } | 1060 } |
| 1072 | 1061 |
| 1073 visible_viewport_size_ = params.visible_viewport_size; | 1062 visible_viewport_size_ = params.visible_viewport_size; |
| 1074 resizer_rect_ = params.resizer_rect; | |
| 1075 | 1063 |
| 1076 // NOTE: We may have entered fullscreen mode without changing our size. | 1064 // NOTE: We may have entered fullscreen mode without changing our size. |
| 1077 bool fullscreen_change = | 1065 bool fullscreen_change = |
| 1078 is_fullscreen_granted_ != params.is_fullscreen_granted; | 1066 is_fullscreen_granted_ != params.is_fullscreen_granted; |
| 1079 is_fullscreen_granted_ = params.is_fullscreen_granted; | 1067 is_fullscreen_granted_ = params.is_fullscreen_granted; |
| 1080 display_mode_ = params.display_mode; | 1068 display_mode_ = params.display_mode; |
| 1081 | 1069 |
| 1082 size_ = params.new_size; | 1070 size_ = params.new_size; |
| 1083 physical_backing_size_ = params.physical_backing_size; | 1071 physical_backing_size_ = params.physical_backing_size; |
| 1084 | 1072 |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1411 pending_window_rect_count_++; | 1399 pending_window_rect_count_++; |
| 1412 | 1400 |
| 1413 // Popups don't get size updates back from the browser so just store the set | 1401 // Popups don't get size updates back from the browser so just store the set |
| 1414 // values. | 1402 // values. |
| 1415 if (popup_type_ != blink::WebPopupTypeNone) { | 1403 if (popup_type_ != blink::WebPopupTypeNone) { |
| 1416 window_screen_rect_ = rect; | 1404 window_screen_rect_ = rect; |
| 1417 view_screen_rect_ = rect; | 1405 view_screen_rect_ = rect; |
| 1418 } | 1406 } |
| 1419 } | 1407 } |
| 1420 | 1408 |
| 1421 WebRect RenderWidget::windowResizerRect() { | |
| 1422 return resizer_rect_; | |
| 1423 } | |
| 1424 | |
| 1425 void RenderWidget::OnImeSetComposition( | 1409 void RenderWidget::OnImeSetComposition( |
| 1426 const base::string16& text, | 1410 const base::string16& text, |
| 1427 const std::vector<WebCompositionUnderline>& underlines, | 1411 const std::vector<WebCompositionUnderline>& underlines, |
| 1428 const gfx::Range& replacement_range, | 1412 const gfx::Range& replacement_range, |
| 1429 int selection_start, int selection_end) { | 1413 int selection_start, int selection_end) { |
| 1430 #if defined(ENABLE_PLUGINS) | 1414 #if defined(ENABLE_PLUGINS) |
| 1431 if (focused_pepper_plugin_) { | 1415 if (focused_pepper_plugin_) { |
| 1432 focused_pepper_plugin_->render_frame()->OnImeSetComposition( | 1416 focused_pepper_plugin_->render_frame()->OnImeSetComposition( |
| 1433 text, underlines, selection_start, selection_end); | 1417 text, underlines, selection_start, selection_end); |
| 1434 return; | 1418 return; |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2193 bool RenderWidget::isPointerLocked() { | 2177 bool RenderWidget::isPointerLocked() { |
| 2194 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2178 return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 2195 webwidget_mouse_lock_target_.get()); | 2179 webwidget_mouse_lock_target_.get()); |
| 2196 } | 2180 } |
| 2197 | 2181 |
| 2198 blink::WebWidget* RenderWidget::GetWebWidget() const { | 2182 blink::WebWidget* RenderWidget::GetWebWidget() const { |
| 2199 return webwidget_internal_; | 2183 return webwidget_internal_; |
| 2200 } | 2184 } |
| 2201 | 2185 |
| 2202 } // namespace content | 2186 } // namespace content |
| OLD | NEW |