~sircmpwn/visurf-devel

nsvi: fix duplicated hints v1 APPLIED

Eyal Sawady: 1
 nsvi: fix duplicated hints

 1 files changed, 8 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/visurf-devel/patches/29901/mbox | git am -3
Learn more about email & git

[PATCH] nsvi: fix duplicated hints Export this patch

In some cases, a single href can be propagated to multiple nodes. Search
through previous hints to avoid hinting the same href twice.

Minimal reproduction:

<body>
<a href="foo">bar&amp;baz</a>
---
I tested this and made sure that both gadgets and multiple hints with
the same target still work
 frontends/visurf/commands.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/frontends/visurf/commands.c b/frontends/visurf/commands.c
index 2541d7fbe..6b12e362b 100644
--- a/frontends/visurf/commands.c
+++ b/frontends/visurf/commands.c
@@ -171,6 +171,12 @@ follow_collect_hints(struct gui_window *win, struct box *node, int x, int y)
{
	struct follow_state *follow = &win->follow;
	if ((node->href || node->gadget) && node->width > 0 && node->height > 0) {
		for (size_t i = 0; i < follow->nhint; i++) {
			if (node->href == follow->hints[i].node->href
					&& node->href != NULL) {
				goto end;
			}
		}
		if (!follow->hints) {
			follow->hints = calloc(64, sizeof(struct link_hint));
			follow->nhint = 0;
@@ -188,6 +194,8 @@ follow_collect_hints(struct gui_window *win, struct box *node, int x, int y)
		hint->node = node;
		++follow->nhint;
	}

end:
	for (struct box *child = node->children; child; child = child->next) {
		follow_collect_hints(win, child, x + node->x, y + node->y);
	}
-- 
2.35.1
Thanks!

To git@git.sr.ht:~sircmpwn/visurf
   14d9df0a4..8f7036e44  master -> master