Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various text selection, footnotes & misc fixes and tweaks #554

Merged
merged 11 commits into from
Feb 16, 2024

Conversation

poire-z
Copy link
Contributor

@poire-z poire-z commented Feb 15, 2024

LvDocView: allow setting custom title/authors/series

Frontend can set custom title/authors/series to be displayed in the top status bar (and in the rarely seen FB2 synthesized front text cover).
Will help koreader/koreader#11463 to do it stuff more properly. See koreader/koreader#11463 (comment)

elementFromPoint(): fix possible crash when float at end of document

A float at the end of the document could add some overflow to the root node "rect", and we would segfault when looking for its parent.
See koreader/koreader#11409 (comment) .
Should allow closing koreader/koreader#11409 .

Non-linear fragments: fix generic handling on erm_final

Followup to 03e0f37, where we added the closing of a non-linear sequence for erm_block elements, but totally forgot to do the same for erm_final elements!
Noticed around koreader/koreader#10193 (comment).

DrawBorder: fix bottom border inset/outset drawing

The bottom border could be thicker than the others.
Now similar to the top/left/right border drawing branches.

getSegmentRects(): allow segments to include images

This will allow including images at start or end of line in text selection & highlights, avoiding holes.
It is also necessary with popup footnotes it we want to have them detected and highlight the link when the footnote link is solely an image (which seems popular in Chinese EPUBs).
Should allow closing the popup footnotes issue in koreader/koreader#11451
Will allow to go on with including images in text selection and highlights: koreader/koreader#11460.

getRangeText(): allow gathering images

Allow getting in the text one unicode codepoint in place of each image (which may make the highlight text more readable).
Can optionally return the list of associated image nodes.
Will allow to go on with including images in text selection and highlights: koreader/koreader#11460.

Allow standalone image in link to trigger in-page footnotes

We were only considering links with text as candidates to get in-page footnotes.
(Image links seem popular in some Chinese books.)
Should allow closing the in-page footnotes issue in koreader/koreader#11451

ldomDocument::render(): avoid uneeded deserialization on each page turn

_pagesData is the serialized pages data, loaded from cache, and to be saved to cache.
pos() > 0 means it has some content, that can be saved to cache. There were some interference with using it as meaning there has been some content read, that should be deserialized. Only deserialize when we know we should, when just loaded from cache.

lvtinydom: add ldomNode::getAllInnerAttributeValues()

Will be useful to get all the id= values in a footnote section.

LVFootNote: avoid retrieving internal CompactArray object

Add methods to get what we want, without the need to get a reference to the internal object itself (which could cause it to be freed when going out of scope and could cause some crashes if accessed again).

In-page footnotes: allows for multiple id= inside them

Previously, when entering a block element tagged with -cr-hint: footnote-inpage, we were associating it with the first id= attribute found inside it.
It was then added to the page containing links with href= this id.
But it may happen that some href= points to some inner id= inside the footnote section (ie. the container has an id= but the href= points to a <span id=> inside the container, with another id), in which case no footnote was found for that href.
We now reference the same LVFootNote to all the ids met.
The LVFootNote stubs created when meeting the href need to be kept, so we associate them with the "actual footnote" we create, so it can act as a proxy to it.
Problem met in a few koreader issues, latest one at koreader/koreader#11411 (comment).


This change is Reviewable

Frontend can set custom title/authors/series to be
displayed in the top status bar (and in the rarely
seen FB2 synthesized front text cover).
A float at the end of the document could add some overflow
to the root node "rect", and we would segfault when looking
for its parent.
Followup to 03e0f37, where we added the closing
of a non-linear sequence for erm_block elements,
but totally forgot to do the same for erm_final
elements!
The bottom border could be thicker than the others.
Now similar to the top/left/right border drawing branches.
This will allow including images at start or end of
line in text selection & highlights, avoiding holes.
It is also necessary with popup footnotes it we want
to have them detected and highlight the link when the
footnote link is solely an image (which seems popular
in Chinese EPUBs).
Allow getting in the text one unicode codepoint in place of
each image (which may make the highlight text more readable).
Can optionally return the list of associated image nodes.
We were only considering links with text as candidates to
get in-page footnotes.
(Image links seem popular in some Chinese books.)
_pagesData is the serialized pages data, loaded from cache,
and to be saved to cache.
pos() > 0 means it has some content, that can be saved to
cache. There were some interference with using it as meaning
there has been some content read, that should be deserialized.
Only deserialize when we know we should, when just loaded
from cache.
Will be useful to get all the id= values in a footnote section.
Add methods to get what we want, without the need to get
a reference to the internal object itself (which could
cause it to be freed when going out of scope and could
cause some crashes if accessed again).
Previously, when entering a block element tagged with
"-cr-hint: footnote-inpage", we were associating it with
the first id= attribute found inside it.
It was then added to the page containing links with href=
this id.
But it may happen that some href= points to some inner id=
inside the footnote section (ie. the container has an id= but
the href= points to a <span id=> inside the container, with
another id), in which case no footnote was found for that href.
We now reference the same LVFootNote to all the ids met.
The LVFootNote stubs created when meeting the href need to
be kept, so we associate them with the "actual footnote" we
create, so it can act as a proxy to it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant