-
Notifications
You must be signed in to change notification settings - Fork 45
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
poire-z
force-pushed
the
misc_footnotes_fixes
branch
from
February 16, 2024 11:18
94ca1e4
to
f03e249
Compare
This was referenced Feb 16, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 imagesThis 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 imagesAllow 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 firstid=
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 innerid=
inside the footnote section (ie. the container has anid=
but thehref=
points to a<span id=>
inside the container, with another id), in which case no footnote was found for thathref
.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