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

Replaced element improved sizing support #372

Merged
merged 14 commits into from
Jul 23, 2019
Merged

Conversation

danfickle
Copy link
Owner

This body of code, works on the the sizing of replaced elements including:

  • img
  • math
  • svg

Specifically it moves much of the sizing code into the core instead of each replaced element implementation having to provide their own sizing code.

Other improvements:

  • Implement min-width and min-height properties for above elements (max-width and max-height were already implemented.
  • embed PDF file via object tag? #344 Implement painting PDF pages as images using the img tag - <img src="happy.pdf" alt="First page" page="1" />

NOTES:

  • Tests are provided for above functionality, but the MathML test is manual as JEuclid produces slightly different output between JDK 8 and 11.
  • Does not (or should not) change the way custom objects are sized. In hindsight the custom object API could be improved. For example, there is no way a custom object can report its intrinsic size to the core. We can perhaps think of a custom objects API v2, but that is not part of this work.

Relevant wiki pages (need to be updated once this is released):

Comments welcome.

P.S. Trying to merge this and do a release within the next couple of days.

danfickle added 14 commits May 2, 2019 00:34
This work moves sizing of replaced objects form externally in each replaced object implementation to internally in the core code. This should reduce duplication and mean all sizing properties are available on each replaced object type.

For example, now images have min-width and min-height as well as a border-box implementation.

This work is published initially in a new branch because while there are good tests for images we need to test the new sizing code for all the other replaced object options such as SVG, PDF, custom, etc.
Including min-width/min-height and border-box sizing. With test.
We can now use unit values such as mm in the width/height attribute of SVG images. With tests.
Now, always keep the correct aspect ratio.
The MathML renderer (JEuclid) produces slightly different results on JDK8 vs JDK11 so is not suitable for auto testing.
Only one broken test - svg linked with img tag.
…mg tag.

This is mostly a revert of d9cdd6a

I forgot about external SVGs rather than inline SVGs where the width/height attribute are converted to CSS earlier in the render process.
Nearly there, the only reason I havent committed the test is that it is a couple of pixels off on width, which is noticeable when there is a border.
Turns out the problem was prematurely casting our width and height to ints and thus getting incorrect scale factors. Test now passing.
I thought I had broken the clear mechanism, but it was fine. Left test as a useful regression test.
Hopefully this will also trigger travis.
@danfickle danfickle merged commit be6eead into open-dev-v1 Jul 23, 2019
@danfickle danfickle deleted the replaced_sizing branch July 23, 2019 04:32
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