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/renderer_host/render_widget_host_view_gtk.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_gtk.h" |
6 | 6 |
7 #include <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
9 #include <gdk/gdkkeysyms.h> | 9 #include <gdk/gdkkeysyms.h> |
10 #include <gdk/gdkx.h> | 10 #include <gdk/gdkx.h> |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 gtk_window_resize(window, bounds.width(), bounds.height()); | 676 gtk_window_resize(window, bounds.width(), bounds.height()); |
677 gtk_window_fullscreen(window); | 677 gtk_window_fullscreen(window); |
678 DoPopupOrFullscreenInit(window, bounds); | 678 DoPopupOrFullscreenInit(window, bounds); |
679 } | 679 } |
680 | 680 |
681 RenderWidgetHost* RenderWidgetHostViewGtk::GetRenderWidgetHost() const { | 681 RenderWidgetHost* RenderWidgetHostViewGtk::GetRenderWidgetHost() const { |
682 return host_; | 682 return host_; |
683 } | 683 } |
684 | 684 |
685 void RenderWidgetHostViewGtk::WasShown() { | 685 void RenderWidgetHostViewGtk::WasShown() { |
686 if (!is_hidden_) | 686 if (!host_ || !is_hidden_) |
687 return; | 687 return; |
688 | 688 |
689 if (web_contents_switch_paint_time_.is_null()) | 689 if (web_contents_switch_paint_time_.is_null()) |
690 web_contents_switch_paint_time_ = base::TimeTicks::Now(); | 690 web_contents_switch_paint_time_ = base::TimeTicks::Now(); |
691 is_hidden_ = false; | 691 is_hidden_ = false; |
| 692 |
692 host_->WasShown(); | 693 host_->WasShown(); |
693 } | 694 } |
694 | 695 |
695 void RenderWidgetHostViewGtk::WasHidden() { | 696 void RenderWidgetHostViewGtk::WasHidden() { |
696 if (is_hidden_) | 697 if (!host_ || is_hidden_) |
697 return; | 698 return; |
698 | 699 |
699 // If we receive any more paint messages while we are hidden, we want to | 700 // If we receive any more paint messages while we are hidden, we want to |
700 // ignore them so we don't re-allocate the backing store. We will paint | 701 // ignore them so we don't re-allocate the backing store. We will paint |
701 // everything again when we become selected again. | 702 // everything again when we become selected again. |
702 is_hidden_ = true; | 703 is_hidden_ = true; |
703 | 704 |
704 // If we have a renderer, then inform it that we are being hidden so it can | 705 // If we have a renderer, then inform it that we are being hidden so it can |
705 // reduce its resource utilization. | 706 // reduce its resource utilization. |
706 host_->WasHidden(); | 707 host_->WasHidden(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 bool RenderWidgetHostViewGtk::Send(IPC::Message* message) { | 786 bool RenderWidgetHostViewGtk::Send(IPC::Message* message) { |
786 return host_->Send(message); | 787 return host_->Send(message); |
787 } | 788 } |
788 | 789 |
789 bool RenderWidgetHostViewGtk::IsSurfaceAvailableForCopy() const { | 790 bool RenderWidgetHostViewGtk::IsSurfaceAvailableForCopy() const { |
790 return true; | 791 return true; |
791 } | 792 } |
792 | 793 |
793 void RenderWidgetHostViewGtk::Show() { | 794 void RenderWidgetHostViewGtk::Show() { |
794 gtk_widget_show(view_.get()); | 795 gtk_widget_show(view_.get()); |
| 796 WasShown(); |
795 } | 797 } |
796 | 798 |
797 void RenderWidgetHostViewGtk::Hide() { | 799 void RenderWidgetHostViewGtk::Hide() { |
798 gtk_widget_hide(view_.get()); | 800 gtk_widget_hide(view_.get()); |
| 801 WasHidden(); |
799 } | 802 } |
800 | 803 |
801 bool RenderWidgetHostViewGtk::IsShowing() { | 804 bool RenderWidgetHostViewGtk::IsShowing() { |
802 return gtk_widget_get_visible(view_.get()); | 805 return gtk_widget_get_visible(view_.get()); |
803 } | 806 } |
804 | 807 |
805 gfx::Rect RenderWidgetHostViewGtk::GetViewBounds() const { | 808 gfx::Rect RenderWidgetHostViewGtk::GetViewBounds() const { |
806 GdkWindow* gdk_window = gtk_widget_get_window(view_.get()); | 809 GdkWindow* gdk_window = gtk_widget_get_window(view_.get()); |
807 if (!gdk_window) | 810 if (!gdk_window) |
808 return gfx::Rect(requested_size_); | 811 return gfx::Rect(requested_size_); |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 gfx::PluginWindowHandle id) { | 1575 gfx::PluginWindowHandle id) { |
1573 plugin_container_manager_.CreatePluginContainer(id); | 1576 plugin_container_manager_.CreatePluginContainer(id); |
1574 } | 1577 } |
1575 | 1578 |
1576 void RenderWidgetHostViewGtk::OnDestroyPluginContainer( | 1579 void RenderWidgetHostViewGtk::OnDestroyPluginContainer( |
1577 gfx::PluginWindowHandle id) { | 1580 gfx::PluginWindowHandle id) { |
1578 plugin_container_manager_.DestroyPluginContainer(id); | 1581 plugin_container_manager_.DestroyPluginContainer(id); |
1579 } | 1582 } |
1580 | 1583 |
1581 } // namespace content | 1584 } // namespace content |
OLD | NEW |