OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/render_widget_host_view_gtk.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" |
6 | 6 |
7 // If this gets included after the gtk headers, then a bunch of compiler | 7 // If this gets included after the gtk headers, then a bunch of compiler |
8 // errors happen because of a "#define Status int" in Xlib.h, which interacts | 8 // errors happen because of a "#define Status int" in Xlib.h, which interacts |
9 // badly with URLRequestStatus::Status. | 9 // badly with URLRequestStatus::Status. |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // TabContentsView which handles zoom events. | 87 // TabContentsView which handles zoom events. |
88 g_signal_connect_after(widget, "scroll-event", | 88 g_signal_connect_after(widget, "scroll-event", |
89 G_CALLBACK(MouseScrollEvent), host_view); | 89 G_CALLBACK(MouseScrollEvent), host_view); |
90 | 90 |
91 return widget; | 91 return widget; |
92 } | 92 } |
93 | 93 |
94 private: | 94 private: |
95 static gboolean SizeAllocate(GtkWidget* widget, GtkAllocation* allocation, | 95 static gboolean SizeAllocate(GtkWidget* widget, GtkAllocation* allocation, |
96 RenderWidgetHostViewGtk* host_view) { | 96 RenderWidgetHostViewGtk* host_view) { |
| 97 host_view->requested_size_ = gfx::Size(allocation->width, |
| 98 allocation->height); |
97 host_view->GetRenderWidgetHost()->WasResized(); | 99 host_view->GetRenderWidgetHost()->WasResized(); |
98 return FALSE; | 100 return FALSE; |
99 } | 101 } |
100 | 102 |
101 static gboolean ExposeEvent(GtkWidget* widget, GdkEventExpose* expose, | 103 static gboolean ExposeEvent(GtkWidget* widget, GdkEventExpose* expose, |
102 RenderWidgetHostViewGtk* host_view) { | 104 RenderWidgetHostViewGtk* host_view) { |
103 const gfx::Rect damage_rect(expose->area); | 105 const gfx::Rect damage_rect(expose->area); |
104 host_view->Paint(damage_rect); | 106 host_view->Paint(damage_rect); |
105 return FALSE; | 107 return FALSE; |
106 } | 108 } |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 // everything again when we become selected again. | 381 // everything again when we become selected again. |
380 is_hidden_ = true; | 382 is_hidden_ = true; |
381 | 383 |
382 // If we have a renderer, then inform it that we are being hidden so it can | 384 // If we have a renderer, then inform it that we are being hidden so it can |
383 // reduce its resource utilization. | 385 // reduce its resource utilization. |
384 GetRenderWidgetHost()->WasHidden(); | 386 GetRenderWidgetHost()->WasHidden(); |
385 } | 387 } |
386 | 388 |
387 void RenderWidgetHostViewGtk::SetSize(const gfx::Size& size) { | 389 void RenderWidgetHostViewGtk::SetSize(const gfx::Size& size) { |
388 // This is called when webkit has sent us a Move message. | 390 // This is called when webkit has sent us a Move message. |
389 // If we are a popup, we want to handle this. | 391 int width = std::min(size.width(), kMaxWindowWidth); |
390 // TODO(estade): are there other situations where we want to respect the | 392 int height = std::min(size.height(), kMaxWindowHeight); |
391 // request? | |
392 #if !defined(TOOLKIT_VIEWS) | |
393 if (parent_) { | 393 if (parent_) { |
394 #else | 394 // We're a popup, honor the size request. |
395 // TOOLKIT_VIEWS' resize logic flow matches windows. When the container widget | 395 gtk_widget_set_size_request(view_.get(), width, height); |
396 // is resized, it calls RWH::WasSized, which sizes this widget using SetSize. | 396 } else { |
397 // TODO(estade): figure out if the logic flow here can be normalized across | 397 #if defined(TOOLKIT_VIEWS) |
398 // platforms | 398 // TOOLKIT_VIEWS' resize logic flow matches windows. so we go ahead and |
| 399 // size the widget. In GTK+, the size of the widget is determined by it's |
| 400 // children. |
| 401 gtk_widget_set_size_request(view_.get(), width, height); |
399 #endif | 402 #endif |
400 gtk_widget_set_size_request(view_.get(), | 403 requested_size_ = gfx::Size(width, height); |
401 std::min(size.width(), kMaxWindowWidth), | 404 host_->WasResized(); |
402 std::min(size.height(), kMaxWindowHeight)); | |
403 #if !defined(TOOLKIT_VIEWS) | |
404 } | 405 } |
405 #endif | |
406 } | 406 } |
407 | 407 |
408 gfx::NativeView RenderWidgetHostViewGtk::GetNativeView() { | 408 gfx::NativeView RenderWidgetHostViewGtk::GetNativeView() { |
409 return view_.get(); | 409 return view_.get(); |
410 } | 410 } |
411 | 411 |
412 void RenderWidgetHostViewGtk::MovePluginWindows( | 412 void RenderWidgetHostViewGtk::MovePluginWindows( |
413 const std::vector<webkit_glue::WebPluginGeometry>& moves) { | 413 const std::vector<webkit_glue::WebPluginGeometry>& moves) { |
414 for (size_t i = 0; i < moves.size(); ++i) { | 414 for (size_t i = 0; i < moves.size(); ++i) { |
415 plugin_container_manager_.MovePluginContainer(moves[i]); | 415 plugin_container_manager_.MovePluginContainer(moves[i]); |
(...skipping 21 matching lines...) Expand all Loading... |
437 void RenderWidgetHostViewGtk::Show() { | 437 void RenderWidgetHostViewGtk::Show() { |
438 gtk_widget_show(view_.get()); | 438 gtk_widget_show(view_.get()); |
439 } | 439 } |
440 | 440 |
441 void RenderWidgetHostViewGtk::Hide() { | 441 void RenderWidgetHostViewGtk::Hide() { |
442 gtk_widget_hide(view_.get()); | 442 gtk_widget_hide(view_.get()); |
443 } | 443 } |
444 | 444 |
445 gfx::Rect RenderWidgetHostViewGtk::GetViewBounds() const { | 445 gfx::Rect RenderWidgetHostViewGtk::GetViewBounds() const { |
446 GtkAllocation* alloc = &view_.get()->allocation; | 446 GtkAllocation* alloc = &view_.get()->allocation; |
447 return gfx::Rect(alloc->x, alloc->y, alloc->width, alloc->height); | 447 return gfx::Rect(alloc->x, alloc->y, |
| 448 requested_size_.width(), |
| 449 requested_size_.height()); |
448 } | 450 } |
449 | 451 |
450 void RenderWidgetHostViewGtk::UpdateCursor(const WebCursor& cursor) { | 452 void RenderWidgetHostViewGtk::UpdateCursor(const WebCursor& cursor) { |
451 // Optimize the common case, where the cursor hasn't changed. | 453 // Optimize the common case, where the cursor hasn't changed. |
452 // However, we can switch between different pixmaps, so only on the | 454 // However, we can switch between different pixmaps, so only on the |
453 // non-pixmap branch. | 455 // non-pixmap branch. |
454 if (current_cursor_.GetCursorType() != GDK_CURSOR_IS_PIXMAP && | 456 if (current_cursor_.GetCursorType() != GDK_CURSOR_IS_PIXMAP && |
455 current_cursor_.GetCursorType() == cursor.GetCursorType()) | 457 current_cursor_.GetCursorType() == cursor.GetCursorType()) |
456 return; | 458 return; |
457 | 459 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 } | 630 } |
629 | 631 |
630 void RenderWidgetHostViewGtk::ForwardKeyboardEvent( | 632 void RenderWidgetHostViewGtk::ForwardKeyboardEvent( |
631 const NativeWebKeyboardEvent& event) { | 633 const NativeWebKeyboardEvent& event) { |
632 EditCommands edit_commands; | 634 EditCommands edit_commands; |
633 if (key_bindings_handler_->Match(event, &edit_commands)) { | 635 if (key_bindings_handler_->Match(event, &edit_commands)) { |
634 host_->ForwardEditCommandsForNextKeyEvent(edit_commands); | 636 host_->ForwardEditCommandsForNextKeyEvent(edit_commands); |
635 } | 637 } |
636 host_->ForwardKeyboardEvent(event); | 638 host_->ForwardKeyboardEvent(event); |
637 } | 639 } |
OLD | NEW |