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/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 GtkWidget* parent = gtk_widget_get_parent(widget); |
|
Evan Martin
2012/01/05 22:50:37
Do we need to null-check widget first here? We do
Elliot Glaysher
2012/01/05 23:19:49
Good catch
| |
| 169 DCHECK_EQ(widget->parent, expanded_); | 169 if (widget && parent) { |
| 170 DCHECK_EQ(parent, expanded_); | |
| 170 gtk_container_remove(GTK_CONTAINER(expanded_), widget); | 171 gtk_container_remove(GTK_CONTAINER(expanded_), widget); |
| 171 } | 172 } |
| 172 } | 173 } |
| 173 | 174 |
| 174 void TabContentsContainerGtk::Observe( | 175 void TabContentsContainerGtk::Observe( |
| 175 int type, | 176 int type, |
| 176 const content::NotificationSource& source, | 177 const content::NotificationSource& source, |
| 177 const content::NotificationDetails& details) { | 178 const content::NotificationDetails& details) { |
| 178 DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED); | 179 DCHECK(type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED); |
| 179 | 180 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 g_value_set_int(&value, allocation->width - requisition.width); | 241 g_value_set_int(&value, allocation->width - requisition.width); |
| 241 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 242 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
| 242 status->widget(), "x", &value); | 243 status->widget(), "x", &value); |
| 243 | 244 |
| 244 int child_y = std::max(allocation->height - requisition.height, 0); | 245 int child_y = std::max(allocation->height - requisition.height, 0); |
| 245 g_value_set_int(&value, child_y + status->y_offset()); | 246 g_value_set_int(&value, child_y + status->y_offset()); |
| 246 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 247 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
| 247 status->widget(), "y", &value); | 248 status->widget(), "y", &value); |
| 248 g_value_unset(&value); | 249 g_value_unset(&value); |
| 249 } | 250 } |
| OLD | NEW |