| 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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 // ignore them so we don't re-allocate the backing store. We will paint | 607 // ignore them so we don't re-allocate the backing store. We will paint |
| 608 // everything again when we become selected again. | 608 // everything again when we become selected again. |
| 609 is_hidden_ = true; | 609 is_hidden_ = true; |
| 610 | 610 |
| 611 // If we have a renderer, then inform it that we are being hidden so it can | 611 // If we have a renderer, then inform it that we are being hidden so it can |
| 612 // reduce its resource utilization. | 612 // reduce its resource utilization. |
| 613 GetRenderWidgetHost()->WasHidden(); | 613 GetRenderWidgetHost()->WasHidden(); |
| 614 } | 614 } |
| 615 | 615 |
| 616 void RenderWidgetHostViewGtk::SetSize(const gfx::Size& size) { | 616 void RenderWidgetHostViewGtk::SetSize(const gfx::Size& size) { |
| 617 // This is called when webkit has sent us a Move message. | |
| 618 int width = std::min(size.width(), kMaxWindowWidth); | 617 int width = std::min(size.width(), kMaxWindowWidth); |
| 619 int height = std::min(size.height(), kMaxWindowHeight); | 618 int height = std::min(size.height(), kMaxWindowHeight); |
| 620 if (IsPopup()) { | 619 if (IsPopup()) { |
| 621 // We're a popup, honor the size request. | 620 // We're a popup, honor the size request. |
| 622 gtk_widget_set_size_request(view_.get(), width, height); | 621 gtk_widget_set_size_request(view_.get(), width, height); |
| 623 } else { | 622 } else { |
| 624 #if defined(TOOLKIT_VIEWS) | 623 #if defined(TOOLKIT_VIEWS) |
| 625 // TOOLKIT_VIEWS' resize logic flow matches windows. so we go ahead and | 624 // TOOLKIT_VIEWS' resize logic flow matches windows. so we go ahead and |
| 626 // size the widget. In GTK+, the size of the widget is determined by its | 625 // size the widget. In GTK+, the size of the widget is determined by its |
| 627 // children. | 626 // children. |
| 628 gtk_widget_set_size_request(view_.get(), width, height); | 627 gtk_widget_set_size_request(view_.get(), width, height); |
| 629 #endif | 628 #endif |
| 630 } | 629 } |
| 630 |
| 631 // Update the size of the RWH. | 631 // Update the size of the RWH. |
| 632 if (requested_size_.width() != width || | 632 if (requested_size_.width() != width || |
| 633 requested_size_.height() != height) { | 633 requested_size_.height() != height) { |
| 634 requested_size_ = gfx::Size(width, height); | 634 requested_size_ = gfx::Size(width, height); |
| 635 host_->WasResized(); | 635 host_->WasResized(); |
| 636 } | 636 } |
| 637 } | 637 } |
| 638 | 638 |
| 639 void RenderWidgetHostViewGtk::SetBounds(const gfx::Rect& rect) { |
| 640 // This is called when webkit has sent us a Move message. |
| 641 if (IsPopup()) { |
| 642 gtk_window_move(GTK_WINDOW(gtk_widget_get_toplevel(view_.get())), |
| 643 rect.x(), rect.y()); |
| 644 } |
| 645 |
| 646 SetSize(rect.size()); |
| 647 } |
| 648 |
| 639 gfx::NativeView RenderWidgetHostViewGtk::GetNativeView() { | 649 gfx::NativeView RenderWidgetHostViewGtk::GetNativeView() { |
| 640 return view_.get(); | 650 return view_.get(); |
| 641 } | 651 } |
| 642 | 652 |
| 643 void RenderWidgetHostViewGtk::MovePluginWindows( | 653 void RenderWidgetHostViewGtk::MovePluginWindows( |
| 644 const std::vector<webkit::npapi::WebPluginGeometry>& moves) { | 654 const std::vector<webkit::npapi::WebPluginGeometry>& moves) { |
| 645 for (size_t i = 0; i < moves.size(); ++i) { | 655 for (size_t i = 0; i < moves.size(); ++i) { |
| 646 plugin_container_manager_.MovePluginContainer(moves[i]); | 656 plugin_container_manager_.MovePluginContainer(moves[i]); |
| 647 } | 657 } |
| 648 } | 658 } |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 } | 1155 } |
| 1146 | 1156 |
| 1147 // static | 1157 // static |
| 1148 RenderWidgetHostView* | 1158 RenderWidgetHostView* |
| 1149 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1159 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
| 1150 gfx::NativeView widget) { | 1160 gfx::NativeView widget) { |
| 1151 gpointer user_data = g_object_get_data(G_OBJECT(widget), | 1161 gpointer user_data = g_object_get_data(G_OBJECT(widget), |
| 1152 kRenderWidgetHostViewKey); | 1162 kRenderWidgetHostViewKey); |
| 1153 return reinterpret_cast<RenderWidgetHostView*>(user_data); | 1163 return reinterpret_cast<RenderWidgetHostView*>(user_data); |
| 1154 } | 1164 } |
| OLD | NEW |