51 #define box_is_float(box) (box->type == BOX_FLOAT_LEFT || \ 52 box->type == BOX_FLOAT_RIGHT) 65 css_computed_style_destroy(b->
style);
70 css_select_results_destroy(b->
styles);
78 lwc_string_unref(b->
id);
81 if (b->
node != NULL) {
82 dom_node_unref(b->
node);
104 css_computed_style *
style,
115 box =
talloc(context,
struct box);
132 for (i = 0; i != 4; i++)
186 parent->
last = child;
215 if (parent->
last == box)
231 struct box *child, *
next;
234 for (child = box->
children; child; child = next) {
255 css_select_results_destroy(box->
styles);
319 css_computed_clip_rect css_rect;
321 if (box->
style != NULL &&
322 css_computed_position(box->
style) ==
323 CSS_POSITION_ABSOLUTE &&
324 css_computed_clip(box->
style, &css_rect) ==
337 if (x >= r.
x0 && x < r.x1 && y >= r.
y0 && y < r.
y1)
343 if (css_rect.left_auto ==
false) {
345 css_rect.left, css_rect.lunit,
348 if (css_rect.top_auto ==
false) {
350 css_rect.top, css_rect.tunit,
353 if (css_rect.right_auto ==
false) {
360 if (css_rect.bottom_auto ==
false) {
369 if (x >= r.
x0 && x < r.x1 && y >= r.
y0 && y < r.
y1) {
388 x < box->list_marker->x - box->
x +
395 y < box->list_marker->y - box->
y +
403 if ((box->
style && css_computed_overflow_x(box->
style) ==
404 CSS_OVERFLOW_VISIBLE) || !box->
style) {
406 x < box->descendant_x1) {
411 if ((box->
style && css_computed_overflow_y(box->
style) ==
412 CSS_OVERFLOW_VISIBLE) || !box->
style) {
414 y < box->descendant_y1) {
446 static inline struct box *
449 struct box *rb = NULL;
510 assert(0 &&
"Bad box walk type.");
576 goto done_float_children;
623 const int x,
const int y,
624 int *box_x,
int *box_y)
631 skip_children =
false;
632 while ((box =
box_next_xy(box, box_x, box_y, skip_children))) {
641 skip_children =
false;
643 skip_children =
true;
678 struct box **nearest,
680 int *nr_xd,
int *nr_yd)
689 if (x >= bx && x1 > x && y >= by && y1 > y) {
699 if (by <= y && bx < x) {
700 yd = y <= y1 ? 0 : y - y1;
701 xd = x <= x1 ? 0 : x - x1;
705 if (y1 > y && x1 > x) {
706 yd = y > by ? 0 : by -
y;
707 xd = x > bx ? 0 : bx -
x;
712 if (yd < *nr_yd || (yd == *nr_yd && xd <= *nr_xd)) {
750 int fx,
int fy,
int x,
int y,
int dir,
struct box **nearest,
751 int *tx,
int *ty,
int *nr_xd,
int *nr_yd)
758 if (*nearest == NULL) {
759 *nr_xd = INT_MAX / 2;
760 *nr_yd = INT_MAX / 2;
767 if (x >= bx && b_x1 > x && y >= by && b_y1 > y) {
775 c_bx = fx + child->
x -
777 c_by = fy + child->
y -
780 c_bx = bx + child->
x -
782 c_by = by + child->
y -
792 if (in_box && child->
text && !child->
object) {
794 c_bx, c_by, x, y, dir, nearest,
795 tx, ty, nr_xd, nr_yd))
804 tx, ty, nr_xd, nr_yd))
808 c_fx, c_fy, x, y, dir, nearest, tx, ty,
826 struct box *text_box = NULL;
843 dir, &text_box, &tx, &ty, &nr_xd, &nr_yd)) {
844 if (text_box && text_box->
text && !text_box->
object) {
878 if (box->
id != NULL &&
879 lwc_string_isequal(
id, box->
id, &m) == lwc_error_ok &&
896 if (box->
style && css_computed_visibility(box->
style) ==
897 CSS_VISIBILITY_HIDDEN)
908 struct box *c, *
prev;
910 for (i = 0; i != depth; i++)
911 fprintf(stream,
" ");
913 fprintf(stream,
"%p ", box);
914 fprintf(stream,
"x%i y%i w%i h%i ", box->
x, box->
y,
918 fprintf(stream,
"(%i %i %i %i) ",
922 fprintf(stream,
"m(%i %i %i %i) ",
927 case BOX_BLOCK: fprintf(stream,
"BLOCK ");
break;
929 case BOX_INLINE: fprintf(stream,
"INLINE ");
break;
932 case BOX_TABLE: fprintf(stream,
"TABLE [columns %i] ",
936 "start %i, rows %i] ", box->
columns,
941 case BOX_BR: fprintf(stream,
"BR ");
break;
942 case BOX_TEXT: fprintf(stream,
"TEXT ");
break;
943 default: fprintf(stream,
"Unknown box type ");
947 fprintf(stream,
"%li '%.*s' ", (
unsigned long) box->
byte_offset,
950 fprintf(stream,
"space ");
952 fprintf(stream,
"(object '%s') ",
956 fprintf(stream,
"(iframe) ");
959 fprintf(stream,
"(gadget) ");
960 if (style && box->
style)
965 fprintf(stream,
" |%s|", box->
target);
967 fprintf(stream,
" [%s]", box->
title);
969 fprintf(stream,
" ID:%s", lwc_string_data(box->
id));
971 fprintf(stream,
" inline_end %p", box->
inline_end);
975 fprintf(stream,
" next_float %p", box->
next_float);
979 fprintf(stream,
" (columns");
980 for (i = 0; i != box->
columns; i++)
981 fprintf(stream,
" (%s %s %i %i %i)",
982 ((
const char *[]) {
"UNKNOWN",
"FIXED",
983 "AUTO",
"PERCENT",
"RELATIVE"})
985 ((
const char *[]) {
"normal",
990 fprintf(stream,
")");
992 if (box->
node != NULL) {
994 if (dom_node_get_node_name(box->
node, &name) == DOM_NO_ERR) {
995 fprintf(stream,
" <%s>", dom_string_data(name));
996 dom_string_unref(name);
999 fprintf(stream,
"\n");
1002 for (i = 0; i != depth; i++)
1003 fprintf(stream,
" ");
1004 fprintf(stream,
"list_marker:\n");
1011 fprintf(stream,
"warning: box->last %p (should be %p) " 1012 "(box %p)\n", box->
last, c, box);
1013 for (prev = 0, c = box->
children; c; prev = c, c = c->
next) {
1015 fprintf(stream,
"warning: box->parent %p (should be " 1016 "%p) (box on next line)\n",
1018 if (c->
prev != prev)
1019 fprintf(stream,
"warning: box->prev %p (should be " 1020 "%p) (box on next line)\n",
1022 box_dump(stream, c, depth + 1, style);
1035 int visible_width, visible_height;
1036 int full_width, full_height;
1039 if (!bottom && box->
scroll_x != NULL) {
1046 if (!right && box->
scroll_y != NULL) {
1053 if (!bottom && !right) {
1116 visible_width, full_width);
1120 if (right && bottom) {
struct form_control * gadget
Form control data, or NULL if not a form control.
struct box * prev
Previous sibling box, or NULL.
unsigned int start_column
Start column for TABLE_CELL only.
const char * target
Link target, or NULL.
void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
Dump a computed style style to the give file handle stream.
struct box * box_create(css_select_results *styles, css_computed_style *style, bool style_owned, nsurl *href, const char *target, const char *title, lwc_string *id, void *context)
Create a box tree node.
int descendant_x1
right edge of descendants
struct object_params * object_params
Parameters for the object, or NULL.
struct box_border border[4]
Border: TOP, RIGHT, BOTTOM, LEFT.
Interface to utility string handling.
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)...
bool box_hscrollbar_present(const struct box *const box)
Determine if a box has a horizontal scrollbar.
struct nsurl * href
Link, or NULL.
box_flags flags
Box flags.
int cached_place_below_level
Level below which floats have been placed.
Public content interface.
int min_width
Width of box taking all line breaks (including margins etc).
int padding[4]
Padding: TOP, RIGHT, BOTTOM, LEFT.
box_walk_dir
Direction to move in a box-tree walk.
size_t byte_offset
Byte offset within a textual representation of this content.
#define talloc_set_destructor(ptr, function)
#define box_is_float(box)
int descendant_y0
top edge of descendants
struct scrollbar * scroll_x
Horizontal scroll.
Core mouse and pointer states.
int descendant_x0
left edge of descendants
void box_unlink_and_free(struct box *box)
Unlink a box from the box tree and then free it recursively.
Interface to platform-specific miscellaneous browser operation table.
void box_insert_sibling(struct box *box, struct box *new_box)
Insert a new box as a sibling to a box in a tree.
void box_add_child(struct box *parent, struct box *child)
Add a child to a box tree node.
struct box * last
Last child box, or NULL.
int min
Minimum width of content.
void box_free_box(struct box *box)
Free the data in a single box structure.
int x
Coordinate of left padding edge relative to parent box, or relative to ancestor that contains this bo...
struct box * layout
Box tree, or NULL.
Length conversion context data.
struct box * float_children
First float child box, or NULL.
int y
Coordinate of top padding edge, relative as for x.
struct scrollbar * scroll_y
Vertical scroll.
unsigned int rows
Number of rows for TABLE only.
int talloc_free(void *ptr)
#define UNKNOWN_MAX_WIDTH
Option reading and saving interface.
void html_overflow_scroll_callback(void *client_data, struct scrollbar_msg_data *scrollbar_data)
Callback for in-page scrollbars.
int space
Width of space after current text (depends on font and size).
nserror
Enumeration of error codes.
struct box * next_float
Next sibling float box.
size_t length
Length of text.
lwc_string * id
value of id attribute (or name for anchors)
int max
Maximum width of content.
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.
struct box * box_at_point(const nscss_len_ctx *len_ctx, struct box *box, const int x, const int y, int *box_x, int *box_y)
Find the boxes at a point.
Corresponds to a single URL.
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.
struct dom_node * node
DOM node that generated this box or NULL.
Private data for text/html content.
HTML content user interaction handling.
static bool box_contains_point(const nscss_len_ctx *len_ctx, const struct box *box, int x, int y, bool *physically)
Determine if a point lies within a box.
struct nsurl * hlcache_handle_get_url(const struct hlcache_handle *handle)
Retrieve the URL associated with a high level cache handle.
nserror box_handle_scrollbars(struct content *c, struct box *box, bool bottom, bool right)
Applies the given scroll setup to a box.
struct box * box_find_by_id(struct box *box, lwc_string *id)
Find a box based upon its id attribute.
struct box * list_marker
List marker box if this is a list-item, or NULL.
Box tree construction and manipulation interface.
struct column * col
Array of table column data for TABLE only.
struct box * float_container
If box is a float, points to box's containing block.
void box_free(struct box *box)
Free a box tree recursively.
const char * title
Title, or NULL.
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.
struct box * children
First child box, or NULL.
css_select_results * styles
Computed styles for elements and their pseudo elements.
bool positioned
Whether all of column's cells are css positioned.
int width
border-width (pixels)
int height
Height of content box (excluding padding etc.).
box_type type
Type of box.
css_fixed nscss_len2px(const nscss_len_ctx *ctx, css_fixed length, css_unit unit, const css_computed_style *style)
Convert a CSS length to pixels.
int descendant_y1
bottom edge of descendants
int width
Preferred width of column.
struct hlcache_handle * background
Background image for this box, or NULL if none.
bool box_vscrollbar_present(const struct box *const box)
Determine if a box has a vertical scrollbar.
bool box_visible(struct box *box)
Determine if a box is visible when the tree is rendered.
char * text
Text, or NULL if none.
nsurl * nsurl_ref(nsurl *url)
Increment the reference count to a NetSurf URL object.
int width
Width of content box (excluding padding etc.).
struct hlcache_handle * object
Object in this box (usually an image), or NULL if none.
static int box_talloc_destructor(struct box *b)
Destructor for box nodes which own styles.
void box_coords(struct box *box, int *x, int *y)
Find the absolute coordinates of a box.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
int margin[4]
Margin: TOP, RIGHT, BOTTOM, LEFT.
struct box * next
Next sibling box, or NULL.
struct box * parent
Parent box, or NULL.
int max_width
Width that would be taken with no line breaks.
unsigned int columns
Number of columns for TABLE / TABLE_CELL.
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.
void box_dump(FILE *stream, struct box *box, unsigned int depth, bool style)
Print a box tree to a file.
#define talloc(ctx, type)
enum column::@132 type
Type of column.
Data specific to CONTENT_HTML.
Interface to core interface table.
css_computed_style * style
Style for this box.
NetSurf URL handling (interface).
struct nsurl nsurl
NetSurf URL object.
struct box * inline_end
INLINE_END box corresponding to this INLINE box, or INLINE box corresponding to this INLINE_END box...
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
struct browser_window * iframe
Iframe's browser_window, or NULL if none.
char * usemap
(Image)map to use with this object, or NULL if none
void box_bounds(struct box *box, struct rect *r)
Find the bounds of a box.