Bug 203788 - Don't show the broken image icon for missing CSS images
Summary: Don't show the broken image icon for missing CSS images
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
: 231078 (view as bug list)
Depends on:
Blocks: 229909
  Show dependency treegraph
 
Reported: 2019-11-02 12:25 PDT by Simon Fraser (smfr)
Modified: 2022-02-09 10:14 PST (History)
4 users (show)

See Also:


Attachments
Some examples (983 bytes, text/html)
2021-10-18 22:00 PDT, Simon Fraser (smfr)
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2019-11-02 12:25:46 PDT
We currently render the broken image icon for missing CSS images (backgrounds, border-image etc) but I don't think we should. I think we should only show it for content images.
Comment 1 Said Abou-Hallawa 2019-11-04 10:10:39 PST
(In reply to Simon Fraser (smfr) from comment #0)
> We currently render the broken image icon for missing CSS images
> (backgrounds, border-image etc) but I don't think we should. I think we
> should only show it for content images.

How can this happen? Can you include a test case?

In RenderBoxModelObject::paintFillLayerExtended() we check:

bool shouldPaintBackgroundImage = bgImage && bgImage->canRender(this, style().effectiveZoom());

If the image is missing, bgImage will be null. And if an error happens while loading or decoding the image, bgImage->canRender() will return false. In both cases drawing the background image step will be skipped.
Comment 2 Simon Fraser (smfr) 2019-11-04 10:27:38 PST
I think I was seeing this for border-image.
Comment 3 Sam Sneddon [:gsnedders] 2021-10-12 02:42:31 PDT
*** Bug 231078 has been marked as a duplicate of this bug. ***
Comment 4 Sam Sneddon [:gsnedders] 2021-10-12 02:48:13 PDT
(In reply to Simon Fraser (smfr) from comment #2)
> I think I was seeing this for border-image.

Bug 206909 was caused by us rendering `content: -webkit-image-set(url(...))` given an invalid image.
Comment 5 Sam Sneddon [:gsnedders] 2021-10-12 08:44:10 PDT
<rdar://problem/82999675>
Comment 6 Simon Fraser (smfr) 2021-10-18 21:16:30 PDT
I can't figure out how to reproduce this now.
Comment 7 Simon Fraser (smfr) 2021-10-18 21:40:31 PDT
This is one way:
            background-image: -webkit-cross-fade(url('http://www.example.com/broken.png'), url('http://www.example.com/broken.png'), 50%);

I think it's bad that CachedImage::image() and CachedImage::imageForRenderer() can return the broken image icon. That causes hilarity like consulting this image for it's opaqueness, or EXIF orientation, even if it's never used in this context (e.g. CSS backgrounds).
Comment 8 Simon Fraser (smfr) 2021-10-18 22:00:42 PDT
Created attachment 441689 [details]
Some examples
Comment 9 Sam Sneddon [:gsnedders] 2021-10-19 05:30:03 PDT
(In reply to Simon Fraser (smfr) from comment #6)
> I can't figure out how to reproduce this now.

content: -webkit-image-set(url('http://www.example.com/broken.png') 1x); still suffices too

should really go through and add a whole bunch of WPT tests for this, in the various places where <image> is used as the value