Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[XulRunner] Problem with browser element

89 views
Skip to first unread message

GMouron

unread,
May 18, 2012, 12:32:13 PM5/18/12
to
Hi,

I already asked my question there https://forums.mozilla.org/addons/viewtopic.php?f=7&t=9930
, but someone advised me to ask my question on this group.
I hope it's the right place. My post will be mostly a copy/paste of
the post in the mozilla forums.

I am trying to build an application based on XulRunner. This
application will need to display some html pages so I want to use the
browser element (https://developer.mozilla.org/en/XUL/browser)
However it does not seem to work. Here is my very simple code :

main.xul :

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window id="main" title="This is my app" width="500" height="500"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<browser src="http://www.mozilla.org" type="content-primary" />
</window>

When I try to start the application (using Firefox as XulRunner), I
get this :

Gmo:MyApp gmo$ /Applications/Firefox.app/Contents/MacOS/firefox -app /
Users/gmo/code/MyApp/application.ini -purgecaches
2012-05-16 20:37:12.445 firefox[5798:903] invalid drawable

I'm running with Firefox 13 on Mac OS X Snow Leopard. I have the same
result on Firefox 13 with WIndows XP (albeit no error message, just a
blank window)
Note that if I replace the browser by an iframe, the page is correctly
dislayed.

Any ideas ?

Thanks

Neil

unread,
May 20, 2012, 6:52:34 PM5/20/12
to
GMouron wrote:

> <browser src="http://www.mozilla.org" type="content-primary" />
>
Does adding flex="1" to the browser make any difference?

--
Warning: May contain traces of nuts.

reverendlinux

unread,
May 28, 2012, 4:00:33 PM5/28/12
to
I was able to get it working with some caveats. The only way I could
get the browser to display was in a straight dialog or window element
with no container. Placing the browser element in an iframe or vbox
would cause the src to not be displayed. Hope that's clear. For
example this code works:

<dialog
title="Browser"
onload="window.resizeTo(screen.availWidth,screen.availHeight);"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
style="background-color: white;">

<browser src="http://www.mozilla.org" type="content" flex="1" />

</dialog>


But this code does not:

<dialog
title="Browser"
onload="window.resizeTo(screen.availWidth,screen.availHeight);"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
style="background-color: white;">

<vbox>
<browser src="http://www.mozilla.org" type="content" flex="1" />
</vbox>

</dialog>

This was tested using XULRunner 12.0 on Fedora 16.

On another note, I remember reading somewhere that it's better
security practice to call the local system's browser versus using the
browser element when displaying external sites. Is that still true?
Was it ever true?

Neil

unread,
May 28, 2012, 5:08:19 PM5/28/12
to
reverendlinux wrote:

>this code does not:
>
><dialog
> title="Browser"
> onload="window.resizeTo(screen.availWidth,screen.availHeight);"
> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
> style="background-color: white;">
>
> <vbox>
> <browser src="http://www.mozilla.org" type="content" flex="1" />
> </vbox>
>
></dialog>
>
>
Try it with <vbox flex="1">.

reverendlinux

unread,
May 28, 2012, 9:57:25 PM5/28/12
to
Okay, that worked. So why is flex="1" needed in both elements?

Neil

unread,
May 29, 2012, 4:47:36 AM5/29/12
to
reverendlinux wrote:

>So why is flex="1" needed in both elements?
>
>
The default size of a <browser>, <vbox> or <hbox> is 0x0. So you need to
do something to get them to take up space in the window. In your case of
a <browser> inside a <vbox>, you need to make the <vbox> take up space
in the window, which then gives you the chance to make the <browser>
take up space in the <vbox>.
Now for horizontal space you don't actually need to do anything as both
<window> and <vbox> will by default stretch their children to their own
width, so the <browser> is already the correct width. (You can if
necessary modify this using the align attribute.) However, you still
need to do something about the height of the browser. The flex="1" on
the browser will make it consume all the "spare" height of the <vbox>,
but that assumes that it has some to spare. To achieve this, you also
need to add flex="1" to the <vbox>, so that it will consume all the
spare height of the window.
0 new messages