2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
2006-03-25 23:30:35 +03:00
|
|
|
* Copyright 2006 James Bursa <bursa@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/>.
|
2004-02-25 18:12:58 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* Browser window creation and manipulation (interface).
|
2002-09-11 18:24:02 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETSURF_DESKTOP_BROWSER_H_
|
|
|
|
#define _NETSURF_DESKTOP_BROWSER_H_
|
|
|
|
|
2008-05-16 13:37:22 +04:00
|
|
|
#include <inttypes.h>
|
2003-11-15 03:26:42 +03:00
|
|
|
#include <stdbool.h>
|
2003-02-28 14:49:13 +03:00
|
|
|
#include <time.h>
|
2009-08-14 14:37:33 +04:00
|
|
|
|
2010-06-04 13:35:08 +04:00
|
|
|
#include "desktop/gui.h"
|
|
|
|
#include "desktop/mouse.h"
|
2011-02-11 22:36:33 +03:00
|
|
|
#include "desktop/shape.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "render/html.h"
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
struct box;
|
2010-03-28 16:56:39 +04:00
|
|
|
struct hlcache_handle;
|
2005-04-15 22:00:21 +04:00
|
|
|
struct form;
|
2004-07-18 21:38:01 +04:00
|
|
|
struct form_control;
|
2004-07-17 17:00:38 +04:00
|
|
|
struct gui_window;
|
|
|
|
struct history;
|
2005-04-15 09:52:25 +04:00
|
|
|
struct selection;
|
2005-04-20 16:24:41 +04:00
|
|
|
struct browser_window;
|
2006-04-10 03:21:13 +04:00
|
|
|
struct url_data;
|
|
|
|
struct bitmap;
|
2009-08-14 14:37:33 +04:00
|
|
|
struct scroll_msg_data;
|
2010-06-04 13:35:08 +04:00
|
|
|
struct fetch_multipart_data;
|
2005-04-20 16:24:41 +04:00
|
|
|
|
2007-03-07 02:50:06 +03:00
|
|
|
typedef bool (*browser_caret_callback)(struct browser_window *bw,
|
2010-03-28 16:56:39 +04:00
|
|
|
uint32_t key, void *p);
|
2005-04-20 16:24:41 +04:00
|
|
|
typedef bool (*browser_paste_callback)(struct browser_window *bw,
|
2010-03-28 16:56:39 +04:00
|
|
|
const char *utf8, unsigned utf8_len, bool last, void *p);
|
2006-08-13 07:05:55 +04:00
|
|
|
typedef void (*browser_move_callback)(struct browser_window *bw,
|
2010-03-28 16:56:39 +04:00
|
|
|
void *p);
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
|
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
/** Browser window data. */
|
2004-10-18 01:11:29 +04:00
|
|
|
struct browser_window {
|
2004-02-25 18:12:58 +03:00
|
|
|
/** Page currently displayed, or 0. Must have status READY or DONE. */
|
2010-03-28 16:56:39 +04:00
|
|
|
struct hlcache_handle *current_content;
|
2004-02-25 18:12:58 +03:00
|
|
|
/** Page being loaded, or 0. */
|
2010-03-28 16:56:39 +04:00
|
|
|
struct hlcache_handle *loading_content;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
/** Window history structure. */
|
|
|
|
struct history *history;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2005-04-15 09:52:25 +04:00
|
|
|
/** Selection state */
|
|
|
|
struct selection *sel;
|
|
|
|
|
2004-02-25 18:12:58 +03:00
|
|
|
/** Handler for keyboard input, or 0. */
|
2005-04-20 16:24:41 +04:00
|
|
|
browser_caret_callback caret_callback;
|
|
|
|
/** Handler for pasting text, or 0. */
|
|
|
|
browser_paste_callback paste_callback;
|
2006-08-13 07:05:55 +04:00
|
|
|
/** Handler for repositioning caret, or 0. */
|
|
|
|
browser_move_callback move_callback;
|
2005-04-20 16:24:41 +04:00
|
|
|
|
|
|
|
/** User parameter for caret_callback and paste_callback */
|
2004-02-25 18:12:58 +03:00
|
|
|
void *caret_p;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-07-17 17:00:38 +04:00
|
|
|
/** Platform specific window data. */
|
|
|
|
struct gui_window *window;
|
2004-02-25 18:12:58 +03:00
|
|
|
|
|
|
|
/** Busy indicator is active. */
|
|
|
|
bool throbbing;
|
|
|
|
/** Add loading_content to the window history when it loads. */
|
2009-04-05 23:17:24 +04:00
|
|
|
bool history_add;
|
2004-08-07 02:19:13 +04:00
|
|
|
|
2004-10-18 01:11:29 +04:00
|
|
|
/** Fragment identifier for current_content. */
|
2004-08-07 02:19:13 +04:00
|
|
|
char *frag_id;
|
2004-08-26 03:56:49 +04:00
|
|
|
|
2004-10-18 01:11:29 +04:00
|
|
|
/** Current drag status. */
|
2005-04-15 09:52:25 +04:00
|
|
|
enum {
|
|
|
|
DRAGGING_NONE,
|
|
|
|
DRAGGING_SELECTION,
|
2005-07-21 03:27:28 +04:00
|
|
|
DRAGGING_PAGE_SCROLL,
|
2006-09-02 19:52:41 +04:00
|
|
|
DRAGGING_FRAME
|
2005-04-15 09:52:25 +04:00
|
|
|
} drag_type;
|
2004-10-18 01:11:29 +04:00
|
|
|
|
2004-11-20 03:02:56 +03:00
|
|
|
/** Mouse position at start of current scroll drag. */
|
2006-09-02 19:52:41 +04:00
|
|
|
int drag_start_x;
|
|
|
|
int drag_start_y;
|
2004-11-20 03:02:56 +03:00
|
|
|
/** Scroll offsets at start of current scroll draw. */
|
2006-09-02 19:52:41 +04:00
|
|
|
int drag_start_scroll_x;
|
|
|
|
int drag_start_scroll_y;
|
|
|
|
/** Frame resize directions for current frame resize drag. */
|
|
|
|
unsigned int drag_resize_left : 1;
|
|
|
|
unsigned int drag_resize_right : 1;
|
|
|
|
unsigned int drag_resize_up : 1;
|
|
|
|
unsigned int drag_resize_down : 1;
|
2010-02-11 13:58:26 +03:00
|
|
|
|
2010-11-03 19:07:30 +03:00
|
|
|
/** Scroll capturing all mouse events, updated to any active HTML
|
|
|
|
* scrollbar, or NULL when no scrollbar drags active */
|
2011-05-10 02:49:17 +04:00
|
|
|
struct scrollbar *scrollbar;
|
2004-10-02 03:19:08 +04:00
|
|
|
|
2005-01-03 05:09:20 +03:00
|
|
|
/** Current fetch is download */
|
|
|
|
bool download;
|
2006-04-10 03:21:13 +04:00
|
|
|
|
2006-03-27 04:19:19 +04:00
|
|
|
/** Refresh interval (-1 if undefined) */
|
|
|
|
int refresh_interval;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
/** Window has been resized, and content needs reformatting. */
|
|
|
|
bool reformat_pending;
|
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/** Window dimensions */
|
|
|
|
int x0;
|
|
|
|
int y0;
|
|
|
|
int x1;
|
|
|
|
int y1;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2007-08-07 07:55:18 +04:00
|
|
|
/** scale of window contents */
|
|
|
|
float scale;
|
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/** Window characteristics */
|
|
|
|
enum {
|
2007-01-27 23:58:20 +03:00
|
|
|
BROWSER_WINDOW_NORMAL,
|
|
|
|
BROWSER_WINDOW_IFRAME,
|
|
|
|
BROWSER_WINDOW_FRAME,
|
|
|
|
BROWSER_WINDOW_FRAMESET,
|
|
|
|
} browser_window_type;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/** frameset characteristics */
|
|
|
|
int rows;
|
|
|
|
int cols;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/** frame dimensions */
|
|
|
|
struct frame_dimension frame_width;
|
|
|
|
struct frame_dimension frame_height;
|
|
|
|
int margin_width;
|
|
|
|
int margin_height;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/** frame name for targetting */
|
|
|
|
char *name;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/** frame characteristics */
|
|
|
|
bool no_resize;
|
|
|
|
frame_scrolling scrolling;
|
|
|
|
bool border;
|
|
|
|
colour border_colour;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/** iframe parent box */
|
|
|
|
struct box *box;
|
|
|
|
|
|
|
|
/** [cols * rows] children */
|
|
|
|
struct browser_window *children;
|
|
|
|
struct browser_window *parent;
|
2006-11-27 18:35:18 +03:00
|
|
|
|
2006-09-02 19:52:41 +04:00
|
|
|
/** [iframe_count] iframes */
|
|
|
|
int iframe_count;
|
|
|
|
struct browser_window *iframes;
|
2009-07-14 19:53:12 +04:00
|
|
|
|
|
|
|
/** Last time a link was followed in this window */
|
|
|
|
unsigned int last_action;
|
2009-12-18 02:55:02 +03:00
|
|
|
|
|
|
|
/** search context for free text search */
|
|
|
|
struct search_context *search_context;
|
2010-02-11 13:58:26 +03:00
|
|
|
|
2009-08-14 14:37:33 +04:00
|
|
|
struct form_control *visible_select_menu;
|
2010-02-11 02:37:06 +03:00
|
|
|
|
2010-02-11 13:58:26 +03:00
|
|
|
/** cache of the currently displayed status text. */
|
|
|
|
char *status_text; /**< Current status bar text. */
|
|
|
|
int status_text_len; /**< Length of the ::status_text buffer. */
|
|
|
|
int status_match; /**< Number of times an idempotent status-set operation was performed. */
|
|
|
|
int status_miss; /**< Number of times status was really updated. */
|
2002-09-11 18:24:02 +04:00
|
|
|
};
|
|
|
|
|
2011-05-10 02:49:17 +04:00
|
|
|
struct browser_scrollbar_data {
|
2009-08-14 14:37:33 +04:00
|
|
|
struct browser_window *bw;
|
|
|
|
struct box *box;
|
|
|
|
};
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2005-04-15 09:52:25 +04:00
|
|
|
extern struct browser_window *current_redraw_browser;
|
2007-08-07 07:55:18 +04:00
|
|
|
extern bool browser_reformat_pending;
|
2005-04-15 09:52:25 +04:00
|
|
|
|
2006-07-05 05:23:25 +04:00
|
|
|
struct browser_window * browser_window_create(const char *url,
|
2010-03-28 16:56:39 +04:00
|
|
|
struct browser_window *clone, const char *referrer,
|
|
|
|
bool history_add, bool new_tab);
|
2007-08-07 11:58:04 +04:00
|
|
|
void browser_window_initialise_common(struct browser_window *bw,
|
2010-03-28 16:56:39 +04:00
|
|
|
struct browser_window *clone);
|
2004-10-01 04:06:49 +04:00
|
|
|
void browser_window_go(struct browser_window *bw, const char *url,
|
2010-03-28 16:56:39 +04:00
|
|
|
const char *referrer, bool history_add);
|
2010-06-04 13:35:08 +04:00
|
|
|
void browser_window_go_post(struct browser_window *bw,
|
|
|
|
const char *url, char *post_urlenc,
|
|
|
|
struct fetch_multipart_data *post_multipart,
|
|
|
|
bool add_to_history, const char *referer, bool download,
|
|
|
|
bool verifiable, struct hlcache_handle *parent);
|
2007-01-27 23:58:20 +03:00
|
|
|
void browser_window_go_unverifiable(struct browser_window *bw,
|
2010-03-28 16:56:39 +04:00
|
|
|
const char *url, const char *referrer, bool history_add,
|
|
|
|
struct hlcache_handle *parent);
|
2009-01-30 08:07:07 +03:00
|
|
|
void browser_window_download(struct browser_window *bw,
|
2010-03-28 16:56:39 +04:00
|
|
|
const char *url, const char *referrer);
|
2009-04-05 23:17:24 +04:00
|
|
|
void browser_window_update(struct browser_window *bw, bool scroll_to_top);
|
2004-02-25 18:12:58 +03:00
|
|
|
void browser_window_stop(struct browser_window *bw);
|
2004-06-29 23:08:19 +04:00
|
|
|
void browser_window_reload(struct browser_window *bw, bool all);
|
2004-02-25 18:12:58 +03:00
|
|
|
void browser_window_destroy(struct browser_window *bw);
|
2006-11-26 23:11:20 +03:00
|
|
|
struct browser_window * browser_window_owner(struct browser_window *bw);
|
2006-11-27 00:04:42 +03:00
|
|
|
void browser_window_reformat(struct browser_window *bw, int width, int height);
|
2006-09-08 20:57:26 +04:00
|
|
|
void browser_window_set_scale(struct browser_window *bw, float scale, bool all);
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2009-03-30 19:46:26 +04:00
|
|
|
void browser_window_refresh_url_bar(struct browser_window *bw, const char *url,
|
2010-03-28 16:56:39 +04:00
|
|
|
const char *frag);
|
2009-03-30 19:46:26 +04:00
|
|
|
|
2004-07-18 03:32:09 +04:00
|
|
|
void browser_window_mouse_click(struct browser_window *bw,
|
2010-03-28 16:56:39 +04:00
|
|
|
browser_mouse_state mouse, int x, int y);
|
2005-04-15 09:52:25 +04:00
|
|
|
void browser_window_mouse_track(struct browser_window *bw,
|
2010-03-28 16:56:39 +04:00
|
|
|
browser_mouse_state mouse, int x, int y);
|
2005-04-15 09:52:25 +04:00
|
|
|
void browser_window_mouse_drag_end(struct browser_window *bw,
|
2010-03-28 16:56:39 +04:00
|
|
|
browser_mouse_state mouse, int x, int y);
|
2010-06-04 13:35:08 +04:00
|
|
|
struct browser_window *browser_window_find_target(
|
|
|
|
struct browser_window *bw, const char *target,
|
|
|
|
browser_mouse_state mouse);
|
2005-04-15 09:52:25 +04:00
|
|
|
|
2008-05-16 13:37:22 +04:00
|
|
|
bool browser_window_key_press(struct browser_window *bw, uint32_t key);
|
2005-04-20 16:24:41 +04:00
|
|
|
bool browser_window_paste_text(struct browser_window *bw, const char *utf8,
|
2010-03-28 16:56:39 +04:00
|
|
|
unsigned utf8_len, bool last);
|
|
|
|
void browser_redraw_box(struct hlcache_handle *c, struct box *box);
|
2004-02-25 18:12:58 +03:00
|
|
|
|
2009-08-14 14:37:33 +04:00
|
|
|
void browser_scroll_callback(void *client_data,
|
2010-03-28 16:56:39 +04:00
|
|
|
struct scroll_msg_data *scroll_data);
|
2009-08-14 14:37:33 +04:00
|
|
|
void browser_select_menu_callback(void *client_data,
|
2010-03-28 16:56:39 +04:00
|
|
|
int x, int y, int width, int height);
|
2010-02-11 13:58:26 +03:00
|
|
|
|
2005-04-15 09:52:25 +04:00
|
|
|
void browser_window_redraw_rect(struct browser_window *bw, int x, int y,
|
2010-03-28 16:56:39 +04:00
|
|
|
int width, int height);
|
2005-04-15 09:52:25 +04:00
|
|
|
|
2010-06-04 13:35:08 +04:00
|
|
|
void browser_window_set_status(struct browser_window *bw, const char *text);
|
|
|
|
void browser_window_set_pointer(struct gui_window *g, gui_pointer_shape shape);
|
|
|
|
void browser_window_page_drag_start(struct browser_window *bw, int x, int y);
|
|
|
|
|
2009-03-24 01:22:30 +03:00
|
|
|
bool browser_window_back_available(struct browser_window *bw);
|
|
|
|
bool browser_window_forward_available(struct browser_window *bw);
|
|
|
|
bool browser_window_reload_available(struct browser_window *bw);
|
|
|
|
bool browser_window_stop_available(struct browser_window *bw);
|
|
|
|
|
2011-02-11 01:35:41 +03:00
|
|
|
/**
|
|
|
|
* Redraw an area of a window
|
|
|
|
*
|
|
|
|
* Calls the redraw function for the content,
|
|
|
|
*
|
2011-02-11 22:36:33 +03:00
|
|
|
* \param bw The window to redraw
|
|
|
|
* \param x coordinate for top-left of redraw
|
|
|
|
* \param y coordinate for top-left of redraw
|
|
|
|
* \param clip clip rectangle coordinates
|
2011-02-11 01:35:41 +03:00
|
|
|
* \return true if successful, false otherwise
|
|
|
|
*
|
2011-02-13 20:06:40 +03:00
|
|
|
* The clip rectangle is guaranteed to be filled to its extents, so there is
|
|
|
|
* no need to render a solid background first.
|
2011-02-11 01:35:41 +03:00
|
|
|
*
|
2011-02-13 20:06:40 +03:00
|
|
|
* x, y and clip are coordinates from the top left of the canvas area.
|
|
|
|
*
|
|
|
|
* The top left corner of the clip rectangle is (x0, y0) and
|
|
|
|
* the bottom right corner of the clip rectangle is (x1, y1).
|
|
|
|
* Units for x, y and clip are pixels.
|
2011-02-11 01:35:41 +03:00
|
|
|
*/
|
2011-02-11 22:36:33 +03:00
|
|
|
bool browser_window_redraw(struct browser_window *bw, int x, int y,
|
2011-02-14 22:17:08 +03:00
|
|
|
const struct rect *clip);
|
2011-02-11 01:35:41 +03:00
|
|
|
|
2011-02-13 19:44:32 +03:00
|
|
|
/**
|
|
|
|
* Check whether browser window is ready for redraw
|
|
|
|
*
|
|
|
|
* \param bw The window to redraw
|
|
|
|
* \return true if browser window is ready for redraw
|
|
|
|
*/
|
|
|
|
bool browser_window_redraw_ready(struct browser_window *bw);
|
|
|
|
|
2004-07-03 21:30:28 +04:00
|
|
|
/* In platform specific hotlist.c. */
|
2010-04-07 16:09:38 +04:00
|
|
|
void hotlist_visited(struct hlcache_handle *c);
|
2004-07-03 21:30:28 +04:00
|
|
|
|
2005-02-07 17:28:43 +03:00
|
|
|
/* In platform specific global_history.c. */
|
2006-04-10 03:21:13 +04:00
|
|
|
void global_history_add(const char *url);
|
2005-02-07 17:28:43 +03:00
|
|
|
void global_history_add_recent(const char *url);
|
|
|
|
char **global_history_get_recent(int *count);
|
|
|
|
|
2005-01-14 01:42:39 +03:00
|
|
|
/* In platform specific theme_install.c. */
|
|
|
|
#ifdef WITH_THEME_INSTALL
|
2010-03-28 16:56:39 +04:00
|
|
|
void theme_install_start(struct hlcache_handle *c);
|
2005-01-14 01:42:39 +03:00
|
|
|
#endif
|
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
#endif
|