Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 405550

Summary: [Text] Height is larger than usual if contained text is very long
Product: [RT] RAP Reporter: Sebastien Arod <sebastien.arod>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.1 M2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Snippet project none

Description Sebastien Arod CLA 2013-04-12 05:53:12 EDT
Created attachment 229665 [details]
Snippet project

Text is Height is larger than usual if contained text is very long.

Reproducible case using the Attached Snippet Project:
* Run the snippet BugSnippetEntryPoint
* Initial text height is ok
* Click on the "Update very long text" button or type a very long text in the text widget
* Text height is still ok
* Click "Force layout" button or resize the browser window
=> The height is almost twice what it generally is
Comment 1 Sebastien Arod CLA 2013-04-12 06:17:49 EDT
Debugging the Text.computeSize() code it looks like the problem comes from TextSizeUtil.stringExtent( getFont(), text ). 
For short strings it returns an extent with y=8
For long strings it returns an extent with y=54

However debugging TextSizeStorageUtil further is too complex given my knowledge of RWT internals ;)
Comment 2 Ivan Furnadjiev CLA 2013-04-15 03:32:56 EDT
Sebastien, I found what the problem is. On the client we have a div responsible for text size measurement. Currently the div is positioned at -1000px on left to prevent the text auto wrapping if the text width is bigger than browser width. In your case the text *is* bigger than 1000 + browser width and it's autowrap by browser when measured. As a result you have 2 lines of text. I can easily increase this left offset from -1000 to -10000 which solves the problem. What I don't understand is the use case of setting of such a big text in a single text filed (without wrapping).
Comment 3 Ivan Furnadjiev CLA 2013-04-15 04:49:49 EDT
Fixed with commit 01123580890be0674d3d92db8453b0691578b963. Set measure node whiteSpace attribute to "nowrap" for texts that don't need wrapping.
Comment 4 Sebastien Arod CLA 2013-04-16 03:28:25 EDT
(In reply to comment #2)
> Sebastien, I found what the problem is. On the client we have a div
> responsible for text size measurement. Currently the div is positioned at
> -1000px on left to prevent the text auto wrapping if the text width is
> bigger than browser width. In your case the text *is* bigger than 1000 +
> browser width and it's autowrap by browser when measured. As a result you
> have 2 lines of text. I can easily increase this left offset from -1000 to
> -10000 which solves the problem. What I don't understand is the use case of
> setting of such a big text in a single text filed (without wrapping).

Hi Ivan,

Thanks for the fix. I agree that displaying such a long text in a single line text field is not ideal however it's still usable using text selection to scroll through the content. 
Regarding our usecase: our application generates forms from metedata described by user. When the user chooses that we should display some data as a single line text we respect users choice even if the content is large and we end up with the reported bug.

Thanks
-Seb