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

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: Oops. Fix compile error. 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.
228 228 if (render_widget_host->IsRenderView()) {
229 if (delegate_.get()) 229 RenderViewHost* rvh = RenderViewHost::From(render_widget_host);
230 drag_dest_->set_delegate(delegate_->GetDragDestDelegate()); 230 if (!static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out())
231 UpdateDragDest(rvh);
232 }
231 233
232 return view; 234 return view;
233 } 235 }
234 236
235 RenderWidgetHostView* WebContentsViewGtk::CreateViewForPopupWidget( 237 RenderWidgetHostView* WebContentsViewGtk::CreateViewForPopupWidget(
236 RenderWidgetHost* render_widget_host) { 238 RenderWidgetHost* render_widget_host) {
237 return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host); 239 return RenderWidgetHostViewPort::CreateViewForWidget(render_widget_host);
238 } 240 }
239 241
240 void WebContentsViewGtk::SetPageTitle(const string16& title) { 242 void WebContentsViewGtk::SetPageTitle(const string16& title) {
(...skipping 15 matching lines...) Expand all
256 requested_size_ = size; 258 requested_size_ = size;
257 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); 259 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
258 if (rwhv) 260 if (rwhv)
259 rwhv->SetSize(size); 261 rwhv->SetSize(size);
260 } 262 }
261 263
262 void WebContentsViewGtk::RenderViewCreated(RenderViewHost* host) { 264 void WebContentsViewGtk::RenderViewCreated(RenderViewHost* host) {
263 } 265 }
264 266
265 void WebContentsViewGtk::RenderViewSwappedIn(RenderViewHost* host) { 267 void WebContentsViewGtk::RenderViewSwappedIn(RenderViewHost* host) {
268 UpdateDragDest(host);
266 } 269 }
267 270
268 WebContents* WebContentsViewGtk::web_contents() { 271 WebContents* WebContentsViewGtk::web_contents() {
269 return web_contents_; 272 return web_contents_;
270 } 273 }
271 274
272 void WebContentsViewGtk::UpdateDragCursor(WebDragOperation operation) { 275 void WebContentsViewGtk::UpdateDragCursor(WebDragOperation operation) {
273 drag_dest_->UpdateDragStatus(operation); 276 drag_dest_->UpdateDragStatus(operation);
274 } 277 }
275 278
(...skipping 11 matching lines...) Expand all
287 GetTopLevelNativeWindow()) { 290 GetTopLevelNativeWindow()) {
288 gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()), 291 gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()),
289 reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD); 292 reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD);
290 } 293 }
291 } 294 }
292 295
293 void WebContentsViewGtk::InsertIntoContentArea(GtkWidget* widget) { 296 void WebContentsViewGtk::InsertIntoContentArea(GtkWidget* widget) {
294 gtk_container_add(GTK_CONTAINER(expanded_.get()), widget); 297 gtk_container_add(GTK_CONTAINER(expanded_.get()), widget);
295 } 298 }
296 299
300 void WebContentsViewGtk::UpdateDragDest(RenderViewHost* host) {
301 gfx::NativeView content_view = host->GetView()->GetNativeView();
302
303 // If the host is already used by the drag_dest_, there's no point in deleting
304 // the old one to create an identical copy.
305 if (drag_dest_.get() && drag_dest_->widget() == content_view)
306 return;
307
308 // Clear the currently connected drag drop signals by deleting the old
309 // drag_dest_ before creating the new one.
310 drag_dest_.reset();
311 // Create the new drag_dest_.
312 drag_dest_.reset(new WebDragDestGtk(web_contents_, content_view));
313
314 if (delegate_.get())
315 drag_dest_->set_delegate(delegate_->GetDragDestDelegate());
316 }
317
297 // Called when the content view gtk widget is tabbed to, or after the call to 318 // Called when the content view gtk widget is tabbed to, or after the call to
298 // gtk_widget_child_focus() in TakeFocus(). We return true 319 // gtk_widget_child_focus() in TakeFocus(). We return true
299 // and grab focus if we don't have it. The call to 320 // and grab focus if we don't have it. The call to
300 // FocusThroughTabTraversal(bool) forwards the "move focus forward" effect to 321 // FocusThroughTabTraversal(bool) forwards the "move focus forward" effect to
301 // webkit. 322 // webkit.
302 gboolean WebContentsViewGtk::OnFocus(GtkWidget* widget, 323 gboolean WebContentsViewGtk::OnFocus(GtkWidget* widget,
303 GtkDirectionType focus) { 324 GtkDirectionType focus) {
304 // Give our view wrapper first chance at this event. 325 // Give our view wrapper first chance at this event.
305 if (delegate_.get()) { 326 if (delegate_.get()) {
306 gboolean return_value = FALSE; 327 gboolean return_value = FALSE;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // We manually tell our RWHV to resize the renderer content. This avoids 403 // We manually tell our RWHV to resize the renderer content. This avoids
383 // spurious resizes from GTK+. 404 // spurious resizes from GTK+.
384 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); 405 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
385 if (rwhv) 406 if (rwhv)
386 rwhv->SetSize(size); 407 rwhv->SetSize(size);
387 if (web_contents_->GetInterstitialPage()) 408 if (web_contents_->GetInterstitialPage())
388 web_contents_->GetInterstitialPage()->SetSize(size); 409 web_contents_->GetInterstitialPage()->SetSize(size);
389 } 410 }
390 411
391 } // namespace content 412 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_gtk.h ('k') | content/browser/web_contents/web_drag_dest_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698