Skip to content

Commit bdae1b5

Browse files
committed
Revert "speed up loading of toc for epub by not resolving toc url destiantion to a page, which requires layout of everything" (fixes #5514)
This reverts commit 57b4a8d.
1 parent 72fb7a0 commit bdae1b5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/EngineMupdf.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ static int ResolveLink(fz_context* ctx, fz_document* doc, const char* uri, float
171171
return pageNo + 1;
172172
}
173173

174+
static int FzGetPageNo(fz_context* ctx, fz_document* doc, fz_link* link, fz_outline* outline) {
175+
float x, y;
176+
const char* uri = link ? link->uri : outline ? outline->uri : nullptr;
177+
int pageNo = ResolveLink(ctx, doc, uri, &x, &y);
178+
return pageNo;
179+
}
180+
174181
static IPageDestination* NewPageDestinationMupdf(fz_context* ctx, fz_document* doc, fz_link* link,
175182
fz_outline* outline) {
176183
ReportIf(link && outline);
@@ -218,7 +225,7 @@ static IPageDestination* NewPageDestinationMupdf(fz_context* ctx, fz_document* d
218225

219226
auto dest = new PageDestinationMupdf(link, outline);
220227
dest->rect = FzGetRectF(link, outline);
221-
// pageNo is resolved lazily in HandleLinkMupdf when navigating
228+
dest->pageNo = FzGetPageNo(ctx, doc, link, outline);
222229
return dest;
223230
}
224231

@@ -2492,6 +2499,8 @@ TocItem* EngineMupdf::BuildTocTree(TocItem* parent, fz_outline* outline, int& id
24922499
name = str::Dup("");
24932500
}
24942501

2502+
int pageNo = FzGetPageNo(ctx, _doc, nullptr, outline);
2503+
24952504
IPageDestination* dest = nullptr;
24962505
if (isAttachment) {
24972506
dest = DestFromAttachment(this, outline);
@@ -2504,8 +2513,8 @@ TocItem* EngineMupdf::BuildTocTree(TocItem* parent, fz_outline* outline, int& id
25042513
item->isOpenDefault = outline->is_open;
25052514
item->id = ++idCounter;
25062515
item->fontFlags = 0; // TODO: had outline->flags; but mupdf changed outline
2507-
// pageNo is resolved lazily in HandleLinkMupdf when navigating
2508-
item->pageNo = 0;
2516+
item->pageNo = pageNo;
2517+
ReportIf(!isAttachment && !item->PageNumbersMatch());
25092518

25102519
// TODO: had outline->n_color and outline->color but mupdf changed outline
25112520
/*

0 commit comments

Comments
 (0)