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/ui/gtk/tab_contents_container_gtk.h" | 5 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "chrome/browser/ui/gtk/status_bubble_gtk.h" | 10 #include "chrome/browser/ui/gtk/status_bubble_gtk.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 gtk_widget_hide(widget); | 158 gtk_widget_hide(widget); |
159 | 159 |
160 tab->web_contents()->WasHidden(); | 160 tab->web_contents()->WasHidden(); |
161 } | 161 } |
162 | 162 |
163 void TabContentsContainerGtk::DetachTab(TabContentsWrapper* tab) { | 163 void TabContentsContainerGtk::DetachTab(TabContentsWrapper* tab) { |
164 gfx::NativeView widget = tab->web_contents()->GetNativeView(); | 164 gfx::NativeView widget = tab->web_contents()->GetNativeView(); |
165 | 165 |
166 // It is possible to detach an unrealized, unparented TabContents if you | 166 // It is possible to detach an unrealized, unparented TabContents if you |
167 // slow things down enough in valgrind. Might happen in the real world, too. | 167 // slow things down enough in valgrind. Might happen in the real world, too. |
168 if (widget && widget->parent) { | 168 if (widget) { |
169 DCHECK_EQ(widget->parent, expanded_); | 169 GtkWidget* parent = gtk_widget_get_parent(widget); |
170 gtk_container_remove(GTK_CONTAINER(expanded_), widget); | 170 if (parent) { |
| 171 DCHECK_EQ(parent, expanded_); |
| 172 gtk_container_remove(GTK_CONTAINER(expanded_), widget); |
| 173 } |
171 } | 174 } |
172 } | 175 } |
173 | 176 |
174 void TabContentsContainerGtk::Observe( | 177 void TabContentsContainerGtk::Observe( |
175 int type, | 178 int type, |
176 const content::NotificationSource& source, | 179 const content::NotificationSource& source, |
177 const content::NotificationDetails& details) { | 180 const content::NotificationDetails& details) { |
178 DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED); | 181 DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED); |
179 | 182 |
180 WebContentsDestroyed(content::Source<WebContents>(source).ptr()); | 183 WebContentsDestroyed(content::Source<WebContents>(source).ptr()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 g_value_set_int(&value, allocation->width - requisition.width); | 243 g_value_set_int(&value, allocation->width - requisition.width); |
241 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 244 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
242 status->widget(), "x", &value); | 245 status->widget(), "x", &value); |
243 | 246 |
244 int child_y = std::max(allocation->height - requisition.height, 0); | 247 int child_y = std::max(allocation->height - requisition.height, 0); |
245 g_value_set_int(&value, child_y + status->y_offset()); | 248 g_value_set_int(&value, child_y + status->y_offset()); |
246 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 249 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
247 status->widget(), "y", &value); | 250 status->widget(), "y", &value); |
248 g_value_unset(&value); | 251 g_value_unset(&value); |
249 } | 252 } |
OLD | NEW |