Hello, I've succeeded in embedding gecko 1.9 in a wxWidget window. It is a very simple beginning.
However, when the "http;//developer.mozilla.org" is loaded, I can see the noscript element : <div id="noscript"><p>Some features of this site require JavaScript.</ p></div>. That is to say, javascript is disabled. When I click on hyperlink, the application crashes. What is to be done to enable javascript ? Is it necessary to handle a profile like the ".vendor / app / profile.file " created by xulrunner ? Thanks a lot, Cyril. =============================================== #define XPCOM_GLUE #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include <iostream> #include "xpcom-config.h" #include "nsXPCOMGlue.h" #include "nsDebug.h" #include "nsCOMPtr.h" #include "widget/nsIBaseWindow.h" #include "nsILocalFile.h" #include "nsIWebBrowser.h" #include "nsIWebBrowserSetup.h" #include "nsStringAPI.h" #include "docshell/nsIWebNavigation.h" #include "nsEmbedCID.h" #include "nsEmbedString.h" #include "xulapp/nsXULAppAPI.h" #include "nsComponentManagerUtils.h" #include "docshell/nsIDocShell.h" #include "docshell/nsIDocShellTreeItem.h" #define wxCSTR wxString::FromAscii using namespace std; XRE_InitEmbeddingType XRE_InitEmbedding; XRE_TermEmbeddingType XRE_TermEmbedding; class MyApp : public wxApp { public: virtual bool OnInit(); }; class MyFrame : public wxFrame { public: MyFrame(const wxString& title); nsCOMPtr<nsIWebBrowser> webBrowser; nsCOMPtr<nsIWebBrowserSetup> webBrowserSetup; nsCOMPtr<nsIBaseWindow> baseWindow; nsCOMPtr<nsIWebNavigation> webNavigation; void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); void OnSize(wxSizeEvent& event); private: DECLARE_EVENT_TABLE() }; enum { Minimal_Quit = wxID_EXIT, Minimal_About = wxID_ABOUT, }; BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(Minimal_Quit, MyFrame::OnQuit) EVT_MENU(Minimal_About, MyFrame::OnAbout) EVT_SIZE(MyFrame::OnSize) END_EVENT_TABLE() IMPLEMENT_APP(MyApp) bool MyApp::OnInit() { if ( !wxApp::OnInit() ) return false; nsCOMPtr<nsILocalFile> libxul; nsCOMPtr<nsILocalFile> appDir; nsCOMPtr<nsILocalFile> profile; nsDynamicFunctionLoad nsFuncs[] = { {"XRE_InitEmbedding", (NSFuncPtr*)&XRE_InitEmbedding}, {"XRE_TermEmbedding", (NSFuncPtr*)&XRE_TermEmbedding}, {0, 0} }; nsresult rv; rv = XPCOMGlueStartup("/home/XXX/YYY/libxpcom.so"); if (NS_FAILED(rv)) { printf("XPCOMGlueStartup\n"); } rv = XPCOMGlueLoadXULFunctions(nsFuncs); if (NS_FAILED(rv)) { printf("XPCOMGlueLoadXULFunctions\n"); } rv = NS_NewNativeLocalFile(nsEmbedCString("/home/XXX/YYY"), PR_FALSE, getter_AddRefs(libxul)); if (NS_FAILED(rv)) { printf("NS_NewNativeLocalFile 1 \n"); } rv = NS_NewNativeLocalFile(nsEmbedCString("/home/XXX/ZZZ"), PR_FALSE, getter_AddRefs(appDir)); if(NS_FAILED(rv)) { printf("NS_NewNativeLocalFile 2\n"); } rv = XRE_InitEmbedding(libxul, appDir, nsnull, 0, 0); if (NS_FAILED(rv)) { printf("XRE_InitEmbedding\n"); } MyFrame *frame = new MyFrame(wxCSTR("Minimal wxWidgets App")); SetTopWindow(frame); frame->Show(true); printf("OnInit OK\n"); return true; } MyFrame::MyFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title) { nsresult rv; wxMenu *fileMenu = new wxMenu; wxMenu *helpMenu = new wxMenu; wxMenuBar *menuBar = new wxMenuBar(); helpMenu->Append(Minimal_About, wxCSTR("&About...\tF1"), wxCSTR("Show about dialog")); fileMenu->Append(Minimal_Quit, wxCSTR("E&xit\tAlt-X"), wxCSTR("Quit this program")); menuBar->Append(fileMenu, wxCSTR("&File")); menuBar->Append(helpMenu, wxCSTR("&Help")); SetMenuBar(menuBar); CreateStatusBar(2); SetStatusText(wxCSTR("Welcome to wxWidgets!")); webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv); if (NS_FAILED(rv)) { printf("do_CreateInstance webBrowser\n"); } nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface( webBrowser ); dsti->SetItemType( nsIDocShellTreeItem::typeContentWrapper ); baseWindow = do_QueryInterface(webBrowser); printf("Just before InitWindow\n"); rv = baseWindow->InitWindow(m_wxwindow, 0, 0, 0, 300, 400); if (NS_FAILED(rv)) { printf("InitWindow\n"); } printf("Just after InitWindow\n"); rv = baseWindow->Create(); if (NS_FAILED(rv)) { printf("Create\n"); } rv = baseWindow->SetVisibility(PR_TRUE); if (NS_FAILED(rv)) { printf("SetVisibility\n"); } webNavigation = do_QueryInterface(webBrowser); rv = webNavigation->LoadURI(NS_LITERAL_STRING("http:// developer.mozilla.org").get(), nsIWebNavigation::LOAD_FLAGS_NONE, 0, 0, 0); if (NS_FAILED(rv)) { printf("LoadURI\n"); } printf("MyFrame::MyFrame\n"); } void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { XRE_TermEmbedding(); XPCOMGlueShutdown(); Close(true); } void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { wxMessageBox(wxCSTR("This is the minimal wxWidgets sample\n"), wxCSTR("About wxWidgets minimal sample"), wxOK | wxICON_INFORMATION, this); } void MyFrame::OnSize ( wxSizeEvent &pEvent ) { printf("OnSize ... \n"); wxRect newRect = this->GetClientRect(); baseWindow->SetPositionAndSize( newRect.GetLeft(), newRect.GetTop(), newRect.GetWidth(), newRect.GetHeight(), PR_FALSE ); } Make : g++ `wx-config --cppflags` -fshort-wchar -c -g $(INCLUDE) wxgecko.cpp -DXPCOM_GLUE g++ -o wxgecko `wx-config --cppflags` `wx-config --libs` wxgecko.o -L$ (SDK)/lib/ -lxpcomglue _______________________________________________ dev-embedding mailing list dev-embedding@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-embedding