Gitweb links:
...log
http://git.netsurf-browser.org/libcss.git/shortlog/c0af9cfa9adf8fdc94efa3...
...commit
http://git.netsurf-browser.org/libcss.git/commit/c0af9cfa9adf8fdc94efa32a...
...tree
http://git.netsurf-browser.org/libcss.git/tree/c0af9cfa9adf8fdc94efa32a68...
The branch, master has been updated
via c0af9cfa9adf8fdc94efa32a6847d7aebba0e107 (commit)
via eb055263ee7625512f44782428925c3b2298ff6f (commit)
from fa5bda25929f86133618d7ec9e664c6243f94eca (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libcss.git/commit/?id=c0af9cfa9adf8fdc94ef...
commit c0af9cfa9adf8fdc94efa32a6847d7aebba0e107
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Selection: Media queries: Apply prefers-color-scheme
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. */
commitdiff
http://git.netsurf-browser.org/libcss.git/commit/?id=eb055263ee7625512f44...
commit eb055263ee7625512f44782428925c3b2298ff6f
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
API: Client media spec: Allow colour scheme preference
diff --git a/include/libcss/types.h b/include/libcss/types.h
index 2b0dfb7..3fb28d3 100644
--- a/include/libcss/types.h
+++ b/include/libcss/types.h
@@ -223,6 +223,8 @@ typedef struct css_media {
css_fixed monochrome; /* monochrome bpp (0 for colour) */
css_fixed inverted_colors; /** boolean: {0|1} */
+ lwc_string *prefers_color_scheme; /* "light", "dark" */
+
/* Interaction media features */
css_media_pointer pointer;
css_media_pointer any_pointer;
-----------------------------------------------------------------------
Summary of changes:
include/libcss/types.h | 2 ++
src/select/mq.h | 33 +++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/include/libcss/types.h b/include/libcss/types.h
index 2b0dfb7..3fb28d3 100644
--- a/include/libcss/types.h
+++ b/include/libcss/types.h
@@ -223,6 +223,8 @@ typedef struct css_media {
css_fixed monochrome; /* monochrome bpp (0 for colour) */
css_fixed inverted_colors; /** boolean: {0|1} */
+ lwc_string *prefers_color_scheme; /* "light", "dark" */
+
/* Interaction media features */
css_media_pointer pointer;
css_media_pointer any_pointer;
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. */
--
Cascading Style Sheets library