[Mozile] White space handling
James A. Overton
james at overton.ca
Thu Jun 1 12:51:27 EDT 2006
I believe that I've fixed three of Max's four bugs (http://
www.mozdev.org/pipermail/mozile/2006-June/001055.html). The cursor
shouldn't disappear anymore, tabs are now ignored, and merging is
fixed. The only one left is inline white space handling, about which
I wanted to ask some questions.
You can now see on the demo page (http://mozile.mozdev.org/0.8/demo/
basic.html) the current behaviours:
- If you press "enter" the current element is split, and if you
press "enter" again more "p" or "li" elements are created. In order
to make them render properly, Mozile inserts a \u00A0 non-breaking
space (NBSP). When text is inserted in a text node which only
contains an NBSP the NBSP character is removed.
- Right now whenever you press "space" a space character is inserted
(ASCII code 32). Ten "space" keypresses means 10 spaces inserted.
Under IE the ten spaces are all visible, but Firefox 1.5 obeys the
standard X/HTML white space rules and only a single space is visible.
A space at the end of block is visible under IE but not visible under
Firefox. Older versions of Mozile used to insert alternating NBSPs
and spaces to make sure the user got what was expected.
The question is: How *should* white space be handled?
There isn't much that can be done to change the way the browsers
render spaces. CSS "white-space" declarations affect spaces and
newlines, which isn't helpful. What can be changed is when white
space characters are allowed to be inserted, and conversion of
inserted spaces into NBSPs to make sure that they show up.
I think that the key to answering the question is to decide whether
you want to maintain XML white space semantics, or you want to
display what the user types like a word-processor. In different
situations people will want Mozile to do both of these things, so I
propose three "white space modes":
- "collapse": consecutive white space characters are treated as a
single character, so pressing "space" 10 times will insert only 1
space character.
- "display": every white space character entered by the user should
be visible, so pressing "space" 10 times will insert spaces (and
NBSPs) as needed to display 10 spaces. This would probably be the
default.
- "manual": don't do anything fancy, just insert what the user types.
The implementation could be tricky, but I don't see any barriers. It
might also be useful to have code that cleans up white space before
the content is saved. Also, I'm not sure what the "tab" key should be
doing in all of this. It could be treated as a "\t" character, or a
space, or used to trigger a command. The CSS white-space mode could
also make a difference. Right now it's just ignored.
Those are my thoughts. I'd really like to hear what other people
think about how Mozile should handle white space.
James
More information about the Mozile
mailing list