Compare commits

...

34 Commits

Author SHA1 Message Date
Matthias Clasen
8a14144658 Replace generic setter code
Instead of going through a big switch of all properties,
make the new_compute() functions for each values struct
directly set its members. This way, we can also avoid the
border-width special case for more properties.
2020-01-26 23:50:52 -05:00
Matthias Clasen
0ff6176525 Add some checking for the group splitup
Verify that we don't miss properties or have them
more than once.
2020-01-26 22:29:55 -05:00
Matthias Clasen
c30befed1e Add accounting for styles 2020-01-26 22:29:55 -05:00
Matthias Clasen
9d38806ced css: Split style into groups 2020-01-26 22:29:55 -05:00
Matthias Clasen
3cdde3fc4b css: Don't lose inset when computing shadows
This was showing up as reftest failures,
sporadically
2020-01-26 20:18:23 -05:00
Timm Bäder
05b9a99661 gsk: Remove some unused defines
These are from the GVariant days of render nodes.
2020-01-26 18:21:07 +01:00
Timm Bäder
a16e1cbf18 cssdimensionvalue: Remove an outdated comment
It's actually implemented in gtkcssdimensionvalue.c these days.
2020-01-26 18:21:07 +01:00
Timm Bäder
c7ea83cd82 cssboxes: Try to avoid doing work for rectangular boxes
Use the new gtk_css_dimension_value_is_zero() to check if we really need
to e.g. apply a border radius at all.
We compute css boxes a lot so this makes sense here, it especially shows
up during pick(), where we need the border box.
2020-01-26 18:21:07 +01:00
Timm Bäder
352c9ba42a dimensionvalue: Add gtk_css_{dimension,corner}_value_is_zero()
We can usually omit computations when the dimension value ends up being
zero anyway.
2020-01-26 18:21:07 +01:00
Timm Bäder
30b37dd7c5 widget: Restructure pick() a bit
Don't even invert transforms if we can do it easily ourselves. This also
fixes a small GtkTransform memory leak.
2020-01-26 18:21:07 +01:00
Timm Bäder
2e256986c3 renderbackground: Avoid unnecessary work in snapshot_background() 2020-01-26 18:21:07 +01:00
Timm Bäder
77e0d360ed Add pure and const annotations to various functions 2020-01-26 18:21:07 +01:00
Timm Bäder
942a93250a render: Remove gtk_render_background_get_clip 2020-01-26 18:21:07 +01:00
Timm Bäder
7ccd6597c3 Remove gtkutils{.c,private.h}
All but one functions are unused. Move the remaining one into
gtkmodules.c, its only caller.
2020-01-26 18:21:07 +01:00
Timm Bäder
355a417dba cssparser: make a few local variables const 2020-01-26 18:21:07 +01:00
Timm Bäder
36e3f4d902 cssprovider: Parse selectors without a GList
The maximum length of this list in Adwaita is 18, so use a generous
maximum length of 64 for the selector list of a ruleset.
2020-01-26 18:21:07 +01:00
Timm Bäder
69fe705d0d GtkCssImageUrl: Implement is_computed() 2020-01-26 18:21:07 +01:00
Timm Bäder
f62535affc gl renderer: Avoid some work when rendering border nodes 2020-01-26 18:21:07 +01:00
Timm Bäder
1a56a10fc1 cssimage: Add gtk_css_image_to_string()
In line with all the other _to_string() implementations
2020-01-26 18:21:07 +01:00
Timm Bäder
4287f0def4 window: Replace GtkStyleContext use to get surface transform
We have GtkCssBoxes for this these days.
2020-01-26 18:21:07 +01:00
Matthias Clasen
7bebc3e2b2 Revert "lookup stats"
This reverts commit 3d9e3390f1.
2020-01-25 23:49:33 -05:00
Matthias Clasen
b4e2df8fca Revert "css: Split style into groups"
This reverts commit 0df0de0b5d.
2020-01-25 23:49:17 -05:00
Matthias Clasen
0df0de0b5d css: Split style into groups 2020-01-25 23:47:02 -05:00
Matthias Clasen
53c22bf833 Adwaita: take out an unnecessary rule
The comment says setting caret-color to currentColor
shouldn't be necessary, and it is right.
2020-01-25 18:38:42 -05:00
Matthias Clasen
d8144ec497 Adwaita: drop the * 2020-01-25 18:20:40 -05:00
Matthias Clasen
3d9e3390f1 lookup stats 2020-01-25 18:20:26 -05:00
Matthias Clasen
03595f9567 Fix a scrollbar sizing issue
The recent Adwaita changes inadvertendly made scrollbars
resize on hover. Fix that, by reinstating some lost rules.
2020-01-25 15:05:14 -05:00
Matthias Clasen
64e026d0a9 Revert "Ensure icon themes are loaded with other themes"
This reverts commit 88d26b7549.

This change caused GtkShortcutWindow to not work anymore,
and we are fixing icon themes differently, anyway.
2020-01-25 14:32:01 -05:00
Matthias Clasen
0623b00512 Merge branch 'style-context-redux' into 'master'
Stop using GtkStyleContext internally

See merge request GNOME/gtk!1353
2020-01-25 19:29:20 +00:00
Matthias Clasen
ac902e697e popover: Stop using style context getters 2020-01-25 14:18:22 -05:00
Matthias Clasen
f1ff69963e drag icon: Stop using style context getters
Just go to the css node directly.
2020-01-25 14:18:22 -05:00
Matthias Clasen
731ae8f39e gskpango: Stop using style context getters
Just go to the css nodes directly.
2020-01-25 14:18:22 -05:00
Matthias Clasen
7da6fdc30e widget: Stop using style context internally 2020-01-25 11:05:27 -05:00
Matthias Clasen
a297129685 Add a profiler mark around renderer realization
This takes time that is worth calling out.
2020-01-25 01:28:24 -05:00
55 changed files with 1604 additions and 793 deletions

View File

@@ -4895,7 +4895,6 @@ gtk_border_free
<SUBSECTION>
gtk_render_arrow
gtk_render_background
gtk_render_background_get_clip
gtk_render_check
gtk_render_expander
gtk_render_focus

View File

@@ -53,15 +53,15 @@ GDK_AVAILABLE_IN_ALL
void gdk_rgba_free (GdkRGBA *rgba);
GDK_AVAILABLE_IN_ALL
gboolean gdk_rgba_is_clear (const GdkRGBA *rgba);
gboolean gdk_rgba_is_clear (const GdkRGBA *rgba) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
gboolean gdk_rgba_is_opaque (const GdkRGBA *rgba);
gboolean gdk_rgba_is_opaque (const GdkRGBA *rgba) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
guint gdk_rgba_hash (gconstpointer p);
guint gdk_rgba_hash (gconstpointer p) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
gboolean gdk_rgba_equal (gconstpointer p1,
gconstpointer p2);
gconstpointer p2) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
gboolean gdk_rgba_parse (GdkRGBA *rgba,

View File

@@ -51,9 +51,9 @@ GdkTexture * gdk_texture_new_from_file (GFile
GError **error);
GDK_AVAILABLE_IN_ALL
int gdk_texture_get_width (GdkTexture *texture);
int gdk_texture_get_width (GdkTexture *texture) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
int gdk_texture_get_height (GdkTexture *texture);
int gdk_texture_get_height (GdkTexture *texture) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
void gdk_texture_download (GdkTexture *texture,

View File

@@ -196,7 +196,7 @@ dump_node (GskRenderNode *node,
cairo_surface_destroy (surface);
}
static inline gboolean
static inline gboolean G_GNUC_PURE
node_is_invisible (const GskRenderNode *node)
{
return node->bounds.size.width == 0.0f ||
@@ -237,7 +237,7 @@ sort_border_sides (const GdkRGBA *colors,
}
}
static inline gboolean
static inline gboolean G_GNUC_PURE
color_matrix_modifies_alpha (GskRenderNode *node)
{
const graphene_matrix_t *matrix = gsk_color_matrix_node_peek_color_matrix (node);
@@ -261,7 +261,7 @@ gsk_rounded_rect_shrink_to_minimum (GskRoundedRect *self)
MAX (self->corner[2].height, self->corner[3].height)) * 2);
}
static inline gboolean
static inline gboolean G_GNUC_PURE
node_supports_transform (GskRenderNode *node)
{
/* Some nodes can't handle non-trivial transforms without being
@@ -611,7 +611,7 @@ render_fallback_node (GskGLRenderer *self,
cairo_fill (cr);
cairo_restore (cr);
#if G_ENABLE_DEBUG
#ifdef G_ENABLE_DEBUG
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), FALLBACK))
{
cairo_move_to (cr, 0, 0);
@@ -744,10 +744,6 @@ render_border_node (GskGLRenderer *self,
GskRenderNode *node,
RenderOpBuilder *builder)
{
const float min_x = builder->dx + node->bounds.origin.x;
const float min_y = builder->dy + node->bounds.origin.y;
const float max_x = min_x + node->bounds.size.width;
const float max_y = min_y + node->bounds.size.height;
const GdkRGBA *colors = gsk_border_node_peek_colors (node);
const GskRoundedRect *rounded_outline = gsk_border_node_peek_outline (node);
const float *widths = gsk_border_node_peek_widths (node);
@@ -824,6 +820,10 @@ render_border_node (GskGLRenderer *self,
sizes[3].h = 0;
{
const float min_x = builder->dx + node->bounds.origin.x;
const float min_y = builder->dy + node->bounds.origin.y;
const float max_x = min_x + node->bounds.size.width;
const float max_y = min_y + node->bounds.size.height;
const GskQuadVertex side_data[4][6] = {
/* Top */
{
@@ -2773,6 +2773,7 @@ gsk_gl_renderer_realize (GskRenderer *renderer,
GError **error)
{
GskGLRenderer *self = GSK_GL_RENDERER (renderer);
gint64 before = g_get_monotonic_time ();
/* If we didn't get a GdkGLContext before realization, try creating
* one now, for our exclusive use.
@@ -2802,6 +2803,9 @@ gsk_gl_renderer_realize (GskRenderer *renderer,
self->icon_cache = get_icon_cache_for_display (gdk_surface_get_display (surface), self->atlases);
gsk_gl_shadow_cache_init (&self->shadow_cache);
if (gdk_profiler_is_running ())
gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "gl renderer realize", NULL);
return TRUE;
}

View File

@@ -8,7 +8,7 @@ rect_equal (const graphene_rect_t *a,
return memcmp (a, b, sizeof (graphene_rect_t)) == 0;
}
static inline gboolean
static inline gboolean G_GNUC_PURE
rounded_rect_equal (const GskRoundedRect *r1,
const GskRoundedRect *r2)
{
@@ -31,7 +31,7 @@ rounded_rect_equal (const GskRoundedRect *r1,
return TRUE;
}
static inline gboolean
static inline gboolean G_GNUC_PURE
rounded_rect_corners_equal (const GskRoundedRect *r1,
const GskRoundedRect *r2)
{

View File

@@ -145,9 +145,9 @@ gsk_render_node_get_node_type (GskRenderNode *node)
return node->node_class->node_type;
}
static inline
G_GNUC_PURE static inline
GskRenderNodeType
_gsk_render_node_get_node_type (GskRenderNode *node)
_gsk_render_node_get_node_type (const GskRenderNode *node)
{
return node->node_class->node_type;
}
@@ -248,8 +248,8 @@ gsk_render_node_draw (GskRenderNode *node,
* Returns: %TRUE if @node1 and @node2 can be expected to be compared
**/
gboolean
gsk_render_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2)
gsk_render_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2)
{
if (node1 == node2)
return TRUE;
@@ -314,9 +314,6 @@ gsk_render_node_diff (GskRenderNode *node1,
return node1->node_class->diff (node1, node2, region);
}
#define GSK_RENDER_NODE_SERIALIZATION_VERSION 0
#define GSK_RENDER_NODE_SERIALIZATION_ID "GskRenderNode"
/**
* gsk_render_node_write_to_file:
* @node: a #GskRenderNode

View File

@@ -41,8 +41,8 @@ rectangle_init_from_graphene (cairo_rectangle_int_t *cairo,
}
static gboolean
gsk_render_node_can_diff_true (GskRenderNode *node1,
GskRenderNode *node2)
gsk_render_node_can_diff_true (const GskRenderNode *node1,
const GskRenderNode *node2)
{
return TRUE;
}
@@ -1707,8 +1707,8 @@ gsk_container_node_draw (GskRenderNode *node,
}
static gboolean
gsk_container_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2)
gsk_container_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2)
{
return TRUE;
}
@@ -1726,7 +1726,7 @@ gsk_render_node_add_to_region (GskRenderNode *node,
static int
gsk_container_node_compare_func (gconstpointer elem1, gconstpointer elem2, gpointer data)
{
return gsk_render_node_can_diff ((GskRenderNode *) elem1, (GskRenderNode *) elem2) ? 0 : 1;
return gsk_render_node_can_diff ((const GskRenderNode *) elem1, (const GskRenderNode *) elem2) ? 0 : 1;
}
static void
@@ -1918,8 +1918,8 @@ gsk_transform_node_draw (GskRenderNode *node,
}
static gboolean
gsk_transform_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2)
gsk_transform_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2)
{
GskTransformNode *self1 = (GskTransformNode *) node1;
GskTransformNode *self2 = (GskTransformNode *) node2;
@@ -2092,8 +2092,8 @@ gsk_debug_node_draw (GskRenderNode *node,
}
static gboolean
gsk_debug_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2)
gsk_debug_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2)
{
GskDebugNode *self1 = (GskDebugNode *) node1;
GskDebugNode *self2 = (GskDebugNode *) node2;

View File

@@ -28,8 +28,8 @@ struct _GskRenderNodeClass
void (* finalize) (GskRenderNode *node);
void (* draw) (GskRenderNode *node,
cairo_t *cr);
gboolean (* can_diff) (GskRenderNode *node1,
GskRenderNode *node2);
gboolean (* can_diff) (const GskRenderNode *node1,
const GskRenderNode *node2);
void (* diff) (GskRenderNode *node1,
GskRenderNode *node2,
cairo_region_t *region);
@@ -38,8 +38,8 @@ struct _GskRenderNodeClass
GskRenderNode * gsk_render_node_new (const GskRenderNodeClass *node_class,
gsize extra_size);
gboolean gsk_render_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2);
gboolean gsk_render_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2) G_GNUC_PURE;
void gsk_render_node_diff (GskRenderNode *node1,
GskRenderNode *node2,
cairo_region_t *region);

View File

@@ -98,16 +98,16 @@ GskRoundedRect * gsk_rounded_rect_shrink (GskRoundedRect
float left);
GDK_AVAILABLE_IN_ALL
gboolean gsk_rounded_rect_is_rectilinear (const GskRoundedRect *self);
gboolean gsk_rounded_rect_is_rectilinear (const GskRoundedRect *self) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
gboolean gsk_rounded_rect_contains_point (const GskRoundedRect *self,
const graphene_point_t *point);
const graphene_point_t *point) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
gboolean gsk_rounded_rect_contains_rect (const GskRoundedRect *self,
const graphene_rect_t *rect);
const graphene_rect_t *rect) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
gboolean gsk_rounded_rect_intersects_rect (const GskRoundedRect *self,
const graphene_rect_t *rect);
const graphene_rect_t *rect) G_GNUC_PURE;
G_END_DECLS

View File

@@ -15,7 +15,7 @@ void gsk_rounded_rect_to_float (const GskRounde
float rect[12]);
gboolean gsk_rounded_rect_equal (gconstpointer rect1,
gconstpointer rect2);
gconstpointer rect2) G_GNUC_PURE;
char * gsk_rounded_rect_to_string (const GskRoundedRect *self);

View File

@@ -261,14 +261,14 @@ gtk_css_parser_get_end_location (GtkCssParser *self)
const GtkCssLocation *
gtk_css_parser_get_block_location (GtkCssParser *self)
{
GtkCssParserBlock *block;
const GtkCssParserBlock *block;
if (self->blocks->len == 0)
{
static const GtkCssLocation start_of_document = { 0, };
return &start_of_document;
}
block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
return &block->start_location;
}
@@ -301,7 +301,7 @@ gtk_css_parser_peek_token (GtkCssParser *self)
if (self->blocks->len)
{
GtkCssParserBlock *block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
const GtkCssParserBlock *block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
if (gtk_css_token_is (&self->token, block->end_token) ||
gtk_css_token_is (&self->token, block->inherited_end_token) ||
gtk_css_token_is (&self->token, block->alternative_token))

View File

@@ -109,16 +109,16 @@ union _GtkCssToken {
void gtk_css_token_clear (GtkCssToken *token);
gboolean gtk_css_token_is_finite (const GtkCssToken *token);
gboolean gtk_css_token_is_finite (const GtkCssToken *token) G_GNUC_PURE;
gboolean gtk_css_token_is_preserved (const GtkCssToken *token,
GtkCssTokenType *out_closing);
GtkCssTokenType *out_closing) G_GNUC_PURE;
#define gtk_css_token_is(token, _type) ((token)->type == (_type))
gboolean gtk_css_token_is_ident (const GtkCssToken *token,
const char *ident);
const char *ident) G_GNUC_PURE;
gboolean gtk_css_token_is_function (const GtkCssToken *token,
const char *ident);
const char *ident) G_GNUC_PURE;
gboolean gtk_css_token_is_delim (const GtkCssToken *token,
gunichar delim);
gunichar delim) G_GNUC_PURE;
void gtk_css_token_print (const GtkCssToken *token,
GString *string);

View File

@@ -23,9 +23,11 @@
#include "gsk/gskrendernodeprivate.h"
#include "gskpango.h"
#include "gtksnapshotprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtktextlayoutprivate.h"
#include "gtktextviewprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include <math.h>
@@ -307,7 +309,6 @@ static void
gsk_pango_renderer_prepare_run (PangoRenderer *renderer,
PangoLayoutRun *run)
{
GtkStyleContext *context;
GskPangoRenderer *crenderer = GSK_PANGO_RENDERER (renderer);
GdkRGBA *bg_rgba = NULL;
GdkRGBA *fg_rgba = NULL;
@@ -320,8 +321,6 @@ gsk_pango_renderer_prepare_run (PangoRenderer *renderer,
if (appearance == NULL)
return;
context = gtk_widget_get_style_context (crenderer->widget);
if (appearance->draw_bg && crenderer->state == GSK_PANGO_RENDERER_NORMAL)
bg_rgba = appearance->bg_rgba;
else
@@ -332,22 +331,21 @@ gsk_pango_renderer_prepare_run (PangoRenderer *renderer,
if (crenderer->state == GSK_PANGO_RENDERER_SELECTED &&
GTK_IS_TEXT_VIEW (crenderer->widget))
{
GtkCssNode *selection_node;
GtkCssNode *node;
GtkCssValue *value;
selection_node = gtk_text_view_get_selection_node ((GtkTextView *)crenderer->widget);
gtk_style_context_save_to_node (context, selection_node);
gtk_style_context_get (context,
"color", &fg_rgba,
NULL);
gtk_style_context_restore (context);
node = gtk_text_view_get_selection_node ((GtkTextView *)crenderer->widget);
value = gtk_css_style_get_value (gtk_css_node_get_style (node), GTK_CSS_PROPERTY_COLOR);
fg_rgba = (GdkRGBA *)gtk_css_color_value_get_rgba (value);
}
else if (crenderer->state == GSK_PANGO_RENDERER_CURSOR && gtk_widget_has_focus (crenderer->widget))
{
gtk_style_context_get (context,
"background-color", &fg_rgba,
NULL);
GtkCssNode *node;
GtkCssValue *value;
node = gtk_widget_get_css_node (crenderer->widget);
value = gtk_css_style_get_value (gtk_css_node_get_style (node), GTK_CSS_PROPERTY_BACKGROUND_COLOR);
fg_rgba = (GdkRGBA *)gtk_css_color_value_get_rgba (value);
}
else
fg_rgba = appearance->fg_rgba;

View File

@@ -38,7 +38,7 @@
#include "gtkmain.h"
#include "gtkrecentmanager.h"
#include "gtkaccelmapprivate.h"
#include "gtkiconthemeprivate.h"
#include "gtkicontheme.h"
#include "gtkbuilder.h"
#include "gtkshortcutswindow.h"
#include "gtkintl.h"
@@ -218,7 +218,6 @@ gtk_application_load_resources (GtkApplication *application)
iconspath = g_strconcat (base_path, "/icons/", NULL);
gtk_icon_theme_add_resource_path (default_theme, iconspath);
g_free (iconspath);
gtk_icon_theme_ensure_loaded (default_theme);
}
/* Load the menus */

View File

@@ -299,7 +299,7 @@ gtk_css_value_array_transition (GtkCssValue *start,
}
static gboolean
gtk_css_value_array_is_dynamic (GtkCssValue *value)
gtk_css_value_array_is_dynamic (const GtkCssValue *value)
{
guint i;

View File

@@ -34,7 +34,7 @@ GtkCssValue * _gtk_css_array_value_parse (GtkCssParser *
GtkCssValue * _gtk_css_array_value_get_nth (GtkCssValue *value,
guint i);
guint _gtk_css_array_value_get_n_values (const GtkCssValue *value);
guint _gtk_css_array_value_get_n_values (const GtkCssValue *value) G_GNUC_PURE;
G_END_DECLS

View File

@@ -23,6 +23,7 @@
#include "gtkcsscornervalueprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssdimensionvalueprivate.h"
#include "gtkwidgetprivate.h"
/* This file is included from gtkcssboxesprivate.h */
@@ -79,15 +80,50 @@ gtk_css_boxes_rect_grow (GskRoundedRect *dest,
int bottom_property,
int left_property)
{
double top = _gtk_css_number_value_get (gtk_css_style_get_value (style, top_property), 100);
double right = _gtk_css_number_value_get (gtk_css_style_get_value (style, right_property), 100);
double bottom = _gtk_css_number_value_get (gtk_css_style_get_value (style, bottom_property), 100);
double left = _gtk_css_number_value_get (gtk_css_style_get_value (style, left_property), 100);
GtkCssValue *top = gtk_css_style_get_value (style, top_property);
GtkCssValue *right = gtk_css_style_get_value (style, right_property);
GtkCssValue *bottom = gtk_css_style_get_value (style, bottom_property);
GtkCssValue *left = gtk_css_style_get_value (style, left_property);
dest->bounds.origin.x = src->bounds.origin.x - left;
dest->bounds.origin.y = src->bounds.origin.y - top;
dest->bounds.size.width = src->bounds.size.width + left + right;
dest->bounds.size.height = src->bounds.size.height + top + bottom;
if (gtk_css_dimension_value_is_zero (left))
{
dest->bounds.origin.x = src->bounds.origin.x;
if (gtk_css_dimension_value_is_zero (right))
dest->bounds.size.width = src->bounds.size.width;
else
dest->bounds.size.width = src->bounds.size.width + _gtk_css_number_value_get (right, 100);
}
else
{
const double left_value = _gtk_css_number_value_get (left, 100);
dest->bounds.origin.x = src->bounds.origin.x - left_value;
if (gtk_css_dimension_value_is_zero (right))
dest->bounds.size.width = src->bounds.size.width + left_value;
else
dest->bounds.size.width = src->bounds.size.width + left_value + _gtk_css_number_value_get (right, 100);
}
if (gtk_css_dimension_value_is_zero (top))
{
dest->bounds.origin.y = src->bounds.origin.y;
if (gtk_css_dimension_value_is_zero (bottom))
dest->bounds.size.height = src->bounds.size.height;
else
dest->bounds.size.height = src->bounds.size.height + _gtk_css_number_value_get (bottom, 100);
}
else
{
const double top_value = _gtk_css_number_value_get (top, 100);
dest->bounds.origin.y = src->bounds.origin.y - top_value;
if (gtk_css_dimension_value_is_zero (bottom))
dest->bounds.size.height = src->bounds.size.height + top_value;
else
dest->bounds.size.height = src->bounds.size.height + top_value + _gtk_css_number_value_get (bottom, 100);
}
}
static inline void
@@ -323,19 +359,38 @@ gtk_css_boxes_apply_border_radius (GskRoundedRect *box,
const GtkCssValue *bottom_right,
const GtkCssValue *bottom_left)
{
box->corner[GSK_CORNER_TOP_LEFT].width = _gtk_css_corner_value_get_x (top_left, box->bounds.size.width);
box->corner[GSK_CORNER_TOP_LEFT].height = _gtk_css_corner_value_get_y (top_left, box->bounds.size.height);
gboolean has_border_radius = FALSE;
box->corner[GSK_CORNER_TOP_RIGHT].width = _gtk_css_corner_value_get_x (top_right, box->bounds.size.width);
box->corner[GSK_CORNER_TOP_RIGHT].height = _gtk_css_corner_value_get_y (top_right, box->bounds.size.height);
if (!gtk_css_corner_value_is_zero (top_left))
{
box->corner[GSK_CORNER_TOP_LEFT].width = _gtk_css_corner_value_get_x (top_left, box->bounds.size.width);
box->corner[GSK_CORNER_TOP_LEFT].height = _gtk_css_corner_value_get_y (top_left, box->bounds.size.height);
has_border_radius = TRUE;
}
box->corner[GSK_CORNER_BOTTOM_RIGHT].width = _gtk_css_corner_value_get_x (bottom_right, box->bounds.size.width);
box->corner[GSK_CORNER_BOTTOM_RIGHT].height = _gtk_css_corner_value_get_y (bottom_right, box->bounds.size.height);
if (!gtk_css_corner_value_is_zero (top_right))
{
box->corner[GSK_CORNER_TOP_RIGHT].width = _gtk_css_corner_value_get_x (top_right, box->bounds.size.width);
box->corner[GSK_CORNER_TOP_RIGHT].height = _gtk_css_corner_value_get_y (top_right, box->bounds.size.height);
has_border_radius = TRUE;
}
box->corner[GSK_CORNER_BOTTOM_LEFT].width = _gtk_css_corner_value_get_x (bottom_left, box->bounds.size.width);
box->corner[GSK_CORNER_BOTTOM_LEFT].height = _gtk_css_corner_value_get_y (bottom_left, box->bounds.size.height);
if (!gtk_css_corner_value_is_zero (bottom_right))
{
box->corner[GSK_CORNER_BOTTOM_RIGHT].width = _gtk_css_corner_value_get_x (bottom_right, box->bounds.size.width);
box->corner[GSK_CORNER_BOTTOM_RIGHT].height = _gtk_css_corner_value_get_y (bottom_right, box->bounds.size.height);
has_border_radius = TRUE;
}
gtk_css_boxes_clamp_border_radius (box);
if (!gtk_css_corner_value_is_zero (bottom_left))
{
box->corner[GSK_CORNER_BOTTOM_LEFT].width = _gtk_css_corner_value_get_x (bottom_left, box->bounds.size.width);
box->corner[GSK_CORNER_BOTTOM_LEFT].height = _gtk_css_corner_value_get_y (bottom_left, box->bounds.size.height);
has_border_radius = TRUE;
}
if (has_border_radius)
gtk_css_boxes_clamp_border_radius (box);
}
/* NB: width and height must be >= 0 */

View File

@@ -24,18 +24,18 @@
G_BEGIN_DECLS
GtkCssValue * gtk_css_color_value_new_transparent (void);
GtkCssValue * gtk_css_color_value_new_white (void);
GtkCssValue * _gtk_css_color_value_new_literal (const GdkRGBA *color);
GtkCssValue * _gtk_css_color_value_new_name (const gchar *name);
GtkCssValue * gtk_css_color_value_new_transparent (void) G_GNUC_PURE;
GtkCssValue * gtk_css_color_value_new_white (void) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_literal (const GdkRGBA *color) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_name (const gchar *name) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_shade (GtkCssValue *color,
gdouble factor);
gdouble factor) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_alpha (GtkCssValue *color,
gdouble factor);
gdouble factor) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_mix (GtkCssValue *color1,
GtkCssValue *color2,
gdouble factor);
GtkCssValue * _gtk_css_color_value_new_current_color (void);
gdouble factor) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_current_color (void) G_GNUC_PURE;
gboolean gtk_css_color_value_can_parse (GtkCssParser *parser);
GtkCssValue * _gtk_css_color_value_parse (GtkCssParser *parser);
@@ -44,7 +44,7 @@ GtkCssValue * _gtk_css_color_value_resolve (GtkCssValue *color
GtkStyleProvider *provider,
GtkCssValue *current,
GSList *cycle_list);
const GdkRGBA * gtk_css_color_value_get_rgba (const GtkCssValue *color);
const GdkRGBA * gtk_css_color_value_get_rgba (const GtkCssValue *color) G_GNUC_CONST;
G_END_DECLS

View File

@@ -18,8 +18,8 @@
#include "config.h"
#include "gtkcsscornervalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssdimensionvalueprivate.h"
struct _GtkCssValue {
GTK_CSS_VALUE_BASE
@@ -184,3 +184,12 @@ _gtk_css_corner_value_get_y (const GtkCssValue *corner,
return _gtk_css_number_value_get (corner->y, one_hundred_percent);
}
gboolean
gtk_css_corner_value_is_zero (const GtkCssValue *corner)
{
if (corner->class != &GTK_CSS_VALUE_CORNER)
return gtk_css_dimension_value_is_zero (corner);
return gtk_css_dimension_value_is_zero (corner->x) &&
gtk_css_dimension_value_is_zero (corner->y);
}

View File

@@ -30,9 +30,10 @@ GtkCssValue * _gtk_css_corner_value_new (GtkCssValue *x,
GtkCssValue * _gtk_css_corner_value_parse (GtkCssParser *parser);
double _gtk_css_corner_value_get_x (const GtkCssValue *corner,
double one_hundred_percent);
double one_hundred_percent) G_GNUC_PURE;
double _gtk_css_corner_value_get_y (const GtkCssValue *corner,
double one_hundred_percent);
double one_hundred_percent) G_GNUC_PURE;
gboolean gtk_css_corner_value_is_zero (const GtkCssValue *corner) G_GNUC_PURE;
G_END_DECLS

View File

@@ -497,3 +497,14 @@ gtk_css_dimension_value_parse (GtkCssParser *parser,
return result;
}
gboolean
gtk_css_dimension_value_is_zero (const GtkCssValue *value)
{
if (!value)
return TRUE;
if (value->class != &GTK_CSS_VALUE_DIMENSION.value_class)
return FALSE;
return value->value == 0;
}

View File

@@ -26,10 +26,12 @@ G_BEGIN_DECLS
GtkCssValue * gtk_css_dimension_value_new (double value,
GtkCssUnit unit);
/* This function implemented in gtkcssparser.c */
GtkCssValue * gtk_css_dimension_value_parse (GtkCssParser *parser,
GtkCssNumberParseFlags flags);
gboolean gtk_css_dimension_value_is_zero (const GtkCssValue *value) G_GNUC_PURE;
G_END_DECLS
#endif /* __GTK_CSS_DIMENSION_VALUE_PRIVATE_H__ */

View File

@@ -340,6 +340,17 @@ _gtk_css_image_print (GtkCssImage *image,
klass->print (image, string);
}
char *
gtk_css_image_to_string (GtkCssImage *image)
{
GString *str = g_string_new ("");
_gtk_css_image_print (image, str);
return g_string_free (str, FALSE);
}
/* Applies the algorithm outlined in
* http://dev.w3.org/csswg/css3-images/#default-sizing
*/

View File

@@ -97,9 +97,9 @@ GType _gtk_css_image_get_type (void) G_GNUC_CONST;
gboolean _gtk_css_image_can_parse (GtkCssParser *parser);
GtkCssImage * _gtk_css_image_new_parse (GtkCssParser *parser);
int _gtk_css_image_get_width (GtkCssImage *image);
int _gtk_css_image_get_height (GtkCssImage *image);
double _gtk_css_image_get_aspect_ratio (GtkCssImage *image);
int _gtk_css_image_get_width (GtkCssImage *image) G_GNUC_PURE;
int _gtk_css_image_get_height (GtkCssImage *image) G_GNUC_PURE;
double _gtk_css_image_get_aspect_ratio (GtkCssImage *image) G_GNUC_PURE;
GtkCssImage * _gtk_css_image_compute (GtkCssImage *image,
guint property_id,
@@ -107,7 +107,7 @@ GtkCssImage * _gtk_css_image_compute (GtkCssImage *
GtkCssStyle *style,
GtkCssStyle *parent_style);
gboolean _gtk_css_image_equal (GtkCssImage *image1,
GtkCssImage *image2);
GtkCssImage *image2) G_GNUC_PURE;
GtkCssImage * _gtk_css_image_transition (GtkCssImage *start,
GtkCssImage *end,
guint property_id,
@@ -121,12 +121,13 @@ void gtk_css_image_snapshot (GtkCssImage *
GtkSnapshot *snapshot,
double width,
double height);
gboolean gtk_css_image_is_invalid (GtkCssImage *image);
gboolean gtk_css_image_is_dynamic (GtkCssImage *image);
gboolean gtk_css_image_is_invalid (GtkCssImage *image) G_GNUC_PURE;
gboolean gtk_css_image_is_dynamic (GtkCssImage *image) G_GNUC_PURE;
GtkCssImage * gtk_css_image_get_dynamic_image (GtkCssImage *image,
gint64 monotonic_time);
void _gtk_css_image_print (GtkCssImage *image,
GString *string);
char * gtk_css_image_to_string (GtkCssImage *image);
void _gtk_css_image_get_concrete_size (GtkCssImage *image,
double specified_width,
@@ -140,7 +141,7 @@ cairo_surface_t *
cairo_surface_t *target,
int surface_width,
int surface_height);
gboolean gtk_css_image_is_computed (GtkCssImage *image);
gboolean gtk_css_image_is_computed (GtkCssImage *image) G_GNUC_PURE;
G_END_DECLS

View File

@@ -161,6 +161,12 @@ gtk_css_image_url_is_invalid (GtkCssImage *image)
return gtk_css_image_is_invalid (gtk_css_image_url_load_image (url, NULL));
}
static gboolean
gtk_css_image_url_is_computed (GtkCssImage *image)
{
return TRUE;
}
static gboolean
gtk_css_image_url_parse (GtkCssImage *image,
GtkCssParser *parser)
@@ -249,6 +255,7 @@ _gtk_css_image_url_class_init (GtkCssImageUrlClass *klass)
image_class->print = gtk_css_image_url_print;
image_class->equal = gtk_css_image_url_equal;
image_class->is_invalid = gtk_css_image_url_is_invalid;
image_class->is_computed = gtk_css_image_url_is_computed;
object_class->dispose = gtk_css_image_url_dispose;
}

View File

@@ -82,7 +82,7 @@ gtk_css_value_image_transition (GtkCssValue *start,
}
static gboolean
gtk_css_value_image_is_dynamic (GtkCssValue *value)
gtk_css_value_image_is_dynamic (const GtkCssValue *value)
{
GtkCssImage *image = _gtk_css_image_value_get_image (value);

View File

@@ -41,7 +41,7 @@ GtkCssKeyframes * _gtk_css_keyframes_compute (GtkCssKeyframes
GtkCssStyle *style,
GtkCssStyle *parent_style);
guint _gtk_css_keyframes_get_n_properties (GtkCssKeyframes *keyframes);
guint _gtk_css_keyframes_get_n_properties (GtkCssKeyframes *keyframes) G_GNUC_PURE;
guint _gtk_css_keyframes_get_property_id (GtkCssKeyframes *keyframes,
guint id);
GtkCssValue * _gtk_css_keyframes_get_value (GtkCssKeyframes *keyframes,

View File

@@ -28,11 +28,14 @@ void
_gtk_css_lookup_init (GtkCssLookup *lookup)
{
memset (lookup, 0, sizeof (*lookup));
lookup->set_values = _gtk_bitmask_new ();
}
void
_gtk_css_lookup_destroy (GtkCssLookup *lookup)
{
_gtk_bitmask_free (lookup->set_values);
}
gboolean
@@ -41,13 +44,7 @@ _gtk_css_lookup_is_missing (const GtkCssLookup *lookup,
{
gtk_internal_return_val_if_fail (lookup != NULL, FALSE);
return lookup->values[id].value == NULL;
}
gboolean
_gtk_css_lookup_all_set (const GtkCssLookup *lookup)
{
return lookup->n_set_values == GTK_CSS_PROPERTY_N_PROPERTIES;
return !_gtk_bitmask_get (lookup->set_values, id);
}
/**
@@ -75,41 +72,5 @@ _gtk_css_lookup_set (GtkCssLookup *lookup,
lookup->values[id].value = value;
lookup->values[id].section = section;
lookup->n_set_values ++;
}
/**
* _gtk_css_lookup_resolve:
* @lookup: the lookup
* @context: the context the values are resolved for
* @values: a new #GtkCssStyle to be filled with the new properties
*
* Resolves the current lookup into a styleproperties object. This is done
* by converting from the “winning declaration” to the “computed value”.
*
* XXX: This bypasses the notion of “specified value”. If this ever becomes
* an issue, go fix it.
**/
void
_gtk_css_lookup_resolve (GtkCssLookup *lookup,
GtkStyleProvider *provider,
GtkCssStaticStyle *style,
GtkCssStyle *parent_style)
{
guint i;
gtk_internal_return_if_fail (lookup != NULL);
gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER (provider));
gtk_internal_return_if_fail (GTK_IS_CSS_STATIC_STYLE (style));
gtk_internal_return_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style));
for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
{
gtk_css_static_style_compute_value (style,
provider,
parent_style,
i,
lookup->values[i].value,
lookup->values[i].section);
}
lookup->set_values = _gtk_bitmask_set (lookup->set_values, id, TRUE);
}

View File

@@ -36,7 +36,7 @@ typedef struct {
} GtkCssLookupValue;
struct _GtkCssLookup {
guint n_set_values;
GtkBitmask *set_values;
GtkCssLookupValue values[GTK_CSS_PROPERTY_N_PROPERTIES];
};
@@ -44,15 +44,16 @@ void _gtk_css_lookup_init (GtkCssLookup
void _gtk_css_lookup_destroy (GtkCssLookup *lookup);
gboolean _gtk_css_lookup_is_missing (const GtkCssLookup *lookup,
guint id);
gboolean _gtk_css_lookup_all_set (const GtkCssLookup *lookup);
void _gtk_css_lookup_set (GtkCssLookup *lookup,
guint id,
GtkCssSection *section,
GtkCssValue *value);
void _gtk_css_lookup_resolve (GtkCssLookup *lookup,
GtkStyleProvider *provider,
GtkCssStaticStyle *style,
GtkCssStyle *parent_style);
static inline const GtkBitmask *
_gtk_css_lookup_get_set_values (const GtkCssLookup *lookup)
{
return lookup->set_values;
}
G_END_DECLS

View File

@@ -74,6 +74,8 @@
* way back to 4.0.
*/
#define MAX_SELECTOR_LIST_LENGTH 64
struct _GtkCssProviderClass
{
GObjectClass parent_class;
@@ -487,9 +489,6 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
ruleset->styles[j].section,
ruleset->styles[j].value);
}
if (_gtk_css_lookup_all_set (lookup))
break;
}
g_ptr_array_free (tree_rules, TRUE);
@@ -550,29 +549,28 @@ gtk_css_provider_new (void)
}
static void
css_provider_commit (GtkCssProvider *css_provider,
GSList *selectors,
GtkCssRuleset *ruleset)
css_provider_commit (GtkCssProvider *css_provider,
GtkCssSelector **selectors,
guint n_selectors,
GtkCssRuleset *ruleset)
{
GtkCssProviderPrivate *priv = gtk_css_provider_get_instance_private (css_provider);
GSList *l;
guint i;
if (ruleset->styles == NULL)
{
g_slist_free_full (selectors, (GDestroyNotify) _gtk_css_selector_free);
return;
}
for (l = selectors; l; l = l->next)
for (i = 0; i < n_selectors; i ++)
{
GtkCssRuleset new;
GtkCssRuleset *new;
gtk_css_ruleset_init_copy (&new, ruleset, l->data);
g_array_set_size (priv->rulesets, priv->rulesets->len + 1);
g_array_append_val (priv->rulesets, new);
new = &g_array_index (priv->rulesets, GtkCssRuleset, priv->rulesets->len - 1);
gtk_css_ruleset_init_copy (new, ruleset, selectors[i]);
}
g_slist_free (selectors);
}
static void
@@ -757,22 +755,32 @@ parse_at_keyword (GtkCssScanner *scanner)
gtk_css_parser_end_block (scanner->parser);
}
static GSList *
parse_selector_list (GtkCssScanner *scanner)
static guint
parse_selector_list (GtkCssScanner *scanner,
GtkCssSelector *out_selectors[MAX_SELECTOR_LIST_LENGTH])
{
GSList *selectors = NULL;
guint n_selectors = 0;
do {
GtkCssSelector *select = _gtk_css_selector_parse (scanner->parser);
if (select == NULL)
return NULL;
return 0;
selectors = g_slist_prepend (selectors, select);
out_selectors[n_selectors] = select;
n_selectors++;
if (G_UNLIKELY (n_selectors > MAX_SELECTOR_LIST_LENGTH))
{
gtk_css_parser_error_syntax (scanner->parser,
"Only %u selectors per ruleset allowed",
MAX_SELECTOR_LIST_LENGTH);
return 0;
}
}
while (gtk_css_parser_try_token (scanner->parser, GTK_CSS_TOKEN_COMMA));
return selectors;
return n_selectors;
}
static void
@@ -891,11 +899,12 @@ parse_declarations (GtkCssScanner *scanner,
static void
parse_ruleset (GtkCssScanner *scanner)
{
GSList *selectors;
GtkCssSelector *selectors[MAX_SELECTOR_LIST_LENGTH];
guint n_selectors;
GtkCssRuleset ruleset = { 0, };
selectors = parse_selector_list (scanner);
if (selectors == NULL)
n_selectors = parse_selector_list (scanner, selectors);
if (n_selectors == 0)
{
gtk_css_parser_skip_until (scanner->parser, GTK_CSS_TOKEN_OPEN_CURLY);
gtk_css_parser_skip (scanner->parser);
@@ -904,8 +913,10 @@ parse_ruleset (GtkCssScanner *scanner)
if (!gtk_css_parser_has_token (scanner->parser, GTK_CSS_TOKEN_OPEN_CURLY))
{
guint i;
gtk_css_parser_error_syntax (scanner->parser, "Expected '{' after selectors");
g_slist_free_full (selectors, (GDestroyNotify) _gtk_css_selector_free);
for (i = 0; i < n_selectors; i ++)
_gtk_css_selector_free (selectors[i]);
gtk_css_parser_skip_until (scanner->parser, GTK_CSS_TOKEN_OPEN_CURLY);
gtk_css_parser_skip (scanner->parser);
return;
@@ -917,7 +928,7 @@ parse_ruleset (GtkCssScanner *scanner)
gtk_css_parser_end_block (scanner->parser);
css_provider_commit (scanner->provider, selectors, &ruleset);
css_provider_commit (scanner->provider, selectors, n_selectors, &ruleset);
gtk_css_ruleset_clear (&ruleset);
}

View File

@@ -131,6 +131,7 @@ gtk_css_value_shadow_compute (GtkCssValue *value,
shadows[i].radius = _gtk_css_value_compute (shadow->radius, property_id, provider, style, parent_style);
shadows[i].spread = _gtk_css_value_compute (shadow->spread, property_id, provider, style, parent_style),
shadows[i].color = _gtk_css_value_compute (shadow->color, property_id, provider, style, parent_style);
shadows[i].inset = shadow->inset;
}
return gtk_css_shadow_value_new (shadows, value->n_shadows);

View File

@@ -46,8 +46,8 @@ void gtk_css_shadow_value_snapshot_inset (const GtkCssValue
GtkSnapshot *snapshot,
const GskRoundedRect *padding_box);
gboolean gtk_css_shadow_value_is_clear (const GtkCssValue *shadow);
gboolean gtk_css_shadow_value_is_none (const GtkCssValue *shadow);
gboolean gtk_css_shadow_value_is_clear (const GtkCssValue *shadow) G_GNUC_PURE;
gboolean gtk_css_shadow_value_is_none (const GtkCssValue *shadow) G_GNUC_PURE;
gboolean gtk_css_shadow_value_push_snapshot (const GtkCssValue *value,
GtkSnapshot *snapshot);

View File

@@ -67,7 +67,7 @@ GType _gtk_css_shorthand_property_get_type (void) G
GtkCssStyleProperty * _gtk_css_shorthand_property_get_subproperty (GtkCssShorthandProperty *shorthand,
guint property);
guint _gtk_css_shorthand_property_get_n_subproperties (GtkCssShorthandProperty *shorthand);
guint _gtk_css_shorthand_property_get_n_subproperties (GtkCssShorthandProperty *shorthand) G_GNUC_CONST;
G_END_DECLS

File diff suppressed because it is too large Load Diff

View File

@@ -34,11 +34,164 @@ G_BEGIN_DECLS
typedef struct _GtkCssStaticStyleClass GtkCssStaticStyleClass;
/* inherited */
typedef struct {
int ref_count;
GtkCssValue *color;
GtkCssValue *dpi;
GtkCssValue *font_size;
GtkCssValue *icon_theme;
GtkCssValue *icon_palette;
} GtkCssCoreValues;
typedef struct {
int ref_count;
GtkCssValue *background_color;
GtkCssValue *box_shadow;
GtkCssValue *background_clip;
GtkCssValue *background_origin;
GtkCssValue *background_size;
GtkCssValue *background_position;
GtkCssValue *background_repeat;
GtkCssValue *background_image;
GtkCssValue *background_blend_mode;
} GtkCssBackgroundValues;
typedef struct {
int ref_count;
GtkCssValue *border_top_style;
GtkCssValue *border_top_width;
GtkCssValue *border_left_style;
GtkCssValue *border_left_width;
GtkCssValue *border_bottom_style;
GtkCssValue *border_bottom_width;
GtkCssValue *border_right_style;
GtkCssValue *border_right_width;
GtkCssValue *border_top_left_radius;
GtkCssValue *border_top_right_radius;
GtkCssValue *border_bottom_right_radius;
GtkCssValue *border_bottom_left_radius;
GtkCssValue *border_top_color;
GtkCssValue *border_right_color;
GtkCssValue *border_bottom_color;
GtkCssValue *border_left_color;
GtkCssValue *border_image_source;
GtkCssValue *border_image_repeat;
GtkCssValue *border_image_slice;
GtkCssValue *border_image_width;
} GtkCssBorderValues;
/* inherited */
typedef struct {
int ref_count;
GtkCssValue *icon_size;
GtkCssValue *icon_shadow;
GtkCssValue *icon_style;
} GtkCssIconValues;
typedef struct {
int ref_count;
GtkCssValue *outline_style;
GtkCssValue *outline_width;
GtkCssValue *outline_offset;
GtkCssValue *outline_top_left_radius;
GtkCssValue *outline_top_right_radius;
GtkCssValue *outline_bottom_right_radius;
GtkCssValue *outline_bottom_left_radius;
GtkCssValue *outline_color;
} GtkCssOutlineValues;
/* inherited */
typedef struct {
int ref_count;
GtkCssValue *font_family;
GtkCssValue *font_style;
GtkCssValue *font_weight;
GtkCssValue *font_stretch;
GtkCssValue *letter_spacing;
GtkCssValue *text_shadow;
GtkCssValue *caret_color;
GtkCssValue *secondary_caret_color;
GtkCssValue *font_feature_settings;
GtkCssValue *font_variation_settings;
} GtkCssFontValues;
typedef struct {
int ref_count;
GtkCssValue *text_decoration_line;
GtkCssValue *text_decoration_color;
GtkCssValue *text_decoration_style;
GtkCssValue *font_kerning;
GtkCssValue *font_variant_ligatures;
GtkCssValue *font_variant_position;
GtkCssValue *font_variant_caps;
GtkCssValue *font_variant_numeric;
GtkCssValue *font_variant_alternates;
GtkCssValue *font_variant_east_asian;
} GtkCssFontVariantValues;
typedef struct {
int ref_count;
GtkCssValue *animation_name;
GtkCssValue *animation_duration;
GtkCssValue *animation_timing_function;
GtkCssValue *animation_iteration_count;
GtkCssValue *animation_direction;
GtkCssValue *animation_play_state;
GtkCssValue *animation_delay;
GtkCssValue *animation_fill_mode;
} GtkCssAnimationValues;
typedef struct {
int ref_count;
GtkCssValue *transition_property;
GtkCssValue *transition_duration;
GtkCssValue *transition_timing_function;
GtkCssValue *transition_delay;
} GtkCssTransitionValues;
typedef struct {
int ref_count;
GtkCssValue *margin_top;
GtkCssValue *margin_left;
GtkCssValue *margin_bottom;
GtkCssValue *margin_right;
GtkCssValue *padding_top;
GtkCssValue *padding_left;
GtkCssValue *padding_bottom;
GtkCssValue *padding_right;
GtkCssValue *border_spacing;
GtkCssValue *min_width;
GtkCssValue *min_height;
} GtkCssSizeValues;
typedef struct {
int ref_count;
GtkCssValue *icon_source;
GtkCssValue *icon_transform;
GtkCssValue *icon_filter;
GtkCssValue *transform;
GtkCssValue *opacity;
GtkCssValue *filter;
} GtkCssOtherValues;
struct _GtkCssStaticStyle
{
GtkCssStyle parent;
GtkCssValue *values[GTK_CSS_PROPERTY_N_PROPERTIES]; /* the values */
GtkCssCoreValues *core;
GtkCssBackgroundValues *background;
GtkCssBorderValues *border;
GtkCssIconValues *icon;
GtkCssOutlineValues *outline;
GtkCssFontValues *font;
GtkCssFontVariantValues *font_variant;
GtkCssAnimationValues *animation;
GtkCssTransitionValues *transition;
GtkCssSizeValues *size;
GtkCssOtherValues *other;
GPtrArray *sections; /* sections the values are defined in */
GtkCssChange change; /* change as returned by value lookup */
@@ -57,13 +210,6 @@ GtkCssStyle * gtk_css_static_style_new_compute (GtkStyleProvide
GtkCssStyle *parent,
GtkCssChange change);
void gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
GtkStyleProvider *provider,
GtkCssStyle *parent_style,
guint id,
GtkCssValue *specified,
GtkCssSection *section);
GtkCssChange gtk_css_static_style_get_change (GtkCssStaticStyle *style);
G_END_DECLS

View File

@@ -64,7 +64,7 @@ GType _gtk_css_style_property_get_type (void) G_GNUC_CO
void _gtk_css_style_property_init_properties (void);
guint _gtk_css_style_property_get_n_properties(void);
guint _gtk_css_style_property_get_n_properties(void) G_GNUC_CONST;
GtkCssStyleProperty * _gtk_css_style_property_lookup_by_id (guint id);
gboolean _gtk_css_style_property_is_inherit (GtkCssStyleProperty *property);

View File

@@ -329,7 +329,7 @@ _gtk_css_value_print (const GtkCssValue *value,
* Returns %TRUE if the value is dynamic
*/
gboolean
gtk_css_value_is_dynamic (GtkCssValue *value)
gtk_css_value_is_dynamic (const GtkCssValue *value)
{
gtk_internal_return_val_if_fail (value != NULL, FALSE);

View File

@@ -55,7 +55,7 @@ struct _GtkCssValueClass {
GtkCssValue *end,
guint property_id,
double progress);
gboolean (* is_dynamic) (GtkCssValue *value);
gboolean (* is_dynamic) (const GtkCssValue *value);
GtkCssValue * (* get_dynamic_value) (GtkCssValue *value,
gint64 monotonic_time);
void (* print) (const GtkCssValue *value,
@@ -77,16 +77,16 @@ GtkCssValue *_gtk_css_value_compute (GtkCssValue
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style);
GtkCssStyle *parent_style) G_GNUC_PURE;
gboolean _gtk_css_value_equal (const GtkCssValue *value1,
const GtkCssValue *value2);
const GtkCssValue *value2) G_GNUC_PURE;
gboolean _gtk_css_value_equal0 (const GtkCssValue *value1,
const GtkCssValue *value2);
const GtkCssValue *value2) G_GNUC_PURE;
GtkCssValue *_gtk_css_value_transition (GtkCssValue *start,
GtkCssValue *end,
guint property_id,
double progress);
gboolean gtk_css_value_is_dynamic (GtkCssValue *value);
gboolean gtk_css_value_is_dynamic (const GtkCssValue *value) G_GNUC_PURE;
GtkCssValue * gtk_css_value_get_dynamic_value (GtkCssValue *value,
gint64 monotonic_time);

View File

@@ -22,9 +22,12 @@
#include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkwidgetprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkcsstypesprivate.h"
#include "gtknativeprivate.h"
#include "gtkpicture.h"
#include "gtkcssnumbervalueprivate.h"
/**
@@ -107,16 +110,15 @@ gtk_drag_icon_native_get_surface_transform (GtkNative *native,
int *x,
int *y)
{
GtkStyleContext *context;
GtkBorder margin, border, padding;
GtkCssStyle *style;
context = gtk_widget_get_style_context (GTK_WIDGET (native));
gtk_style_context_get_margin (context, &margin);
gtk_style_context_get_border (context, &border);
gtk_style_context_get_padding (context, &padding);
*x = margin.left + border.left + padding.left;
*y = margin.top + border.top + padding.top;
style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (native)));
*x = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_MARGIN_LEFT), 100) +
_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100) +
_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_PADDING_LEFT), 100);
*y = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_MARGIN_TOP), 100) +
_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100) +
_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_PADDING_TOP), 100);
}
static void

View File

@@ -762,6 +762,7 @@ do_theme_change (GtkIconTheme *self)
blow_themes (self);
queue_theme_changed (self);
}
static void
@@ -1269,7 +1270,6 @@ load_themes (GtkIconTheme *self)
IconThemeDirMtime *dir_mtime;
GStatBuf stat_buf;
GList *d;
gint64 before = g_get_monotonic_time ();
if (self->current_theme)
insert_theme (self, self->current_theme);
@@ -1356,9 +1356,6 @@ load_themes (GtkIconTheme *self)
g_message ("%s", s->str);
g_string_free (s, TRUE);
});
self->loading_themes = FALSE;
gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "icon theme load", self->current_theme);
}
static void
@@ -1366,6 +1363,7 @@ ensure_valid_themes (GtkIconTheme *self)
{
GTimeVal tv;
gboolean was_valid = self->themes_valid;
gint64 before = g_get_monotonic_time ();
if (self->loading_themes)
return;
@@ -1391,12 +1389,11 @@ ensure_valid_themes (GtkIconTheme *self)
if (was_valid)
queue_theme_changed (self);
}
}
void
gtk_icon_theme_ensure_loaded (GtkIconTheme *self)
{
ensure_valid_themes (self);
if (gdk_profiler_is_running ())
gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "icon theme load", NULL);
self->loading_themes = FALSE;
}
static inline gboolean

View File

@@ -27,6 +27,4 @@ void gtk_icon_theme_lookup_symbolic_colors (GtkCssStyle *style,
GdkRGBA *warning_out,
GdkRGBA *error_out);
void gtk_icon_theme_ensure_loaded (GtkIconTheme *self);
#endif /* __GTK_ICON_THEME_PRIVATE_H__ */

View File

@@ -37,7 +37,6 @@
#include "gtkmodulesprivate.h"
#include "gtksettings.h"
#include "gtkprivate.h"
#include "gtkutilsprivate.h"
#include "gtkintl.h"
#ifdef GDK_WINDOWING_X11

View File

@@ -25,10 +25,82 @@
#include "gtkprivate.h"
#include "gtkmodulesprivate.h"
#include "gtkintl.h"
#include "gtkutilsprivate.h"
#include <gmodule.h>
static char *
gtk_trim_string (const char *str)
{
int len;
g_return_val_if_fail (str != NULL, NULL);
while (*str && g_ascii_isspace (*str))
str++;
len = strlen (str);
while (len > 0 && g_ascii_isspace (str[len - 1]))
len--;
return g_strndup (str, len);
}
static char **
split_file_list (const char *str)
{
int i = 0;
int j;
char **files;
files = g_strsplit (str, G_SEARCHPATH_SEPARATOR_S, -1);
while (files[i])
{
char *file = gtk_trim_string (files[i]);
/* If the resulting file is empty, skip it */
if (file[0] == '\0')
{
g_free (file);
g_free (files[i]);
for (j = i + 1; files[j]; j++)
files[j - 1] = files[j];
files[j - 1] = NULL;
continue;
}
#ifndef G_OS_WIN32
/* '~' is a quite normal and common character in file names on
* Windows, especially in the 8.3 versions of long file names, which
* still occur now and then. Also, few Windows user are aware of the
* Unix shell convention that '~' stands for the home directory,
* even if they happen to have a home directory.
*/
if (file[0] == '~' && file[1] == G_DIR_SEPARATOR)
{
char *tmp = g_strconcat (g_get_home_dir(), file + 1, NULL);
g_free (file);
file = tmp;
}
else if (file[0] == '~' && file[1] == '\0')
{
g_free (file);
file = g_strdup (g_get_home_dir ());
}
#endif
g_free (files[i]);
files[i] = file;
i++;
}
return files;
}
static gchar **
get_module_path (void)
{
@@ -58,7 +130,7 @@ get_module_path (void)
g_free (default_dir);
result = gtk_split_file_list (module_path);
result = split_file_list (module_path);
g_free (module_path);
return result;

View File

@@ -117,7 +117,10 @@
#include "gtkmenusectionboxprivate.h"
#include "gdk/gdkeventsprivate.h"
#include "gtkpointerfocusprivate.h"
#include "gtkcsstypesprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtksnapshot.h"
#include "gtkrender.h"
@@ -207,16 +210,15 @@ gtk_popover_native_get_surface_transform (GtkNative *native,
int *x,
int *y)
{
GtkStyleContext *context;
GtkBorder margin, border, padding;
GtkCssStyle *style;
context = gtk_widget_get_style_context (GTK_WIDGET (native));
gtk_style_context_get_margin (context, &margin);
gtk_style_context_get_border (context, &border);
gtk_style_context_get_padding (context, &padding);
*x = margin.left + border.left + padding.left;
*y = margin.top + border.top + padding.top;
style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (native)));
*x = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_MARGIN_LEFT), 100) +
_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100) +
_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_PADDING_LEFT), 100);
*y = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_MARGIN_TOP), 100) +
_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100) +
_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_PADDING_TOP), 100);
}
static void
@@ -560,7 +562,6 @@ gtk_popover_init (GtkPopover *popover)
GtkPopoverPrivate *priv = gtk_popover_get_instance_private (popover);
GtkWidget *widget = GTK_WIDGET (popover);
GtkEventController *controller;
GtkStyleContext *context;
priv->position = GTK_POS_BOTTOM;
priv->final_position = GTK_POS_BOTTOM;
@@ -586,8 +587,8 @@ gtk_popover_init (GtkPopover *popover)
gtk_widget_set_layout_manager (priv->contents_widget, gtk_bin_layout_new ());
gtk_widget_set_parent (priv->contents_widget, GTK_WIDGET (popover));
context = gtk_widget_get_style_context (GTK_WIDGET (popover));
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BACKGROUND);
gtk_css_node_add_class (gtk_widget_get_css_node (GTK_WIDGET (popover)),
g_quark_from_static_string (GTK_STYLE_CLASS_BACKGROUND));
add_actions (popover);
}
@@ -775,10 +776,10 @@ gtk_popover_get_gap_coords (GtkPopover *popover,
gint tip_x, tip_y;
gint final_x, final_y;
GtkPositionType pos;
gint border_radius;
GtkStyleContext *context;
GtkBorder border;
int border_top, border_right, border_bottom;
int border_radius;
int popover_width, popover_height;
GtkCssStyle *style;
popover_width = gtk_widget_get_allocated_width (widget);
popover_height = gtk_widget_get_allocated_height (widget);
@@ -795,28 +796,27 @@ gtk_popover_get_gap_coords (GtkPopover *popover,
rect.x -= priv->final_rect.x;
rect.y -= priv->final_rect.y;
context = gtk_widget_get_style_context (priv->contents_widget);
pos = priv->final_position;
gtk_style_context_get_border (context, &border);
gtk_style_context_get (context,
GTK_STYLE_PROPERTY_BORDER_RADIUS, &border_radius,
NULL);
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
border_radius = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS), 100);
border_top = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
border_right = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
border_bottom = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
if (pos == GTK_POS_BOTTOM || pos == GTK_POS_RIGHT)
{
tip = 0;
base = TAIL_HEIGHT + border.top;
base = TAIL_HEIGHT + border_top;
}
else if (pos == GTK_POS_TOP)
{
base = popover_height - border.bottom - TAIL_HEIGHT;
base = popover_height - border_bottom - TAIL_HEIGHT;
tip = popover_height;
}
else if (pos == GTK_POS_LEFT)
{
base = popover_width - border.right - TAIL_HEIGHT;
base = popover_width - border_right - TAIL_HEIGHT;
tip = popover_width;
}
else
@@ -870,11 +870,16 @@ static void
get_margin (GtkWidget *widget,
GtkBorder *border)
{
GtkStyleContext *context;
GtkCssStyle *style;
context = gtk_widget_get_style_context (widget);
gtk_style_context_get_margin (context, border);
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
border->top = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_MARGIN_TOP), 100);
border->right = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_MARGIN_RIGHT), 100);
border->bottom = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_MARGIN_BOTTOM), 100);
border->left = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_MARGIN_LEFT), 100);
}
static void
gtk_popover_get_rect_for_size (GtkPopover *popover,
int popover_width,
@@ -923,6 +928,20 @@ gtk_popover_get_rect_coords (GtkPopover *popover,
*h_out = rect.height;
}
static void
get_border (GtkCssNode *node,
GtkBorder *border)
{
GtkCssStyle *style;
style = gtk_css_node_get_style (node);
border->top = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
border->right = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
border->bottom = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
border->left = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
}
static void
gtk_popover_apply_tail_path (GtkPopover *popover,
cairo_t *cr)
@@ -931,14 +950,12 @@ gtk_popover_apply_tail_path (GtkPopover *popover,
gint initial_x, initial_y;
gint tip_x, tip_y;
gint final_x, final_y;
GtkStyleContext *context;
GtkBorder border;
if (!priv->relative_to)
return;
context = gtk_widget_get_style_context (priv->contents_widget);
gtk_style_context_get_border (context, &border);
get_border (priv->arrow_node, &border);
cairo_set_line_width (cr, 1);
gtk_popover_get_gap_coords (popover,
@@ -957,11 +974,9 @@ gtk_popover_fill_border_path (GtkPopover *popover,
{
GtkWidget *widget = GTK_WIDGET (popover);
GtkAllocation allocation;
GtkStyleContext *context;
int x, y, w, h;
GskRoundedRect box;
context = gtk_widget_get_style_context (widget);
gtk_widget_get_allocation (widget, &allocation);
cairo_set_source_rgba (cr, 0, 0, 0, 1);
@@ -974,7 +989,7 @@ gtk_popover_fill_border_path (GtkPopover *popover,
gtk_rounded_boxes_init_for_style (&box,
NULL, NULL,
gtk_style_context_lookup_style (context),
gtk_css_node_get_style (gtk_widget_get_css_node (widget)),
x, y, w, h);
gsk_rounded_rect_path (&box, cr);
cairo_fill (cr);
@@ -1016,14 +1031,10 @@ gtk_popover_update_shape (GtkPopover *popover)
static gint
get_border_radius (GtkWidget *widget)
{
GtkStyleContext *context;
gint border_radius;
GtkCssStyle *style;
context = gtk_widget_get_style_context (widget);
gtk_style_context_get (context,
GTK_STYLE_PROPERTY_BORDER_RADIUS, &border_radius,
NULL);
return border_radius;
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
return round (_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS), 100));
}
static gint
@@ -1146,9 +1157,10 @@ create_arrow_render_node (GtkPopover *popover)
gtk_popover_apply_tail_path (popover, cr);
cairo_clip (cr);
get_border (priv->arrow_node, &border);
context = gtk_widget_get_style_context (widget);
gtk_style_context_save_to_node (context, priv->arrow_node);
gtk_style_context_get_border (context, &border);
/* Render the arrow background */
gtk_render_background (context, cr,
@@ -1159,15 +1171,17 @@ create_arrow_render_node (GtkPopover *popover)
/* Render the border of the arrow tip */
if (border.bottom > 0)
{
GdkRGBA *border_color;
GtkCssValue *value;
const GdkRGBA *border_color;
value = gtk_css_style_get_value (gtk_css_node_get_style (priv->arrow_node), GTK_CSS_PROPERTY_BORDER_LEFT_COLOR);
border_color = gtk_css_color_value_get_rgba (value);
gtk_style_context_get (context, "border-color", &border_color, NULL);
gtk_popover_apply_tail_path (popover, cr);
gdk_cairo_set_source_rgba (cr, border_color);
cairo_set_line_width (cr, border.bottom + 1);
cairo_stroke (cr);
gdk_rgba_free (border_color);
}
cairo_restore (cr);

View File

@@ -209,37 +209,6 @@ gtk_render_background (GtkStyleContext *context,
gsk_render_node_unref (node);
}
/**
* gtk_render_background_get_clip:
* @context: a #GtkStyleContext
* @x: X origin of the rectangle
* @y: Y origin of the rectangle
* @width: rectangle width
* @height: rectangle height
* @out_clip: (out): return location for the clip
*
* Returns the area that will be affected (i.e. drawn to) when
* calling gtk_render_background() for the given @context and
* rectangle.
*/
void
gtk_render_background_get_clip (GtkStyleContext *context,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GdkRectangle *out_clip)
{
GtkBorder shadow;
gtk_css_shadow_value_get_extents (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BOX_SHADOW), &shadow);
out_clip->x = floor (x) - shadow.left;
out_clip->y = floor (y) - shadow.top;
out_clip->width = ceil (width) + shadow.left + shadow.right;
out_clip->height = ceil (height) + shadow.top + shadow.bottom;
}
/**
* gtk_render_frame:
* @context: a #GtkStyleContext

View File

@@ -60,14 +60,6 @@ void gtk_render_background (GtkStyleContext *context,
gdouble width,
gdouble height);
GDK_AVAILABLE_IN_ALL
void gtk_render_background_get_clip (GtkStyleContext *context,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
GdkRectangle *out_clip);
GDK_AVAILABLE_IN_ALL
void gtk_render_frame (GtkStyleContext *context,
cairo_t *cr,

View File

@@ -269,63 +269,65 @@ void
gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
GtkSnapshot *snapshot)
{
GtkCssValue *background_image = gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BACKGROUND_IMAGE);
const GdkRGBA *bg_color = gtk_css_color_value_get_rgba (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
const GtkCssValue *box_shadow = gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BOX_SHADOW);
const gboolean has_bg_color = !gdk_rgba_is_clear (bg_color);
const gboolean has_bg_image = _gtk_css_image_value_get_image (_gtk_css_array_value_get_nth (background_image, 0)) != NULL;
const gboolean has_shadow = !gtk_css_shadow_value_is_none (box_shadow);
gint idx;
GtkCssValue *background_image;
GtkCssValue *box_shadow;
GtkCssValue *blend_modes;
const GdkRGBA *bg_color;
gint number_of_layers;
GskBlendMode *blend_mode_values;
background_image = gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BACKGROUND_IMAGE);
bg_color = gtk_css_color_value_get_rgba (gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
box_shadow = gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BOX_SHADOW);
/* This is the common default case of no background */
if (gdk_rgba_is_clear (bg_color) &&
_gtk_css_array_value_get_n_values (background_image) == 1 &&
_gtk_css_image_value_get_image (_gtk_css_array_value_get_nth (background_image, 0)) == NULL &&
gtk_css_shadow_value_is_none (box_shadow))
if (!has_bg_color && !has_bg_image && !has_shadow)
return;
gtk_snapshot_push_debug (snapshot, "CSS background");
gtk_css_shadow_value_snapshot_outset (box_shadow,
snapshot,
gtk_css_boxes_get_border_box (boxes));
if (has_shadow)
gtk_css_shadow_value_snapshot_outset (box_shadow,
snapshot,
gtk_css_boxes_get_border_box (boxes));
blend_modes = gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE);
number_of_layers = _gtk_css_array_value_get_n_values (background_image);
blend_mode_values = g_alloca (sizeof (GskBlendMode) * number_of_layers);
for (idx = number_of_layers - 1; idx >= 0; idx--)
if (has_bg_image)
{
blend_mode_values[idx] = _gtk_css_blend_mode_value_get (_gtk_css_array_value_get_nth (blend_modes, idx));
GtkCssValue *blend_modes = gtk_css_style_get_value (boxes->style, GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE);
const int number_of_layers = _gtk_css_array_value_get_n_values (background_image);
GskBlendMode *blend_mode_values = g_alloca (sizeof (GskBlendMode) * number_of_layers);
if (blend_mode_values[idx] != GSK_BLEND_MODE_DEFAULT)
gtk_snapshot_push_blend (snapshot, blend_mode_values[idx]);
}
if (!gdk_rgba_is_clear (bg_color))
gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, background_image);
for (idx = number_of_layers - 1; idx >= 0; idx--)
{
if (blend_mode_values[idx] == GSK_BLEND_MODE_DEFAULT)
for (idx = number_of_layers - 1; idx >= 0; idx--)
{
gtk_theming_background_snapshot_layer (boxes, idx, snapshot);
blend_mode_values[idx] = _gtk_css_blend_mode_value_get (_gtk_css_array_value_get_nth (blend_modes, idx));
if (blend_mode_values[idx] != GSK_BLEND_MODE_DEFAULT)
gtk_snapshot_push_blend (snapshot, blend_mode_values[idx]);
}
else
if (has_bg_color)
gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, background_image);
for (idx = number_of_layers - 1; idx >= 0; idx--)
{
gtk_snapshot_pop (snapshot);
gtk_theming_background_snapshot_layer (boxes, idx, snapshot);
gtk_snapshot_pop (snapshot);
if (blend_mode_values[idx] == GSK_BLEND_MODE_DEFAULT)
{
gtk_theming_background_snapshot_layer (boxes, idx, snapshot);
}
else
{
gtk_snapshot_pop (snapshot);
gtk_theming_background_snapshot_layer (boxes, idx, snapshot);
gtk_snapshot_pop (snapshot);
}
}
}
else if (has_bg_color)
{
gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, background_image);
}
gtk_css_shadow_value_snapshot_inset (box_shadow,
snapshot,
gtk_css_boxes_get_padding_box (boxes));
if (has_shadow)
gtk_css_shadow_value_snapshot_inset (box_shadow,
snapshot,
gtk_css_boxes_get_padding_box (boxes));
gtk_snapshot_pop (snapshot);
}

View File

@@ -1,268 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.Free
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include "gtkutilsprivate.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gstdio.h>
#include <gmodule.h>
/* Copied from pango-utils.c */
/* We need to call getc() a lot in a loop. This is suboptimal,
* as getc() does thread locking on the FILE it is given.
* To optimize that, lock the file first, then call getc(),
* then unlock.
* If locking functions are not present in libc, fall back
* to the suboptimal getc().
*/
#if !defined(HAVE_FLOCKFILE) && !defined(HAVE__LOCK_FILE)
# define flockfile(f) (void)1
# define funlockfile(f) (void)1
# define getc_unlocked(f) getc(f)
#elif !defined(HAVE_FLOCKFILE) && defined(HAVE__LOCK_FILE)
# define flockfile(f) _lock_file(f)
# define funlockfile(f) _unlock_file(f)
# define getc_unlocked(f) _getc_nolock(f)
#endif
gboolean
gtk_scan_string (const char **pos, GString *out)
{
const char *p = *pos, *q = *pos;
char *tmp, *tmp2;
gboolean quoted;
while (g_ascii_isspace (*p))
p++;
if (!*p)
return FALSE;
else if (*p == '"')
{
p++;
quoted = FALSE;
for (q = p; (*q != '"') || quoted; q++)
{
if (!*q)
return FALSE;
quoted = (*q == '\\') && !quoted;
}
tmp = g_strndup (p, q - p);
tmp2 = g_strcompress (tmp);
g_string_truncate (out, 0);
g_string_append (out, tmp2);
g_free (tmp);
g_free (tmp2);
}
q++;
*pos = q;
return TRUE;
}
gboolean
gtk_skip_space (const char **pos)
{
const char *p = *pos;
while (g_ascii_isspace (*p))
p++;
*pos = p;
return !(*p == '\0');
}
gint
gtk_read_line (FILE *stream, GString *str)
{
gboolean quoted = FALSE;
gboolean comment = FALSE;
int n_read = 0;
int lines = 1;
flockfile (stream);
g_string_truncate (str, 0);
while (1)
{
int c;
c = getc_unlocked (stream);
if (c == EOF)
{
if (quoted)
g_string_append_c (str, '\\');
goto done;
}
else
n_read++;
if (quoted)
{
quoted = FALSE;
switch (c)
{
case '#':
g_string_append_c (str, '#');
break;
case '\r':
case '\n':
{
int next_c = getc_unlocked (stream);
if (!(next_c == EOF ||
(c == '\r' && next_c == '\n') ||
(c == '\n' && next_c == '\r')))
ungetc (next_c, stream);
lines++;
break;
}
default:
g_string_append_c (str, '\\');
g_string_append_c (str, c);
}
}
else
{
switch (c)
{
case '#':
comment = TRUE;
break;
case '\\':
if (!comment)
quoted = TRUE;
break;
case '\n':
{
int next_c = getc_unlocked (stream);
if (!(c == EOF ||
(c == '\r' && next_c == '\n') ||
(c == '\n' && next_c == '\r')))
ungetc (next_c, stream);
goto done;
}
default:
if (!comment)
g_string_append_c (str, c);
}
}
}
done:
funlockfile (stream);
return (n_read > 0) ? lines : 0;
}
char *
gtk_trim_string (const char *str)
{
int len;
g_return_val_if_fail (str != NULL, NULL);
while (*str && g_ascii_isspace (*str))
str++;
len = strlen (str);
while (len > 0 && g_ascii_isspace (str[len - 1]))
len--;
return g_strndup (str, len);
}
char **
gtk_split_file_list (const char *str)
{
int i = 0;
int j;
char **files;
files = g_strsplit (str, G_SEARCHPATH_SEPARATOR_S, -1);
while (files[i])
{
char *file = gtk_trim_string (files[i]);
/* If the resulting file is empty, skip it */
if (file[0] == '\0')
{
g_free (file);
g_free (files[i]);
for (j = i + 1; files[j]; j++)
files[j - 1] = files[j];
files[j - 1] = NULL;
continue;
}
#ifndef G_OS_WIN32
/* '~' is a quite normal and common character in file names on
* Windows, especially in the 8.3 versions of long file names, which
* still occur now and then. Also, few Windows user are aware of the
* Unix shell convention that '~' stands for the home directory,
* even if they happen to have a home directory.
*/
if (file[0] == '~' && file[1] == G_DIR_SEPARATOR)
{
char *tmp = g_strconcat (g_get_home_dir(), file + 1, NULL);
g_free (file);
file = tmp;
}
else if (file[0] == '~' && file[1] == '\0')
{
g_free (file);
file = g_strdup (g_get_home_dir ());
}
#endif
g_free (files[i]);
files[i] = file;
i++;
}
return files;
}

View File

@@ -1,19 +0,0 @@
#ifndef __GTKUTILS_H__
#define __GTKUTILS_H__
#include <stdio.h>
#include <glib.h>
G_BEGIN_DECLS
gboolean gtk_scan_string (const char **pos,
GString *out);
gboolean gtk_skip_space (const char **pos);
gint gtk_read_line (FILE *stream,
GString *str);
char * gtk_trim_string (const char *str);
char ** gtk_split_file_list (const char *str);
G_END_DECLS
#endif

View File

@@ -5645,9 +5645,6 @@ gtk_widget_set_name (GtkWidget *widget,
g_free (priv->name);
priv->name = g_strdup (name);
if (priv->context)
gtk_style_context_set_id (priv->context, priv->name);
gtk_css_node_set_id (priv->cssnode, priv->name);
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_NAME]);
@@ -8099,7 +8096,7 @@ gtk_widget_propagate_state (GtkWidget *widget,
if (!gtk_widget_is_sensitive (widget) && gtk_widget_has_grab (widget))
gtk_grab_remove (widget);
gtk_style_context_set_state (_gtk_widget_get_style_context (widget), new_flags);
gtk_css_node_set_state (priv->cssnode, new_flags);
g_signal_emit (widget, widget_signals[STATE_FLAGS_CHANGED], 0, old_flags);
@@ -10482,7 +10479,6 @@ gtk_widget_do_pick (GtkWidget *widget,
child = _gtk_widget_get_prev_sibling (child))
{
GtkWidgetPrivate *child_priv = gtk_widget_get_instance_private (child);
GskTransform *transform;
GtkWidget *picked;
graphene_point3d_t res;
@@ -10494,39 +10490,41 @@ gtk_widget_do_pick (GtkWidget *widget,
if (child_priv->transform)
{
transform = gsk_transform_invert (gsk_transform_ref (child_priv->transform));
if (transform == NULL)
continue;
if (gsk_transform_get_category (child_priv->transform) >= GSK_TRANSFORM_CATEGORY_2D_AFFINE)
{
graphene_point_t transformed_p;
gsk_transform_transform_point (child_priv->transform,
&(graphene_point_t) { 0, 0 },
&transformed_p);
graphene_point3d_init (&res, x - transformed_p.x, y - transformed_p.y, 0.);
}
else
{
GskTransform *transform;
graphene_matrix_t inv;
graphene_point3d_t p0, p1;
transform = gsk_transform_invert (gsk_transform_ref (child_priv->transform));
if (transform == NULL)
continue;
gsk_transform_to_matrix (transform, &inv);
gsk_transform_unref (transform);
graphene_point3d_init (&p0, x, y, 0);
graphene_point3d_init (&p1, x, y, 1);
graphene_matrix_transform_point3d (&inv, &p0, &p0);
graphene_matrix_transform_point3d (&inv, &p1, &p1);
if (fabs (p0.z - p1.z) < 1.f / 4096)
continue;
graphene_point3d_interpolate (&p0, &p1, p0.z / (p0.z - p1.z), &res);
}
}
else
{
transform = NULL;
}
if (gsk_transform_get_category (transform) >= GSK_TRANSFORM_CATEGORY_2D_AFFINE)
{
graphene_point_t transformed_p;
gsk_transform_transform_point (transform,
&(graphene_point_t) { x, y },
&transformed_p);
graphene_point3d_init (&res, transformed_p.x, transformed_p.y, 0.);
}
else
{
graphene_matrix_t inv;
graphene_point3d_t p0, p1;
gsk_transform_to_matrix (transform, &inv);
gsk_transform_unref (transform);
graphene_point3d_init (&p0, x, y, 0);
graphene_point3d_init (&p1, x, y, 1);
graphene_matrix_transform_point3d (&inv, &p0, &p0);
graphene_matrix_transform_point3d (&inv, &p1, &p1);
if (fabs (p0.z - p1.z) < 1.f / 4096)
continue;
graphene_point3d_interpolate (&p0, &p1, p0.z / (p0.z - p1.z), &res);
graphene_point3d_init (&res, x, y, 0);
}
picked = gtk_widget_do_pick (child, res.x, res.y, flags);
@@ -11315,8 +11313,6 @@ gtk_widget_get_style_context (GtkWidget *widget)
priv->context = gtk_style_context_new_for_node (priv->cssnode);
gtk_style_context_set_id (priv->context, priv->name);
gtk_style_context_set_state (priv->context, priv->state_flags);
gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
display = _gtk_widget_get_display (widget);

View File

@@ -68,6 +68,7 @@
#include "gtkwidgetprivate.h"
#include "gtkwindowgroup.h"
#include "gtkpopovermenubarprivate.h"
#include "gtkcssboxesimplprivate.h"
#include "a11y/gtkwindowaccessibleprivate.h"
#include "a11y/gtkcontaineraccessibleprivate.h"
@@ -2354,17 +2355,14 @@ gtk_window_native_get_surface_transform (GtkNative *native,
int *x,
int *y)
{
GtkWindow *self = GTK_WINDOW (native);
GtkStyleContext *context;
GtkBorder margin, border, padding;
const graphene_rect_t *margin_rect;
GtkCssBoxes boxes;
context = gtk_widget_get_style_context (GTK_WIDGET (self));
gtk_style_context_get_margin (context, &margin);
gtk_style_context_get_border (context, &border);
gtk_style_context_get_padding (context, &padding);
gtk_css_boxes_init (&boxes, GTK_WIDGET (native));
margin_rect = gtk_css_boxes_get_margin_rect (&boxes);
*x = margin.left + border.left + padding.left;
*y = margin.top + border.top + padding.top;
*x = - margin_rect->origin.x;
*y = - margin_rect->origin.y;
}
static void

View File

@@ -391,7 +391,6 @@ gtk_public_sources = files([
'gtktreestore.c',
'gtktreeview.c',
'gtktreeviewcolumn.c',
'gtkutils.c',
'gtkvideo.c',
'gtkviewport.c',
'gtkvolumebutton.c',

View File

@@ -11,12 +11,6 @@ $menu_radius: 5px;
$window_radius: $button_radius + 3;
$popover_radius: $button_radius + 4;
* {
padding: 0;
-gtk-secondary-caret-color: $selected_bg_color
}
button:focus(visible),
checkbutton:focus(visible),
radiobutton:focus(visible),
@@ -163,8 +157,6 @@ flowbox {
}
label {
caret-color: currentColor; // this shouldn't be needed.
&.separator {
@extend .dim-label;
}
@@ -2276,6 +2268,20 @@ scrollbar {
background-color: $fg_color;
border: 1px solid if($variant == 'light', white, black);
}
&.horizontal {
> range > trough > slider {
margin: 0 2px;
min-width: $_slider_min_length;
}
}
&.vertical {
> range > trough > slider {
margin: 2px 0;
min-height: $_slider_min_length;
}
}
}
&.dragging,
@@ -2283,7 +2289,6 @@ scrollbar {
}
&.horizontal > range > trough > slider { min-width: $_slider_min_length; }
&.vertical > range > trough > slider { min-height: $_slider_min_length; }
}

View File

@@ -883,6 +883,10 @@ scrollbar.overlay-indicator:not(.dragging):not(.hovering) { border-color: transp
scrollbar.overlay-indicator:not(.dragging):not(.hovering) > range > trough > slider { margin: 0; min-width: 3px; min-height: 3px; background-color: #eeeeec; border: 1px solid black; }
scrollbar.overlay-indicator:not(.dragging):not(.hovering).horizontal > range > trough > slider { margin: 0 2px; min-width: 40px; }
scrollbar.overlay-indicator:not(.dragging):not(.hovering).vertical > range > trough > slider { margin: 2px 0; min-height: 40px; }
scrollbar.overlay-indicator.dragging, scrollbar.overlay-indicator.hovering { opacity: 0.8; }
scrollbar.horizontal > range > trough > slider { min-width: 40px; }

View File

@@ -891,6 +891,10 @@ scrollbar.overlay-indicator:not(.dragging):not(.hovering) { border-color: transp
scrollbar.overlay-indicator:not(.dragging):not(.hovering) > range > trough > slider { margin: 0; min-width: 3px; min-height: 3px; background-color: #2e3436; border: 1px solid white; }
scrollbar.overlay-indicator:not(.dragging):not(.hovering).horizontal > range > trough > slider { margin: 0 2px; min-width: 40px; }
scrollbar.overlay-indicator:not(.dragging):not(.hovering).vertical > range > trough > slider { margin: 2px 0; min-height: 40px; }
scrollbar.overlay-indicator.dragging, scrollbar.overlay-indicator.hovering { opacity: 0.8; }
scrollbar.horizontal > range > trough > slider { min-width: 40px; }