summaryrefslogtreecommitdiff
path: root/include/netsurf
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-06-06 08:59:23 +0100
committerVincent Sanders <vince@kyllikki.org>2016-06-06 09:01:38 +0100
commit76a68d7dd02f3819e4e60cd9febfd45e20821e14 (patch)
treea86fc61314fd53d383cb95a313a2897779984214 /include/netsurf
parentd923e109cd56c553c8e87cdb8bdab5085e68cc73 (diff)
downloadnetsurf-76a68d7dd02f3819e4e60cd9febfd45e20821e14.tar.gz
netsurf-76a68d7dd02f3819e4e60cd9febfd45e20821e14.tar.bz2
Update content to split public and internal API
Diffstat (limited to 'include/netsurf')
-rw-r--r--include/netsurf/content.h188
-rw-r--r--include/netsurf/content_type.h76
2 files changed, 264 insertions, 0 deletions
diff --git a/include/netsurf/content.h b/include/netsurf/content.h
new file mode 100644
index 000000000..3f3a30c0e
--- /dev/null
+++ b/include/netsurf/content.h
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2016 Vincent Sanders <vince@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
+ * Public content interface.
+ *
+ * The content functions manipulate content objects.
+ */
+
+#ifndef _NETSURF_CONTENT_H_
+#define _NETSURF_CONTENT_H_
+
+#include <libwapcaplet/libwapcaplet.h>
+
+#include "desktop/plot_style.h" /* color typedef */
+#include "netsurf/content_type.h"
+
+struct bitmap;
+struct hlcache_handle;
+struct rect;
+struct redraw_context;
+
+/** parameters to content redraw */
+struct content_redraw_data {
+ int x; /**< coordinate for top-left of redraw */
+ int y; /**< coordinate for top-left of redraw */
+
+ /** dimensions to render content at (for scaling contents with
+ * intrinsic dimensions)
+ */
+ int width; /**< horizontal dimension */
+ int height; /**< vertical dimension */
+
+ /** The background colour */
+ colour background_colour;
+
+ /** Scale for redraw
+ * (for scaling contents without intrinsic dimensions)
+ */
+ float scale; /**< Scale factor for redraw */
+
+ bool repeat_x; /**< whether content is tiled in x direction */
+ bool repeat_y; /**< whether content is tiled in y direction */
+};
+
+/**
+ * Retrieve the bitmap contained in an image content
+ *
+ * \param h handle to the content.
+ * \return Pointer to bitmap, or NULL if none.
+ */
+struct bitmap *content_get_bitmap(struct hlcache_handle *h);
+
+
+/**
+ * Retrieve the encoding of a content
+ *
+ * \param h handle to the content.
+ * \param op encoding operation.
+ * \return Pointer to content info or NULL if none.
+ */
+const char *content_get_encoding(struct hlcache_handle *h, enum content_encoding_type op);
+
+
+/**
+ * Retrieve mime-type of content
+ *
+ * \param h handle to the content to retrieve mime type from
+ * \return Pointer to referenced mime type, or NULL if not found.
+ */
+lwc_string *content_get_mime_type(struct hlcache_handle *h);
+
+
+/**
+ * Retrieve source of content
+ *
+ * \param h Content handle to retrieve source of
+ * \param size Pointer to location to receive byte size of source
+ * \return Pointer to source data
+ */
+const char *content_get_source_data(struct hlcache_handle *h, unsigned long *size);
+
+
+/**
+ * Retrieve title associated with content
+ *
+ * \param h handle to the content to retrieve title from
+ * \return Pointer to title, or NULL if not found.
+ */
+const char *content_get_title(struct hlcache_handle *h);
+
+
+/**
+ * Retrieve computed type of content
+ *
+ * \param h handle to the content to retrieve type of.
+ * \return Computed content type
+ */
+content_type content_get_type(struct hlcache_handle *h);
+
+
+/**
+ * Retrieve width of content
+ *
+ * \param h handle to the content to get width of.
+ * \return Content width
+ */
+int content_get_width(struct hlcache_handle *h);
+
+
+/**
+ * Retrieve height of content
+ *
+ * \param h handle to the content to get height of.
+ * \return Content height
+ */
+int content_get_height(struct hlcache_handle *h);
+
+
+/**
+ * Invalidate content reuse data.
+ *
+ * causes subsequent requests for content URL to query server to
+ * determine if content can be reused. This is required behaviour for
+ * forced reloads etc.
+ *
+ * \param h Content handle to invalidate.
+ */
+void content_invalidate_reuse_data(struct hlcache_handle *h);
+
+
+/**
+ * Display content on screen with optional tiling.
+ *
+ * \param h The content to redraw
+ * \param ctx current redraw context
+ * \return true if successful, false otherwise
+ *
+ * Calls the redraw function for the content.
+ */
+bool content_redraw(struct hlcache_handle *h, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx);
+
+
+/**
+ * Redraw a content with scale set for horizontal fit.
+ *
+ * Redraws the content at a specified width and height with the
+ * content drawing scaled to fit within the area.
+ *
+ * \param h The content to redraw
+ * \param width The target width
+ * \param height The target height
+ * \param ctx current redraw context
+ * \return true if successful, false otherwise
+ *
+ * The thumbnail is guaranteed to be filled to its width/height extents, so
+ * there is no need to render a solid background first.
+ *
+ * Units for width and height are pixels.
+ */
+bool content_scaled_redraw(struct hlcache_handle *h, int width, int height, const struct redraw_context *ctx);
+
+
+/**
+ * Retrieve the URL associated with a high level cache handle
+ *
+ * \param handle The handle to inspect
+ * \return Pointer to URL.
+ */
+struct nsurl *hlcache_handle_get_url(const struct hlcache_handle *handle);
+
+#endif
diff --git a/include/netsurf/content_type.h b/include/netsurf/content_type.h
new file mode 100644
index 000000000..b3d574309
--- /dev/null
+++ b/include/netsurf/content_type.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2003 James Bursa <bursa@users.sourceforge.net>
+ *
+ * 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
+ * Declaration of content type enumerations.
+ *
+ * The content enumerations are defined here.
+ */
+
+#ifndef _NETSURF_CONTENT_TYPE_H_
+#define _NETSURF_CONTENT_TYPE_H_
+
+/** Debugging dump operations */
+enum content_debug {
+ CONTENT_DEBUG_RENDER, /** Debug the contents rendering. */
+ CONTENT_DEBUG_DOM, /** Debug the contents Document Object. */
+ CONTENT_DEBUG_REDRAW /** Debug redraw operations. */
+};
+
+/** Content encoding information types */
+enum content_encoding_type {
+ CONTENT_ENCODING_NORMAL, /** The content encoding */
+ CONTENT_ENCODING_SOURCE /** The content encoding source */
+};
+
+/** The type of a content. */
+typedef enum {
+ /** no type for content */
+ CONTENT_NONE = 0x00,
+
+ /** content is HTML */
+ CONTENT_HTML = 0x01,
+
+ /** content is plain text */
+ CONTENT_TEXTPLAIN = 0x02,
+
+ /** content is CSS */
+ CONTENT_CSS = 0x04,
+
+ /** All images */
+ CONTENT_IMAGE = 0x08,
+
+ /** Navigator API Plugins */
+ CONTENT_PLUGIN = 0x10,
+
+ /** RISC OS themes content */
+ CONTENT_THEME = 0x20,
+
+ /** Javascript */
+ CONTENT_JS = 0x40,
+
+ /** All script types. */
+ CONTENT_SCRIPT = 0x40,
+
+ /** Any content matches */
+ CONTENT_ANY = 0x7f
+} content_type;
+
+
+#endif