NetSurf
content.h
Go to the documentation of this file.
1/*
2 * Copyright 2016 Vincent Sanders <vince@netsurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 * \file
21 * Public content interface.
22 *
23 * The content functions manipulate content objects.
24 */
25
26#ifndef _NETSURF_CONTENT_H_
27#define _NETSURF_CONTENT_H_
28
29#include <libwapcaplet/libwapcaplet.h>
30
31#include "netsurf/types.h"
33
34struct bitmap;
35struct hlcache_handle;
36struct rect;
37struct redraw_context;
38
39/** parameters to content redraw */
41 int x; /**< coordinate for top-left of redraw */
42 int y; /**< coordinate for top-left of redraw */
43
44 /** dimensions to render content at (for scaling contents with
45 * intrinsic dimensions)
46 */
47 int width; /**< horizontal dimension */
48 int height; /**< vertical dimension */
49
50 /** The background colour */
52
53 /** Scale for redraw
54 * (for scaling contents without intrinsic dimensions)
55 */
56 float scale; /**< Scale factor for redraw */
57
58 bool repeat_x; /**< whether content is tiled in x direction */
59 bool repeat_y; /**< whether content is tiled in y direction */
60};
61
62/**
63 * Retrieve the bitmap contained in an image content
64 *
65 * \param h handle to the content.
66 * \return Pointer to bitmap, or NULL if none.
67 */
69
70
71/**
72 * Retrieve the encoding of a content
73 *
74 * \param h handle to the content.
75 * \param op encoding operation.
76 * \return Pointer to content info or NULL if none.
77 */
78const char *content_get_encoding(struct hlcache_handle *h, enum content_encoding_type op);
79
80
81/**
82 * Retrieve mime-type of content
83 *
84 * \param h handle to the content to retrieve mime type from
85 * \return Pointer to referenced mime type, or NULL if not found.
86 */
87lwc_string *content_get_mime_type(struct hlcache_handle *h);
88
89
90/**
91 * Retrieve source of content
92 *
93 * \param h Content handle to retrieve source of
94 * \param size Pointer to location to receive byte size of source
95 * \return Pointer to source data
96 */
97const uint8_t *content_get_source_data(struct hlcache_handle *h, size_t *size);
98
99
100/**
101 * Retrieve title associated with content
102 *
103 * \param h handle to the content to retrieve title from
104 * \return Pointer to title, or NULL if not found.
105 */
106const char *content_get_title(struct hlcache_handle *h);
107
108
109/**
110 * Retrieve computed type of content
111 *
112 * \param h handle to the content to retrieve type of.
113 * \return Computed content type
114 */
116
117
118/**
119 * Retrieve width of content
120 *
121 * \param h handle to the content to get width of.
122 * \return Content width
123 */
124int content_get_width(struct hlcache_handle *h);
125
126
127/**
128 * Retrieve height of content
129 *
130 * \param h handle to the content to get height of.
131 * \return Content height
132 */
134
135
136/**
137 * Invalidate content reuse data.
138 *
139 * causes subsequent requests for content URL to query server to
140 * determine if content can be reused. This is required behaviour for
141 * forced reloads etc.
142 *
143 * \param h Content handle to invalidate.
144 */
146
147
148/**
149 * Display content on screen with optional tiling.
150 *
151 * \param h The content to redraw.
152 * \param data The contents redraw data.
153 * \param clip The clipping rectangle to use when redrawing the content.
154 * \param ctx current redraw context.
155 * \return true if successful otherwise false.
156 *
157 * Calls the redraw function for the content.
158 */
159bool content_redraw(struct hlcache_handle *h, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx);
160
161
162/**
163 * Redraw a content with scale set for horizontal fit.
164 *
165 * Redraws the content at a specified width and height with the
166 * content drawing scaled to fit within the area.
167 *
168 * \param h The content to redraw
169 * \param width The target width
170 * \param height The target height
171 * \param ctx current redraw context
172 * \return true if successful, false otherwise
173 *
174 * The thumbnail is guaranteed to be filled to its width/height extents, so
175 * there is no need to render a solid background first.
176 *
177 * Units for width and height are pixels.
178 */
179bool content_scaled_redraw(struct hlcache_handle *h, int width, int height, const struct redraw_context *ctx);
180
181
182/**
183 * Retrieve the URL associated with a high level cache handle
184 *
185 * \param handle The handle to inspect
186 * \return Pointer to URL.
187 */
188struct nsurl *hlcache_handle_get_url(const struct hlcache_handle *handle);
189
190#endif
Declaration of content enumerations.
content_type
The type of a content.
Definition: content_type.h:53
content_encoding_type
Content encoding information types.
Definition: content_type.h:43
bool content_redraw(struct hlcache_handle *h, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
Display content on screen with optional tiling.
Definition: content.c:558
struct nsurl * hlcache_handle_get_url(const struct hlcache_handle *handle)
Retrieve the URL associated with a high level cache handle.
const char * content_get_title(struct hlcache_handle *h)
Retrieve title associated with content.
Definition: content.c:1106
int content_get_height(struct hlcache_handle *h)
Retrieve height of content.
Definition: content.c:1175
struct bitmap * content_get_bitmap(struct hlcache_handle *h)
Retrieve the bitmap contained in an image content.
Definition: content.c:1264
const uint8_t * content_get_source_data(struct hlcache_handle *h, size_t *size)
Retrieve source of content.
Definition: content.c:1209
int content_get_width(struct hlcache_handle *h)
Retrieve width of content.
Definition: content.c:1158
void content_invalidate_reuse_data(struct hlcache_handle *h)
Invalidate content reuse data.
Definition: content.c:1229
const char * content_get_encoding(struct hlcache_handle *h, enum content_encoding_type op)
Retrieve the encoding of a content.
Definition: content.c:1321
lwc_string * content_get_mime_type(struct hlcache_handle *h)
Retrieve mime-type of content.
Definition: content.c:1073
bool content_scaled_redraw(struct hlcache_handle *h, int width, int height, const struct redraw_context *ctx)
Redraw a content with scale set for horizontal fit.
Definition: content.c:583
content_type content_get_type(struct hlcache_handle *h)
Retrieve computed type of content.
Definition: content.c:1061
struct nsurl nsurl
NetSurf URL object.
Definition: nsurl.h:31
int width
Definition: gui.c:160
int height
Definition: gui.c:161
RISC OS wimp toolkit bitmap.
Definition: bitmap.c:68
uint32 size
Definition: bitmap.c:73
parameters to content redraw
Definition: content.h:40
int height
vertical dimension
Definition: content.h:48
bool repeat_y
whether content is tiled in y direction
Definition: content.h:59
bool repeat_x
whether content is tiled in x direction
Definition: content.h:58
int y
coordinate for top-left of redraw
Definition: content.h:42
int x
coordinate for top-left of redraw
Definition: content.h:41
colour background_colour
The background colour.
Definition: content.h:51
int width
dimensions to render content at (for scaling contents with intrinsic dimensions)
Definition: content.h:47
float scale
Scale for redraw (for scaling contents without intrinsic dimensions)
Definition: content.h:56
High-level cache handle.
Definition: hlcache.c:66
Rectangle coordinates.
Definition: types.h:40
Redraw context.
Definition: plotters.h:51
NetSurf types.
uint32_t colour
Colour type: XBGR.
Definition: types.h:35
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357