Bug 192634 - [Label] Label swallows subsequent whitespaces
Summary: [Label] Label swallows subsequent whitespaces
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.3 M2   Edit
Assignee: Rüdiger Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday
Depends on:
Blocks:
 
Reported: 2007-06-14 07:02 EDT by Rüdiger Herrmann CLA
Modified: 2009-09-14 05:36 EDT (History)
2 users (show)

See Also:


Attachments
Example scenario for html whitespace width (2.00 KB, text/html)
2008-05-29 07:07 EDT, Sebastian Fastner CLA
no flags Details
Example scenario for html whitespace wrapping (resize browser window) (1.14 KB, text/html)
2008-05-29 07:08 EDT, Sebastian Fastner CLA
no flags Details
Space width example rendered with Firefox (29.77 KB, image/png)
2008-05-29 07:09 EDT, Sebastian Fastner CLA
no flags Details
Rendered wrapping of thinsp in Firefox (14.57 KB, image/png)
2008-05-29 07:09 EDT, Sebastian Fastner CLA
no flags Details
Rendered wrapping of nbsp in Firefox (15.23 KB, image/png)
2008-05-29 07:10 EDT, Sebastian Fastner CLA
no flags Details
Patch for whitespace bug solved with   (3.02 KB, patch)
2008-05-30 13:37 EDT, Sebastian Fastner CLA
no flags Details | Diff
Proposed patch (7.30 KB, patch)
2009-09-11 08:33 EDT, Jordan Yakovchev CLA
no flags Details | Diff
Proposed patch (6.02 KB, patch)
2009-09-14 05:18 EDT, Jordan Yakovchev CLA
ruediger.herrmann: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rüdiger Herrmann CLA 2007-06-14 07:02:19 EDT
Label label = new Label( parent, SWT.NONE );
label.setText( "some     spaces      in     between" );

will show as "some spaces in between" in the browser.

As the Label widget uses an HTML fragment to show its content, the browser correctly eliminates subsequent whitespaces. 
Possible solutions:
- escape whitespaces with   or  
- escape every second subsequent whitespace with   (this way keep the wrapping behavior)

This not only applies to the Label widget but all other widgets that display text in some way.
Comment 1 Sebastian Fastner CLA 2008-05-29 07:06:33 EDT
There is an additional entity called   that also is a html whitespace character.

I created an whitespace example html file (test1.html) to compare the width of all whitespace entities. In my oppinion both   and   have to much width.   is a bit too small but it is a good solution. See spacewidthexample.png for rendering in Firefox.

The difference between  -wrapping and  -wrapping is a wrapping of whitespaces as block (thinsp) and wrapping whitespace as small pieces (nbsp).
Please take a look at both nbspwrapping.png and thinspwrapping.png (created from test2.html).

If the nbsp method is preferred a decision have to be made whether the last or second last whitespace is a wrapped whitespace (particularly with odd number of whitespaces). If the last one is a nbsp the word after the nbsp will never wrap without leading whitespace.
Comment 2 Sebastian Fastner CLA 2008-05-29 07:07:52 EDT
Created attachment 102607 [details]
Example scenario for html whitespace width
Comment 3 Sebastian Fastner CLA 2008-05-29 07:08:49 EDT
Created attachment 102608 [details]
Example scenario for html whitespace wrapping (resize browser window)
Comment 4 Sebastian Fastner CLA 2008-05-29 07:09:13 EDT
Created attachment 102609 [details]
Space width example rendered with Firefox
Comment 5 Sebastian Fastner CLA 2008-05-29 07:09:46 EDT
Created attachment 102610 [details]
Rendered wrapping of thinsp in Firefox
Comment 6 Sebastian Fastner CLA 2008-05-29 07:10:05 EDT
Created attachment 102611 [details]
Rendered wrapping of nbsp in Firefox
Comment 7 Sebastian Fastner CLA 2008-05-30 13:37:07 EDT
Created attachment 102913 [details]
Patch for whitespace bug solved with  
Comment 8 Jordan Yakovchev CLA 2009-09-11 08:33:58 EDT
Created attachment 146941 [details]
Proposed patch
Comment 9 Jordan Yakovchev CLA 2009-09-14 05:18:49 EDT
Created attachment 147083 [details]
Proposed patch
Comment 10 Rüdiger Herrmann CLA 2009-09-14 05:36:01 EDT
Applied patch to CVS HEAD