1.9 KiB
id, title, status, assignee, created_date, updated_date, labels, milestone, dependencies, references, priority
| id | title | status | assignee | created_date | updated_date | labels | milestone | dependencies | references | priority | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| TASK-11 | Break up the applyInvisibleSubtitleLayoutFromMpvMetrics mega function | To Do | 2026-02-11 08:21 | 2026-02-15 07:00 |
|
Codebase Clarity & Composability |
|
|
medium |
Description
In renderer.ts (around lines 865-1075), applyInvisibleSubtitleLayoutFromMpvMetrics is a 211-line function with up to 5 levels of nesting. It handles OSD scaling calculations, platform-specific font compensation (macOS vs Linux), DPR calculations, ASS alignment tag interpretation (\an tags), baseline compensation, line-height fixes, font property application, and transform origin — all interleaved.
Extract into focused helpers:
calculateOsdScale(metrics, renderAreaHeight)— pure scaling mathcalculateSubtitlePosition(metrics, scale, alignment)— ASS \an tag interpretation + positioningapplyPlatformFontCompensation(style, platform)— macOS kerning/size adjustmentsapplySubtitleStyle(element, computedStyle)— DOM style application
This can be done independently of or as part of TASK-6 (renderer split).
Acceptance Criteria
- #1 No single function exceeds ~50 lines in the positioning logic
- #2 Helper functions are pure where possible (take inputs, return outputs)
- #3 Platform-specific branches isolated into dedicated helpers
- #4 Invisible overlay positioning still works correctly on Linux and macOS
Implementation Notes
Reparented as a dependency of TASK-27.5: the mega-function lives in positioning.ts (513 LOC), which is the exact file TASK-27.5 targets for splitting. Decomposing this function is a natural part of that file split. Should be executed together with TASK-27.5.