[csswg-drafts] [cssom-view] getBoundingClientRect undefined in paged media (#4463)

frivoal has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom-view] getBoundingClientRect undefined in paged media ==
There are a few steps to determining the return value of `getBoundingClientRect()`. The base/fallback case is [described](https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect) as:

> return a DOMRect object describing the smallest rectangle that includes all of the rectangles in list of which the height or width is not zero.

Each rectangle in the list corresponds to a single fragment, so far so good.

However, while it is true on screen, in the general case, there is no guarantee that all these pre-fragment-rectangles exist in a singe coordinate space. In paginated media, each page is a 2d space, and you can reason about "the smallest rectangle that includes all of the rectangles" within that page. However, if two of these rectangles end up being on different pages, "the smallest rectangle that includes both" is undefined, because there is no well defined 2d space in which the pages themselves are placed. Since some of the environments in which pagination is possible also support scripting, this needs an answer.

Possible answers (with no particular judgement as to which is a good idea):
1. define this abstract space in which the pages are placed, so that when some object is on page 2, we can express where it is in terms of the coordinate system rooted in page 1. Maybe they're laid out next to each other horizontally from left to right, top aligned, with their [bleed edges](https://drafts.csswg.org/css-page-3/#bleed-area) adjacent. Or maybe their margin edge. Or maybe they're stacked top to bottom, left aligned. There's a notion of spread, and pages in a spread are next to each other horizontally, and spreads are stacked up vertically. Maybe the author has control about whether there are spreads or not. Maybe this is sensitive to `writing-modes` and `direction`, maybe not.
2. define that `getBoundingClientRect()` does not consider the whole list, but only the rectangles within the list that fit within the same page as the first one in the list / or within the first page.
3. Same as 2, but abstracted to any kind of fragmentation container, not just pages.
4. return `undefined`
5. throw an exception
6. return a list/array/collection of some kind, defining each such smallest rectangle *per page*.

If we had a time machine, I'd advocate for 6, but we don't. All the other options seem somewhat unappealing to me for various reasons, yet we still need to know what this API is supposed to return.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4463 using your GitHub account

Received on Tuesday, 29 October 2019 06:04:43 UTC