summaryrefslogtreecommitdiffstats
path: root/views/controls
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-25 23:09:39 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-25 23:09:39 +0000
commit154a9820511c94bdcc8a69a3f7cc69b56ea75cd1 (patch)
tree41404665474d256283ab285ca688c5913d3eb22c /views/controls
parent2186fec4df1dde813a12011eb1ea650ce8470ea2 (diff)
downloadchromium_src-154a9820511c94bdcc8a69a3f7cc69b56ea75cd1.zip
chromium_src-154a9820511c94bdcc8a69a3f7cc69b56ea75cd1.tar.gz
chromium_src-154a9820511c94bdcc8a69a3f7cc69b56ea75cd1.tar.bz2
Fixed a few bugs in view/gtk framework
NativeControlGtk * Layout if the visibility is changed after the native view is created. (I also added DCHECK(GetWidget()) to make sure Wiget is available at this point) NativeViewHostGtk * decrement the native_view's ref count only if it still has a parent. * create fixed in AddedToWidget if fixed_ does not exist. This can happen when a view is removed, then added. BUG=none TEST=unit test for last 2 bugs is added to view_unittest.cc (ChangeVisibility). Review URL: http://codereview.chromium.org/219035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27282 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r--views/controls/native/native_view_host_gtk.cc5
-rw-r--r--views/controls/native_control_gtk.cc28
2 files changed, 22 insertions, 11 deletions
diff --git a/views/controls/native/native_view_host_gtk.cc b/views/controls/native/native_view_host_gtk.cc
index ea9bd62..581f08d 100644
--- a/views/controls/native/native_view_host_gtk.cc
+++ b/views/controls/native/native_view_host_gtk.cc
@@ -76,11 +76,12 @@ void NativeViewHostGtk::NativeViewDetaching() {
installed_clip_ = false;
- // Release ownership back to the caller.
- gtk_widget_unref(host_->native_view());
+ g_object_unref(G_OBJECT(host_->native_view()));
}
void NativeViewHostGtk::AddedToWidget() {
+ if (!fixed_)
+ CreateFixed(false);
if (gtk_widget_get_parent(fixed_))
GetHostWidget()->ReparentChild(fixed_);
else
diff --git a/views/controls/native_control_gtk.cc b/views/controls/native_control_gtk.cc
index 082e610..49453ef 100644
--- a/views/controls/native_control_gtk.cc
+++ b/views/controls/native_control_gtk.cc
@@ -35,21 +35,31 @@ void NativeControlGtk::ViewHierarchyChanged(bool is_add, View* parent,
// Call the base class to hide the view if we're being removed.
NativeViewHost::ViewHierarchyChanged(is_add, parent, child);
- // Create the widget when we're added to a valid Widget. Many controls need a
- // parent widget to function properly.
- if (is_add && GetWidget() && !native_view())
+ if (!is_add && child == this && native_view()) {
+ Detach();
+ } else if (is_add && GetWidget() && !native_view()) {
+ // Create the widget when we're added to a valid Widget. Many
+ // controls need a parent widget to function properly.
CreateNativeControl();
+ }
}
void NativeControlGtk::VisibilityChanged(View* starting_from, bool is_visible) {
if (!is_visible) {
- // We destroy the child widget when we become invisible because of the
- // performance cost of maintaining widgets that aren't currently needed.
- GtkWidget* widget = native_view();
- Detach();
- gtk_widget_destroy(widget);
+ if (native_view()) {
+ // We destroy the child widget when we become invisible because of the
+ // performance cost of maintaining widgets that aren't currently needed.
+ GtkWidget* widget = native_view();
+ Detach();
+ gtk_widget_destroy(widget);
+ }
} else if (!native_view()) {
- CreateNativeControl();
+ if (GetWidget())
+ CreateNativeControl();
+ } else {
+ // The view becomes visible after native control is created.
+ // Layout now.
+ Layout();
}
}