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

Bug 401301

Summary: [Browser] Default font inconsistent in Browsers
Product: [RT] RAP Reporter: Heiner Napp <h.napp>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: ivan, ruediger.herrmann
Version: 2.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Heiner Napp CLA 2013-02-20 06:54:21 EST
The folllowing Code shows a normal labeltext an a big browsertext in IE ( Version 8.0 ). In Chrome the size is equal.

Display display = new Display();
Shell shell = new Shell(display, SWT.NONE);
shell.setMaximized(true);
Label label = new Label(shell, SWT.NONE);
label.setBounds(20, 20, 400, 25);
label.setText("text in label");
Browser browser = new Browser(shell, SWT.NONE);
browser.setBounds(20, 50, 400, 400);
browser.setText("text in browser");
shell.open();
Comment 1 Ivan Furnadjiev CLA 2013-03-06 04:05:05 EST
Browser#setText method is used the set *html* content in the browser widget. If you want to have a cross-browser styling of your html content you have to ensure this in the html content itself. I don't think that RAP as a framework should do this. I will close it as NOT_ECLIPSE. Please reopen if you disagree.
Comment 2 RĂ¼diger Herrmann CLA 2013-03-06 05:55:40 EST
When setting an HTML snippet like "<html><body>Hello World</body></html>" that doesn't specify a particualr font, I would expect that the font of the browser widget (or the one inherited from its parent) is used.
It seems that this is not the case, at least on IE 8.
Comment 3 Ivan Furnadjiev CLA 2013-03-06 06:17:22 EST
The Browser widget in RAP is an iframe. The style of the HTML document inside the iframe cannot be inherited from the 'parent' document. The only way to change the document style (font, background etc) is to do it into the document itself. I don't think that RAP as a framework should modify the user's html/document in order to set these default properties. You could change your snippet like:
<html><body style="font:...; background-color: transparent;...">Hello World</body></html>
Thus your text inside the Browser widget will look the same in all browsers.
Comment 4 Ralf Sternberg CLA 2013-03-06 06:36:27 EST
(In reply to comment #2)
> When setting an HTML snippet like "<html><body>Hello World</body></html>" that
> doesn't specify a particualr font, I would expect that the font of the browser
> widget (or the one inherited from its parent) is used.

This is also not the case in SWT. Browser#setFont doesn't seem to have an effect.

Could a Label with markup support be an alternative for your use case?
Comment 5 Ivan Furnadjiev CLA 2013-03-06 06:38:34 EST
... and to have stronger arguments about what I'm saying... I've tested it in SWT and the Browser font is not respected there too. The snippet:
Browser browser = new Browser( parent, SWT.NONE );
browser.setFont( new Font( browser.getDisplay(), "Arial", 26, SWT.BOLD ) );
browser.setText( "<html><body>Hello World</body></html>" );
does not make the the "Hello World" with Arial, 26, bold font. :-)
That's why I even think now that the bug is INVALID.
Comment 6 RĂ¼diger Herrmann CLA 2013-03-06 07:33:59 EST
OK, you convinced me, this ain't no RAP bug :-)

Thanks for the markup label hint. The use case is to display a mailto-link with a background image:
  <div style="background-image:..." background-repeat:no-repeat>
  <a href="mailto:help@example.com">Support</a>
  </div>
This code 
  label  = new Label( parent, style );
  label.setData( RWT.MARKUP_ENABLED, Boolean.TRUE );
  label.setText( "<a href='mailto:help@example.com'>Support</a>" );
  label.setBackgroundImage( ... );
shows the <a> tag as desired but the background-image should not repeat. Is there a (CSS?) way to tell setBackgroundImage to show the image with npo-repeat?
Comment 7 Ivan Furnadjiev CLA 2013-03-06 07:45:22 EST
(In reply to comment #6)
> Is there a (CSS?) way to tell setBackgroundImage to show the image with npo-repeat?
We have a bug 361799 opened and the work is in progress.