netsurf: branch master updated. release/3.10-263-gd082717
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/d082717ea653b61c36ebf...
...commit http://git.netsurf-browser.org/netsurf.git/commit/d082717ea653b61c36ebf06...
...tree http://git.netsurf-browser.org/netsurf.git/tree/d082717ea653b61c36ebf067a...
The branch, master has been updated
via d082717ea653b61c36ebf067a12d468abedc8e5f (commit)
via 64d90e014b3d95fe3fa37cdad09c37bee3e384d9 (commit)
from 8b7bbb415828c72ba1719d7ed210772ff7cc4dc8 (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/netsurf.git/commit/?id=d082717ea653b61c36e...
commit d082717ea653b61c36ebf067a12d468abedc8e5f
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
HTML: CSS media spec: Pass in dark mode preference.
diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index c6a2872..2b6b1a8 100644
--- a/content/handlers/html/html.c
+++ b/content/handlers/html/html.c
@@ -458,6 +458,8 @@ html_create_html_data(html_content *c, const http_parameter *params)
dom_hubbub_error error;
dom_exception err;
void *old_node_data;
+ const char *prefer_color_mode = (nsoption_bool(prefer_dark_mode)) ?
+ "dark" : "light";
c->parser = NULL;
c->parse_completed = false;
@@ -505,6 +507,13 @@ html_create_html_data(html_content *c, const http_parameter *params)
return NSERROR_NOMEM;
}
+ if (lwc_intern_string(prefer_color_mode, strlen(prefer_color_mode),
+ &c->media.prefers_color_scheme) != lwc_error_ok) {
+ lwc_string_unref(c->universal);
+ c->universal = NULL;
+ return NSERROR_NOMEM;
+ }
+
c->sel = selection_create((struct content *)c);
nerror = http_parameter_list_find_item(params, corestring_lwc_charset, &charset);
@@ -516,6 +525,8 @@ html_create_html_data(html_content *c, const http_parameter *params)
if (c->encoding == NULL) {
lwc_string_unref(c->universal);
c->universal = NULL;
+ lwc_string_unref(c->media.prefers_color_scheme);
+ c->media.prefers_color_scheme = NULL;
return NSERROR_NOMEM;
}
@@ -552,6 +563,8 @@ html_create_html_data(html_content *c, const http_parameter *params)
lwc_string_unref(c->universal);
c->universal = NULL;
+ lwc_string_unref(c->media.prefers_color_scheme);
+ c->media.prefers_color_scheme = NULL;
return libdom_hubbub_error_to_nserror(error);
}
@@ -568,6 +581,8 @@ html_create_html_data(html_content *c, const http_parameter *params)
lwc_string_unref(c->universal);
c->universal = NULL;
+ lwc_string_unref(c->media.prefers_color_scheme);
+ c->media.prefers_color_scheme = NULL;
NSLOG(netsurf, INFO, "Unable to set user data.");
return NSERROR_DOM;
@@ -1274,6 +1289,11 @@ static void html_destroy(struct content *c)
html->universal = NULL;
}
+ if (html->media.prefers_color_scheme != NULL) {
+ lwc_string_unref(html->media.prefers_color_scheme);
+ html->media.prefers_color_scheme = NULL;
+ }
+
/* Free stylesheets */
html_css_free_stylesheets(html);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=64d90e014b3d95fe3fa...
commit 64d90e014b3d95fe3fa37cdad09c37bee3e384d9
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Core: Options: Add user preference for dark mode colours
diff --git a/desktop/options.h b/desktop/options.h
index 539ff21..a12275e 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -255,6 +255,9 @@ NSOPTION_BOOL(enable_PDF_compression, true)
/** setting a password and encoding PDF documents */
NSOPTION_BOOL(enable_PDF_password, false)
+/** whether to prefer dark mode (light on dark) */
+NSOPTION_BOOL(prefer_dark_mode, false)
+
/******** System colours ********/
NSOPTION_COLOUR(sys_colour_ActiveBorder, 0x00d3d3d3)
NSOPTION_COLOUR(sys_colour_ActiveCaption, 0x00f1f1f1)
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/html.c | 20 ++++++++++++++++++++
desktop/options.h | 3 +++
2 files changed, 23 insertions(+)
diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index c6a2872..2b6b1a8 100644
--- a/content/handlers/html/html.c
+++ b/content/handlers/html/html.c
@@ -458,6 +458,8 @@ html_create_html_data(html_content *c, const http_parameter *params)
dom_hubbub_error error;
dom_exception err;
void *old_node_data;
+ const char *prefer_color_mode = (nsoption_bool(prefer_dark_mode)) ?
+ "dark" : "light";
c->parser = NULL;
c->parse_completed = false;
@@ -505,6 +507,13 @@ html_create_html_data(html_content *c, const http_parameter *params)
return NSERROR_NOMEM;
}
+ if (lwc_intern_string(prefer_color_mode, strlen(prefer_color_mode),
+ &c->media.prefers_color_scheme) != lwc_error_ok) {
+ lwc_string_unref(c->universal);
+ c->universal = NULL;
+ return NSERROR_NOMEM;
+ }
+
c->sel = selection_create((struct content *)c);
nerror = http_parameter_list_find_item(params, corestring_lwc_charset, &charset);
@@ -516,6 +525,8 @@ html_create_html_data(html_content *c, const http_parameter *params)
if (c->encoding == NULL) {
lwc_string_unref(c->universal);
c->universal = NULL;
+ lwc_string_unref(c->media.prefers_color_scheme);
+ c->media.prefers_color_scheme = NULL;
return NSERROR_NOMEM;
}
@@ -552,6 +563,8 @@ html_create_html_data(html_content *c, const http_parameter *params)
lwc_string_unref(c->universal);
c->universal = NULL;
+ lwc_string_unref(c->media.prefers_color_scheme);
+ c->media.prefers_color_scheme = NULL;
return libdom_hubbub_error_to_nserror(error);
}
@@ -568,6 +581,8 @@ html_create_html_data(html_content *c, const http_parameter *params)
lwc_string_unref(c->universal);
c->universal = NULL;
+ lwc_string_unref(c->media.prefers_color_scheme);
+ c->media.prefers_color_scheme = NULL;
NSLOG(netsurf, INFO, "Unable to set user data.");
return NSERROR_DOM;
@@ -1274,6 +1289,11 @@ static void html_destroy(struct content *c)
html->universal = NULL;
}
+ if (html->media.prefers_color_scheme != NULL) {
+ lwc_string_unref(html->media.prefers_color_scheme);
+ html->media.prefers_color_scheme = NULL;
+ }
+
/* Free stylesheets */
html_css_free_stylesheets(html);
diff --git a/desktop/options.h b/desktop/options.h
index 539ff21..a12275e 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -255,6 +255,9 @@ NSOPTION_BOOL(enable_PDF_compression, true)
/** setting a password and encoding PDF documents */
NSOPTION_BOOL(enable_PDF_password, false)
+/** whether to prefer dark mode (light on dark) */
+NSOPTION_BOOL(prefer_dark_mode, false)
+
/******** System colours ********/
NSOPTION_COLOUR(sys_colour_ActiveBorder, 0x00d3d3d3)
NSOPTION_COLOUR(sys_colour_ActiveCaption, 0x00f1f1f1)
--
NetSurf Browser
1 year, 1 month
libcss: branch master updated. release/0.9.1-38-gc0af9cf
by NetSurf Browser Project
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
1 year, 1 month