| 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 #ifndef CHROME_BROWSER_UI_LIBGTKUI_GTK_UTIL_H_ | 5 #ifndef CHROME_BROWSER_UI_LIBGTKUI_GTK_UTIL_H_ |
| 6 #define CHROME_BROWSER_UI_LIBGTKUI_GTK_UTIL_H_ | 6 #define CHROME_BROWSER_UI_LIBGTKUI_GTK_UTIL_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 typedef ScopedGObject<GtkStyleContext> ScopedStyleContext; | 132 typedef ScopedGObject<GtkStyleContext> ScopedStyleContext; |
| 133 | 133 |
| 134 // Parses |css_selector| into a GtkStyleContext. The format is a | 134 // Parses |css_selector| into a GtkStyleContext. The format is a |
| 135 // sequence of whitespace-separated objects. Each object may have at | 135 // sequence of whitespace-separated objects. Each object may have at |
| 136 // most one object name at the beginning of the string, and any number | 136 // most one object name at the beginning of the string, and any number |
| 137 // of '.'-prefixed classes and ':'-prefixed pseudoclasses. An example | 137 // of '.'-prefixed classes and ':'-prefixed pseudoclasses. An example |
| 138 // is "GtkButton.button.suggested-action:hover:active". The caller | 138 // is "GtkButton.button.suggested-action:hover:active". The caller |
| 139 // must g_object_unref() the returned context. | 139 // must g_object_unref() the returned context. |
| 140 ScopedStyleContext GetStyleContextFromCss(const char* css_selector); | 140 ScopedStyleContext GetStyleContextFromCss(const char* css_selector); |
| 141 | 141 |
| 142 SkColor SkColorFromStyleContext(GtkStyleContext* context); |
| 143 |
| 142 // Removes all border-type properties on |context| and all of its parents. | 144 // Removes all border-type properties on |context| and all of its parents. |
| 143 void RemoveBorders(GtkStyleContext* context); | 145 void RemoveBorders(GtkStyleContext* context); |
| 144 | 146 |
| 145 // Get the 'color' property from the style context created by | 147 // Get the 'color' property from the style context created by |
| 146 // GetStyleContextFromCss(|css_selector|). | 148 // GetStyleContextFromCss(|css_selector|). |
| 147 SkColor GetFgColor(const char* css_selector); | 149 SkColor GetFgColor(const char* css_selector); |
| 148 | 150 |
| 149 // Renders the backgrounds of all ancestors of |context|, then renders | 151 // Renders the backgrounds of all ancestors of |context|, then renders |
| 150 // the background for |context| itself. | 152 // the background for |context| itself. |
| 151 void RenderBackground(const gfx::Size& size, | 153 void RenderBackground(const gfx::Size& size, |
| 152 cairo_t* cr, | 154 cairo_t* cr, |
| 153 GtkStyleContext* context); | 155 GtkStyleContext* context); |
| 154 | 156 |
| 155 // Renders a background from the style context created by | 157 // Renders a background from the style context created by |
| 156 // GetStyleContextFromCss(|css_selector|) into a single pixel and | 158 // GetStyleContextFromCss(|css_selector|) into a single pixel and |
| 157 // returns the color. | 159 // returns the color. |
| 158 SkColor GetBgColor(const char* css_selector); | 160 SkColor GetBgColor(const char* css_selector); |
| 159 | 161 |
| 160 // If there is a border, renders the border from the style context | 162 // If there is a border, renders the border from the style context |
| 161 // created by GetStyleContextFromCss(|css_selector|) into a single | 163 // created by GetStyleContextFromCss(|css_selector|) into a single |
| 162 // pixel and returns the color. Otherwise returns kInvalidColor. | 164 // pixel and returns the color. Otherwise returns kInvalidColor. |
| 163 SkColor GetBorderColor(const char* css_selector); | 165 SkColor GetBorderColor(const char* css_selector); |
| 164 #endif | 166 #endif |
| 165 | 167 |
| 166 } // namespace libgtkui | 168 } // namespace libgtkui |
| 167 | 169 |
| 168 #endif // CHROME_BROWSER_UI_LIBGTKUI_GTK_UTIL_H_ | 170 #endif // CHROME_BROWSER_UI_LIBGTKUI_GTK_UTIL_H_ |
| OLD | NEW |