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

Side by Side Diff: content/browser/web_contents/web_contents_view_gtk.cc

Issue 12252016: Prevented connecting drag drop events to a SwappedOut RenderViewHost in WebContentsViewGtk (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 months 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/web_contents/web_contents_view_gtk.h" 5 #include "content/browser/web_contents/web_contents_view_gtk.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 g_signal_connect(content_view, "leave-notify-event", 216 g_signal_connect(content_view, "leave-notify-event",
217 G_CALLBACK(OnLeaveNotify), web_contents_); 217 G_CALLBACK(OnLeaveNotify), web_contents_);
218 g_signal_connect(content_view, "motion-notify-event", 218 g_signal_connect(content_view, "motion-notify-event",
219 G_CALLBACK(OnMouseMove), web_contents_); 219 G_CALLBACK(OnMouseMove), web_contents_);
220 g_signal_connect(content_view, "scroll-event", 220 g_signal_connect(content_view, "scroll-event",
221 G_CALLBACK(OnMouseScroll), web_contents_); 221 G_CALLBACK(OnMouseScroll), web_contents_);
222 gtk_widget_add_events(content_view, GDK_LEAVE_NOTIFY_MASK | 222 gtk_widget_add_events(content_view, GDK_LEAVE_NOTIFY_MASK |
223 GDK_POINTER_MOTION_MASK); 223 GDK_POINTER_MOTION_MASK);
224 InsertIntoContentArea(content_view); 224 InsertIntoContentArea(content_view);
225 225
226 // Renderer target DnD. 226 // We don't want to change any state in this class for swapped out RVHs
227 drag_dest_.reset(new WebDragDestGtk(web_contents_, content_view)); 227 // because they will not be visible at this time.
Charlie Reis 2013/02/27 20:01:44 Great. Please add: It is important to update this
228 if (render_widget_host->IsRenderView()) {
229 RenderViewHost* rvh = RenderViewHost::From(render_widget_host);
230 if (!static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out()) {
231 // Renderer target DnD.
232 drag_dest_.reset(new WebDragDestGtk(web_contents_, content_view));
228 233
229 if (delegate_.get()) 234 if (delegate_.get())
230 drag_dest_->set_delegate(delegate_->GetDragDestDelegate()); 235 drag_dest_->set_delegate(delegate_->GetDragDestDelegate());
236 }
237 }
231 238
232 return view; 239 return view;
233 } 240 }
234 241
235 RenderWidgetHostView* WebContentsViewGtk::CreateViewForPopupWidget( 242 RenderWidgetHostView* WebContentsViewGtk::CreateViewForPopupWidget(
236 RenderWidgetHost* render_widget_host) { 243 RenderWidgetHost* render_widget_host) {
237 return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host); 244 return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host);
238 } 245 }
239 246
240 void WebContentsViewGtk::SetPageTitle(const string16& title) { 247 void WebContentsViewGtk::SetPageTitle(const string16& title) {
(...skipping 14 matching lines...) Expand all
255 // sizing information on to the renderer. 262 // sizing information on to the renderer.
256 requested_size_ = size; 263 requested_size_ = size;
257 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); 264 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
258 if (rwhv) 265 if (rwhv)
259 rwhv->SetSize(size); 266 rwhv->SetSize(size);
260 } 267 }
261 268
262 void WebContentsViewGtk::RenderViewCreated(RenderViewHost* host) { 269 void WebContentsViewGtk::RenderViewCreated(RenderViewHost* host) {
263 } 270 }
264 271
265 void WebContentsViewGtk::RenderViewSwappedIn(RenderViewHost* host) { 272 void WebContentsViewGtk::RenderViewSwappedIn(RenderViewHost* new_host,
273 RenderViewHost* old_host) {
274 // If we don't have a drag_dest yet, then we should set the drag dest to the
275 // new RVH.
276 // Also, not sure if this ever happens, but if the renderViewHost we're
277 // swapping out is used by the drag_dest, then we need to reset the drag_dest
278 // to the new host.
279 if (!drag_dest_.get() || (old_host &&
280 (old_host->GetView()->GetNativeView() == drag_dest_->widget()))) {
281 drag_dest_.reset(new WebDragDestGtk(web_contents_,
282 new_host->GetView()->GetNativeView()));
283 if (delegate_.get())
284 drag_dest_->set_delegate(delegate_->GetDragDestDelegate());
285 }
266 } 286 }
267 287
268 WebContents* WebContentsViewGtk::web_contents() { 288 WebContents* WebContentsViewGtk::web_contents() {
269 return web_contents_; 289 return web_contents_;
270 } 290 }
271 291
272 void WebContentsViewGtk::UpdateDragCursor(WebDragOperation operation) { 292 void WebContentsViewGtk::UpdateDragCursor(WebDragOperation operation) {
273 drag_dest_->UpdateDragStatus(operation); 293 drag_dest_->UpdateDragStatus(operation);
274 } 294 }
275 295
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // We manually tell our RWHV to resize the renderer content. This avoids 402 // We manually tell our RWHV to resize the renderer content. This avoids
383 // spurious resizes from GTK+. 403 // spurious resizes from GTK+.
384 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); 404 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
385 if (rwhv) 405 if (rwhv)
386 rwhv->SetSize(size); 406 rwhv->SetSize(size);
387 if (web_contents_->GetInterstitialPage()) 407 if (web_contents_->GetInterstitialPage())
388 web_contents_->GetInterstitialPage()->SetSize(size); 408 web_contents_->GetInterstitialPage()->SetSize(size);
389 } 409 }
390 410
391 } // namespace content 411 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_gtk.h ('k') | content/browser/web_contents/web_contents_view_guest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698