NetSurf
Functions | Variables
redraw.c File Reference

Redrawing CONTENT_HTML implementation. More...

#include "utils/config.h"
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <dom/dom.h>
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
#include "utils/corestrings.h"
#include "netsurf/content.h"
#include "netsurf/browser_window.h"
#include "netsurf/plotters.h"
#include "netsurf/bitmap.h"
#include "netsurf/layout.h"
#include "content/content.h"
#include "content/content_protected.h"
#include "content/textsearch.h"
#include "css/utils.h"
#include "desktop/selection.h"
#include "desktop/print.h"
#include "desktop/scrollbar.h"
#include "desktop/textarea.h"
#include "desktop/gui_internal.h"
#include "html/box.h"
#include "html/box_inspect.h"
#include "html/box_manipulate.h"
#include "html/font.h"
#include "html/form_internal.h"
#include "html/private.h"
#include "html/layout.h"
Include dependency graph for redraw.c:

Go to the source code of this file.

Functions

static bool html_redraw_box_has_background (struct box *box)
 Determine if a box has a background that needs drawing. More...
 
static struct boxhtml_redraw_find_bg_box (struct box *box)
 Find the background box for a box. More...
 
static bool text_redraw (const char *utf8_text, size_t utf8_len, size_t offset, int space, const plot_font_style_t *fstyle, int x, int y, const struct rect *clip, int height, float scale, bool excluded, struct content *c, const struct selection *sel, const struct redraw_context *ctx)
 Redraw a short text string, complete with highlighting (for selection/search) More...
 
static bool html_redraw_checkbox (int x, int y, int width, int height, bool selected, const struct redraw_context *ctx)
 Plot a checkbox. More...
 
static bool html_redraw_radio (int x, int y, int width, int height, bool selected, const struct redraw_context *ctx)
 Plot a radio icon. More...
 
static bool html_redraw_file (int x, int y, int width, int height, struct box *box, float scale, colour background_colour, const css_unit_ctx *unit_len_ctx, const struct redraw_context *ctx)
 Plot a file upload input. More...
 
static bool html_redraw_background (int x, int y, struct box *box, float scale, const struct rect *clip, colour *background_colour, struct box *background, const css_unit_ctx *unit_len_ctx, const struct redraw_context *ctx)
 Plot background images. More...
 
static bool html_redraw_inline_background (int x, int y, struct box *box, float scale, const struct rect *clip, struct rect b, bool first, bool last, colour *background_colour, const css_unit_ctx *unit_len_ctx, const struct redraw_context *ctx)
 Plot an inline's background and/or background image. More...
 
static bool html_redraw_text_decoration_inline (struct box *box, int x, int y, float scale, colour colour, float ratio, const struct redraw_context *ctx)
 Plot text decoration for an inline box. More...
 
static bool html_redraw_text_decoration_block (struct box *box, int x, int y, float scale, colour colour, float ratio, const struct redraw_context *ctx)
 Plot text decoration for an non-inline box. More...
 
static bool html_redraw_text_decoration (struct box *box, int x_parent, int y_parent, float scale, colour background_colour, const struct redraw_context *ctx)
 Plot text decoration for a box. More...
 
static bool html_redraw_text_box (const html_content *html, struct box *box, int x, int y, const struct rect *clip, float scale, colour current_background_color, const struct redraw_context *ctx)
 Redraw the text content of a box, possibly partially highlighted because the text has been selected, or matches a search operation. More...
 
bool html_redraw_box (const html_content *html, struct box *box, int x_parent, int y_parent, const struct rect *clip, const float scale, colour current_background_color, const struct redraw_context *ctx)
 Recursively draw a box. More...
 
static bool html_redraw_box_children (const html_content *html, struct box *box, int x_parent, int y_parent, const struct rect *clip, float scale, colour current_background_color, const struct redraw_context *ctx)
 Draw the various children of a box. More...
 
bool html_redraw (struct content *c, struct content_redraw_data *data, const struct rect *clip, const struct redraw_context *ctx)
 Draw a CONTENT_HTML using the current set of plotters (plot). More...
 

Variables

bool html_redraw_debug = false
 Render padding and margin box outlines in html_redraw(). More...
 

Detailed Description

Redrawing CONTENT_HTML implementation.

Definition in file redraw.c.

Function Documentation

◆ html_redraw()

bool html_redraw ( struct content c,
struct content_redraw_data data,
const struct rect clip,
const struct redraw_context ctx 
)

Draw a CONTENT_HTML using the current set of plotters (plot).

Parameters
ccontent of type CONTENT_HTML
dataredraw data for this content redraw
clipcurrent clip region
ctxcurrent redraw context
Returns
true if successful, false otherwise

x, y, clip_[xy][01] are in target coordinates.

Definition at line 1944 of file redraw.c.

References html_content::background_colour, content_redraw_data::background_colour, box::border, BOTTOM, form_control::box, box_coords(), clip(), plotter_table::clip, form_control::data, plot_style_s::fill_colour, plot_style_s::fill_type, form_clip_inside_select_menu(), form_redraw_select_menu(), box::height, form_control::html, html_redraw_box(), redraw_context::interactive, html_content::layout, LEFT, NS_TRANSPARENT, NSERROR_OK, box::padding, redraw_context::plot, PLOT_OP_TYPE_SOLID, plotter_table::rectangle, result, form_control::select, TOP, html_content::visible_select_menu, and box_border::width.

Here is the call graph for this function:

◆ html_redraw_background()

static bool html_redraw_background ( int  x,
int  y,
struct box box,
float  scale,
const struct rect clip,
colour background_colour,
struct box background,
const css_unit_ctx *  unit_len_ctx,
const struct redraw_context ctx 
)
static

Plot background images.

The reason for the presence of background is the backwards compatibility mess that is backgrounds on <body>. The background will be drawn relative to box, using the background information contained within background.

Parameters
xcoordinate of box
ycoordinate of box
boxbox to draw background image of
scalescale for redraw
clipcurrent clip rectangle
background_colourcurrent background colour
backgroundbox containing background details (usually box)
unit_len_ctxLength conversion context
ctxcurrent redraw context
Returns
true if successful, false otherwise

Definition at line 595 of file redraw.c.

References box::background, content_redraw_data::background_colour, redraw_context::background_images, BOTTOM, BOX_TABLE, BOX_TABLE_CELL, BOX_TABLE_ROW, box::children, clip(), plotter_table::clip, content_get_height(), content_get_opaque(), content_get_width(), content_redraw(), plot_style_s::fill_colour, plot_style_s::fill_type, box::height, height, content_redraw_data::height, LEFT, box::margin, box::next, nscss_color_is_transparent, nscss_color_to_ns, NSERROR_OK, box::padding, box::parent, parent, redraw_context::plot, PLOT_OP_TYPE_SOLID, plotter_table::rectangle, content_redraw_data::repeat_x, content_redraw_data::repeat_y, RIGHT, content_redraw_data::scale, box::style, TOP, box::type, box::width, width, content_redraw_data::width, box::x, content_redraw_data::x, rect::x0, rect::x1, box::y, content_redraw_data::y, rect::y0, and rect::y1.

Referenced by html_redraw_box().

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

◆ html_redraw_box()

bool html_redraw_box ( const html_content html,
struct box box,
int  x_parent,
int  y_parent,
const struct rect clip,
const float  scale,
colour  current_background_color,
const struct redraw_context ctx 
)

Recursively draw a box.

Parameters
htmlhtml content
boxbox to draw
x_parentcoordinate of parent box
y_parentcoordinate of parent box
clipclip rectangle
scalescale for redraw
current_background_colorbackground colour under this box
ctxcurrent redraw context
Returns
true if successful, false otherwise

x, y, clip_[xy][01] are in target coordinates.

Definition at line 1231 of file redraw.c.

References content_redraw_data::background_colour, plotter_table::bitmap, BITMAPF_NONE, box::border, BOTTOM, BOX_BLOCK, BOX_BR, BOX_FLOAT_LEFT, BOX_FLOAT_RIGHT, box_handle_scrollbars(), box_hscrollbar_present(), BOX_INLINE, BOX_INLINE_BLOCK, BOX_INLINE_END, BOX_TABLE, BOX_TABLE_CELL, BOX_TEXT, box_vscrollbar_present(), browser_window_redraw(), clip(), plotter_table::clip, content_get_type(), CONTENT_HTML, content_redraw(), form_control::data, box::descendant_x0, box::descendant_x1, box::descendant_y0, box::descendant_y1, box::flags, box::gadget, GADGET_CHECKBOX, GADGET_FILE, GADGET_PASSWORD, GADGET_RADIO, GADGET_TEXTAREA, GADGET_TEXTBOX, plotter_table::group_end, plotter_table::group_start, guit, box::height, height, content_redraw_data::height, html_redraw_background(), html_redraw_borders(), html_redraw_box(), html_redraw_box_children(), html_redraw_box_has_background(), html_redraw_checkbox(), html_redraw_debug, html_redraw_file(), html_redraw_find_bg_box(), html_redraw_inline_background(), html_redraw_inline_borders(), html_redraw_printing, html_redraw_printing_border, html_redraw_printing_top_cropped, html_redraw_radio(), html_redraw_text_box(), html_redraw_text_decoration(), IFRAME, box::iframe, box::inline_end, netsurf_table::layout, LEFT, box::list_marker, box::margin, messages_get_errorcode(), NEW_LINE, box::next, box::node, NSERROR_OK, NSLOG, box::object, box::padding, box::parent, redraw_context::plot, plot_fstyle_broken_object, plot_style_broken_object, plot_style_content_edge, plot_style_margin_edge, plot_style_padding_edge, PRINTED, plotter_table::rectangle, content_redraw_data::repeat_x, content_redraw_data::repeat_y, REPLACE_DIM, RIGHT, content_redraw_data::scale, box::scroll_x, box::scroll_y, scrollbar_get_offset(), scrollbar_redraw(), SCROLLBAR_WIDTH, form_control::selected, box::style, box::text, plotter_table::text, textarea_redraw(), TOP, box::type, form_control::type, html_content::unit_len_ctx, box_border::width, box::width, width, content_redraw_data::width, gui_layout_table::width, box::x, content_redraw_data::x, rect::x0, rect::x1, box::y, content_redraw_data::y, rect::y0, and rect::y1.

Referenced by html_redraw(), html_redraw_box(), and html_redraw_box_children().

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

◆ html_redraw_box_children()

static bool html_redraw_box_children ( const html_content html,
struct box box,
int  x_parent,
int  y_parent,
const struct rect clip,
float  scale,
colour  current_background_color,
const struct redraw_context ctx 
)
static

Draw the various children of a box.

Parameters
htmlhtml content
boxbox to draw children of
x_parentcoordinate of parent box
y_parentcoordinate of parent box
clipclip rectangle
scalescale for redraw
current_background_colorbackground colour under this box
ctxcurrent redraw context
Returns
true if successful, false otherwise

Definition at line 1182 of file redraw.c.

References BOX_FLOAT_LEFT, BOX_FLOAT_RIGHT, box::children, clip(), box::float_children, html_redraw_box(), box::next, box::next_float, box::scroll_x, box::scroll_y, scrollbar_get_offset(), box::type, box::x, and box::y.

Referenced by html_redraw_box().

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

◆ html_redraw_box_has_background()

static bool html_redraw_box_has_background ( struct box box)
static

Determine if a box has a background that needs drawing.

Parameters
boxBox to consider
Returns
True if box has a background, false otherwise.

Definition at line 76 of file redraw.c.

References box::background, nscss_color_is_transparent, and box::style.

Referenced by html_redraw_box(), and html_redraw_find_bg_box().

Here is the caller graph for this function:

◆ html_redraw_checkbox()

static bool html_redraw_checkbox ( int  x,
int  y,
int  width,
int  height,
bool  selected,
const struct redraw_context ctx 
)
static

Plot a checkbox.

Parameters
xleft coordinate
ytop coordinate
widthdimensions of checkbox
heightdimensions of checkbox
selectedthe checkbox is selected
ctxcurrent redraw context
Returns
true if successful, false otherwise

Definition at line 367 of file redraw.c.

References height, plotter_table::line, NSERROR_OK, redraw_context::plot, plot_style_fill_wbasec, plot_style_fill_wblobc, plot_style_stroke_darkwbasec, plot_style_stroke_lightwbasec, plot_style_stroke_wblobc, plotter_table::rectangle, width, rect::x0, rect::x1, rect::y0, and rect::y1.

Referenced by html_redraw_box().

Here is the caller graph for this function:

◆ html_redraw_file()

static bool html_redraw_file ( int  x,
int  y,
int  width,
int  height,
struct box box,
float  scale,
colour  background_colour,
const css_unit_ctx *  unit_len_ctx,
const struct redraw_context ctx 
)
static

Plot a file upload input.

Parameters
xleft coordinate
ytop coordinate
widthdimensions of input
heightdimensions of input
boxbox of input
scalescale for redraw
background_colourcurrent background colour
unit_len_ctxLength conversion context
ctxcurrent redraw context
Returns
true if successful, false otherwise

Definition at line 536 of file redraw.c.

References plot_font_style::background, font_plot_style_from_css(), box::gadget, guit, height, netsurf_table::layout, messages_get(), NSERROR_OK, redraw_context::plot, box::style, text(), plotter_table::text, form_control::value, width, and gui_layout_table::width.

Referenced by html_redraw_box().

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

◆ html_redraw_find_bg_box()

static struct box * html_redraw_find_bg_box ( struct box box)
static

Find the background box for a box.

Parameters
boxBox to find background box for
Returns
Pointer to background box, or NULL if there is none

Definition at line 99 of file redraw.c.

References box::children, html_redraw_box_has_background(), and box::parent.

Referenced by html_redraw_box().

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

◆ html_redraw_inline_background()

static bool html_redraw_inline_background ( int  x,
int  y,
struct box box,
float  scale,
const struct rect clip,
struct rect  b,
bool  first,
bool  last,
colour background_colour,
const css_unit_ctx *  unit_len_ctx,
const struct redraw_context ctx 
)
static

Plot an inline's background and/or background image.

Parameters
xcoordinate of box
ycoordinate of box
boxBOX_INLINE which created the background
scalescale for redraw
clipcoordinates of clip rectangle
bcoordinates of border edge rectangle
firsttrue if this is the first rectangle associated with the inline
lasttrue if this is the last rectangle associated with the inline
background_colourupdated to current background colour if plotted
unit_len_ctxLength conversion context
ctxcurrent redraw context
Returns
true if successful, false otherwise

Definition at line 824 of file redraw.c.

References box::background, content_redraw_data::background_colour, clip(), plotter_table::clip, content_get_height(), content_get_opaque(), content_get_width(), content_redraw(), plot_style_s::fill_colour, plot_style_s::fill_type, height, content_redraw_data::height, html_redraw_printing, nscss_color_is_transparent, nscss_color_to_ns, NSERROR_OK, nsoption_bool, redraw_context::plot, PLOT_OP_TYPE_SOLID, plotter_table::rectangle, content_redraw_data::repeat_x, content_redraw_data::repeat_y, content_redraw_data::scale, box::style, width, content_redraw_data::width, content_redraw_data::x, rect::x0, rect::x1, content_redraw_data::y, rect::y0, and rect::y1.

Referenced by html_redraw_box().

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

◆ html_redraw_radio()

static bool html_redraw_radio ( int  x,
int  y,
int  width,
int  height,
bool  selected,
const struct redraw_context ctx 
)
static

Plot a radio icon.

Parameters
xleft coordinate
ytop coordinate
widthdimensions of radio icon
heightdimensions of radio icon
selectedthe radio icon is selected
ctxcurrent redraw context
Returns
true if successful, false otherwise

Definition at line 466 of file redraw.c.

References plotter_table::arc, plotter_table::disc, height, NSERROR_OK, redraw_context::plot, plot_style_fill_darkwbasec, plot_style_fill_lightwbasec, plot_style_fill_wbasec, plot_style_fill_wblobc, and width.

Referenced by html_redraw_box().

Here is the caller graph for this function:

◆ html_redraw_text_box()

static bool html_redraw_text_box ( const html_content html,
struct box box,
int  x,
int  y,
const struct rect clip,
float  scale,
colour  current_background_color,
const struct redraw_context ctx 
)
static

Redraw the text content of a box, possibly partially highlighted because the text has been selected, or matches a search operation.

Parameters
htmlThe html content to redraw text within.
boxbox with text content
xx co-ord of box
yy co-ord of box
clipcurrent clip rectangle
scalecurrent scale setting (1.0 = 100%)
current_background_color
ctxcurrent redraw context
Returns
true iff successful and redraw should proceed

Definition at line 1133 of file redraw.c.

References plot_font_style::background, box::byte_offset, clip(), font_plot_style_from_css(), box::height, box::length, box::object, html_content::sel, box::space, box::style, box::text, text_redraw(), and html_content::unit_len_ctx.

Referenced by html_redraw_box().

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

◆ html_redraw_text_decoration()

static bool html_redraw_text_decoration ( struct box box,
int  x_parent,
int  y_parent,
float  scale,
colour  background_colour,
const struct redraw_context ctx 
)
static

Plot text decoration for a box.

Parameters
boxbox to plot decorations for
x_parentx coordinate of parent of box
y_parenty coordinate of parent of box
scalescale for redraw
background_colourcurrent background colour
ctxcurrent redraw context
Returns
true if successful, false otherwise

Definition at line 1073 of file redraw.c.

References blend_colour, BOX_INLINE, html_redraw_printing, html_redraw_text_decoration_block(), html_redraw_text_decoration_inline(), box::inline_end, NOF_ELEMENTS, nscss_color_to_ns, box::style, box::type, box::x, and box::y.

Referenced by html_redraw_box().

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

◆ html_redraw_text_decoration_block()

static bool html_redraw_text_decoration_block ( struct box box,
int  x,
int  y,
float  scale,
colour  colour,
float  ratio,
const struct redraw_context ctx 
)
static

Plot text decoration for an non-inline box.

Parameters
boxbox to plot decorations for, of type other than BOX_INLINE
xx coordinate of box
yy coordinate of box
scalescale for redraw
colourcolour for decorations
ratioposition of line as a ratio of line height
ctxcurrent redraw context
Returns
true if successful, false otherwise

Definition at line 1024 of file redraw.c.

References BOX_BLOCK, BOX_INLINE_CONTAINER, BOX_TEXT, box::children, box::height, html_redraw_text_decoration_block(), plotter_table::line, box::next, NSERROR_OK, redraw_context::plot, PLOT_OP_TYPE_SOLID, plot_style_s::stroke_type, box::type, box::width, box::x, rect::x0, rect::x1, box::y, rect::y0, and rect::y1.

Referenced by html_redraw_text_decoration(), and html_redraw_text_decoration_block().

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

◆ html_redraw_text_decoration_inline()

static bool html_redraw_text_decoration_inline ( struct box box,
int  x,
int  y,
float  scale,
colour  colour,
float  ratio,
const struct redraw_context ctx 
)
static

Plot text decoration for an inline box.

Parameters
boxbox to plot decorations for, of type BOX_INLINE
xx coordinate of parent of box
yy coordinate of parent of box
scalescale for redraw
colourcolour for decorations
ratioposition of line as a ratio of line height
ctxcurrent redraw context
Returns
true if successful, false otherwise

Definition at line 976 of file redraw.c.

References BOX_TEXT, box::height, box::inline_end, plotter_table::line, box::next, NSERROR_OK, redraw_context::plot, PLOT_OP_TYPE_SOLID, plot_style_s::stroke_type, box::type, box::width, box::x, rect::x0, rect::x1, box::y, rect::y0, and rect::y1.

Referenced by html_redraw_text_decoration().

Here is the caller graph for this function:

◆ text_redraw()

static bool text_redraw ( const char *  utf8_text,
size_t  utf8_len,
size_t  offset,
int  space,
const plot_font_style_t fstyle,
int  x,
int  y,
const struct rect clip,
int  height,
float  scale,
bool  excluded,
struct content c,
const struct selection sel,
const struct redraw_context ctx 
)
static

Redraw a short text string, complete with highlighting (for selection/search)

Parameters
utf8_textpointer to UTF-8 text string
utf8_lenlength of string, in bytes
offsetbyte offset within textual representation
spacewidth of space that follows string (0 = no space)
fstyletext style to use (pass text size unscaled)
xx ordinate at which to plot text
yy ordinate at which to plot text
clippointer to current clip rectangle
heightheight of text string
scalecurrent display scale (1.0 = 100%)
excludedexclude this text string from the selection
cContent being redrawn.
selSelection context
searchSearch context
ctxcurrent redraw context
Returns
true iff successful and redraw should proceed

Definition at line 158 of file redraw.c.

References plot_font_style::background, clip(), plotter_table::clip, colour_to_bw_furthest, content_textsearch_ishighlighted(), content::context, plot_style_s::fill_colour, plot_font_style::foreground, guit, height, redraw_context::interactive, netsurf_table::layout, max, min, NSERROR_OK, redraw_context::plot, plot_style_fill_white, plotter_table::rectangle, selection_highlighted(), plot_font_style::size, box::space, plotter_table::text, content::textsearch, gui_layout_table::width, rect::x0, rect::x1, rect::y0, and rect::y1.

Referenced by html_redraw_text_box().

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

Variable Documentation

◆ html_redraw_debug

bool html_redraw_debug = false

Render padding and margin box outlines in html_redraw().

Definition at line 68 of file redraw.c.

Referenced by deskmenu_update(), html_debug(), html_redraw_box(), and menu_debug_render().