NetSurf
Data Structures | Enumerations | Functions | Variables
page-info.c File Reference

Pave info viewer window implementation. More...

#include <stdlib.h>
#include <string.h>
#include "css/utils.h"
#include "utils/nsurl.h"
#include "utils/nscolour.h"
#include "netsurf/mouse.h"
#include "netsurf/layout.h"
#include "netsurf/keypress.h"
#include "netsurf/plotters.h"
#include "netsurf/core_window.h"
#include "netsurf/browser_window.h"
#include "desktop/knockout.h"
#include "desktop/page-info.h"
#include "desktop/gui_internal.h"
#include "desktop/system_colour.h"
Include dependency graph for page-info.c:

Go to the source code of this file.

Data Structures

struct  page_info_text
 An "text" type page info entry. More...
 
struct  page_info_item
 An "item" type page info entry. More...
 
struct  page_info_entry
 An entry on a page info window. More...
 
struct  page_info
 The page info window structure. More...
 

Enumerations

enum  pi_entry {
  PI_ENTRY_HEADER , PI_ENTRY_DOMAIN , PI_ENTRY_CERT , PI_ENTRY_COOKIES ,
  PI_ENTRY__COUNT
}
 List of page info window entries. More...
 

Functions

nserror page_info_init (void)
 Initialise the page_info module. More...
 
nserror page_info_fini (void)
 Finalise the page_info module. More...
 
static nserror page_info__measure_text_entry (struct page_info_text *pit)
 Measure the text in the page_info window. More...
 
static nserror page_info__measure_text (struct page_info *pi)
 Measure the text in the page_info window. More...
 
static nserror page_info__set_text (struct page_info *pi)
 Set the text for the page_info window. More...
 
static nserror page_info__create_from_bw (struct page_info *pi, struct browser_window *bw)
 Create page info from a browser window. More...
 
static bool page_info__hide_entry (enum pi_entry entry, enum nsurl_scheme_type scheme)
 Check whether an entry is relevant. More...
 
static nserror page_info__layout (struct page_info *pi)
 Lay out the page info window. More...
 
nserror page_info_create (const struct core_window_callback_table *cw_t, struct core_window *cw_h, struct browser_window *bw, struct page_info **pi_out)
 Create a page info corewindow. More...
 
nserror page_info_destroy (struct page_info *pi)
 Destroy a page info corewindow. More...
 
nserror page_info_set (struct page_info *pgi, struct browser_window *bw)
 change the browser window the page information refers to More...
 
static nserror page_info__redraw_text_entry (const struct page_info_text *pit, int x, int y, const struct redraw_context *ctx)
 Render a text entry. More...
 
nserror page_info_redraw (const struct page_info *pi, int x, int y, const struct rect *clip, const struct redraw_context *ctx)
 Redraw the page info window. More...
 
static nserror page_info__handle_item_click (struct page_info *pi, enum browser_mouse_state mouse, enum pi_entry clicked, bool *did_something)
 Handle any clicks on an item. More...
 
nserror page_info_mouse_action (struct page_info *pi, enum browser_mouse_state mouse, int x, int y, bool *did_something)
 Mouse action handling. More...
 
bool page_info_keypress (struct page_info *pi, int32_t key)
 Key press handling. More...
 
nserror page_info_get_size (struct page_info *pi, int *width, int *height)
 Get size of page info content area. More...
 

Variables

static plot_font_style_t pi__heading [PAGE_STATE__COUNT]
 Plot style for heading font. More...
 
static plot_font_style_t pi__domain
 Plot style for domain font. More...
 
static plot_font_style_t pi__item
 Plot style for item font. More...
 
static plot_font_style_t pi__item_detail
 Plot style for item detail font. More...
 
static plot_style_t pi__bg
 Plot style for window background. More...
 
static plot_style_t pi__hover
 Plot style for hover background. More...
 
struct page_info_entry pi__entries [PI_ENTRY__COUNT]
 The default page info window data. More...
 

Detailed Description

Pave info viewer window implementation.

Definition in file page-info.c.

Enumeration Type Documentation

◆ pi_entry

enum pi_entry

List of page info window entries.

Enumerator
PI_ENTRY_HEADER 
PI_ENTRY_DOMAIN 
PI_ENTRY_CERT 
PI_ENTRY_COOKIES 
PI_ENTRY__COUNT 

Definition at line 162 of file page-info.c.

Function Documentation

◆ page_info__create_from_bw()

static nserror page_info__create_from_bw ( struct page_info pi,
struct browser_window bw 
)
static

Create page info from a browser window.

Parameters
[in]piThe page info window handle.
[in]bwBrowser window to show page info for.
Returns
NSERROR_OK on success, appropriate error code otherwise.

Definition at line 441 of file page-info.c.

References browser_window_access_url(), browser_window_get_cookie_count(), browser_window_get_page_info_state(), page_info::bw, page_info::cookies, page_info::domain, nsurl_get_component(), nsurl_get_scheme_type(), NSURL_HOST, page_info__set_text(), page_info::scheme, and page_info::state.

Referenced by page_info_create(), and page_info_set().

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

◆ page_info__handle_item_click()

static nserror page_info__handle_item_click ( struct page_info pi,
enum browser_mouse_state  mouse,
enum pi_entry  clicked,
bool *  did_something 
)
static

Handle any clicks on an item.

Parameters
[in]piThe page info window handle.
[in]mouseThe current mouse state.
[in]clickedThe page info window entry to consider clicks on.
[out]did_somethingSet to true if this click did something
Returns
NSERROR_OK on success, appropriate error code otherwise.

Definition at line 727 of file page-info.c.

References BROWSER_MOUSE_CLICK_1, browser_window_show_certificates(), browser_window_show_cookies(), page_info::bw, NSERROR_OK, PI_ENTRY_CERT, and PI_ENTRY_COOKIES.

Referenced by page_info_mouse_action().

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

◆ page_info__hide_entry()

static bool page_info__hide_entry ( enum pi_entry  entry,
enum nsurl_scheme_type  scheme 
)
inlinestatic

Check whether an entry is relevant.

Parameters
[in]entryThe page info entry to consider.
[in]schemeURL scheme that the page info is for.
Returns
true if the entry should be hidden, otherwise false.

Definition at line 463 of file page-info.c.

References NSURL_SCHEME_HTTP, NSURL_SCHEME_HTTPS, PI_ENTRY_CERT, and PI_ENTRY_COOKIES.

Referenced by page_info__layout(), page_info_mouse_action(), and page_info_redraw().

Here is the caller graph for this function:

◆ page_info__layout()

static nserror page_info__layout ( struct page_info pi)
static

Lay out the page info window.

Parameters
[in]piThe page info window handle.
Returns
NSERROR_OK on success, appropriate error code otherwise.

Definition at line 492 of file page-info.c.

References page_info::cw_h, page_info::cw_t, page_info_item::detail, page_info::entries, page_info_text::height, page_info::height, page_info_item::item, page_info_entry::item, page_info_text::padding_bottom, page_info_item::padding_bottom, page_info_item::padding_top, page_info__hide_entry(), page_info_entry::PAGE_INFO_ENTRY_TYPE_ITEM, page_info_entry::PAGE_INFO_ENTRY_TYPE_TEXT, PI_ENTRY__COUNT, page_info::scheme, page_info_entry::text, page_info_entry::type, page_info_entry::u, core_window_callback_table::update_size, page_info_text::width, page_info::width, and page_info::window_padding.

Referenced by page_info_create(), and page_info_set().

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

◆ page_info__measure_text()

static nserror page_info__measure_text ( struct page_info pi)
static

Measure the text in the page_info window.

Parameters
[in]piThe page info window handle.
Returns
NSERROR_OK on success, appropriate error code otherwise.

Definition at line 331 of file page-info.c.

References page_info_item::detail, page_info::entries, page_info_text::height, page_info_item::item, page_info_entry::item, NSERROR_OK, page_info_text::padding_bottom, page_info_item::padding_bottom, page_info_item::padding_top, page_info__measure_text_entry(), page_info_entry::PAGE_INFO_ENTRY_TYPE_ITEM, page_info_entry::PAGE_INFO_ENTRY_TYPE_TEXT, PI_ENTRY__COUNT, PI_ENTRY_DOMAIN, page_info_entry::text, page_info_entry::type, page_info_entry::u, and page_info::window_padding.

Referenced by page_info__set_text().

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

◆ page_info__measure_text_entry()

static nserror page_info__measure_text_entry ( struct page_info_text pit)
static

Measure the text in the page_info window.

Parameters
[in]piThe page info window handle.
Returns
NSERROR_OK on success, appropriate error code otherwise.

Definition at line 303 of file page-info.c.

References guit, page_info_text::height, netsurf_table::layout, nscss_screen_dpi, NSERROR_OK, PLOT_STYLE_SCALE, plot_font_style::size, page_info_text::style, page_info_text::text, page_info_text::width, and gui_layout_table::width.

Referenced by page_info__measure_text().

Here is the caller graph for this function:

◆ page_info__redraw_text_entry()

static nserror page_info__redraw_text_entry ( const struct page_info_text pit,
int  x,
int  y,
const struct redraw_context ctx 
)
static

Render a text entry.

Parameters
[in]pitThe page info window handle.
[in]xX-coordinate to plot at.
[in]yY-coordinate to plot at.
[in]ctxCurrent redraw context.
Returns
NSERROR_OK on success, appropriate error code otherwise.

Definition at line 609 of file page-info.c.

References page_info_text::height, NSERROR_OK, redraw_context::plot, page_info_text::style, page_info_text::text, and plotter_table::text.

Referenced by page_info_redraw().

Here is the caller graph for this function:

◆ page_info__set_text()

static nserror page_info__set_text ( struct page_info pi)
static

Set the text for the page_info window.

Todo:
Use messages for internationalisation.
Parameters
[in]piThe page info window handle.
Returns
NSERROR_OK on success, appropriate error code otherwise.

Definition at line 386 of file page-info.c.

References page_info::cookie_text, page_info::cookies, page_info_item::detail, page_info::domain, page_info::entries, page_info_item::item, page_info_entry::item, NSERROR_NOSPACE, NSERROR_UNKNOWN, page_info__measure_text(), PAGE_STATE__COUNT, PAGE_STATE_INSECURE, PAGE_STATE_INTERNAL, PAGE_STATE_LOCAL, PAGE_STATE_SECURE, PAGE_STATE_SECURE_ISSUES, PAGE_STATE_SECURE_OVERRIDE, PAGE_STATE_UNKNOWN, pi__heading, PI_ENTRY_CERT, PI_ENTRY_COOKIES, PI_ENTRY_DOMAIN, PI_ENTRY_HEADER, page_info::state, page_info_text::style, page_info_text::text, page_info_entry::text, and page_info_entry::u.

Referenced by page_info__create_from_bw().

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

◆ page_info_create()

nserror page_info_create ( const struct core_window_callback_table cw_t,
struct core_window *  cw_h,
struct browser_window bw,
struct page_info **  pi_out 
)

Create a page info corewindow.

The page info window is opened for a particular browser window. It can be destroyed before the browser window is destroyed by calling page_info_destroy.

Parameters
[in]cw_tCallback table for the containing core_window.
[in]cw_hHandle for the containing core_window.
[in]bwBrowser window to show page info for.
[out]pi_outThe created page info window handle.
Returns
NSERROR_OK on success, appropriate error code otherwise.

Definition at line 538 of file page-info.c.

References page_info::bw, page_info::cw_h, page_info::cw_t, cw_t, page_info::entries, NSERROR_NOMEM, NSERROR_OK, page_info__create_from_bw(), page_info__layout(), page_info_destroy(), and pi__entries.

Referenced by ami_pageinfo_open(), nsgtk_page_info(), and ro_pageinfo_init().

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

◆ page_info_destroy()

nserror page_info_destroy ( struct page_info pi)

Destroy a page info corewindow.

Parameters
[in]piThe page info window handle.

Definition at line 574 of file page-info.c.

References page_info::domain, and NSERROR_OK.

Referenced by ami_pageinfo_destroy(), nsgtk_pi_delete_event(), page_info_create(), and ro_gui_pageinfo_finalise().

Here is the caller graph for this function:

◆ page_info_fini()

nserror page_info_fini ( void  )

Finalise the page_info module.

Returns
NSERROR_OK on success, appropriate error code otherwise.

Definition at line 292 of file page-info.c.

References NSERROR_OK.

Referenced by netsurf_exit().

Here is the caller graph for this function:

◆ page_info_get_size()

nserror page_info_get_size ( struct page_info pi,
int *  width,
int *  height 
)

Get size of page info content area.

Parameters
[in]piThe page info window handle.
[out]widthOn success, return the page info content width.
[out]heightOn success, return the page info content height.
Returns
NSERROR_OK on success, appropriate error code otherwise.

Definition at line 827 of file page-info.c.

References page_info::height, height, NSERROR_OK, page_info::width, and width.

Referenced by ami_pageinfo_open(), and ro_pageinfo_open().

Here is the caller graph for this function:

◆ page_info_init()

nserror page_info_init ( void  )

Initialise the page_info module.

Returns
NSERROR_OK on success, appropriate error code otherwise.

Definition at line 259 of file page-info.c.

References plot_font_style::background, plot_style_s::fill_colour, plot_font_style::foreground, NSCOLOUR_WIN_EVEN_BG, NSCOLOUR_WIN_EVEN_BG_HOVER, NSCOLOUR_WIN_EVEN_FG, NSCOLOUR_WIN_EVEN_FG_BAD, NSCOLOUR_WIN_EVEN_FG_FADED, NSCOLOUR_WIN_EVEN_FG_GOOD, nscolours, NSERROR_OK, PAGE_STATE_INSECURE, PAGE_STATE_INTERNAL, PAGE_STATE_LOCAL, PAGE_STATE_SECURE, PAGE_STATE_SECURE_ISSUES, PAGE_STATE_SECURE_OVERRIDE, PAGE_STATE_UNKNOWN, pi__bg, pi__domain, pi__heading, pi__hover, pi__item, and pi__item_detail.

Referenced by netsurf_init().

Here is the caller graph for this function:

◆ page_info_keypress()

bool page_info_keypress ( struct page_info pi,
int32_t  key 
)

Key press handling.

Parameters
[in]piThe page info window handle.
[in]keyThe ucs4 character codepoint.
Returns
true if the keypress is dealt with, false otherwise.

Definition at line 819 of file page-info.c.

References NSERROR_OK.

Referenced by ami_pageinfo_key(), nsgtk_pi_key(), and ro_pageinfo_key().

Here is the caller graph for this function:

◆ page_info_mouse_action()

nserror page_info_mouse_action ( struct page_info pi,
enum browser_mouse_state  mouse,
int  x,
int  y,
bool *  did_something 
)

Mouse action handling.

Parameters
[in]piThe page info window handle.
[in]mouseThe current mouse state
[in]xThe current mouse X coordinate
[in]yThe current mouse Y coordinate
[out]did_somethingSet to true if this resulted in some action
Returns
NSERROR_OK on success, appropriate error code otherwise.

Definition at line 757 of file page-info.c.

References page_info::cw_h, page_info::cw_t, page_info::entries, core_window_callback_table::get_window_dimensions, page_info_text::height, height, page_info_item::hover, core_window_callback_table::invalidate, page_info_item::item, page_info_entry::item, NSERROR_OK, page_info_text::padding_bottom, page_info_item::padding_bottom, page_info_item::padding_top, page_info__handle_item_click(), page_info__hide_entry(), page_info_entry::PAGE_INFO_ENTRY_TYPE_ITEM, page_info_entry::PAGE_INFO_ENTRY_TYPE_TEXT, PI_ENTRY__COUNT, page_info::scheme, page_info_entry::text, page_info_entry::type, page_info_entry::u, page_info::width, page_info::window_padding, rect::x0, and rect::x1.

Referenced by ami_pageinfo_mouse(), nsgtk_pi_mouse(), and ro_pageinfo_mouse().

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

◆ page_info_redraw()

nserror page_info_redraw ( const struct page_info pi,
int  x,
int  y,
const struct rect clip,
const struct redraw_context ctx 
)

Redraw the page info window.

Causes the page info window to issue plot operations to redraw the specified area of the viewport.

Parameters
[in]piThe page info window handle.
[in]xX coordinate to render page_info at.
[in]yY coordinate to render page_info at.
[in]clipCurrent clip rectangle.
[in]ctxCurrent redraw context.
Returns
NSERROR_OK on success, appropriate error code otherwise.

Definition at line 624 of file page-info.c.

References clip(), plotter_table::clip, page_info_item::detail, page_info::entries, page_info_text::height, page_info_item::hover, page_info_item::item, page_info_entry::item, knockout_plot_end(), knockout_plot_start(), NSERROR_OK, NSERROR_UNKNOWN, plotter_table::option_knockout, page_info_text::padding_bottom, page_info_item::padding_bottom, page_info_item::padding_top, page_info__hide_entry(), page_info__redraw_text_entry(), page_info_entry::PAGE_INFO_ENTRY_TYPE_ITEM, page_info_entry::PAGE_INFO_ENTRY_TYPE_TEXT, pi__bg, pi__hover, PI_ENTRY__COUNT, redraw_context::plot, plotter_table::rectangle, page_info::scheme, page_info_entry::text, page_info_entry::type, page_info_entry::u, page_info_text::width, page_info::window_padding, rect::x0, rect::y0, and rect::y1.

Referenced by ami_pageinfo_draw(), nsgtk_pi_draw(), and ro_pageinfo_draw().

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

◆ page_info_set()

nserror page_info_set ( struct page_info pgi,
struct browser_window bw 
)

change the browser window the page information refers to

Parameters
[in]pgiThe page info window context
[in]bwThe new browser window
Returns
NSERROR_OK on sucess else error code.

Definition at line 584 of file page-info.c.

References page_info::bw, page_info::domain, NSERROR_OK, page_info__create_from_bw(), and page_info__layout().

Referenced by ro_pageinfo_init().

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

Variable Documentation

◆ pi__bg

plot_style_t pi__bg
static
Initial value:
= {
.fill_type = PLOT_OP_TYPE_SOLID,
}
@ PLOT_OP_TYPE_SOLID
Solid colour.
Definition: plot_style.h:67

Plot style for window background.

Definition at line 125 of file page-info.c.

Referenced by page_info_init(), and page_info_redraw().

◆ pi__domain

plot_font_style_t pi__domain
static
Initial value:
= {
.size = 8 * PLOT_STYLE_SCALE,
.flags = FONTF_NONE,
.weight = 700,
}
@ FONTF_NONE
Definition: plot_style.h:102
@ PLOT_FONT_FAMILY_SANS_SERIF
Definition: plot_style.h:89
#define PLOT_STYLE_SCALE
Scaling factor for plot styles.
Definition: plot_style.h:45

Plot style for domain font.

Definition at line 95 of file page-info.c.

Referenced by page_info_init().

◆ pi__entries

struct page_info_entry pi__entries[PI_ENTRY__COUNT]

The default page info window data.

Definition at line 193 of file page-info.c.

Referenced by page_info_create().

◆ pi__heading

plot_font_style_t pi__heading[PAGE_STATE__COUNT]
static

Plot style for heading font.

Definition at line 47 of file page-info.c.

Referenced by page_info__set_text(), and page_info_init().

◆ pi__hover

plot_style_t pi__hover
static
Initial value:
= {
.fill_type = PLOT_OP_TYPE_SOLID,
}

Plot style for hover background.

Definition at line 132 of file page-info.c.

Referenced by page_info_init(), and page_info_redraw().

◆ pi__item

plot_font_style_t pi__item
static
Initial value:
= {
.size = 11 * PLOT_STYLE_SCALE,
.flags = FONTF_NONE,
.weight = 400,
}

Plot style for item font.

Definition at line 105 of file page-info.c.

Referenced by page_info_init().

◆ pi__item_detail

plot_font_style_t pi__item_detail
static
Initial value:
= {
.size = 11 * PLOT_STYLE_SCALE,
.flags = FONTF_NONE,
.weight = 400,
}

Plot style for item detail font.

Definition at line 115 of file page-info.c.

Referenced by page_info_init().