koreader / crengine

This is the KOReader CREngine fork. It cross-pollinates with the official CoolReader repository at https://github.com/buggins/coolreader, in case you were looking for that one.
70 stars 45 forks source link

Fix FB2 image sizing & centering, and bottom border on empty block elements #563

Closed poire-z closed 5 months ago

poire-z commented 5 months ago

EPUB: avoid crash when @font-face in <head><style>

Assertions in LVFontCache::_removeDocumentFonts() would fail (when DEBUG enabled). Noticed and investigated at https://github.com/koreader/crengine/pull/536#issuecomment-2002142872.

FB2: fix block images sizing and centering

Followup to 1544bcfb, where we made an image self container's width adjust to the image width, so text-align:center no longer does what was expected. Switch to margin-left/right:auto to get them centered again. See https://github.com/koreader/koreader/issues/11623#issuecomment-2040436412. Also, for standalone block images, set the strut and line-height to 0 (as we do for HTML) so they their block is adjusted to the page height when the image itself exceeds it, to avoid such images to be truncated and sliced on two pages. Noticed and investigated in https://github.com/koreader/crengine/pull/562. Should allow closing https://github.com/koreader/koreader/issues/11623.

lvrend: fix positionning of bottom border on empty block elements

Fix some possible issues with empty block elements having some bottom border (included in padding_bottom) when previous vertical margins are collapsing. (Not 100% certain this is the right fix that won't cause side effects...) Should allow closing https://github.com/koreader/koreader/issues/11594.


This change is Reviewable

Frenzie commented 5 months ago

There's a whole bunch of margin collapse test cases over here btw. "8.3.1 collapsing margins"

http://test.csswg.org/suites/css21_dev/20110323/xhtml1/chapter-8.xht http://test.csswg.org/suites/css21_dev/20110323/html4/chapter-8.html

Frenzie commented 5 months ago

margin-collapse.zip

Frenzie commented 5 months ago

NOT passing in the current version:

and, um, probably all following but I got bored. :-)

poire-z commented 5 months ago

The ones that fail are related to overflow, position:absolute, floats inside empty div (that I know there are tricky interactions we don't handle well), and some with imbricated tables with empty cells (that may be our code to compute table cells widths from their content don't handle well, but they really look like torture tests :)) Pretty happy with the many not failing ones anyway :)