| 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/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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 using WebKit::WebDragOperation; | 31 using WebKit::WebDragOperation; |
| 32 using WebKit::WebDragOperationsMask; | 32 using WebKit::WebDragOperationsMask; |
| 33 using content::RenderWidgetHost; | 33 using content::RenderWidgetHost; |
| 34 using content::WebContents; | 34 using content::WebContents; |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 // Called when the mouse leaves the widget. We notify our delegate. | 38 // Called when the mouse leaves the widget. We notify our delegate. |
| 39 gboolean OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event, | 39 gboolean OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event, |
| 40 TabContents* tab_contents) { | 40 WebContentsImpl* web_contents) { |
| 41 if (tab_contents->GetDelegate()) | 41 if (web_contents->GetDelegate()) |
| 42 tab_contents->GetDelegate()->ContentsMouseEvent( | 42 web_contents->GetDelegate()->ContentsMouseEvent( |
| 43 tab_contents, gfx::Point(event->x_root, event->y_root), false); | 43 web_contents, gfx::Point(event->x_root, event->y_root), false); |
| 44 return FALSE; | 44 return FALSE; |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Called when the mouse moves within the widget. We notify our delegate. | 47 // Called when the mouse moves within the widget. We notify our delegate. |
| 48 gboolean OnMouseMove(GtkWidget* widget, GdkEventMotion* event, | 48 gboolean OnMouseMove(GtkWidget* widget, GdkEventMotion* event, |
| 49 TabContents* tab_contents) { | 49 WebContentsImpl* web_contents) { |
| 50 if (tab_contents->GetDelegate()) | 50 if (web_contents->GetDelegate()) |
| 51 tab_contents->GetDelegate()->ContentsMouseEvent( | 51 web_contents->GetDelegate()->ContentsMouseEvent( |
| 52 tab_contents, gfx::Point(event->x_root, event->y_root), true); | 52 web_contents, gfx::Point(event->x_root, event->y_root), true); |
| 53 return FALSE; | 53 return FALSE; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // See tab_contents_view_views.cc for discussion of mouse scroll zooming. | 56 // See tab_contents_view_views.cc for discussion of mouse scroll zooming. |
| 57 gboolean OnMouseScroll(GtkWidget* widget, GdkEventScroll* event, | 57 gboolean OnMouseScroll(GtkWidget* widget, GdkEventScroll* event, |
| 58 TabContents* tab_contents) { | 58 WebContentsImpl* web_contents) { |
| 59 if ((event->state & gtk_accelerator_get_default_mod_mask()) != | 59 if ((event->state & gtk_accelerator_get_default_mod_mask()) != |
| 60 GDK_CONTROL_MASK) { | 60 GDK_CONTROL_MASK) { |
| 61 return FALSE; | 61 return FALSE; |
| 62 } | 62 } |
| 63 | 63 |
| 64 content::WebContentsDelegate* delegate = tab_contents->GetDelegate(); | 64 content::WebContentsDelegate* delegate = web_contents->GetDelegate(); |
| 65 if (!delegate) | 65 if (!delegate) |
| 66 return FALSE; | 66 return FALSE; |
| 67 | 67 |
| 68 if (!(event->direction == GDK_SCROLL_DOWN || | 68 if (!(event->direction == GDK_SCROLL_DOWN || |
| 69 event->direction == GDK_SCROLL_UP)) { | 69 event->direction == GDK_SCROLL_UP)) { |
| 70 return FALSE; | 70 return FALSE; |
| 71 } | 71 } |
| 72 | 72 |
| 73 delegate->ContentsZoomChange(event->direction == GDK_SCROLL_UP); | 73 delegate->ContentsZoomChange(event->direction == GDK_SCROLL_UP); |
| 74 return TRUE; | 74 return TRUE; |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace | 77 } // namespace |
| 78 | 78 |
| 79 namespace content { | 79 namespace content { |
| 80 | 80 |
| 81 WebContentsViewGtk::WebContentsViewGtk( | 81 WebContentsViewGtk::WebContentsViewGtk( |
| 82 TabContents* tab_contents, | 82 WebContentsImpl* web_contents, |
| 83 content::WebContentsViewDelegate* delegate) | 83 content::WebContentsViewDelegate* delegate) |
| 84 : tab_contents_(tab_contents), | 84 : web_contents_(web_contents), |
| 85 expanded_(gtk_expanded_container_new()), | 85 expanded_(gtk_expanded_container_new()), |
| 86 delegate_(delegate) { | 86 delegate_(delegate) { |
| 87 gtk_widget_set_name(expanded_.get(), "chrome-tab-contents-view"); | 87 gtk_widget_set_name(expanded_.get(), "chrome-tab-contents-view"); |
| 88 g_signal_connect(expanded_.get(), "size-allocate", | 88 g_signal_connect(expanded_.get(), "size-allocate", |
| 89 G_CALLBACK(OnSizeAllocateThunk), this); | 89 G_CALLBACK(OnSizeAllocateThunk), this); |
| 90 g_signal_connect(expanded_.get(), "child-size-request", | 90 g_signal_connect(expanded_.get(), "child-size-request", |
| 91 G_CALLBACK(OnChildSizeRequestThunk), this); | 91 G_CALLBACK(OnChildSizeRequestThunk), this); |
| 92 | 92 |
| 93 gtk_widget_show(expanded_.get()); | 93 gtk_widget_show(expanded_.get()); |
| 94 drag_source_.reset(new content::WebDragSourceGtk(tab_contents)); | 94 drag_source_.reset(new content::WebDragSourceGtk(web_contents)); |
| 95 | 95 |
| 96 if (delegate_.get()) | 96 if (delegate_.get()) |
| 97 delegate_->Initialize(expanded_.get(), &focus_store_); | 97 delegate_->Initialize(expanded_.get(), &focus_store_); |
| 98 } | 98 } |
| 99 | 99 |
| 100 WebContentsViewGtk::~WebContentsViewGtk() { | 100 WebContentsViewGtk::~WebContentsViewGtk() { |
| 101 expanded_.Destroy(); | 101 expanded_.Destroy(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void WebContentsViewGtk::CreateView(const gfx::Size& initial_size) { | 104 void WebContentsViewGtk::CreateView(const gfx::Size& initial_size) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 116 DCHECK(RenderViewHostFactory::has_factory()); | 116 DCHECK(RenderViewHostFactory::has_factory()); |
| 117 return render_widget_host->GetView(); | 117 return render_widget_host->GetView(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 RenderWidgetHostView* view = | 120 RenderWidgetHostView* view = |
| 121 RenderWidgetHostView::CreateViewForWidget(render_widget_host); | 121 RenderWidgetHostView::CreateViewForWidget(render_widget_host); |
| 122 view->InitAsChild(NULL); | 122 view->InitAsChild(NULL); |
| 123 gfx::NativeView content_view = view->GetNativeView(); | 123 gfx::NativeView content_view = view->GetNativeView(); |
| 124 g_signal_connect(content_view, "focus", G_CALLBACK(OnFocusThunk), this); | 124 g_signal_connect(content_view, "focus", G_CALLBACK(OnFocusThunk), this); |
| 125 g_signal_connect(content_view, "leave-notify-event", | 125 g_signal_connect(content_view, "leave-notify-event", |
| 126 G_CALLBACK(OnLeaveNotify), tab_contents_); | 126 G_CALLBACK(OnLeaveNotify), web_contents_); |
| 127 g_signal_connect(content_view, "motion-notify-event", | 127 g_signal_connect(content_view, "motion-notify-event", |
| 128 G_CALLBACK(OnMouseMove), tab_contents_); | 128 G_CALLBACK(OnMouseMove), web_contents_); |
| 129 g_signal_connect(content_view, "scroll-event", | 129 g_signal_connect(content_view, "scroll-event", |
| 130 G_CALLBACK(OnMouseScroll), tab_contents_); | 130 G_CALLBACK(OnMouseScroll), web_contents_); |
| 131 gtk_widget_add_events(content_view, GDK_LEAVE_NOTIFY_MASK | | 131 gtk_widget_add_events(content_view, GDK_LEAVE_NOTIFY_MASK | |
| 132 GDK_POINTER_MOTION_MASK); | 132 GDK_POINTER_MOTION_MASK); |
| 133 InsertIntoContentArea(content_view); | 133 InsertIntoContentArea(content_view); |
| 134 | 134 |
| 135 // Renderer target DnD. | 135 // Renderer target DnD. |
| 136 drag_dest_.reset(new content::WebDragDestGtk(tab_contents_, content_view)); | 136 drag_dest_.reset(new content::WebDragDestGtk(web_contents_, content_view)); |
| 137 | 137 |
| 138 if (delegate_.get()) | 138 if (delegate_.get()) |
| 139 drag_dest_->set_delegate(delegate_->GetDragDestDelegate()); | 139 drag_dest_->set_delegate(delegate_->GetDragDestDelegate()); |
| 140 | 140 |
| 141 return view; | 141 return view; |
| 142 } | 142 } |
| 143 | 143 |
| 144 gfx::NativeView WebContentsViewGtk::GetNativeView() const { | 144 gfx::NativeView WebContentsViewGtk::GetNativeView() const { |
| 145 if (delegate_.get()) | 145 if (delegate_.get()) |
| 146 return delegate_->GetNativeView(); | 146 return delegate_->GetNativeView(); |
| 147 | 147 |
| 148 return expanded_.get(); | 148 return expanded_.get(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 gfx::NativeView WebContentsViewGtk::GetContentNativeView() const { | 151 gfx::NativeView WebContentsViewGtk::GetContentNativeView() const { |
| 152 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); | 152 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
| 153 if (!rwhv) | 153 if (!rwhv) |
| 154 return NULL; | 154 return NULL; |
| 155 return rwhv->GetNativeView(); | 155 return rwhv->GetNativeView(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 gfx::NativeWindow WebContentsViewGtk::GetTopLevelNativeWindow() const { | 158 gfx::NativeWindow WebContentsViewGtk::GetTopLevelNativeWindow() const { |
| 159 GtkWidget* window = gtk_widget_get_ancestor(GetNativeView(), GTK_TYPE_WINDOW); | 159 GtkWidget* window = gtk_widget_get_ancestor(GetNativeView(), GTK_TYPE_WINDOW); |
| 160 return window ? GTK_WINDOW(window) : NULL; | 160 return window ? GTK_WINDOW(window) : NULL; |
| 161 } | 161 } |
| 162 | 162 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 191 | 191 |
| 192 void WebContentsViewGtk::OnTabCrashed(base::TerminationStatus status, | 192 void WebContentsViewGtk::OnTabCrashed(base::TerminationStatus status, |
| 193 int error_code) { | 193 int error_code) { |
| 194 } | 194 } |
| 195 | 195 |
| 196 void WebContentsViewGtk::SizeContents(const gfx::Size& size) { | 196 void WebContentsViewGtk::SizeContents(const gfx::Size& size) { |
| 197 // We don't need to manually set the size of of widgets in GTK+, but we do | 197 // We don't need to manually set the size of of widgets in GTK+, but we do |
| 198 // need to pass the sizing information on to the RWHV which will pass the | 198 // need to pass the sizing information on to the RWHV which will pass the |
| 199 // sizing information on to the renderer. | 199 // sizing information on to the renderer. |
| 200 requested_size_ = size; | 200 requested_size_ = size; |
| 201 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); | 201 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
| 202 if (rwhv) | 202 if (rwhv) |
| 203 rwhv->SetSize(size); | 203 rwhv->SetSize(size); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void WebContentsViewGtk::RenderViewCreated(content::RenderViewHost* host) { | 206 void WebContentsViewGtk::RenderViewCreated(content::RenderViewHost* host) { |
| 207 } | 207 } |
| 208 | 208 |
| 209 void WebContentsViewGtk::Focus() { | 209 void WebContentsViewGtk::Focus() { |
| 210 if (tab_contents_->ShowingInterstitialPage()) { | 210 if (web_contents_->ShowingInterstitialPage()) { |
| 211 tab_contents_->GetInterstitialPage()->Focus(); | 211 web_contents_->GetInterstitialPage()->Focus(); |
| 212 } else if (delegate_.get()) { | 212 } else if (delegate_.get()) { |
| 213 delegate_->Focus(); | 213 delegate_->Focus(); |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| 217 void WebContentsViewGtk::SetInitialFocus() { | 217 void WebContentsViewGtk::SetInitialFocus() { |
| 218 if (tab_contents_->FocusLocationBarByDefault()) | 218 if (web_contents_->FocusLocationBarByDefault()) |
| 219 tab_contents_->SetFocusToLocationBar(false); | 219 web_contents_->SetFocusToLocationBar(false); |
| 220 else | 220 else |
| 221 Focus(); | 221 Focus(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void WebContentsViewGtk::StoreFocus() { | 224 void WebContentsViewGtk::StoreFocus() { |
| 225 focus_store_.Store(GetNativeView()); | 225 focus_store_.Store(GetNativeView()); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void WebContentsViewGtk::RestoreFocus() { | 228 void WebContentsViewGtk::RestoreFocus() { |
| 229 if (focus_store_.widget()) | 229 if (focus_store_.widget()) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 251 if (!window) { | 251 if (!window) { |
| 252 out->SetRect(0, 0, requested_size_.width(), requested_size_.height()); | 252 out->SetRect(0, 0, requested_size_.width(), requested_size_.height()); |
| 253 return; | 253 return; |
| 254 } | 254 } |
| 255 int x = 0, y = 0, w, h; | 255 int x = 0, y = 0, w, h; |
| 256 gdk_window_get_geometry(window, &x, &y, &w, &h, NULL); | 256 gdk_window_get_geometry(window, &x, &y, &w, &h, NULL); |
| 257 out->SetRect(x, y, w, h); | 257 out->SetRect(x, y, w, h); |
| 258 } | 258 } |
| 259 | 259 |
| 260 WebContents* WebContentsViewGtk::web_contents() { | 260 WebContents* WebContentsViewGtk::web_contents() { |
| 261 return tab_contents_; | 261 return web_contents_; |
| 262 } | 262 } |
| 263 | 263 |
| 264 void WebContentsViewGtk::UpdateDragCursor(WebDragOperation operation) { | 264 void WebContentsViewGtk::UpdateDragCursor(WebDragOperation operation) { |
| 265 drag_dest_->UpdateDragStatus(operation); | 265 drag_dest_->UpdateDragStatus(operation); |
| 266 } | 266 } |
| 267 | 267 |
| 268 void WebContentsViewGtk::GotFocus() { | 268 void WebContentsViewGtk::GotFocus() { |
| 269 // This is only used in the views FocusManager stuff but it bleeds through | 269 // This is only used in the views FocusManager stuff but it bleeds through |
| 270 // all subclasses. http://crbug.com/21875 | 270 // all subclasses. http://crbug.com/21875 |
| 271 } | 271 } |
| 272 | 272 |
| 273 // This is called when the renderer asks us to take focus back (i.e., it has | 273 // This is called when the renderer asks us to take focus back (i.e., it has |
| 274 // iterated past the last focusable element on the page). | 274 // iterated past the last focusable element on the page). |
| 275 void WebContentsViewGtk::TakeFocus(bool reverse) { | 275 void WebContentsViewGtk::TakeFocus(bool reverse) { |
| 276 if (!tab_contents_->GetDelegate()) | 276 if (!web_contents_->GetDelegate()) |
| 277 return; | 277 return; |
| 278 if (!tab_contents_->GetDelegate()->TakeFocus(reverse)) { | 278 if (!web_contents_->GetDelegate()->TakeFocus(reverse)) { |
| 279 gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()), | 279 gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()), |
| 280 reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD); | 280 reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD); |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 | 283 |
| 284 void WebContentsViewGtk::InsertIntoContentArea(GtkWidget* widget) { | 284 void WebContentsViewGtk::InsertIntoContentArea(GtkWidget* widget) { |
| 285 gtk_container_add(GTK_CONTAINER(expanded_.get()), widget); | 285 gtk_container_add(GTK_CONTAINER(expanded_.get()), widget); |
| 286 } | 286 } |
| 287 | 287 |
| 288 // Called when the content view gtk widget is tabbed to, or after the call to | 288 // Called when the content view gtk widget is tabbed to, or after the call to |
| (...skipping 11 matching lines...) Expand all Loading... |
| 300 } | 300 } |
| 301 | 301 |
| 302 // If we already have focus, let the next widget have a shot at it. We will | 302 // If we already have focus, let the next widget have a shot at it. We will |
| 303 // reach this situation after the call to gtk_widget_child_focus() in | 303 // reach this situation after the call to gtk_widget_child_focus() in |
| 304 // TakeFocus(). | 304 // TakeFocus(). |
| 305 if (gtk_widget_is_focus(widget)) | 305 if (gtk_widget_is_focus(widget)) |
| 306 return FALSE; | 306 return FALSE; |
| 307 | 307 |
| 308 gtk_widget_grab_focus(widget); | 308 gtk_widget_grab_focus(widget); |
| 309 bool reverse = focus == GTK_DIR_TAB_BACKWARD; | 309 bool reverse = focus == GTK_DIR_TAB_BACKWARD; |
| 310 tab_contents_->FocusThroughTabTraversal(reverse); | 310 web_contents_->FocusThroughTabTraversal(reverse); |
| 311 return TRUE; | 311 return TRUE; |
| 312 } | 312 } |
| 313 | 313 |
| 314 void WebContentsViewGtk::CreateNewWindow( | 314 void WebContentsViewGtk::CreateNewWindow( |
| 315 int route_id, | 315 int route_id, |
| 316 const ViewHostMsg_CreateWindow_Params& params) { | 316 const ViewHostMsg_CreateWindow_Params& params) { |
| 317 web_contents_view_helper_.CreateNewWindow(tab_contents_, route_id, params); | 317 web_contents_view_helper_.CreateNewWindow(web_contents_, route_id, params); |
| 318 } | 318 } |
| 319 | 319 |
| 320 void WebContentsViewGtk::CreateNewWidget( | 320 void WebContentsViewGtk::CreateNewWidget( |
| 321 int route_id, WebKit::WebPopupType popup_type) { | 321 int route_id, WebKit::WebPopupType popup_type) { |
| 322 web_contents_view_helper_.CreateNewWidget(tab_contents_, | 322 web_contents_view_helper_.CreateNewWidget(web_contents_, |
| 323 route_id, | 323 route_id, |
| 324 false, | 324 false, |
| 325 popup_type); | 325 popup_type); |
| 326 } | 326 } |
| 327 | 327 |
| 328 void WebContentsViewGtk::CreateNewFullscreenWidget(int route_id) { | 328 void WebContentsViewGtk::CreateNewFullscreenWidget(int route_id) { |
| 329 web_contents_view_helper_.CreateNewWidget(tab_contents_, | 329 web_contents_view_helper_.CreateNewWidget(web_contents_, |
| 330 route_id, | 330 route_id, |
| 331 true, | 331 true, |
| 332 WebKit::WebPopupTypeNone); | 332 WebKit::WebPopupTypeNone); |
| 333 } | 333 } |
| 334 | 334 |
| 335 void WebContentsViewGtk::ShowCreatedWindow(int route_id, | 335 void WebContentsViewGtk::ShowCreatedWindow(int route_id, |
| 336 WindowOpenDisposition disposition, | 336 WindowOpenDisposition disposition, |
| 337 const gfx::Rect& initial_pos, | 337 const gfx::Rect& initial_pos, |
| 338 bool user_gesture) { | 338 bool user_gesture) { |
| 339 web_contents_view_helper_.ShowCreatedWindow( | 339 web_contents_view_helper_.ShowCreatedWindow( |
| 340 tab_contents_, route_id, disposition, initial_pos, user_gesture); | 340 web_contents_, route_id, disposition, initial_pos, user_gesture); |
| 341 } | 341 } |
| 342 | 342 |
| 343 void WebContentsViewGtk::ShowCreatedWidget( | 343 void WebContentsViewGtk::ShowCreatedWidget( |
| 344 int route_id, const gfx::Rect& initial_pos) { | 344 int route_id, const gfx::Rect& initial_pos) { |
| 345 web_contents_view_helper_.ShowCreatedWidget(tab_contents_, | 345 web_contents_view_helper_.ShowCreatedWidget(web_contents_, |
| 346 route_id, | 346 route_id, |
| 347 false, | 347 false, |
| 348 initial_pos); | 348 initial_pos); |
| 349 } | 349 } |
| 350 | 350 |
| 351 void WebContentsViewGtk::ShowCreatedFullscreenWidget(int route_id) { | 351 void WebContentsViewGtk::ShowCreatedFullscreenWidget(int route_id) { |
| 352 web_contents_view_helper_.ShowCreatedWidget(tab_contents_, | 352 web_contents_view_helper_.ShowCreatedWidget(web_contents_, |
| 353 route_id, | 353 route_id, |
| 354 true, | 354 true, |
| 355 gfx::Rect()); | 355 gfx::Rect()); |
| 356 } | 356 } |
| 357 | 357 |
| 358 void WebContentsViewGtk::ShowContextMenu( | 358 void WebContentsViewGtk::ShowContextMenu( |
| 359 const content::ContextMenuParams& params) { | 359 const content::ContextMenuParams& params) { |
| 360 // Allow delegates to handle the context menu operation first. | 360 // Allow delegates to handle the context menu operation first. |
| 361 if (web_contents()->GetDelegate() && | 361 if (web_contents()->GetDelegate() && |
| 362 web_contents()->GetDelegate()->HandleContextMenu(params)) { | 362 web_contents()->GetDelegate()->HandleContextMenu(params)) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 382 | 382 |
| 383 // Render view DnD ------------------------------------------------------------- | 383 // Render view DnD ------------------------------------------------------------- |
| 384 | 384 |
| 385 void WebContentsViewGtk::StartDragging(const WebDropData& drop_data, | 385 void WebContentsViewGtk::StartDragging(const WebDropData& drop_data, |
| 386 WebDragOperationsMask ops, | 386 WebDragOperationsMask ops, |
| 387 const SkBitmap& image, | 387 const SkBitmap& image, |
| 388 const gfx::Point& image_offset) { | 388 const gfx::Point& image_offset) { |
| 389 DCHECK(GetContentNativeView()); | 389 DCHECK(GetContentNativeView()); |
| 390 | 390 |
| 391 RenderWidgetHostViewGtk* view_gtk = static_cast<RenderWidgetHostViewGtk*>( | 391 RenderWidgetHostViewGtk* view_gtk = static_cast<RenderWidgetHostViewGtk*>( |
| 392 tab_contents_->GetRenderWidgetHostView()); | 392 web_contents_->GetRenderWidgetHostView()); |
| 393 if (!view_gtk || !view_gtk->GetLastMouseDown()) | 393 if (!view_gtk || !view_gtk->GetLastMouseDown()) |
| 394 return; | 394 return; |
| 395 | 395 |
| 396 drag_source_->StartDragging(drop_data, ops, view_gtk->GetLastMouseDown(), | 396 drag_source_->StartDragging(drop_data, ops, view_gtk->GetLastMouseDown(), |
| 397 image, image_offset); | 397 image, image_offset); |
| 398 } | 398 } |
| 399 | 399 |
| 400 // ----------------------------------------------------------------------------- | 400 // ----------------------------------------------------------------------------- |
| 401 | 401 |
| 402 void WebContentsViewGtk::OnChildSizeRequest(GtkWidget* widget, | 402 void WebContentsViewGtk::OnChildSizeRequest(GtkWidget* widget, |
| 403 GtkWidget* child, | 403 GtkWidget* child, |
| 404 GtkRequisition* requisition) { | 404 GtkRequisition* requisition) { |
| 405 if (tab_contents_->GetDelegate()) { | 405 if (web_contents_->GetDelegate()) { |
| 406 requisition->height += | 406 requisition->height += |
| 407 tab_contents_->GetDelegate()->GetExtraRenderViewHeight(); | 407 web_contents_->GetDelegate()->GetExtraRenderViewHeight(); |
| 408 } | 408 } |
| 409 } | 409 } |
| 410 | 410 |
| 411 void WebContentsViewGtk::OnSizeAllocate(GtkWidget* widget, | 411 void WebContentsViewGtk::OnSizeAllocate(GtkWidget* widget, |
| 412 GtkAllocation* allocation) { | 412 GtkAllocation* allocation) { |
| 413 int width = allocation->width; | 413 int width = allocation->width; |
| 414 int height = allocation->height; | 414 int height = allocation->height; |
| 415 // |delegate()| can be NULL here during browser teardown. | 415 // |delegate()| can be NULL here during browser teardown. |
| 416 if (tab_contents_->GetDelegate()) | 416 if (web_contents_->GetDelegate()) |
| 417 height += tab_contents_->GetDelegate()->GetExtraRenderViewHeight(); | 417 height += web_contents_->GetDelegate()->GetExtraRenderViewHeight(); |
| 418 gfx::Size size(width, height); | 418 gfx::Size size(width, height); |
| 419 requested_size_ = size; | 419 requested_size_ = size; |
| 420 | 420 |
| 421 // We manually tell our RWHV to resize the renderer content. This avoids | 421 // We manually tell our RWHV to resize the renderer content. This avoids |
| 422 // spurious resizes from GTK+. | 422 // spurious resizes from GTK+. |
| 423 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); | 423 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
| 424 if (rwhv) | 424 if (rwhv) |
| 425 rwhv->SetSize(size); | 425 rwhv->SetSize(size); |
| 426 if (tab_contents_->GetInterstitialPage()) | 426 if (web_contents_->GetInterstitialPage()) |
| 427 tab_contents_->GetInterstitialPage()->SetSize(size); | 427 web_contents_->GetInterstitialPage()->SetSize(size); |
| 428 } | 428 } |
| 429 | 429 |
| 430 } // namespace content | 430 } // namespace content |
| OLD | NEW |