Paginator: use CSS grid

Massively simplify margin/padding and header/footer layout and eliminate
unnecessary resizes and resize loops.

Also remove layout and style API from View, as these are only applicable
to the paginator.
This commit is contained in:
John Factotum
2023-05-28 22:17:56 +08:00
parent 21744e3c85
commit d5d1541d3b
4 changed files with 130 additions and 117 deletions
-9
View File
@@ -83,7 +83,6 @@ export class View extends HTMLElement {
#sectionProgress
#tocProgress
#pageProgress
#css
isFixedLayout = false
lastLocation
history = new History()
@@ -162,7 +161,6 @@ export class View extends HTMLElement {
if (!this.language.isCJK)
doc.documentElement.dir ||= this.language.direction ?? ''
this.renderer.setStyle?.(this.#css)
this.#handleLinks(doc, index)
this.#emit('load', { doc, index })
@@ -315,13 +313,6 @@ export class View extends HTMLElement {
goRight() {
return this.book.dir === 'rtl' ? this.prev() : this.next()
}
setAppearance({ layout, css }) {
if (this.isFixedLayout) return
Object.assign(this.renderer.layout, layout)
this.#css = css
this.renderer.setStyle(css)
this.renderer.render()
}
async * #searchSection(matcher, query, index) {
const doc = await this.book.sections[index].createDocument()
for (const { range, excerpt } of matcher(doc, query))