From 76a68d7dd02f3819e4e60cd9febfd45e20821e14 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 6 Jun 2016 08:59:23 +0100 Subject: Update content to split public and internal API --- include/netsurf/content.h | 188 +++++++++++++++++++++++++++++++++++++++++ include/netsurf/content_type.h | 76 +++++++++++++++++ 2 files changed, 264 insertions(+) create mode 100644 include/netsurf/content.h create mode 100644 include/netsurf/content_type.h (limited to 'include') 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 + * + * 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 . + */ + +/** + * \file + * Public content interface. + * + * The content functions manipulate content objects. + */ + +#ifndef _NETSURF_CONTENT_H_ +#define _NETSURF_CONTENT_H_ + +#include + +#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 + * + * 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 . + */ + +/** + * \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 -- cgit v1.2.3