| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "views/controls/native_control_gtk.h" | 5 #include "views/controls/native_control_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "views/focus/focus_manager.h" | 10 #include "views/focus/focus_manager.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // controls need a parent widget to function properly. | 42 // controls need a parent widget to function properly. |
| 43 CreateNativeControl(); | 43 CreateNativeControl(); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 void NativeControlGtk::VisibilityChanged(View* starting_from, bool is_visible) { | 47 void NativeControlGtk::VisibilityChanged(View* starting_from, bool is_visible) { |
| 48 if (!is_visible) { | 48 if (!is_visible) { |
| 49 if (native_view()) { | 49 if (native_view()) { |
| 50 // We destroy the child widget when we become invisible because of the | 50 // We destroy the child widget when we become invisible because of the |
| 51 // performance cost of maintaining widgets that aren't currently needed. | 51 // performance cost of maintaining widgets that aren't currently needed. |
| 52 GtkWidget* widget = native_view(); | |
| 53 Detach(); | 52 Detach(); |
| 54 gtk_widget_destroy(widget); | 53 // Make sure that Detach destroyed the widget. |
| 54 DCHECK(!native_view()); |
| 55 } | 55 } |
| 56 } else if (!native_view()) { | 56 } else if (!native_view()) { |
| 57 if (GetWidget()) | 57 if (GetWidget()) |
| 58 CreateNativeControl(); | 58 CreateNativeControl(); |
| 59 } else { | 59 } else { |
| 60 // The view becomes visible after native control is created. | 60 // The view becomes visible after native control is created. |
| 61 // Layout now. | 61 // Layout now. |
| 62 Layout(); | 62 Layout(); |
| 63 } | 63 } |
| 64 } | 64 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 89 // TODO(jcampan): http://crbug.com/21378 Reenable this NOTREACHED() when the | 89 // TODO(jcampan): http://crbug.com/21378 Reenable this NOTREACHED() when the |
| 90 // options page is only based on views. | 90 // options page is only based on views. |
| 91 // NOTREACHED(); | 91 // NOTREACHED(); |
| 92 NOTIMPLEMENTED(); | 92 NOTIMPLEMENTED(); |
| 93 return; | 93 return; |
| 94 } | 94 } |
| 95 focus_manager->SetFocusedView(control->focus_view()); | 95 focus_manager->SetFocusedView(control->focus_view()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // namespace views | 98 } // namespace views |
| OLD | NEW |