|
@@ -3356,6 +3356,101 @@ static void add_bg_size(struct br_decl *out, unsigned int *nout,
|
|
|
(void)kh;
|
|
(void)kh;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* Parse the `position / size` part of the background shorthand. The image
|
|
|
|
|
+ * URL may contain slashes, so only a slash outside url(...)/quotes counts. */
|
|
|
|
|
+static void add_bg_shorthand_extra(struct br_decl *out, unsigned int *nout,
|
|
|
|
|
+ const char *v, unsigned int len,
|
|
|
|
|
+ int important)
|
|
|
|
|
+{
|
|
|
|
|
+ unsigned int i, slash = 0, depth = 0, p, first, count;
|
|
|
|
|
+ char q = 0;
|
|
|
|
|
+ signed short nv;
|
|
|
|
|
+ int vert;
|
|
|
|
|
+ unsigned char kind;
|
|
|
|
|
+
|
|
|
|
|
+ for (i = 0; i < len; i++) {
|
|
|
|
|
+ char c = v[i];
|
|
|
|
|
+
|
|
|
|
|
+ if (q) {
|
|
|
|
|
+ if (c == q)
|
|
|
|
|
+ q = 0;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (c == '\'' || c == '"') {
|
|
|
|
|
+ q = c;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (c == '(') {
|
|
|
|
|
+ depth++;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (c == ')') {
|
|
|
|
|
+ if (depth)
|
|
|
|
|
+ depth--;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (c == '/' && !depth) {
|
|
|
|
|
+ slash = i;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!slash)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ /* Up to two position tokens immediately before the slash. */
|
|
|
|
|
+ p = slash;
|
|
|
|
|
+ first = slash;
|
|
|
|
|
+ count = 0;
|
|
|
|
|
+ while (count < 2) {
|
|
|
|
|
+ unsigned int e;
|
|
|
|
|
+
|
|
|
|
|
+ while (p > 0 && is_space(v[p - 1]))
|
|
|
|
|
+ p--;
|
|
|
|
|
+ e = p;
|
|
|
|
|
+ while (p > 0 && !is_space(v[p - 1]))
|
|
|
|
|
+ p--;
|
|
|
|
|
+ if (e == p)
|
|
|
|
|
+ break;
|
|
|
|
|
+ if (bg_keyword(v + p, e - p, &nv, &vert) ||
|
|
|
|
|
+ bg_number(v + p, e - p, &nv, &kind)) {
|
|
|
|
|
+ first = p;
|
|
|
|
|
+ count++;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (count)
|
|
|
|
|
+ add_bg_position(out, nout, v + first, slash - first,
|
|
|
|
|
+ important);
|
|
|
|
|
+
|
|
|
|
|
+ /* Up to two size tokens after the slash. */
|
|
|
|
|
+ p = slash + 1;
|
|
|
|
|
+ while (p < len && is_space(v[p]))
|
|
|
|
|
+ p++;
|
|
|
|
|
+ first = p;
|
|
|
|
|
+ count = 0;
|
|
|
|
|
+ while (count < 2) {
|
|
|
|
|
+ unsigned int ts = p;
|
|
|
|
|
+
|
|
|
|
|
+ while (p < len && !is_space(v[p]))
|
|
|
|
|
+ p++;
|
|
|
|
|
+ if (p == ts)
|
|
|
|
|
+ break;
|
|
|
|
|
+ if ((ts + 5 <= p && ci_eq_n(v + ts, "cover", 5)) ||
|
|
|
|
|
+ (ts + 7 <= p && ci_eq_n(v + ts, "contain", 7)) ||
|
|
|
|
|
+ (ts + 4 <= p && ci_eq_n(v + ts, "auto", 4)) ||
|
|
|
|
|
+ bg_number(v + ts, p - ts, &nv, &kind)) {
|
|
|
|
|
+ count++;
|
|
|
|
|
+ while (p < len && is_space(v[p]))
|
|
|
|
|
+ p++;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (count)
|
|
|
|
|
+ add_bg_size(out, nout, v + first, p - first, important);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static int parse_fixed_100(const char *s, unsigned int len,
|
|
static int parse_fixed_100(const char *s, unsigned int len,
|
|
|
unsigned int *pos, signed short *out)
|
|
unsigned int *pos, signed short *out)
|
|
|
{
|
|
{
|
|
@@ -4404,6 +4499,10 @@ static void parse_decls(struct br_doc *d, const char *s,
|
|
|
if (is_bg) {
|
|
if (is_bg) {
|
|
|
add_bg_image_decl(out, nout, s + vstart,
|
|
add_bg_image_decl(out, nout, s + vstart,
|
|
|
vend - vstart, important);
|
|
vend - vstart, important);
|
|
|
|
|
+ add_bg_shorthand_extra(out, nout,
|
|
|
|
|
+ s + vstart,
|
|
|
|
|
+ vend - vstart,
|
|
|
|
|
+ important);
|
|
|
if (contains_ci_len(s + vstart, vend - vstart,
|
|
if (contains_ci_len(s + vstart, vend - vstart,
|
|
|
"no-repeat"))
|
|
"no-repeat"))
|
|
|
decl_add(out, nout, PROP_BG_REPEAT, 1,
|
|
decl_add(out, nout, PROP_BG_REPEAT, 1,
|