[PATCH] nsvi: use box_coords to get the absolute coordinates
Export this patch
The previous method didn't handle some edge cases relating to float
elements, which sometimes lead to hints placed in the wrong place.
---
frontends/visurf/commands.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/frontends/visurf/commands.c b/frontends/visurf/commands.c
index 2541d7fbe..da98be36b 100644
--- a/frontends/visurf/commands.c
+++ b/frontends/visurf/commands.c
@@ -11,6 +11,7 @@
#include "content/content.h"
#include "content/content_protected.h"
#include "content/handlers/html/box.h"
+#include "content/handlers/html/box_inspect.h"
#include "content/handlers/html/html.h"
#include "content/handlers/html/html_save.h"
#include "content/hlcache.h"
@@ -167,7 +168,7 @@ cmd_exline(struct nsvi_state *state, int argc, char *argv[])
}
static void
-follow_collect_hints(struct gui_window *win, struct box *node, int x, int y)
+follow_collect_hints(struct gui_window *win, struct box *node)
{
struct follow_state *follow = &win->follow;
if ((node->href || node->gadget) && node->width > 0 && node->height > 0) {
@@ -181,15 +182,13 @@ follow_collect_hints(struct gui_window *win, struct box *node, int x, int y)
follow->zhint * sizeof(struct link_hint));
}
struct link_hint *hint = &follow->hints[follow->nhint];
- float scale = browser_window_get_scale(win->bw);
- hint->x = lroundf(scale * (x + node->x));
- hint->y = lroundf(scale * (y + node->y));
hint->width = node->width, hint->height = node->height;
+ box_coords(node, &hint->x, &hint->y);
hint->node = node;
++follow->nhint;
}
for (struct box *child = node->children; child; child = child->next) {
- follow_collect_hints(win, child, x + node->x, y + node->y);
+ follow_collect_hints(win, child);
}
}
@@ -357,7 +356,7 @@ cmd_follow(struct nsvi_state *state, int argc, char *argv[])
return 1;
}
struct box *tree = html_get_box_tree(handle);
- follow_collect_hints(gw, tree, 0, 0);
+ follow_collect_hints(gw, tree);
if (gw->follow.nhint == 0) {
NSLOG(netsurf, ERROR, "follow: no hints");
handle_error(strdup("follow: no hints"));
--
2.35.1
Thanks!
To git@git.sr.ht:~sircmpwn/visurf
14d9df0a4..8f7036e44 master -> master