Review comments

This commit is contained in:
jpirnay
2026-05-23 20:21:11 +02:00
parent 0dc3fc623c
commit 7f61b99be2
8 changed files with 26 additions and 11 deletions
+1 -1
View File
@@ -177,7 +177,7 @@ Only one of (2), (3a), or (3b) writes the cache file `<book-cache>/pagelist.bin`
Written once per book at index time; consumed once per section build. Format:
```
```text
[uint16_t entryCount]
[String href][String anchor][String label] // repeated entryCount times
```
+1 -1
View File
@@ -264,7 +264,7 @@ if (parsedSize != fileSize) {
Per-book cache file produced at index time from one of the EPUB printed-page sources (NCX `<pageList>`, EPUB 3 nav `<nav epub:type="page-list">`, or EPUB 2.01 `page-map.xml`). Consumed once per section build by `Section::createSectionFile`. Absent for books that have no printed-page data.
```
```text
u16 entryCount
struct PageListEntry {
String href; // normalised spine href, e.g. "OEBPS/c9_split_000.xhtml"
+2 -1
View File
@@ -25,10 +25,11 @@ namespace {
// <nav epub:type="page-list"> share the same writer.
template <typename Entry>
void writePageListBin(const std::string& cachePath, const std::vector<Entry>& pageList) {
const auto pageListPath = cachePath + "/pagelist.bin";
if (pageList.empty()) {
Storage.remove(pageListPath.c_str());
return;
}
const auto pageListPath = cachePath + "/pagelist.bin";
FsFile pageListFile;
if (!Storage.openFileForWrite("EBP", pageListPath, pageListFile)) {
LOG_ERR("EBP", "Could not write pagelist.bin");
@@ -507,6 +507,7 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char*
self->recordPageBreakLabel(label);
if (!idAttr.empty()) {
self->anchorData.emplace_back(idAttr, static_cast<uint16_t>(self->completedPageCount));
self->pendingAnchorId = idAttr;
}
}
+7 -1
View File
@@ -68,7 +68,13 @@ void XMLCALL PageMapParser::startElement(void* userData, const XML_Char* name, c
// We only care about <page name="..." href="..."/> elements. The wrapping <page-map>
// root is ignored (no need for a state machine — every page element carries its data).
if (strcmp(name, "page") != 0) {
const char* localName = strrchr(name, ':');
if (localName) {
localName++;
} else {
localName = name;
}
if (strcmp(localName, "page") != 0) {
return;
}
+4 -1
View File
@@ -737,7 +737,10 @@ void EpubReaderActivity::onReaderMenuConfirm(EpubReaderMenuActivity::MenuAction
// Resolve the typed label back to a (href, anchor) by linear scan. Entries are
// small (typically <500 even for long books) and this fires once per user action.
for (const auto& entry : entries) {
if (entry.label == pick.label) {
const auto entryLabelValue = parsePrintedPageLabel(entry.label);
const auto pickLabelValue = parsePrintedPageLabel(pick.label);
if (entry.label == pick.label ||
(entryLabelValue && pickLabelValue && *entryLabelValue == *pickLabelValue)) {
const int spineIdx = epub->resolveHrefToSpineIndex(entry.href);
if (spineIdx < 0) {
LOG_DBG("ERS", "printed-page jump: could not resolve spine for href=%s", entry.href.c_str());
+9 -5
View File
@@ -794,7 +794,7 @@ void BaseTheme::drawStatusBar(GfxRenderer& renderer, const float bookProgress, c
const bool hasProgressText = SETTINGS.statusBarBookProgressPercentage || SETTINGS.statusBarChapterPageCount;
const bool hasStatusItems = hasProgressText || SETTINGS.statusBarBattery || !title.empty() ||
SETTINGS.statusBarTitle != CrossPointSettings::STATUS_BAR_TITLE::HIDE_TITLE ||
(SETTINGS.useClock && SETTINGS.statusBarClock);
(SETTINGS.useClock && SETTINGS.statusBarClock) || !printedPageLabel.empty();
if (!hasStatusItems) {
return;
}
@@ -812,6 +812,9 @@ void BaseTheme::drawStatusBar(GfxRenderer& renderer, const float bookProgress, c
: screenHeight - orientedMarginBottom - paddingBottom - adjacentProgressHeight -
statusItemsHeight + 4;
int progressTextWidth = 0;
const int printedLabelWidth =
printedPageLabel.empty() ? 0 : renderer.getTextWidth(SMALL_FONT_ID, printedPageLabel.c_str());
const int printedLabelGap = printedLabelWidth > 0 && hasProgressText ? 8 : 0;
if (hasProgressText) {
// Right-aligned device page counter / progress percentage. The printed-page label, if any,
@@ -828,16 +831,17 @@ void BaseTheme::drawStatusBar(GfxRenderer& renderer, const float bookProgress, c
}
const int progressStrWidth = renderer.getTextWidth(SMALL_FONT_ID, progressStr);
const int printedLabelWidth =
printedPageLabel.empty() ? 0 : renderer.getTextWidth(SMALL_FONT_ID, printedPageLabel.c_str());
const int printedLabelGap = printedLabelWidth > 0 ? 8 : 0;
progressTextWidth = progressStrWidth + printedLabelGap + printedLabelWidth;
const int textX = screenWidth - metrics.statusBarHorizontalMargin - orientedMarginRight - progressStrWidth;
renderer.drawText(SMALL_FONT_ID, textX, textY, progressStr);
if (!printedPageLabel.empty()) {
if (printedLabelWidth > 0) {
renderer.drawText(SMALL_FONT_ID, textX - printedLabelGap - printedLabelWidth, textY, printedPageLabel.c_str());
}
} else if (printedLabelWidth > 0) {
progressTextWidth = printedLabelWidth;
const int textX = screenWidth - metrics.statusBarHorizontalMargin - orientedMarginRight - printedLabelWidth;
renderer.drawText(SMALL_FONT_ID, textX, textY, printedPageLabel.c_str());
}
// Draw Battery