Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 303087 - [JFace] Make FontDescriptor implementation more RAP-friendly
Summary: [JFace] Make FontDescriptor implementation more RAP-friendly
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact: Susan McCourt CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-17 11:54 EST by Rüdiger Herrmann CLA
Modified: 2010-07-24 03:55 EDT (History)
1 user (show)

See Also:


Attachments
Patch (7.27 KB, patch)
2010-02-17 11:58 EST, Rüdiger Herrmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rüdiger Herrmann CLA 2010-02-17 11:54:30 EST
Background:
RAP re-uses the JFace source code with some internal modifications to provide the same API for web-development as is known from rich-client -development. To minimize the changes necessary to adopt the JFaces sources I suggest the following change:
All code that manipulates FontData should re-create fonts instead of using the setStyle() and setHeight() methods. RAP shares FontData across sessions and thus provides a subset of the FontData class from SWT that is immutable and hence does not have setters. 
This change would bring RAP one step closer re-use JFace code without changes.
I will attach a patch with the necessary changes.
Comment 1 Rüdiger Herrmann CLA 2010-02-17 11:58:10 EST
Created attachment 159338 [details]
Patch
Comment 2 Boris Bokowski CLA 2010-02-19 12:31:08 EST
Rüdiger, did you look at the performance implications of making this change? It would be good to understand if this could lead to cases where Eclipse got slower in a way that is noticeable by end users.
Comment 3 Rüdiger Herrmann CLA 2010-02-22 06:49:09 EST
I did a very naive test (currentTimeMillis, see code below) that simulates calling FontDescriptor#setHeight() before and after the change. On my machine, the change becomes measurable (1 ms) after 200 iterations.
Is this low enough to count as not noticeable?

	public static void main( String[] args ) {
		int count = 200;
		Display display = Display.getDefault();
		Font systemFont = display.getSystemFont();
		FontData fontData = systemFont.getFontData()[ 0 ];
		// simulate "old" approach: FontDescriptor#setHeight is forwarded to FontData#setHeight
		int delta = 1;
		long start = System.currentTimeMillis();
		for (int i = 0; i < count; i++) {
			fontData.setHeight( fontData.getHeight() + delta );
			delta = delta * ( -1 );
		}
		System.out.println( "duration before patch: " + ( System.currentTimeMillis() - start ) );
		// simulate "RAP-frienly" approach: FontDescriptor#setHeight re-creates FontData
		delta = 1;
		for (int i = 0; i < count; i++) {
			fontData = new FontData( fontData.getName(), fontData.getHeight() + delta, fontData.getStyle() );
			delta = delta * ( -1 );
		}
		System.out.println( "duration after patch: " + ( System.currentTimeMillis() - start ) );
	}
Comment 4 Rüdiger Herrmann CLA 2010-07-24 03:55:22 EDT
In the meanwhile we found a way to support the setStyle() and setHeight() methods in RAP.