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

CSS: add a few style tweaks helpers, and other fixes #485

Merged
merged 5 commits into from Jul 6, 2022

Conversation

poire-z
Copy link
Contributor

@poire-z poire-z commented Jul 6, 2022

CSS: add "-cr-hint: late" to increase selectors specificity

Should allow '* { -cr-hint: late; ... }' to be checked and applied after other selectors with higher specifity.
This can be useful with style tweaks, and makes tweaks a lot simpler.
See koreader/koreader#5863 (comment)

CSS: add a few non-static "-cr-only-if:" values

Existing values are static, and depend on the document and rendering options.
Add a few non-static ones, that need to be saved in the declaration and checked on each node.
This allows such combinations:

* { -cr-only-if: inside-inpage-footnote -inpage-footnote -inline;
        margin: 0 !important; display: inline; }

See koreader/koreader#5863 (comment)

getStyledImageSize(): fix missing images when gRenderDPI=0

When gRenderDPI=0 (old crengine behaviour), lengthToPx() returns 0 for absolute CSS units (in, cm, mm, pt, pc), which might be ok for margins and such, but not for images: we want non-zero w/h: so do as if no style when the unit is one of these, to avoid missing images.
See koreader/koreader#9281 (comment)

Text: fix possible crash with floats and <br/>

With:
<p><span dir="ltr"><img src="..." style="float: right"/><br/></span></p>
we would crash soon after with:
FATAL ERROR #130: Unexpected object type for word
This just avoids getting this fatal error, but does not really do the proper handling this edgy construction should get.
(Noticed while trying to test/understand why we got blank pages with the book from koreader/koreader#9281 - it looks like we don't really handle correctly paragraphs made only of collapsed spaces, ignorable bidi unicode chars, and floats....)

LVImg: fix crash on GIF images without color table

See koreader/koreader#9297 (comment)
Should allow closing koreader/koreader#9297


This change is Reviewable

Should allow '* { -cr-hint: late; ... }' to be checked and
applied after other selectors with higher specifity.
This can be useful with style tweaks, and makes tweaks
a lot simpler.
Existing values are static, and depend on the document and
rendering options.
Add a few non-static ones, that need to be saved in the
declaration and checked on each node.
This allows such combinations:
* { -cr-only-if: inside-inpage-footnote -inpage-footnote -inline;
        margin: 0 !important; display: inline; }
When gRenderDPI=0 (old crengine behaviour), lengthToPx()
returns 0 for absolute CSS units (in, cm, mm, pt, pc),
which might be ok for margins and such, but not for images:
we want non-zero w/h: so do as if no style when the unit
is one of these, to avoid missing images.
With:
<p><span dir="ltr"><img src="..." style="float: right"/><br/></span></p>
we would crash soon after with:
  FATAL ERROR koreader#130: Unexpected object type for word
This just avoids getting this fatal error, but does not really
do the proper handling this edgy construction should get.
Copy link
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice comments again. 👍

@poire-z poire-z merged commit e17a751 into koreader:master Jul 6, 2022
@poire-z poire-z deleted the css_tweaks_and_other_fixes branch July 6, 2022 19:41
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.

None yet

2 participants