NetSurf
box_inspect.c
Go to the documentation of this file.
1/*
2 * Copyright 2008 Michael Drake <tlsa@netsurf-browser.org>
3 * Copyright 2020 Vincent Sanders <vince@netsurf-browser.org>
4 *
5 * This file is part of NetSurf, http://www.netsurf-browser.org/
6 *
7 * NetSurf is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * NetSurf is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20/**
21 * \file
22 * implementation of box tree inspection.
23 */
24
25#include <stdio.h>
26#include <dom/dom.h>
27
28#include "utils/utils.h"
29#include "utils/nsurl.h"
30#include "utils/errors.h"
31#include "netsurf/types.h"
32#include "netsurf/content.h"
33#include "netsurf/mouse.h"
34#include "css/utils.h"
35#include "css/dump.h"
36#include "desktop/scrollbar.h"
37
38#include "html/private.h"
39#include "html/box.h"
40#include "html/box_inspect.h"
41
42/**
43 * Direction to move in a box-tree walk
44 */
52};
53
54#define box_is_float(box) (box->type == BOX_FLOAT_LEFT || \
55 box->type == BOX_FLOAT_RIGHT)
56
57/**
58 * Determine if a point lies within a box.
59 *
60 * \param[in] unit_len_ctx CSS length conversion context to use.
61 * \param[in] box Box to consider
62 * \param[in] x Coordinate relative to box
63 * \param[in] y Coordinate relative to box
64 * \param[out] physically If function returning true, physically is set true
65 * iff point is within the box's physical dimensions and
66 * false if the point is not within the box's physical
67 * dimensions but is in the area defined by the box's
68 * descendants. If function returns false, physically
69 * is undefined.
70 * \return true if the point is within the box or a descendant box
71 *
72 * This is a helper function for box_at_point().
73 */
74static bool
75box_contains_point(const css_unit_ctx *unit_len_ctx,
76 const struct box *box,
77 int x,
78 int y,
79 bool *physically)
80{
81 css_computed_clip_rect css_rect;
82
83 if (box->style != NULL &&
84 css_computed_position(box->style) == CSS_POSITION_ABSOLUTE &&
85 css_computed_clip(box->style, &css_rect) == CSS_CLIP_RECT) {
86 /* We have an absolutly positioned box with a clip rect */
87 struct rect r = {
88 .x0 = box->border[LEFT].width,
89 .y0 = box->border[TOP].width,
90 .x1 = box->padding[LEFT] + box->width +
93 .y1 = box->padding[TOP] + box->height +
96 };
97 if (x >= r.x0 && x < r.x1 && y >= r.y0 && y < r.y1) {
98 *physically = true;
99 } else {
100 *physically = false;
101 }
102
103 /* Adjust rect to css clip region */
104 if (css_rect.left_auto == false) {
105 r.x0 += FIXTOINT(css_unit_len2device_px(
106 box->style,
107 unit_len_ctx,
108 css_rect.left,
109 css_rect.lunit));
110 }
111 if (css_rect.top_auto == false) {
112 r.y0 += FIXTOINT(css_unit_len2device_px(
113 box->style,
114 unit_len_ctx,
115 css_rect.top,
116 css_rect.tunit));
117 }
118 if (css_rect.right_auto == false) {
119 r.x1 = box->border[LEFT].width +
120 FIXTOINT(css_unit_len2device_px(
121 box->style,
122 unit_len_ctx,
123 css_rect.right,
124 css_rect.runit));
125 }
126 if (css_rect.bottom_auto == false) {
127 r.y1 = box->border[TOP].width +
128 FIXTOINT(css_unit_len2device_px(
129 box->style,
130 unit_len_ctx,
131 css_rect.bottom,
132 css_rect.bunit));
133 }
134
135 /* Test if point is in clipped box */
136 if (x >= r.x0 && x < r.x1 && y >= r.y0 && y < r.y1) {
137 /* inside clip area */
138 return true;
139 }
140
141 /* Not inside clip area */
142 return false;
143 }
144 if (x >= -box->border[LEFT].width &&
145 x < box->padding[LEFT] + box->width +
147 y >= -box->border[TOP].width &&
148 y < box->padding[TOP] + box->height +
150 *physically = true;
151 return true;
152 }
153 if (box->list_marker && box->list_marker->x - box->x <= x +
155 x < box->list_marker->x - box->x +
160 box->list_marker->y - box->y <= y +
162 y < box->list_marker->y - box->y +
167 *physically = true;
168 return true;
169 }
170 if ((box->style && css_computed_overflow_x(box->style) ==
171 CSS_OVERFLOW_VISIBLE) || !box->style) {
172 if (box->descendant_x0 <= x &&
173 x < box->descendant_x1) {
174 *physically = false;
175 return true;
176 }
177 }
178 if ((box->style && css_computed_overflow_y(box->style) ==
179 CSS_OVERFLOW_VISIBLE) || !box->style) {
180 if (box->descendant_y0 <= y &&
181 y < box->descendant_y1) {
182 *physically = false;
183 return true;
184 }
185 }
186 return false;
187}
188
189
190/**
191 * Move from box to next box in given direction, adjusting for box coord change
192 *
193 * \param b box to move from from
194 * \param dir direction to move in
195 * \param x box's global x-coord, updated to position of next box
196 * \param y box's global y-coord, updated to position of next box
197 *
198 * If no box can be found in given direction, NULL is returned.
199 */
200static inline struct box *
201box_move_xy(struct box *b, enum box_walk_dir dir, int *x, int *y)
202{
203 struct box *rb = NULL;
204
205 switch (dir) {
207 b = b->children;
208 if (b == NULL)
209 break;
210 *x += b->x;
211 *y += b->y;
212 if (!box_is_float(b)) {
213 rb = b;
214 break;
215 }
217
219 do {
220 *x -= b->x;
221 *y -= b->y;
222 b = b->next;
223 if (b == NULL)
224 break;
225 *x += b->x;
226 *y += b->y;
227 } while (box_is_float(b));
228 rb = b;
229 break;
230
231 case BOX_WALK_PARENT:
232 *x -= b->x;
233 *y -= b->y;
234 rb = b->parent;
235 break;
236
238 b = b->float_children;
239 if (b == NULL)
240 break;
241 *x += b->x;
242 *y += b->y;
243 rb = b;
244 break;
245
247 *x -= b->x;
248 *y -= b->y;
249 b = b->next_float;
250 if (b == NULL)
251 break;
252 *x += b->x;
253 *y += b->y;
254 rb = b;
255 break;
256
258 *x -= b->x;
259 *y -= b->y;
260 rb = b->float_container;
261 break;
262
263 default:
264 assert(0 && "Bad box walk type.");
265 }
266
267 return rb;
268}
269
270
271/**
272 * Itterator for walking to next box in interaction order
273 *
274 * \param b box to find next box from
275 * \param x box's global x-coord, updated to position of next box
276 * \param y box's global y-coord, updated to position of next box
277 * \param skip_children whether to skip box's children
278 *
279 * This walks to a boxes float children before its children. When walking
280 * children, floating boxes are skipped.
281 */
282static inline struct box *
283box_next_xy(struct box *b, int *x, int *y, bool skip_children)
284{
285 struct box *n;
286 int tx, ty;
287
288 assert(b != NULL);
289
290 if (skip_children) {
291 /* Caller is not interested in any kind of children */
292 goto skip_children;
293 }
294
295 tx = *x; ty = *y;
296 n = box_move_xy(b, BOX_WALK_FLOAT_CHILDREN, &tx, &ty);
297 if (n) {
298 /* Next node is float child */
299 *x = tx;
300 *y = ty;
301 return n;
302 }
303 done_float_children:
304
305 tx = *x; ty = *y;
306 n = box_move_xy(b, BOX_WALK_CHILDREN, &tx, &ty);
307 if (n) {
308 /* Next node is child */
309 *x = tx;
310 *y = ty;
311 return n;
312 }
313
314 skip_children:
315 tx = *x; ty = *y;
317 if (n) {
318 /* Go to next float sibling */
319 *x = tx;
320 *y = ty;
321 return n;
322 }
323
324 if (box_is_float(b)) {
325 /* Done floats, but the float container may have children,
326 * or siblings, or ansestors with siblings. Change to
327 * float container and move past handling its float children.
328 */
330 goto done_float_children;
331 }
332
333 /* Go to next sibling, or nearest ancestor with next sibling. */
334 while (b) {
335 while (!b->next && b->parent) {
336 b = box_move_xy(b, BOX_WALK_PARENT, x, y);
337 if (box_is_float(b)) {
338 /* Go on to next float, if there is one */
339 goto skip_children;
340 }
341 }
342 if (!b->next) {
343 /* No more boxes */
344 return NULL;
345 }
346
347 tx = *x; ty = *y;
348 n = box_move_xy(b, BOX_WALK_NEXT_SIBLING, &tx, &ty);
349 if (n) {
350 /* Go to non-float (ancestor) sibling */
351 *x = tx;
352 *y = ty;
353 return n;
354
355 } else if (b->parent) {
356 b = box_move_xy(b, BOX_WALK_PARENT, x, y);
357 if (box_is_float(b)) {
358 /* Go on to next float, if there is one */
359 goto skip_children;
360 }
361
362 } else {
363 /* No more boxes */
364 return NULL;
365 }
366 }
367
368 assert(b != NULL);
369 return NULL;
370}
371
372
373/**
374 * Check whether box is nearer mouse coordinates than current nearest box
375 *
376 * \param box box to test
377 * \param bx position of box, in global document coordinates
378 * \param by position of box, in global document coordinates
379 * \param x mouse point, in global document coordinates
380 * \param y mouse point, in global document coordinates
381 * \param dir direction in which to search (-1 = above-left,
382 * +1 = below-right)
383 * \param nearest nearest text box found, or NULL if none
384 * updated if box is nearer than existing nearest
385 * \param tx position of text_box, in global document coordinates
386 * updated if box is nearer than existing nearest
387 * \param ty position of text_box, in global document coordinates
388 * updated if box is nearer than existing nearest
389 * \param nr_xd distance to nearest text box found
390 * updated if box is nearer than existing nearest
391 * \param nr_yd distance to nearest text box found
392 * updated if box is nearer than existing nearest
393 * \return true if mouse point is inside box
394 */
395static bool
397 int bx, int by,
398 int x, int y,
399 int dir,
400 struct box **nearest,
401 int *tx, int *ty,
402 int *nr_xd, int *nr_yd)
403{
404 int w = box->padding[LEFT] + box->width + box->padding[RIGHT];
405 int h = box->padding[TOP] + box->height + box->padding[BOTTOM];
406 int y1 = by + h;
407 int x1 = bx + w;
408 int yd = INT_MAX;
409 int xd = INT_MAX;
410
411 if (x >= bx && x1 > x && y >= by && y1 > y) {
412 *nearest = box;
413 *tx = bx;
414 *ty = by;
415 return true;
416 }
417
418 if (box->parent->list_marker != box) {
419 if (dir < 0) {
420 /* consider only those children (partly) above-left */
421 if (by <= y && bx < x) {
422 yd = y <= y1 ? 0 : y - y1;
423 xd = x <= x1 ? 0 : x - x1;
424 }
425 } else {
426 /* consider only those children (partly) below-right */
427 if (y1 > y && x1 > x) {
428 yd = y > by ? 0 : by - y;
429 xd = x > bx ? 0 : bx - x;
430 }
431 }
432
433 /* give y displacement precedence over x */
434 if (yd < *nr_yd || (yd == *nr_yd && xd <= *nr_xd)) {
435 *nr_yd = yd;
436 *nr_xd = xd;
437 *nearest = box;
438 *tx = bx;
439 *ty = by;
440 }
441 }
442 return false;
443}
444
445
446/**
447 * Pick the text box child of 'box' that is closest to and above-left
448 * (dir -ve) or below-right (dir +ve) of the point 'x,y'
449 *
450 * \param box parent box
451 * \param bx position of box, in global document coordinates
452 * \param by position of box, in global document coordinates
453 * \param fx position of float parent, in global document coordinates
454 * \param fy position of float parent, in global document coordinates
455 * \param x mouse point, in global document coordinates
456 * \param y mouse point, in global document coordinates
457 * \param dir direction in which to search (-1 = above-left,
458 * +1 = below-right)
459 * \param nearest nearest text box found, or NULL if none
460 * updated if a descendant of box is nearer than old nearest
461 * \param tx position of nearest, in global document coordinates
462 * updated if a descendant of box is nearer than old nearest
463 * \param ty position of nearest, in global document coordinates
464 * updated if a descendant of box is nearer than old nearest
465 * \param nr_xd distance to nearest text box found
466 * updated if a descendant of box is nearer than old nearest
467 * \param nr_yd distance to nearest text box found
468 * updated if a descendant of box is nearer than old nearest
469 * \return true if mouse point is inside text_box
470 */
471static bool
473 int bx, int by,
474 int fx, int fy,
475 int x, int y,
476 int dir,
477 struct box **nearest,
478 int *tx, int *ty,
479 int *nr_xd, int *nr_yd)
480{
481 struct box *child = box->children;
482 int c_bx, c_by;
483 int c_fx, c_fy;
484 bool in_box = false;
485
486 if (*nearest == NULL) {
487 *nr_xd = INT_MAX / 2; /* displacement of 'nearest so far' */
488 *nr_yd = INT_MAX / 2;
489 }
490 if (box->type == BOX_INLINE_CONTAINER) {
491 int bw = box->padding[LEFT] + box->width + box->padding[RIGHT];
492 int bh = box->padding[TOP] + box->height + box->padding[BOTTOM];
493 int b_y1 = by + bh;
494 int b_x1 = bx + bw;
495 if (x >= bx && b_x1 > x && y >= by && b_y1 > y) {
496 in_box = true;
497 }
498 }
499
500 while (child) {
501 if (child->type == BOX_FLOAT_LEFT ||
502 child->type == BOX_FLOAT_RIGHT) {
503 c_bx = fx + child->x -
505 c_by = fy + child->y -
507 } else {
508 c_bx = bx + child->x -
510 c_by = by + child->y -
512 }
513 if (child->float_children) {
514 c_fx = c_bx;
515 c_fy = c_by;
516 } else {
517 c_fx = fx;
518 c_fy = fy;
519 }
520 if (in_box && child->text && !child->object) {
521 if (box_nearer_text_box(child,
522 c_bx, c_by, x, y, dir, nearest,
523 tx, ty, nr_xd, nr_yd))
524 return true;
525 } else {
526 if (child->list_marker) {
528 child->list_marker,
529 c_bx + child->list_marker->x,
530 c_by + child->list_marker->y,
531 x, y, dir, nearest,
532 tx, ty, nr_xd, nr_yd))
533 return true;
534 }
535 if (box_nearest_text_box(child, c_bx, c_by,
536 c_fx, c_fy,
537 x, y, dir, nearest, tx, ty,
538 nr_xd, nr_yd))
539 return true;
540 }
541 child = child->next;
542 }
543
544 return false;
545}
546
547
548/* Exported function documented in html/box.h */
549void box_coords(struct box *box, int *x, int *y)
550{
551 *x = box->x;
552 *y = box->y;
553 while (box->parent) {
554 if (box_is_float(box)) {
555 assert(box->float_container);
557 } else {
558 box = box->parent;
559 }
562 }
563}
564
565
566/* Exported function documented in html/box.h */
567void box_bounds(struct box *box, struct rect *r)
568{
569 int width, height;
570
571 box_coords(box, &r->x0, &r->y0);
572
575
576 r->x1 = r->x0 + width;
577 r->y1 = r->y0 + height;
578}
579
580
581/* Exported function documented in html/box.h */
582struct box *
583box_at_point(const css_unit_ctx *unit_len_ctx,
584 struct box *box,
585 const int x, const int y,
586 int *box_x, int *box_y)
587{
588 bool skip_children;
589 bool physically;
590
591 assert(box);
592
593 skip_children = false;
594 while ((box = box_next_xy(box, box_x, box_y, skip_children))) {
595 if (box_contains_point(unit_len_ctx, box, x - *box_x, y - *box_y,
596 &physically)) {
599
600 if (physically)
601 return box;
602
603 skip_children = false;
604 } else {
605 skip_children = true;
606 }
607 }
608
609 return NULL;
610}
611
612
613/* Exported function documented in html/box.h */
614struct box *box_find_by_id(struct box *box, lwc_string *id)
615{
616 struct box *a, *b;
617 bool m;
618
619 if (box->id != NULL &&
620 lwc_string_isequal(id, box->id, &m) == lwc_error_ok &&
621 m == true) {
622 return box;
623 }
624
625 for (a = box->children; a; a = a->next) {
626 if ((b = box_find_by_id(a, id)) != NULL) {
627 return b;
628 }
629 }
630
631 return NULL;
632}
633
634
635/* Exported function documented in html/box.h */
636bool box_visible(struct box *box)
637{
638 /* visibility: hidden */
639 if (box->style &&
640 css_computed_visibility(box->style) == CSS_VISIBILITY_HIDDEN) {
641 return false;
642 }
643
644 return true;
645}
646
647
648/* Exported function documented in html/box.h */
649void box_dump(FILE *stream, struct box *box, unsigned int depth, bool style)
650{
651 unsigned int i;
652 struct box *c, *prev;
653
654 for (i = 0; i != depth; i++) {
655 fprintf(stream, " ");
656 }
657
658 fprintf(stream, "%p ", box);
659 fprintf(stream, "x%i y%i w%i h%i ",
660 box->x, box->y, box->width, box->height);
662 fprintf(stream, "min%i max%i ", box->min_width, box->max_width);
663 }
664 fprintf(stream, "desc(%i %i %i %i) ",
667
668 fprintf(stream, "m(%i %i %i %i) ",
671
672 switch (box->type) {
673 case BOX_BLOCK:
674 fprintf(stream, "BLOCK ");
675 break;
676
678 fprintf(stream, "INLINE_CONTAINER ");
679 break;
680
681 case BOX_INLINE:
682 fprintf(stream, "INLINE ");
683 break;
684
685 case BOX_INLINE_END:
686 fprintf(stream, "INLINE_END ");
687 break;
688
689 case BOX_INLINE_BLOCK:
690 fprintf(stream, "INLINE_BLOCK ");
691 break;
692
693 case BOX_TABLE:
694 fprintf(stream, "TABLE [columns %i] ", box->columns);
695 break;
696
697 case BOX_TABLE_ROW:
698 fprintf(stream, "TABLE_ROW ");
699 break;
700
701 case BOX_TABLE_CELL:
702 fprintf(stream, "TABLE_CELL [columns %i, start %i, rows %i] ",
703 box->columns,
705 box->rows);
706 break;
707
709 fprintf(stream, "TABLE_ROW_GROUP ");
710 break;
711
712 case BOX_FLOAT_LEFT:
713 fprintf(stream, "FLOAT_LEFT ");
714 break;
715
716 case BOX_FLOAT_RIGHT:
717 fprintf(stream, "FLOAT_RIGHT ");
718 break;
719
720 case BOX_BR:
721 fprintf(stream, "BR ");
722 break;
723
724 case BOX_TEXT:
725 fprintf(stream, "TEXT ");
726 break;
727
728 case BOX_FLEX:
729 fprintf(stream, "FLEX ");
730 break;
731
732 case BOX_INLINE_FLEX:
733 fprintf(stream, "INLINE_FLEX ");
734 break;
735
736 default:
737 fprintf(stream, "Unknown box type ");
738 }
739
740 if (box->text)
741 fprintf(stream, "%li '%.*s' ", (unsigned long) box->byte_offset,
742 (int) box->length, box->text);
743 if (box->space)
744 fprintf(stream, "space ");
745 if (box->object) {
746 fprintf(stream, "(object '%s') ",
748 }
749 if (box->iframe) {
750 fprintf(stream, "(iframe) ");
751 }
752 if (box->gadget)
753 fprintf(stream, "(gadget) ");
754 if (style && box->style)
756 if (box->href)
757 fprintf(stream, " -> '%s'", nsurl_access(box->href));
758 if (box->target)
759 fprintf(stream, " |%s|", box->target);
760 if (box->title)
761 fprintf(stream, " [%s]", box->title);
762 if (box->id)
763 fprintf(stream, " ID:%s", lwc_string_data(box->id));
764 if (box->type == BOX_INLINE || box->type == BOX_INLINE_END)
765 fprintf(stream, " inline_end %p", box->inline_end);
766 if (box->float_children)
767 fprintf(stream, " float_children %p", box->float_children);
768 if (box->next_float)
769 fprintf(stream, " next_float %p", box->next_float);
770 if (box->float_container)
771 fprintf(stream, " float_container %p", box->float_container);
772 if (box->col) {
773 fprintf(stream, " (columns");
774 for (i = 0; i != box->columns; i++) {
775 fprintf(stream, " (%s %s %i %i %i)",
776 ((const char *[]) {
777 "UNKNOWN",
778 "FIXED",
779 "AUTO",
780 "PERCENT",
781 "RELATIVE"
782 })
783 [box->col[i].type],
784 ((const char *[]) {
785 "normal",
786 "positioned"})
787 [box->col[i].positioned],
788 box->col[i].width,
789 box->col[i].min, box->col[i].max);
790 }
791 fprintf(stream, ")");
792 }
793 if (box->node != NULL) {
794 dom_string *name;
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);
798 }
799 }
800 fprintf(stream, "\n");
801
802 if (box->list_marker) {
803 for (i = 0; i != depth; i++)
804 fprintf(stream, " ");
805 fprintf(stream, "list_marker:\n");
806 box_dump(stream, box->list_marker, depth + 1, style);
807 }
808
809 for (c = box->children; c && c->next; c = c->next)
810 ;
811 if (box->last != c)
812 fprintf(stream, "warning: box->last %p (should be %p) "
813 "(box %p)\n", box->last, c, box);
814 for (prev = 0, c = box->children; c; prev = c, c = c->next) {
815 if (c->parent != box)
816 fprintf(stream, "warning: box->parent %p (should be "
817 "%p) (box on next line)\n",
818 c->parent, box);
819 if (c->prev != prev)
820 fprintf(stream, "warning: box->prev %p (should be "
821 "%p) (box on next line)\n",
822 c->prev, prev);
823 box_dump(stream, c, depth + 1, style);
824 }
825}
826
827
828/* exported interface documented in html/box.h */
829bool box_vscrollbar_present(const struct box * const box)
830{
831 return box->padding[TOP] +
832 box->height +
833 box->padding[BOTTOM] +
835}
836
837
838/* exported interface documented in html/box.h */
839bool box_hscrollbar_present(const struct box * const box)
840{
841 return box->padding[LEFT] +
842 box->width +
843 box->padding[RIGHT] +
845}
846
847
848/* Exported function documented in html/box.h */
849struct box *
851 int x, int y,
852 int dir,
853 int *dx, int *dy)
854{
855 struct box *text_box = NULL;
856 struct box *box;
857 int nr_xd, nr_yd;
858 int bx, by;
859 int fx, fy;
860 int tx, ty;
861
862 if (html == NULL)
863 return NULL;
864
865 box = html->layout;
866 bx = box->margin[LEFT];
867 by = box->margin[TOP];
868 fx = bx;
869 fy = by;
870
871 if (!box_nearest_text_box(box, bx, by, fx, fy, x, y,
872 dir, &text_box, &tx, &ty, &nr_xd, &nr_yd)) {
873 if (text_box && text_box->text && !text_box->object) {
874 int w = (text_box->padding[LEFT] +
875 text_box->width +
876 text_box->padding[RIGHT]);
877 int h = (text_box->padding[TOP] +
878 text_box->height +
879 text_box->padding[BOTTOM]);
880 int x1, y1;
881
882 y1 = ty + h;
883 x1 = tx + w;
884
885 /* ensure point lies within the text box */
886 if (x < tx) x = tx;
887 if (y < ty) y = ty;
888 if (y > y1) y = y1;
889 if (x > x1) x = x1;
890 }
891 }
892
893 /* return coordinates relative to box */
894 *dx = x - tx;
895 *dy = y - ty;
896
897 return text_box;
898}
Box interface.
#define UNKNOWN_MAX_WIDTH
Definition: box.h:46
@ BOX_BLOCK
Definition: box.h:56
@ BOX_FLOAT_LEFT
Definition: box.h:63
@ BOX_INLINE_BLOCK
Definition: box.h:65
@ BOX_FLOAT_RIGHT
Definition: box.h:64
@ BOX_INLINE_CONTAINER
Definition: box.h:57
@ BOX_TABLE_CELL
Definition: box.h:61
@ BOX_TABLE_ROW_GROUP
Definition: box.h:62
@ BOX_INLINE_END
Definition: box.h:68
@ BOX_TABLE
Definition: box.h:59
@ BOX_INLINE
Definition: box.h:58
@ BOX_TABLE_ROW
Definition: box.h:60
@ BOX_TEXT
Definition: box.h:67
@ BOX_INLINE_FLEX
Definition: box.h:71
@ BOX_BR
Definition: box.h:66
@ BOX_FLEX
Definition: box.h:70
@ TOP
Definition: box.h:98
@ BOTTOM
Definition: box.h:98
@ LEFT
Definition: box.h:98
@ RIGHT
Definition: box.h:98
bool box_hscrollbar_present(const struct box *const box)
Determine if a box has a horizontal scrollbar.
Definition: box_inspect.c:839
#define box_is_float(box)
Definition: box_inspect.c:54
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.
Definition: box_inspect.c:75
bool box_vscrollbar_present(const struct box *const box)
Determine if a box has a vertical scrollbar.
Definition: box_inspect.c:829
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
void box_coords(struct box *box, int *x, int *y)
Find the absolute coordinates of a box.
Definition: box_inspect.c:549
void box_bounds(struct box *box, struct rect *r)
Find the bounds of a box.
Definition: box_inspect.c:567
box_walk_dir
Direction to move in a box-tree walk.
Definition: box_inspect.c:45
@ BOX_WALK_CHILDREN
Definition: box_inspect.c:46
@ BOX_WALK_FLOAT_CONTAINER
Definition: box_inspect.c:51
@ BOX_WALK_NEXT_SIBLING
Definition: box_inspect.c:48
@ BOX_WALK_PARENT
Definition: box_inspect.c:47
@ BOX_WALK_NEXT_FLOAT_SIBLING
Definition: box_inspect.c:50
@ BOX_WALK_FLOAT_CHILDREN
Definition: box_inspect.c:49
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.
Definition: box_inspect.c:283
bool box_visible(struct box *box)
Determine if a box is visible when the tree is rendered.
Definition: box_inspect.c:636
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)...
Definition: box_inspect.c:472
struct box * box_find_by_id(struct box *box, lwc_string *id)
Find a box based upon its id attribute.
Definition: box_inspect.c:614
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.
Definition: box_inspect.c:396
void box_dump(FILE *stream, struct box *box, unsigned int depth, bool style)
Print a box tree to a file.
Definition: box_inspect.c:649
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,...
Definition: box_inspect.c:850
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.
Definition: box_inspect.c:201
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.
Definition: dump.c:155
Error codes.
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
Definition: gui.c:160
int height
Definition: gui.c:161
int scrollbar_get_offset(struct scrollbar *s)
Get the current scroll offset to the visible part of the full area.
Definition: scrollbar.c:628
Scrollbar widget interface.
int width
border-width (pixels)
Definition: box.h:107
Node in box tree.
Definition: box.h:177
int descendant_y1
bottom edge of descendants
Definition: box.h:312
struct box_border border[4]
Border: TOP, RIGHT, BOTTOM, LEFT.
Definition: box.h:327
int min_width
Width of box taking all line breaks (including margins etc).
Definition: box.h:343
int width
Width of content box (excluding padding etc.).
Definition: box.h:289
struct box * parent
Parent box, or NULL.
Definition: box.h:236
struct scrollbar * scroll_x
Horizontal scroll.
Definition: box.h:332
lwc_string * id
value of id attribute (or name for anchors)
Definition: box.h:210
size_t byte_offset
Byte offset within a textual representation of this content.
Definition: box.h:370
struct column * col
Array of table column data for TABLE only.
Definition: box.h:407
const char * title
Title, or NULL.
Definition: box.h:386
struct box * inline_end
INLINE_END box corresponding to this INLINE box, or INLINE box corresponding to this INLINE_END box.
Definition: box.h:242
struct box * children
First child box, or NULL.
Definition: box.h:226
int height
Height of content box (excluding padding etc.).
Definition: box.h:293
struct box * float_container
If box is a float, points to box's containing block.
Definition: box.h:261
struct box * prev
Previous sibling box, or NULL.
Definition: box.h:221
struct box * list_marker
List marker box if this is a list-item, or NULL.
Definition: box.h:417
int margin[4]
Margin: TOP, RIGHT, BOTTOM, LEFT.
Definition: box.h:317
int max_width
Width that would be taken with no line breaks.
Definition: box.h:349
const char * target
Link target, or NULL.
Definition: box.h:381
struct box * next_float
Next sibling float box.
Definition: box.h:256
struct box * last
Last child box, or NULL.
Definition: box.h:231
struct box * next
Next sibling box, or NULL.
Definition: box.h:216
int descendant_x0
left edge of descendants
Definition: box.h:309
struct scrollbar * scroll_y
Vertical scroll.
Definition: box.h:337
unsigned int start_column
Start column for TABLE_CELL only.
Definition: box.h:402
box_type type
Type of box.
Definition: box.h:181
struct nsurl * href
Link, or NULL.
Definition: box.h:376
struct box * float_children
First float child box, or NULL.
Definition: box.h:251
int descendant_x1
right edge of descendants
Definition: box.h:311
struct browser_window * iframe
Iframe's browser_window, or NULL if none.
Definition: box.h:452
css_computed_style * style
Style for this box.
Definition: box.h:205
size_t length
Length of text.
Definition: box.h:360
struct hlcache_handle * object
Object in this box (usually an image), or NULL if none.
Definition: box.h:441
char * text
Text, or NULL if none.
Definition: box.h:355
int padding[4]
Padding: TOP, RIGHT, BOTTOM, LEFT.
Definition: box.h:322
int x
Coordinate of left padding edge relative to parent box, or relative to ancestor that contains this bo...
Definition: box.h:280
int space
Width of space after current text (depends on font and size).
Definition: box.h:365
struct form_control * gadget
Form control data, or NULL if not a form control.
Definition: box.h:423
int descendant_y0
top edge of descendants
Definition: box.h:310
unsigned int rows
Number of rows for TABLE only.
Definition: box.h:397
struct dom_node * node
DOM node that generated this box or NULL.
Definition: box.h:191
unsigned int columns
Number of columns for TABLE / TABLE_CELL.
Definition: box.h:392
int y
Coordinate of top padding edge, relative as for x.
Definition: box.h:284
bool positioned
Whether all of column's cells are css positioned.
Definition: box.h:145
int width
Preferred width of column.
Definition: box.h:130
int max
Maximum width of content.
Definition: box.h:140
enum column::@131 type
Type of column.
int min
Minimum width of content.
Definition: box.h:135
Data specific to CONTENT_HTML.
Definition: private.h:93
struct box * layout
Box tree, or NULL.
Definition: private.h:140
Rectangle coordinates.
Definition: types.h:40
int x0
Definition: types.h:41
int y0
Top left.
Definition: types.h:41
int x1
Definition: types.h:42
int y1
Bottom right.
Definition: types.h:42
NetSurf types.
Interface to a number of general purpose functionality.
#define fallthrough
switch fall through
Definition: utils.h:119