summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-11-05 23:44:31 +0000
committerVincent Sanders <vince@kyllikki.org>2014-11-05 23:44:31 +0000
commit8ec7ad053a9a291ea2619055b1ca1989d4c975b9 (patch)
treeaa7272b673e2062985667d87fcfe7e19f30eb239 /content
parent4ca959f46baf18213bf5ded769d87c7f030d392f (diff)
downloadnetsurf-8ec7ad053a9a291ea2619055b1ca1989d4c975b9.tar.gz
netsurf-8ec7ad053a9a291ea2619055b1ca1989d4c975b9.tar.bz2
Make the fetching of a contents encoding generic.
The frontends previously had to use an html renderer API to get the encoding of a content. This also required the explicit checking of the contents type rather than using the existing content API to abstract this knowledge.
Diffstat (limited to 'content')
-rw-r--r--content/content.c24
-rw-r--r--content/content.h3
-rw-r--r--content/content_protected.h3
-rw-r--r--content/hlcache.c5
4 files changed, 30 insertions, 5 deletions
diff --git a/content/content.c b/content/content.c
index ee6ff818f..728147f31 100644
--- a/content/content.c
+++ b/content/content.c
@@ -1302,6 +1302,30 @@ bool content_get_quirks(hlcache_handle *h)
/**
+ * Retrieve the encoding of a content
+ *
+ * \param c Content to retrieve bitmap from
+ * \return Pointer to bitmap, or NULL if none.
+ */
+const char *content_get_encoding(hlcache_handle *h)
+{
+ return content__get_encoding(hlcache_handle_get_content(h));
+}
+
+const char *content__get_encoding(struct content *c)
+{
+ const char *encoding = NULL;
+
+ if ((c != NULL) &&
+ (c->handler != NULL) &&
+ (c->handler->get_encoding != NULL) ) {
+ encoding = c->handler->get_encoding(c);
+ }
+
+ return encoding;
+}
+
+/**
* Return whether a content is currently locked
*
* \param c Content to test
diff --git a/content/content.h b/content/content.h
index 11ddee1dd..67a519df6 100644
--- a/content/content.h
+++ b/content/content.h
@@ -318,7 +318,8 @@ void content_invalidate_reuse_data(struct hlcache_handle *c);
nsurl *content_get_refresh_url(struct hlcache_handle *c);
struct bitmap *content_get_bitmap(struct hlcache_handle *c);
bool content_get_opaque(struct hlcache_handle *h);
-bool content_get_quirks(struct hlcache_handle *c);
+bool content_get_quirks(struct hlcache_handle *h);
+const char *content_get_encoding(struct hlcache_handle *h);
bool content_is_locked(struct hlcache_handle *h);
diff --git a/content/content_protected.h b/content/content_protected.h
index 84b401f00..ce161befc 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -79,6 +79,7 @@ struct content_handler {
nserror (*debug_dump)(struct content *c, FILE *f, enum content_debug op);
nserror (*clone)(const struct content *old, struct content **newc);
bool (*matches_quirks)(const struct content *c, bool quirks);
+ const char *(*get_encoding)(const struct content *c);
content_type (*type)(void);
/** handler dependant content sensitive internal data interface. */
@@ -196,7 +197,7 @@ void content__invalidate_reuse_data(struct content *c);
nsurl *content__get_refresh_url(struct content *c);
struct bitmap *content__get_bitmap(struct content *c);
bool content__get_opaque(struct content *c);
-
+const char *content__get_encoding(struct content *c);
bool content__is_locked(struct content *c);
#endif
diff --git a/content/hlcache.c b/content/hlcache.c
index 8a7ffe9da..6cfcba328 100644
--- a/content/hlcache.c
+++ b/content/hlcache.c
@@ -718,10 +718,9 @@ nserror hlcache_handle_release(hlcache_handle *handle)
/* See hlcache.h for documentation */
struct content *hlcache_handle_get_content(const hlcache_handle *handle)
{
- assert(handle != NULL);
-
- if (handle->entry != NULL)
+ if ((handle != NULL) && (handle->entry != NULL)) {
return handle->entry->content;
+ }
return NULL;
}