2003-06-30 16:44:03 +04:00
|
|
|
/*
|
2007-01-13 03:21:15 +03:00
|
|
|
* Copyright 2005-2007 James Bursa <bursa@users.sourceforge.net>
|
2003-06-30 16:44:03 +04:00
|
|
|
* Copyright 2003 Philip Pemberton <philpem@users.sourceforge.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* 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/>.
|
2003-02-09 15:58:15 +03:00
|
|
|
*/
|
|
|
|
|
2003-09-08 01:08:13 +04:00
|
|
|
/** \file
|
|
|
|
* Content handling (interface).
|
|
|
|
*
|
|
|
|
* The content functions manipulate struct contents, which correspond to URLs.
|
|
|
|
*/
|
|
|
|
|
2009-01-15 18:58:35 +03:00
|
|
|
#ifndef _NETSURF_CONTENT_CONTENT_H_
|
|
|
|
#define _NETSURF_CONTENT_CONTENT_H_
|
2003-02-09 15:58:15 +03:00
|
|
|
|
2010-03-28 16:56:39 +04:00
|
|
|
#include <stdbool.h>
|
2008-09-16 00:23:02 +04:00
|
|
|
|
2011-05-07 00:40:09 +04:00
|
|
|
#include <libwapcaplet/libwapcaplet.h>
|
|
|
|
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/config.h"
|
2010-04-04 16:41:19 +04:00
|
|
|
#include "utils/errors.h"
|
2011-05-07 00:40:09 +04:00
|
|
|
#include "utils/http.h"
|
2011-10-03 19:56:47 +04:00
|
|
|
#include "utils/nsurl.h"
|
2011-06-30 19:48:07 +04:00
|
|
|
#include "utils/types.h"
|
2011-05-07 00:40:09 +04:00
|
|
|
#include "content/content_factory.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "content/content_type.h"
|
2010-06-04 13:35:08 +04:00
|
|
|
#include "desktop/mouse.h"
|
2010-03-28 16:56:39 +04:00
|
|
|
#include "desktop/plot_style.h"
|
2003-02-09 15:58:15 +03:00
|
|
|
|
2004-08-11 23:02:32 +04:00
|
|
|
struct box;
|
|
|
|
struct browser_window;
|
|
|
|
struct content;
|
2010-04-06 01:35:38 +04:00
|
|
|
struct llcache_handle;
|
2010-03-28 16:56:39 +04:00
|
|
|
struct hlcache_handle;
|
2004-08-11 23:02:32 +04:00
|
|
|
struct object_params;
|
2011-02-14 01:25:11 +03:00
|
|
|
struct rect;
|
2011-06-30 19:48:07 +04:00
|
|
|
struct redraw_context;
|
|
|
|
|
2004-06-21 19:09:59 +04:00
|
|
|
|
2010-03-28 16:56:39 +04:00
|
|
|
/** Status of a content */
|
|
|
|
typedef enum {
|
|
|
|
CONTENT_STATUS_LOADING, /**< Content is being fetched or
|
|
|
|
converted and is not safe to display. */
|
|
|
|
CONTENT_STATUS_READY, /**< Some parts of content still being
|
|
|
|
loaded, but can be displayed. */
|
|
|
|
CONTENT_STATUS_DONE, /**< All finished. */
|
|
|
|
CONTENT_STATUS_ERROR /**< Error occurred, content will be
|
|
|
|
destroyed imminently. */
|
|
|
|
} content_status;
|
2004-06-21 19:09:59 +04:00
|
|
|
|
2003-09-08 01:08:13 +04:00
|
|
|
/** Used in callbacks to indicate what has occurred. */
|
2003-06-17 23:24:21 +04:00
|
|
|
typedef enum {
|
2003-09-08 01:08:13 +04:00
|
|
|
CONTENT_MSG_LOADING, /**< fetching or converting */
|
|
|
|
CONTENT_MSG_READY, /**< may be displayed */
|
|
|
|
CONTENT_MSG_DONE, /**< finished */
|
|
|
|
CONTENT_MSG_ERROR, /**< error occurred */
|
|
|
|
CONTENT_MSG_STATUS, /**< new status string */
|
2003-10-25 23:20:13 +04:00
|
|
|
CONTENT_MSG_REFORMAT, /**< content_reformat done */
|
2004-03-21 15:50:10 +03:00
|
|
|
CONTENT_MSG_REDRAW, /**< needs redraw (eg. new animation frame) */
|
2006-01-25 09:52:38 +03:00
|
|
|
CONTENT_MSG_REFRESH, /**< wants refresh */
|
2011-01-07 16:10:20 +03:00
|
|
|
CONTENT_MSG_DOWNLOAD, /**< download, not for display */
|
2011-10-07 03:31:55 +04:00
|
|
|
CONTENT_MSG_LINK, /**< RFC5988 link */
|
2003-06-17 23:24:21 +04:00
|
|
|
} content_msg;
|
|
|
|
|
2011-10-07 22:12:47 +04:00
|
|
|
/** RFC5988 metadata link */
|
|
|
|
struct content_rfc5988_link {
|
|
|
|
struct content_rfc5988_link *next; /**< next rfc5988_link in list */
|
|
|
|
|
|
|
|
lwc_string *rel; /**< the link relationship - must be present */
|
|
|
|
nsurl *href; /* the link href - must be present */
|
|
|
|
lwc_string *hreflang;
|
|
|
|
lwc_string *type;
|
|
|
|
lwc_string *media;
|
|
|
|
lwc_string *sizes;
|
|
|
|
};
|
|
|
|
|
2004-04-25 03:42:32 +04:00
|
|
|
/** Extra data for some content_msg messages. */
|
|
|
|
union content_msg_data {
|
|
|
|
const char *error; /**< Error message, for CONTENT_MSG_ERROR. */
|
|
|
|
/** Area of content which needs redrawing, for CONTENT_MSG_REDRAW. */
|
|
|
|
struct {
|
2011-03-03 00:10:29 +03:00
|
|
|
int x, y, width, height;
|
2004-04-25 03:42:32 +04:00
|
|
|
/** Redraw the area fully. If false, object must be set,
|
|
|
|
* and only the object will be redrawn. */
|
|
|
|
bool full_redraw;
|
|
|
|
/** Object to redraw if full_redraw is false. */
|
|
|
|
struct content *object;
|
|
|
|
/** Coordinates to plot object at. */
|
2011-03-03 00:10:29 +03:00
|
|
|
int object_x, object_y;
|
2004-04-26 17:47:51 +04:00
|
|
|
/** Dimensions to plot object with. */
|
2011-03-03 00:10:29 +03:00
|
|
|
int object_width, object_height;
|
2004-04-25 03:42:32 +04:00
|
|
|
} redraw;
|
2006-01-25 09:52:38 +03:00
|
|
|
int delay; /**< Minimum delay, for CONTENT_MSG_REFRESH */
|
2011-06-24 13:30:33 +04:00
|
|
|
/** Reformat should not cause a redraw, for CONTENT_MSG_REFORMAT */
|
|
|
|
bool background;
|
2010-04-06 01:35:38 +04:00
|
|
|
/** Low-level cache handle, for CONTENT_MSG_DOWNLOAD */
|
|
|
|
struct llcache_handle *download;
|
2011-10-07 03:31:55 +04:00
|
|
|
/** rfc5988 link data CONTENT_MSG_RFC5988_LINK */
|
2011-10-07 22:12:47 +04:00
|
|
|
struct content_rfc5988_link *rfc5988_link;
|
2004-04-25 03:42:32 +04:00
|
|
|
};
|
|
|
|
|
2011-06-29 00:17:39 +04:00
|
|
|
|
|
|
|
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 */
|
|
|
|
int height; /* vertical */
|
|
|
|
|
|
|
|
/** the background colour */
|
|
|
|
colour background_colour;
|
|
|
|
|
|
|
|
/** Scale for redraw
|
|
|
|
* (for scaling contents without intrinsic dimensions) */
|
|
|
|
float scale; /* scale factor */
|
|
|
|
|
|
|
|
bool repeat_x; /* whether content is tiled in x direction */
|
|
|
|
bool repeat_y; /* whether content is tiled in y direction */
|
|
|
|
};
|
|
|
|
|
2010-03-28 16:56:39 +04:00
|
|
|
/* The following are for hlcache */
|
|
|
|
void content_destroy(struct content *c);
|
|
|
|
|
|
|
|
bool content_add_user(struct content *h,
|
|
|
|
void (*callback)(struct content *c, content_msg msg,
|
|
|
|
union content_msg_data data, void *pw),
|
|
|
|
void *pw);
|
|
|
|
void content_remove_user(struct content *c,
|
|
|
|
void (*callback)(struct content *c, content_msg msg,
|
|
|
|
union content_msg_data data, void *pw),
|
|
|
|
void *pw);
|
2003-02-09 15:58:15 +03:00
|
|
|
|
2010-04-04 16:41:19 +04:00
|
|
|
uint32_t content_count_users(struct content *c);
|
2010-04-11 20:34:23 +04:00
|
|
|
bool content_matches_quirks(struct content *c, bool quirks);
|
2010-04-11 20:37:39 +04:00
|
|
|
bool content_is_shareable(struct content *c);
|
2011-03-04 00:13:58 +03:00
|
|
|
content_status content__get_status(struct content *c);
|
2010-04-04 16:41:19 +04:00
|
|
|
|
2010-03-28 16:56:39 +04:00
|
|
|
const struct llcache_handle *content_get_llcache_handle(struct content *c);
|
2011-12-04 18:55:23 +04:00
|
|
|
nsurl *content_get_url(struct content *c);
|
2004-06-11 00:41:26 +04:00
|
|
|
|
2010-04-04 16:41:19 +04:00
|
|
|
struct content *content_clone(struct content *c);
|
|
|
|
|
|
|
|
nserror content_abort(struct content *c);
|
2003-02-09 15:58:15 +03:00
|
|
|
|
2010-03-28 16:56:39 +04:00
|
|
|
/* Client functions */
|
|
|
|
bool content_can_reformat(struct hlcache_handle *h);
|
2011-06-24 13:30:33 +04:00
|
|
|
void content_reformat(struct hlcache_handle *h, bool background,
|
|
|
|
int width, int height);
|
2010-03-28 16:56:39 +04:00
|
|
|
void content_request_redraw(struct hlcache_handle *h,
|
|
|
|
int x, int y, int width, int height);
|
2010-06-04 13:35:08 +04:00
|
|
|
void content_mouse_track(struct hlcache_handle *h, struct browser_window *bw,
|
|
|
|
browser_mouse_state mouse, int x, int y);
|
|
|
|
void content_mouse_action(struct hlcache_handle *h, struct browser_window *bw,
|
|
|
|
browser_mouse_state mouse, int x, int y);
|
2011-06-29 00:17:39 +04:00
|
|
|
bool content_redraw(struct hlcache_handle *h, struct content_redraw_data *data,
|
2011-06-30 19:48:07 +04:00
|
|
|
const struct rect *clip, const struct redraw_context *ctx);
|
2010-03-28 16:56:39 +04:00
|
|
|
void content_open(struct hlcache_handle *h, struct browser_window *bw,
|
2011-03-11 02:13:03 +03:00
|
|
|
struct content *page, struct box *box,
|
2004-08-12 02:08:26 +04:00
|
|
|
struct object_params *params);
|
2010-03-28 16:56:39 +04:00
|
|
|
void content_close(struct hlcache_handle *h);
|
2011-07-13 17:20:26 +04:00
|
|
|
struct selection *content_get_selection(struct hlcache_handle *h);
|
2011-09-06 22:07:30 +04:00
|
|
|
void content_get_contextual_content(struct hlcache_handle *h,
|
|
|
|
int x, int y, struct contextual_content *data);
|
2011-11-29 21:47:29 +04:00
|
|
|
bool content_scroll_at_point(struct hlcache_handle *h,
|
|
|
|
int x, int y, int scrx, int scry);
|
2011-12-02 01:49:57 +04:00
|
|
|
bool content_drop_file_at_point(struct hlcache_handle *h,
|
|
|
|
int x, int y, char *file);
|
2011-10-07 22:12:47 +04:00
|
|
|
struct content_rfc5988_link *content_find_rfc5988_link(struct hlcache_handle *c,
|
|
|
|
lwc_string *rel);
|
2010-03-28 16:56:39 +04:00
|
|
|
|
|
|
|
/* Member accessors */
|
|
|
|
content_type content_get_type(struct hlcache_handle *c);
|
2011-05-07 00:40:09 +04:00
|
|
|
lwc_string *content_get_mime_type(struct hlcache_handle *c);
|
2010-03-28 16:56:39 +04:00
|
|
|
const char *content_get_title(struct hlcache_handle *c);
|
|
|
|
content_status content_get_status(struct hlcache_handle *c);
|
|
|
|
const char *content_get_status_message(struct hlcache_handle *c);
|
|
|
|
int content_get_width(struct hlcache_handle *c);
|
|
|
|
int content_get_height(struct hlcache_handle *c);
|
|
|
|
int content_get_available_width(struct hlcache_handle *c);
|
|
|
|
const char *content_get_source_data(struct hlcache_handle *c,
|
|
|
|
unsigned long *size);
|
|
|
|
void content_invalidate_reuse_data(struct hlcache_handle *c);
|
2011-10-03 19:56:47 +04:00
|
|
|
nsurl *content_get_refresh_url(struct hlcache_handle *c);
|
2010-03-28 16:56:39 +04:00
|
|
|
struct bitmap *content_get_bitmap(struct hlcache_handle *c);
|
2011-08-31 16:12:41 +04:00
|
|
|
bool content_get_opaque(struct hlcache_handle *h);
|
2010-04-17 00:54:57 +04:00
|
|
|
bool content_get_quirks(struct hlcache_handle *c);
|
2010-03-28 16:56:39 +04:00
|
|
|
|
2010-04-07 22:50:18 +04:00
|
|
|
bool content_is_locked(struct hlcache_handle *h);
|
|
|
|
|
2003-02-09 15:58:15 +03:00
|
|
|
#endif
|