Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 net::URLRequestStatus::Status. | 9 // badly with net::URLRequestStatus::Status. |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 // ignore them so we don't re-allocate the backing store. We will paint | 595 // ignore them so we don't re-allocate the backing store. We will paint |
| 596 // everything again when we become selected again. | 596 // everything again when we become selected again. |
| 597 is_hidden_ = true; | 597 is_hidden_ = true; |
| 598 | 598 |
| 599 // If we have a renderer, then inform it that we are being hidden so it can | 599 // If we have a renderer, then inform it that we are being hidden so it can |
| 600 // reduce its resource utilization. | 600 // reduce its resource utilization. |
| 601 GetRenderWidgetHost()->WasHidden(); | 601 GetRenderWidgetHost()->WasHidden(); |
| 602 } | 602 } |
| 603 | 603 |
| 604 void RenderWidgetHostViewGtk::SetSize(const gfx::Size& size) { | 604 void RenderWidgetHostViewGtk::SetSize(const gfx::Size& size) { |
| 605 // This is called when webkit has sent us a Move message. | |
| 606 int width = std::min(size.width(), kMaxWindowWidth); | 605 int width = std::min(size.width(), kMaxWindowWidth); |
| 607 int height = std::min(size.height(), kMaxWindowHeight); | 606 int height = std::min(size.height(), kMaxWindowHeight); |
| 608 if (IsPopup()) { | 607 if (IsPopup()) { |
| 609 // We're a popup, honor the size request. | 608 // We're a popup, honor the size request. |
| 610 gtk_widget_set_size_request(view_.get(), width, height); | 609 gtk_widget_set_size_request(view_.get(), width, height); |
| 611 } else { | 610 } else { |
| 612 #if defined(TOOLKIT_VIEWS) | 611 #if defined(TOOLKIT_VIEWS) |
| 613 // TOOLKIT_VIEWS' resize logic flow matches windows. so we go ahead and | 612 // TOOLKIT_VIEWS' resize logic flow matches windows. so we go ahead and |
| 614 // size the widget. In GTK+, the size of the widget is determined by its | 613 // size the widget. In GTK+, the size of the widget is determined by its |
| 615 // children. | 614 // children. |
| 616 gtk_widget_set_size_request(view_.get(), width, height); | 615 gtk_widget_set_size_request(view_.get(), width, height); |
| 617 #endif | 616 #endif |
| 618 } | 617 } |
| 618 | |
| 619 // Update the size of the RWH. | 619 // Update the size of the RWH. |
| 620 if (requested_size_.width() != width || | 620 if (requested_size_.width() != width || |
| 621 requested_size_.height() != height) { | 621 requested_size_.height() != height) { |
| 622 requested_size_ = gfx::Size(width, height); | 622 requested_size_ = gfx::Size(width, height); |
| 623 host_->WasResized(); | 623 host_->WasResized(); |
| 624 } | 624 } |
| 625 } | 625 } |
| 626 | 626 |
| 627 void RenderWidgetHostViewGtk::SetBounds(const gfx::Rect& rect) { | |
| 628 // This is called when webkit has sent us a Move message. | |
| 629 GtkWidget* parent_widget = gtk_widget_get_parent(view_.get()); | |
| 630 if (GTK_IS_WINDOW(parent_widget)) | |
|
Evan Stade
2011/02/23 20:25:18
can you use IsPopup() and then do gtk_widget_get_t
honten.org
2011/02/24 08:03:58
Done.
| |
| 631 gtk_window_move(GTK_WINDOW(parent_widget), rect.x(), rect.y()); | |
| 632 | |
| 633 SetSize(rect.size()); | |
| 634 } | |
| 635 | |
| 627 gfx::NativeView RenderWidgetHostViewGtk::GetNativeView() { | 636 gfx::NativeView RenderWidgetHostViewGtk::GetNativeView() { |
| 628 return view_.get(); | 637 return view_.get(); |
| 629 } | 638 } |
| 630 | 639 |
| 631 void RenderWidgetHostViewGtk::MovePluginWindows( | 640 void RenderWidgetHostViewGtk::MovePluginWindows( |
| 632 const std::vector<webkit::npapi::WebPluginGeometry>& moves) { | 641 const std::vector<webkit::npapi::WebPluginGeometry>& moves) { |
| 633 for (size_t i = 0; i < moves.size(); ++i) { | 642 for (size_t i = 0; i < moves.size(); ++i) { |
| 634 plugin_container_manager_.MovePluginContainer(moves[i]); | 643 plugin_container_manager_.MovePluginContainer(moves[i]); |
| 635 } | 644 } |
| 636 } | 645 } |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1133 } | 1142 } |
| 1134 | 1143 |
| 1135 // static | 1144 // static |
| 1136 RenderWidgetHostView* | 1145 RenderWidgetHostView* |
| 1137 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1146 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
| 1138 gfx::NativeView widget) { | 1147 gfx::NativeView widget) { |
| 1139 gpointer user_data = g_object_get_data(G_OBJECT(widget), | 1148 gpointer user_data = g_object_get_data(G_OBJECT(widget), |
| 1140 kRenderWidgetHostViewKey); | 1149 kRenderWidgetHostViewKey); |
| 1141 return reinterpret_cast<RenderWidgetHostView*>(user_data); | 1150 return reinterpret_cast<RenderWidgetHostView*>(user_data); |
| 1142 } | 1151 } |
| OLD | NEW |