NetSurf
Functions | Variables
browser.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "utils/utils.h"
#include "utils/ring.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/nsurl.h"
#include "netsurf/mouse.h"
#include "netsurf/window.h"
#include "netsurf/browser_window.h"
#include "netsurf/plotters.h"
#include "monkey/output.h"
#include "monkey/browser.h"
#include "monkey/plot.h"
Include dependency graph for browser.c:

Go to the source code of this file.

Functions

nserror monkey_warn_user (const char *warning, const char *detail)
 
struct gui_windowmonkey_find_window_by_num (uint32_t win_num)
 
void monkey_kill_browser_windows (void)
 
static struct gui_windowgui_window_create (struct browser_window *bw, struct gui_window *existing, gui_window_create_flags flags)
 
static void gui_window_destroy (struct gui_window *g)
 
static void gui_window_set_title (struct gui_window *g, const char *title)
 
static nserror gui_window_get_dimensions (struct gui_window *g, int *width, int *height)
 Find the current dimensions of a monkey browser window content area. More...
 
static void gui_window_new_content (struct gui_window *g)
 
static void gui_window_set_icon (struct gui_window *g, struct hlcache_handle *icon)
 
static void gui_window_start_throbber (struct gui_window *g)
 
static void gui_window_stop_throbber (struct gui_window *g)
 
static nserror gui_window_set_scroll (struct gui_window *gw, const struct rect *rect)
 Set the scroll position of a monkey browser window. More...
 
static nserror monkey_window_invalidate_area (struct gui_window *gw, const struct rect *rect)
 Invalidates an area of a monkey browser window. More...
 
static void gui_window_update_extent (struct gui_window *g)
 
static void gui_window_set_status (struct gui_window *g, const char *text)
 
static void gui_window_set_pointer (struct gui_window *g, gui_pointer_shape shape)
 
static nserror gui_window_set_url (struct gui_window *g, nsurl *url)
 
static bool gui_window_get_scroll (struct gui_window *g, int *sx, int *sy)
 
static bool gui_window_scroll_start (struct gui_window *g)
 
static void gui_window_place_caret (struct gui_window *g, int x, int y, int height, const struct rect *clip)
 
static void gui_window_remove_caret (struct gui_window *g)
 
static bool gui_window_drag_start (struct gui_window *g, gui_drag_type type, const struct rect *rect)
 
static nserror gui_window_save_link (struct gui_window *g, nsurl *url, const char *title)
 
static void gui_window_console_log (struct gui_window *g, browser_window_console_source src, const char *msg, size_t msglen, browser_window_console_flags flags)
 
static void gui_window_report_page_info (struct gui_window *g)
 
static void monkey_window_handle_new (int argc, char **argv)
 
static void monkey_window_handle_destroy (int argc, char **argv)
 
static void monkey_window_handle_go (int argc, char **argv)
 
static void monkey_window_handle_stop (int argc, char **argv)
 handle WINDOW STOP command More...
 
static void monkey_window_handle_redraw (int argc, char **argv)
 
static void monkey_window_handle_reload (int argc, char **argv)
 
static void monkey_window_handle_exec (int argc, char **argv)
 
static void monkey_window_handle_click (int argc, char **argv)
 
void monkey_window_handle_command (int argc, char **argv)
 
static nserror gui_window_event (struct gui_window *gw, enum gui_window_event event)
 process miscellaneous window events More...
 

Variables

static uint32_t win_ctr = 0
 
static struct gui_windowgw_ring = NULL
 
static struct gui_window_table window_table
 
struct gui_window_tablemonkey_window_table = &window_table
 

Function Documentation

◆ gui_window_console_log()

static void gui_window_console_log ( struct gui_window g,
browser_window_console_source  src,
const char *  msg,
size_t  msglen,
browser_window_console_flags  flags 
)
static

Definition at line 354 of file browser.c.

References BW_CS_FLAG_FOLDABLE, BW_CS_FLAG_LEVEL_DEBUG, BW_CS_FLAG_LEVEL_ERROR, BW_CS_FLAG_LEVEL_INFO, BW_CS_FLAG_LEVEL_LOG, BW_CS_FLAG_LEVEL_MASK, BW_CS_FLAG_LEVEL_WARN, BW_CS_INPUT, BW_CS_SCRIPT_CONSOLE, BW_CS_SCRIPT_ERROR, MOUT_WINDOW, moutf(), and gui_window::win_num.

Here is the call graph for this function:

◆ gui_window_create()

static struct gui_window * gui_window_create ( struct browser_window bw,
struct gui_window existing,
gui_window_create_flags  flags 
)
static

Definition at line 74 of file browser.c.

References gui_window::bw, GW_CREATE_CLONE, GW_CREATE_TAB, gw_ring, gui_window::height, MOUT_WINDOW, moutf(), RING_INSERT, gui_window::width, win_ctr, and gui_window::win_num.

Here is the call graph for this function:

◆ gui_window_destroy()

static void gui_window_destroy ( struct gui_window g)
static

Definition at line 103 of file browser.c.

References gw_ring, MOUT_WINDOW, moutf(), RING_REMOVE, and gui_window::win_num.

Here is the call graph for this function:

◆ gui_window_drag_start()

static bool gui_window_drag_start ( struct gui_window g,
gui_drag_type  type,
const struct rect rect 
)
static

Definition at line 338 of file browser.c.

References MOUT_WINDOW, moutf(), type, and gui_window::win_num.

Here is the call graph for this function:

◆ gui_window_event()

static nserror gui_window_event ( struct gui_window gw,
enum gui_window_event  event 
)
static

process miscellaneous window events

Parameters
gwThe window receiving the event.
eventThe event code.
Returns
NSERROR_OK when processed ok

Definition at line 736 of file browser.c.

References gui_window_new_content(), gui_window_remove_caret(), gui_window_report_page_info(), gui_window_scroll_start(), gui_window_start_throbber(), gui_window_stop_throbber(), gui_window_update_extent(), GW_EVENT_NEW_CONTENT, GW_EVENT_PAGE_INFO_CHANGE, GW_EVENT_REMOVE_CARET, GW_EVENT_SCROLL_START, GW_EVENT_START_THROBBER, GW_EVENT_STOP_THROBBER, GW_EVENT_UPDATE_EXTENT, and NSERROR_OK.

Here is the call graph for this function:

◆ gui_window_get_dimensions()

static nserror gui_window_get_dimensions ( struct gui_window g,
int *  width,
int *  height 
)
static

Find the current dimensions of a monkey browser window content area.

Parameters
gThe gui window to measure content area of.
widthreceives width of window
heightreceives height of window
Returns
NSERROR_OK on sucess and width and height updated.

Definition at line 125 of file browser.c.

References gui_window::height, height, MOUT_WINDOW, moutf(), NSERROR_OK, gui_window::width, width, and gui_window::win_num.

Here is the call graph for this function:

◆ gui_window_get_scroll()

static bool gui_window_get_scroll ( struct gui_window g,
int *  sx,
int *  sy 
)
static

Definition at line 305 of file browser.c.

References MOUT_WINDOW, moutf(), gui_window::scrollx, gui_window::scrolly, and gui_window::win_num.

Here is the call graph for this function:

◆ gui_window_new_content()

static void gui_window_new_content ( struct gui_window g)
static

Definition at line 138 of file browser.c.

References MOUT_WINDOW, moutf(), and gui_window::win_num.

Referenced by gui_window_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_window_place_caret()

static void gui_window_place_caret ( struct gui_window g,
int  x,
int  y,
int  height,
const struct rect clip 
)
static

Definition at line 324 of file browser.c.

References height, MOUT_WINDOW, moutf(), and gui_window::win_num.

Here is the call graph for this function:

◆ gui_window_remove_caret()

static void gui_window_remove_caret ( struct gui_window g)
static

Definition at line 332 of file browser.c.

References MOUT_WINDOW, moutf(), and gui_window::win_num.

Referenced by gui_window_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_window_report_page_info()

static void gui_window_report_page_info ( struct gui_window g)
static

Definition at line 408 of file browser.c.

References browser_window_get_page_info_state(), gui_window::bw, MOUT_WINDOW, moutf(), PAGE_STATE_INSECURE, PAGE_STATE_INTERNAL, PAGE_STATE_LOCAL, PAGE_STATE_SECURE, PAGE_STATE_SECURE_ISSUES, PAGE_STATE_SECURE_OVERRIDE, PAGE_STATE_UNKNOWN, gui_window::state, and gui_window::win_num.

Referenced by gui_window_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_window_save_link()

static nserror gui_window_save_link ( struct gui_window g,
nsurl url,
const char *  title 
)
static

Definition at line 346 of file browser.c.

References MOUT_WINDOW, moutf(), NSERROR_OK, nsurl_access(), gui_window::title, gui_window::url, and gui_window::win_num.

Here is the call graph for this function:

◆ gui_window_scroll_start()

static bool gui_window_scroll_start ( struct gui_window g)
static

Definition at line 315 of file browser.c.

References MOUT_WINDOW, moutf(), gui_window::scrollx, gui_window::scrolly, and gui_window::win_num.

Referenced by gui_window_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_window_set_icon()

static void gui_window_set_icon ( struct gui_window g,
struct hlcache_handle icon 
)
static

Definition at line 144 of file browser.c.

References MOUT_WINDOW, moutf(), and gui_window::win_num.

Here is the call graph for this function:

◆ gui_window_set_pointer()

static void gui_window_set_pointer ( struct gui_window g,
gui_pointer_shape  shape 
)
static

◆ gui_window_set_scroll()

static nserror gui_window_set_scroll ( struct gui_window gw,
const struct rect rect 
)
static

Set the scroll position of a monkey browser window.

Scrolls the viewport to ensure the specified rectangle of the content is shown.

Parameters
gwgui window to scroll
rectThe rectangle to ensure is shown.
Returns
NSERROR_OK on success or apropriate error code.

Definition at line 173 of file browser.c.

References MOUT_WINDOW, moutf(), NSERROR_OK, gui_window::scrollx, gui_window::scrolly, gui_window::win_num, rect::x0, and rect::y0.

Here is the call graph for this function:

◆ gui_window_set_status()

static void gui_window_set_status ( struct gui_window g,
const char *  text 
)
static

Definition at line 220 of file browser.c.

References MOUT_WINDOW, moutf(), text(), and gui_window::win_num.

Here is the call graph for this function:

◆ gui_window_set_title()

static void gui_window_set_title ( struct gui_window g,
const char *  title 
)
static

Definition at line 111 of file browser.c.

References MOUT_WINDOW, moutf(), gui_window::title, and gui_window::win_num.

Here is the call graph for this function:

◆ gui_window_set_url()

static nserror gui_window_set_url ( struct gui_window g,
nsurl url 
)
static

Definition at line 297 of file browser.c.

References MOUT_WINDOW, moutf(), NSERROR_OK, nsurl_access(), gui_window::url, and gui_window::win_num.

Here is the call graph for this function:

◆ gui_window_start_throbber()

static void gui_window_start_throbber ( struct gui_window g)
static

Definition at line 150 of file browser.c.

References MOUT_WINDOW, moutf(), and gui_window::win_num.

Referenced by gui_window_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_window_stop_throbber()

static void gui_window_stop_throbber ( struct gui_window g)
static

Definition at line 156 of file browser.c.

References MOUT_WINDOW, moutf(), and gui_window::win_num.

Referenced by gui_window_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_window_update_extent()

static void gui_window_update_extent ( struct gui_window g)
static

Definition at line 208 of file browser.c.

References browser_window_get_extents(), gui_window::bw, height, MOUT_WINDOW, moutf(), NSERROR_OK, width, and gui_window::win_num.

Referenced by gui_window_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monkey_find_window_by_num()

struct gui_window * monkey_find_window_by_num ( uint32_t  win_num)

Definition at line 51 of file browser.c.

References gw_ring, RING_ITERATE_END, RING_ITERATE_START, RING_ITERATE_STOP, and gui_window::win_num.

Referenced by monkey_window_handle_click(), monkey_window_handle_destroy(), monkey_window_handle_exec(), monkey_window_handle_go(), monkey_window_handle_redraw(), monkey_window_handle_reload(), and monkey_window_handle_stop().

Here is the caller graph for this function:

◆ monkey_kill_browser_windows()

void monkey_kill_browser_windows ( void  )

Definition at line 66 of file browser.c.

References browser_window_destroy(), gui_window::bw, and gw_ring.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monkey_warn_user()

nserror monkey_warn_user ( const char *  warning,
const char *  detail 
)

Definition at line 44 of file browser.c.

References MOUT_WARNING, moutf(), and NSERROR_OK.

Referenced by monkey_window_handle_go(), and monkey_window_handle_new().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monkey_window_handle_click()

static void monkey_window_handle_click ( int  argc,
char **  argv 
)
static

Definition at line 659 of file browser.c.

References BROWSER_MOUSE_CLICK_1, BROWSER_MOUSE_CLICK_2, BROWSER_MOUSE_DOUBLE_CLICK, BROWSER_MOUSE_TRIPLE_CLICK, browser_window_mouse_click(), gui_window::bw, monkey_find_window_by_num(), gui_window::mouse, MOUT_ERROR, and moutf().

Referenced by monkey_window_handle_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monkey_window_handle_command()

void monkey_window_handle_command ( int  argc,
char **  argv 
)

Definition at line 701 of file browser.c.

References monkey_window_handle_click(), monkey_window_handle_destroy(), monkey_window_handle_exec(), monkey_window_handle_go(), monkey_window_handle_new(), monkey_window_handle_redraw(), monkey_window_handle_reload(), monkey_window_handle_stop(), MOUT_ERROR, and moutf().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monkey_window_handle_destroy()

static void monkey_window_handle_destroy ( int  argc,
char **  argv 
)
static

Definition at line 479 of file browser.c.

References browser_window_destroy(), gui_window::bw, monkey_find_window_by_num(), MOUT_ERROR, and moutf().

Referenced by monkey_window_handle_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monkey_window_handle_exec()

static void monkey_window_handle_exec ( int  argc,
char **  argv 
)
static

Definition at line 621 of file browser.c.

References browser_window_exec(), gui_window::bw, monkey_find_window_by_num(), MOUT_ERROR, MOUT_WINDOW, and moutf().

Referenced by monkey_window_handle_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monkey_window_handle_go()

static void monkey_window_handle_go ( int  argc,
char **  argv 
)
static

Definition at line 494 of file browser.c.

References browser_window_navigate(), gui_window::bw, BW_NAVIGATE_HISTORY, messages_get_errorcode(), monkey_find_window_by_num(), monkey_warn_user(), MOUT_ERROR, moutf(), NSERROR_OK, nsurl_create(), nsurl_unref(), and gui_window::url.

Referenced by monkey_window_handle_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monkey_window_handle_new()

static void monkey_window_handle_new ( int  argc,
char **  argv 
)
static

Definition at line 452 of file browser.c.

References browser_window_create(), BW_CREATE_HISTORY, messages_get_errorcode(), monkey_warn_user(), NSERROR_OK, nsurl_create(), nsurl_unref(), and gui_window::url.

Referenced by monkey_window_handle_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monkey_window_handle_redraw()

static void monkey_window_handle_redraw ( int  argc,
char **  argv 
)
static

Definition at line 562 of file browser.c.

References browser_window_redraw(), gui_window::bw, clip(), gui_window::height, redraw_context::interactive, monkey_find_window_by_num(), monkey_plotters, MOUT_ERROR, MOUT_WINDOW, moutf(), NSLOG, gui_window::scrollx, gui_window::scrolly, and gui_window::width.

Referenced by monkey_window_handle_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monkey_window_handle_reload()

static void monkey_window_handle_reload ( int  argc,
char **  argv 
)
static

Definition at line 603 of file browser.c.

References browser_window_reload(), gui_window::bw, monkey_find_window_by_num(), MOUT_ERROR, and moutf().

Referenced by monkey_window_handle_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monkey_window_handle_stop()

static void monkey_window_handle_stop ( int  argc,
char **  argv 
)
static

handle WINDOW STOP command

Definition at line 543 of file browser.c.

References browser_window_stop(), gui_window::bw, monkey_find_window_by_num(), MOUT_ERROR, and moutf().

Referenced by monkey_window_handle_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monkey_window_invalidate_area()

static nserror monkey_window_invalidate_area ( struct gui_window gw,
const struct rect rect 
)
static

Invalidates an area of a monkey browser window.

Parameters
gwgui_window
rectarea to redraw or NULL for the entire window area
Returns
NSERROR_OK on success or appropriate error code

Definition at line 192 of file browser.c.

References MOUT_WINDOW, moutf(), NSERROR_OK, gui_window::win_num, rect::x0, rect::x1, rect::y0, and rect::y1.

Here is the call graph for this function:

Variable Documentation

◆ gw_ring

struct gui_window* gw_ring = NULL
static

◆ monkey_window_table

struct gui_window_table* monkey_window_table = &window_table

Definition at line 794 of file browser.c.

Referenced by main().

◆ win_ctr

uint32_t win_ctr = 0
static

Definition at line 39 of file browser.c.

Referenced by gui_window_create().

◆ window_table

struct gui_window_table window_table
static
Initial value:
= {
.create = gui_window_create,
.destroy = gui_window_destroy,
.get_scroll = gui_window_get_scroll,
.set_scroll = gui_window_set_scroll,
.get_dimensions = gui_window_get_dimensions,
.event = gui_window_event,
.set_title = gui_window_set_title,
.set_url = gui_window_set_url,
.set_icon = gui_window_set_icon,
.set_status = gui_window_set_status,
.set_pointer = gui_window_set_pointer,
.place_caret = gui_window_place_caret,
.drag_start = gui_window_drag_start,
.save_link = gui_window_save_link,
.console_log = gui_window_console_log,
}
static nserror gui_window_save_link(struct gui_window *g, nsurl *url, const char *title)
Definition: browser.c:346
static nserror gui_window_set_scroll(struct gui_window *gw, const struct rect *rect)
Set the scroll position of a monkey browser window.
Definition: browser.c:173
static void gui_window_set_status(struct gui_window *g, const char *text)
Definition: browser.c:220
static nserror gui_window_event(struct gui_window *gw, enum gui_window_event event)
process miscellaneous window events
Definition: browser.c:736
static void gui_window_destroy(struct gui_window *g)
Definition: browser.c:103
static void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
Definition: browser.c:226
static struct gui_window * gui_window_create(struct browser_window *bw, struct gui_window *existing, gui_window_create_flags flags)
Definition: browser.c:74
static nserror monkey_window_invalidate_area(struct gui_window *gw, const struct rect *rect)
Invalidates an area of a monkey browser window.
Definition: browser.c:192
static void gui_window_set_title(struct gui_window *g, const char *title)
Definition: browser.c:111
static nserror gui_window_set_url(struct gui_window *g, nsurl *url)
Definition: browser.c:297
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height, const struct rect *clip)
Definition: browser.c:324
static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
Definition: browser.c:305
static void gui_window_set_icon(struct gui_window *g, struct hlcache_handle *icon)
Definition: browser.c:144
static nserror gui_window_get_dimensions(struct gui_window *g, int *width, int *height)
Find the current dimensions of a monkey browser window content area.
Definition: browser.c:125
static bool gui_window_drag_start(struct gui_window *g, gui_drag_type type, const struct rect *rect)
Definition: browser.c:338
static void gui_window_console_log(struct gui_window *g, browser_window_console_source src, const char *msg, size_t msglen, browser_window_console_flags flags)
Definition: browser.c:354

Definition at line 773 of file browser.c.