Open Bug 1303574 Opened 8 years ago Updated 2 years ago

I can't style with css pseudo img::before when an image is broken or inexistent.

Categories

(Core :: Layout: Images, Video, and HTML Frames, defect, P3)

48 Branch
defect

Tracking

()

People

(Reporter: fcasantos, Unassigned)

Details

(Keywords: testcase)

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0
Build ID: 20160823121617

Steps to reproduce:

Show additional information in case of an image is broken or inexistent.

HTML
<img src="any-image.jpg" width="256" height="256" alt="Harry and James" />

CSS
img::before { 
   content: "Sorry, this image is broken or inexistent. \a My cat Harry and my dog James together"
   white-space: pre;
}


Actual results:

Only appears the alternative text of the broken image, nothing more.

Note:
If i use img::after, works fine.

Sometimes i need to use both ::before and ::after pseudo elements.

My actual Firefox desktop version is 48.0.2.


Expected results:

Show the text defined in css "content" property.
My working OS is Windows 7 x64.
Attached file 1303574.html
Component: Untriaged → Layout: Images
Product: Firefox → Core
Product: Core → Core Graveyard
Product: Core Graveyard → Core
The box tree we create for this testcase looks like this:
Inline(img)<
  Inline(_moz_generated_content_before)<
    Text(0)"alt"
  >
  Inline(_moz_generated_content_after)<
    Text(0)"::after"
  >
>
Status: UNCONFIRMED → NEW
Component: Layout: Images, Video, and HTML Frames → Layout
Ever confirmed: true
Keywords: testcase
OS: Unspecified → All
Priority: -- → P3
Hardware: Unspecified → All
This is expected, per this rule:

  https://searchfox.org/mozilla-central/rev/1ce4e8a5601da8e744ca6eda69e782318afab54d/layout/style/res/html.css#647

I think this is a Layout: Images bug. We could try to avoid hacking up the alt content using ::before.
Component: Layout → Layout: Images, Video, and HTML Frames
Oh, that's where it comes from... I figured it was a frame constructor
bug which is why I changed the component.

Yeah, it's definitely not correct to implement ALT like that.
It appears we use ::before in our UA sheet to display the <optgroup>
label too, so I imagine we should fix that in a similar way to this bug.
(testcase in bug 1498358)
Note: the ALT (and the <optgroup> label) text is selectable in Chrome.
::after works but ::before not indeed seems to be broken. We should either disable both or support both. I wonder what other browsers do and what the spec says... I wouldn't be surprised if the spec doesn't say anything about this, though, since it seems to be an error case...
The spec actually goes into some detail about this:
https://html.spec.whatwg.org/multipage/rendering.html#images-3

It'd be interesting to know what Chrome/Safari/Edge/Firefox do
for each of the listed cases there...
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: