Преглед изворни кода

Record hitboxes for floated anchor links

Bootstrap navbars put each item in a floated <a>, but layout_float_group()
laid the float out with the inherited link instead of the anchor's own href.
The text was painted correctly, yet no hitbox was recorded, so clicks on the
visible navbar items found no node.

Propagate the qualified link into the float group and switch to the floated
anchor's href before laying out its contents.  The Cloudron topbar items now
register hitboxes on their visible row (/store, docs, forum, pricing, get and
console).

Verified with a hitbox dump against the local Cloudron fixture; the browser
pack, floppy, USB and UEFI images were rebuilt.
Johannes Zellner пре 1 недеља
родитељ
комит
436e6149b7
1 измењених фајлова са 5 додато и 2 уклоњено
  1. 5 2
      browser.c

+ 5 - 2
browser.c

@@ -2826,6 +2826,7 @@ static unsigned int layout_float_group(struct lay *l, unsigned int first,
 	while (n) {
 	while (n) {
 		struct br_node *nd = &doc.nodes[n];
 		struct br_node *nd = &doc.nodes[n];
 		struct br_style cs;
 		struct br_style cs;
+		unsigned short lk = link;
 		int colw;
 		int colw;
 
 
 		if (nd->type == BR_NODE_TEXT) {
 		if (nd->type == BR_NODE_TEXT) {
@@ -2842,6 +2843,8 @@ static unsigned int layout_float_group(struct lay *l, unsigned int first,
 		}
 		}
 		if (!cs.float_left || cs.display != BR_DISPLAY_BLOCK)
 		if (!cs.float_left || cs.display != BR_DISPLAY_BLOCK)
 			break;
 			break;
+		if (nd->tag == BR_TAG_A && nd->href_off)
+			lk = (unsigned short)n;
 		if (cs.width_kind == 2)
 		if (cs.width_kind == 2)
 			colw = (row_right - row_left) * (int)cs.width / 100;
 			colw = (row_right - row_left) * (int)cs.width / 100;
 		else if (cs.width_kind == 1)
 		else if (cs.width_kind == 1)
@@ -2873,7 +2876,7 @@ static unsigned int layout_float_group(struct lay *l, unsigned int first,
 		l->nruns = 0;
 		l->nruns = 0;
 		l->space_pending = 0;
 		l->space_pending = 0;
 		l->align = cs.align;
 		l->align = cs.align;
-		layout_block(l, n, &cs, depth + 1, link);
+		layout_block(l, n, &cs, depth + 1, lk);
 		if (l->y > row_bottom)
 		if (l->y > row_bottom)
 			row_bottom = l->y;
 			row_bottom = l->y;
 		x += colw;
 		x += colw;
@@ -3552,7 +3555,7 @@ static void layout_children(struct lay *l, unsigned int parent,
 			continue;
 			continue;
 		}
 		}
 		if (cs.float_left && cs.display == BR_DISPLAY_BLOCK) {
 		if (cs.float_left && cs.display == BR_DISPLAY_BLOCK) {
-			n = layout_float_group(l, n, pst, depth, link);
+			n = layout_float_group(l, n, pst, depth, lk);
 			continue;
 			continue;
 		}
 		}
 		if (cs.display == BR_DISPLAY_INLINE_BLOCK) {
 		if (cs.display == BR_DISPLAY_INLINE_BLOCK) {