54#define box_is_float(box) (box->type == BOX_FLOAT_LEFT || \
55 box->type == BOX_FLOAT_RIGHT)
81 css_computed_clip_rect css_rect;
84 css_computed_position(
box->
style) == CSS_POSITION_ABSOLUTE &&
85 css_computed_clip(
box->
style, &css_rect) == CSS_CLIP_RECT) {
97 if (x >= r.
x0 && x < r.x1 && y >= r.
y0 && y < r.
y1) {
104 if (css_rect.left_auto ==
false) {
105 r.
x0 += FIXTOINT(css_unit_len2device_px(
111 if (css_rect.top_auto ==
false) {
112 r.
y0 += FIXTOINT(css_unit_len2device_px(
118 if (css_rect.right_auto ==
false) {
120 FIXTOINT(css_unit_len2device_px(
126 if (css_rect.bottom_auto ==
false) {
128 FIXTOINT(css_unit_len2device_px(
136 if (x >= r.
x0 && x < r.x1 && y >= r.
y0 && y < r.
y1) {
155 x < box->list_marker->x -
box->
x +
162 y < box->list_marker->y -
box->
y +
171 CSS_OVERFLOW_VISIBLE) || !
box->
style) {
173 x < box->descendant_x1) {
179 CSS_OVERFLOW_VISIBLE) || !
box->
style) {
181 y < box->descendant_y1) {
200static inline struct box *
203 struct box *rb = NULL;
264 assert(0 &&
"Bad box walk type.");
282static inline struct box *
330 goto done_float_children;
400 struct box **nearest,
402 int *nr_xd,
int *nr_yd)
411 if (
x >= bx && x1 >
x &&
y >= by && y1 >
y) {
421 if (by <=
y && bx <
x) {
422 yd =
y <= y1 ? 0 :
y - y1;
423 xd =
x <= x1 ? 0 :
x - x1;
427 if (y1 >
y && x1 >
x) {
428 yd =
y > by ? 0 : by -
y;
429 xd =
x > bx ? 0 : bx -
x;
434 if (yd < *nr_yd || (yd == *nr_yd && xd <= *nr_xd)) {
477 struct box **nearest,
479 int *nr_xd,
int *nr_yd)
486 if (*nearest == NULL) {
487 *nr_xd = INT_MAX / 2;
488 *nr_yd = INT_MAX / 2;
495 if (
x >= bx && b_x1 >
x &&
y >= by && b_y1 >
y) {
503 c_bx = fx + child->
x -
505 c_by = fy + child->
y -
508 c_bx = bx + child->
x -
510 c_by = by + child->
y -
520 if (in_box && child->
text && !child->
object) {
522 c_bx, c_by,
x,
y, dir, nearest,
523 tx, ty, nr_xd, nr_yd))
532 tx, ty, nr_xd, nr_yd))
537 x,
y, dir, nearest, tx, ty,
585 const int x,
const int y,
586 int *box_x,
int *box_y)
593 skip_children =
false;
603 skip_children =
false;
605 skip_children =
true;
619 if (
box->
id != NULL &&
620 lwc_string_isequal(
id,
box->
id, &m) == lwc_error_ok &&
640 css_computed_visibility(
box->
style) == CSS_VISIBILITY_HIDDEN) {
654 for (i = 0; i != depth; i++) {
655 fprintf(stream,
" ");
658 fprintf(stream,
"%p ",
box);
659 fprintf(stream,
"x%i y%i w%i h%i ",
664 fprintf(stream,
"desc(%i %i %i %i) ",
668 fprintf(stream,
"m(%i %i %i %i) ",
674 fprintf(stream,
"BLOCK ");
678 fprintf(stream,
"INLINE_CONTAINER ");
682 fprintf(stream,
"INLINE ");
686 fprintf(stream,
"INLINE_END ");
690 fprintf(stream,
"INLINE_BLOCK ");
694 fprintf(stream,
"TABLE [columns %i] ",
box->
columns);
698 fprintf(stream,
"TABLE_ROW ");
702 fprintf(stream,
"TABLE_CELL [columns %i, start %i, rows %i] ",
709 fprintf(stream,
"TABLE_ROW_GROUP ");
713 fprintf(stream,
"FLOAT_LEFT ");
717 fprintf(stream,
"FLOAT_RIGHT ");
721 fprintf(stream,
"BR ");
725 fprintf(stream,
"TEXT ");
729 fprintf(stream,
"FLEX ");
733 fprintf(stream,
"INLINE_FLEX ");
737 fprintf(stream,
"Unknown box type ");
744 fprintf(stream,
"space ");
746 fprintf(stream,
"(object '%s') ",
750 fprintf(stream,
"(iframe) ");
753 fprintf(stream,
"(gadget) ");
761 fprintf(stream,
" [%s]",
box->
title);
763 fprintf(stream,
" ID:%s", lwc_string_data(
box->
id));
773 fprintf(stream,
" (columns");
775 fprintf(stream,
" (%s %s %i %i %i)",
791 fprintf(stream,
")");
795 if (dom_node_get_node_name(
box->
node, &name) == DOM_NO_ERR) {
796 fprintf(stream,
" <%s>", dom_string_data(name));
797 dom_string_unref(name);
800 fprintf(stream,
"\n");
803 for (i = 0; i != depth; i++)
804 fprintf(stream,
" ");
805 fprintf(stream,
"list_marker:\n");
812 fprintf(stream,
"warning: box->last %p (should be %p) "
816 fprintf(stream,
"warning: box->parent %p (should be "
817 "%p) (box on next line)\n",
820 fprintf(stream,
"warning: box->prev %p (should be "
821 "%p) (box on next line)\n",
855 struct box *text_box = NULL;
872 dir, &text_box, &tx, &ty, &nr_xd, &nr_yd)) {
873 if (text_box && text_box->
text && !text_box->
object) {
#define UNKNOWN_MAX_WIDTH
bool box_hscrollbar_present(const struct box *const box)
Determine if a box has a horizontal scrollbar.
#define box_is_float(box)
static bool box_contains_point(const css_unit_ctx *unit_len_ctx, const struct box *box, int x, int y, bool *physically)
Determine if a point lies within a box.
bool box_vscrollbar_present(const struct box *const box)
Determine if a box has a vertical scrollbar.
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.
void box_coords(struct box *box, int *x, int *y)
Find the absolute coordinates of a box.
void box_bounds(struct box *box, struct rect *r)
Find the bounds of a box.
box_walk_dir
Direction to move in a box-tree walk.
@ BOX_WALK_FLOAT_CONTAINER
@ BOX_WALK_NEXT_FLOAT_SIBLING
@ BOX_WALK_FLOAT_CHILDREN
static struct box * box_next_xy(struct box *b, int *x, int *y, bool skip_children)
Itterator for walking to next box in interaction order.
bool box_visible(struct box *box)
Determine if a box is visible when the tree is rendered.
static bool box_nearest_text_box(struct box *box, int bx, int by, int fx, int fy, int x, int y, int dir, struct box **nearest, int *tx, int *ty, int *nr_xd, int *nr_yd)
Pick the text box child of 'box' that is closest to and above-left (dir -ve) or below-right (dir +ve)...
struct box * box_find_by_id(struct box *box, lwc_string *id)
Find a box based upon its id attribute.
static bool box_nearer_text_box(struct box *box, int bx, int by, int x, int y, int dir, struct box **nearest, int *tx, int *ty, int *nr_xd, int *nr_yd)
Check whether box is nearer mouse coordinates than current nearest box.
void box_dump(FILE *stream, struct box *box, unsigned int depth, bool style)
Print a box tree to a file.
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,...
static struct box * box_move_xy(struct box *b, enum box_walk_dir dir, int *x, int *y)
Move from box to next box in given direction, adjusting for box coord change.
HTML Box tree inspection interface.
void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
Dump a computed style style to the give file handle stream.
Public content interface.
struct nsurl * hlcache_handle_get_url(const struct hlcache_handle *handle)
Retrieve the URL associated with a high level cache handle.
Core mouse and pointer states.
NetSurf URL handling (interface).
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
Private data for text/html content.
int width
border-width (pixels)
int descendant_y1
bottom edge of descendants
struct box_border border[4]
Border: TOP, RIGHT, BOTTOM, LEFT.
int min_width
Width of box taking all line breaks (including margins etc).
int width
Width of content box (excluding padding etc.).
struct box * parent
Parent box, or NULL.
struct scrollbar * scroll_x
Horizontal scroll.
lwc_string * id
value of id attribute (or name for anchors)
size_t byte_offset
Byte offset within a textual representation of this content.
struct column * col
Array of table column data for TABLE only.
const char * title
Title, or NULL.
struct box * inline_end
INLINE_END box corresponding to this INLINE box, or INLINE box corresponding to this INLINE_END box.
struct box * children
First child box, or NULL.
int height
Height of content box (excluding padding etc.).
struct box * float_container
If box is a float, points to box's containing block.
struct box * prev
Previous sibling box, or NULL.
struct box * list_marker
List marker box if this is a list-item, or NULL.
int margin[4]
Margin: TOP, RIGHT, BOTTOM, LEFT.
int max_width
Width that would be taken with no line breaks.
const char * target
Link target, or NULL.
struct box * next_float
Next sibling float box.
struct box * last
Last child box, or NULL.
struct box * next
Next sibling box, or NULL.
int descendant_x0
left edge of descendants
struct scrollbar * scroll_y
Vertical scroll.
unsigned int start_column
Start column for TABLE_CELL only.
box_type type
Type of box.
struct nsurl * href
Link, or NULL.
struct box * float_children
First float child box, or NULL.
int descendant_x1
right edge of descendants
struct browser_window * iframe
Iframe's browser_window, or NULL if none.
css_computed_style * style
Style for this box.
size_t length
Length of text.
struct hlcache_handle * object
Object in this box (usually an image), or NULL if none.
char * text
Text, or NULL if none.
int padding[4]
Padding: TOP, RIGHT, BOTTOM, LEFT.
int x
Coordinate of left padding edge relative to parent box, or relative to ancestor that contains this bo...
int space
Width of space after current text (depends on font and size).
struct form_control * gadget
Form control data, or NULL if not a form control.
int descendant_y0
top edge of descendants
unsigned int rows
Number of rows for TABLE only.
struct dom_node * node
DOM node that generated this box or NULL.
unsigned int columns
Number of columns for TABLE / TABLE_CELL.
int y
Coordinate of top padding edge, relative as for x.
bool positioned
Whether all of column's cells are css positioned.
int width
Preferred width of column.
int max
Maximum width of content.
enum column::@131 type
Type of column.
int min
Minimum width of content.
Data specific to CONTENT_HTML.
struct box * layout
Box tree, or NULL.
Interface to a number of general purpose functionality.
#define fallthrough
switch fall through