WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
207740
Inline boxes for images that represent nothing should collapse to empty.
https://bugs.webkit.org/show_bug.cgi?id=207740
Summary
Inline boxes for images that represent nothing should collapse to empty.
zalan
Reported
2020-02-13 19:20:48 PST
https://www.w3.org/TR/2016/WD-html51-20160412/rendering.html#replaced-elements-images
Attachments
Patch
(3.66 KB, patch)
2020-02-13 19:38 PST
,
zalan
no flags
Details
Formatted Diff
Diff
Patch
(3.71 KB, patch)
2020-02-14 08:15 PST
,
zalan
no flags
Details
Formatted Diff
Diff
Patch
(3.81 KB, patch)
2020-02-14 10:10 PST
,
zalan
no flags
Details
Formatted Diff
Diff
Patch
(3.83 KB, patch)
2020-02-14 11:04 PST
,
zalan
no flags
Details
Formatted Diff
Diff
Patch
(5.23 KB, patch)
2020-02-14 12:44 PST
,
zalan
no flags
Details
Formatted Diff
Diff
Patch
(13.18 KB, patch)
2020-02-16 09:57 PST
,
zalan
no flags
Details
Formatted Diff
Diff
Patch
(13.16 KB, patch)
2020-02-16 12:27 PST
,
zalan
no flags
Details
Formatted Diff
Diff
Patch
(13.27 KB, patch)
2020-02-16 17:13 PST
,
zalan
no flags
Details
Formatted Diff
Diff
Patch
(13.29 KB, patch)
2020-02-17 12:53 PST
,
zalan
no flags
Details
Formatted Diff
Diff
Patch
(23.00 KB, patch)
2020-02-17 14:48 PST
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Show Obsolete
(10)
View All
Add attachment
proposed patch, testcase, etc.
zalan
Comment 1
2020-02-13 19:21:15 PST
<
rdar://problem/57339992
>
zalan
Comment 2
2020-02-13 19:38:29 PST
Created
attachment 390724
[details]
Patch
zalan
Comment 3
2020-02-14 08:15:21 PST
Created
attachment 390771
[details]
Patch
zalan
Comment 4
2020-02-14 10:10:41 PST
Created
attachment 390780
[details]
Patch
zalan
Comment 5
2020-02-14 11:04:12 PST
Created
attachment 390786
[details]
Patch
Simon Fraser (smfr)
Comment 6
2020-02-14 11:48:42 PST
Comment on
attachment 390786
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=390786&action=review
> Source/WebCore/ChangeLog:11 > + Let's collapse inline boxes when we would display only a broken image and
Say why, not just "let's". Preferably link to the spec.
zalan
Comment 7
2020-02-14 11:56:54 PST
(In reply to Simon Fraser (smfr) from
comment #6
)
> Comment on
attachment 390786
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=390786&action=review
> > > Source/WebCore/ChangeLog:11 > > + Let's collapse inline boxes when we would display only a broken image and > > Say why, not just "let's". Preferably link to the spec.
Sure, in the final patch. It's a WIP for EWS.
zalan
Comment 8
2020-02-14 12:44:37 PST
Created
attachment 390798
[details]
Patch
zalan
Comment 9
2020-02-16 09:57:13 PST
Created
attachment 390888
[details]
Patch
Darin Adler
Comment 10
2020-02-16 12:24:19 PST
Comment on
attachment 390888
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=390888&action=review
Probably not quite expert enough to review, but spotted two small things
> Source/WebCore/rendering/RenderImage.cpp:265 > + return imageResource().errorOccurred() && (m_altText.isEmpty() || m_altText.isNull());
Null is also empty, so no need for "|| .isNull" clause here.
> Source/WebCore/rendering/RenderImage.cpp:276 > + if (element() && shouldCollapseToEmpty())
Can the null check for element go inside the shouldCollapseToEmpty function? Before I noticed every call doing this check I was going to ask about the assumption in that function that element can’t be null.
zalan
Comment 11
2020-02-16 12:27:56 PST
Created
attachment 390891
[details]
Patch
zalan
Comment 12
2020-02-16 12:38:50 PST
(In reply to Darin Adler from
comment #10
)
> Comment on
attachment 390888
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=390888&action=review
> > Probably not quite expert enough to review, but spotted two small things > > > Source/WebCore/rendering/RenderImage.cpp:265 > > + return imageResource().errorOccurred() && (m_altText.isEmpty() || m_altText.isNull()); > > Null is also empty, so no need for "|| .isNull" clause here.
Thanks! Clearly I don't use String class very often.
> > > Source/WebCore/rendering/RenderImage.cpp:276 > > + if (element() && shouldCollapseToEmpty()) > > Can the null check for element go inside the shouldCollapseToEmpty function? > Before I noticed every call doing this check I was going to ask about the > assumption in that function that element can’t be null.
Yeah, I moved it there (I had a previous version of this patch where the check was in shouldCollapseToEmpty(), but then I thought maybe shouldCollapseToEmpty() should only have the relevant logic. I think it's safer this way though.)
Darin Adler
Comment 13
2020-02-16 14:38:29 PST
(In reply to zalan from
comment #12
)
> (In reply to Darin Adler from
comment #10
) > > Can the null check for element go inside the shouldCollapseToEmpty function? > > Before I noticed every call doing this check I was going to ask about the > > assumption in that function that element can’t be null. > Yeah, I moved it there (I had a previous version of this patch where the > check was in shouldCollapseToEmpty(), but then I thought maybe > shouldCollapseToEmpty() should only have the relevant logic. I think it's > safer this way though.)
I agree that while this is safer, it’s not as conceptually clear and pure given the function name. Maybe best mitigated by writing a brief comment inside the function explaining why returning false for the case where there is no element is always a good idea.
zalan
Comment 14
2020-02-16 16:59:36 PST
(In reply to Darin Adler from
comment #13
)
> (In reply to zalan from
comment #12
) > > (In reply to Darin Adler from
comment #10
) > > > Can the null check for element go inside the shouldCollapseToEmpty function? > > > Before I noticed every call doing this check I was going to ask about the > > > assumption in that function that element can’t be null. > > Yeah, I moved it there (I had a previous version of this patch where the > > check was in shouldCollapseToEmpty(), but then I thought maybe > > shouldCollapseToEmpty() should only have the relevant logic. I think it's > > safer this way though.) > > I agree that while this is safer, it’s not as conceptually clear and pure > given the function name. Maybe best mitigated by writing a brief comment > inside the function explaining why returning false for the case where there > is no element is always a good idea.
Agreed!
zalan
Comment 15
2020-02-16 17:13:58 PST
Created
attachment 390893
[details]
Patch
zalan
Comment 16
2020-02-16 17:14:47 PST
(In reply to Darin Adler from
comment #13
)
> (In reply to zalan from
comment #12
) > > (In reply to Darin Adler from
comment #10
) > > > Can the null check for element go inside the shouldCollapseToEmpty function? > > > Before I noticed every call doing this check I was going to ask about the > > > assumption in that function that element can’t be null. > > Yeah, I moved it there (I had a previous version of this patch where the > > check was in shouldCollapseToEmpty(), but then I thought maybe > > shouldCollapseToEmpty() should only have the relevant logic. I think it's > > safer this way though.) > > I agree that while this is safer, it’s not as conceptually clear and pure > given the function name. Maybe best mitigated by writing a brief comment > inside the function explaining why returning false for the case where there > is no element is always a good idea.
Thanks for the review!
Simon Fraser (smfr)
Comment 17
2020-02-17 10:59:02 PST
Comment on
attachment 390893
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=390893&action=review
> Source/WebCore/ChangeLog:16 > +
https://www.w3.org/TR/2016/WD-html51-20160412/rendering.html#replaced-elements-images
It's weird to reference an out-of-date W3C HTML spec. Is this in the WHATWG spec? Or in CSS?
> Source/WebCore/rendering/RenderImage.cpp:269 > + // category of possible unwanted content.
possibly unwanted? Does this mean that it's pseudoelement content? Is there a more explicit check for this?
> Source/WebCore/rendering/RenderImage.cpp:304 > + if (shouldCollapseToEmpty()) { > + // Image might need resizing when we are at the final state. > + setNeedsLayout(); > + }
What about the other direction? Good image swapping to a bad image? Do we get here?
zalan
Comment 18
2020-02-17 12:53:04 PST
Created
attachment 390961
[details]
Patch
zalan
Comment 19
2020-02-17 12:55:29 PST
(In reply to Simon Fraser (smfr) from
comment #17
)
> Comment on
attachment 390893
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=390893&action=review
> > > Source/WebCore/ChangeLog:16 > > +
https://www.w3.org/TR/2016/WD-html51-20160412/rendering.html#replaced-elements-images
> > It's weird to reference an out-of-date W3C HTML spec. Is this in the WHATWG > spec? Or in CSS?
I didn't even notice it was an out-of-date spec. Updated to WHATWG.
> > > Source/WebCore/rendering/RenderImage.cpp:269 > > + // category of possible unwanted content. > > possibly unwanted? > > Does this mean that it's pseudoelement content? Is there a more explicit > check for this? > > > Source/WebCore/rendering/RenderImage.cpp:304 > > + if (shouldCollapseToEmpty()) { > > + // Image might need resizing when we are at the final state. > > + setNeedsLayout(); > > + } > > What about the other direction? Good image swapping to a bad image? Do we > get here?
Good->bad case is actually what is covered here. The bad->good case is covered implicitly through geometry changes since the "bad" state has (0, 0) dimension.
WebKit Commit Bot
Comment 20
2020-02-17 14:23:08 PST
Comment on
attachment 390961
[details]
Patch Clearing flags on attachment: 390961 Committed
r256773
: <
https://trac.webkit.org/changeset/256773
>
WebKit Commit Bot
Comment 21
2020-02-17 14:23:09 PST
All reviewed patches have been landed. Closing bug.
youenn fablet
Comment 22
2020-02-17 14:48:20 PST
Reopening to attach new patch.
youenn fablet
Comment 23
2020-02-17 14:48:21 PST
Created
attachment 390986
[details]
Patch
youenn fablet
Comment 24
2020-02-17 14:50:53 PST
Comment on
attachment 390986
[details]
Patch Wrong bug
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug