st-shadow: Parse the 'inset' keyword
The box-shadow property in the CSS3 draft[0] supports the optional 'inset' keyword for inner shadows cast onto the background. Add support for the keyword to the shadow parsing code. [0] http://www.w3.org/TR/css3-background/#box-shadow https://bugzilla.gnome.org/show_bug.cgi?id=642334
This commit is contained in:
parent
794c986b10
commit
2b90be77b3
@ -291,6 +291,13 @@ st_icon_style_changed (StWidget *widget)
|
|||||||
}
|
}
|
||||||
priv->shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow");
|
priv->shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow");
|
||||||
|
|
||||||
|
if (priv->shadow_spec && priv->shadow_spec->inset)
|
||||||
|
{
|
||||||
|
g_warning ("The icon-shadow property does not support inset shadows");
|
||||||
|
st_shadow_unref (priv->shadow_spec);
|
||||||
|
priv->shadow_spec = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
priv->theme_icon_size = (int)(0.5 + st_theme_node_get_length (theme_node, "icon-size"));
|
priv->theme_icon_size = (int)(0.5 + st_theme_node_get_length (theme_node, "icon-size"));
|
||||||
st_icon_update_icon_size (self);
|
st_icon_update_icon_size (self);
|
||||||
st_icon_update (self);
|
st_icon_update (self);
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
* @yoffset: vertical offset
|
* @yoffset: vertical offset
|
||||||
* @blur: blur radius
|
* @blur: blur radius
|
||||||
* @spread: spread radius
|
* @spread: spread radius
|
||||||
|
* @inset: whether the shadow should be inset
|
||||||
*
|
*
|
||||||
* Creates a new #StShadow
|
* Creates a new #StShadow
|
||||||
*
|
*
|
||||||
@ -49,7 +50,8 @@ st_shadow_new (ClutterColor *color,
|
|||||||
gdouble xoffset,
|
gdouble xoffset,
|
||||||
gdouble yoffset,
|
gdouble yoffset,
|
||||||
gdouble blur,
|
gdouble blur,
|
||||||
gdouble spread)
|
gdouble spread,
|
||||||
|
gboolean inset)
|
||||||
{
|
{
|
||||||
StShadow *shadow;
|
StShadow *shadow;
|
||||||
|
|
||||||
@ -60,6 +62,7 @@ st_shadow_new (ClutterColor *color,
|
|||||||
shadow->yoffset = yoffset;
|
shadow->yoffset = yoffset;
|
||||||
shadow->blur = blur;
|
shadow->blur = blur;
|
||||||
shadow->spread = spread;
|
shadow->spread = spread;
|
||||||
|
shadow->inset = inset;
|
||||||
shadow->ref_count = 1;
|
shadow->ref_count = 1;
|
||||||
|
|
||||||
return shadow;
|
return shadow;
|
||||||
@ -129,7 +132,8 @@ st_shadow_equal (StShadow *shadow,
|
|||||||
shadow->xoffset == other->xoffset &&
|
shadow->xoffset == other->xoffset &&
|
||||||
shadow->yoffset == other->yoffset &&
|
shadow->yoffset == other->yoffset &&
|
||||||
shadow->blur == other->blur &&
|
shadow->blur == other->blur &&
|
||||||
shadow->spread == other->spread);
|
shadow->spread == other->spread &&
|
||||||
|
shadow->inset == other->inset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,6 +154,17 @@ st_shadow_get_box (StShadow *shadow,
|
|||||||
g_return_if_fail (actor_box != NULL);
|
g_return_if_fail (actor_box != NULL);
|
||||||
g_return_if_fail (shadow_box != NULL);
|
g_return_if_fail (shadow_box != NULL);
|
||||||
|
|
||||||
|
/* Inset shadows are drawn below the border, so returning
|
||||||
|
* the original box is not actually correct; still, it's
|
||||||
|
* good enough for the purpose of determing additional space
|
||||||
|
* required outside the actor box.
|
||||||
|
*/
|
||||||
|
if (shadow->inset)
|
||||||
|
{
|
||||||
|
*shadow_box = *actor_box;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
shadow_box->x1 = actor_box->x1 + shadow->xoffset
|
shadow_box->x1 = actor_box->x1 + shadow->xoffset
|
||||||
- shadow->blur - shadow->spread;
|
- shadow->blur - shadow->spread;
|
||||||
shadow_box->x2 = actor_box->x2 + shadow->xoffset
|
shadow_box->x2 = actor_box->x2 + shadow->xoffset
|
||||||
|
@ -48,6 +48,7 @@ struct _StShadow {
|
|||||||
gdouble yoffset;
|
gdouble yoffset;
|
||||||
gdouble blur;
|
gdouble blur;
|
||||||
gdouble spread;
|
gdouble spread;
|
||||||
|
gboolean inset;
|
||||||
volatile int ref_count;
|
volatile int ref_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -57,7 +58,8 @@ StShadow *st_shadow_new (ClutterColor *color,
|
|||||||
gdouble xoffset,
|
gdouble xoffset,
|
||||||
gdouble yoffset,
|
gdouble yoffset,
|
||||||
gdouble blur,
|
gdouble blur,
|
||||||
gdouble spread);
|
gdouble spread,
|
||||||
|
gboolean inset);
|
||||||
StShadow *st_shadow_ref (StShadow *shadow);
|
StShadow *st_shadow_ref (StShadow *shadow);
|
||||||
void st_shadow_unref (StShadow *shadow);
|
void st_shadow_unref (StShadow *shadow);
|
||||||
|
|
||||||
|
@ -2649,9 +2649,9 @@ parse_shadow_property (StThemeNode *node,
|
|||||||
gdouble *xoffset,
|
gdouble *xoffset,
|
||||||
gdouble *yoffset,
|
gdouble *yoffset,
|
||||||
gdouble *blur,
|
gdouble *blur,
|
||||||
gdouble *spread)
|
gdouble *spread,
|
||||||
|
gboolean *inset)
|
||||||
{
|
{
|
||||||
/* Set value for width/color/blur in any order */
|
|
||||||
GetFromTermResult result;
|
GetFromTermResult result;
|
||||||
CRTerm *term;
|
CRTerm *term;
|
||||||
int n_offsets = 0;
|
int n_offsets = 0;
|
||||||
@ -2662,7 +2662,17 @@ parse_shadow_property (StThemeNode *node,
|
|||||||
*yoffset = 0.;
|
*yoffset = 0.;
|
||||||
*blur = 0.;
|
*blur = 0.;
|
||||||
*spread = 0.;
|
*spread = 0.;
|
||||||
|
*inset = FALSE;
|
||||||
|
|
||||||
|
/* The CSS3 draft of the box-shadow property[0] is a lot stricter
|
||||||
|
* regarding the order of terms:
|
||||||
|
* If the 'inset' keyword is specified, it has to be first or last,
|
||||||
|
* and the color may not be mixed with the lengths; while we parse
|
||||||
|
* length values in the correct order, we allow for arbitrary
|
||||||
|
* placement of the color and 'inset' keyword.
|
||||||
|
*
|
||||||
|
* [0] http://www.w3.org/TR/css3-background/#box-shadow
|
||||||
|
*/
|
||||||
for (term = decl->value; term; term = term->next)
|
for (term = decl->value; term; term = term->next)
|
||||||
{
|
{
|
||||||
if (term->type == TERM_NUMBER)
|
if (term->type == TERM_NUMBER)
|
||||||
@ -2707,6 +2717,12 @@ parse_shadow_property (StThemeNode *node,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (term->type == TERM_IDENT &&
|
||||||
|
strcmp (term->content.str->stryng->str, "inset") == 0)
|
||||||
|
{
|
||||||
|
*inset = TRUE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
result = get_color_from_term (node, term, color);
|
result = get_color_from_term (node, term, color);
|
||||||
|
|
||||||
@ -2766,6 +2782,7 @@ st_theme_node_lookup_shadow (StThemeNode *node,
|
|||||||
gdouble yoffset = 0.;
|
gdouble yoffset = 0.;
|
||||||
gdouble blur = 0.;
|
gdouble blur = 0.;
|
||||||
gdouble spread = 0.;
|
gdouble spread = 0.;
|
||||||
|
gboolean inset = FALSE;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -2783,10 +2800,14 @@ st_theme_node_lookup_shadow (StThemeNode *node,
|
|||||||
&xoffset,
|
&xoffset,
|
||||||
&yoffset,
|
&yoffset,
|
||||||
&blur,
|
&blur,
|
||||||
&spread);
|
&spread,
|
||||||
|
&inset);
|
||||||
if (result == VALUE_FOUND)
|
if (result == VALUE_FOUND)
|
||||||
{
|
{
|
||||||
*shadow = st_shadow_new (&color, xoffset, yoffset, blur, spread);
|
*shadow = st_shadow_new (&color,
|
||||||
|
xoffset, yoffset,
|
||||||
|
blur, spread,
|
||||||
|
inset);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else if (result == VALUE_INHERIT)
|
else if (result == VALUE_INHERIT)
|
||||||
@ -2865,6 +2886,14 @@ st_theme_node_get_box_shadow (StThemeNode *node)
|
|||||||
FALSE,
|
FALSE,
|
||||||
&shadow))
|
&shadow))
|
||||||
{
|
{
|
||||||
|
if (shadow->inset)
|
||||||
|
{
|
||||||
|
g_warning ("Inset shadows are not implemented for the box-shadow "
|
||||||
|
"property");
|
||||||
|
st_shadow_unref (shadow);
|
||||||
|
shadow = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
node->box_shadow = shadow;
|
node->box_shadow = shadow;
|
||||||
|
|
||||||
return node->box_shadow;
|
return node->box_shadow;
|
||||||
@ -2898,6 +2927,14 @@ st_theme_node_get_background_image_shadow (StThemeNode *node)
|
|||||||
FALSE,
|
FALSE,
|
||||||
&shadow))
|
&shadow))
|
||||||
{
|
{
|
||||||
|
if (shadow->inset)
|
||||||
|
{
|
||||||
|
g_warning ("The -st-background-image-shadow property does not "
|
||||||
|
"support inset shadows");
|
||||||
|
st_shadow_unref (shadow);
|
||||||
|
shadow = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
node->background_image_shadow = shadow;
|
node->background_image_shadow = shadow;
|
||||||
|
|
||||||
return node->background_image_shadow;
|
return node->background_image_shadow;
|
||||||
@ -2938,6 +2975,13 @@ st_theme_node_get_text_shadow (StThemeNode *node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result && result->inset)
|
||||||
|
{
|
||||||
|
g_warning ("The text-shadow property does not support inset shadows");
|
||||||
|
st_shadow_unref (result);
|
||||||
|
result = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
node->text_shadow = result;
|
node->text_shadow = result;
|
||||||
node->text_shadow_computed = TRUE;
|
node->text_shadow_computed = TRUE;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user