diff --git a/mozilla/embedding/base/nsEmbedAPI.cpp b/mozilla/embedding/base/nsEmbedAPI.cpp index 2b50d4deec0..3beb3ce1b13 100644 --- a/mozilla/embedding/base/nsEmbedAPI.cpp +++ b/mozilla/embedding/base/nsEmbedAPI.cpp @@ -24,6 +24,7 @@ #include "nsIServiceManager.h" #include "nsIEventQueueService.h" +#include "nsIChromeRegistry.h" #include "nsIStringBundle.h" @@ -160,7 +161,17 @@ nsresult NS_InitEmbedding(nsILocalFile *aPath) } #endif - return NS_OK; + + // Init the chrome registry. + + nsCOMPtr chromeReg = do_GetService("component://netscape/chrome/chrome-registry"); + NS_ASSERTION(chromeReg, "chrome check couldn't get the chrome registry"); + + if (!chromeReg) + return NS_ERROR_FAILURE; + + return chromeReg->CheckForNewChrome(); + } diff --git a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index df76e0ee662..525dfd8dca8 100644 --- a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -42,6 +42,7 @@ nsDocShellTreeOwner::nsDocShellTreeOwner() : mWebBrowser(nsnull), mTreeOwner(nsnull), + mPrimaryContentShell(nsnull), mWebBrowserChrome(nsnull), mOwnerProgressListener(nsnull), mOwnerWin(nsnull), @@ -121,12 +122,15 @@ NS_IMETHODIMP nsDocShellTreeOwner::FindItemWithName(const PRUnichar* aName, return NS_OK; } + NS_IMETHODIMP nsDocShellTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell, PRBool aPrimary, const PRUnichar* aID) { if(mTreeOwner) return mTreeOwner->ContentShellAdded(aContentShell, aPrimary, aID); + if (aPrimary) + mPrimaryContentShell = aContentShell; return NS_OK; } @@ -134,7 +138,10 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** { NS_ENSURE_ARG_POINTER(aShell); - *aShell = mWebBrowser->mDocShellAsItem; + if (mTreeOwner) + return mTreeOwner->GetPrimaryContentShell(aShell); + + *aShell = (mPrimaryContentShell ? mPrimaryContentShell : mWebBrowser->mDocShellAsItem.get()); NS_IF_ADDREF(*aShell); return NS_OK; @@ -229,7 +236,8 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetNewWindow(PRInt32 aChromeFlags, NS_IMETHODIMP nsDocShellTreeOwner::InitWindow(nativeWindow aParentNativeWindow, nsIWidget* aParentWidget, PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->InitWindow(aParentNativeWindow, aParentWidget, aX, aY, aCX, aCY); @@ -237,42 +245,48 @@ NS_IMETHODIMP nsDocShellTreeOwner::InitWindow(nativeWindow aParentNativeWindow, NS_IMETHODIMP nsDocShellTreeOwner::Create() { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->Create(); } NS_IMETHODIMP nsDocShellTreeOwner::Destroy() { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->Destroy(); } NS_IMETHODIMP nsDocShellTreeOwner::SetPosition(PRInt32 aX, PRInt32 aY) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->SetPosition(aX, aY); } NS_IMETHODIMP nsDocShellTreeOwner::GetPosition(PRInt32* aX, PRInt32* aY) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->GetPosition(aX, aY); } NS_IMETHODIMP nsDocShellTreeOwner::SetSize(PRInt32 aCX, PRInt32 aCY, PRBool aRepaint) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->SetSize(aCX, aCY, aRepaint); } NS_IMETHODIMP nsDocShellTreeOwner::GetSize(PRInt32* aCX, PRInt32* aCY) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->GetSize(aCX, aCY); } @@ -280,7 +294,8 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetSize(PRInt32* aCX, PRInt32* aCY) NS_IMETHODIMP nsDocShellTreeOwner::SetPositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool aRepaint) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->SetPositionAndSize(aX, aY, aCX, aCY, aRepaint); } @@ -288,70 +303,80 @@ NS_IMETHODIMP nsDocShellTreeOwner::SetPositionAndSize(PRInt32 aX, PRInt32 aY, NS_IMETHODIMP nsDocShellTreeOwner::GetPositionAndSize(PRInt32* aX, PRInt32* aY, PRInt32* aCX, PRInt32* aCY) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->GetPositionAndSize(aX, aY, aCX, aCY); } NS_IMETHODIMP nsDocShellTreeOwner::Repaint(PRBool aForce) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->Repaint(aForce); } NS_IMETHODIMP nsDocShellTreeOwner::GetParentWidget(nsIWidget** aParentWidget) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->GetParentWidget(aParentWidget); } NS_IMETHODIMP nsDocShellTreeOwner::SetParentWidget(nsIWidget* aParentWidget) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->SetParentWidget(aParentWidget); } NS_IMETHODIMP nsDocShellTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->GetParentNativeWindow(aParentNativeWindow); } NS_IMETHODIMP nsDocShellTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->SetParentNativeWindow(aParentNativeWindow); } NS_IMETHODIMP nsDocShellTreeOwner::GetVisibility(PRBool* aVisibility) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->GetVisibility(aVisibility); } NS_IMETHODIMP nsDocShellTreeOwner::SetVisibility(PRBool aVisibility) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->SetVisibility(aVisibility); } NS_IMETHODIMP nsDocShellTreeOwner::GetMainWidget(nsIWidget** aMainWidget) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->GetMainWidget(aMainWidget); } NS_IMETHODIMP nsDocShellTreeOwner::SetFocus() { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->SetFocus(); } @@ -359,21 +384,24 @@ NS_IMETHODIMP nsDocShellTreeOwner::SetFocus() NS_IMETHODIMP nsDocShellTreeOwner::FocusAvailable(nsIBaseWindow* aCurrentFocus, PRBool* aTookFocus) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->FocusAvailable(aCurrentFocus, aTookFocus); } NS_IMETHODIMP nsDocShellTreeOwner::GetTitle(PRUnichar** aTitle) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->GetTitle(aTitle); } NS_IMETHODIMP nsDocShellTreeOwner::SetTitle(const PRUnichar* aTitle) { - NS_ENSURE_STATE(mOwnerWin); + if (!mOwnerWin) + return NS_ERROR_NULL_POINTER; return mOwnerWin->SetTitle(aTitle); } diff --git a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.h b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.h index 94b69c804a0..42ba1c4fabc 100644 --- a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.h +++ b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.h @@ -65,6 +65,8 @@ protected: // Weak References nsWebBrowser* mWebBrowser; nsIDocShellTreeOwner* mTreeOwner; + nsIDocShellTreeItem* mPrimaryContentShell; + nsIWebBrowserChrome* mWebBrowserChrome; nsIWebProgressListener* mOwnerProgressListener; nsIBaseWindow* mOwnerWin; diff --git a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp index b4baa257873..2b001a1e948 100644 --- a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -46,9 +46,9 @@ static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID); nsWebBrowser::nsWebBrowser() : mDocShellTreeOwner(nsnull), mContentListener(nsnull), mInitInfo(nsnull), mParentNativeWindow(nsnull), - mParentWidget(nsnull), mParent(nsnull) + mParentWidget(nsnull), mParent(nsnull), mContentType(typeContentWrapper) { - NS_INIT_REFCNT(); + NS_INIT_REFCNT(); mInitInfo = new nsWebBrowserInitInfo(); } @@ -88,15 +88,15 @@ NS_IMPL_ADDREF(nsWebBrowser) NS_IMPL_RELEASE(nsWebBrowser) NS_INTERFACE_MAP_BEGIN(nsWebBrowser) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowser) - NS_INTERFACE_MAP_ENTRY(nsIWebBrowser) - NS_INTERFACE_MAP_ENTRY(nsIWebNavigation) - NS_INTERFACE_MAP_ENTRY(nsIWebProgress) - NS_INTERFACE_MAP_ENTRY(nsIBaseWindow) - NS_INTERFACE_MAP_ENTRY(nsIScrollable) - NS_INTERFACE_MAP_ENTRY(nsITextScroll) - NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeItem) - NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowser) + NS_INTERFACE_MAP_ENTRY(nsIWebBrowser) + NS_INTERFACE_MAP_ENTRY(nsIWebNavigation) + NS_INTERFACE_MAP_ENTRY(nsIWebProgress) + NS_INTERFACE_MAP_ENTRY(nsIBaseWindow) + NS_INTERFACE_MAP_ENTRY(nsIScrollable) + NS_INTERFACE_MAP_ENTRY(nsITextScroll) + NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeItem) + NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor) NS_INTERFACE_MAP_END ///***************************************************************************** @@ -225,14 +225,15 @@ NS_IMETHODIMP nsWebBrowser::GetItemType(PRInt32* aItemType) { NS_ENSURE_ARG_POINTER(aItemType); - *aItemType = typeContentWrapper; + *aItemType = mContentType; return NS_OK; } NS_IMETHODIMP nsWebBrowser::SetItemType(PRInt32 aItemType) { - NS_ERROR("Can't call that on this"); - return NS_ERROR_FAILURE; + NS_ENSURE_TRUE((aItemType == typeContentWrapper || aItemType == typeChromeWrapper), NS_ERROR_FAILURE); + mContentType = aItemType; + return NS_OK; } NS_IMETHODIMP nsWebBrowser::GetParent(nsIDocShellTreeItem** aParent) @@ -466,7 +467,7 @@ nsWebBrowser::GetSHEForChild(PRInt32 aChildOffset, nsISHEntry ** aResult) { // XXX Not yet implemented - return NS_OK; + return NS_OK; } @@ -591,7 +592,14 @@ NS_IMETHODIMP nsWebBrowser::Create() mInitInfo->cy), NS_ERROR_FAILURE); mDocShellAsItem->SetName(mInitInfo->name.GetUnicode()); - mDocShellAsItem->SetItemType(nsIDocShellTreeItem::typeContent); + if (mContentType == typeChromeWrapper) + { + mDocShellAsItem->SetItemType(nsIDocShellTreeItem::typeChrome); + } + else + { + mDocShellAsItem->SetItemType(nsIDocShellTreeItem::typeContent); + } mDocShellAsItem->SetTreeOwner(mDocShellTreeOwner); mDocShell->SetParentURIContentListener(mContentListener); @@ -997,44 +1005,49 @@ NS_IMETHODIMP nsWebBrowser::ScrollByPages(PRInt32 aNumPages) NS_IMETHODIMP nsWebBrowser::SetDocShell(nsIDocShell* aDocShell) { - if(aDocShell) - { - NS_ENSURE_TRUE(!mDocShell, NS_ERROR_FAILURE); + if(aDocShell) + { + NS_ENSURE_TRUE(!mDocShell, NS_ERROR_FAILURE); + + nsCOMPtr req(do_QueryInterface(aDocShell)); + nsCOMPtr baseWin(do_QueryInterface(aDocShell)); + nsCOMPtr item(do_QueryInterface(aDocShell)); + nsCOMPtr nav(do_QueryInterface(aDocShell)); + nsCOMPtr progress(do_GetInterface(aDocShell)); + nsCOMPtr scrollable(do_QueryInterface(aDocShell)); + nsCOMPtr textScroll(do_QueryInterface(aDocShell)); + NS_ENSURE_TRUE(req && baseWin && item && nav && scrollable && textScroll && + progress, NS_ERROR_FAILURE); + + mDocShell = aDocShell; + mDocShellAsReq = req; + mDocShellAsWin = baseWin; + mDocShellAsItem = item; + mDocShellAsNav = nav; + mDocShellAsProgress = progress; + mDocShellAsScrollable = scrollable; + mDocShellAsTextScroll = textScroll; + + AddProgressListener(NS_STATIC_CAST(nsIWebProgressListener *, mDocShellTreeOwner)); + } + else + { + if (mDocShell) + { + RemoveProgressListener(NS_STATIC_CAST(nsIWebProgressListener *, mDocShellTreeOwner)); + mDocShellAsWin->Destroy(); + } + mDocShell = nsnull; + mDocShellAsReq = nsnull; + mDocShellAsWin = nsnull; + mDocShellAsItem = nsnull; + mDocShellAsNav = nsnull; + mDocShellAsProgress = nsnull; + mDocShellAsScrollable = nsnull; + mDocShellAsTextScroll = nsnull; + } - nsCOMPtr req(do_QueryInterface(aDocShell)); - nsCOMPtr baseWin(do_QueryInterface(aDocShell)); - nsCOMPtr item(do_QueryInterface(aDocShell)); - nsCOMPtr nav(do_QueryInterface(aDocShell)); - nsCOMPtr progress(do_GetInterface(aDocShell)); - nsCOMPtr scrollable(do_QueryInterface(aDocShell)); - nsCOMPtr textScroll(do_QueryInterface(aDocShell)); - NS_ENSURE_TRUE(req && baseWin && item && nav && scrollable && textScroll && - progress, NS_ERROR_FAILURE); - - mDocShell = aDocShell; - mDocShellAsReq = req; - mDocShellAsWin = baseWin; - mDocShellAsItem = item; - mDocShellAsNav = nav; - mDocShellAsProgress = progress; - mDocShellAsScrollable = scrollable; - mDocShellAsTextScroll = textScroll; - } - else - { - if(mDocShell) - mDocShellAsWin->Destroy(); - mDocShell = nsnull; - mDocShellAsReq = nsnull; - mDocShellAsWin = nsnull; - mDocShellAsItem = nsnull; - mDocShellAsNav = nsnull; - mDocShellAsProgress = nsnull; - mDocShellAsScrollable = nsnull; - mDocShellAsTextScroll = nsnull; - } - - return NS_OK; + return NS_OK; } NS_IMETHODIMP nsWebBrowser::EnsureDocShellTreeOwner() diff --git a/mozilla/embedding/browser/webBrowser/nsWebBrowser.h b/mozilla/embedding/browser/webBrowser/nsWebBrowser.h index 725d076c551..cd0e3dc0081 100644 --- a/mozilla/embedding/browser/webBrowser/nsWebBrowser.h +++ b/mozilla/embedding/browser/webBrowser/nsWebBrowser.h @@ -106,6 +106,7 @@ protected: nsCOMPtr mDocShellAsTextScroll; nsCOMPtr mInternalWidget; nsWebBrowserInitInfo* mInitInfo; + PRUint32 mContentType; nativeWindow mParentNativeWindow; //Weak Reference interfaces... diff --git a/mozilla/embedding/tests/winEmbed/WebBrowser.cpp b/mozilla/embedding/tests/winEmbed/WebBrowser.cpp index afcd12c66db..f8c118de016 100644 --- a/mozilla/embedding/tests/winEmbed/WebBrowser.cpp +++ b/mozilla/embedding/tests/winEmbed/WebBrowser.cpp @@ -41,6 +41,8 @@ #include "nsIScriptGlobalObject.h" #include "nsIInterfaceRequestor.h" +#include "nsIDocShellTreeItem.h" +#include "nsIDocShellTreeOwner.h" nsresult ConvertDocShellToDOMWindow(nsIDocShell* aDocShell, nsIDOMWindow** aDOMWindow) @@ -73,34 +75,39 @@ WebBrowser::~WebBrowser() } nsresult -WebBrowser::Init(nsNativeWidget widget) +WebBrowser::Init(nsNativeWidget widget, nsIWebBrowserChrome* aTopWindow) { nsresult rv; mWebBrowser = do_CreateInstance(NS_WEBBROWSER_PROGID, &rv); - if (NS_FAILED(rv)) - return rv; + if (!mWebBrowser) + return NS_ERROR_FAILURE; mBaseWindow = do_QueryInterface(mWebBrowser); - + + mTopWindow = aTopWindow; + mWebBrowser->SetTopLevelWindow(aTopWindow); + + nsCOMPtr dsti = do_QueryInterface(mWebBrowser); + dsti->SetItemType(nsIDocShellTreeItem::typeChromeWrapper); + rv = mBaseWindow->InitWindow( widget, nsnull, 0, 0, 100, 100); - - mWebBrowser->SetTopLevelWindow(nsnull); - + mBaseWindow->Create(); mBaseWindow->SetVisibility(PR_TRUE); + return rv; } nsresult -WebBrowser::GetIWebBrowser(nsIWebBrowser **outBrowser) +WebBrowser::GetWebBrowser(nsIWebBrowser **outBrowser) { *outBrowser = mWebBrowser; NS_IF_ADDREF(*outBrowser); diff --git a/mozilla/embedding/tests/winEmbed/WebBrowser.h b/mozilla/embedding/tests/winEmbed/WebBrowser.h index 9ad32a2a43c..cde9262c387 100644 --- a/mozilla/embedding/tests/winEmbed/WebBrowser.h +++ b/mozilla/embedding/tests/winEmbed/WebBrowser.h @@ -29,24 +29,26 @@ #include "nsIBaseWindow.h" #include "nsIWebBrowser.h" #include "nsIEditorShell.h" +#include "nsIWebBrowserChrome.h" class WebBrowser { public: - nsresult Init(nsNativeWidget widget); + nsresult Init(nsNativeWidget widget, nsIWebBrowserChrome* aTopWindow); nsresult SetPositionAndSize(int x, int y, int cx, int cy); nsresult GoTo(char* url); nsresult Edit(char* url); nsresult Print(void); - nsresult GetIWebBrowser(nsIWebBrowser **outBrowser); - + + nsresult GetWebBrowser(nsIWebBrowser **outBrowser); + WebBrowser(); virtual ~WebBrowser(); protected: nsCOMPtr mWebBrowser; nsCOMPtr mBaseWindow; - + nsCOMPtr mTopWindow; //for editing nsCOMPtr mEditor; }; diff --git a/mozilla/embedding/tests/winEmbed/winEmbed.cpp b/mozilla/embedding/tests/winEmbed/winEmbed.cpp index c2cf5b4a43c..b6ac62466ac 100644 --- a/mozilla/embedding/tests/winEmbed/winEmbed.cpp +++ b/mozilla/embedding/tests/winEmbed/winEmbed.cpp @@ -29,17 +29,19 @@ #include "nsEmbedAPI.h" #include "WebBrowser.h" +#include "WebBrowserChrome.h" -nsresult CreateWebBrowser(WebBrowser **outBrowser); +WebBrowser* CreateWebBrowser(); #define MAX_LOADSTRING 100 // Global Variables: -HINSTANCE hInst; // current instance -TCHAR szTitle[MAX_LOADSTRING]; // The title bar text -TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text +HINSTANCE hInst; +TCHAR szTitle[MAX_LOADSTRING]; + +TCHAR szWindowClass[MAX_LOADSTRING]; // Foward declarations of functions included in this code module: ATOM MyRegisterClass(HINSTANCE hInstance); @@ -52,7 +54,7 @@ char gLastURI[100]; int main () { - printf("\nYour embedded, man!\n\n"); + printf("\nYou are embedded, man!\n\n"); MSG msg; HINSTANCE hInstance = GetModuleHandle(NULL); @@ -67,8 +69,7 @@ int main () // put up at lease on browser window .... ///////////////////////////////////////////////////////////// - WebBrowser* newBrowser; - CreateWebBrowser(&newBrowser); + WebBrowser* newBrowser = CreateWebBrowser(); if (!newBrowser) return -1; newBrowser->GoTo("http://people.netscape.com/dougt"); @@ -126,7 +127,7 @@ ATOM MyRegisterClass(HINSTANCE hInstance) -nsresult CreateWebBrowser(WebBrowser **outBrowser) +WebBrowser * CreateWebBrowser() { STARTUPINFO StartupInfo; @@ -139,7 +140,7 @@ nsresult CreateWebBrowser(WebBrowser **outBrowser) WebBrowser *browser = new WebBrowser(); if (! browser) - return NS_ERROR_FAILURE; + return NULL; HWND hWnd; @@ -157,16 +158,16 @@ nsresult CreateWebBrowser(WebBrowser **outBrowser) if (!hWnd) { - return NS_ERROR_FAILURE; + return NULL; } SetWindowLong( hWnd, GWL_USERDATA, (LONG)browser); // save the browser LONG_PTR. + WebBrowserChrome* chrome = nsnull;//new WebBrowserChrome(); - - if ( NS_FAILED( browser->Init(hWnd) ) ) // this will own hWnd - return NS_ERROR_FAILURE; - + if ( NS_FAILED( browser->Init(hWnd, chrome) ) ) // this will own hWnd + return NULL; + RECT rect; GetClientRect(hWnd, &rect); rect.top += 32; @@ -176,9 +177,7 @@ nsresult CreateWebBrowser(WebBrowser **outBrowser) ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); - *outBrowser = browser; - - return NS_OK; + return browser; } // @@ -218,8 +217,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) gLastURI[0] = 0; if (DialogBox(hInst, (LPCTSTR)MOZ_GetURI, hWnd, (DLGPROC)GetURI)) { - WebBrowser* newBrowser; - CreateWebBrowser(&newBrowser); + WebBrowser* newBrowser = CreateWebBrowser(); if (!newBrowser) break; newBrowser->GoTo(gLastURI); @@ -230,8 +228,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) gLastURI[0] = 0; if (DialogBox(hInst, (LPCTSTR)MOZ_GetURI, hWnd, (DLGPROC)GetURI)) { - WebBrowser* newBrowser; - CreateWebBrowser(&newBrowser); + WebBrowser* newBrowser = CreateWebBrowser(); if (!newBrowser) break; newBrowser->Edit(gLastURI);