W3C home > Mailing lists > Public > public-css-archive@w3.org > January 2021

Re: [csswg-drafts] [CSSOM] There is no way to get correct viewport position in relation to the screen (#5814)

From: Maxim Tsoy via GitHub <sysbot+gh@w3.org>
Date: Thu, 21 Jan 2021 00:22:26 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-764065424-1611188545-sysbot+gh@w3.org>
I've just come across the same exact problem today.

Some historical background I could find:
- You can actually do it in IE11 with `window.screenTop` and `window.screenLeft`. And they are **different** from `screenY` and `screenX`.
- Blink, Gecko and WebKit all define `screenLeft` and `screenTop` as aliases to `screenX` and `screenY`. I tracked down the implementation in Blink to [this commit](https://chromium.googlesource.com/chromium/src/+/3c9374d0ebd6fc647485a637050546c98f64f90e) from 2007 and [this commit](https://chromium.googlesource.com/chromium/src/+/300df7371f3576267255a3d227ebe98aecf3a9e8) from 2002. So this implementation is from pre-Blink era.
- According to various sources, this was initially implemented as a webcompat fix due to the popularity among developers. Although I don't understand how aliases actually helped, since in IE it is a different thing.
- The CSS spec standardized these aliases in https://github.com/w3c/csswg-drafts/issues/1091 (2018)

The problem that I'm trying to solve is basically this:
- Given a MouseEvent or a Touch inside a deeply nested iframe, I need to get its coordinates within the top-level context.
- The iframe is cross-origin, so I can't recursively calculate it using iframe's getBoundingRect(), without a chain of cumbersome postMessages.
- In my case I can also assume that there is no CSS transforms involved on any of those iframes.

So ideally I'd like to do `mouseEvent.screenY - window.viewportScreenY`, where `viewportScreenY` works like `screenTop` in IE 11.


-- 
GitHub Notification of comment by muodov
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5814#issuecomment-764065424 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 21 January 2021 00:22:29 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 19 October 2021 01:31:38 UTC