Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » compute size of org.eclipse.swt.browser.Browser dependent on its content
compute size of org.eclipse.swt.browser.Browser dependent on its content [message #749907] Tue, 25 October 2011 14:06 Go to next message
Werner Hihn is currently offline Werner HihnFriend
Messages: 32
Registered: July 2009
Member
Hi everybody,

I'm integrating Browser widgets in a pretty complex GridLayout.
What I would like to achieve is this: The size of the browser should
be calculated depending on its content, i.e. it should grab as much
vertical space it needs and not display a scrollbar.
After some research I noticed that this is a known issue in swt [1].

I understand that it' s probably not possible to achieve this with
the known swt layouting techniques. So does anybody know a workaround
for this?
I already tried to use css styles ('overflow:visible'), but without success.

Thanks in advance for any hints,
Werner

[1] - https://bugs.eclipse.org/bugs/show_bug.cgi?id=232501
Re: compute size of org.eclipse.swt.browser.Browser dependent on its content [message #750034 is a reply to message #749907] Tue, 25 October 2011 15:40 Go to previous messageGo to next message
Austin Riddle is currently offline Austin RiddleFriend
Messages: 128
Registered: July 2009
Senior Member
Hi Werner,

I have wrestled with this issue as well. I wish I had a better answer, but the best that I have come up with is to set the size manually (in my case based on explicit knowledge of the content).
Re: compute size of org.eclipse.swt.browser.Browser dependent on its content [message #750038 is a reply to message #749907] Tue, 25 October 2011 15:40 Go to previous messageGo to next message
Austin Riddle is currently offline Austin RiddleFriend
Messages: 8
Registered: July 2009
Junior Member
Hi Werner,

I have wrestled with this issue as well. I wish I had a better answer, but the best that I have come up with is to set the size manually (in my case based on explicit knowledge of the content).
Re: compute size of org.eclipse.swt.browser.Browser dependent on its content [message #750040 is a reply to message #749907] Tue, 25 October 2011 15:43 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 335
Registered: July 2009
Senior Member
Werner,

The overflow CSS style wouldn't solve the problem. Apart from
overflow:visible isn't supported, it doesn't grow the size of the widget
(i.e. HTML element), instead it just doesn't clip at its bounds.

Did you try to use GridData with a widthHint? If you can either
calculate or estimate the size of the content or if you can calculate
the remaining width for the browser widget then this might help.

HTH
Rüdiger

On 25.10.2011 16:06, Werner Hihn wrote:
> Hi everybody,
>
> I'm integrating Browser widgets in a pretty complex GridLayout.
> What I would like to achieve is this: The size of the browser should
> be calculated depending on its content, i.e. it should grab as much
> vertical space it needs and not display a scrollbar.
> After some research I noticed that this is a known issue in swt [1].
>
> I understand that it' s probably not possible to achieve this with
> the known swt layouting techniques. So does anybody know a workaround
> for this?
> I already tried to use css styles ('overflow:visible'), but without
> success.
>
> Thanks in advance for any hints,
> Werner
>
> [1] - https://bugs.eclipse.org/bugs/show_bug.cgi?id=232501
>
--
Rüdiger Herrmann

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: compute size of org.eclipse.swt.browser.Browser dependent on its content [message #750051 is a reply to message #750040] Tue, 25 October 2011 15:52 Go to previous messageGo to next message
Cole Markham is currently offline Cole MarkhamFriend
Messages: 150
Registered: July 2009
Location: College Station, TX
Senior Member

This is really a limitation in HTML in general. From the parent page, there is no way to know what the size of the content in an iframe should be. The only thing I can think might work is to have the content of the iframe run a javascript function when it is done loading to compute its rendered size. Then callback into the parent (you could use BrowserFunction in SWT/RAP) to adjust the size of the Browser widget. Of course, this requires coordination from the nested content and will only work if both the parent and the content are from the same domain (desktop SWT would not have the crossdomain limitation since there is no origin domain).

Hope that helps,

Cole
Re: compute size of org.eclipse.swt.browser.Browser dependent on its content [message #753644 is a reply to message #750051] Fri, 28 October 2011 07:50 Go to previous message
Werner Hihn is currently offline Werner HihnFriend
Messages: 32
Registered: July 2009
Member
Thanks for the hints, they already pointed me in the right direction!

@Rüdiger: Yes, using a heightHint seems to be the only possible
solution. But as I don' t know the content I have to combine that with
the solution proposed by Cole.
So I'm using this javascript function [1] to determine the needed height
via browser.evaluate(function), use that as heightHint for the
gridData, and call layout() on the parent composite.

This seems to work in general, but there is still one drawback:
the browser is flickering a little (you can see the original size with
the scrollbar for a moment, before the new gridData is set).
I still have to spend a little time on that.

Thanks and Regards,
Werner

[1] -
var D = document;
return Math.max(
Math.max(D.body.scrollHeight, D.documentElement.scrollHeight)
Math.max(D.body.offsetHeight, D.documentElement.offsetHeight)
Math.max(D.body.clientHeight, D.documentElement.clientHeight));
Previous Topic:how to make two OSGi bundles and connect then?
Next Topic:XDocReport Eclipse RAP demo
Goto Forum:
  


Current Time: Sat Apr 27 02:36:44 GMT 2024

Powered by FUDForum. Page generated in 0.03249 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top