Files
zed/crates/gpui_web
Joshua Moon 5a40bc8bd7 gpui_web: Fix safe-area insets under a strict style CSP (#66907)
## Summary

gpui web uses exploratory divs to learn about the unusable deadspace on
the margins of a device's screen, which it calls safe-area insets.

When doing this, it uses html `style` attributes with raw css
parameters. In modern web development, is typical to use a
`Content-Security-Policy` to block `unsafe-inline` css in html. This
feature breaks when such security settings are in use.

However, while raw CSS in the style element is not permitted, even with
the CSP set to block `unsafe-inline` style attributes, it still permits
some direct adjustments via CSSOM with `el.style.setProperty(p, v)`.
This workaround is already used by gpui web on the canvas and IME
elements.

See
*
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/style-src
*
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/style-src-attr

## Testing

I have manually reviewed this change in WebKit, Chromium, and Gecko. All
modern web engines support this workaround and document it as safe.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] There are no UI changes.
- [x] Tests are not relevant for this change.

Release Notes:

- [GPUI] Fixed safe-area insets reading as zero on pages with a strict
style Content-Security-Policy.
2026-11-13 11:33:53 +00:00
..