Open Bug 1502610 Opened 7 years ago Updated 1 year ago

Unnecessary line break when using negative margins on an inline-child of an inline-block element

Categories

(Core :: Layout: Block and Inline, defect, P3)

defect

Tracking

()

Tracking Status
firefox65 --- wontfix

People

(Reporter: mstange, Unassigned)

References

Details

Attachments

(4 files)

I don't know if this behavior is per spec, but it differs from Chrome. Steps to reproduce: 1. Load this testcase: data:text/html,<span style="display:inline-block"><span style="margin-right:-1px">Two words</span></span> Expected results: The text "Two words" should be within one line. Actual results: There is a line break between "Two" and "words" Chrome has no line break. I encountered this issue on https://w3c.github.io/navigation-timing/#issue-container-generatedID-3 where Respec's default styling hits this bug on certain types of references.
Attached file testcase
Attached file further testcase
I haven't dug through the spec, but experimenting a bit further I'd say Chrome's behavior (shared by Safari, FWIW) seems pretty weird. Try gradually increasing the negative right margin using the slider in this example, and watch how the second testcase (with spaces in "w o r d s") behaves... makes no sense, afaict.
Edge never breaks, but never shrinks the inline-block either.
I wonder what Chrome's new engine does. If somebody has Canary around (I tested edge via browserstack) it can be turned on from the chrome://flags page. If it does something different it'd be wonderful :-)
Chrome's LayoutNG does a line break.
Blocks: 1476925

Fwiw, I re-tested this in the latest Canary with LayoutNG enabled
and it's still compatible with Firefox, so hopefully they'll ship
that soon :-)

Indeed, Chrome LayoutNG works like us... I filed a bug on the W3C to fix their stylesheet. It feels like we are doing the right thing here (bug in Safari then ;) ).

It feels like we are doing the right thing here

Um. I'm pretty sure the testcase here should pass. The point of shrink-to-fit sizing is to size the box to fit its content exactly without triggering any unforced line breaks. We're sizing to fit the content, we're just failing to fit the content into the resulting custom-fitted size... I'm guessing because the "extra space" created by the negative margin isn't accounted for when we're placing the text.

I'm not able to reproduce this via the following anymore in Nightly (web render enabled):
https://w3c.github.io/navigation-timing/#issue-container-generatedID-3

Maybe it got fixed by something else?

Not sure what's changed about the example at https://w3c.github.io/navigation-timing/#issue-container-generatedID-3, but Markus' testcase here (attachment 9020527 [details]) still fails on Nightly for me.

(In reply to Jonathan Kew (:jfkthame) from comment #11)

Not sure what's changed about the example at https://w3c.github.io/navigation-timing/#issue-container-generatedID-3

The content was updated so that respec is no longer "offended" by the element, and it was also regenerated with a version that includes the following workaround for this very issue:

/* TODO: Remove once https://github.com/w3c/tr-design/pull/176 is merged. */
.respec-offending-element a[href] {
  margin: 0;
}

While it's nice that the original site has been modified to work around the issue, the underlying bug in Gecko (as per comment 9) is still present. We should fix this.

Priority: -- → P3
No longer blocks: 1476925

Sorry, my mistake -- per bug 871224 comment 27, it turns out Chrome has changed behavior and matches us on that bug's testcases now. So this is not a dupe of that bug after all.

I'll dupe this family of bugs (which have unexpectedly-linewrapped text, with intrinsic sizing & margin-right & padding-right) to this bug here.

Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Status: REOPENED → NEW

Both Chrome and Firefox break the words with data:text/html,<span style="display:inline-block"><span style="margin-right:-1px">Two words</span></span>, while Safari doesn't.

However, if you use data:text/html,<span style="display:inline-block"><span style="padding-right:1px;margin-right:-1px">Two words</span></span>, only Firefox breaks the words.

This is a problem for me at https://explained-from-first-principles.com/email/tools/#dkim-record. Please fix! 🙂

Severity: normal → S3

The severity field for this bug is relatively low, S3. However, the bug has 5 duplicates.
:jfkthame, could you consider increasing the bug severity?

For more information, please visit auto_nag documentation.

Flags: needinfo?(jfkthame)

The last needinfo from me was triggered in error by recent activity on the bug. I'm clearing the needinfo since this is a very old bug and I don't know if it's still relevant.

Flags: needinfo?(jfkthame)

I've noticed this bug affecting the subtitles on the BBC website — I'm going to work around it by removing the negative margins from the subtitles, but I think this bug is still causing problems in the wild.

I've been looking at this with Robert Bryer and agree that this bug is causing us a significant subtitle and caption rendering issue, only on Firefox.

Additional observation: the unwanted line break happens with a negative margin only on the edge that the direction is pointing to, i.e. margin-right for direction: ltr and margin-left for direction:rtl.

If we do what he suggests and remove the negative margin, then we will not be able to render conformant to the subtitle spec (see EBU-TT-D Annex D) on any browser unless we try to detect the presence of this bug. If we leave it as is, then it will be conformant on other browsers, but unusably broken on Firefox. I would back the request to increase the severity of this bug.

Further observation: merely moving the last character on the line into a separate <span> and shifting the negative margin to that <span> causes the behaviour to look normal, i.e. it avoids the line wrap. That inconsistency also looks like a bug!

Duplicate of this bug: 1897682
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: