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

Side by Side Diff: views/controls/native/native_view_host_gtk.h

Issue 159751: Fix leak of GtkWidgets in NativeViewHost, and in doing so fix a crash on shut... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #ifndef VIEWS_CONTROLS_NATIVE_HOST_VIEW_GTK_H_ 5 #ifndef VIEWS_CONTROLS_NATIVE_HOST_VIEW_GTK_H_
6 #define VIEWS_CONTROLS_NATIVE_HOST_VIEW_GTK_H_ 6 #define VIEWS_CONTROLS_NATIVE_HOST_VIEW_GTK_H_
7 7
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #include <string> 9 #include <string>
10 10
11 #include "base/gfx/rect.h" 11 #include "base/gfx/rect.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "views/controls/native/native_view_host_wrapper.h" 13 #include "views/controls/native/native_view_host_wrapper.h"
14 14
15 namespace views { 15 namespace views {
16 16
17 class View; 17 class View;
18 class WidgetGtk; 18 class WidgetGtk;
19 19
20 // Note that the NativeViewHostGtk assumes ownership of the GtkWidget attached
21 // to it for the duration of its attachment. This is so the NativeViewHostGtk
22 // can safely reparent the GtkWidget in multiple passes without having to worry
23 // about the GtkWidget's refcnt falling to 0.
20 class NativeViewHostGtk : public NativeViewHostWrapper { 24 class NativeViewHostGtk : public NativeViewHostWrapper {
21 public: 25 public:
22 explicit NativeViewHostGtk(NativeViewHost* host); 26 explicit NativeViewHostGtk(NativeViewHost* host);
23 virtual ~NativeViewHostGtk(); 27 virtual ~NativeViewHostGtk();
24 28
25 // Overridden from NativeViewHostWrapper: 29 // Overridden from NativeViewHostWrapper:
26 virtual void NativeViewAttached(); 30 virtual void NativeViewAttached();
27 virtual void NativeViewDetaching(); 31 virtual void NativeViewDetaching();
28 virtual void AddedToWidget(); 32 virtual void AddedToWidget();
29 virtual void RemovedFromWidget(); 33 virtual void RemovedFromWidget();
30 virtual void InstallClip(int x, int y, int w, int h); 34 virtual void InstallClip(int x, int y, int w, int h);
31 virtual bool HasInstalledClip(); 35 virtual bool HasInstalledClip();
32 virtual void UninstallClip(); 36 virtual void UninstallClip();
33 virtual void ShowWidget(int x, int y, int w, int h); 37 virtual void ShowWidget(int x, int y, int w, int h);
34 virtual void HideWidget(); 38 virtual void HideWidget();
35 virtual void SetFocus(); 39 virtual void SetFocus();
36 40
37 private: 41 private:
38 // Create and Destroy the GtkFixed that performs clipping on our hosted 42 // Create and Destroy the GtkFixed that performs clipping on our hosted
39 // GtkWidget. |needs_window| is true when a clip is installed and implies the 43 // GtkWidget. |needs_window| is true when a clip is installed and implies the
40 // fixed is backed by a X Window which actually performs the clipping. 44 // fixed is backed by a X Window which actually performs the clipping.
41 // It's kind of retarded that Gtk/Cairo doesn't clip painting of child windows 45 // It's kind of retarded that Gtk/Cairo doesn't clip painting of child windows
42 // regardless of whether or not there's an X Window. It's not that hard. 46 // regardless of whether or not there's an X Window. It's not that hard.
43 void CreateFixed(bool needs_window); 47 void CreateFixed(bool needs_window);
44 48
45 // DestroyFixed returns true if an associated GtkWidget was addref'ed. 49 // DestroyFixed returns true if an associated GtkWidget was addref'ed.
jcampan 2009/07/31 23:51:56 It does not return anything anymore, fix comment.
46 // It does this because when the fixed is destroyed the refcount for the 50 // It does this because when the fixed is destroyed the refcount for the
47 // contained GtkWidget is decremented, which may cause it to be destroyed 51 // contained GtkWidget is decremented, which may cause it to be destroyed
48 // which we do not want. If this function returns true, the caller is 52 // which we do not want.
49 // responsible for unrefing the GtkWidget after it has been added to the new 53 void DestroyFixed();
50 // container.
51 bool DestroyFixed();
52 54
53 WidgetGtk* GetHostWidget() const; 55 WidgetGtk* GetHostWidget() const;
54 56
55 // Invoked from the 'destroy' signal. 57 // Invoked from the 'destroy' signal.
56 static void CallDestroy(GtkObject* object, NativeViewHostGtk* host); 58 static void CallDestroy(GtkObject* object, NativeViewHostGtk* host);
57 59
58 // Our associated NativeViewHost. 60 // Our associated NativeViewHost.
59 NativeViewHost* host_; 61 NativeViewHost* host_;
60 62
61 // Have we installed a region on the gfx::NativeView used to clip to only the 63 // Have we installed a region on the gfx::NativeView used to clip to only the
(...skipping 11 matching lines...) Expand all
73 // clipping). 75 // clipping).
74 GtkWidget* fixed_; 76 GtkWidget* fixed_;
75 77
76 DISALLOW_COPY_AND_ASSIGN(NativeViewHostGtk); 78 DISALLOW_COPY_AND_ASSIGN(NativeViewHostGtk);
77 }; 79 };
78 80
79 } // namespace views 81 } // namespace views
80 82
81 #endif // VIEWS_CONTROLS_NATIVE_HOST_VIEW_GTK_H_ 83 #endif // VIEWS_CONTROLS_NATIVE_HOST_VIEW_GTK_H_
82 84
OLDNEW
« no previous file with comments | « chrome/browser/views/location_bar_view.cc ('k') | views/controls/native/native_view_host_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698