Bug 220225

Summary: Wrong background opacity with overflowing divs and fixed position
Product: WebKit Reporter: Karel Bilek <kb>
Component: CompositingAssignee: Simon Fraser (smfr) <simon.fraser>
Status: NEW ---    
Severity: Normal CC: simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Mac (Intel)   
OS: macOS 11   
Attachments:
Description Flags
Simple testcase
none
Clearer testcase none

Description Karel Bilek 2021-01-02 02:52:52 PST
I caught a bug with this minimal replication code.

```
<div style="width:100%;height: 100%; position: fixed; overflow-x:hidden; background-color: rgba(0,0,0,0.5);">
	<div style="overflow-x: hidden;height: 18000px;width: 100px; background-color: white">
        	<div style="height: 20000px;">
        	</div>
	</div>
</div>
```

When the inner div is bigger than the middle div, the background opacity of the top div is wrong. (20000px > 18000px)

When I change 20000 to 10000, the opacity is correct.

I have tried this in Chrome and Firefox and it does not happen there, so it must be a webkit bug.

I don't see Big Sur in build archives so I cannot try this there; I use Safari Technology Preview, Release 117 (Safari 14.1, WebKit 16611.1.7.2)
Comment 1 Karel Bilek 2021-01-02 02:57:16 PST
Created attachment 416894 [details]
Simple testcase

Simple testcase
Comment 2 Karel Bilek 2021-01-02 02:58:17 PST
I have added an even simpler testcase. Left and right column should be the same, but they are not.
Comment 3 Karel Bilek 2021-01-02 03:02:37 PST
Comment on attachment 416894 [details]
Simple testcase

It seems the *top* `overflow-x:hidden` is not actually needed to replicate the bug.
Comment 4 Karel Bilek 2021-01-02 03:20:06 PST
Ignore comment 3.

The top `overflow-x:hidden` is needed to replicate the bug.
Comment 5 Simon Fraser (smfr) 2021-01-05 19:52:36 PST
Created attachment 417064 [details]
Clearer testcase

This is about "simple container" layers. We set the alpha color both as layer background color, and also paint it into a sublayer.

Adding border, box-shadow or contents to the outer element makes the bug not happen.
Comment 6 Simon Fraser (smfr) 2021-01-05 20:51:50 PST
RenderLayerBacking::updateDrawsContent() calls m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent) but that ignores that fact that we've already determined that the content is a simple background color.
Comment 7 Radar WebKit Bug Importer 2021-01-09 02:53:11 PST
<rdar://problem/72961068>