Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 9703044: aura: fix hang when the content window is removed from the tree while a swap is pending (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "content/browser/renderer_host/backing_store_skia.h" 10 #include "content/browser/renderer_host/backing_store_skia.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // because clang doesn't like implementing multiple interfaces that have 105 // because clang doesn't like implementing multiple interfaces that have
106 // methods with the same name. This object is owned by the 106 // methods with the same name. This object is owned by the
107 // RenderWidgetHostViewAura. 107 // RenderWidgetHostViewAura.
108 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver { 108 class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver {
109 public: 109 public:
110 WindowObserver(RenderWidgetHostViewAura* view) : view_(view) {} 110 WindowObserver(RenderWidgetHostViewAura* view) : view_(view) {}
111 virtual ~WindowObserver() {} 111 virtual ~WindowObserver() {}
112 112
113 // Overridden from aura::WindowObserver: 113 // Overridden from aura::WindowObserver:
114 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE { 114 virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE {
115 // TODO: It would be better to not use aura::RootWindow here 115 view_->RemovingFromRootWindow();
116 ui::Compositor* compositor = view_->GetCompositor();
117 if (compositor && compositor->HasObserver(view_))
118 compositor->RemoveObserver(view_);
119 } 116 }
120 117
121 private: 118 private:
122 RenderWidgetHostViewAura* view_; 119 RenderWidgetHostViewAura* view_;
123 120
124 DISALLOW_COPY_AND_ASSIGN(WindowObserver); 121 DISALLOW_COPY_AND_ASSIGN(WindowObserver);
125 }; 122 };
126 123
127 class RenderWidgetHostViewAura::ResizeLock : 124 class RenderWidgetHostViewAura::ResizeLock :
128 public base::SupportsWeakPtr<RenderWidgetHostViewAura::ResizeLock> { 125 public base::SupportsWeakPtr<RenderWidgetHostViewAura::ResizeLock> {
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 void RenderWidgetHostViewAura::OnActivated() { 996 void RenderWidgetHostViewAura::OnActivated() {
1000 } 997 }
1001 998
1002 void RenderWidgetHostViewAura::OnLostActive() { 999 void RenderWidgetHostViewAura::OnLostActive() {
1003 } 1000 }
1004 1001
1005 //////////////////////////////////////////////////////////////////////////////// 1002 ////////////////////////////////////////////////////////////////////////////////
1006 // RenderWidgetHostViewAura, ui::CompositorDelegate implementation: 1003 // RenderWidgetHostViewAura, ui::CompositorDelegate implementation:
1007 1004
1008 void RenderWidgetHostViewAura::OnCompositingEnded(ui::Compositor* compositor) { 1005 void RenderWidgetHostViewAura::OnCompositingEnded(ui::Compositor* compositor) {
1009 for (std::vector< base::Callback<void(void)> >::const_iterator 1006 RunCompositingCallbacks();
1010 it = on_compositing_ended_callbacks_.begin();
1011 it != on_compositing_ended_callbacks_.end(); ++it) {
1012 it->Run();
1013 }
1014 on_compositing_ended_callbacks_.clear();
1015 compositor->RemoveObserver(this); 1007 compositor->RemoveObserver(this);
1016 } 1008 }
1017 1009
1018 //////////////////////////////////////////////////////////////////////////////// 1010 ////////////////////////////////////////////////////////////////////////////////
1019 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: 1011 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation:
1020 1012
1021 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) { 1013 void RenderWidgetHostViewAura::OnLostResources(ui::Compositor* compositor) {
1022 image_transport_clients_.clear(); 1014 image_transport_clients_.clear();
1023 current_surface_ = 0; 1015 current_surface_ = 0;
1024 UpdateExternalTexture(); 1016 UpdateExternalTexture();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 gfx::Rect rect = window_->bounds(); 1109 gfx::Rect rect = window_->bounds();
1118 int border_x = rect.width() * kMouseLockBorderPercentage / 100; 1110 int border_x = rect.width() * kMouseLockBorderPercentage / 100;
1119 int border_y = rect.height() * kMouseLockBorderPercentage / 100; 1111 int border_y = rect.height() * kMouseLockBorderPercentage / 100;
1120 1112
1121 return global_mouse_position_.x() < rect.x() + border_x || 1113 return global_mouse_position_.x() < rect.x() + border_x ||
1122 global_mouse_position_.x() > rect.right() - border_x || 1114 global_mouse_position_.x() > rect.right() - border_x ||
1123 global_mouse_position_.y() < rect.y() + border_y || 1115 global_mouse_position_.y() < rect.y() + border_y ||
1124 global_mouse_position_.y() > rect.bottom() - border_y; 1116 global_mouse_position_.y() > rect.bottom() - border_y;
1125 } 1117 }
1126 1118
1119 void RenderWidgetHostViewAura::RunCompositingCallbacks() {
1120 for (std::vector< base::Callback<void(void)> >::const_iterator
1121 it = on_compositing_ended_callbacks_.begin();
1122 it != on_compositing_ended_callbacks_.end(); ++it) {
1123 it->Run();
1124 }
1125 on_compositing_ended_callbacks_.clear();
1126 }
1127
1128 void RenderWidgetHostViewAura::RemovingFromRootWindow() {
1129 RunCompositingCallbacks();
sky 2012/03/15 00:30:41 Can you add a comment as to why we need to do this
piman 2012/03/15 00:38:16 Done.
1130 ui::Compositor* compositor = GetCompositor();
1131 if (compositor && compositor->HasObserver(this))
1132 compositor->RemoveObserver(this);
1133 }
1134
1127 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() { 1135 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() {
1128 aura::RootWindow* root_window = window_->GetRootWindow(); 1136 aura::RootWindow* root_window = window_->GetRootWindow();
1129 return root_window ? root_window->compositor() : NULL; 1137 return root_window ? root_window->compositor() : NULL;
1130 } 1138 }
1131 1139
1132 //////////////////////////////////////////////////////////////////////////////// 1140 ////////////////////////////////////////////////////////////////////////////////
1133 // RenderWidgetHostView, public: 1141 // RenderWidgetHostView, public:
1134 1142
1135 // static 1143 // static
1136 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( 1144 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
1137 RenderWidgetHost* widget) { 1145 RenderWidgetHost* widget) {
1138 return new RenderWidgetHostViewAura(widget); 1146 return new RenderWidgetHostViewAura(widget);
1139 } 1147 }
1140 1148
1141 // static 1149 // static
1142 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( 1150 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo(
1143 WebKit::WebScreenInfo* results) { 1151 WebKit::WebScreenInfo* results) {
1144 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize(); 1152 const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize();
1145 results->rect = WebKit::WebRect(0, 0, size.width(), size.height()); 1153 results->rect = WebKit::WebRect(0, 0, size.width(), size.height());
1146 results->availableRect = results->rect; 1154 results->availableRect = results->rect;
1147 // TODO(derat): Don't hardcode this? 1155 // TODO(derat): Don't hardcode this?
1148 results->depth = 24; 1156 results->depth = 24;
1149 results->depthPerComponent = 8; 1157 results->depthPerComponent = 8;
1150 results->verticalDPI = 96; 1158 results->verticalDPI = 96;
1151 results->horizontalDPI = 96; 1159 results->horizontalDPI = 96;
1152 } 1160 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698