8000 Support viewport-percentage length units and calc() by MurakamiShinyu · Pull Request #507 · vivliostyle/vivliostyle.js · GitHub
[go: up one dir, main page]

Skip to content

Conversation

MurakamiShinyu
Copy link
Member

viewport-percentage length units: vw, vh, vi, vb, vmin, vmax

Spec: https://drafts.csswg.org/css-values/#viewport-relative-lengths

The viewport-percentage lengths are relative to the size of the initial containing block.

For paged media, the exact definition of the viewport-percentage lengths is deferred to [CSS3PAGE].

CSS3PAGE: https://drafts.csswg.org/css-page-3/#page-model says:

The content area of a page box is called the page area. The page area acts as a container for all the boxes generated by the root element and its descendants that are laid out within a given page box. The edges of the page area on the first page establish the rectangle th D3A6 at is the initial containing block of the document.

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() function

This simple solution is not perfect but a starting point.

Known issue: width: calc(100%) should be same as width: 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:

  • viewport_unit.html: viewport-percentage units
  • viewport_unit_vertical.html: viewport-percentage units (vertical writing-mode)
  • page_viewport_unit.html: page viewport-percentage units with calc()

### viewport-percentage length units: vw, vh, vi, vb, vmin, vmax

Spec: https://drafts.csswg.org/css-values/#viewport-relative-lengths

> The **viewport-percentage lengths** are relative to the size of the *initial containing block*.

> For paged media, the exact definition of the viewport-percentage lengths is deferred to [CSS3PAGE].

CSS3PAGE: https://drafts.csswg.org/css-page-3/#page-model says:

> The content area of a page box is called the **page area**. The page area acts as a container for all the boxes generated by the root element and its descendants that are laid out within a given page box. The edges of the page area on the first page establish the rectangle that is the *initial containing block* of the document.

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](https://www.antennahouse.com/product/ahf66/ahf-ext.html#pvw).

### calc()

Added CSS `calc()` support by simply converting it to old `-epubx-expr()` function

This simple solution is not perfect but a starting point.

Known issue: `width: calc(100%)` should be same as `width: 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:
- viewport_unit.html: viewport-percentage units
- viewport_unit_vertical.html: viewport-percentage units (vertical writing-mode)
- page_viewport_unit.html: page viewport-percentage units with calc()
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
0