CSSOM View geometry utilities
- Category
- DOM
- Type
- New or changed feature
- Status
- Enabled by default (Chrome Enabled by default)
- Intent stage
- None
WPT details: https://wpt.fyi/results/css?label=master&label=experimental&aligned&q=geometryutils%7CgetBoxQuads
Summary
The API exposes getBoxQuads(), convertQuadFromNode(), convertRectFromNode(), and convertPointFromNode() on Document, Element, Text, and CSSPseudoElement so authors can obtain and convert precise DOM geometry using standard DOMPoint, DOMRect, and DOMQuad objects.
Motivation
Web authors currently do not have a standard native API for getting precise box geometry and converting points, rects, and quads between DOM nodes after layout, scrolling, fragmentation, writing modes, and CSS transforms have been applied. Applications that need this today, such as visual editors, inspection tools, custom selection UI, and overlay systems, usually approximate the result in JavaScript by walking ancestor chains, reading layout data, and composing transform matrices. These polyfills are costly when repeated for many elements, are easy to get subtly wrong, and cannot always match the browser’s layout and painting behavior. GeometryUtils exposes this geometry through standard DOMPoint, DOMRect, and DOMQuad objects, allowing authors to ask the engine for the same kind of coordinate-space conversion that is already needed internally for layout, hit testing, painting, and developer tooling. Concrete motivating use cases include visual editor and inspection tools that draw live overlays for many selected elements, including deeply nested custom elements, shadow DOM, transformed content, and generated pseudo-elements. Examples of tools in this space include web-component designers, page builders, browser extensions such as VisBug, and custom design/inspection overlays in developer applications.
Standards & signals
- Specification: https://drafts.csswg.org/cssom-view/#the-geometryutils-interface
- Firefox: Shipped/Shipping
- Safari: No signal — https://bugs.webkit.org/show_bug.cgi?id=321597 rdar://problem/185319307
- Web developers: Positive
- Tracking bug: https://issues.chromium.org/issues/427918516
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=geometryutils%7CgetBoxQuads
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+CSSOM%20View%20geometry%20utilities
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=CSSOM%20View%20geometry%20utilities
- Baseline status: https://webstatus.dev/?q=CSSOM%20View%20geometry%20utilities
Samples: https://jogibear9988.github.io/getBoxQuadsPolyfill
Explainers: https://gist.github.com/jogibear9988/8420264d0911ce6c5aab0ac5cda0744e