summaryrefslogtreecommitdiff
path: root/source/html
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-11-15 16:25:20 +0100
committerTor Andersson <tor.andersson@artifex.com>2016-11-16 12:24:29 +0100
commitadaa08a921d32f3c1600c5c855e7da9ffb8a994a (patch)
treec28a5898ec4704d4c5cbc82d71539c96a749cc8b /source/html
parent00043f2f93a344319e4e282087646f082bffe8dd (diff)
downloadmupdf-adaa08a921d32f3c1600c5c855e7da9ffb8a994a.tar.xz
Fix 697335: Handle links with content in nested tag.
We would not create a link box for the "bar" text in links of the form: <a href="foo"><span>bar</span></a>.
Diffstat (limited to 'source/html')
-rw-r--r--source/html/html-layout.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/source/html/html-layout.c b/source/html/html-layout.c
index 945149f4..95f2a76b 100644
--- a/source/html/html-layout.c
+++ b/source/html/html-layout.c
@@ -1906,19 +1906,43 @@ static int is_internal_uri(const char *uri)
return 1;
}
+static const char *box_href(fz_html_box *box)
+{
+ while (box)
+ {
+ const char *href = box->href;
+ if (href)
+ return href;
+ box = box->up;
+ }
+ return NULL;
+}
+
+static int has_same_href(fz_html_box *box, const char *old_href)
+{
+ while (box)
+ {
+ const char *href = box->href;
+ if (href)
+ return !strcmp(old_href, href);
+ box = box->up;
+ }
+ return 0;
+}
+
static fz_link *load_link_flow(fz_context *ctx, fz_html_flow *flow, fz_link *head, int page, int page_h, const char *dir, const char *file)
{
fz_link *link;
fz_html_flow *next;
char path[2048];
fz_rect bbox;
- char *dest;
- char *href;
+ const char *dest;
+ const char *href;
float end;
while (flow)
{
- href = flow->box->href;
+ href = box_href(flow->box);
next = flow->next;
if (href && (int)(flow->y / page_h) == page)
{
@@ -1927,8 +1951,7 @@ static fz_link *load_link_flow(fz_context *ctx, fz_html_flow *flow, fz_link *hea
while (next &&
next->y == flow->y &&
next->h == flow->h &&
- next->box->href &&
- !strcmp(href, next->box->href))
+ has_same_href(next->box, href))
{
end = next->x + next->w;
next = next->next;