summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parse/mq.c5
-rw-r--r--src/select/mq.h33
2 files changed, 34 insertions, 4 deletions
diff --git a/src/parse/mq.c b/src/parse/mq.c
index dde2bbe..b5478a1 100644
--- a/src/parse/mq.c
+++ b/src/parse/mq.c
@@ -1012,6 +1012,7 @@ static css_error mq_parse_media_query(lwc_string **strings,
return error;
}
+ result->type = CSS_MEDIA_ALL;
goto finished;
}
@@ -1066,10 +1067,6 @@ static css_error mq_parse_media_query(lwc_string **strings,
}
finished:
- if (result->type == 0) {
- result->type = CSS_MEDIA_ALL;
- }
-
*query = result;
return CSS_OK;
}
diff --git a/src/select/mq.h b/src/select/mq.h
index a012a7b..014814b 100644
--- a/src/select/mq.h
+++ b/src/select/mq.h
@@ -78,6 +78,31 @@ static inline bool mq_match_feature_range_length_op2(
}
}
+static inline bool mq_match_feature_eq_ident_op1(
+ css_mq_feature_op op,
+ const css_mq_value *value,
+ const lwc_string *client_value)
+{
+ bool is_match;
+
+ if (value->type != CSS_MQ_VALUE_TYPE_IDENT) {
+ return false;
+ }
+
+ if (value->data.ident == NULL || client_value == NULL) {
+ return false;
+ }
+
+ switch (op) {
+ case CSS_MQ_FEATURE_OP_EQ:
+ return (lwc_string_isequal(value->data.ident,
+ client_value, &is_match) == lwc_error_ok) &&
+ is_match;
+ default:
+ return false;
+ }
+}
+
/**
* Match media query features.
*
@@ -108,6 +133,14 @@ static inline bool mq_match_feature(
return mq_match_feature_range_length_op2(feat->op2,
&feat->value2, media->height, unit_ctx);
+
+ } else if (strcmp(lwc_string_data(feat->name), "prefers-color-scheme") == 0) {
+ if (!mq_match_feature_eq_ident_op1(feat->op, &feat->value,
+ media->prefers_color_scheme)) {
+ return false;
+ }
+
+ return true;
}
/* TODO: Look at other feature names. */