Bug 189518 - Wrong getComputedStyle for 'auto' value of inset properties in fixed positioned elements
Summary: Wrong getComputedStyle for 'auto' value of inset properties in fixed position...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2018-09-11 12:59 PDT by Oriol Brufau
Modified: 2023-11-29 18:13 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oriol Brufau 2018-09-11 12:59:08 PDT
Run this code: http://jsfiddle.net/msz9Lpfe/

```css
#container {
  transform: scale(1);
  border: 25px solid;
  height: 100px;
}
#fixed {
  position: fixed;
}
```
```html
<div id="container">
  <div id="fixed"></div>
</div>
```
```js
fixed.append("top: ", getComputedStyle(fixed).top);
```

If the containing block of a fixed positioned element is derived from an ancestor element, then it should be the ancestor's padding area (*).
This means that "top: auto" should resolve to "top: 0px", but getComputedStyle says "25px" instead.
Note that if you set "top: 0", the element stays at the same position as with "top: auto", and with "top: 25px" it's shifted downwards.
So the element is painted at the right position, this is just a getComputedStyle problem.
Neither Firefox nor Chromium have this problem.

(*) The spec doesn't define that for fixed positioning, but it's how browsers behave and is consistent with absolutely positioning, which is properly defined in the spec.
Comment 1 Oriol Brufau 2018-09-12 08:09:03 PDT
In fact, all values are currently affected. However, in https://bugs.webkit.org/show_bug.cgi?id=188711 I plan to fix all cases except for 'auto' values.
Comment 2 Ahmad Saleem 2022-09-03 14:21:59 PDT
I am able to reproduce this bug using attached JSFiddle from Comment 0 and it shows "25px" for Safari 15.6.1 and STP 152 while it shows "0px" for Chrome Canary 107 and Firefox Nightly 106. Thanks!
Comment 3 Radar WebKit Bug Importer 2022-09-03 17:04:35 PDT
<rdar://problem/99533470>