| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 471 |
| 469 AddBorders(context); | 472 AddBorders(context); |
| 470 PixelSurface surface; | 473 PixelSurface surface; |
| 471 RenderBackground(gfx::Size(1, 1), surface.cairo(), context); | 474 RenderBackground(gfx::Size(1, 1), surface.cairo(), context); |
| 472 gtk_render_frame(context, surface.cairo(), 0, 0, 1, 1); | 475 gtk_render_frame(context, surface.cairo(), 0, 0, 1, 1); |
| 473 return surface.GetPixelValue(); | 476 return surface.GetPixelValue(); |
| 474 } | 477 } |
| 475 #endif | 478 #endif |
| 476 | 479 |
| 477 } // namespace libgtkui | 480 } // namespace libgtkui |
| OLD | NEW |