Dear experts,

I am trying to embed the Mozilla parser in my WIN32 C++ application, but now 
I am stuck.

First I tried using the XULRunner SDK. According to the documentation you 
should use the nsIWebNavigation interface to control the browser instance 
which is strange since this interface is not part of the SDK. How can I 
control the browser without either nsIWebNavigation nor nsIDocShell? I guess 
they are not part of the SDK because they are not frozen, but how can I then 
use the SDK?

When I did not find a solution using the XULRunner package I decided to 
download and build the whole Mozilla tree. Then I could use the non frozen 
APIs. However when trying to load an URL I get "Out of memory" error...

Here is the key points of what my app does:

1. Create native window
hwnd = CreateWindow(wclassname, wclassname, WS_OVERLAPPEDWINDOW, 
0,0,800,600,NULL,NULL,hInstance,NULL);

2. Initialize XPCOM
rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
I have also tried rv = NS_InitEmbedding(nsnull, nsnull);

3. Create mozilla browser
webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);

4. Get navigation interface
webNav = do_QueryInterface( webBrowser, &rv );

5. Set chrome that handles required interfaces: 
nsIEmbeddingSiteWindow/nsIWebBrowserChrome/nsIWebProgressListener
rv = webBrowser->SetContainerWindow(chrome);

6. Tell browser about the chrome type
setup = do_QueryInterface(webBrowser, &rv);
setup->SetProperty(nsIWebBrowserSetup::SETUP_IS_CHROME_WRAPPER, PR_TRUE);

7. Create the browser window
baseWindow = do_QueryInterface( webBrowser, &rv );
rv = baseWindow->InitWindow(nsNativeWidget(hwnd), nsnull, 0,0,800,600);
rv = baseWindow->Create();

8. Set up progress listener
webBrowser->AddWebBrowserListener(weakRefToChrome, 
NS_GET_IID(nsIWebProgressListener));

9. Make browser visible
rv = baseWindow->SetVisibility(PR_TRUE);

10. Load URL
rv = webNav->LoadURI(uri, nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, 
nsnull);

At this point I receive an Out of memory error (8007000e)

What am I missing?
Maybe some compile configurations?
Maybe something in the initialization?

Any help is greatly appreciated

/Emil Wikström

PS. The purpose of the application is to analyze the DOM of DHTML web pages 
(spider/scraper)
PPS. This is a C++ app so XULRunner/Javascript runtime scripting is not an 
option
PPPS. Ultimately this should be a service/daemon so I want to get rid of the 
GUI at some point

_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding

Reply via email to