Support viewport-percentage length units and calc() #507
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.
viewport-percentage length units: vw, vh, vi, vb, vmin, vmax
Spec: https://drafts.csswg.org/css-values/#viewport-relative-lengths
CSS3PAGE: https://drafts.csswg.org/css-page-3/#page-model says:
From these spec descriptions, we assume that the definition of "viewport-percentage length units" should be: viewport-percentage lengths are relative to the size of the page area, i.e., the content area of a page box and not including margin, border and padding specified on
@page
rule.page viewport-percentage length units: pvw, pvh, pvi, pvb, pvmin, pvmax
We need also page size based units. The pvw, pvh, pvi, pvb, pvmin, pvmax units are similar to the vw, vh, vi, vb, vmin, vmax but the reference size is the page size including page margins.
These units are not yet in standard CSS spec, but Antenna House Formatter has pvw/pvh/pvmin/pvmax.
calc()
Added CSS
calc()
support by simply converting it to old-epubx-expr()
functionThis simple solution is not perfect but a starting point.
Known issue:
width: calc(100%)
should be same aswidth: 100%
and calculated using width of the containing block. However, it uses page width due to the-epubx-expr()
implementation.Test cases
Added the following test cases: