netsurf: branch vince/curlapiupdates updated. release/3.10-383-g46328a4
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/46328a4e206159c21fced...
...commit http://git.netsurf-browser.org/netsurf.git/commit/46328a4e206159c21fced3a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/46328a4e206159c21fced3a19...
The branch, vince/curlapiupdates has been updated
via 46328a4e206159c21fced3a19a01a40728d32b59 (commit)
from af4234d4f2fbd8d4e054fda702296ec887a92121 (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=46328a4e206159c21fc...
commit 46328a4e206159c21fced3a19a01a40728d32b59
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
resolve curl progress function deprication
diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c
index 35793c4..c892429 100644
--- a/content/fetchers/curl.c
+++ b/content/fetchers/curl.c
@@ -222,6 +222,16 @@ struct cert_info {
long err; /**< OpenSSL error code */
};
+#if LIBCURL_VERSION_NUM >= 0x072000 /* 7.32.0 depricated CURLOPT_PROGRESSFUNCTION*/
+#define NSCURLOPT_PROGRESS_FUNCTION CURLOPT_XFERINFOFUNCTION
+#define NSCURLOPT_PROGRESS_DATA CURLOPT_XFERINFODATA
+#define NSCURL_PROGRESS_T curl_off_t
+#else
+#define NSCURLOPT_PROGRESS_FUNCTION CURLOPT_PROGRESSFUNCTION
+#define NSCURLOPT_PROGRESS_DATA CURLOPT_PROGRESSDATA
+#define NSCURL_PROGRESS_T double
+#endif
+
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 depricated curl_formadd */
#define NSCURL_POSTDATA_T curl_mime
#define NSCURL_POSTDATA_CURLOPT CURLOPT_MIMEPOST
@@ -1168,7 +1178,7 @@ static CURLcode fetch_curl_set_options(struct curl_fetch_info *f)
SETOPT(CURLOPT_PRIVATE, f);
SETOPT(CURLOPT_WRITEDATA, f);
SETOPT(CURLOPT_WRITEHEADER, f);
- SETOPT(CURLOPT_PROGRESSDATA, f);
+ SETOPT(NSCURLOPT_PROGRESS_DATA, f);
SETOPT(CURLOPT_HTTPHEADER, f->headers);
code = fetch_curl_set_postdata(f);
if (code != CURLE_OK) {
@@ -1704,10 +1714,10 @@ static void fetch_curl_poll(lwc_string *scheme_ignored)
*/
static int
fetch_curl_progress(void *clientp,
- double dltotal,
- double dlnow,
- double ultotal,
- double ulnow)
+ NSCURL_PROGRESS_T dltotal,
+ NSCURL_PROGRESS_T dlnow,
+ NSCURL_PROGRESS_T ultotal,
+ NSCURL_PROGRESS_T ulnow)
{
static char fetch_progress_buffer[256]; /**< Progress buffer for cURL */
struct curl_fetch_info *f = (struct curl_fetch_info *) clientp;
@@ -2021,7 +2031,7 @@ nserror fetch_curl_register(void)
SETOPT(CURLOPT_WRITEFUNCTION, fetch_curl_data);
SETOPT(CURLOPT_HEADERFUNCTION, fetch_curl_header);
- SETOPT(CURLOPT_PROGRESSFUNCTION, fetch_curl_progress);
+ SETOPT(NSCURLOPT_PROGRESS_FUNCTION, fetch_curl_progress);
SETOPT(CURLOPT_NOPROGRESS, 0);
SETOPT(CURLOPT_USERAGENT, user_agent_string());
SETOPT(CURLOPT_ENCODING, "gzip");
-----------------------------------------------------------------------
Summary of changes:
content/fetchers/curl.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c
index 35793c4..c892429 100644
--- a/content/fetchers/curl.c
+++ b/content/fetchers/curl.c
@@ -222,6 +222,16 @@ struct cert_info {
long err; /**< OpenSSL error code */
};
+#if LIBCURL_VERSION_NUM >= 0x072000 /* 7.32.0 depricated CURLOPT_PROGRESSFUNCTION*/
+#define NSCURLOPT_PROGRESS_FUNCTION CURLOPT_XFERINFOFUNCTION
+#define NSCURLOPT_PROGRESS_DATA CURLOPT_XFERINFODATA
+#define NSCURL_PROGRESS_T curl_off_t
+#else
+#define NSCURLOPT_PROGRESS_FUNCTION CURLOPT_PROGRESSFUNCTION
+#define NSCURLOPT_PROGRESS_DATA CURLOPT_PROGRESSDATA
+#define NSCURL_PROGRESS_T double
+#endif
+
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 depricated curl_formadd */
#define NSCURL_POSTDATA_T curl_mime
#define NSCURL_POSTDATA_CURLOPT CURLOPT_MIMEPOST
@@ -1168,7 +1178,7 @@ static CURLcode fetch_curl_set_options(struct curl_fetch_info *f)
SETOPT(CURLOPT_PRIVATE, f);
SETOPT(CURLOPT_WRITEDATA, f);
SETOPT(CURLOPT_WRITEHEADER, f);
- SETOPT(CURLOPT_PROGRESSDATA, f);
+ SETOPT(NSCURLOPT_PROGRESS_DATA, f);
SETOPT(CURLOPT_HTTPHEADER, f->headers);
code = fetch_curl_set_postdata(f);
if (code != CURLE_OK) {
@@ -1704,10 +1714,10 @@ static void fetch_curl_poll(lwc_string *scheme_ignored)
*/
static int
fetch_curl_progress(void *clientp,
- double dltotal,
- double dlnow,
- double ultotal,
- double ulnow)
+ NSCURL_PROGRESS_T dltotal,
+ NSCURL_PROGRESS_T dlnow,
+ NSCURL_PROGRESS_T ultotal,
+ NSCURL_PROGRESS_T ulnow)
{
static char fetch_progress_buffer[256]; /**< Progress buffer for cURL */
struct curl_fetch_info *f = (struct curl_fetch_info *) clientp;
@@ -2021,7 +2031,7 @@ nserror fetch_curl_register(void)
SETOPT(CURLOPT_WRITEFUNCTION, fetch_curl_data);
SETOPT(CURLOPT_HEADERFUNCTION, fetch_curl_header);
- SETOPT(CURLOPT_PROGRESSFUNCTION, fetch_curl_progress);
+ SETOPT(NSCURLOPT_PROGRESS_FUNCTION, fetch_curl_progress);
SETOPT(CURLOPT_NOPROGRESS, 0);
SETOPT(CURLOPT_USERAGENT, user_agent_string());
SETOPT(CURLOPT_ENCODING, "gzip");
--
NetSurf Browser
11 hours, 29 minutes
netsurf: branch vince/curlapiupdates created. release/3.10-382-gaf4234d
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/af4234d4f2fbd8d4e054f...
...commit http://git.netsurf-browser.org/netsurf.git/commit/af4234d4f2fbd8d4e054fda...
...tree http://git.netsurf-browser.org/netsurf.git/tree/af4234d4f2fbd8d4e054fda70...
The branch, vince/curlapiupdates has been created
at af4234d4f2fbd8d4e054fda702296ec887a92121 (commit)
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=af4234d4f2fbd8d4e05...
commit af4234d4f2fbd8d4e054fda702296ec887a92121
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Remove use of depricated API after libcurl 7.56
diff --git a/content/fetch.h b/content/fetch.h
index 843fec9..e7180d0 100644
--- a/content/fetch.h
+++ b/content/fetch.h
@@ -94,6 +94,16 @@ typedef struct fetch_msg {
} fetch_msg;
/**
+ * Fetcher post data types
+ */
+typedef enum {
+ FETCH_POSTDATA_NONE,
+ FETCH_POSTDATA_URLENC,
+ FETCH_POSTDATA_MULTIPART,
+} fetch_postdata_type;
+
+
+/**
* Fetch POST multipart data
*/
struct fetch_multipart_data {
@@ -106,6 +116,20 @@ struct fetch_multipart_data {
bool file; /**< Item is a file */
};
+/**
+ * fetch POST data
+ */
+struct fetch_postdata {
+ fetch_postdata_type type;
+ union {
+ /** Url encoded POST string if type is FETCH_POSTDATA_URLENC */
+ char *urlenc;
+ /** Multipart post data if type is FETCH_POSTDATA_MULTIPART */
+ struct fetch_multipart_data *multipart;
+ } data;
+};
+
+
typedef void (*fetch_callback)(const fetch_msg *msg, void *p);
/**
diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c
index 1377ec7..35793c4 100644
--- a/content/fetchers/curl.c
+++ b/content/fetchers/curl.c
@@ -222,6 +222,16 @@ struct cert_info {
long err; /**< OpenSSL error code */
};
+#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 depricated curl_formadd */
+#define NSCURL_POSTDATA_T curl_mime
+#define NSCURL_POSTDATA_CURLOPT CURLOPT_MIMEPOST
+#define NSCURL_POSTDATA_FREE(x) curl_mime_free(x)
+#else
+#define NSCURL_POSTDATA_T struct curl_httppost
+#define NSCURL_POSTDATA_CURLOPT CURLOPT_HTTPPOST
+#define NSCURL_POSTDATA_FREE(x) curl_formfree(x)
+#endif
+
/** Information for a single fetch. */
struct curl_fetch_info {
struct fetch *fetch_handle; /**< The fetch handle we're parented by. */
@@ -239,9 +249,11 @@ struct curl_fetch_info {
unsigned long content_length; /**< Response Content-Length, or 0. */
char *cookie_string; /**< Cookie string for this fetch */
char *realm; /**< HTTP Auth Realm */
- char *post_urlenc; /**< Url encoded POST string, or 0. */
+ struct fetch_postdata *postdata; /**< POST data */
+ NSCURL_POSTDATA_T *curl_postdata; /**< POST data in curl representation */
+
long http_code; /**< HTTP result code from cURL. */
- struct curl_httppost *post_multipart; /**< Multipart post data, or 0. */
+
uint64_t last_progress_update; /**< Time of last progress update */
int cert_depth; /**< deepest certificate in use */
struct cert_info cert_data[MAX_CERT_DEPTH]; /**< HTTPS certificate data */
@@ -348,85 +360,59 @@ static bool fetch_curl_can_fetch(const nsurl *url)
}
+
/**
- * Convert a list of struct ::fetch_multipart_data to a list of
- * struct curl_httppost for libcurl.
+ * allocate postdata
*/
-static struct curl_httppost *
-fetch_curl_post_convert(const struct fetch_multipart_data *control)
+static struct fetch_postdata *
+fetch_curl_alloc_postdata(const char *post_urlenc,
+ const struct fetch_multipart_data *post_multipart)
{
- struct curl_httppost *post = 0, *last = 0;
- CURLFORMcode code;
- nserror ret;
-
- for (; control; control = control->next) {
- if (control->file) {
- char *leafname = NULL;
- ret = guit->file->basename(control->value, &leafname, NULL);
- if (ret != NSERROR_OK) {
- continue;
+ struct fetch_postdata *postdata;
+ postdata = calloc(1, sizeof(struct fetch_postdata));
+ if (postdata != NULL) {
+
+ if (post_urlenc) {
+ postdata->type = FETCH_POSTDATA_URLENC;
+ postdata->data.urlenc = strdup(post_urlenc);
+ if (postdata->data.urlenc == NULL) {
+ free(postdata);
+ postdata = NULL;
}
-
- /* We have to special case filenames of "", so curl
- * a) actually attempts the fetch and
- * b) doesn't attempt to open the file ""
- */
- if (control->value[0] == '\0') {
- /* dummy buffer - needs to be static so
- * pointer's still valid when we go out
- * of scope (not that libcurl should be
- * attempting to access it, of course).
- */
- static char buf;
-
- code = curl_formadd(&post, &last,
- CURLFORM_COPYNAME, control->name,
- CURLFORM_BUFFER, control->value,
- /* needed, as basename("") == "." */
- CURLFORM_FILENAME, "",
- CURLFORM_BUFFERPTR, &buf,
- CURLFORM_BUFFERLENGTH, 0,
- CURLFORM_CONTENTTYPE,
- "application/octet-stream",
- CURLFORM_END);
- if (code != CURL_FORMADD_OK)
- NSLOG(netsurf, INFO,
- "curl_formadd: %d (%s)", code,
- control->name);
- } else {
- char *mimetype = guit->fetch->mimetype(control->value);
- code = curl_formadd(&post, &last,
- CURLFORM_COPYNAME, control->name,
- CURLFORM_FILE, control->rawfile,
- CURLFORM_FILENAME, leafname,
- CURLFORM_CONTENTTYPE,
- (mimetype != 0 ? mimetype : "text/plain"),
- CURLFORM_END);
- if (code != CURL_FORMADD_OK)
- NSLOG(netsurf, INFO,
- "curl_formadd: %d (%s=%s)",
- code,
- control->name,
- control->value);
- free(mimetype);
+ } else if (post_multipart) {
+ postdata->type = FETCH_POSTDATA_MULTIPART;
+ postdata->data.multipart = fetch_multipart_data_clone(post_multipart);
+ if (postdata->data.multipart == NULL) {
+ free(postdata);
+ postdata = NULL;
}
- free(leafname);
- }
- else {
- code = curl_formadd(&post, &last,
- CURLFORM_COPYNAME, control->name,
- CURLFORM_COPYCONTENTS, control->value,
- CURLFORM_END);
- if (code != CURL_FORMADD_OK)
- NSLOG(netsurf, INFO,
- "curl_formadd: %d (%s=%s)", code,
- control->name, control->value);
+ } else {
+ postdata->type = FETCH_POSTDATA_NONE;
}
}
-
- return post;
+ return postdata;
}
+/**
+ * free postdata
+ */
+static void fetch_curl_free_postdata(struct fetch_postdata *postdata)
+{
+ if (postdata != NULL) {
+ switch (postdata->type) {
+ case FETCH_POSTDATA_NONE:
+ break;
+ case FETCH_POSTDATA_URLENC:
+ free(postdata->data.urlenc);
+ break;
+ case FETCH_POSTDATA_MULTIPART:
+ fetch_multipart_data_destroy(postdata->data.multipart);
+ break;
+ }
+
+ free(postdata);
+ }
+}
/**
* Start fetching data for the given URL.
@@ -481,30 +467,26 @@ fetch_curl_setup(struct fetch *parent_fetch,
fetch->headers = NULL;
fetch->url = nsurl_ref(url);
fetch->host = nsurl_get_component(url, NSURL_HOST);
+ if (fetch->host == NULL) {
+ goto failed;
+ }
+
fetch->location = NULL;
fetch->content_length = 0;
fetch->http_code = 0;
fetch->cookie_string = NULL;
fetch->realm = NULL;
- fetch->post_urlenc = NULL;
- fetch->post_multipart = NULL;
- if (post_urlenc) {
- fetch->post_urlenc = strdup(post_urlenc);
- } else if (post_multipart) {
- fetch->post_multipart = fetch_curl_post_convert(post_multipart);
- }
fetch->last_progress_update = 0;
+ fetch->postdata = fetch_curl_alloc_postdata(post_urlenc, post_multipart);
+ if (fetch->postdata == NULL) {
+ goto failed;
+ }
+ fetch->curl_postdata = NULL;
/* Clear certificate chain data */
memset(fetch->cert_data, 0, sizeof(fetch->cert_data));
fetch->cert_depth = -1;
- if ((fetch->host == NULL) ||
- (post_multipart != NULL && fetch->post_multipart == NULL) ||
- (post_urlenc != NULL && fetch->post_urlenc == NULL)) {
- goto failed;
- }
-
#define APPEND(list, value) \
slist = curl_slist_append(list, value); \
if (slist == NULL) \
@@ -554,9 +536,7 @@ failed:
lwc_string_unref(fetch->host);
nsurl_unref(fetch->url);
- free(fetch->post_urlenc);
- if (fetch->post_multipart)
- curl_formfree(fetch->post_multipart);
+ fetch_curl_free_postdata(fetch->postdata);
curl_slist_free_all(fetch->headers);
free(fetch);
return NULL;
@@ -867,6 +847,304 @@ fetch_curl_report_certs_upstream(struct curl_fetch_info *f)
f->sent_ssl_chain = true;
}
+#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 depricated curl_formadd */
+
+/**
+ * curl mime data context
+ */
+struct curl_mime_ctx {
+ char *buffer;
+ curl_off_t size;
+ curl_off_t position;
+};
+
+static size_t mime_data_read_callback(char *buffer, size_t size, size_t nitems, void *arg)
+{
+ struct curl_mime_ctx *mctx = (struct curl_mime_ctx *) arg;
+ curl_off_t sz = mctx->size - mctx->position;
+
+ nitems *= size;
+ if(sz > (curl_off_t)nitems) {
+ sz = nitems;
+ }
+ if(sz) {
+ memcpy(buffer, mctx->buffer + mctx->position, sz);
+ }
+ mctx->position += sz;
+ return sz;
+}
+
+static int mime_data_seek_callback(void *arg, curl_off_t offset, int origin)
+{
+ struct curl_mime_ctx *mctx = (struct curl_mime_ctx *) arg;
+
+ switch(origin) {
+ case SEEK_END:
+ offset += mctx->size;
+ break;
+ case SEEK_CUR:
+ offset += mctx->position;
+ break;
+ }
+
+ if(offset < 0) {
+ return CURL_SEEKFUNC_FAIL;
+ }
+ mctx->position = offset;
+ return CURL_SEEKFUNC_OK;
+}
+
+static void mime_data_free_callback(void *arg)
+{
+ struct curl_mime_ctx *mctx = (struct curl_mime_ctx *) arg;
+ free(mctx);
+}
+
+/**
+ * Convert a POST data list to a libcurl curl_mime.
+ *
+ * \param chandle curl fetch handle.
+ * \param multipart limked list of struct ::fetch_multipart forming post data.
+ */
+static curl_mime *
+fetch_curl_postdata_convert(CURL *chandle,
+ const struct fetch_multipart_data *multipart)
+{
+ curl_mime *cmime;
+ curl_mimepart *part;
+ CURLcode code;
+ size_t value_len;
+
+ cmime = curl_mime_init(chandle);
+ if (cmime == NULL) {
+ goto convert_failed;
+ }
+
+ /* iterate post data */
+ for (; multipart != NULL; multipart = multipart->next) {
+ part = curl_mime_addpart(cmime);
+ if (part == NULL) {
+ goto convert_failed;
+ }
+
+ code = curl_mime_name(part, multipart->name);
+ if (code != CURLE_OK) {
+ goto convert_failed;
+ }
+
+ value_len = strlen(multipart->value);
+
+ if (multipart->file && value_len==0) {
+ /* file entries with no filename require special handling */
+ code=curl_mime_data(part, multipart->value, value_len);
+ if (code != CURLE_OK) {
+ goto convert_failed;
+ }
+
+ code = curl_mime_filename(part, "");
+ if (code != CURLE_OK) {
+ goto convert_failed;
+ }
+
+ code = curl_mime_type(part, "application/octet-stream");
+ if (code != CURLE_OK) {
+ goto convert_failed;
+ }
+
+ } else if(multipart->file) {
+ /* file entry */
+ nserror ret;
+ char *leafname = NULL;
+ char *mimetype = NULL;
+
+ code = curl_mime_filedata(part, multipart->rawfile);
+ if (code != CURLE_OK) {
+ goto convert_failed;
+ }
+
+ ret = guit->file->basename(multipart->value, &leafname, NULL);
+ if (ret != NSERROR_OK) {
+ goto convert_failed;
+ }
+ code = curl_mime_filename(part, leafname);
+ free(leafname);
+ if (code != CURLE_OK) {
+ goto convert_failed;
+ }
+
+ mimetype = guit->fetch->mimetype(multipart->value);
+ if (mimetype == NULL) {
+ mimetype=strdup("text/plain");
+ }
+ if (mimetype == NULL) {
+ goto convert_failed;
+ }
+ code = curl_mime_type(part, mimetype);
+ free(mimetype);
+ if (code != CURLE_OK) {
+ goto convert_failed;
+ }
+
+ } else if(value_len > sizeof (struct curl_mime_ctx)) {
+ /* reference the existing multipart data */
+ struct curl_mime_ctx *cb_ctx;
+ cb_ctx = malloc(sizeof(struct curl_mime_ctx));
+ if (cb_ctx == NULL) {
+ goto convert_failed;
+ }
+ cb_ctx->buffer = multipart->value;
+ cb_ctx->size = value_len;
+ cb_ctx->position = 0;
+ code = curl_mime_data_cb(part,
+ value_len,
+ mime_data_read_callback,
+ mime_data_seek_callback,
+ mime_data_free_callback,
+ cb_ctx);
+ if (code != CURLE_OK) {
+ free(cb_ctx);
+ goto convert_failed;
+ }
+ } else {
+ /* simple copy data */
+ code=curl_mime_data(part, multipart->value, value_len);
+ if (code != CURLE_OK) {
+ goto convert_failed;
+ }
+ }
+ }
+
+ return cmime;
+
+convert_failed:
+ NSLOG(netsurf, INFO, "postdata conversion failed with curl code: %d", code);
+ curl_mime_free(cmime);
+ return NULL;
+}
+
+#else /* LIBCURL_VERSION_NUM >= 0x073800 */
+
+/**
+ * Convert a list of struct ::fetch_multipart_data to a list of
+ * struct curl_httppost for libcurl.
+ */
+static struct curl_httppost *
+fetch_curl_postdata_convert(CURL *chandle,
+ const struct fetch_multipart_data *control)
+{
+ struct curl_httppost *post = NULL, *last = NULL;
+ CURLFORMcode code;
+ nserror ret;
+
+ for (; control; control = control->next) {
+ if (control->file) {
+ char *leafname = NULL;
+ ret = guit->file->basename(control->value, &leafname, NULL);
+ if (ret != NSERROR_OK) {
+ continue;
+ }
+
+ /* We have to special case filenames of "", so curl
+ * a) actually attempts the fetch and
+ * b) doesn't attempt to open the file ""
+ */
+ if (control->value[0] == '\0') {
+ /* dummy buffer - needs to be static so
+ * pointer's still valid when we go out
+ * of scope (not that libcurl should be
+ * attempting to access it, of course).
+ */
+ static char buf;
+
+ code = curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, control->name,
+ CURLFORM_BUFFER, control->value,
+ /* needed, as basename("") == "." */
+ CURLFORM_FILENAME, "",
+ CURLFORM_BUFFERPTR, &buf,
+ CURLFORM_BUFFERLENGTH, 0,
+ CURLFORM_CONTENTTYPE,
+ "application/octet-stream",
+ CURLFORM_END);
+ if (code != CURL_FORMADD_OK)
+ NSLOG(netsurf, INFO,
+ "curl_formadd: %d (%s)", code,
+ control->name);
+ } else {
+ char *mimetype = guit->fetch->mimetype(control->value);
+ code = curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, control->name,
+ CURLFORM_FILE, control->rawfile,
+ CURLFORM_FILENAME, leafname,
+ CURLFORM_CONTENTTYPE,
+ (mimetype != 0 ? mimetype : "text/plain"),
+ CURLFORM_END);
+ if (code != CURL_FORMADD_OK)
+ NSLOG(netsurf, INFO,
+ "curl_formadd: %d (%s=%s)",
+ code,
+ control->name,
+ control->value);
+ free(mimetype);
+ }
+ free(leafname);
+ } else {
+ code = curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, control->name,
+ CURLFORM_COPYCONTENTS, control->value,
+ CURLFORM_END);
+ if (code != CURL_FORMADD_OK)
+ NSLOG(netsurf, INFO,
+ "curl_formadd: %d (%s=%s)", code,
+ control->name, control->value);
+ }
+ }
+
+ return post;
+}
+
+#endif /* LIBCURL_VERSION_NUM >= 0x073800 */
+
+/**
+ * Setup multipart post data
+ */
+static CURLcode fetch_curl_set_postdata(struct curl_fetch_info *f)
+{
+ CURLcode code;
+
+#undef SETOPT
+#define SETOPT(option, value) { \
+ code = curl_easy_setopt(f->curl_handle, option, value); \
+ if (code != CURLE_OK) \
+ return code; \
+ }
+
+ switch (f->postdata->type) {
+ case FETCH_POSTDATA_NONE:
+ SETOPT(CURLOPT_POSTFIELDS, NULL);
+ SETOPT(NSCURL_POSTDATA_CURLOPT, NULL);
+ SETOPT(CURLOPT_HTTPGET, 1L);
+ break;
+
+ case FETCH_POSTDATA_URLENC:
+ SETOPT(NSCURL_POSTDATA_CURLOPT, NULL);
+ SETOPT(CURLOPT_HTTPGET, 0L);
+ SETOPT(CURLOPT_POSTFIELDS, f->postdata->data.urlenc);
+ break;
+
+ case FETCH_POSTDATA_MULTIPART:
+ SETOPT(CURLOPT_POSTFIELDS, NULL);
+ SETOPT(CURLOPT_HTTPGET, 0L);
+ if (f->curl_postdata == NULL) {
+ f->curl_postdata =
+ fetch_curl_postdata_convert(f->curl_handle,
+ f->postdata->data.multipart);
+ }
+ SETOPT(NSCURL_POSTDATA_CURLOPT, f->curl_postdata);
+ break;
+ }
+ return code;
+}
/**
* Set options specific for a fetch.
@@ -892,18 +1170,9 @@ static CURLcode fetch_curl_set_options(struct curl_fetch_info *f)
SETOPT(CURLOPT_WRITEHEADER, f);
SETOPT(CURLOPT_PROGRESSDATA, f);
SETOPT(CURLOPT_HTTPHEADER, f->headers);
- if (f->post_urlenc) {
- SETOPT(CURLOPT_HTTPPOST, NULL);
- SETOPT(CURLOPT_HTTPGET, 0L);
- SETOPT(CURLOPT_POSTFIELDS, f->post_urlenc);
- } else if (f->post_multipart) {
- SETOPT(CURLOPT_POSTFIELDS, NULL);
- SETOPT(CURLOPT_HTTPGET, 0L);
- SETOPT(CURLOPT_HTTPPOST, f->post_multipart);
- } else {
- SETOPT(CURLOPT_POSTFIELDS, NULL);
- SETOPT(CURLOPT_HTTPPOST, NULL);
- SETOPT(CURLOPT_HTTPGET, 1L);
+ code = fetch_curl_set_postdata(f);
+ if (code != CURLE_OK) {
+ return code;
}
f->cookie_string = urldb_get_cookie(f->url, true);
@@ -1163,10 +1432,8 @@ static void fetch_curl_free(void *vf)
if (f->headers) {
curl_slist_free_all(f->headers);
}
- free(f->post_urlenc);
- if (f->post_multipart) {
- curl_formfree(f->post_multipart);
- }
+ fetch_curl_free_postdata(f->postdata);
+ NSCURL_POSTDATA_FREE(f->curl_postdata);
/* free certificate data */
for (i = 0; i < MAX_CERT_DEPTH; i++) {
@@ -1201,7 +1468,7 @@ static bool fetch_curl_process_headers(struct curl_fetch_info *f)
http_code = f->http_code;
NSLOG(netsurf, INFO, "HTTP status code %li", http_code);
- if (http_code == 304 && !f->post_urlenc && !f->post_multipart) {
+ if ((http_code == 304) && (f->postdata->type==FETCH_POSTDATA_NONE)) {
/* Not Modified && GET request */
msg.type = FETCH_NOTMODIFIED;
fetch_send_callback(&msg, f->fetch_handle);
-----------------------------------------------------------------------
--
NetSurf Browser
14 hours, 46 minutes
netsurf: branch master updated. release/3.10-381-gf68aca9
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/f68aca93b7e9f5dd05f1e...
...commit http://git.netsurf-browser.org/netsurf.git/commit/f68aca93b7e9f5dd05f1e49...
...tree http://git.netsurf-browser.org/netsurf.git/tree/f68aca93b7e9f5dd05f1e49ba...
The branch, master has been updated
via f68aca93b7e9f5dd05f1e49ba8ae70ada3ef3d1f (commit)
via d59f30c683b9c65a3380a8276247141989359acb (commit)
via 6fa4c04deaf516e938ab0f458cc931318b42ea32 (commit)
via 249e8472a2cdf8b822e46d1e28c91a41efded19d (commit)
via b19fcdd26fc33f0d03597e8cf411c073a99d5d3d (commit)
via dbe5d1ef87ff5a348ae758bdb9635f767822d7d4 (commit)
from bbeb93d512973f7c04714f7a43ea185c15ec65ba (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=f68aca93b7e9f5dd05f...
commit f68aca93b7e9f5dd05f1e49ba8ae70ada3ef3d1f
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
jpegxl: Ensure decoded bitmap format is converted to front end format
diff --git a/content/handlers/image/jpegxl.c b/content/handlers/image/jpegxl.c
index 0451e2a..01c7045 100644
--- a/content/handlers/image/jpegxl.c
+++ b/content/handlers/image/jpegxl.c
@@ -97,6 +97,17 @@ jpegxl_cache_convert(struct content *c)
const uint8_t *src_data;
size_t src_size;
uint8_t * output;
+ bitmap_fmt_t jxl_fmt = {
+ /** TODO: At the moment we have to set the layout to the only
+ * pixel layout that libjxl supports. It looks like they
+ * plan to add support for decoding to other layouts
+ * in the future, as shown by the TODO in the docs:
+ *
+ * https://libjxl.readthedocs.io/en/latest/api_common.html#_CPPv414JxlPixelF...
+ */
+ .layout = BITMAP_LAYOUT_R8G8B8A8,
+ .pma = bitmap_fmt.pma,
+ };
jxldec = JxlDecoderCreate(NULL);
if (jxldec == NULL) {
@@ -180,8 +191,9 @@ jpegxl_cache_convert(struct content *c)
JxlDecoderDestroy(jxldec);
+ bitmap_format_to_client(bitmap, &jxl_fmt);
guit->bitmap->modified(bitmap);
-
+
return bitmap;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=d59f30c683b9c65a338...
commit d59f30c683b9c65a3380a8276247141989359acb
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
jpegxl: Tell libjxl to decode unpremultiply alpha if needed
On some platforms our bitmap format does not use premultiplied alpha.
diff --git a/content/handlers/image/jpegxl.c b/content/handlers/image/jpegxl.c
index d5152fb..0451e2a 100644
--- a/content/handlers/image/jpegxl.c
+++ b/content/handlers/image/jpegxl.c
@@ -103,6 +103,15 @@ jpegxl_cache_convert(struct content *c)
NSLOG(netsurf, ERROR, "Unable to allocate decoder");
return NULL;
}
+
+ decstatus = JxlDecoderSetUnpremultiplyAlpha(jxldec, !bitmap_fmt.pma);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "unable to set premultiplied alpha status: %d",
+ decstatus);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
decstatus= JxlDecoderSubscribeEvents(jxldec, JXL_DEC_FULL_IMAGE);
if (decstatus != JXL_DEC_SUCCESS) {
NSLOG(netsurf, ERROR, "Unable to subscribe");
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=6fa4c04deaf516e938a...
commit 6fa4c04deaf516e938ab0f458cc931318b42ea32
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
jpegxl: Designated initialiser for output format struct
So I could see the meanings of how we'd set up the decode.
diff --git a/content/handlers/image/jpegxl.c b/content/handlers/image/jpegxl.c
index ba385f3..d5152fb 100644
--- a/content/handlers/image/jpegxl.c
+++ b/content/handlers/image/jpegxl.c
@@ -49,7 +49,12 @@
/**
* output image format
*/
-static const JxlPixelFormat jxl_output_format = {4, JXL_TYPE_UINT8, JXL_LITTLE_ENDIAN, 0};
+static const JxlPixelFormat jxl_output_format = {
+ .num_channels = 4,
+ .data_type = JXL_TYPE_UINT8,
+ .endianness = JXL_LITTLE_ENDIAN,
+ .align = 0,
+};
/**
* Content create entry point.
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=249e8472a2cdf8b822e...
commit 249e8472a2cdf8b822e46d1e28c91a41efded19d
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Makefile: Set libjxl to AUTO
diff --git a/Makefile.defaults b/Makefile.defaults
index 85be748..bbff688 100644
--- a/Makefile.defaults
+++ b/Makefile.defaults
@@ -51,6 +51,10 @@ NETSURF_USE_GIF := AUTO
# Valid options: YES, NO (highly recommended)
NETSURF_USE_JPEG := YES
+# Enable NetSurf's use of libjxl for displaying JPEGXLs
+# Valid options: YES, NO, AUTO (highly recommended)
+NETSURF_USE_JPEGXL := AUTO
+
# Enable NetSurf's use of libpng for displaying PNGs.
# Valid options: YES, NO, AUTO (highly recommended)
NETSURF_USE_PNG := AUTO
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=b19fcdd26fc33f0d035...
commit b19fcdd26fc33f0d03597e8cf411c073a99d5d3d
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
avoid the unecessary callback API
diff --git a/content/handlers/image/jpegxl.c b/content/handlers/image/jpegxl.c
index 4bba02d..ba385f3 100644
--- a/content/handlers/image/jpegxl.c
+++ b/content/handlers/image/jpegxl.c
@@ -79,20 +79,6 @@ nsjpegxl_create(const content_handler *handler,
return NSERROR_OK;
}
-static void image_out_callback(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels)
-{
- struct bitmap * bitmap = opaque;
- uint8_t * output;
-
- output = guit->bitmap->get_buffer(bitmap);
- if (output != NULL) {
- /* bitmap buffer available */
- memcpy(output + (x*jxl_output_format.num_channels) + (y * guit->bitmap->get_rowstride(bitmap)),
- pixels,
- num_pixels*jxl_output_format.num_channels);
- }
-}
-
/**
* create a bitmap from jpeg xl content.
*/
@@ -105,6 +91,7 @@ jpegxl_cache_convert(struct content *c)
JxlBasicInfo binfo;
const uint8_t *src_data;
size_t src_size;
+ uint8_t * output;
jxldec = JxlDecoderCreate(NULL);
if (jxldec == NULL) {
@@ -154,14 +141,14 @@ jpegxl_cache_convert(struct content *c)
}
/* ensure buffer was allocated */
- if (guit->bitmap->get_buffer(bitmap) == NULL) {
+ output = guit->bitmap->get_buffer(bitmap);
+ if (output == NULL) {
/* bitmap with no buffer available */
guit->bitmap->destroy(bitmap);
JxlDecoderDestroy(jxldec);
return NULL;
}
-
- decstatus = JxlDecoderSetImageOutCallback(jxldec, &jxl_output_format, image_out_callback, bitmap);
+ decstatus = JxlDecoderSetImageOutBuffer(jxldec, &jxl_output_format, output, c->size);
if (decstatus != JXL_DEC_SUCCESS) {
NSLOG(netsurf, ERROR, "unable to set output buffer callback status:%d",decstatus);
guit->bitmap->destroy(bitmap);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=dbe5d1ef87ff5a348ae...
commit dbe5d1ef87ff5a348ae758bdb9635f767822d7d4
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Implement simple jpeg xl image handler
diff --git a/Makefile b/Makefile
index 828f83b..05cb03e 100644
--- a/Makefile
+++ b/Makefile
@@ -171,6 +171,7 @@ endif
$(eval $(call pkg_config_find_and_add_enabled,OPENSSL,openssl,OpenSSL))
$(eval $(call pkg_config_find_and_add_enabled,UTF8PROC,libutf8proc,utf8))
+$(eval $(call pkg_config_find_and_add_enabled,JPEGXL,libjxl,JPEGXL))
$(eval $(call pkg_config_find_and_add_enabled,WEBP,libwebp,WEBP))
$(eval $(call pkg_config_find_and_add_enabled,PNG,libpng,PNG))
$(eval $(call pkg_config_find_and_add_enabled,BMP,libnsbmp,BMP))
diff --git a/content/handlers/image/Makefile b/content/handlers/image/Makefile
index afc90f4..ac052b3 100644
--- a/content/handlers/image/Makefile
+++ b/content/handlers/image/Makefile
@@ -7,6 +7,7 @@ S_IMAGE_$(NETSURF_USE_BMP) += bmp.c
S_IMAGE_$(NETSURF_USE_GIF) += gif.c
S_IMAGE_$(NETSURF_USE_BMP) += ico.c
S_IMAGE_$(NETSURF_USE_JPEG) += jpeg.c
+S_IMAGE_$(NETSURF_USE_JPEGXL) += jpegxl.c
S_IMAGE_$(NETSURF_USE_ROSPRITE) += nssprite.c
S_IMAGE_$(NETSURF_USE_PNG) += png.c
S_IMAGE_$(NETSURF_USE_NSSVG) += svg.c
diff --git a/content/handlers/image/image.c b/content/handlers/image/image.c
index 3107ee4..2bd5f5f 100644
--- a/content/handlers/image/image.c
+++ b/content/handlers/image/image.c
@@ -32,6 +32,7 @@
#include "image/gif.h"
#include "image/ico.h"
#include "image/jpeg.h"
+#include "image/jpegxl.h"
#include "image/nssprite.h"
#include "image/png.h"
#include "image/rsvg.h"
@@ -72,6 +73,12 @@ nserror image_init(void)
return error;
#endif
+#ifdef WITH_JPEGXL
+ error = nsjpegxl_init();
+ if (error != NSERROR_OK)
+ return error;
+#endif
+
#ifdef WITH_PNG
error = nspng_init();
if (error != NSERROR_OK)
diff --git a/content/handlers/image/jpegxl.c b/content/handlers/image/jpegxl.c
new file mode 100644
index 0000000..4bba02d
--- /dev/null
+++ b/content/handlers/image/jpegxl.c
@@ -0,0 +1,327 @@
+/*
+ * Copyright 2023 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * implementation of content handling for image/jpegxl
+ *
+ * This implementation uses the JXL library.
+ */
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <setjmp.h>
+#include <string.h>
+
+#include <jxl/decode.h>
+
+#include "utils/utils.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "netsurf/bitmap.h"
+#include "content/llcache.h"
+#include "content/content.h"
+#include "content/content_protected.h"
+#include "content/content_factory.h"
+#include "desktop/gui_internal.h"
+#include "desktop/bitmap.h"
+
+#include "image/image_cache.h"
+
+#include "image/jpegxl.h"
+
+
+/**
+ * output image format
+ */
+static const JxlPixelFormat jxl_output_format = {4, JXL_TYPE_UINT8, JXL_LITTLE_ENDIAN, 0};
+
+/**
+ * Content create entry point.
+ */
+static nserror
+nsjpegxl_create(const content_handler *handler,
+ lwc_string *imime_type, const struct http_parameter *params,
+ llcache_handle *llcache, const char *fallback_charset,
+ bool quirks, struct content **c)
+{
+ struct content *jpeg;
+ nserror error;
+
+ jpeg = calloc(1, sizeof(struct content));
+ if (jpeg == NULL)
+ return NSERROR_NOMEM;
+
+ error = content__init(jpeg, handler, imime_type, params,
+ llcache, fallback_charset, quirks);
+ if (error != NSERROR_OK) {
+ free(jpeg);
+ return error;
+ }
+
+ *c = jpeg;
+
+ return NSERROR_OK;
+}
+
+static void image_out_callback(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels)
+{
+ struct bitmap * bitmap = opaque;
+ uint8_t * output;
+
+ output = guit->bitmap->get_buffer(bitmap);
+ if (output != NULL) {
+ /* bitmap buffer available */
+ memcpy(output + (x*jxl_output_format.num_channels) + (y * guit->bitmap->get_rowstride(bitmap)),
+ pixels,
+ num_pixels*jxl_output_format.num_channels);
+ }
+}
+
+/**
+ * create a bitmap from jpeg xl content.
+ */
+static struct bitmap *
+jpegxl_cache_convert(struct content *c)
+{
+ struct bitmap * bitmap = NULL;
+ JxlDecoder *jxldec;
+ JxlDecoderStatus decstatus;
+ JxlBasicInfo binfo;
+ const uint8_t *src_data;
+ size_t src_size;
+
+ jxldec = JxlDecoderCreate(NULL);
+ if (jxldec == NULL) {
+ NSLOG(netsurf, ERROR, "Unable to allocate decoder");
+ return NULL;
+ }
+ decstatus= JxlDecoderSubscribeEvents(jxldec, JXL_DEC_FULL_IMAGE);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "Unable to subscribe");
+ return NULL;
+ }
+ src_data = content__get_source_data(c, &src_size);
+
+ decstatus = JxlDecoderSetInput(jxldec, src_data, src_size);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "unable to set input");
+ return NULL;
+ }
+
+ decstatus = JxlDecoderProcessInput(jxldec);
+ if (decstatus != JXL_DEC_NEED_IMAGE_OUT_BUFFER) {
+ NSLOG(netsurf, ERROR,
+ "expected status JXL_DEC_NEED_IMAGE_OUT_BUFFER(%d) got %d",
+ JXL_DEC_NEED_IMAGE_OUT_BUFFER,
+ decstatus);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ decstatus = JxlDecoderGetBasicInfo(jxldec, &binfo);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "unable to get basic info status:%d",decstatus);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ /* create bitmap with appropriate opacity */
+ if (binfo.alpha_bits > 0) {
+ bitmap = guit->bitmap->create(c->width, c->height, BITMAP_OPAQUE);
+ } else {
+ bitmap = guit->bitmap->create(c->width, c->height, BITMAP_NONE);
+ }
+ if (bitmap == NULL) {
+ /* empty bitmap could not be created */
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ /* ensure buffer was allocated */
+ if (guit->bitmap->get_buffer(bitmap) == NULL) {
+ /* bitmap with no buffer available */
+ guit->bitmap->destroy(bitmap);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ decstatus = JxlDecoderSetImageOutCallback(jxldec, &jxl_output_format, image_out_callback, bitmap);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "unable to set output buffer callback status:%d",decstatus);
+ guit->bitmap->destroy(bitmap);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ decstatus = JxlDecoderProcessInput(jxldec);
+ if (decstatus != JXL_DEC_FULL_IMAGE) {
+ NSLOG(netsurf, ERROR, "did not get decode event");
+ guit->bitmap->destroy(bitmap);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ JxlDecoderDestroy(jxldec);
+
+ guit->bitmap->modified(bitmap);
+
+ return bitmap;
+}
+
+/**
+ * report failiure
+ */
+static bool jxl_report_fail(struct content *c, JxlDecoderStatus decstatus, const char *msg)
+{
+ union content_msg_data msg_data;
+ NSLOG(netsurf, ERROR, "%s decoder status:%d", msg, decstatus);
+ msg_data.errordata.errorcode = NSERROR_UNKNOWN;
+ msg_data.errordata.errormsg = msg;
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
+ return false;
+}
+
+/**
+ * Convert a CONTENT_JPEGXL for display.
+ */
+static bool nsjpegxl_convert(struct content *c)
+{
+ JxlDecoder *jxldec;
+ JxlSignature decsig;
+ JxlDecoderStatus decstatus = JXL_DEC_ERROR;
+ JxlBasicInfo binfo;
+ union content_msg_data msg_data;
+ const uint8_t *data;
+ size_t size;
+ char *title;
+ size_t image_size;
+
+ /* check image header is valid and get width/height */
+ data = content__get_source_data(c, &size);
+
+ decsig = JxlSignatureCheck(data,size);
+ if ((decsig != JXL_SIG_CODESTREAM) && (decsig != JXL_SIG_CONTAINER)) {
+ NSLOG(netsurf, ERROR, "signature failed");
+ msg_data.errordata.errorcode = NSERROR_UNKNOWN;
+ msg_data.errordata.errormsg = "Signature failed";
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
+ return false;
+ }
+
+ jxldec = JxlDecoderCreate(NULL);
+ if (jxldec == NULL) {
+ return jxl_report_fail(c, decstatus, "Unable to allocate decoder");
+ }
+ decstatus= JxlDecoderSubscribeEvents(jxldec, JXL_DEC_BASIC_INFO);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ return jxl_report_fail(c, decstatus, "Unable to subscribe");
+ }
+ decstatus = JxlDecoderSetInput(jxldec, data,size);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ return jxl_report_fail(c, decstatus, "unable to set input");
+ }
+ decstatus = JxlDecoderProcessInput(jxldec);
+ if (decstatus != JXL_DEC_BASIC_INFO) {
+ return jxl_report_fail(c, decstatus, "did not get basic info event");
+ }
+ decstatus = JxlDecoderGetBasicInfo(jxldec, &binfo);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ return jxl_report_fail(c, decstatus, "unable to get basic info");
+ }
+ decstatus = JxlDecoderImageOutBufferSize(jxldec, &jxl_output_format, &image_size);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ return jxl_report_fail(c, decstatus, "unable get image size");
+ }
+
+ JxlDecoderDestroy(jxldec);
+
+ NSLOG(netsurf, INFO, "got basic info size:%ld x:%d y:%d", image_size, binfo.xsize, binfo.ysize);
+
+ c->width = binfo.xsize;
+ c->height = binfo.ysize;
+ c->size = image_size;
+
+ image_cache_add(c, NULL, jpegxl_cache_convert);
+
+ /* set title text */
+ title = messages_get_buff("JPEGXLTitle",
+ nsurl_access_leaf(llcache_handle_get_url(c->llcache)),
+ c->width, c->height);
+ if (title != NULL) {
+ content__set_title(c, title);
+ free(title);
+ }
+
+ content_set_ready(c);
+ content_set_done(c);
+ content_set_status(c, ""); /* Done: update status bar */
+
+ return true;
+}
+
+
+/**
+ * Clone content.
+ */
+static nserror nsjpegxl_clone(const struct content *old, struct content **newc)
+{
+ struct content *jpegxl_c;
+ nserror error;
+
+ jpegxl_c = calloc(1, sizeof(struct content));
+ if (jpegxl_c == NULL)
+ return NSERROR_NOMEM;
+
+ error = content__clone(old, jpegxl_c);
+ if (error != NSERROR_OK) {
+ content_destroy(jpegxl_c);
+ return error;
+ }
+
+ /* re-convert if the content is ready */
+ if ((old->status == CONTENT_STATUS_READY) ||
+ (old->status == CONTENT_STATUS_DONE)) {
+ if (nsjpegxl_convert(jpegxl_c) == false) {
+ content_destroy(jpegxl_c);
+ return NSERROR_CLONE_FAILED;
+ }
+ }
+
+ *newc = jpegxl_c;
+
+ return NSERROR_OK;
+}
+
+static const content_handler nsjpegxl_content_handler = {
+ .create = nsjpegxl_create,
+ .data_complete = nsjpegxl_convert,
+ .destroy = image_cache_destroy,
+ .redraw = image_cache_redraw,
+ .clone = nsjpegxl_clone,
+ .get_internal = image_cache_get_internal,
+ .type = image_cache_content_type,
+ .is_opaque = image_cache_is_opaque,
+ .no_share = false,
+};
+
+static const char *nsjpegxl_types[] = {
+ "image/jxl",
+};
+
+CONTENT_FACTORY_REGISTER_TYPES(nsjpegxl, nsjpegxl_types, nsjpegxl_content_handler);
diff --git a/content/handlers/image/jpegxl.h b/content/handlers/image/jpegxl.h
new file mode 100644
index 0000000..e37d934
--- /dev/null
+++ b/content/handlers/image/jpegxl.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2023 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Content for image/jpegxl (interface).
+ */
+
+#ifndef _NETSURF_IMAGE_JPEGXL_H_
+#define _NETSURF_IMAGE_JPEGXL_H_
+
+nserror nsjpegxl_init(void);
+
+#endif
diff --git a/content/mimesniff.c b/content/mimesniff.c
index 9a11834..adc000d 100644
--- a/content/mimesniff.c
+++ b/content/mimesniff.c
@@ -260,6 +260,13 @@ static nserror mimesniff__match_unknown_exact(const uint8_t *data, size_t len,
SIG(&corestring_lwc_application_x_gzip, "\x1f\x8b\x08", true),
SIG(&corestring_lwc_application_postscript, "%!PS-Adobe-",true),
SIG(&corestring_lwc_application_pdf, "%PDF-", false),
+ SIG(&corestring_lwc_image_jxl, "\xFF\x0A", true), /* containerless jpeg xl*/
+ {
+ (const uint8_t *)"\x00\x00\x00\x0CJXL \x0D\x0A\x87\x0A",
+ 12,
+ true,
+ &corestring_lwc_image_jxl
+ }, /* containered jpeg xl*/
{ NULL, 0, false, NULL }
};
#undef SIG
@@ -376,6 +383,12 @@ static nserror mimesniff__compute_image(lwc_string *official_type,
SIG(&corestring_lwc_image_jpeg, "\xff\xd8\xff"),
SIG(&corestring_lwc_image_bmp, "BM"),
SIG(&corestring_lwc_image_vnd_microsoft_icon, "\x00\x00\x01\x00"),
+ SIG(&corestring_lwc_image_jxl, "\xFF\x0A"), /* containerless jpeg xl*/
+ {
+ (const uint8_t *)"\x00\x00\x00\x0CJXL \x0D\x0A\x87\x0A",
+ 12,
+ &corestring_lwc_image_jxl
+ }, /* containered jpeg xl*/
{ NULL, 0, NULL }
};
#undef SIG
diff --git a/frontends/gtk/fetch.c b/frontends/gtk/fetch.c
index 58bd0b8..d77073a 100644
--- a/frontends/gtk/fetch.c
+++ b/frontends/gtk/fetch.c
@@ -75,6 +75,7 @@ void gtk_fetch_filetype_init(const char *mimefile)
hash_add(mime_hash, "html", "text/html");
hash_add(mime_hash, "jpg", "image/jpeg");
hash_add(mime_hash, "jpeg", "image/jpeg");
+ hash_add(mime_hash, "jxl", "image/jxl");
hash_add(mime_hash, "gif", "image/gif");
hash_add(mime_hash, "png", "image/png");
hash_add(mime_hash, "jng", "image/jng");
diff --git a/utils/corestringlist.h b/utils/corestringlist.h
index b253b3b..5cdbb3a 100644
--- a/utils/corestringlist.h
+++ b/utils/corestringlist.h
@@ -167,6 +167,7 @@ CORESTRING_LWC_VALUE(application_octet_stream, "application/octet-stream");
CORESTRING_LWC_VALUE(image_gif, "image/gif");
CORESTRING_LWC_VALUE(image_png, "image/png");
CORESTRING_LWC_VALUE(image_jpeg, "image/jpeg");
+CORESTRING_LWC_VALUE(image_jxl, "image/jxl");
CORESTRING_LWC_VALUE(image_bmp, "image/bmp");
CORESTRING_LWC_VALUE(image_vnd_microsoft_icon, "image/vnd.microsoft.icon");
CORESTRING_LWC_VALUE(image_webp, "image/webp");
-----------------------------------------------------------------------
Summary of changes:
Makefile | 1 +
Makefile.defaults | 4 +
content/handlers/image/Makefile | 1 +
content/handlers/image/image.c | 7 +
content/handlers/image/jpegxl.c | 340 ++++++++++++++++++++++++++++
content/handlers/image/{svg.h => jpegxl.h} | 10 +-
content/mimesniff.c | 13 ++
frontends/gtk/fetch.c | 1 +
utils/corestringlist.h | 1 +
9 files changed, 373 insertions(+), 5 deletions(-)
create mode 100644 content/handlers/image/jpegxl.c
copy content/handlers/image/{svg.h => jpegxl.h} (77%)
diff --git a/Makefile b/Makefile
index 828f83b..05cb03e 100644
--- a/Makefile
+++ b/Makefile
@@ -171,6 +171,7 @@ endif
$(eval $(call pkg_config_find_and_add_enabled,OPENSSL,openssl,OpenSSL))
$(eval $(call pkg_config_find_and_add_enabled,UTF8PROC,libutf8proc,utf8))
+$(eval $(call pkg_config_find_and_add_enabled,JPEGXL,libjxl,JPEGXL))
$(eval $(call pkg_config_find_and_add_enabled,WEBP,libwebp,WEBP))
$(eval $(call pkg_config_find_and_add_enabled,PNG,libpng,PNG))
$(eval $(call pkg_config_find_and_add_enabled,BMP,libnsbmp,BMP))
diff --git a/Makefile.defaults b/Makefile.defaults
index 85be748..bbff688 100644
--- a/Makefile.defaults
+++ b/Makefile.defaults
@@ -51,6 +51,10 @@ NETSURF_USE_GIF := AUTO
# Valid options: YES, NO (highly recommended)
NETSURF_USE_JPEG := YES
+# Enable NetSurf's use of libjxl for displaying JPEGXLs
+# Valid options: YES, NO, AUTO (highly recommended)
+NETSURF_USE_JPEGXL := AUTO
+
# Enable NetSurf's use of libpng for displaying PNGs.
# Valid options: YES, NO, AUTO (highly recommended)
NETSURF_USE_PNG := AUTO
diff --git a/content/handlers/image/Makefile b/content/handlers/image/Makefile
index afc90f4..ac052b3 100644
--- a/content/handlers/image/Makefile
+++ b/content/handlers/image/Makefile
@@ -7,6 +7,7 @@ S_IMAGE_$(NETSURF_USE_BMP) += bmp.c
S_IMAGE_$(NETSURF_USE_GIF) += gif.c
S_IMAGE_$(NETSURF_USE_BMP) += ico.c
S_IMAGE_$(NETSURF_USE_JPEG) += jpeg.c
+S_IMAGE_$(NETSURF_USE_JPEGXL) += jpegxl.c
S_IMAGE_$(NETSURF_USE_ROSPRITE) += nssprite.c
S_IMAGE_$(NETSURF_USE_PNG) += png.c
S_IMAGE_$(NETSURF_USE_NSSVG) += svg.c
diff --git a/content/handlers/image/image.c b/content/handlers/image/image.c
index 3107ee4..2bd5f5f 100644
--- a/content/handlers/image/image.c
+++ b/content/handlers/image/image.c
@@ -32,6 +32,7 @@
#include "image/gif.h"
#include "image/ico.h"
#include "image/jpeg.h"
+#include "image/jpegxl.h"
#include "image/nssprite.h"
#include "image/png.h"
#include "image/rsvg.h"
@@ -72,6 +73,12 @@ nserror image_init(void)
return error;
#endif
+#ifdef WITH_JPEGXL
+ error = nsjpegxl_init();
+ if (error != NSERROR_OK)
+ return error;
+#endif
+
#ifdef WITH_PNG
error = nspng_init();
if (error != NSERROR_OK)
diff --git a/content/handlers/image/jpegxl.c b/content/handlers/image/jpegxl.c
new file mode 100644
index 0000000..01c7045
--- /dev/null
+++ b/content/handlers/image/jpegxl.c
@@ -0,0 +1,340 @@
+/*
+ * Copyright 2023 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * implementation of content handling for image/jpegxl
+ *
+ * This implementation uses the JXL library.
+ */
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <setjmp.h>
+#include <string.h>
+
+#include <jxl/decode.h>
+
+#include "utils/utils.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "netsurf/bitmap.h"
+#include "content/llcache.h"
+#include "content/content.h"
+#include "content/content_protected.h"
+#include "content/content_factory.h"
+#include "desktop/gui_internal.h"
+#include "desktop/bitmap.h"
+
+#include "image/image_cache.h"
+
+#include "image/jpegxl.h"
+
+
+/**
+ * output image format
+ */
+static const JxlPixelFormat jxl_output_format = {
+ .num_channels = 4,
+ .data_type = JXL_TYPE_UINT8,
+ .endianness = JXL_LITTLE_ENDIAN,
+ .align = 0,
+};
+
+/**
+ * Content create entry point.
+ */
+static nserror
+nsjpegxl_create(const content_handler *handler,
+ lwc_string *imime_type, const struct http_parameter *params,
+ llcache_handle *llcache, const char *fallback_charset,
+ bool quirks, struct content **c)
+{
+ struct content *jpeg;
+ nserror error;
+
+ jpeg = calloc(1, sizeof(struct content));
+ if (jpeg == NULL)
+ return NSERROR_NOMEM;
+
+ error = content__init(jpeg, handler, imime_type, params,
+ llcache, fallback_charset, quirks);
+ if (error != NSERROR_OK) {
+ free(jpeg);
+ return error;
+ }
+
+ *c = jpeg;
+
+ return NSERROR_OK;
+}
+
+/**
+ * create a bitmap from jpeg xl content.
+ */
+static struct bitmap *
+jpegxl_cache_convert(struct content *c)
+{
+ struct bitmap * bitmap = NULL;
+ JxlDecoder *jxldec;
+ JxlDecoderStatus decstatus;
+ JxlBasicInfo binfo;
+ const uint8_t *src_data;
+ size_t src_size;
+ uint8_t * output;
+ bitmap_fmt_t jxl_fmt = {
+ /** TODO: At the moment we have to set the layout to the only
+ * pixel layout that libjxl supports. It looks like they
+ * plan to add support for decoding to other layouts
+ * in the future, as shown by the TODO in the docs:
+ *
+ * https://libjxl.readthedocs.io/en/latest/api_common.html#_CPPv414JxlPixelF...
+ */
+ .layout = BITMAP_LAYOUT_R8G8B8A8,
+ .pma = bitmap_fmt.pma,
+ };
+
+ jxldec = JxlDecoderCreate(NULL);
+ if (jxldec == NULL) {
+ NSLOG(netsurf, ERROR, "Unable to allocate decoder");
+ return NULL;
+ }
+
+ decstatus = JxlDecoderSetUnpremultiplyAlpha(jxldec, !bitmap_fmt.pma);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "unable to set premultiplied alpha status: %d",
+ decstatus);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ decstatus= JxlDecoderSubscribeEvents(jxldec, JXL_DEC_FULL_IMAGE);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "Unable to subscribe");
+ return NULL;
+ }
+ src_data = content__get_source_data(c, &src_size);
+
+ decstatus = JxlDecoderSetInput(jxldec, src_data, src_size);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "unable to set input");
+ return NULL;
+ }
+
+ decstatus = JxlDecoderProcessInput(jxldec);
+ if (decstatus != JXL_DEC_NEED_IMAGE_OUT_BUFFER) {
+ NSLOG(netsurf, ERROR,
+ "expected status JXL_DEC_NEED_IMAGE_OUT_BUFFER(%d) got %d",
+ JXL_DEC_NEED_IMAGE_OUT_BUFFER,
+ decstatus);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ decstatus = JxlDecoderGetBasicInfo(jxldec, &binfo);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "unable to get basic info status:%d",decstatus);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ /* create bitmap with appropriate opacity */
+ if (binfo.alpha_bits > 0) {
+ bitmap = guit->bitmap->create(c->width, c->height, BITMAP_OPAQUE);
+ } else {
+ bitmap = guit->bitmap->create(c->width, c->height, BITMAP_NONE);
+ }
+ if (bitmap == NULL) {
+ /* empty bitmap could not be created */
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ /* ensure buffer was allocated */
+ output = guit->bitmap->get_buffer(bitmap);
+ if (output == NULL) {
+ /* bitmap with no buffer available */
+ guit->bitmap->destroy(bitmap);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+ decstatus = JxlDecoderSetImageOutBuffer(jxldec, &jxl_output_format, output, c->size);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "unable to set output buffer callback status:%d",decstatus);
+ guit->bitmap->destroy(bitmap);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ decstatus = JxlDecoderProcessInput(jxldec);
+ if (decstatus != JXL_DEC_FULL_IMAGE) {
+ NSLOG(netsurf, ERROR, "did not get decode event");
+ guit->bitmap->destroy(bitmap);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ JxlDecoderDestroy(jxldec);
+
+ bitmap_format_to_client(bitmap, &jxl_fmt);
+ guit->bitmap->modified(bitmap);
+
+ return bitmap;
+}
+
+/**
+ * report failiure
+ */
+static bool jxl_report_fail(struct content *c, JxlDecoderStatus decstatus, const char *msg)
+{
+ union content_msg_data msg_data;
+ NSLOG(netsurf, ERROR, "%s decoder status:%d", msg, decstatus);
+ msg_data.errordata.errorcode = NSERROR_UNKNOWN;
+ msg_data.errordata.errormsg = msg;
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
+ return false;
+}
+
+/**
+ * Convert a CONTENT_JPEGXL for display.
+ */
+static bool nsjpegxl_convert(struct content *c)
+{
+ JxlDecoder *jxldec;
+ JxlSignature decsig;
+ JxlDecoderStatus decstatus = JXL_DEC_ERROR;
+ JxlBasicInfo binfo;
+ union content_msg_data msg_data;
+ const uint8_t *data;
+ size_t size;
+ char *title;
+ size_t image_size;
+
+ /* check image header is valid and get width/height */
+ data = content__get_source_data(c, &size);
+
+ decsig = JxlSignatureCheck(data,size);
+ if ((decsig != JXL_SIG_CODESTREAM) && (decsig != JXL_SIG_CONTAINER)) {
+ NSLOG(netsurf, ERROR, "signature failed");
+ msg_data.errordata.errorcode = NSERROR_UNKNOWN;
+ msg_data.errordata.errormsg = "Signature failed";
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
+ return false;
+ }
+
+ jxldec = JxlDecoderCreate(NULL);
+ if (jxldec == NULL) {
+ return jxl_report_fail(c, decstatus, "Unable to allocate decoder");
+ }
+ decstatus= JxlDecoderSubscribeEvents(jxldec, JXL_DEC_BASIC_INFO);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ return jxl_report_fail(c, decstatus, "Unable to subscribe");
+ }
+ decstatus = JxlDecoderSetInput(jxldec, data,size);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ return jxl_report_fail(c, decstatus, "unable to set input");
+ }
+ decstatus = JxlDecoderProcessInput(jxldec);
+ if (decstatus != JXL_DEC_BASIC_INFO) {
+ return jxl_report_fail(c, decstatus, "did not get basic info event");
+ }
+ decstatus = JxlDecoderGetBasicInfo(jxldec, &binfo);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ return jxl_report_fail(c, decstatus, "unable to get basic info");
+ }
+ decstatus = JxlDecoderImageOutBufferSize(jxldec, &jxl_output_format, &image_size);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ return jxl_report_fail(c, decstatus, "unable get image size");
+ }
+
+ JxlDecoderDestroy(jxldec);
+
+ NSLOG(netsurf, INFO, "got basic info size:%ld x:%d y:%d", image_size, binfo.xsize, binfo.ysize);
+
+ c->width = binfo.xsize;
+ c->height = binfo.ysize;
+ c->size = image_size;
+
+ image_cache_add(c, NULL, jpegxl_cache_convert);
+
+ /* set title text */
+ title = messages_get_buff("JPEGXLTitle",
+ nsurl_access_leaf(llcache_handle_get_url(c->llcache)),
+ c->width, c->height);
+ if (title != NULL) {
+ content__set_title(c, title);
+ free(title);
+ }
+
+ content_set_ready(c);
+ content_set_done(c);
+ content_set_status(c, ""); /* Done: update status bar */
+
+ return true;
+}
+
+
+/**
+ * Clone content.
+ */
+static nserror nsjpegxl_clone(const struct content *old, struct content **newc)
+{
+ struct content *jpegxl_c;
+ nserror error;
+
+ jpegxl_c = calloc(1, sizeof(struct content));
+ if (jpegxl_c == NULL)
+ return NSERROR_NOMEM;
+
+ error = content__clone(old, jpegxl_c);
+ if (error != NSERROR_OK) {
+ content_destroy(jpegxl_c);
+ return error;
+ }
+
+ /* re-convert if the content is ready */
+ if ((old->status == CONTENT_STATUS_READY) ||
+ (old->status == CONTENT_STATUS_DONE)) {
+ if (nsjpegxl_convert(jpegxl_c) == false) {
+ content_destroy(jpegxl_c);
+ return NSERROR_CLONE_FAILED;
+ }
+ }
+
+ *newc = jpegxl_c;
+
+ return NSERROR_OK;
+}
+
+static const content_handler nsjpegxl_content_handler = {
+ .create = nsjpegxl_create,
+ .data_complete = nsjpegxl_convert,
+ .destroy = image_cache_destroy,
+ .redraw = image_cache_redraw,
+ .clone = nsjpegxl_clone,
+ .get_internal = image_cache_get_internal,
+ .type = image_cache_content_type,
+ .is_opaque = image_cache_is_opaque,
+ .no_share = false,
+};
+
+static const char *nsjpegxl_types[] = {
+ "image/jxl",
+};
+
+CONTENT_FACTORY_REGISTER_TYPES(nsjpegxl, nsjpegxl_types, nsjpegxl_content_handler);
diff --git a/content/handlers/image/svg.h b/content/handlers/image/jpegxl.h
similarity index 77%
copy from content/handlers/image/svg.h
copy to content/handlers/image/jpegxl.h
index 96b9c38..e37d934 100644
--- a/content/handlers/image/svg.h
+++ b/content/handlers/image/jpegxl.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2007-2008 James Bursa <bursa(a)users.sourceforge.net>
+ * Copyright 2023 Vincent Sanders <vince(a)netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -17,12 +17,12 @@
*/
/** \file
- * Content for image/svg (interface).
+ * Content for image/jpegxl (interface).
*/
-#ifndef _NETSURF_IMAGE_SVG_H_
-#define _NETSURF_IMAGE_SVG_H_
+#ifndef _NETSURF_IMAGE_JPEGXL_H_
+#define _NETSURF_IMAGE_JPEGXL_H_
-nserror svg_init(void);
+nserror nsjpegxl_init(void);
#endif
diff --git a/content/mimesniff.c b/content/mimesniff.c
index 9a11834..adc000d 100644
--- a/content/mimesniff.c
+++ b/content/mimesniff.c
@@ -260,6 +260,13 @@ static nserror mimesniff__match_unknown_exact(const uint8_t *data, size_t len,
SIG(&corestring_lwc_application_x_gzip, "\x1f\x8b\x08", true),
SIG(&corestring_lwc_application_postscript, "%!PS-Adobe-",true),
SIG(&corestring_lwc_application_pdf, "%PDF-", false),
+ SIG(&corestring_lwc_image_jxl, "\xFF\x0A", true), /* containerless jpeg xl*/
+ {
+ (const uint8_t *)"\x00\x00\x00\x0CJXL \x0D\x0A\x87\x0A",
+ 12,
+ true,
+ &corestring_lwc_image_jxl
+ }, /* containered jpeg xl*/
{ NULL, 0, false, NULL }
};
#undef SIG
@@ -376,6 +383,12 @@ static nserror mimesniff__compute_image(lwc_string *official_type,
SIG(&corestring_lwc_image_jpeg, "\xff\xd8\xff"),
SIG(&corestring_lwc_image_bmp, "BM"),
SIG(&corestring_lwc_image_vnd_microsoft_icon, "\x00\x00\x01\x00"),
+ SIG(&corestring_lwc_image_jxl, "\xFF\x0A"), /* containerless jpeg xl*/
+ {
+ (const uint8_t *)"\x00\x00\x00\x0CJXL \x0D\x0A\x87\x0A",
+ 12,
+ &corestring_lwc_image_jxl
+ }, /* containered jpeg xl*/
{ NULL, 0, NULL }
};
#undef SIG
diff --git a/frontends/gtk/fetch.c b/frontends/gtk/fetch.c
index 58bd0b8..d77073a 100644
--- a/frontends/gtk/fetch.c
+++ b/frontends/gtk/fetch.c
@@ -75,6 +75,7 @@ void gtk_fetch_filetype_init(const char *mimefile)
hash_add(mime_hash, "html", "text/html");
hash_add(mime_hash, "jpg", "image/jpeg");
hash_add(mime_hash, "jpeg", "image/jpeg");
+ hash_add(mime_hash, "jxl", "image/jxl");
hash_add(mime_hash, "gif", "image/gif");
hash_add(mime_hash, "png", "image/png");
hash_add(mime_hash, "jng", "image/jng");
diff --git a/utils/corestringlist.h b/utils/corestringlist.h
index b253b3b..5cdbb3a 100644
--- a/utils/corestringlist.h
+++ b/utils/corestringlist.h
@@ -167,6 +167,7 @@ CORESTRING_LWC_VALUE(application_octet_stream, "application/octet-stream");
CORESTRING_LWC_VALUE(image_gif, "image/gif");
CORESTRING_LWC_VALUE(image_png, "image/png");
CORESTRING_LWC_VALUE(image_jpeg, "image/jpeg");
+CORESTRING_LWC_VALUE(image_jxl, "image/jxl");
CORESTRING_LWC_VALUE(image_bmp, "image/bmp");
CORESTRING_LWC_VALUE(image_vnd_microsoft_icon, "image/vnd.microsoft.icon");
CORESTRING_LWC_VALUE(image_webp, "image/webp");
--
NetSurf Browser
3 days, 11 hours
netsurf: branch tlsa/vince/libjxl created. release/3.10-371-gd695d21
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/d695d21817cbc1d4bdf0e...
...commit http://git.netsurf-browser.org/netsurf.git/commit/d695d21817cbc1d4bdf0e1b...
...tree http://git.netsurf-browser.org/netsurf.git/tree/d695d21817cbc1d4bdf0e1bdc...
The branch, tlsa/vince/libjxl has been created
at d695d21817cbc1d4bdf0e1bdcafdd32dac025302 (commit)
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=d695d21817cbc1d4bdf...
commit d695d21817cbc1d4bdf0e1bdcafdd32dac025302
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
jpegxl: Ensure decoded bitmap format is converted to front end format
diff --git a/content/handlers/image/jpegxl.c b/content/handlers/image/jpegxl.c
index 0451e2a..01c7045 100644
--- a/content/handlers/image/jpegxl.c
+++ b/content/handlers/image/jpegxl.c
@@ -97,6 +97,17 @@ jpegxl_cache_convert(struct content *c)
const uint8_t *src_data;
size_t src_size;
uint8_t * output;
+ bitmap_fmt_t jxl_fmt = {
+ /** TODO: At the moment we have to set the layout to the only
+ * pixel layout that libjxl supports. It looks like they
+ * plan to add support for decoding to other layouts
+ * in the future, as shown by the TODO in the docs:
+ *
+ * https://libjxl.readthedocs.io/en/latest/api_common.html#_CPPv414JxlPixelF...
+ */
+ .layout = BITMAP_LAYOUT_R8G8B8A8,
+ .pma = bitmap_fmt.pma,
+ };
jxldec = JxlDecoderCreate(NULL);
if (jxldec == NULL) {
@@ -180,8 +191,9 @@ jpegxl_cache_convert(struct content *c)
JxlDecoderDestroy(jxldec);
+ bitmap_format_to_client(bitmap, &jxl_fmt);
guit->bitmap->modified(bitmap);
-
+
return bitmap;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=12872ed3d5d402b6ab0...
commit 12872ed3d5d402b6ab0b61f8cda4b8642e2c34f1
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
jpegxl: Tell libjxl to decode unpremultiply alpha if needed
On some platforms our bitmap format does not use premultiplied alpha.
diff --git a/content/handlers/image/jpegxl.c b/content/handlers/image/jpegxl.c
index d5152fb..0451e2a 100644
--- a/content/handlers/image/jpegxl.c
+++ b/content/handlers/image/jpegxl.c
@@ -103,6 +103,15 @@ jpegxl_cache_convert(struct content *c)
NSLOG(netsurf, ERROR, "Unable to allocate decoder");
return NULL;
}
+
+ decstatus = JxlDecoderSetUnpremultiplyAlpha(jxldec, !bitmap_fmt.pma);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "unable to set premultiplied alpha status: %d",
+ decstatus);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
decstatus= JxlDecoderSubscribeEvents(jxldec, JXL_DEC_FULL_IMAGE);
if (decstatus != JXL_DEC_SUCCESS) {
NSLOG(netsurf, ERROR, "Unable to subscribe");
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=3dfe73af9a2282d7eb2...
commit 3dfe73af9a2282d7eb2f1329ab1dfe2688bea185
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
jpegxl: Designated initialiser for output format struct
So I could see the meanings of how we'd set up the decode.
diff --git a/content/handlers/image/jpegxl.c b/content/handlers/image/jpegxl.c
index ba385f3..d5152fb 100644
--- a/content/handlers/image/jpegxl.c
+++ b/content/handlers/image/jpegxl.c
@@ -49,7 +49,12 @@
/**
* output image format
*/
-static const JxlPixelFormat jxl_output_format = {4, JXL_TYPE_UINT8, JXL_LITTLE_ENDIAN, 0};
+static const JxlPixelFormat jxl_output_format = {
+ .num_channels = 4,
+ .data_type = JXL_TYPE_UINT8,
+ .endianness = JXL_LITTLE_ENDIAN,
+ .align = 0,
+};
/**
* Content create entry point.
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=cb5d8e58d436806cd69...
commit cb5d8e58d436806cd69268e1f20156d8e8eb387e
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Makefile: Set libjxl to AUTO
diff --git a/Makefile.defaults b/Makefile.defaults
index 85be748..bbff688 100644
--- a/Makefile.defaults
+++ b/Makefile.defaults
@@ -51,6 +51,10 @@ NETSURF_USE_GIF := AUTO
# Valid options: YES, NO (highly recommended)
NETSURF_USE_JPEG := YES
+# Enable NetSurf's use of libjxl for displaying JPEGXLs
+# Valid options: YES, NO, AUTO (highly recommended)
+NETSURF_USE_JPEGXL := AUTO
+
# Enable NetSurf's use of libpng for displaying PNGs.
# Valid options: YES, NO, AUTO (highly recommended)
NETSURF_USE_PNG := AUTO
-----------------------------------------------------------------------
--
NetSurf Browser
3 days, 11 hours
netsurf: branch vince/libjxl updated. release/3.10-367-g794d9b0
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/794d9b00260ea23a1ed93...
...commit http://git.netsurf-browser.org/netsurf.git/commit/794d9b00260ea23a1ed935f...
...tree http://git.netsurf-browser.org/netsurf.git/tree/794d9b00260ea23a1ed935fbf...
The branch, vince/libjxl has been updated
via 794d9b00260ea23a1ed935fbf6ad0a994b6a1d1f (commit)
from 9d5ebb857caa8561972f0c2395e2176ce2b03146 (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=794d9b00260ea23a1ed...
commit 794d9b00260ea23a1ed935fbf6ad0a994b6a1d1f
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
avoid the unecessary callback API
diff --git a/content/handlers/image/jpegxl.c b/content/handlers/image/jpegxl.c
index 4bba02d..ba385f3 100644
--- a/content/handlers/image/jpegxl.c
+++ b/content/handlers/image/jpegxl.c
@@ -79,20 +79,6 @@ nsjpegxl_create(const content_handler *handler,
return NSERROR_OK;
}
-static void image_out_callback(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels)
-{
- struct bitmap * bitmap = opaque;
- uint8_t * output;
-
- output = guit->bitmap->get_buffer(bitmap);
- if (output != NULL) {
- /* bitmap buffer available */
- memcpy(output + (x*jxl_output_format.num_channels) + (y * guit->bitmap->get_rowstride(bitmap)),
- pixels,
- num_pixels*jxl_output_format.num_channels);
- }
-}
-
/**
* create a bitmap from jpeg xl content.
*/
@@ -105,6 +91,7 @@ jpegxl_cache_convert(struct content *c)
JxlBasicInfo binfo;
const uint8_t *src_data;
size_t src_size;
+ uint8_t * output;
jxldec = JxlDecoderCreate(NULL);
if (jxldec == NULL) {
@@ -154,14 +141,14 @@ jpegxl_cache_convert(struct content *c)
}
/* ensure buffer was allocated */
- if (guit->bitmap->get_buffer(bitmap) == NULL) {
+ output = guit->bitmap->get_buffer(bitmap);
+ if (output == NULL) {
/* bitmap with no buffer available */
guit->bitmap->destroy(bitmap);
JxlDecoderDestroy(jxldec);
return NULL;
}
-
- decstatus = JxlDecoderSetImageOutCallback(jxldec, &jxl_output_format, image_out_callback, bitmap);
+ decstatus = JxlDecoderSetImageOutBuffer(jxldec, &jxl_output_format, output, c->size);
if (decstatus != JXL_DEC_SUCCESS) {
NSLOG(netsurf, ERROR, "unable to set output buffer callback status:%d",decstatus);
guit->bitmap->destroy(bitmap);
-----------------------------------------------------------------------
Summary of changes:
content/handlers/image/jpegxl.c | 21 ++++-----------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/content/handlers/image/jpegxl.c b/content/handlers/image/jpegxl.c
index 4bba02d..ba385f3 100644
--- a/content/handlers/image/jpegxl.c
+++ b/content/handlers/image/jpegxl.c
@@ -79,20 +79,6 @@ nsjpegxl_create(const content_handler *handler,
return NSERROR_OK;
}
-static void image_out_callback(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels)
-{
- struct bitmap * bitmap = opaque;
- uint8_t * output;
-
- output = guit->bitmap->get_buffer(bitmap);
- if (output != NULL) {
- /* bitmap buffer available */
- memcpy(output + (x*jxl_output_format.num_channels) + (y * guit->bitmap->get_rowstride(bitmap)),
- pixels,
- num_pixels*jxl_output_format.num_channels);
- }
-}
-
/**
* create a bitmap from jpeg xl content.
*/
@@ -105,6 +91,7 @@ jpegxl_cache_convert(struct content *c)
JxlBasicInfo binfo;
const uint8_t *src_data;
size_t src_size;
+ uint8_t * output;
jxldec = JxlDecoderCreate(NULL);
if (jxldec == NULL) {
@@ -154,14 +141,14 @@ jpegxl_cache_convert(struct content *c)
}
/* ensure buffer was allocated */
- if (guit->bitmap->get_buffer(bitmap) == NULL) {
+ output = guit->bitmap->get_buffer(bitmap);
+ if (output == NULL) {
/* bitmap with no buffer available */
guit->bitmap->destroy(bitmap);
JxlDecoderDestroy(jxldec);
return NULL;
}
-
- decstatus = JxlDecoderSetImageOutCallback(jxldec, &jxl_output_format, image_out_callback, bitmap);
+ decstatus = JxlDecoderSetImageOutBuffer(jxldec, &jxl_output_format, output, c->size);
if (decstatus != JXL_DEC_SUCCESS) {
NSLOG(netsurf, ERROR, "unable to set output buffer callback status:%d",decstatus);
guit->bitmap->destroy(bitmap);
--
NetSurf Browser
3 days, 12 hours
netsurf: branch vince/libjxl created. release/3.10-366-g9d5ebb8
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/9d5ebb857caa8561972f0...
...commit http://git.netsurf-browser.org/netsurf.git/commit/9d5ebb857caa8561972f0c2...
...tree http://git.netsurf-browser.org/netsurf.git/tree/9d5ebb857caa8561972f0c239...
The branch, vince/libjxl has been created
at 9d5ebb857caa8561972f0c2395e2176ce2b03146 (commit)
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9d5ebb857caa8561972...
commit 9d5ebb857caa8561972f0c2395e2176ce2b03146
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Implement simple jpeg xl image handler
diff --git a/Makefile b/Makefile
index 828f83b..05cb03e 100644
--- a/Makefile
+++ b/Makefile
@@ -171,6 +171,7 @@ endif
$(eval $(call pkg_config_find_and_add_enabled,OPENSSL,openssl,OpenSSL))
$(eval $(call pkg_config_find_and_add_enabled,UTF8PROC,libutf8proc,utf8))
+$(eval $(call pkg_config_find_and_add_enabled,JPEGXL,libjxl,JPEGXL))
$(eval $(call pkg_config_find_and_add_enabled,WEBP,libwebp,WEBP))
$(eval $(call pkg_config_find_and_add_enabled,PNG,libpng,PNG))
$(eval $(call pkg_config_find_and_add_enabled,BMP,libnsbmp,BMP))
diff --git a/content/handlers/image/Makefile b/content/handlers/image/Makefile
index afc90f4..ac052b3 100644
--- a/content/handlers/image/Makefile
+++ b/content/handlers/image/Makefile
@@ -7,6 +7,7 @@ S_IMAGE_$(NETSURF_USE_BMP) += bmp.c
S_IMAGE_$(NETSURF_USE_GIF) += gif.c
S_IMAGE_$(NETSURF_USE_BMP) += ico.c
S_IMAGE_$(NETSURF_USE_JPEG) += jpeg.c
+S_IMAGE_$(NETSURF_USE_JPEGXL) += jpegxl.c
S_IMAGE_$(NETSURF_USE_ROSPRITE) += nssprite.c
S_IMAGE_$(NETSURF_USE_PNG) += png.c
S_IMAGE_$(NETSURF_USE_NSSVG) += svg.c
diff --git a/content/handlers/image/image.c b/content/handlers/image/image.c
index 3107ee4..2bd5f5f 100644
--- a/content/handlers/image/image.c
+++ b/content/handlers/image/image.c
@@ -32,6 +32,7 @@
#include "image/gif.h"
#include "image/ico.h"
#include "image/jpeg.h"
+#include "image/jpegxl.h"
#include "image/nssprite.h"
#include "image/png.h"
#include "image/rsvg.h"
@@ -72,6 +73,12 @@ nserror image_init(void)
return error;
#endif
+#ifdef WITH_JPEGXL
+ error = nsjpegxl_init();
+ if (error != NSERROR_OK)
+ return error;
+#endif
+
#ifdef WITH_PNG
error = nspng_init();
if (error != NSERROR_OK)
diff --git a/content/handlers/image/jpegxl.c b/content/handlers/image/jpegxl.c
new file mode 100644
index 0000000..4bba02d
--- /dev/null
+++ b/content/handlers/image/jpegxl.c
@@ -0,0 +1,327 @@
+/*
+ * Copyright 2023 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * implementation of content handling for image/jpegxl
+ *
+ * This implementation uses the JXL library.
+ */
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <setjmp.h>
+#include <string.h>
+
+#include <jxl/decode.h>
+
+#include "utils/utils.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "netsurf/bitmap.h"
+#include "content/llcache.h"
+#include "content/content.h"
+#include "content/content_protected.h"
+#include "content/content_factory.h"
+#include "desktop/gui_internal.h"
+#include "desktop/bitmap.h"
+
+#include "image/image_cache.h"
+
+#include "image/jpegxl.h"
+
+
+/**
+ * output image format
+ */
+static const JxlPixelFormat jxl_output_format = {4, JXL_TYPE_UINT8, JXL_LITTLE_ENDIAN, 0};
+
+/**
+ * Content create entry point.
+ */
+static nserror
+nsjpegxl_create(const content_handler *handler,
+ lwc_string *imime_type, const struct http_parameter *params,
+ llcache_handle *llcache, const char *fallback_charset,
+ bool quirks, struct content **c)
+{
+ struct content *jpeg;
+ nserror error;
+
+ jpeg = calloc(1, sizeof(struct content));
+ if (jpeg == NULL)
+ return NSERROR_NOMEM;
+
+ error = content__init(jpeg, handler, imime_type, params,
+ llcache, fallback_charset, quirks);
+ if (error != NSERROR_OK) {
+ free(jpeg);
+ return error;
+ }
+
+ *c = jpeg;
+
+ return NSERROR_OK;
+}
+
+static void image_out_callback(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels)
+{
+ struct bitmap * bitmap = opaque;
+ uint8_t * output;
+
+ output = guit->bitmap->get_buffer(bitmap);
+ if (output != NULL) {
+ /* bitmap buffer available */
+ memcpy(output + (x*jxl_output_format.num_channels) + (y * guit->bitmap->get_rowstride(bitmap)),
+ pixels,
+ num_pixels*jxl_output_format.num_channels);
+ }
+}
+
+/**
+ * create a bitmap from jpeg xl content.
+ */
+static struct bitmap *
+jpegxl_cache_convert(struct content *c)
+{
+ struct bitmap * bitmap = NULL;
+ JxlDecoder *jxldec;
+ JxlDecoderStatus decstatus;
+ JxlBasicInfo binfo;
+ const uint8_t *src_data;
+ size_t src_size;
+
+ jxldec = JxlDecoderCreate(NULL);
+ if (jxldec == NULL) {
+ NSLOG(netsurf, ERROR, "Unable to allocate decoder");
+ return NULL;
+ }
+ decstatus= JxlDecoderSubscribeEvents(jxldec, JXL_DEC_FULL_IMAGE);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "Unable to subscribe");
+ return NULL;
+ }
+ src_data = content__get_source_data(c, &src_size);
+
+ decstatus = JxlDecoderSetInput(jxldec, src_data, src_size);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "unable to set input");
+ return NULL;
+ }
+
+ decstatus = JxlDecoderProcessInput(jxldec);
+ if (decstatus != JXL_DEC_NEED_IMAGE_OUT_BUFFER) {
+ NSLOG(netsurf, ERROR,
+ "expected status JXL_DEC_NEED_IMAGE_OUT_BUFFER(%d) got %d",
+ JXL_DEC_NEED_IMAGE_OUT_BUFFER,
+ decstatus);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ decstatus = JxlDecoderGetBasicInfo(jxldec, &binfo);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "unable to get basic info status:%d",decstatus);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ /* create bitmap with appropriate opacity */
+ if (binfo.alpha_bits > 0) {
+ bitmap = guit->bitmap->create(c->width, c->height, BITMAP_OPAQUE);
+ } else {
+ bitmap = guit->bitmap->create(c->width, c->height, BITMAP_NONE);
+ }
+ if (bitmap == NULL) {
+ /* empty bitmap could not be created */
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ /* ensure buffer was allocated */
+ if (guit->bitmap->get_buffer(bitmap) == NULL) {
+ /* bitmap with no buffer available */
+ guit->bitmap->destroy(bitmap);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ decstatus = JxlDecoderSetImageOutCallback(jxldec, &jxl_output_format, image_out_callback, bitmap);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ NSLOG(netsurf, ERROR, "unable to set output buffer callback status:%d",decstatus);
+ guit->bitmap->destroy(bitmap);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ decstatus = JxlDecoderProcessInput(jxldec);
+ if (decstatus != JXL_DEC_FULL_IMAGE) {
+ NSLOG(netsurf, ERROR, "did not get decode event");
+ guit->bitmap->destroy(bitmap);
+ JxlDecoderDestroy(jxldec);
+ return NULL;
+ }
+
+ JxlDecoderDestroy(jxldec);
+
+ guit->bitmap->modified(bitmap);
+
+ return bitmap;
+}
+
+/**
+ * report failiure
+ */
+static bool jxl_report_fail(struct content *c, JxlDecoderStatus decstatus, const char *msg)
+{
+ union content_msg_data msg_data;
+ NSLOG(netsurf, ERROR, "%s decoder status:%d", msg, decstatus);
+ msg_data.errordata.errorcode = NSERROR_UNKNOWN;
+ msg_data.errordata.errormsg = msg;
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
+ return false;
+}
+
+/**
+ * Convert a CONTENT_JPEGXL for display.
+ */
+static bool nsjpegxl_convert(struct content *c)
+{
+ JxlDecoder *jxldec;
+ JxlSignature decsig;
+ JxlDecoderStatus decstatus = JXL_DEC_ERROR;
+ JxlBasicInfo binfo;
+ union content_msg_data msg_data;
+ const uint8_t *data;
+ size_t size;
+ char *title;
+ size_t image_size;
+
+ /* check image header is valid and get width/height */
+ data = content__get_source_data(c, &size);
+
+ decsig = JxlSignatureCheck(data,size);
+ if ((decsig != JXL_SIG_CODESTREAM) && (decsig != JXL_SIG_CONTAINER)) {
+ NSLOG(netsurf, ERROR, "signature failed");
+ msg_data.errordata.errorcode = NSERROR_UNKNOWN;
+ msg_data.errordata.errormsg = "Signature failed";
+ content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
+ return false;
+ }
+
+ jxldec = JxlDecoderCreate(NULL);
+ if (jxldec == NULL) {
+ return jxl_report_fail(c, decstatus, "Unable to allocate decoder");
+ }
+ decstatus= JxlDecoderSubscribeEvents(jxldec, JXL_DEC_BASIC_INFO);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ return jxl_report_fail(c, decstatus, "Unable to subscribe");
+ }
+ decstatus = JxlDecoderSetInput(jxldec, data,size);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ return jxl_report_fail(c, decstatus, "unable to set input");
+ }
+ decstatus = JxlDecoderProcessInput(jxldec);
+ if (decstatus != JXL_DEC_BASIC_INFO) {
+ return jxl_report_fail(c, decstatus, "did not get basic info event");
+ }
+ decstatus = JxlDecoderGetBasicInfo(jxldec, &binfo);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ return jxl_report_fail(c, decstatus, "unable to get basic info");
+ }
+ decstatus = JxlDecoderImageOutBufferSize(jxldec, &jxl_output_format, &image_size);
+ if (decstatus != JXL_DEC_SUCCESS) {
+ return jxl_report_fail(c, decstatus, "unable get image size");
+ }
+
+ JxlDecoderDestroy(jxldec);
+
+ NSLOG(netsurf, INFO, "got basic info size:%ld x:%d y:%d", image_size, binfo.xsize, binfo.ysize);
+
+ c->width = binfo.xsize;
+ c->height = binfo.ysize;
+ c->size = image_size;
+
+ image_cache_add(c, NULL, jpegxl_cache_convert);
+
+ /* set title text */
+ title = messages_get_buff("JPEGXLTitle",
+ nsurl_access_leaf(llcache_handle_get_url(c->llcache)),
+ c->width, c->height);
+ if (title != NULL) {
+ content__set_title(c, title);
+ free(title);
+ }
+
+ content_set_ready(c);
+ content_set_done(c);
+ content_set_status(c, ""); /* Done: update status bar */
+
+ return true;
+}
+
+
+/**
+ * Clone content.
+ */
+static nserror nsjpegxl_clone(const struct content *old, struct content **newc)
+{
+ struct content *jpegxl_c;
+ nserror error;
+
+ jpegxl_c = calloc(1, sizeof(struct content));
+ if (jpegxl_c == NULL)
+ return NSERROR_NOMEM;
+
+ error = content__clone(old, jpegxl_c);
+ if (error != NSERROR_OK) {
+ content_destroy(jpegxl_c);
+ return error;
+ }
+
+ /* re-convert if the content is ready */
+ if ((old->status == CONTENT_STATUS_READY) ||
+ (old->status == CONTENT_STATUS_DONE)) {
+ if (nsjpegxl_convert(jpegxl_c) == false) {
+ content_destroy(jpegxl_c);
+ return NSERROR_CLONE_FAILED;
+ }
+ }
+
+ *newc = jpegxl_c;
+
+ return NSERROR_OK;
+}
+
+static const content_handler nsjpegxl_content_handler = {
+ .create = nsjpegxl_create,
+ .data_complete = nsjpegxl_convert,
+ .destroy = image_cache_destroy,
+ .redraw = image_cache_redraw,
+ .clone = nsjpegxl_clone,
+ .get_internal = image_cache_get_internal,
+ .type = image_cache_content_type,
+ .is_opaque = image_cache_is_opaque,
+ .no_share = false,
+};
+
+static const char *nsjpegxl_types[] = {
+ "image/jxl",
+};
+
+CONTENT_FACTORY_REGISTER_TYPES(nsjpegxl, nsjpegxl_types, nsjpegxl_content_handler);
diff --git a/content/handlers/image/jpegxl.h b/content/handlers/image/jpegxl.h
new file mode 100644
index 0000000..e37d934
--- /dev/null
+++ b/content/handlers/image/jpegxl.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2023 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Content for image/jpegxl (interface).
+ */
+
+#ifndef _NETSURF_IMAGE_JPEGXL_H_
+#define _NETSURF_IMAGE_JPEGXL_H_
+
+nserror nsjpegxl_init(void);
+
+#endif
diff --git a/content/mimesniff.c b/content/mimesniff.c
index 9a11834..adc000d 100644
--- a/content/mimesniff.c
+++ b/content/mimesniff.c
@@ -260,6 +260,13 @@ static nserror mimesniff__match_unknown_exact(const uint8_t *data, size_t len,
SIG(&corestring_lwc_application_x_gzip, "\x1f\x8b\x08", true),
SIG(&corestring_lwc_application_postscript, "%!PS-Adobe-",true),
SIG(&corestring_lwc_application_pdf, "%PDF-", false),
+ SIG(&corestring_lwc_image_jxl, "\xFF\x0A", true), /* containerless jpeg xl*/
+ {
+ (const uint8_t *)"\x00\x00\x00\x0CJXL \x0D\x0A\x87\x0A",
+ 12,
+ true,
+ &corestring_lwc_image_jxl
+ }, /* containered jpeg xl*/
{ NULL, 0, false, NULL }
};
#undef SIG
@@ -376,6 +383,12 @@ static nserror mimesniff__compute_image(lwc_string *official_type,
SIG(&corestring_lwc_image_jpeg, "\xff\xd8\xff"),
SIG(&corestring_lwc_image_bmp, "BM"),
SIG(&corestring_lwc_image_vnd_microsoft_icon, "\x00\x00\x01\x00"),
+ SIG(&corestring_lwc_image_jxl, "\xFF\x0A"), /* containerless jpeg xl*/
+ {
+ (const uint8_t *)"\x00\x00\x00\x0CJXL \x0D\x0A\x87\x0A",
+ 12,
+ &corestring_lwc_image_jxl
+ }, /* containered jpeg xl*/
{ NULL, 0, NULL }
};
#undef SIG
diff --git a/frontends/gtk/fetch.c b/frontends/gtk/fetch.c
index 58bd0b8..d77073a 100644
--- a/frontends/gtk/fetch.c
+++ b/frontends/gtk/fetch.c
@@ -75,6 +75,7 @@ void gtk_fetch_filetype_init(const char *mimefile)
hash_add(mime_hash, "html", "text/html");
hash_add(mime_hash, "jpg", "image/jpeg");
hash_add(mime_hash, "jpeg", "image/jpeg");
+ hash_add(mime_hash, "jxl", "image/jxl");
hash_add(mime_hash, "gif", "image/gif");
hash_add(mime_hash, "png", "image/png");
hash_add(mime_hash, "jng", "image/jng");
diff --git a/utils/corestringlist.h b/utils/corestringlist.h
index b253b3b..5cdbb3a 100644
--- a/utils/corestringlist.h
+++ b/utils/corestringlist.h
@@ -167,6 +167,7 @@ CORESTRING_LWC_VALUE(application_octet_stream, "application/octet-stream");
CORESTRING_LWC_VALUE(image_gif, "image/gif");
CORESTRING_LWC_VALUE(image_png, "image/png");
CORESTRING_LWC_VALUE(image_jpeg, "image/jpeg");
+CORESTRING_LWC_VALUE(image_jxl, "image/jxl");
CORESTRING_LWC_VALUE(image_bmp, "image/bmp");
CORESTRING_LWC_VALUE(image_vnd_microsoft_icon, "image/vnd.microsoft.icon");
CORESTRING_LWC_VALUE(image_webp, "image/webp");
-----------------------------------------------------------------------
--
NetSurf Browser
3 days, 13 hours
netsurf: branch master updated. release/3.10-375-gbbeb93d
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/bbeb93d512973f7c04714...
...commit http://git.netsurf-browser.org/netsurf.git/commit/bbeb93d512973f7c04714f7...
...tree http://git.netsurf-browser.org/netsurf.git/tree/bbeb93d512973f7c04714f7a4...
The branch, master has been updated
via bbeb93d512973f7c04714f7a43ea185c15ec65ba (commit)
from 14b6fa95469b2a3ecae7ee4ff7c5334250d26c56 (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=bbeb93d512973f7c047...
commit bbeb93d512973f7c04714f7a43ea185c15ec65ba
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
RISC OS: Add "Disable CSS" option to content choices UI
diff --git a/frontends/riscos/configure/con_content.c b/frontends/riscos/configure/con_content.c
index 50bbd15..bdf147b 100644
--- a/frontends/riscos/configure/con_content.c
+++ b/frontends/riscos/configure/con_content.c
@@ -30,7 +30,7 @@
#define CONTENT_BLOCK_ADVERTISEMENTS 2
#define CONTENT_BLOCK_POPUPS 3
-#define CONTENT_NO_PLUGINS 4
+#define CONTENT_BLOCK_CSS 4
#define CONTENT_TARGET_BLANK 7
#define CONTENT_DEFAULT_BUTTON 8
#define CONTENT_CANCEL_BUTTON 9
@@ -47,8 +47,8 @@ bool ro_gui_options_content_initialise(wimp_w w)
nsoption_bool(block_advertisements));
ro_gui_set_icon_selected_state(w, CONTENT_BLOCK_POPUPS,
nsoption_bool(block_popups));
- ro_gui_set_icon_selected_state(w, CONTENT_NO_PLUGINS,
- nsoption_bool(no_plugins));
+ ro_gui_set_icon_selected_state(w, CONTENT_BLOCK_CSS,
+ !nsoption_bool(author_level_css));
ro_gui_set_icon_selected_state(w, CONTENT_TARGET_BLANK,
nsoption_bool(target_blank));
ro_gui_set_icon_selected_state(w, CONTENT_NO_JAVASCRIPT,
@@ -57,7 +57,7 @@ bool ro_gui_options_content_initialise(wimp_w w)
/* initialise all functions for a newly created window */
ro_gui_wimp_event_register_checkbox(w, CONTENT_BLOCK_ADVERTISEMENTS);
ro_gui_wimp_event_register_checkbox(w, CONTENT_BLOCK_POPUPS);
- ro_gui_wimp_event_register_checkbox(w, CONTENT_NO_PLUGINS);
+ ro_gui_wimp_event_register_checkbox(w, CONTENT_BLOCK_CSS);
ro_gui_wimp_event_register_checkbox(w, CONTENT_TARGET_BLANK);
ro_gui_wimp_event_register_checkbox(w, CONTENT_NO_JAVASCRIPT);
ro_gui_wimp_event_register_button(w, CONTENT_DEFAULT_BUTTON,
@@ -78,7 +78,7 @@ void ro_gui_options_content_default(wimp_pointer *pointer)
false);
ro_gui_set_icon_selected_state(pointer->w, CONTENT_BLOCK_POPUPS,
false);
- ro_gui_set_icon_selected_state(pointer->w, CONTENT_NO_PLUGINS,
+ ro_gui_set_icon_selected_state(pointer->w, CONTENT_BLOCK_CSS,
false);
ro_gui_set_icon_selected_state(pointer->w, CONTENT_TARGET_BLANK,
true);
@@ -93,8 +93,8 @@ bool ro_gui_options_content_ok(wimp_w w)
nsoption_set_bool(block_popups,
ro_gui_get_icon_selected_state(w, CONTENT_BLOCK_POPUPS));
- nsoption_set_bool(no_plugins,
- ro_gui_get_icon_selected_state(w, CONTENT_NO_PLUGINS));
+ nsoption_set_bool(author_level_css,
+ !ro_gui_get_icon_selected_state(w, CONTENT_BLOCK_CSS));
nsoption_set_bool(target_blank,
ro_gui_get_icon_selected_state(w, CONTENT_TARGET_BLANK));
diff --git a/frontends/riscos/templates/de b/frontends/riscos/templates/de
index a6c1372..b5710d4 100644
--- a/frontends/riscos/templates/de
+++ b/frontends/riscos/templates/de
@@ -3370,11 +3370,11 @@ wimp_window {
}
wimp_icon {
extent:32,-256,496,-212
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_DELETED | wimp_BUTTON_RADIO
+ icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
- text_and_sprite.text:"Plugins nicht benutzen"
+ text_and_sprite.text:"CSS nicht benutzen"
text_and_sprite.size:42
text_and_sprite.validation:"Soptoff,opton"
}
diff --git a/frontends/riscos/templates/en b/frontends/riscos/templates/en
index 8b84d15..6ea18a8 100644
--- a/frontends/riscos/templates/en
+++ b/frontends/riscos/templates/en
@@ -3040,11 +3040,11 @@ wimp_window {
}
wimp_icon {
extent:32,-256,344,-212
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_DELETED | wimp_BUTTON_RADIO
+ icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
- text_and_sprite.text:"Disable plug-ins"
+ text_and_sprite.text:"Disable CSS"
text_and_sprite.size:42
text_and_sprite.validation:"Soptoff,opton"
}
diff --git a/frontends/riscos/templates/fr b/frontends/riscos/templates/fr
index 6128d3f..e2741df 100644
--- a/frontends/riscos/templates/fr
+++ b/frontends/riscos/templates/fr
@@ -2842,11 +2842,11 @@ wimp_window {
}
wimp_icon {
extent:32,-256,404,-212
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_DELETED | wimp_BUTTON_RADIO
+ icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
- text_and_sprite.text:"D�sactiver les plug-ins"
+ text_and_sprite.text:"D�sactiver les CSS"
text_and_sprite.size:42
text_and_sprite.validation:"Soptoff,opton"
}
diff --git a/frontends/riscos/templates/nl b/frontends/riscos/templates/nl
index 2fba8b5..24b1768 100644
--- a/frontends/riscos/templates/nl
+++ b/frontends/riscos/templates/nl
@@ -3090,11 +3090,11 @@ wimp_window {
}
wimp_icon {
extent:32,-256,540,-212
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_DELETED | wimp_BUTTON_RADIO
+ icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
- text_and_sprite.text:"Plug-ins uitschakelen"
+ text_and_sprite.text:"CSS uitschakelen"
text_and_sprite.size:42
text_and_sprite.validation:"Soptoff,opton"
}
diff --git a/resources/FatMessages b/resources/FatMessages
index 3492c3f..b02b640 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -7449,12 +7449,12 @@ it.ro.HelpContentConfig3:Indica se NetSurf impedir�� ai siti Web di aprire autom
nl.ro.HelpContentConfig3:Deze optie geeft aan of NetSurf websites, die automatisch nieuwe pagina's proberen te openen blokkeerd.
zh_CN.ro.HelpContentConfig3:���������NetSurf���������������������������������������������������������������
-en.ro.HelpContentConfig4:This indicates whether NetSurf will allow external plug-ins to handle additional types of content, such as Flash.
-de.ro.HelpContentConfig4:Stellt ein, ob externe Pluginroutinen genutzt werden d��rfen, um Zusatzinhalte darzustellen (z.B. Flash).
-fr.ro.HelpContentConfig4:Ceci indique si Netsurf doit autoriser les plug-ins externes �� manipuler des types de contenu suppl��mentaires, comme le Flash.
-it.ro.HelpContentConfig4:Indica se NetSurf consentir�� ai plug-in esterni di gestire tipi di contenuto aggiuntivi come il Flash.
-nl.ro.HelpContentConfig4:Deze optie geeft aan of NetSurf externe plug-ins, voor aanvullende soorten inhoud zoals Flash toestaat.
-zh_CN.ro.HelpContentConfig4:��������� NetSurf ������������������������������������������������������������ Flash ���������
+en.ro.HelpContentConfig4:This indicates whether NetSurf will allow web pages to style their content with CSS.
+de.ro.HelpContentConfig4:This indicates whether NetSurf will allow web pages to style their content with CSS.
+fr.ro.HelpContentConfig4:This indicates whether NetSurf will allow web pages to style their content with CSS.
+it.ro.HelpContentConfig4:This indicates whether NetSurf will allow web pages to style their content with CSS.
+nl.ro.HelpContentConfig4:This indicates whether NetSurf will allow web pages to style their content with CSS.
+zh_CN.ro.HelpContentConfig4:This indicates whether NetSurf will allow web pages to style their content with CSS.
en.ro.HelpContentConfig7:This indicates whether NetSurf will allow links to open in new windows.
de.ro.HelpContentConfig7:Stellt ein, ob NetSurf erlaubt, da�� Links beim Aufruf neue Browserfenster ��ffnen d��rfen.
-----------------------------------------------------------------------
Summary of changes:
frontends/riscos/configure/con_content.c | 14 +++++++-------
frontends/riscos/templates/de | 4 ++--
frontends/riscos/templates/en | 4 ++--
frontends/riscos/templates/fr | 4 ++--
frontends/riscos/templates/nl | 4 ++--
resources/FatMessages | 12 ++++++------
6 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/frontends/riscos/configure/con_content.c b/frontends/riscos/configure/con_content.c
index 50bbd15..bdf147b 100644
--- a/frontends/riscos/configure/con_content.c
+++ b/frontends/riscos/configure/con_content.c
@@ -30,7 +30,7 @@
#define CONTENT_BLOCK_ADVERTISEMENTS 2
#define CONTENT_BLOCK_POPUPS 3
-#define CONTENT_NO_PLUGINS 4
+#define CONTENT_BLOCK_CSS 4
#define CONTENT_TARGET_BLANK 7
#define CONTENT_DEFAULT_BUTTON 8
#define CONTENT_CANCEL_BUTTON 9
@@ -47,8 +47,8 @@ bool ro_gui_options_content_initialise(wimp_w w)
nsoption_bool(block_advertisements));
ro_gui_set_icon_selected_state(w, CONTENT_BLOCK_POPUPS,
nsoption_bool(block_popups));
- ro_gui_set_icon_selected_state(w, CONTENT_NO_PLUGINS,
- nsoption_bool(no_plugins));
+ ro_gui_set_icon_selected_state(w, CONTENT_BLOCK_CSS,
+ !nsoption_bool(author_level_css));
ro_gui_set_icon_selected_state(w, CONTENT_TARGET_BLANK,
nsoption_bool(target_blank));
ro_gui_set_icon_selected_state(w, CONTENT_NO_JAVASCRIPT,
@@ -57,7 +57,7 @@ bool ro_gui_options_content_initialise(wimp_w w)
/* initialise all functions for a newly created window */
ro_gui_wimp_event_register_checkbox(w, CONTENT_BLOCK_ADVERTISEMENTS);
ro_gui_wimp_event_register_checkbox(w, CONTENT_BLOCK_POPUPS);
- ro_gui_wimp_event_register_checkbox(w, CONTENT_NO_PLUGINS);
+ ro_gui_wimp_event_register_checkbox(w, CONTENT_BLOCK_CSS);
ro_gui_wimp_event_register_checkbox(w, CONTENT_TARGET_BLANK);
ro_gui_wimp_event_register_checkbox(w, CONTENT_NO_JAVASCRIPT);
ro_gui_wimp_event_register_button(w, CONTENT_DEFAULT_BUTTON,
@@ -78,7 +78,7 @@ void ro_gui_options_content_default(wimp_pointer *pointer)
false);
ro_gui_set_icon_selected_state(pointer->w, CONTENT_BLOCK_POPUPS,
false);
- ro_gui_set_icon_selected_state(pointer->w, CONTENT_NO_PLUGINS,
+ ro_gui_set_icon_selected_state(pointer->w, CONTENT_BLOCK_CSS,
false);
ro_gui_set_icon_selected_state(pointer->w, CONTENT_TARGET_BLANK,
true);
@@ -93,8 +93,8 @@ bool ro_gui_options_content_ok(wimp_w w)
nsoption_set_bool(block_popups,
ro_gui_get_icon_selected_state(w, CONTENT_BLOCK_POPUPS));
- nsoption_set_bool(no_plugins,
- ro_gui_get_icon_selected_state(w, CONTENT_NO_PLUGINS));
+ nsoption_set_bool(author_level_css,
+ !ro_gui_get_icon_selected_state(w, CONTENT_BLOCK_CSS));
nsoption_set_bool(target_blank,
ro_gui_get_icon_selected_state(w, CONTENT_TARGET_BLANK));
diff --git a/frontends/riscos/templates/de b/frontends/riscos/templates/de
index a6c1372..b5710d4 100644
--- a/frontends/riscos/templates/de
+++ b/frontends/riscos/templates/de
@@ -3370,11 +3370,11 @@ wimp_window {
}
wimp_icon {
extent:32,-256,496,-212
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_DELETED | wimp_BUTTON_RADIO
+ icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
- text_and_sprite.text:"Plugins nicht benutzen"
+ text_and_sprite.text:"CSS nicht benutzen"
text_and_sprite.size:42
text_and_sprite.validation:"Soptoff,opton"
}
diff --git a/frontends/riscos/templates/en b/frontends/riscos/templates/en
index 8b84d15..6ea18a8 100644
--- a/frontends/riscos/templates/en
+++ b/frontends/riscos/templates/en
@@ -3040,11 +3040,11 @@ wimp_window {
}
wimp_icon {
extent:32,-256,344,-212
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_DELETED | wimp_BUTTON_RADIO
+ icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
- text_and_sprite.text:"Disable plug-ins"
+ text_and_sprite.text:"Disable CSS"
text_and_sprite.size:42
text_and_sprite.validation:"Soptoff,opton"
}
diff --git a/frontends/riscos/templates/fr b/frontends/riscos/templates/fr
index 6128d3f..e2741df 100644
--- a/frontends/riscos/templates/fr
+++ b/frontends/riscos/templates/fr
@@ -2842,11 +2842,11 @@ wimp_window {
}
wimp_icon {
extent:32,-256,404,-212
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_DELETED | wimp_BUTTON_RADIO
+ icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
- text_and_sprite.text:"D�sactiver les plug-ins"
+ text_and_sprite.text:"D�sactiver les CSS"
text_and_sprite.size:42
text_and_sprite.validation:"Soptoff,opton"
}
diff --git a/frontends/riscos/templates/nl b/frontends/riscos/templates/nl
index 2fba8b5..24b1768 100644
--- a/frontends/riscos/templates/nl
+++ b/frontends/riscos/templates/nl
@@ -3090,11 +3090,11 @@ wimp_window {
}
wimp_icon {
extent:32,-256,540,-212
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_DELETED | wimp_BUTTON_RADIO
+ icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
- text_and_sprite.text:"Plug-ins uitschakelen"
+ text_and_sprite.text:"CSS uitschakelen"
text_and_sprite.size:42
text_and_sprite.validation:"Soptoff,opton"
}
diff --git a/resources/FatMessages b/resources/FatMessages
index 3492c3f..b02b640 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -7449,12 +7449,12 @@ it.ro.HelpContentConfig3:Indica se NetSurf impedir�� ai siti Web di aprire autom
nl.ro.HelpContentConfig3:Deze optie geeft aan of NetSurf websites, die automatisch nieuwe pagina's proberen te openen blokkeerd.
zh_CN.ro.HelpContentConfig3:���������NetSurf���������������������������������������������������������������
-en.ro.HelpContentConfig4:This indicates whether NetSurf will allow external plug-ins to handle additional types of content, such as Flash.
-de.ro.HelpContentConfig4:Stellt ein, ob externe Pluginroutinen genutzt werden d��rfen, um Zusatzinhalte darzustellen (z.B. Flash).
-fr.ro.HelpContentConfig4:Ceci indique si Netsurf doit autoriser les plug-ins externes �� manipuler des types de contenu suppl��mentaires, comme le Flash.
-it.ro.HelpContentConfig4:Indica se NetSurf consentir�� ai plug-in esterni di gestire tipi di contenuto aggiuntivi come il Flash.
-nl.ro.HelpContentConfig4:Deze optie geeft aan of NetSurf externe plug-ins, voor aanvullende soorten inhoud zoals Flash toestaat.
-zh_CN.ro.HelpContentConfig4:��������� NetSurf ������������������������������������������������������������ Flash ���������
+en.ro.HelpContentConfig4:This indicates whether NetSurf will allow web pages to style their content with CSS.
+de.ro.HelpContentConfig4:This indicates whether NetSurf will allow web pages to style their content with CSS.
+fr.ro.HelpContentConfig4:This indicates whether NetSurf will allow web pages to style their content with CSS.
+it.ro.HelpContentConfig4:This indicates whether NetSurf will allow web pages to style their content with CSS.
+nl.ro.HelpContentConfig4:This indicates whether NetSurf will allow web pages to style their content with CSS.
+zh_CN.ro.HelpContentConfig4:This indicates whether NetSurf will allow web pages to style their content with CSS.
en.ro.HelpContentConfig7:This indicates whether NetSurf will allow links to open in new windows.
de.ro.HelpContentConfig7:Stellt ein, ob NetSurf erlaubt, da�� Links beim Aufruf neue Browserfenster ��ffnen d��rfen.
--
NetSurf Browser
3 days, 16 hours
netsurf: branch master updated. release/3.10-374-g14b6fa9
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/14b6fa95469b2a3ecae7e...
...commit http://git.netsurf-browser.org/netsurf.git/commit/14b6fa95469b2a3ecae7ee4...
...tree http://git.netsurf-browser.org/netsurf.git/tree/14b6fa95469b2a3ecae7ee4ff...
The branch, master has been updated
via 14b6fa95469b2a3ecae7ee4ff7c5334250d26c56 (commit)
from dcdd0148b2d61caa118172df97d44c3b1a4ffa47 (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=14b6fa95469b2a3ecae...
commit 14b6fa95469b2a3ecae7ee4ff7c5334250d26c56
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
RISC OS: Remove last vestiges of plugin support
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index 22f6f25..1a2b944 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -144,27 +144,6 @@ static ns_wimp_message_list task_messages = {
message_URI_PROCESS,
message_URI_RETURN_RESULT,
message_INET_SUITE_OPEN_URL,
-#ifdef WITH_PLUGIN
- message_PLUG_IN_OPENING,
- message_PLUG_IN_CLOSED,
- message_PLUG_IN_RESHAPE_REQUEST,
- message_PLUG_IN_FOCUS,
- message_PLUG_IN_URL_ACCESS,
- message_PLUG_IN_STATUS,
- message_PLUG_IN_BUSY,
- message_PLUG_IN_STREAM_NEW,
- message_PLUG_IN_STREAM_WRITE,
- message_PLUG_IN_STREAM_WRITTEN,
- message_PLUG_IN_STREAM_DESTROY,
- message_PLUG_IN_OPEN,
- message_PLUG_IN_CLOSE,
- message_PLUG_IN_RESHAPE,
- message_PLUG_IN_STREAM_AS_FILE,
- message_PLUG_IN_NOTIFY,
- message_PLUG_IN_ABORT,
- message_PLUG_IN_ACTION,
- /* message_PLUG_IN_INFORMED, (not provided by oslib) */
-#endif
message_PRINT_SAVE,
message_PRINT_ERROR,
message_PRINT_TYPE_ODD,
@@ -1779,51 +1758,6 @@ static void ro_gui_user_message(wimp_event_no event, wimp_message *message)
ro_url_message_received(message);
}
break;
-#ifdef WITH_PLUGIN
- case message_PLUG_IN_OPENING:
- plugin_opening(message);
- break;
- case message_PLUG_IN_CLOSED:
- plugin_closed(message);
- break;
- case message_PLUG_IN_RESHAPE_REQUEST:
- plugin_reshape_request(message);
- break;
- case message_PLUG_IN_FOCUS:
- break;
- case message_PLUG_IN_URL_ACCESS:
- plugin_url_access(message);
- break;
- case message_PLUG_IN_STATUS:
- plugin_status(message);
- break;
- case message_PLUG_IN_BUSY:
- break;
- case message_PLUG_IN_STREAM_NEW:
- plugin_stream_new(message);
- break;
- case message_PLUG_IN_STREAM_WRITE:
- break;
- case message_PLUG_IN_STREAM_WRITTEN:
- plugin_stream_written(message);
- break;
- case message_PLUG_IN_STREAM_DESTROY:
- break;
- case message_PLUG_IN_OPEN:
- if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
- plugin_open_msg(message);
- break;
- case message_PLUG_IN_CLOSE:
- if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
- plugin_close_msg(message);
- break;
- case message_PLUG_IN_RESHAPE:
- case message_PLUG_IN_STREAM_AS_FILE:
- case message_PLUG_IN_NOTIFY:
- case message_PLUG_IN_ABORT:
- case message_PLUG_IN_ACTION:
- break;
-#endif
case message_PRINT_SAVE:
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
ro_print_save_bounce(message);
diff --git a/frontends/riscos/templates/de b/frontends/riscos/templates/de
index 4ad0513..a6c1372 100644
--- a/frontends/riscos/templates/de
+++ b/frontends/riscos/templates/de
@@ -3370,11 +3370,7 @@ wimp_window {
}
wimp_icon {
extent:32,-256,496,-212
-#ifdef WITH_PLUGIN
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
-#else
icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_DELETED | wimp_BUTTON_RADIO
-#endif
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
diff --git a/frontends/riscos/templates/en b/frontends/riscos/templates/en
index c418ed7..8b84d15 100644
--- a/frontends/riscos/templates/en
+++ b/frontends/riscos/templates/en
@@ -3040,11 +3040,7 @@ wimp_window {
}
wimp_icon {
extent:32,-256,344,-212
-#ifdef WITH_PLUGIN
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
-#else
icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_DELETED | wimp_BUTTON_RADIO
-#endif
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
diff --git a/frontends/riscos/templates/fr b/frontends/riscos/templates/fr
index cdc1098..6128d3f 100644
--- a/frontends/riscos/templates/fr
+++ b/frontends/riscos/templates/fr
@@ -2842,11 +2842,7 @@ wimp_window {
}
wimp_icon {
extent:32,-256,404,-212
-#ifdef WITH_PLUGIN
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
-#else
icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_DELETED | wimp_BUTTON_RADIO
-#endif
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
-----------------------------------------------------------------------
Summary of changes:
frontends/riscos/gui.c | 66 -----------------------------------------
frontends/riscos/templates/de | 4 ---
frontends/riscos/templates/en | 4 ---
frontends/riscos/templates/fr | 4 ---
4 files changed, 78 deletions(-)
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index 22f6f25..1a2b944 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -144,27 +144,6 @@ static ns_wimp_message_list task_messages = {
message_URI_PROCESS,
message_URI_RETURN_RESULT,
message_INET_SUITE_OPEN_URL,
-#ifdef WITH_PLUGIN
- message_PLUG_IN_OPENING,
- message_PLUG_IN_CLOSED,
- message_PLUG_IN_RESHAPE_REQUEST,
- message_PLUG_IN_FOCUS,
- message_PLUG_IN_URL_ACCESS,
- message_PLUG_IN_STATUS,
- message_PLUG_IN_BUSY,
- message_PLUG_IN_STREAM_NEW,
- message_PLUG_IN_STREAM_WRITE,
- message_PLUG_IN_STREAM_WRITTEN,
- message_PLUG_IN_STREAM_DESTROY,
- message_PLUG_IN_OPEN,
- message_PLUG_IN_CLOSE,
- message_PLUG_IN_RESHAPE,
- message_PLUG_IN_STREAM_AS_FILE,
- message_PLUG_IN_NOTIFY,
- message_PLUG_IN_ABORT,
- message_PLUG_IN_ACTION,
- /* message_PLUG_IN_INFORMED, (not provided by oslib) */
-#endif
message_PRINT_SAVE,
message_PRINT_ERROR,
message_PRINT_TYPE_ODD,
@@ -1779,51 +1758,6 @@ static void ro_gui_user_message(wimp_event_no event, wimp_message *message)
ro_url_message_received(message);
}
break;
-#ifdef WITH_PLUGIN
- case message_PLUG_IN_OPENING:
- plugin_opening(message);
- break;
- case message_PLUG_IN_CLOSED:
- plugin_closed(message);
- break;
- case message_PLUG_IN_RESHAPE_REQUEST:
- plugin_reshape_request(message);
- break;
- case message_PLUG_IN_FOCUS:
- break;
- case message_PLUG_IN_URL_ACCESS:
- plugin_url_access(message);
- break;
- case message_PLUG_IN_STATUS:
- plugin_status(message);
- break;
- case message_PLUG_IN_BUSY:
- break;
- case message_PLUG_IN_STREAM_NEW:
- plugin_stream_new(message);
- break;
- case message_PLUG_IN_STREAM_WRITE:
- break;
- case message_PLUG_IN_STREAM_WRITTEN:
- plugin_stream_written(message);
- break;
- case message_PLUG_IN_STREAM_DESTROY:
- break;
- case message_PLUG_IN_OPEN:
- if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
- plugin_open_msg(message);
- break;
- case message_PLUG_IN_CLOSE:
- if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
- plugin_close_msg(message);
- break;
- case message_PLUG_IN_RESHAPE:
- case message_PLUG_IN_STREAM_AS_FILE:
- case message_PLUG_IN_NOTIFY:
- case message_PLUG_IN_ABORT:
- case message_PLUG_IN_ACTION:
- break;
-#endif
case message_PRINT_SAVE:
if (event == wimp_USER_MESSAGE_ACKNOWLEDGE)
ro_print_save_bounce(message);
diff --git a/frontends/riscos/templates/de b/frontends/riscos/templates/de
index 4ad0513..a6c1372 100644
--- a/frontends/riscos/templates/de
+++ b/frontends/riscos/templates/de
@@ -3370,11 +3370,7 @@ wimp_window {
}
wimp_icon {
extent:32,-256,496,-212
-#ifdef WITH_PLUGIN
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
-#else
icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_DELETED | wimp_BUTTON_RADIO
-#endif
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
diff --git a/frontends/riscos/templates/en b/frontends/riscos/templates/en
index c418ed7..8b84d15 100644
--- a/frontends/riscos/templates/en
+++ b/frontends/riscos/templates/en
@@ -3040,11 +3040,7 @@ wimp_window {
}
wimp_icon {
extent:32,-256,344,-212
-#ifdef WITH_PLUGIN
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
-#else
icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_DELETED | wimp_BUTTON_RADIO
-#endif
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
diff --git a/frontends/riscos/templates/fr b/frontends/riscos/templates/fr
index cdc1098..6128d3f 100644
--- a/frontends/riscos/templates/fr
+++ b/frontends/riscos/templates/fr
@@ -2842,11 +2842,7 @@ wimp_window {
}
wimp_icon {
extent:32,-256,404,-212
-#ifdef WITH_PLUGIN
- icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_BUTTON_RADIO
-#else
icon_flags:wimp_ICON_TEXT | wimp_ICON_SPRITE | wimp_ICON_VCENTRED | wimp_ICON_INDIRECTED | wimp_ICON_DELETED | wimp_BUTTON_RADIO
-#endif
icon_esg:0
icon_fg:wimp_COLOUR_BLACK
icon_bg:wimp_COLOUR_VERY_LIGHT_GREY
--
NetSurf Browser
3 days, 17 hours
netsurf: branch master updated. release/3.10-373-gdcdd014
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/dcdd0148b2d61caa11817...
...commit http://git.netsurf-browser.org/netsurf.git/commit/dcdd0148b2d61caa118172d...
...tree http://git.netsurf-browser.org/netsurf.git/tree/dcdd0148b2d61caa118172df9...
The branch, master has been updated
via dcdd0148b2d61caa118172df97d44c3b1a4ffa47 (commit)
via 571a9ca0c9fe6ab4b2340fc3627fafc53bb82eab (commit)
via 33bba1d9fdffad503f9f6529dbecc3eca261b864 (commit)
via 74ab1eb244ba4470ec968bd7dcd1f9bec182f202 (commit)
from 303d5f251f462193f7a15af997f3fa843f78d12b (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=dcdd0148b2d61caa118...
commit dcdd0148b2d61caa118172df97d44c3b1a4ffa47
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: css: Remove redundant origin filtering for author_level_css
diff --git a/content/handlers/html/css.c b/content/handlers/html/css.c
index 7ee94c1..0bc3884 100644
--- a/content/handlers/html/css.c
+++ b/content/handlers/html/css.c
@@ -687,11 +687,6 @@ html_css_new_selection_context(html_content *c, css_select_ctx **ret_select_ctx)
origin = CSS_ORIGIN_USER;
}
- if (origin == CSS_ORIGIN_AUTHOR &&
- nsoption_bool(author_level_css) == false) {
- continue;
- }
-
if (hsheet->sheet != NULL) {
sheet = nscss_get_stylesheet(hsheet->sheet);
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=571a9ca0c9fe6ab4b23...
commit 571a9ca0c9fe6ab4b2340fc3627fafc53bb82eab
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: Avoid processing STYLE elements if author_level_css disabled
diff --git a/content/handlers/html/dom_event.c b/content/handlers/html/dom_event.c
index 36a020b..d389a21 100644
--- a/content/handlers/html/dom_event.c
+++ b/content/handlers/html/dom_event.c
@@ -622,7 +622,9 @@ dom_default_action_DOMNodeInserted_cb(struct dom_event *evt, void *pw)
break;
case DOM_HTML_ELEMENT_TYPE_STYLE:
- html_css_process_style(htmlc, (dom_node *)node);
+ if (nsoption_bool(author_level_css)) {
+ html_css_process_style(htmlc, (dom_node *)node);
+ }
break;
case DOM_HTML_ELEMENT_TYPE_SCRIPT:
@@ -730,7 +732,10 @@ dom_default_action_DOMSubtreeModified_cb(struct dom_event *evt, void *pw)
switch (tag_type) {
case DOM_HTML_ELEMENT_TYPE_STYLE:
- html_css_update_style(htmlc, (dom_node *)node);
+ if (nsoption_bool(author_level_css)) {
+ html_css_update_style(htmlc,
+ (dom_node *)node);
+ }
break;
case DOM_HTML_ELEMENT_TYPE_TEXTAREA:
case DOM_HTML_ELEMENT_TYPE_INPUT:
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=33bba1d9fdffad503f9...
commit 33bba1d9fdffad503f9f6529dbecc3eca261b864
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: Avoid fetching (and decoding) linked stylesheets
When the `author_level_css` option is disabled, avoid fetching
stylesheets that won't be used for selection.
diff --git a/content/handlers/html/css.c b/content/handlers/html/css.c
index cdb9494..7ee94c1 100644
--- a/content/handlers/html/css.c
+++ b/content/handlers/html/css.c
@@ -406,6 +406,10 @@ bool html_css_process_link(html_content *htmlc, dom_node *node)
}
dom_string_unref(rel);
+ if (nsoption_bool(author_level_css) == false) {
+ return true;
+ }
+
/* type='text/css' or not present */
exc = dom_element_get_attribute(node, corestring_dom_type, &type_attr);
if (exc == DOM_NO_ERR && type_attr != NULL) {
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=74ab1eb244ba4470ec9...
commit 74ab1eb244ba4470ec968bd7dcd1f9bec182f202
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <mdrake.unique(a)gmail.com>
html: css: Minor code style fix
diff --git a/content/handlers/html/css.c b/content/handlers/html/css.c
index 69d5458..cdb9494 100644
--- a/content/handlers/html/css.c
+++ b/content/handlers/html/css.c
@@ -396,10 +396,10 @@ bool html_css_process_link(html_content *htmlc, dom_node *node)
if (exc != DOM_NO_ERR || rel == NULL)
return true;
- if (strcasestr(dom_string_data(rel), "stylesheet") == 0) {
+ if (strcasestr(dom_string_data(rel), "stylesheet") == NULL) {
dom_string_unref(rel);
return true;
- } else if (strcasestr(dom_string_data(rel), "alternate") != 0) {
+ } else if (strcasestr(dom_string_data(rel), "alternate") != NULL) {
/* Ignore alternate stylesheets */
dom_string_unref(rel);
return true;
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/css.c | 13 ++++++-------
content/handlers/html/dom_event.c | 9 +++++++--
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/content/handlers/html/css.c b/content/handlers/html/css.c
index 69d5458..0bc3884 100644
--- a/content/handlers/html/css.c
+++ b/content/handlers/html/css.c
@@ -396,16 +396,20 @@ bool html_css_process_link(html_content *htmlc, dom_node *node)
if (exc != DOM_NO_ERR || rel == NULL)
return true;
- if (strcasestr(dom_string_data(rel), "stylesheet") == 0) {
+ if (strcasestr(dom_string_data(rel), "stylesheet") == NULL) {
dom_string_unref(rel);
return true;
- } else if (strcasestr(dom_string_data(rel), "alternate") != 0) {
+ } else if (strcasestr(dom_string_data(rel), "alternate") != NULL) {
/* Ignore alternate stylesheets */
dom_string_unref(rel);
return true;
}
dom_string_unref(rel);
+ if (nsoption_bool(author_level_css) == false) {
+ return true;
+ }
+
/* type='text/css' or not present */
exc = dom_element_get_attribute(node, corestring_dom_type, &type_attr);
if (exc == DOM_NO_ERR && type_attr != NULL) {
@@ -683,11 +687,6 @@ html_css_new_selection_context(html_content *c, css_select_ctx **ret_select_ctx)
origin = CSS_ORIGIN_USER;
}
- if (origin == CSS_ORIGIN_AUTHOR &&
- nsoption_bool(author_level_css) == false) {
- continue;
- }
-
if (hsheet->sheet != NULL) {
sheet = nscss_get_stylesheet(hsheet->sheet);
}
diff --git a/content/handlers/html/dom_event.c b/content/handlers/html/dom_event.c
index 36a020b..d389a21 100644
--- a/content/handlers/html/dom_event.c
+++ b/content/handlers/html/dom_event.c
@@ -622,7 +622,9 @@ dom_default_action_DOMNodeInserted_cb(struct dom_event *evt, void *pw)
break;
case DOM_HTML_ELEMENT_TYPE_STYLE:
- html_css_process_style(htmlc, (dom_node *)node);
+ if (nsoption_bool(author_level_css)) {
+ html_css_process_style(htmlc, (dom_node *)node);
+ }
break;
case DOM_HTML_ELEMENT_TYPE_SCRIPT:
@@ -730,7 +732,10 @@ dom_default_action_DOMSubtreeModified_cb(struct dom_event *evt, void *pw)
switch (tag_type) {
case DOM_HTML_ELEMENT_TYPE_STYLE:
- html_css_update_style(htmlc, (dom_node *)node);
+ if (nsoption_bool(author_level_css)) {
+ html_css_update_style(htmlc,
+ (dom_node *)node);
+ }
break;
case DOM_HTML_ELEMENT_TYPE_TEXTAREA:
case DOM_HTML_ELEMENT_TYPE_INPUT:
--
NetSurf Browser
3 days, 18 hours