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

Unified Diff: chrome/browser/ui/libgtkui/gtk_util.cc

Issue 2696903003: Gtk3: Fix memory leaks (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/libgtkui/gtk_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/libgtkui/gtk_util.cc
diff --git a/chrome/browser/ui/libgtkui/gtk_util.cc b/chrome/browser/ui/libgtkui/gtk_util.cc
index 87579d29aa07b808abc29b0866c2c9e670e778d6..a17fd4ba0a0da527762f12780751685e8203ca34 100644
--- a/chrome/browser/ui/libgtkui/gtk_util.cc
+++ b/chrome/browser/ui/libgtkui/gtk_util.cc
@@ -305,8 +305,7 @@ ScopedStyleContext AppendCssNodeToStyleContext(GtkStyleContext* context,
{"visited", GTK_STATE_FLAG_VISITED},
{"checked", GTK_STATE_FLAG_CHECKED},
};
- GtkStateFlags state =
- context ? gtk_style_context_get_state(context) : GTK_STATE_FLAG_NORMAL;
+ GtkStateFlags state = GTK_STATE_FLAG_NORMAL;
base::StringTokenizer t(css_node, ".:#");
t.set_options(base::StringTokenizer::RETURN_DELIMS);
while (t.GetNext()) {
@@ -374,9 +373,26 @@ ScopedStyleContext AppendCssNodeToStyleContext(GtkStyleContext* context,
// widgets specially if they want to.
gtk_widget_path_iter_add_class(path, -1, "chromium");
+ if (GtkVersionCheck(3, 14)) {
+ static auto* _gtk_widget_path_iter_set_state =
+ reinterpret_cast<void (*)(GtkWidgetPath*, gint, GtkStateFlags)>(
+ dlsym(GetGtk3SharedLibrary(), "gtk_widget_path_iter_set_state"));
+ DCHECK(_gtk_widget_path_iter_set_state);
+ _gtk_widget_path_iter_set_state(path, -1, state);
+ }
+
ScopedStyleContext child_context(gtk_style_context_new());
gtk_style_context_set_path(child_context, path);
- gtk_style_context_set_state(child_context, state);
+ if (GtkVersionCheck(3, 14)) {
+ gtk_style_context_set_state(child_context, state);
+ } else {
+ GtkStateFlags child_state = state;
+ if (context) {
+ child_state = static_cast<GtkStateFlags>(
+ child_state | gtk_style_context_get_state(context));
+ }
+ gtk_style_context_set_state(child_context, child_state);
+ }
gtk_style_context_set_parent(child_context, context);
gtk_widget_path_unref(path);
return child_context;
« no previous file with comments | « chrome/browser/ui/libgtkui/gtk_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698