Further to my investigations on whitespace problems, documented
at http://gair.firstpr.com.au/public-files/mozilla-bugs/ and

  http://bugzilla.mozilla.org/show_bug.cgi?id=61228

I have developed this series of simple tests cases show 
problems which must be fixed before the more complex problems 
of Composer's whitespace handling can be tackled - and before 
Composer can be much use to anyone.

It includes proof that "View HTML Source" changes Composer's
internal data structure, and the content of any file which is
subsequently saved.

Follow these instructions precisely.  Don't use "View HTML
Source" at all except at the end.

I did this with Win98 2000112908.  But I believe it is not
platform-specific.

Since these tests are extremely simple and reproducible, they
should lead to quick identification of at least some of the
faulty mechanisms I identifed in my third page on whitespace
problems at the above URL.

Once these problems are fixed, then there will be fewer problems
and the remaining glitches should be easier to investigate. 




Open composer with a blank page. 

Save the page as 0.html and close Composer.  For purity, don't give 
these files any title, though Composer will keep asking you to do so.

I will show the file contents verbatim, with a "#" for a space, 
except in the tags.



----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
##<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
##<title></title>
</head>
<body>
<br>
</body>
</html>
----------------



Open 0.html and type "The ".

Save this as 1.html and close Composer.

----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
###   
##<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
##<title></title>
</head>
#<body>
The##<br>
#
</body>
</html>
----------------



The rot has already set in.  We have an extra line in the header, 
which does not matter - but should point to a bug in need of 
extermination.

There are two spaces after "The". Don't ask me why!

A line with a space and newline has been added after that.  

The user has pressed the space bar exactly once but already there are
4 extra whitespace characters (depending on interpretation) in the file: 

  The space before <br>.

  The newline after <br>.

  The space and newline after those.  

If Composer was behaving properly, the results would be:

<body>
The#<br>
</body>

Now open 1.html and click after "T".  Now use the cursor keys to move the 
cursor as far to the right of "The " as it will go.  

The user thinks that this should take three right arrow presses, and that
there should be no further possible movement.  However, if you press the 
arrow key a fourth time, the cursor disappears and will not reappear with 
any keyboard action I can find.  Close the file without saving.

Open 1.html again and move the cursor to the right of the space immediately
following "The".

Now press "r".  Note how it is placed *2* spaces after "The".  

Now type: "ain ".

Then press the left arrow key 5 times to bring the cursor just to the left 
of "r". Press backspace so there is only one space between the words.

Save this as 2.html and close Composer.

----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
#######
##<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
##<title></title>
</head>
#<body>
#The#rain#<br>
###   
</body>
</html>
----------------



Open 2.html, position the cursor to the right of the space following "rain".
Type: "in ".

The moment the "i" key is pressed, two spaces appear to the left of "The".  
The rot has truly set in now.

Save as 3.html and close Composer:

----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
###########
##<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
##<title></title>
</head>
##<body>
&nbsp;#The#rain#in#<br>
#####
</body>
</html>
----------------



Open 3.html and position the cursor to the right of the space following "in".
Type: "Spain goes mainly down the drain. "  (Note trailing space.)

Save as 4.html and close Composer.

----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
###############
##<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
##<title></title>
</head>
#<body>
#&nbsp;#The#rain#in#Spain#goes#mainly#down#the#drain.#<br>
#######
</body>
</html>
----------------



Note there are now three spaces in front of "The".

Open 4.html and delete those pesky spaces at the start of the
line.  Do this with the cursor at the left of the line and by 
pressing Delete.  Note how the first two key presses seems to 
do nothing and the final one deletes two spaces. 

This sort of behaviour is really unsettling to the any user.

Type Control A and Control C to select all and copy to the 
clipboard.  Place the cursor to the left of "The" and press 
Control V for paste.  Do this another four times so you see
6 identical lines.

This looks good, but the file is very sus - it has a space at the 
start of each line.

Save as 5.html and close Composer.

----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
###################
##<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
##<title></title>
</head>
#<body>
#The#rain#in#Spain#goes#mainly#down#the#drain.#<br>
#The#rain#in#Spain#goes#mainly#down#the#drain.#<br>
#The#rain#in#Spain#goes#mainly#down#the#drain.#<br>
#The#rain#in#Spain#goes#mainly#down#the#drain.#<br>
#The#rain#in#Spain#goes#mainly#down#the#drain.#<br>
#The#rain#in#Spain#goes#mainly#down#the#drain.#<br>
#########
</body>
</html>
----------------



Open 5.html in Composer and press the End key to place the cursor as far as
it will go to the right of the first line.  Press Delete.  
The top line now appears very wrong.  There are two more pesky spaces at the 
far left and a total of three spaces between "drain." and "The".

Repeat the process of using End to go to the right of your growing paragraph 
and then Delete to bring the next line up into the paragraph.  You will need 
to you your trackball/mouse or down arrow to get to the end of the paragraph 
once it wraps in your window.

Save as 6.html and exit Composer.

Below, I have left spaces as spaces where they are obvious.

----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
#######################
##<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
##<title></title>
</head>
##<body>
&nbsp; The rain in Spain goes mainly down the drain. &nbsp; The rain in Spain
goes mainly down the drain. &nbsp; The rain in Spain goes mainly down the
drain. &nbsp; The rain in Spain goes mainly down the drain. &nbsp; The rain
in Spain goes mainly down the drain. &nbsp; The rain in Spain goes mainly
down the drain. <br>
###########
</body>
</html>
----------------



Now open 6.html and resize your window so that the following text is on the top line:


  The rain in Spain goes mainly down the drain.   The rain in Spain goes mainly down 
the drain.   The rain in Spain goes mainly down the drain.   The


This is three sentences and the word "The" of the fourth.

Click three times in the top line.  This should select the line.  
Now perform the following commands on this selection:

Format > Font > Helvetica/Arial.
Bold.  Italic.

Save as 7.html and close Composer.

----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
###########################
##<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
##<title></title>
</head>
#<body>
<i><b><font face="Helvetica, Arial, sans-serif"> &nbsp; The rain in Spain
goes mainly down the drain. &nbsp; The rain in Spain goes mainly down the
drain. &nbsp; The rain in Spain goes mainly down the drain. &nbsp; The</font></b></i>
 rain in Spain goes mainly down the drain. &nbsp; The rain in Spain goes
mainly down the drain. &nbsp; The rain in Spain goes mainly down the drain.
<br>
#############
</body>
</html>
----------------



Open 7.html and leave the cursor where it starts, at the top left corner.

Now it is time to get rid of those pesky spaces at the start of the file!

Watch the whole screen carefully as you press Delete.  Here's what happens:

1 - There is no change to the two spaces before the first "The".

2 - A space is *added* after the last bold italic "The.".


Feel like Mickey Mouse and the Sorcerer's multiplying broomsticks??  You have 
Faith, so press the Delete key again!

Like a gambling machine, you sometimes WIN!  The cursed spaces at the start 
are gone now.

Now place the cursor exactly at the right of the last bold italic "The" and prepare 
to get rid of another space by pressing Delete.  Success again!

Save the file as 8.html and close Composer.

----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
###############################
##<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
##<title></title>
</head>
#<body>
#<i><b><font face="Helvetica, Arial, sans-serif"> The rain in Spain goes
mainly down the drain. &nbsp; The rain in Spain goes mainly down the drain.
&nbsp; The rain in Spain goes mainly down the drain. &nbsp; The</font></b></i>
#rain in Spain goes mainly down the drain. &nbsp; The rain in Spain goes mainly
down the drain. &nbsp; The rain in Spain goes mainly down the drain. <br>
###############
</body>
</html>
----------------



Open 8.html.  Double click the first "Spain" to select it.  Then make it 
one size bigger and give it a bright red colour (Format > Text Color).  
Now place the cursor right after the final full-stop, press the right arrow 
button once, and type "x".

Two spaces appear at the start again - and another one appears just to the 
right of the last bold italic "The".  !!!!!!!

It is now apparent that the Space Monster concentrates its efforts on certain
itchy spots in your file.

Save this as 9.html and close Composer.

----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
###################################
##<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
##<title></title>
</head>
#<body>
&nbsp; <i><b><font face="Helvetica, Arial, sans-serif"> The rain in <font 
color="#ff0000"><big>
Spain </big></font>goes mainly down the drain. &nbsp; The rain in Spain goes
mainly down the drain. &nbsp; The rain in Spain goes mainly down the drain.
&nbsp; The</font></b></i>&nbsp; rain in Spain goes mainly down the drain.
&nbsp; The rain in Spain goes mainly down the drain. &nbsp; The rain in Spain
goes mainly down the drain. x<br>
#################
</body>
</html>
----------------



Open 9.html.

Now, you might expect that the Space Monster is ready to strike if you 
do one teensie bit more work on your file. 

Try placing your cursor just to the right of the "x" you have placed at the
end of your text.

Press "x".  No extra spaces!!   

Press Control Z to undo that last action.  (As far as I know, the Undo
function is *Immaculate*.)  


Now watch this very closely:

Select View > HTML Source.

Don't believe what you see there.  Composer's data structure is not at all
like an HTML file.  It is a tree-structured thing where elements such as 
"nbsp;" are reduced to single bytes (or double-bytes if you are using a 16 
bit character set).

Go back to View > Normal Edit mode.

Now put the cursor where you had it, immediately to the right of the "x".

Press "x" again.  An extra space DOES appear at the start of the file.

This constitutes absolute proof that using "View HTML Source" changes the
data structure in memory.  

Another proof is to open 9.html and save it as 9a.html.  Close Composer.  
Now open 9.html, View HTML Source, go back to View Normal Edit Mode and 
save it as 9b.html.

Both 9a.html and and 9b.html are different from the original 9.html, even
though you haven't changed a thing.  Those differences are not visible in a 
web browser, but Composer will no doubt read them in ways which cause 
differing patterns of whitespace problems in the future.

9a.html:
----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
#######################################
##<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
##<title></title>
</head>
#<body>
#&nbsp; <i><b><font face="Helvetica, Arial, sans-serif"> The rain in <font 
color="#ff0000"><big>
#Spain </big></font>goes mainly down the drain. &nbsp; The rain in Spain
goes mainly down the drain. &nbsp; The rain in Spain goes mainly down the
drain. &nbsp; The</font></b></i>&nbsp; rain in Spain goes mainly down the
drain. &nbsp; The rain in Spain goes mainly down the drain. &nbsp; The rain
in Spain goes mainly down the drain. x<br>
###################
</body>
</html>
----------------


9b.html:
----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
###########################################
  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
###
##<title></title>
</head>
#<body>
##&nbsp; <i><b><font face="Helvetica, Arial, sans-serif"> The rain in <font 
color="#ff0000"><big>
##Spain </big></font>goes mainly down the drain. &nbsp; The rain in Spain 
goes mainly down the drain. &nbsp; The rain in Spain goes mainly down the 
drain. &nbsp; The</font></b></i>&nbsp; rain in Spain goes mainly down the 
drain. &nbsp; The rain in Spain goes mainly down the drain. &nbsp; The rain 
in Spain goes mainly down the drain. x<br>
<br>
</body>
</html>
----------------

Both the above files are direct saves of 9.html.  9b.html shows two 
things which are notable with View HTML Source, even with a completely 
"empty" file:

1 - There are two blank lines added in the head section if they are 
    not already there.

2 - Every use of View HTML Source adds another <br> at the end.

The other changes are 2 spaces in front of the first two body lines, 
while the direct save of 9.html to 9a.html added 1 space on those lines.

At least "View HTML Source" cleaned up that pile of spaces at the end.  
That means your cursor can't drop off the end of the file.


Some bugs which may relate to this:

  http://bugzilla.mozilla.org/show_bug.cgi?id=46227
  http://bugzilla.mozilla.org/show_bug.cgi?id=55224
  http://bugzilla.mozilla.org/show_bug.cgi?id=59880



The text you are reading has been posted to newsgroup:

   netscape.public.mozilla.editor

and is available with all the files listed above at:


   http://gair.firstpr.com.au/public-files/mozilla-bugs/bugsville/



 -  Robin

Reply via email to