diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index e9ac1df684a..b6f2eb0ca13 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -29,6 +29,7 @@ #include "nsIPref.h" #include "nsINameSpaceManager.h" +#include "nsEscape.h" #include "nsVoidArray.h" #include "nsIScriptGlobalObject.h" #include "nsIDOMWindow.h" @@ -266,9 +267,7 @@ nsresult nsWebShellWindow::Initialize(nsIWebShellWindow* aParent, { nsresult rv; - nsString urlString; nsIWidget *parentWidget; - const char *tmpStr = NULL; // XXX: need to get the default window size from prefs... // Doesn't come from prefs... will come from CSS/XUL/RDF @@ -276,16 +275,6 @@ nsresult nsWebShellWindow::Initialize(nsIWebShellWindow* aParent, nsWidgetInitData initData; - - //if (nsnull == aUrl) { - // rv = NS_ERROR_NULL_POINTER; - // goto done; - //} - if (nsnull != aUrl) { - aUrl->GetSpec(&tmpStr); - urlString = tmpStr; - } - // Create top level window rv = nsComponentManager::CreateInstance(kWindowCID, nsnull, kIWidgetIID, (void**)&mWindow); @@ -352,6 +341,11 @@ nsresult nsWebShellWindow::Initialize(nsIWebShellWindow* aParent, NS_IF_ADDREF(mCallbacks); if (nsnull != aUrl) { + const char *tmpStr = NULL; + nsString urlString; + + aUrl->GetSpec(&tmpStr); + urlString = tmpStr; mWebShell->LoadURL(urlString.GetUnicode()); } @@ -1407,6 +1401,7 @@ nsWebShellWindow::OnEndDocumentLoad(nsIDocumentLoader* loader, SetSizeFromXUL(); SetTitleFromXUL(); ShowAppropriateChrome(); + LoadContentAreas(); #if 0 nsCOMPtr toolbarDOMDoc(GetNamedDOMDoc(nsAutoString("browser.toolbar"))); @@ -1907,6 +1902,70 @@ void nsWebShellWindow::ShowAppropriateChrome() } } +// if the main document URL specified URLs for any content areas, start them loading +void nsWebShellWindow::LoadContentAreas() { + + nsAutoString searchSpec; + + // fetch the chrome document URL + nsCOMPtr contentViewer; + mWebShell->GetContentViewer(getter_AddRefs(contentViewer)); + if (contentViewer) { + nsCOMPtr docViewer = do_QueryInterface(contentViewer); + if (docViewer) { + nsCOMPtr doc; + docViewer->GetDocument(*getter_AddRefs(doc)); + nsCOMPtr mainURL = getter_AddRefs(doc->GetDocumentURL()); + if (mainURL) { + const char *search; + mainURL->GetSearch(&search); + searchSpec = search; + } + } + } + + // content URLs are specified in the search part of the URL + // as =[;(repeat)] + if (searchSpec.Length() > 0) { + PRInt32 begPos, + eqPos, + endPos; + nsString contentAreaID, + contentURL; + char *urlChar; + nsIWebShell *contentShell; + nsresult rv; + for (endPos = 0; endPos < searchSpec.Length(); ) { + // extract contentAreaID and URL substrings + begPos = endPos; + eqPos = searchSpec.Find('=', begPos); + if (eqPos < 0) + break; + + endPos = searchSpec.Find(';', eqPos); + if (endPos < 0) + endPos = searchSpec.Length(); + searchSpec.Mid(contentAreaID, begPos, eqPos-begPos); + searchSpec.Mid(contentURL, eqPos+1, endPos-eqPos-1); + endPos++; + + // see if we have a webshell with a matching contentAreaID + rv = GetContentShellById(contentAreaID, &contentShell); + if (NS_SUCCEEDED(rv)) { + urlChar = contentURL.ToNewCString(); + if (urlChar) { + PRInt32 colonPos; + nsUnescape(urlChar); + contentURL = urlChar; + contentShell->LoadURL(contentURL.GetUnicode()); + delete [] urlChar; + } + NS_RELEASE(contentShell); + } + } + } +} + //---------------------------------------------------------------- //-- nsIDocumentObserver //---------------------------------------------------------------- diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.h b/mozilla/xpfe/appshell/src/nsWebShellWindow.h index 06638164a6d..edfbeb7d284 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.h +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.h @@ -242,6 +242,7 @@ protected: void SetSizeFromXUL(); void SetTitleFromXUL(); void ShowAppropriateChrome(); + void LoadContentAreas(); virtual ~nsWebShellWindow();