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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 1410313006: Separate RenderViewHost from RenderWidgetHost, part 5: move calls to the RenderWidgetHostDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 1 month 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
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/browser/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 // deal as RenderWidget::WasShown delays updating, so that the resize from 558 // deal as RenderWidget::WasShown delays updating, so that the resize from
559 // WasResized is usually processed before the renderer is painted. 559 // WasResized is usually processed before the renderer is painted.
560 WasResized(); 560 WasResized();
561 } 561 }
562 562
563 bool RenderWidgetHostImpl::GetResizeParams( 563 bool RenderWidgetHostImpl::GetResizeParams(
564 ViewMsg_Resize_Params* resize_params) { 564 ViewMsg_Resize_Params* resize_params) {
565 *resize_params = ViewMsg_Resize_Params(); 565 *resize_params = ViewMsg_Resize_Params();
566 566
567 GetWebScreenInfo(&resize_params->screen_info); 567 GetWebScreenInfo(&resize_params->screen_info);
568 resize_params->resizer_rect = GetRootWindowResizerRect(); 568 if (delegate_)
569 resize_params->resizer_rect = delegate_->GetRootWindowResizerRect();
569 570
570 if (view_) { 571 if (view_) {
571 resize_params->new_size = view_->GetRequestedRendererSize(); 572 resize_params->new_size = view_->GetRequestedRendererSize();
572 resize_params->physical_backing_size = view_->GetPhysicalBackingSize(); 573 resize_params->physical_backing_size = view_->GetPhysicalBackingSize();
573 resize_params->top_controls_height = view_->GetTopControlsHeight(); 574 resize_params->top_controls_height = view_->GetTopControlsHeight();
574 resize_params->top_controls_shrink_blink_size = 575 resize_params->top_controls_shrink_blink_size =
575 view_->DoTopControlsShrinkBlinkSize(); 576 view_->DoTopControlsShrinkBlinkSize();
576 resize_params->visible_viewport_size = view_->GetVisibleViewportSize(); 577 resize_params->visible_viewport_size = view_->GetVisibleViewportSize();
577 resize_params->is_fullscreen_granted = IsFullscreenGranted(); 578 resize_params->is_fullscreen_granted = IsFullscreenGranted();
578 resize_params->display_mode = GetDisplayMode(); 579 resize_params->display_mode = GetDisplayMode();
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 // Some keypresses that are accepted by the listener might have follow up 1090 // Some keypresses that are accepted by the listener might have follow up
1090 // char events, which should be ignored. 1091 // char events, which should be ignored.
1091 if (key_event.type == WebKeyboardEvent::RawKeyDown) 1092 if (key_event.type == WebKeyboardEvent::RawKeyDown)
1092 suppress_next_char_events_ = true; 1093 suppress_next_char_events_ = true;
1093 return; 1094 return;
1094 } 1095 }
1095 1096
1096 if (key_event.type == WebKeyboardEvent::Char && 1097 if (key_event.type == WebKeyboardEvent::Char &&
1097 (key_event.windowsKeyCode == ui::VKEY_RETURN || 1098 (key_event.windowsKeyCode == ui::VKEY_RETURN ||
1098 key_event.windowsKeyCode == ui::VKEY_SPACE)) { 1099 key_event.windowsKeyCode == ui::VKEY_SPACE)) {
1099 OnUserGesture(); 1100 if (delegate_)
1101 delegate_->OnUserGesture();
1100 } 1102 }
1101 1103
1102 // Double check the type to make sure caller hasn't sent us nonsense that 1104 // Double check the type to make sure caller hasn't sent us nonsense that
1103 // will mess up our key queue. 1105 // will mess up our key queue.
1104 if (!WebInputEvent::isKeyboardEventType(key_event.type)) 1106 if (!WebInputEvent::isKeyboardEventType(key_event.type))
1105 return; 1107 return;
1106 1108
1107 if (suppress_next_char_events_) { 1109 if (suppress_next_char_events_) {
1108 // If preceding RawKeyDown event was handled by the browser, then we need 1110 // If preceding RawKeyDown event was handled by the browser, then we need
1109 // suppress all Char events generated by it. Please note that, one 1111 // suppress all Char events generated by it. Please note that, one
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 bool keep_selection) { 1362 bool keep_selection) {
1361 Send(new InputMsg_ImeConfirmComposition( 1363 Send(new InputMsg_ImeConfirmComposition(
1362 GetRoutingID(), text, replacement_range, keep_selection)); 1364 GetRoutingID(), text, replacement_range, keep_selection));
1363 } 1365 }
1364 1366
1365 void RenderWidgetHostImpl::ImeCancelComposition() { 1367 void RenderWidgetHostImpl::ImeCancelComposition() {
1366 Send(new InputMsg_ImeSetComposition(GetRoutingID(), base::string16(), 1368 Send(new InputMsg_ImeSetComposition(GetRoutingID(), base::string16(),
1367 std::vector<blink::WebCompositionUnderline>(), 0, 0)); 1369 std::vector<blink::WebCompositionUnderline>(), 0, 0));
1368 } 1370 }
1369 1371
1370 gfx::Rect RenderWidgetHostImpl::GetRootWindowResizerRect() const {
1371 return gfx::Rect();
1372 }
1373
1374 void RenderWidgetHostImpl::RequestToLockMouse(bool user_gesture, 1372 void RenderWidgetHostImpl::RequestToLockMouse(bool user_gesture,
ncarter (slow) 2015/10/30 04:08:12 Maybe inline this function? It's only got one call
Avi (use Gerrit) 2015/10/30 20:06:29 Done.
1375 bool last_unlocked_by_target) { 1373 bool last_unlocked_by_target) {
1376 // Directly reject to lock the mouse. Subclass can override this method to 1374 if (delegate_) {
1377 // decide whether to allow mouse lock or not. 1375 delegate_->RequestToLockMouse(user_gesture, last_unlocked_by_target);
1376 return;
1377 }
1378 // If there's no delegate, just reject it.
1378 GotResponseToLockMouseRequest(false); 1379 GotResponseToLockMouseRequest(false);
1379 } 1380 }
1380 1381
1381 void RenderWidgetHostImpl::RejectMouseLockOrUnlockIfNecessary() { 1382 void RenderWidgetHostImpl::RejectMouseLockOrUnlockIfNecessary() {
1382 DCHECK(!pending_mouse_lock_request_ || !IsMouseLocked()); 1383 DCHECK(!pending_mouse_lock_request_ || !IsMouseLocked());
1383 if (pending_mouse_lock_request_) { 1384 if (pending_mouse_lock_request_) {
1384 pending_mouse_lock_request_ = false; 1385 pending_mouse_lock_request_ = false;
1385 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); 1386 Send(new ViewMsg_LockMouse_ACK(routing_id_, false));
1386 } else if (IsMouseLocked()) { 1387 } else if (IsMouseLocked()) {
1387 view_->UnlockMouse(); 1388 view_->UnlockMouse();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 1426
1426 delete this; 1427 delete this;
1427 } 1428 }
1428 1429
1429 void RenderWidgetHostImpl::RendererIsUnresponsive() { 1430 void RenderWidgetHostImpl::RendererIsUnresponsive() {
1430 NotificationService::current()->Notify( 1431 NotificationService::current()->Notify(
1431 NOTIFICATION_RENDER_WIDGET_HOST_HANG, 1432 NOTIFICATION_RENDER_WIDGET_HOST_HANG,
1432 Source<RenderWidgetHost>(this), 1433 Source<RenderWidgetHost>(this),
1433 NotificationService::NoDetails()); 1434 NotificationService::NoDetails());
1434 is_unresponsive_ = true; 1435 is_unresponsive_ = true;
1435 NotifyRendererUnresponsive(); 1436 if (delegate_)
1437 delegate_->RendererUnresponsive(this);
1436 } 1438 }
1437 1439
1438 void RenderWidgetHostImpl::RendererIsResponsive() { 1440 void RenderWidgetHostImpl::RendererIsResponsive() {
1439 if (is_unresponsive_) { 1441 if (is_unresponsive_) {
1440 is_unresponsive_ = false; 1442 is_unresponsive_ = false;
1441 NotifyRendererResponsive(); 1443 if (delegate_)
1444 delegate_->RendererResponsive(this);
1442 } 1445 }
1443 } 1446 }
1444 1447
1445 void RenderWidgetHostImpl::ClearDisplayedGraphics() { 1448 void RenderWidgetHostImpl::ClearDisplayedGraphics() {
1446 NotifyNewContentRenderingTimeoutForTesting(); 1449 NotifyNewContentRenderingTimeoutForTesting();
1447 if (view_) 1450 if (view_)
1448 view_->ClearCompositorFrame(); 1451 view_->ClearCompositorFrame();
1449 } 1452 }
1450 1453
1451 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) { 1454 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) {
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 // events are being ignored in order to keep the renderer from getting 1848 // events are being ignored in order to keep the renderer from getting
1846 // confused about how many touches are active. 1849 // confused about how many touches are active.
1847 if (IgnoreInputEvents() && event.type != WebInputEvent::TouchCancel) 1850 if (IgnoreInputEvents() && event.type != WebInputEvent::TouchCancel)
1848 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; 1851 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
1849 1852
1850 if (!process_->HasConnection()) 1853 if (!process_->HasConnection())
1851 return INPUT_EVENT_ACK_STATE_UNKNOWN; 1854 return INPUT_EVENT_ACK_STATE_UNKNOWN;
1852 1855
1853 if (event.type == WebInputEvent::MouseDown || 1856 if (event.type == WebInputEvent::MouseDown ||
1854 event.type == WebInputEvent::GestureTapDown) { 1857 event.type == WebInputEvent::GestureTapDown) {
1855 OnUserGesture(); 1858 if (delegate_)
1859 delegate_->OnUserGesture();
ncarter (slow) 2015/10/30 04:08:12 This is a behavior change for non-view widgets. Wh
1856 } 1860 }
1857 1861
1858 if (delegate_) { 1862 if (delegate_) {
1859 if (event.type == WebInputEvent::MouseDown || 1863 if (event.type == WebInputEvent::MouseDown ||
1860 event.type == WebInputEvent::GestureTapDown || 1864 event.type == WebInputEvent::GestureTapDown ||
1861 event.type == WebInputEvent::RawKeyDown) { 1865 event.type == WebInputEvent::RawKeyDown) {
1862 delegate_->OnUserInteraction(event.type); 1866 delegate_->OnUserInteraction(event.type);
ncarter (slow) 2015/10/30 04:08:12 With the behavior change above, it seems safe to m
dominickn 2015/10/30 04:38:41 I just landed the OnUserInteraction hook earlier t
Avi (use Gerrit) 2015/10/30 20:06:29 I'm going to leave them as functionally unchanged
1863 } 1867 }
1864 } 1868 }
1865 1869
1866 return view_ ? view_->FilterInputEvent(event) 1870 return view_ ? view_->FilterInputEvent(event)
1867 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 1871 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
1868 } 1872 }
1869 1873
1870 void RenderWidgetHostImpl::IncrementInFlightEventCount() { 1874 void RenderWidgetHostImpl::IncrementInFlightEventCount() {
1871 increment_in_flight_event_count(); 1875 increment_in_flight_event_count();
1872 if (!is_hidden_) 1876 if (!is_hidden_)
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 1983
1980 void RenderWidgetHostImpl::OnSyntheticGestureCompleted( 1984 void RenderWidgetHostImpl::OnSyntheticGestureCompleted(
1981 SyntheticGesture::Result result) { 1985 SyntheticGesture::Result result) {
1982 Send(new InputMsg_SyntheticGestureCompleted(GetRoutingID())); 1986 Send(new InputMsg_SyntheticGestureCompleted(GetRoutingID()));
1983 } 1987 }
1984 1988
1985 bool RenderWidgetHostImpl::IgnoreInputEvents() const { 1989 bool RenderWidgetHostImpl::IgnoreInputEvents() const {
1986 return ignore_input_events_ || process_->IgnoreInputEvents(); 1990 return ignore_input_events_ || process_->IgnoreInputEvents();
1987 } 1991 }
1988 1992
1989 void RenderWidgetHostImpl::StartUserGesture() {
ncarter (slow) 2015/10/30 04:08:12 Nice find.
1990 OnUserGesture();
1991 }
1992
1993 void RenderWidgetHostImpl::SetBackgroundOpaque(bool opaque) { 1993 void RenderWidgetHostImpl::SetBackgroundOpaque(bool opaque) {
1994 Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque)); 1994 Send(new ViewMsg_SetBackgroundOpaque(GetRoutingID(), opaque));
1995 } 1995 }
1996 1996
1997 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent( 1997 void RenderWidgetHostImpl::SetEditCommandsForNextKeyEvent(
1998 const std::vector<EditCommand>& commands) { 1998 const std::vector<EditCommand>& commands) {
1999 Send(new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands)); 1999 Send(new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), commands));
2000 } 2000 }
2001 2001
2002 void RenderWidgetHostImpl::ExecuteEditCommand(const std::string& command, 2002 void RenderWidgetHostImpl::ExecuteEditCommand(const std::string& command,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2063 2063
2064 void RenderWidgetHostImpl::DelayedAutoResized() { 2064 void RenderWidgetHostImpl::DelayedAutoResized() {
2065 gfx::Size new_size = new_auto_size_; 2065 gfx::Size new_size = new_auto_size_;
2066 // Clear the new_auto_size_ since the empty value is used as a flag to 2066 // Clear the new_auto_size_ since the empty value is used as a flag to
2067 // indicate that no callback is in progress (i.e. without this line 2067 // indicate that no callback is in progress (i.e. without this line
2068 // DelayedAutoResized will not get called again). 2068 // DelayedAutoResized will not get called again).
2069 new_auto_size_.SetSize(0, 0); 2069 new_auto_size_.SetSize(0, 0);
2070 if (!auto_resize_enabled_) 2070 if (!auto_resize_enabled_)
2071 return; 2071 return;
2072 2072
2073 OnRenderAutoResized(new_size); 2073 if (delegate_)
2074 delegate_->ResizeDueToAutoResize(new_size);
ncarter (slow) 2015/10/30 04:08:12 So in theory, right, this would allow non-view wid
2074 } 2075 }
2075 2076
2076 void RenderWidgetHostImpl::DetachDelegate() { 2077 void RenderWidgetHostImpl::DetachDelegate() {
2077 delegate_ = NULL; 2078 delegate_ = NULL;
2078 } 2079 }
2079 2080
2080 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { 2081 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) {
2081 ui::LatencyInfo::LatencyComponent window_snapshot_component; 2082 ui::LatencyInfo::LatencyComponent window_snapshot_component;
2082 if (latency_info.FindLatency(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, 2083 if (latency_info.FindLatency(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT,
2083 GetLatencyComponentId(), 2084 GetLatencyComponentId(),
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2191 } 2192 }
2192 2193
2193 #if defined(OS_WIN) 2194 #if defined(OS_WIN)
2194 gfx::NativeViewAccessible 2195 gfx::NativeViewAccessible
2195 RenderWidgetHostImpl::GetParentNativeViewAccessible() { 2196 RenderWidgetHostImpl::GetParentNativeViewAccessible() {
2196 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL; 2197 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL;
2197 } 2198 }
2198 #endif 2199 #endif
2199 2200
2200 } // namespace content 2201 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698