more performance optimizations + cleanup
This commit is contained in:
15 files changed
+396
-469
No files matched your search
@@ -148,8 +148,8 @@ public:
|
||||
virtual QString author() const;
|
||||
virtual QString coverImageUrl() const;
|
||||
virtual QByteArray contentHash() const = 0; // MD5 hash for stable persistent state
|
||||
virtual QVector<PageInfo> pages() const; // Comic mode
|
||||
virtual QStringList chunks() const; // Text mode: HTML fragments
|
||||
virtual QVector<PageInfo> pages() const; // Comic mode
|
||||
virtual QVector<ContentChunk> chunks() const; // Text mode: structured content chunks
|
||||
};
|
||||
```
|
||||
|
||||
@@ -158,13 +158,10 @@ public:
|
||||
## Rendering Architecture
|
||||
|
||||
### 1. Text Mode (`ScrollPageView.qml`)
|
||||
- `ReadingModel` manages a list of HTML chunks.
|
||||
- `EpubReader` unwraps unstyled structural containers (`<div>`, `<section>`, `<article>`, etc.) that contain block-level children and partitions documents into fine-grained block/paragraph chunks (~512 chars max), propagating inherited CSS declarations. Paragraph `<div>`s containing inline markup (`<em>`, `<span>`, `<a>`, etc.) are preserved intact as atomic blocks without fragmenting text or punctuation.
|
||||
- `ReadingModel` manages a list of `ContentChunk`s (`QVector<ContentChunk>`).
|
||||
- `EpubReader` cascades CSS onto the spine DOM and delegates directly to `HtmlBlockParser::parseChunks()`. This bypasses raw HTML string serialization and eliminates the double-parsing penalty, producing structured `ContentChunk` entities with pre-parsed `BlockItem`s, `wordCount`, `charCount`, and `unnestedContainers` for open containers spanning chunk boundaries.
|
||||
- When viewport geometry or font preferences change, `ReadingModel::updateLayoutMetrics()` runs `ChunkLayoutEngine` off-thread:
|
||||
- `HtmlBlockParser` extracts structured blocks (`Paragraph`, `ImageBlock`, `Rule`, `Container`).
|
||||
- Block-level `background` sets `BoxStyle::background` (emitted as `PositionedDecoration`), while inline spans apply to `TextStyle::background` (individual word runs).
|
||||
- Cleans up trailing `<br/>` and trailing/leading whitespace in blocks.
|
||||
- `CssParser` evaluates stylesheets and styles inline tags. Parses full `border` shorthand, individual borders (`border-top/right/bottom/left`), widths (1-4 values), keywords, styles, and colours.
|
||||
- Pre-parsed `BlockItem`s in `ContentChunk` scale dynamically with user font preferences in `ChunkLayoutEngine::prepareBlocks()` with zero HTML/XML re-parsing.
|
||||
- `KnuthPlass` computes optimal justified/aligned line breaks.
|
||||
- `BookImageResolver` resolves embedded image dimensions and URLs.
|
||||
- Off-thread calculation stores `ChunkLayout` and pixel heights.
|
||||
|
||||
Reference in new issue
Block a user