FW: NoWrap property

Hi

We are trying to decide on what is the best behavior for line wrapping on the boundary of "whitespace:nowrap". CSS2.1 spec is clear that it *doesn't* define line wrapping algorithms. It would be ideal however to choose what is preferable.

The particular question we want to answer is:

"If there is break opportunity between NoWrap span and following character, does NoWrap span prohibit it?"

Attached is an example with a nowrap element ending with a space, followed by a non-space character, by a space and by another nowrap. Interestingly enough there is a whole range of behavior in current implementation. There is even a case where adding nowrap creates a new break opportunity where there isn't one before...

Do people have preference for how this should behave?

One option is to treat nowrap as something that doesn't contain spaces (or all spaces are nonbreaking). That is easy to implement and consistent.

Another option is to say that 'nowrap' means that no part of this element can be moved to another line, but if a break previously existed on its edge it will still be allowed with nowrap.

Obviously there are more options...


[cid:image001.png@01C9559F.CFE45AE0]

From: Sergey Genkin
Sent: Thursday, November 27, 2008 2:25 PM
To: Alex Mogilevsky
Cc: Eugene Veselov; Sergey Malkin; Igor Zverev; Sylvain Galineau; Arron Eicholz
Subject: RE: NoWrap property


I would like to do the right thing right now. The problem is that I am still not convinced that your intuition is correct. Can we involve more people (program management? CSS committee?) in this discussion?

It would be great if we could define "correct" behavior, and never change it in the future.

________________________________
From: Alex Mogilevsky
Sent: Monday, November 24, 2008 6:03 PM
To: Sergey Genkin
Cc: Eugene Veselov; Sergey Malkin; Igor Zverev; Sylvain Galineau; Arron Eicholz
Subject: RE: NoWrap property
It seems there are two questions here: (1) what is the right thing to do, and (2) is the current behavior acceptable.

For (1), my intuition suggests that setting 'nowrap' around a piece of content that wouldn't otherwise have a wrap inside it, shouldn't change layout. Which means I would expect that 'nowrap' ending with a space does have a break opportunity after it. That makes the model simple and removes any questions on what happens with whitespace collapsed across a boundary of nowrap.

CSS2.1 section 16.6.1 doesn't provide specific requirements for where there must be a break opportunity

Note. CSS 2.1 does not fully define where line breaking opportunities occur.

, so the answer for (2) is probably yes.

The case of whitespace crossing 'nowrap' boundary can be pretty confusing though - a perfectly breakable space is getting eaten by a non-breaking space, even though it is outside of the 'nowrap' element...


From: Sergey Genkin
Sent: Monday, November 24, 2008 12:21 PM
To: Alex Mogilevsky
Cc: Eugene Veselov; Sergey Malkin; Igor Zverev
Subject: NoWrap property

There is a problem with implementation of NoWrap property.

There is one important question that allows different interpretations:
If there is break opportunity between NoWrap span and following character, does NoWrap span prohibit it?

And there is one important principle in PTLS approach to this problem that that we are not prepared to violate:

Adding NoWrap span never introduces new break opportunities, it can only prohibit some break opportunities.

Another principle is being consistent.

I tried to answer the question in blue analyzing how different browsers lay out the enclosed NowrapEndsOnSpaceFollowedByText.htm document:

<DIV style="width:200px;border:3px solid red">
  <span style="white-space: nowrap;">nowrap text one and </span>longlonglonglong...continuation
</DIV>

Results were inconclusive:

IE7 and Firefox do not break, Opera and Safari do break.

Then I tried small modification, surrounding the end of the text with another NoWrap span - NowrapEndsOnSpaceFollowedByNoWrapSpan.htm:

<DIV style="width:200px;border:3px solid red">
  <span style="white-space: nowrap;">nowrap text one and </span><span style="white-space: nowrap;">longlonglonglong...continuation</span>
</DIV>

Results did not change for Firefox and Opera.
Safari stopped breaking.
IE7 did break violating the main principle of PTLS implementation (new break opportunity was introduced after adding NoWrap span).

Another interesting modification for browsers that did not break in first example (IE7 and Firefox) is starting following text with space. Spaces inside and outside NoWrap span collapse, and it is interesting if they treat this collapsed space as break opportunity or not. This was tested with file NowrapEndsOnSpaceFollowedSpace.htm:

<DIV style="width:200px;border:3px solid red">
  <span style="white-space: nowrap;">nowrap text one and </span> longlonglonglong...continuation
</DIV>

Results are of course different:
IE7 does not break; Firefox breaks.

Last experiment shows that if continuation of the text is on the new line, Firefox treats it differently. It breaks in both NowrapEndsOnSpaceFollowedByTextOnNextLine.htm and NowrapEndsOnSpaceFollowedByNoWrapSpanOnNextLine.htm.

It is clear that we are not going to be compatible with all these crazy behaviors.

Still we would like to have answer to the question above in blue, implement behavior consistent with this answer and stand by it. We would prefer the answer that is implemented in current code: NoWrap span does not allow break after its last character. Still we are open to changing this behavior if you find it necessary.

Thanks,
Sergey

Received on Thursday, 4 December 2008 07:45:42 UTC