OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/libgtkui/gtk_util.h" | 5 #include "chrome/browser/ui/libgtkui/gtk_util.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
9 #include <gdk/gdkx.h> | 9 #include <gdk/gdkx.h> |
10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 context = AppendNode(context, widget_type); | 340 context = AppendNode(context, widget_type); |
341 } | 341 } |
342 return context; | 342 return context; |
343 } | 343 } |
344 | 344 |
345 SkColor GdkRgbaToSkColor(const GdkRGBA& color) { | 345 SkColor GdkRgbaToSkColor(const GdkRGBA& color) { |
346 return SkColorSetARGB(color.alpha * 255, color.red * 255, color.green * 255, | 346 return SkColorSetARGB(color.alpha * 255, color.red * 255, color.green * 255, |
347 color.blue * 255); | 347 color.blue * 255); |
348 } | 348 } |
349 | 349 |
350 SkColor GetFgColor(const char* css_selector) { | 350 SkColor SkColorFromStyleContext(GtkStyleContext* context) { |
351 auto context = GetStyleContextFromCss(css_selector); | |
352 GdkRGBA color; | 351 GdkRGBA color; |
353 gtk_style_context_get_color(context, gtk_style_context_get_state(context), | 352 gtk_style_context_get_color(context, gtk_style_context_get_state(context), |
354 &color); | 353 &color); |
355 return GdkRgbaToSkColor(color); | 354 return GdkRgbaToSkColor(color); |
356 } | 355 } |
357 | 356 |
| 357 SkColor GetFgColor(const char* css_selector) { |
| 358 return SkColorFromStyleContext(GetStyleContextFromCss(css_selector)); |
| 359 } |
| 360 |
358 GtkCssProvider* GetCssProvider(const char* css) { | 361 GtkCssProvider* GetCssProvider(const char* css) { |
359 GtkCssProvider* provider = gtk_css_provider_new(); | 362 GtkCssProvider* provider = gtk_css_provider_new(); |
360 GError* error = nullptr; | 363 GError* error = nullptr; |
361 gtk_css_provider_load_from_data(provider, css, -1, &error); | 364 gtk_css_provider_load_from_data(provider, css, -1, &error); |
362 DCHECK(!error); | 365 DCHECK(!error); |
363 return provider; | 366 return provider; |
364 } | 367 } |
365 | 368 |
366 void ApplyCssToContext(GtkStyleContext* context, GtkCssProvider* provider) { | 369 void ApplyCssToContext(GtkStyleContext* context, GtkCssProvider* provider) { |
367 while (context) { | 370 while (context) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 // background color. Only return the border color if there is one. | 484 // background color. Only return the border color if there is one. |
482 SkColor border = GetBorderColor(css_selector); | 485 SkColor border = GetBorderColor(css_selector); |
483 if (SkColorGetA(border)) | 486 if (SkColorGetA(border)) |
484 return border; | 487 return border; |
485 | 488 |
486 return GetBgColor(css_selector); | 489 return GetBgColor(css_selector); |
487 } | 490 } |
488 #endif | 491 #endif |
489 | 492 |
490 } // namespace libgtkui | 493 } // namespace libgtkui |
OLD | NEW |