Thanks Timothy!

Yeah, this is far from being trivial..

If fact, this is one of the aspects that I'm trying to evaluate and compare
with WebKit and IE. So far, Gecko solution seems to be much more complex.

But what would you say about using XULRunner, build a regular XUL
application and use XPCOM to link the UI with the C++ logic behind? Is that
the case you've mentioned and pointed debugging as the big issue?

On Mon, Feb 1, 2010 at 16:17, Timothy Madden <[email protected]> wrote:

> Pedro P. Ribeiro wrote:
> > Hey guys!
> >
> > I'm having a hard time trying to understand how this works. What I need
> is
> > simple to write a Win32 C++ application, like a Wizard, but with the
> > interface designed in HTML and JavaScript.
> >
> > I've already done that using WebKit and IE, but now I also want to use
> Gecko
> > for comparison purposes.
> >
> > The thing is that I can't find a clear start point. The informations
> seems
> > to be conflicting, sometimes I read about Gecko, sometimes XULRunner, and
> > I'm not sure what should I use. Is there a SDK, or a set of libraries
> that I
> > can just include to my project?
> >
> > I appreciate the attetion.
>
> What I did, on Windows with Visual Studio 2008 with mozilla-1.9.1, was
> download the mozilla sources for Firefox and follow the build
> instructions referred to from there. You might need to search a little
> for the sources on the mozilla web site, but they are there. Also I
> have read on the web site that you can simply download the SDK if you
> want, but I guess you will still need the sources for any form of
> useful debugging (unless you can just write your programs without any
> mistake :) ). Having the debugger download the public symbol files
> from Microsoft online symbol store for all the system .dll files will
> also help.
>
>
> The mozilla sources can be used to build more than one application,
> i.e. you can build thunderbird, firefox, calendar, seamonkey, etc. One
> of these applications, that you can also build with just the sources
> for Firefox, is called xulrunner and is the SDK you need for
> embedding. The build process presented on the site just worked for me
> and I will not repeat it here. You have to expect some more work than
> a simple setup-like installation, though ...
>
> After building xulrunner application you can also proceed to building
> the SDK with *make sdk* in the build directory. The resulting .zip
> file is what you need to unpack and include in your project.
>
> I chose to include the .zip as is in my project and define a custom
> build step that invokes a makefile to unpack the archive anytime it is
> needed, so as to not actually include all those many files in my
> project.
>
> You then include the libraries from the sdk/lib/ folder, and the files
> from include/ and sdk/include/ folders. The SDK has a strange
> directory structure that is not clearly documented. They say somewhere
> on the site that those include directories are sufficient, but I found
> I also need to use subdirectories as include dirs.
>
> What they do not say is that you have to pay attention to the order of
> libraries. If you get it wrong you will get undefined symbols. Here is
> the order I use:
>    xpcom.lib
>    xpcomglue_s.lib
>    embed_base_s.lib
>    crmf.lib
>    ssl3.lib
>    mozreg_s.lib
>    plc4.lib
>    plds4.lib
>    smime3.lib
>    nspr4.lib
>    nss3.lib
>    nssutil3.lib
>    unicharutil_external_s.lib
>    xul.lib
>    js3250.lib
>
> They say that instead of xpcom and xpcomglue_s you can also link
> against just xpcomglue, but do not use all three of them at once. I
> also had to disable linking of the default library msvcrt.lib (which
> is normal that it should not be linked on Debug configuration).
>
> For the include directories I use I will give you the list but I think
> it is less important for you because I also need to use some internal
> stuff from Mozilla, that you should probably not need, so the list
> here is longer than what you need:
>
>
> $(ProjectDir)..\Redist\dbg\xulrunner-sdk\sdk\include
> $(ProjectDir)..\Redist\dbg\xulrunner-sdk\include
> $(ProjectDir)..\Redist\dbg\xulrunner-sdk\include\xpcom
> $(ProjectDir)..\Redist\dbg\xulrunner-sdk\include\gfx
> $(ProjectDir)..\Redist\dbg\xulrunner-sdk\include\widget
> $(ProjectDir)..\Redist\dbg\xulrunner-sdk\include\layout
> $(ProjectDir)..\Redist\dbg\xulrunner-sdk\include\content
> $(ProjectDir)..\Redist\dbg\xulrunner-sdk\include\dom
>
>
> I have not seen these actually documented on the web site (the sources
> also do not include documentation).
>
> With these include dirs, the files I need to include are (again, these
> are more than what you need):
>
> /* Include XPCOM and Gecko/Mozilla headers */
>
> // Tell XPCOM the current platform is Windows
> # ifndef XP_WIN
> #  define XP_WIN
> # endif
>
> // Save current warning level and set it to 3 (default)
> # pragma warning(push, 3)
> # pragma warning(disable: 4996) // 'function' was declared deprecated
>                                // some XPCOM headers use strdup which
>                                // by VS2008 should be deprecated
>
> # include "nsError.h"
> # include "nsIInterfaceRequestor.h"
> # include "xpcom/nsIInterfaceRequestorUtils.h"
> # include "nsWeakReference.h"
> # include "nsCOMPtr.h"
>
> # include "gfx/nsIRenderingContext.h"
> # include "widget/nsIWidget.h"
> # include "widget/nsIBaseWindow.h"
>
> # include "nsIWebBrowser.h"
> # include "nsIWebBrowserSetup.h"
> # include "nsIWebBrowserChrome.h"
> # include "nsIEmbeddingSiteWindow.h"
>
> # include "nsIDOMEventListener.h"
> # include "nsIDOMWindow.h"
>
> # include "content/nsPIDOMEventTarget.h"
> # include "content/nsINode.h"
> # include "content/nsIContent.h"
> # include "content/nsIDocument.h"
> # include "nsComponentManagerUtils.h"
> # include "layout/nsIPresShell.h"
> # include "docshell/nsIDocShell.h"
> # include "docshell/nsIWebNavigation.h"
> # include "dom/nsIDOMNode.h"
> # include "dom/nsIDOMElement.h"
> # include "dom/nsIDOMEvent.h"
> # include "dom/nsIDOMDocument.h"
> # include "dom/nsIDOMWindow2.h"
> # include "dom/nsIDOMWindowCollection.h"
> # include "dom/nsIDOMEventTarget.h"
> # include "nsIWebBrowserFocus.h"
> # include "nsEmbedAPI.h"
> # include "nsEmbedCID.h"
>
> # include "nsStringAPI.h"
>
> // Restore warning level
> # pragma warning(pop)
>
> Yes, it is a long list, and it is strange you have to include all that
> line by line. I made a separate precompiled header for this list
>
> As you can see you should also define XP_WIN in your project.
>
> All these lists are made on an as-needed bases, or ad-hoc if you want.
> The documentation on the subject is exemplary lacking from the MDC.
> The entire documentation site is search-based and I found that more
> often than not what I need is not documented (or not documented yet)
> and can not be found.
>
> With the documentation so scarce, you definetly need a good source
> code browser (I use ctags with vim) and search the interfaces in the
> header files for one that does what you need, then, include the file
> you find is appropriate to provide you that interface.
>
> After getting these you just need to call
>
>  NS_InitEmbedding/NS_TermEmbedding,
>  do_CreateInstance(NS_WEBBROWSER_CONTRACTID)
>  nsIWebBrowser::SetContainerWindow,
>  do_QueryInterface for nsIBaseWindow,
>  nsIBaseWindow::Init
>  nsIBaseWindow::Create
>  do_QueryInterface for nsIWebNavigation
>  nsIWebNavigation::LoadURI
>
> and implement yourself a component exposing nsIWebBrowserChrome,
> nsIWeakReference and nsIInterfaceRequestor. Also nsIDOMEventListener
> might be helpfull.
>
> However these actual programming details are better documented if you
> search the MDC site.
>
> It is not exactly a robust product as they say, actually it is
> immature with respect to embedding, but it works, so good luck with
> it.
>
> Hope that helps anyone.
>
> Timothy Madden
>
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding

Reply via email to