NetSurf
Functions
box_inspect.h File Reference

HTML Box tree inspection interface. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void box_coords (struct box *box, int *x, int *y)
 Find the absolute coordinates of a box. More...
 
void box_bounds (struct box *box, struct rect *r)
 Find the bounds of a box. More...
 
struct boxbox_at_point (const css_unit_ctx *unit_len_ctx, struct box *box, const int x, const int y, int *box_x, int *box_y)
 Find the boxes at a point. More...
 
struct boxbox_find_by_id (struct box *box, lwc_string *id)
 Find a box based upon its id attribute. More...
 
bool box_visible (struct box *box)
 Determine if a box is visible when the tree is rendered. More...
 
void box_dump (FILE *stream, struct box *box, unsigned int depth, bool style)
 Print a box tree to a file. More...
 
bool box_vscrollbar_present (const struct box *box)
 Determine if a box has a vertical scrollbar. More...
 
bool box_hscrollbar_present (const struct box *box)
 Determine if a box has a horizontal scrollbar. More...
 
struct boxbox_pick_text_box (struct html_content *html, int x, int y, int dir, int *dx, int *dy)
 Peform pick text on browser window contents to locate the box under the mouse pointer, or nearest in the given direction if the pointer is not over a text box. More...
 
static bool box_is_first_child (struct box *b)
 Check if layout box is a first child. More...
 
static unsigned box_count_children (const struct box *b)
 

Detailed Description

HTML Box tree inspection interface.

Definition in file box_inspect.h.

Function Documentation

◆ box_at_point()

struct box * box_at_point ( const css_unit_ctx *  unit_len_ctx,
struct box box,
const int  x,
const int  y,
int *  box_x,
int *  box_y 
)

Find the boxes at a point.

Parameters
unit_len_ctxCSS length conversion context for document.
boxbox to search children of
xpoint to find, in global document coordinates
ypoint to find, in global document coordinates
box_xposition of box, in global document coordinates, updated to position of returned box, if any
box_yposition of box, in global document coordinates, updated to position of returned box, if any
Returns
box at given point, or 0 if none found

To find all the boxes in the hierarchy at a certain point, use code like this:

struct box *box = top_of_document_to_search;
int box_x = 0, box_y = 0;
while ((box = box_at_point(unit_len_ctx, box, x, y, &box_x, &box_y))) {
// process box
}
struct box * box_at_point(const css_unit_ctx *unit_len_ctx, struct box *box, const int x, const int y, int *box_x, int *box_y)
Find the boxes at a point.
Definition: box_inspect.c:583
Node in box tree.
Definition: box.h:177
int x
Coordinate of left padding edge relative to parent box, or relative to ancestor that contains this bo...
Definition: box.h:280
int y
Coordinate of top padding edge, relative as for x.
Definition: box.h:284

Definition at line 583 of file box_inspect.c.

References box_contains_point(), box_next_xy(), box::scroll_x, box::scroll_y, scrollbar_get_offset(), box::x, and box::y.

Referenced by get_mouse_action_node(), html_drop_file_at_point(), html_get_contextual_content(), and html_scroll_at_point().

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

◆ box_bounds()

void box_bounds ( struct box box,
struct rect r 
)

Find the bounds of a box.

Parameters
boxthe box to calculate bounds of
rreceives bounds

Definition at line 567 of file box_inspect.c.

References BOTTOM, box_coords(), box::height, height, LEFT, box::padding, RIGHT, TOP, box::width, width, rect::x0, rect::x1, rect::y0, and rect::y1.

Referenced by browser_window_create_iframes(), and form_control_bounding_rect().

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

◆ box_coords()

void box_coords ( struct box box,
int *  x,
int *  y 
)

Find the absolute coordinates of a box.

Parameters
boxthe box to calculate coordinates of
xupdated to x coordinate
yupdated to y coordinate

Definition at line 549 of file box_inspect.c.

References box_is_float, box::float_container, box::parent, box::scroll_x, box::scroll_y, scrollbar_get_offset(), box::x, and box::y.

Referenced by box_bounds(), box_textarea_callback(), coords_from_range(), form_select_menu_callback(), form_select_mouse_drag_end(), html__redraw_a_box(), html_box_drag_start(), html_drop_file_at_point(), html_get_id_offset(), html_object_callback(), html_overflow_scroll_drag_end(), html_redraw(), html_redraw_a_box(), html_set_focus(), html_textsearch_bounds(), layout_calculate_descendant_bboxes(), mouse_action_drag_content(), mouse_action_drag_scrollbar(), mouse_action_drag_textarea(), and mouse_action_select_menu().

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

◆ box_count_children()

static unsigned box_count_children ( const struct box b)
inlinestatic

Definition at line 142 of file box_inspect.h.

References box::children, count(), and box::next.

Referenced by layout_flex_ctx__create().

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

◆ box_dump()

void box_dump ( FILE *  stream,
struct box box,
unsigned int  depth,
bool  style 
)

◆ box_find_by_id()

struct box * box_find_by_id ( struct box box,
lwc_string *  id 
)

Find a box based upon its id attribute.

Parameters
boxbox tree to search
idid to look for
Returns
the box or 0 if not found

Definition at line 614 of file box_inspect.c.

References box_find_by_id(), box::children, box::id, and box::next.

Referenced by box_find_by_id(), and html_get_id_offset().

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

◆ box_hscrollbar_present()

bool box_hscrollbar_present ( const struct box box)

Determine if a box has a horizontal scrollbar.

Parameters
boxscrolling box
Returns
the box has a horizontal scrollbar

Definition at line 839 of file box_inspect.c.

References box::border, box::descendant_x1, LEFT, box::padding, RIGHT, box_border::width, and box::width.

Referenced by html_redraw_box(), and layout_block_add_scrollbar().

Here is the caller graph for this function:

◆ box_is_first_child()

static bool box_is_first_child ( struct box b)
inlinestatic

Check if layout box is a first child.

Parameters
[in]bBox to check.
Returns
true iff box is first child.

Definition at line 137 of file box_inspect.h.

References box::children, and box::parent.

Referenced by layout_block_context(), and layout_next_margin_block().

Here is the caller graph for this function:

◆ box_pick_text_box()

struct box * box_pick_text_box ( struct html_content html,
int  x,
int  y,
int  dir,
int *  dx,
int *  dy 
)

Peform pick text on browser window contents to locate the box under the mouse pointer, or nearest in the given direction if the pointer is not over a text box.

Parameters
htmlan HTML content
xcoordinate of mouse
ycoordinate of mouse
dirdirection to search (-1 = above-left, +1 = below-right)
dxreceives x ordinate of mouse relative to text box
dyreceives y ordinate of mouse relative to text box

Definition at line 850 of file box_inspect.c.

References BOTTOM, box_nearest_text_box(), box::height, html_content::layout, LEFT, box::margin, box::object, box::padding, RIGHT, box::text, TOP, box::width, box::x, and box::y.

Referenced by html_selection_drag_end(), and mouse_action_drag_selection().

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

◆ box_visible()

bool box_visible ( struct box box)

Determine if a box is visible when the tree is rendered.

Parameters
boxbox to check
Returns
true iff the box is rendered

Definition at line 636 of file box_inspect.c.

References box::style.

Referenced by html_object_callback().

Here is the caller graph for this function:

◆ box_vscrollbar_present()

bool box_vscrollbar_present ( const struct box box)

Determine if a box has a vertical scrollbar.

Parameters
boxscrolling box
Returns
the box has a vertical scrollbar

Definition at line 829 of file box_inspect.c.

References box::border, BOTTOM, box::descendant_y1, box::height, box::padding, TOP, and box_border::width.

Referenced by html_redraw_box(), and layout_block_add_scrollbar().

Here is the caller graph for this function: