[css-images] API for authors to request concrete object size & position, for replaced element w/ "object-fit"/"object-position"

Hi www-style,

When an image or a video has "object-fit" and/or "object-position" set,
it would be quite convenient for web developers if they had a way to
determine the exact on-screen rect that the media is rendering into. We
(Mozilla) received a request for such a feature here:
 https://bugzilla.mozilla.org/show_bug.cgi?id=1211711
 https://bugzilla.mozilla.org/show_bug.cgi?id=1211717

Briefly, the use case is a web author wanting to know where a user's
cursor is, relative to a <video>'s rendered content.

3 QUESTIONS:
==========
(1) Is this positioning information already easily-exposed somewhere? (I
don't think it is, but I might've missed it.)

(2) What should an API to query this information look like? Maybe a new
getter "DOMRect getConcreteObjectRect()" on all replaced elements?
(This may really be a question for the WHATWG -- not sure -- but since
object-fit & object-position are defined in CSS, I figured I'd start
with the CSSWG.)

(3) Any reasons we shouldn't expose an API like this?

Thanks,
~Daniel

Received on Wednesday, 7 October 2015 04:18:47 UTC