docs: update tracking for ported PRs #1329, #1143, #1172, #1320, #1325

Add detailed entries to MERGED.md for all 5 ported PRs with context,
changes applied, and differences from upstream. Update upstream-sync.md
tracking table with new entries and sync date.

Made-with: Cursor
This commit is contained in:
cottongin
2026-03-08 05:02:05 -04:00
parent 7fe093b57a
commit 83aa38d1a2
3 changed files with 169 additions and 1 deletions

View File

@@ -0,0 +1,62 @@
# Port 5 Upstream PRs (#1329, #1143, #1172, #1320, #1325)
**Date:** 2026-03-08
**Task:** Port unmerged upstream PRs to the mod across 4 feature branches
## Summary
Ported 5 upstream PRs from `crosspoint-reader/crosspoint-reader` to the mod codebase, organized across 4 phased feature branches:
### Phase 1: PR #1329 — ReaderUtils refactor
**Branch:** `port/1329-reader-utils`
- Created `src/activities/reader/ReaderUtils.h` with shared reader utilities: `GO_HOME_MS`, `applyOrientation()`, `detectPageTurn()`, `displayWithRefreshCycle()`, `renderAntiAliased()`
- Refactored `EpubReaderActivity.cpp` and `TxtReaderActivity.cpp` to use ReaderUtils
- Applied CodeRabbit's `storeBwBuffer()` null-check suggestion
### Phase 2: PRs #1143 + #1172 — TOC fragment navigation + multi-spine TOC
**Branch:** `port/1143-1172-toc-navigation`
- Extended `Section.h/.cpp` with TOC boundary tracking (`tocBoundaries`, `buildTocBoundaries()`, page lookup methods)
- Added TOC anchor page breaks to `ChapterHtmlSlimParser` (chapters start on fresh pages)
- Added TOC-aware navigation to `EpubReaderActivity` (long-press walks TOC entries, status bar shows subchapter title)
- Updated `EpubReaderChapterSelectionActivity` to pass and accept `tocIndex`
- Added multi-spine chapter caching (`cacheMultiSpineChapter()`)
- Incremented `SECTION_FILE_VERSION` from 18 to 19
- Preserved mod's footnote support, image rendering options, and Activity base class
### Phase 3: PR #1320 — JPEG resource cleanup
**Branch:** `port/1320-jpeg-cleanup`
- Added `ScopedCleanup` RAII struct to `JpegToBmpConverter.cpp`
- Removed scattered `free()`/`delete` calls
- Changed `rowCount` from `uint16_t*` to `uint32_t*` to prevent overflow
### Phase 4: PR #1325 — Settings tab label
**Branch:** `port/1325-settings-label`
- Dynamic confirm label in `SettingsActivity.cpp` shows next category name when tab bar is focused
## Files changed
| File | Phase | Change type |
|------|-------|-------------|
| `src/activities/reader/ReaderUtils.h` | 1 | New file |
| `src/activities/reader/EpubReaderActivity.cpp` | 1, 2 | Refactored |
| `src/activities/reader/EpubReaderActivity.h` | 2 | Extended |
| `src/activities/reader/TxtReaderActivity.cpp` | 1 | Refactored |
| `lib/Epub/Epub/Section.h` | 2 | Extended |
| `lib/Epub/Epub/Section.cpp` | 2 | Extended |
| `lib/Epub/Epub/parsers/ChapterHtmlSlimParser.h` | 2 | Extended |
| `lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp` | 2 | Extended |
| `src/activities/ActivityResult.h` | 2 | Extended |
| `src/activities/reader/EpubReaderChapterSelectionActivity.h` | 2 | Extended |
| `src/activities/reader/EpubReaderChapterSelectionActivity.cpp` | 2 | Extended |
| `lib/JpegToBmpConverter/JpegToBmpConverter.cpp` | 3 | Refactored |
| `src/activities/settings/SettingsActivity.cpp` | 4 | Modified |
| `mod/prs/MERGED.md` | Housekeeping | Updated |
| `mod/docs/upstream-sync.md` | Housekeeping | Updated |
## Follow-up items
- All 4 branches need hardware testing before merging to `mod/master`
- Test TOC navigation with multi-chapter spine EPUBs (short story collections, academic texts)
- Test JPEG resource cleanup with large image-heavy EPUBs
- Verify `SECTION_FILE_VERSION` bump invalidates old caches properly (delete `.crosspoint/` on SD card)
- When upstream merges these PRs, these ports should be dropped during the next sync

View File

@@ -312,11 +312,16 @@ Additionally, keep the quick-reference status table below up to date during each
| #1055 | Byte-level framebuffer writes | OPEN | #1141 (MERGED, wrapped text in GfxRender) | Keep, adapt to GfxRenderer changes | | #1055 | Byte-level framebuffer writes | OPEN | #1141 (MERGED, wrapped text in GfxRender) | Keep, adapt to GfxRenderer changes |
| #1068 | URL hyphenation fix | OPEN | None | Keep until merged upstream | | #1068 | URL hyphenation fix | OPEN | None | Keep until merged upstream |
| #1090 | KOReader push progress + sleep | OPEN | #946 (OPEN, sync streamlining) | Evaluate overlap with #946 | | #1090 | KOReader push progress + sleep | OPEN | #946 (OPEN, sync streamlining) | Evaluate overlap with #946 |
| #1143 | TOC fragment navigation | OPEN (draft) | #1172 (OPEN, multi-spine TOC) | Keep until merged upstream |
| #1172 | Multi-spine TOC items | OPEN (draft) | #1143 (OPEN, TOC fragment nav) | Keep until merged upstream |
| #1185 | KOReader document hash cache | OPEN | #1286 (OPEN, OPDS filename matching) | Keep until merged upstream | | #1185 | KOReader document hash cache | OPEN | #1286 (OPEN, OPDS filename matching) | Keep until merged upstream |
| #1209 | Multiple OPDS servers | OPEN | #1214 (OPEN, author folders) | Keep until merged upstream | | #1209 | Multiple OPDS servers | OPEN | #1214 (OPEN, author folders) | Keep until merged upstream |
| #1217 | KOReader sync improvements | OPEN | #946 (OPEN, sync streamlining) | Evaluate overlap with #946 | | #1217 | KOReader sync improvements | OPEN | #946 (OPEN, sync streamlining) | Evaluate overlap with #946 |
| #1320 | JPEG resource cleanup (RAII) | OPEN | None | Keep until merged upstream |
| #1325 | Settings tab label | OPEN | None | Keep until merged upstream |
| #1329 | Reader utils refactor | OPEN (draft) | #1143 (dependent) | Keep until merged upstream |
*Last updated: 2026-03-07* *Last updated: 2026-03-08*
### How to update this table during a sync ### How to update this table during a sync

View File

@@ -9,6 +9,10 @@ Tracking document for upstream PRs ported into this mod.
- [PR #1055](#pr-1055-byte-level-framebuffer-writes-for-fillrect-and-axis-aligned-drawline) — Byte-level framebuffer writes for fillRect and drawLine (jpirnay) - [PR #1055](#pr-1055-byte-level-framebuffer-writes-for-fillrect-and-axis-aligned-drawline) — Byte-level framebuffer writes for fillRect and drawLine (jpirnay)
- [PR #1027](#pr-1027-reduce-parsedtext-layout-time-79-via-word-width-cache-and-hyphenation-early-exit) — Reduce ParsedText layout time 79% via word-width cache and hyphenation early exit (jpirnay) - [PR #1027](#pr-1027-reduce-parsedtext-layout-time-79-via-word-width-cache-and-hyphenation-early-exit) — Reduce ParsedText layout time 79% via word-width cache and hyphenation early exit (jpirnay)
- [PR #1068](#pr-1068-correct-hyphenation-of-urls) — Correct hyphenation of URLs (Uri-Tauber) - [PR #1068](#pr-1068-correct-hyphenation-of-urls) — Correct hyphenation of URLs (Uri-Tauber)
- [PR #1329](#pr-1329-refactor-reader-utils) — Refactor shared reader utilities (upstream)
- [PR #1143 + #1172](#pr-1143--1172-toc-fragment-navigation--multi-spine-toc) — TOC fragment navigation + multi-spine TOC (upstream)
- [PR #1320](#pr-1320-jpeg-resource-cleanup) — RAII JPEG resource cleanup (upstream)
- [PR #1325](#pr-1325-settings-tab-label) — Dynamic settings tab label (upstream)
--- ---
@@ -255,3 +259,100 @@ Long URLs in EPUBs could not be line-wrapped because `buildExplicitBreakInfos` r
- coderabbit approved the `isExplicitHyphen` change and flagged the repeated-separator edge case as a nitpick. The PR author has not yet addressed it. - coderabbit approved the `isExplicitHyphen` change and flagged the repeated-separator edge case as a nitpick. The PR author has not yet addressed it.
- The PR resolves the URL portion of issue #1066, where MIT Press EPUBs with long URLs caused rendering problems. - The PR resolves the URL portion of issue #1066, where MIT Press EPUBs with long URLs caused rendering problems.
---
## PR #1329: Refactor reader utils
- **URL:** [https://github.com/crosspoint-reader/crosspoint-reader/pull/1329](https://github.com/crosspoint-reader/crosspoint-reader/pull/1329)
- **Author:** upstream
- **Status in upstream:** Open (draft)
- **Method:** Manual port (3 files)
### Context
Both `EpubReaderActivity` and `TxtReaderActivity` contained duplicated logic for orientation switching, page-turn detection, refresh cycling, and grayscale anti-aliasing. This PR extracts shared reader utilities into a new `ReaderUtils.h` header.
### Changes applied
1. **`src/activities/reader/ReaderUtils.h`** (new): Created namespace `ReaderUtils` containing `GO_HOME_MS`, `applyOrientation()`, `PageTurnResult` + `detectPageTurn()`, `displayWithRefreshCycle()`, and `renderAntiAliased()` (template to avoid `std::function` overhead). Includes `storeBwBuffer()` null-check from CodeRabbit review.
2. **`src/activities/reader/EpubReaderActivity.cpp`**: Replaced local `applyReaderOrientation()`, `goHomeMs`, manual page-turn detection, and refresh cycling with `ReaderUtils::` equivalents.
3. **`src/activities/reader/TxtReaderActivity.cpp`**: Same delegation to `ReaderUtils::`, removing duplicated orientation switch, page-turn detection, and anti-aliasing code.
### Differences from upstream PR
- **CodeRabbit fix applied**: Added `storeBwBuffer()` return value check in `renderAntiAliased()` that upstream's draft doesn't yet include.
- **Mod's `applyOrientation` preserved**: The mod's `EpubReaderActivity::applyOrientation()` method (which handles settings persistence and section reset) was kept and internally calls `ReaderUtils::applyOrientation()` for the renderer orientation change.
---
## PR #1143 + #1172: TOC fragment navigation + multi-spine TOC
- **URL (1143):** [https://github.com/crosspoint-reader/crosspoint-reader/pull/1143](https://github.com/crosspoint-reader/crosspoint-reader/pull/1143)
- **URL (1172):** [https://github.com/crosspoint-reader/crosspoint-reader/pull/1172](https://github.com/crosspoint-reader/crosspoint-reader/pull/1172)
- **Author:** upstream
- **Status in upstream:** Both open (drafts)
- **Method:** Surgical feature extraction (7 files modified)
### Context
Many EPUBs have spine files containing multiple TOC chapters (e.g., short story collections, academic texts). The status bar showed incorrect chapter titles, chapter skip jumped entire spine items instead of TOC entries, and cross-spine chapter transitions required full re-indexing. These PRs add TOC-aware boundary tracking and multi-spine section caching.
### Changes applied
1. **`lib/Epub/Epub/Section.h`**: Added `TocBoundary` struct, `tocBoundaries` vector, `buildTocBoundaries()`, `getTocIndexForPage()`, `getPageForTocIndex()`, `getPageRangeForTocIndex()`, `readAnchorMap()`, `readCachedPageCount()`.
2. **`lib/Epub/Epub/Section.cpp`**: Implemented all new TOC boundary methods. Incremented `SECTION_FILE_VERSION` from 18 to 19. Integrated `buildTocBoundaries()` into both `loadSectionFile` and `createSectionFile`. Added static `readAnchorMap()` for lightweight section probing.
3. **`lib/Epub/Epub/parsers/ChapterHtmlSlimParser.h/.cpp`**: Added `tocAnchors` set and `tocAnchorPageMap`. Constructor accepts `tocAnchors` parameter. Forced page breaks at TOC anchor boundaries in `startNewTextBlock` so chapters start on fresh pages.
4. **`src/activities/ActivityResult.h`**: Added `tocIndex` to `ChapterResult`.
5. **`src/activities/reader/EpubReaderActivity.h/.cpp`**: Added `pendingTocIndex` for deferred cross-spine TOC navigation. Chapter skip (long-press) now walks TOC entries. Status bar uses `section->getTocIndexForPage()` for accurate subchapter title. Added `cacheMultiSpineChapter()` for proactive indexing of all spines in the same TOC chapter.
6. **`src/activities/reader/EpubReaderChapterSelectionActivity.h/.cpp`**: Added `currentTocIndex` parameter for precise pre-positioning. Returns `tocIndex` alongside `spineIndex` in `ChapterResult`.
### Differences from upstream PRs
- **Mod's footnote support preserved**: Upstream removed footnote navigation; the mod's `getPageForAnchor()`, footnote depth tracking, and `EpubReaderFootnotesActivity` are all retained.
- **Mod's image rendering preserved**: Upstream removed image rendering options; the mod's `imageRendering` parameter chain is preserved throughout Section, parser, and settings.
- **Activity base class retained**: Upstream adopted `ActivityWithSubactivity`; the mod keeps `Activity` as the base class for reader activities.
- **No `STR_INDEXING_PROGRESS` key**: Instead of adding a new translation key, the progress popup reuses `tr(STR_INDEXING)` with `snprintf` to append the numeric `(x/y)` progress, avoiding changes to 17+ YAML files.
- **Section file version**: Mod increments from v18 to v19 (upstream from v13 to v14). The mod's higher version reflects additional fields from previous mod-exclusive changes.
---
## PR #1320: JPEG resource cleanup
- **URL:** [https://github.com/crosspoint-reader/crosspoint-reader/pull/1320](https://github.com/crosspoint-reader/crosspoint-reader/pull/1320)
- **Author:** upstream
- **Status in upstream:** Open
- **Method:** Manual port (1 file)
### Context
`JpegToBmpConverter::convert()` had scattered `free()`/`delete` calls across multiple early-return paths, making it prone to resource leaks on error.
### Changes applied
1. **`lib/JpegToBmpConverter/JpegToBmpConverter.cpp`**: Introduced `ScopedCleanup` RAII struct that manages `rowBuffer`, `mcuRowBuffer`, `atkinsonDitherer`, `fsDitherer`, `atkinson1BitDitherer`, `rowAccum`, and `rowCount`. All pointers are initialized to `nullptr` and freed in the destructor. Removed scattered manual `free()`/`delete` calls. Changed `rowCount` from `uint16_t*` to `uint32_t*` to prevent overflow for wide images.
### Differences from upstream PR
- None -- clean port. The mod's `JpegToBmpConverter.cpp` had the same structure as upstream's pre-PR version.
---
## PR #1325: Settings tab label
- **URL:** [https://github.com/crosspoint-reader/crosspoint-reader/pull/1325](https://github.com/crosspoint-reader/crosspoint-reader/pull/1325)
- **Author:** upstream
- **Status in upstream:** Open
- **Method:** Manual port (1 file)
### Context
The settings screen's "Confirm" button showed a hardcoded "Toggle" label even when the tab bar was focused, where it should indicate the next category name.
### Changes applied
1. **`src/activities/settings/SettingsActivity.cpp`**: When `selectedSettingIndex == 0` (tab bar focused), the confirm button now shows the next category's name using `I18N.get(categoryNames[(selectedCategoryIndex + 1) % categoryCount])`. Otherwise, it shows the standard `tr(STR_TOGGLE)` label.
### Differences from upstream PR
- None -- clean port.