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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // context with |context| as the parent. | 188 // context with |context| as the parent. |
189 ScopedStyleContext AppendCssNodeToStyleContext(GtkStyleContext* context, | 189 ScopedStyleContext AppendCssNodeToStyleContext(GtkStyleContext* context, |
190 const std::string& css_node); | 190 const std::string& css_node); |
191 | 191 |
192 // Parses |css_selector| into a GtkStyleContext. The format is a | 192 // Parses |css_selector| into a GtkStyleContext. The format is a |
193 // sequence of whitespace-separated objects. Each object may have at | 193 // sequence of whitespace-separated objects. Each object may have at |
194 // most one object name at the beginning of the string, and any number | 194 // most one object name at the beginning of the string, and any number |
195 // of '.'-prefixed classes and ':'-prefixed pseudoclasses. An example | 195 // of '.'-prefixed classes and ':'-prefixed pseudoclasses. An example |
196 // is "GtkButton.button.suggested-action:hover:active". The caller | 196 // is "GtkButton.button.suggested-action:hover:active". The caller |
197 // must g_object_unref() the returned context. | 197 // must g_object_unref() the returned context. |
198 ScopedStyleContext GetStyleContextFromCss(const char* css_selector); | 198 ScopedStyleContext GetStyleContextFromCss(const std::string& css_selector); |
199 | 199 |
200 SkColor GetFgColorFromStyleContext(GtkStyleContext* context); | 200 SkColor GetFgColorFromStyleContext(GtkStyleContext* context); |
201 | 201 |
202 // Overrides properties on |context| and all its parents with those | 202 // Overrides properties on |context| and all its parents with those |
203 // provided by |css|. | 203 // provided by |css|. |
204 void ApplyCssToContext(GtkStyleContext* context, const char* css); | 204 void ApplyCssToContext(GtkStyleContext* context, const std::string& css); |
205 | 205 |
206 // Get the 'color' property from the style context created by | 206 // Get the 'color' property from the style context created by |
207 // GetStyleContextFromCss(|css_selector|). | 207 // GetStyleContextFromCss(|css_selector|). |
208 SkColor GetFgColor(const char* css_selector); | 208 SkColor GetFgColor(const std::string& css_selector); |
209 | 209 |
210 // Renders the backgrounds of all ancestors of |context|, then renders | 210 // Renders the backgrounds of all ancestors of |context|, then renders |
211 // the background for |context| itself. | 211 // the background for |context| itself. |
212 void RenderBackground(const gfx::Size& size, | 212 void RenderBackground(const gfx::Size& size, |
213 cairo_t* cr, | 213 cairo_t* cr, |
214 GtkStyleContext* context); | 214 GtkStyleContext* context); |
215 | 215 |
216 // Renders a background from the style context created by | 216 // Renders a background from the style context created by |
217 // GetStyleContextFromCss(|css_selector|) into a 24x24 bitmap and | 217 // GetStyleContextFromCss(|css_selector|) into a 24x24 bitmap and |
218 // returns the average color. | 218 // returns the average color. |
219 SkColor GetBgColor(const char* css_selector); | 219 SkColor GetBgColor(const std::string& css_selector); |
220 | 220 |
221 // Renders the border from the style context created by | 221 // Renders the border from the style context created by |
222 // GetStyleContextFromCss(|css_selector|) into a 24x24 bitmap and | 222 // GetStyleContextFromCss(|css_selector|) into a 24x24 bitmap and |
223 // returns the average color. | 223 // returns the average color. |
224 SkColor GetBorderColor(const char* css_selector); | 224 SkColor GetBorderColor(const std::string& css_selector); |
225 | 225 |
226 // On Gtk3.20 or later, behaves like GetBgColor. Otherwise, returns | 226 // On Gtk3.20 or later, behaves like GetBgColor. Otherwise, returns |
227 // the background-color property. | 227 // the background-color property. |
228 SkColor GetSelectionBgColor(const char* css_selector); | 228 SkColor GetSelectionBgColor(const std::string& css_selector); |
229 | 229 |
230 // Get the color of the GtkSeparator specified by |css_selector|. | 230 // Get the color of the GtkSeparator specified by |css_selector|. |
231 SkColor GetSeparatorColor(const char* css_selector); | 231 SkColor GetSeparatorColor(const std::string& css_selector); |
232 #endif | 232 #endif |
233 | 233 |
234 } // namespace libgtkui | 234 } // namespace libgtkui |
235 | 235 |
236 #endif // CHROME_BROWSER_UI_LIBGTKUI_GTK_UTIL_H_ | 236 #endif // CHROME_BROWSER_UI_LIBGTKUI_GTK_UTIL_H_ |
OLD | NEW |