API changes for embedding. b=46847, r=dougt, a=valeski

This commit is contained in:
locka%iol.ie 2000-08-25 18:39:46 +00:00
Родитель fc0a492c57
Коммит c52f68cce4
54 изменённых файлов: 621 добавлений и 1002 удалений

Просмотреть файл

@ -51,6 +51,8 @@ CPP_OBJS= \
include <$(DEPTH)\config\rules.mak> include <$(DEPTH)\config\rules.mak>
include <$(DEPTH)\config\config.mak> include <$(DEPTH)\config\config.mak>
nsDocShell.cpp : nsDocShell.h
install:: $(LIBRARY) install:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib $(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
$(MAKE_INSTALL) appstrings.properties $(DIST)\bin\chrome\locales\en-US\global\locale $(MAKE_INSTALL) appstrings.properties $(DIST)\bin\chrome\locales\en-US\global\locale

Просмотреть файл

@ -99,6 +99,8 @@ nsDocShell::nsDocShell() :
mInitialPageLoad(PR_TRUE), mInitialPageLoad(PR_TRUE),
mAllowPlugins(PR_TRUE), mAllowPlugins(PR_TRUE),
mViewMode(viewNormal), mViewMode(viewNormal),
mLastViewMode(viewNormal),
mRestoreViewMode(PR_FALSE),
mEODForCurrentDocument (PR_FALSE), mEODForCurrentDocument (PR_FALSE),
mUseExternalProtocolHandler (PR_FALSE), mUseExternalProtocolHandler (PR_FALSE),
mParent(nsnull), mParent(nsnull),
@ -165,19 +167,28 @@ NS_IMETHODIMP nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
if(aIID.Equals(NS_GET_IID(nsIURIContentListener)) && if(aIID.Equals(NS_GET_IID(nsIURIContentListener)) &&
NS_SUCCEEDED(EnsureContentListener())) NS_SUCCEEDED(EnsureContentListener()))
*aSink = mContentListener; {
*aSink = mContentListener;
}
else if(aIID.Equals(NS_GET_IID(nsIScriptGlobalObject)) && else if(aIID.Equals(NS_GET_IID(nsIScriptGlobalObject)) &&
NS_SUCCEEDED(EnsureScriptEnvironment())) NS_SUCCEEDED(EnsureScriptEnvironment()))
{
*aSink = mScriptGlobal; *aSink = mScriptGlobal;
}
else if(aIID.Equals(NS_GET_IID(nsIDOMWindow)) && else if(aIID.Equals(NS_GET_IID(nsIDOMWindow)) &&
NS_SUCCEEDED(EnsureScriptEnvironment())) NS_SUCCEEDED(EnsureScriptEnvironment()))
{ {
NS_ENSURE_SUCCESS(mScriptGlobal->QueryInterface(NS_GET_IID(nsIDOMWindow), NS_ENSURE_SUCCESS(mScriptGlobal->QueryInterface(NS_GET_IID(nsIDOMWindow),
aSink), NS_ERROR_FAILURE); aSink), NS_ERROR_FAILURE);
return NS_OK; return NS_OK;
} }
else if (aIID.Equals(NS_GET_IID(nsIDOMDocument)) &&
NS_SUCCEEDED(EnsureContentViewer()))
{
mContentViewer->GetDOMDocument((nsIDOMDocument**) aSink);
}
else if(aIID.Equals(NS_GET_IID(nsIPrompt))) else if(aIID.Equals(NS_GET_IID(nsIPrompt)))
{ {
nsCOMPtr<nsIPrompt> prompter(do_GetInterface(mTreeOwner)); nsCOMPtr<nsIPrompt> prompter(do_GetInterface(mTreeOwner));
if (prompter) if (prompter)
{ {
@ -204,7 +215,9 @@ NS_IMETHODIMP nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
else else
{
return QueryInterface(aIID, aSink); return QueryInterface(aIID, aSink);
}
NS_IF_ADDREF(((nsISupports*)*aSink)); NS_IF_ADDREF(((nsISupports*)*aSink));
return NS_OK; return NS_OK;
@ -345,12 +358,6 @@ NS_IMETHODIMP nsDocShell::StopLoad()
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsDocShell::SetDocument(nsIDOMDocument *aDOMDoc, nsIDOMElement *aRootNode)
{
/* XXX: This method is obsolete and will be removed. */
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsDocShell::GetCurrentURI(nsIURI** aURI) NS_IMETHODIMP nsDocShell::GetCurrentURI(nsIURI** aURI)
{ {
@ -1444,6 +1451,7 @@ NS_IMETHODIMP nsDocShell::Stop()
return NS_OK; return NS_OK;
} }
/*
NS_IMETHODIMP nsDocShell::SetDocument(nsIDOMDocument* aDocument, NS_IMETHODIMP nsDocShell::SetDocument(nsIDOMDocument* aDocument,
const PRUnichar* aContentType) const PRUnichar* aContentType)
{ {
@ -1451,6 +1459,7 @@ NS_IMETHODIMP nsDocShell::SetDocument(nsIDOMDocument* aDocument,
NS_ERROR("Not Yet Implemented"); NS_ERROR("Not Yet Implemented");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
*/
NS_IMETHODIMP nsDocShell::GetDocument(nsIDOMDocument** aDocument) NS_IMETHODIMP nsDocShell::GetDocument(nsIDOMDocument** aDocument)
{ {
@ -1513,6 +1522,7 @@ NS_IMETHODIMP nsDocShell::GetSessionHistory(nsISHistory** aSessionHistory)
} }
return NS_OK; return NS_OK;
} }
//***************************************************************************** //*****************************************************************************
// nsDocShell::nsIBaseWindow // nsDocShell::nsIBaseWindow
//***************************************************************************** //*****************************************************************************
@ -2439,7 +2449,7 @@ nsDocShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest,
{ {
// Clear the LSHE reference to indicate document loading has finished // Clear the LSHE reference to indicate document loading has finished
// one way or another. // one way or another.
if ((aStateFlags & flag_stop) && (aStateFlags & flag_is_network)) { if ((aStateFlags & STATE_STOP) && (aStateFlags & STATE_IS_NETWORK)) {
LSHE = nsnull; LSHE = nsnull;
} }
return NS_OK; return NS_OK;
@ -2828,6 +2838,29 @@ NS_IMETHODIMP nsDocShell::CreateFixupURI(const PRUnichar* aStringURI,
nsAutoString uriString(aStringURI); nsAutoString uriString(aStringURI);
uriString.Trim(" "); // Cleanup the empty spaces that might be on each end. uriString.Trim(" "); // Cleanup the empty spaces that might be on each end.
// XXX nasty hack to check for the view-source: prefix
//
// The long term way and probably CORRECT way to do this is to write a
// protocol handler for the view-source: schema and have that feed back a
// content type that the docshell recognizes to mean to use viewSource mode.
//
const char cViewSource[] = "view-source:";
if (uriString.EqualsWithConversion(cViewSource, PR_TRUE, sizeof(cViewSource) - 1))
{
// Strip the view-source: prefix and set the docshell's view mode
nsAutoString newUri;
uriString.Mid(newUri, sizeof(cViewSource) - 1, -1);
uriString = newUri;
mLastViewMode = mViewMode;
mViewMode = viewSource;
mRestoreViewMode = PR_TRUE;
}
else if (mRestoreViewMode)
{
mRestoreViewMode = PR_FALSE;
mViewMode = mLastViewMode;
}
// Just try to create an URL out of it // Just try to create an URL out of it
NS_NewURI(aURI, uriString, nsnull); NS_NewURI(aURI, uriString, nsnull);
if(*aURI) if(*aURI)

Просмотреть файл

@ -260,7 +260,8 @@ protected:
PRBool mInitialPageLoad; PRBool mInitialPageLoad;
PRBool mAllowPlugins; PRBool mAllowPlugins;
PRInt32 mViewMode; PRInt32 mViewMode;
PRInt32 mLastViewMode;
PRBool mRestoreViewMode;
PRInt32 mChildOffset; // Offset in the parent's child list. PRInt32 mChildOffset; // Offset in the parent's child list.
// Reference to the SHEntry for this docshell until the page is destroyed. // Reference to the SHEntry for this docshell until the page is destroyed.
// Somebody give me better name // Somebody give me better name

Просмотреть файл

@ -95,14 +95,6 @@ interface nsIDocShell : nsISupports
nsIWebNavigation::Stop() method. nsIWebNavigation::Stop() method.
*/ */
void stopLoad(); void stopLoad();
/*
Sets the current document to the one being passed in. This will simulate
a load.
@param document - The document to load.
@param rootNode - The root of the document content, to be hooked up
*/
[noscript]void setDocument(in nsIDOMDocument document, in nsIDOMElement rootNode);
/* /*
The current URI that is loaded. The current URI that is loaded.

Просмотреть файл

@ -85,16 +85,26 @@ interface nsIWebNavigation : nsISupports
/* /*
Definitions for the reload types. Definitions for the reload types.
*/ */
/* these are load type enums... */ /* these are load type enums... */
const long loadNormal = 0; // Normal Load const long LOAD_NORMAL = 0; // Normal Load
const long loadNormalReplace = 1; // Normal Load but replaces current history slot const long LOAD_NORMAL_REPLACE = 1; // Normal Load but replaces current history slot
const long loadHistory = 2; // Load from history const long LOAD_HISTORY = 2; // Load from history
const long loadReloadNormal = 3; // normal Reload const long LOAD_RELOAD_NORMAL = 3; // normal Reload
const long loadReloadBypassCache = 4; // Reloads bypassing the cache const long LOAD_RELOAD_BYPASS_CACHE = 4; // Reloads bypassing the cache
const long loadReloadBypassProxy = 5; // Reloads bypassing the proxy const long LOAD_RELOAD_BYPASS_PROXY = 5; // Reloads bypassing the proxy
const long loadReloadBypassProxyAndCache = 6;// Reloads bypassing proxy and cache const long LOAD_RELOAD_BYPASS_PROXY_AND_CACHE = 6;// Reloads bypassing proxy and cache
const long loadLink = 7; const long LOAD_LINK = 7;
const long loadRefresh = 8; const long LOAD_REFRESH = 8;
const long loadNormal = 0; // Normal Load
const long loadNormalReplace = 1; // Normal Load but replaces current history slot
const long loadHistory = 2; // Load from history
const long loadReloadNormal = 3; // normal Reload
const long loadReloadBypassCache = 4; // Reloads bypassing the cache
const long loadReloadBypassProxy = 5; // Reloads bypassing the proxy
const long loadReloadBypassProxyAndCache = 6;// Reloads bypassing proxy and cache
const long loadLink = 7;
const long loadRefresh = 8;
/* /*
Tells the Object to reload the current location. Tells the Object to reload the current location.
@ -107,19 +117,7 @@ interface nsIWebNavigation : nsISupports
void stop(); void stop();
/* /*
Set the document for the current webBrowser. This will simulate the normal Retrieves the current Document for the WebBrowser. When setting
load process of a document being loaded.
@param document - The document to be set.
@param contentType - This is the content type to try and render the document
as. This may be null. If this is null, the method will try to query
the document to identify the content type of the document. If the query
fails, content type "HTML" will be assumed.
*/
void setDocument(in nsIDOMDocument document, in wstring contentType);
/*
Retrieves or sets the current Document for the WebBrowser. When setting
this will simulate the normal load process. this will simulate the normal load process.
*/ */
readonly attribute nsIDOMDocument document; readonly attribute nsIDOMDocument document;

Просмотреть файл

@ -856,7 +856,7 @@ nsWebShell::OnOverLink(nsIContent* aContent,
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(mTreeOwner)); nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(mTreeOwner));
if(browserChrome) if(browserChrome)
browserChrome->SetOverLink(aURLSpec); browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_LINK, aURLSpec);
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -86,7 +86,7 @@ NS_IMETHODIMP BarPropImpl::GetVisibleByFlag(PRBool *aVisible,
*aVisible = PR_FALSE; *aVisible = PR_FALSE;
if(mBrowserChrome) if(mBrowserChrome)
{ {
NS_ENSURE_SUCCESS(mBrowserChrome->GetChromeMask(&chromeFlags), NS_ENSURE_SUCCESS(mBrowserChrome->GetChromeFlags(&chromeFlags),
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
if(chromeFlags & aChromeFlag) if(chromeFlags & aChromeFlag)
*aVisible = PR_TRUE; *aVisible = PR_TRUE;
@ -101,13 +101,13 @@ NS_IMETHODIMP BarPropImpl::SetVisibleByFlag(PRBool aVisible,
PRUint32 chromeFlags; PRUint32 chromeFlags;
if(mBrowserChrome) if(mBrowserChrome)
{ {
NS_ENSURE_SUCCESS(mBrowserChrome->GetChromeMask(&chromeFlags), NS_ENSURE_SUCCESS(mBrowserChrome->GetChromeFlags(&chromeFlags),
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
if(aVisible) if(aVisible)
chromeFlags |= aChromeFlag; chromeFlags |= aChromeFlag;
else else
chromeFlags |= ~aChromeFlag; chromeFlags |= ~aChromeFlag;
NS_ENSURE_SUCCESS(mBrowserChrome->SetChromeMask(chromeFlags), NS_ENSURE_SUCCESS(mBrowserChrome->SetChromeFlags(chromeFlags),
NS_ERROR_FAILURE); NS_ERROR_FAILURE);
return NS_OK; return NS_OK;
} }
@ -128,12 +128,12 @@ MenubarPropImpl::~MenubarPropImpl()
NS_IMETHODIMP MenubarPropImpl::GetVisible(PRBool *aVisible) NS_IMETHODIMP MenubarPropImpl::GetVisible(PRBool *aVisible)
{ {
return BarPropImpl::GetVisibleByFlag(aVisible, nsIWebBrowserChrome::menuBarOn); return BarPropImpl::GetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_MENUBAR);
} }
NS_IMETHODIMP MenubarPropImpl::SetVisible(PRBool aVisible) NS_IMETHODIMP MenubarPropImpl::SetVisible(PRBool aVisible)
{ {
return BarPropImpl::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::menuBarOn); return BarPropImpl::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_MENUBAR);
} }
// //
@ -150,12 +150,12 @@ ToolbarPropImpl::~ToolbarPropImpl()
NS_IMETHODIMP ToolbarPropImpl::GetVisible(PRBool *aVisible) NS_IMETHODIMP ToolbarPropImpl::GetVisible(PRBool *aVisible)
{ {
return BarPropImpl::GetVisibleByFlag(aVisible, nsIWebBrowserChrome::toolBarOn); return BarPropImpl::GetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_TOOLBAR);
} }
NS_IMETHODIMP ToolbarPropImpl::SetVisible(PRBool aVisible) NS_IMETHODIMP ToolbarPropImpl::SetVisible(PRBool aVisible)
{ {
return BarPropImpl::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::toolBarOn); return BarPropImpl::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_TOOLBAR);
} }
// //
@ -172,12 +172,12 @@ LocationbarPropImpl::~LocationbarPropImpl()
NS_IMETHODIMP LocationbarPropImpl::GetVisible(PRBool *aVisible) NS_IMETHODIMP LocationbarPropImpl::GetVisible(PRBool *aVisible)
{ {
return BarPropImpl::GetVisibleByFlag(aVisible, nsIWebBrowserChrome::locationBarOn); return BarPropImpl::GetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_LOCATIONBAR);
} }
NS_IMETHODIMP LocationbarPropImpl::SetVisible(PRBool aVisible) NS_IMETHODIMP LocationbarPropImpl::SetVisible(PRBool aVisible)
{ {
return BarPropImpl::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::locationBarOn); return BarPropImpl::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_LOCATIONBAR);
} }
// //
@ -194,12 +194,12 @@ PersonalbarPropImpl::~PersonalbarPropImpl()
NS_IMETHODIMP PersonalbarPropImpl::GetVisible(PRBool *aVisible) NS_IMETHODIMP PersonalbarPropImpl::GetVisible(PRBool *aVisible)
{ {
return BarPropImpl::GetVisibleByFlag(aVisible, nsIWebBrowserChrome::personalToolBarOn); return BarPropImpl::GetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR);
} }
NS_IMETHODIMP PersonalbarPropImpl::SetVisible(PRBool aVisible) NS_IMETHODIMP PersonalbarPropImpl::SetVisible(PRBool aVisible)
{ {
return BarPropImpl::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::personalToolBarOn); return BarPropImpl::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR);
} }
// //
@ -216,12 +216,12 @@ StatusbarPropImpl::~StatusbarPropImpl()
NS_IMETHODIMP StatusbarPropImpl::GetVisible(PRBool *aVisible) NS_IMETHODIMP StatusbarPropImpl::GetVisible(PRBool *aVisible)
{ {
return BarPropImpl::GetVisibleByFlag(aVisible, nsIWebBrowserChrome::statusBarOn); return BarPropImpl::GetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_STATUSBAR);
} }
NS_IMETHODIMP StatusbarPropImpl::SetVisible(PRBool aVisible) NS_IMETHODIMP StatusbarPropImpl::SetVisible(PRBool aVisible)
{ {
return BarPropImpl::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::statusBarOn); return BarPropImpl::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_STATUSBAR);
} }
// //

Просмотреть файл

@ -859,10 +859,10 @@ NS_IMETHODIMP GlobalWindowImpl::SetStatus(const nsAReadableString& aStatus)
{ {
mStatus = aStatus; mStatus = aStatus;
nsCOMPtr<nsIWebBrowserChrome> browserChrome; nsCOMPtr<nsIWebBrowserChrome> browserChrome;
GetWebBrowserChrome(getter_AddRefs(browserChrome)); GetWebBrowserChrome(getter_AddRefs(browserChrome));
if (browserChrome) if(browserChrome)
browserChrome->SetJSStatus(nsPromiseFlatString(aStatus)); browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_SCRIPT, nsPromiseFlatString(aStatus));
return NS_OK; return NS_OK;
} }
@ -877,10 +877,10 @@ NS_IMETHODIMP GlobalWindowImpl::SetDefaultStatus(const nsAReadableString& aDefau
{ {
mDefaultStatus = aDefaultStatus; mDefaultStatus = aDefaultStatus;
nsCOMPtr<nsIWebBrowserChrome> browserChrome; nsCOMPtr<nsIWebBrowserChrome> browserChrome;
GetWebBrowserChrome(getter_AddRefs(browserChrome)); GetWebBrowserChrome(getter_AddRefs(browserChrome));
if (browserChrome) if(browserChrome)
browserChrome->SetJSDefaultStatus(nsPromiseFlatString(aDefaultStatus)); browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_SCRIPT_DEFAULT, nsPromiseFlatString(aDefaultStatus));
return NS_OK; return NS_OK;
} }
@ -2924,7 +2924,7 @@ NS_IMETHODIMP GlobalWindowImpl::OpenInternal(JSContext *cx,
if (!newDocShellItem) { if (!newDocShellItem) {
windowIsNew = PR_TRUE; windowIsNew = PR_TRUE;
if (chromeFlags & nsIWebBrowserChrome::modal) { if (chromeFlags & nsIWebBrowserChrome::CHROME_MODAL) {
eventQService = do_GetService(kEventQueueServiceCID); eventQService = do_GetService(kEventQueueServiceCID);
if (eventQService && if (eventQService &&
NS_SUCCEEDED(eventQService-> NS_SUCCEEDED(eventQService->
@ -3060,14 +3060,14 @@ NS_IMETHODIMP GlobalWindowImpl::AttachArguments(nsIDOMWindow *aWindow,
*/ */
PRUint32 GlobalWindowImpl::CalculateChromeFlags(char *aFeatures, PRBool aDialog) PRUint32 GlobalWindowImpl::CalculateChromeFlags(char *aFeatures, PRBool aDialog)
{ {
if (!aFeatures) { if(!aFeatures) {
if (aDialog) if(aDialog)
return nsIWebBrowserChrome::allChrome | return nsIWebBrowserChrome::CHROME_ALL |
nsIWebBrowserChrome::openAsDialog | nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
nsIWebBrowserChrome::openAsChrome; nsIWebBrowserChrome::CHROME_OPENAS_CHROME;
else else
return nsIWebBrowserChrome::allChrome; return nsIWebBrowserChrome::CHROME_ALL;
} }
/* This function has become complicated since browser windows and /* This function has become complicated since browser windows and
dialogs diverged. The difference is, browser windows assume all dialogs diverged. The difference is, browser windows assume all
@ -3080,32 +3080,31 @@ PRUint32 GlobalWindowImpl::CalculateChromeFlags(char *aFeatures, PRBool aDialog)
PRUint32 chromeFlags = 0; PRUint32 chromeFlags = 0;
PRBool presenceFlag = PR_FALSE; PRBool presenceFlag = PR_FALSE;
chromeFlags = nsIWebBrowserChrome::CHROME_WINDOW_BORDERS;
chromeFlags = nsIWebBrowserChrome::windowBordersOn;
if (aDialog && WinHasOption(aFeatures, "all", 0, &presenceFlag)) if (aDialog && WinHasOption(aFeatures, "all", 0, &presenceFlag))
chromeFlags = nsIWebBrowserChrome::allChrome; chromeFlags = nsIWebBrowserChrome::CHROME_ALL;
/* Next, allow explicitly named options to override the initial settings */ /* Next, allow explicitly named options to override the initial settings */
chromeFlags |= WinHasOption(aFeatures, "titlebar", 0, &presenceFlag) chromeFlags |= WinHasOption(aFeatures, "titlebar", 0, &presenceFlag)
? nsIWebBrowserChrome::titlebarOn : 0; ? nsIWebBrowserChrome::CHROME_TITLEBAR : 0;
chromeFlags |= WinHasOption(aFeatures, "close", 0, &presenceFlag) chromeFlags |= WinHasOption(aFeatures, "close", 0, &presenceFlag)
? nsIWebBrowserChrome::windowCloseOn : 0; ? nsIWebBrowserChrome::CHROME_WINDOW_CLOSE : 0;
chromeFlags |= WinHasOption(aFeatures, "toolbar", 0, &presenceFlag) chromeFlags |= WinHasOption(aFeatures, "toolbar", 0, &presenceFlag)
? nsIWebBrowserChrome::toolBarOn : 0; ? nsIWebBrowserChrome::CHROME_TOOLBAR : 0;
chromeFlags |= WinHasOption(aFeatures, "location", 0, &presenceFlag) chromeFlags |= WinHasOption(aFeatures, "location", 0, &presenceFlag)
? nsIWebBrowserChrome::locationBarOn : 0; ? nsIWebBrowserChrome::CHROME_LOCATIONBAR : 0;
chromeFlags |= (WinHasOption(aFeatures, "directories", 0, &presenceFlag) || chromeFlags |= (WinHasOption(aFeatures, "directories", 0, &presenceFlag) ||
WinHasOption(aFeatures, "personalbar", 0, &presenceFlag)) WinHasOption(aFeatures, "personalbar", 0, &presenceFlag))
? nsIWebBrowserChrome::personalToolBarOn : 0; ? nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR : 0;
chromeFlags |= WinHasOption(aFeatures, "status", 0, &presenceFlag) chromeFlags |= WinHasOption(aFeatures, "status", 0, &presenceFlag)
? nsIWebBrowserChrome::statusBarOn : 0; ? nsIWebBrowserChrome::CHROME_STATUSBAR : 0;
chromeFlags |= WinHasOption(aFeatures, "menubar", 0, &presenceFlag) chromeFlags |= WinHasOption(aFeatures, "menubar", 0, &presenceFlag)
? nsIWebBrowserChrome::menuBarOn : 0; ? nsIWebBrowserChrome::CHROME_MENUBAR : 0;
chromeFlags |= WinHasOption(aFeatures, "scrollbars", 0, &presenceFlag) chromeFlags |= WinHasOption(aFeatures, "scrollbars", 0, &presenceFlag)
? nsIWebBrowserChrome::scrollbarsOn : 0; ? nsIWebBrowserChrome::CHROME_SCROLLBARS : 0;
chromeFlags |= WinHasOption(aFeatures, "resizable", 0, &presenceFlag) chromeFlags |= WinHasOption(aFeatures, "resizable", 0, &presenceFlag)
? nsIWebBrowserChrome::windowResizeOn : 0; ? nsIWebBrowserChrome::CHROME_WINDOW_RESIZE : 0;
/* OK. /* OK.
Normal browser windows, in spite of a stated pattern of turning off Normal browser windows, in spite of a stated pattern of turning off
@ -3116,12 +3115,12 @@ PRUint32 GlobalWindowImpl::CalculateChromeFlags(char *aFeatures, PRBool aDialog)
// default titlebar and closebox to "on," if not mentioned at all // default titlebar and closebox to "on," if not mentioned at all
if (!PL_strcasestr(aFeatures, "titlebar")) if (!PL_strcasestr(aFeatures, "titlebar"))
chromeFlags |= nsIWebBrowserChrome::titlebarOn; chromeFlags |= nsIWebBrowserChrome::CHROME_TITLEBAR;
if (!PL_strcasestr(aFeatures, "close")) if (!PL_strcasestr(aFeatures, "close"))
chromeFlags |= nsIWebBrowserChrome::windowCloseOn; chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_CLOSE;
if (aDialog && !presenceFlag) if (aDialog && !presenceFlag)
chromeFlags = nsIWebBrowserChrome::defaultChrome; chromeFlags = nsIWebBrowserChrome::CHROME_DEFAULT;
/* Finally, once all the above normal chrome has been divined, deal /* Finally, once all the above normal chrome has been divined, deal
with the features that are more operating hints than appearance with the features that are more operating hints than appearance
@ -3129,28 +3128,28 @@ PRUint32 GlobalWindowImpl::CalculateChromeFlags(char *aFeatures, PRBool aDialog)
if (WinHasOption(aFeatures, "alwaysLowered", 0, nsnull) || if (WinHasOption(aFeatures, "alwaysLowered", 0, nsnull) ||
WinHasOption(aFeatures, "z-lock", 0, nsnull)) WinHasOption(aFeatures, "z-lock", 0, nsnull))
chromeFlags |= nsIWebBrowserChrome::windowLowered; chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_LOWERED;
else if (WinHasOption(aFeatures, "alwaysRaised", 0, nsnull)) else if (WinHasOption(aFeatures, "alwaysRaised", 0, nsnull))
chromeFlags |= nsIWebBrowserChrome::windowRaised; chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_RAISED;
chromeFlags |= WinHasOption(aFeatures, "chrome", 0, nsnull) ? chromeFlags |= WinHasOption(aFeatures, "chrome", 0, nsnull) ?
nsIWebBrowserChrome::openAsChrome : 0; nsIWebBrowserChrome::CHROME_OPENAS_CHROME : 0;
chromeFlags |= WinHasOption(aFeatures, "centerscreen", 0, nsnull) ? chromeFlags |= WinHasOption(aFeatures, "centerscreen", 0, nsnull) ?
nsIWebBrowserChrome::centerScreen : 0; nsIWebBrowserChrome::CHROME_CENTER_SCREEN : 0;
chromeFlags |= WinHasOption(aFeatures, "dependent", 0, nsnull) ? chromeFlags |= WinHasOption(aFeatures, "dependent", 0, nsnull) ?
nsIWebBrowserChrome::dependent : 0; nsIWebBrowserChrome::CHROME_DEPENDENT : 0;
chromeFlags |= WinHasOption(aFeatures, "modal", 0, nsnull) ? chromeFlags |= WinHasOption(aFeatures, "modal", 0, nsnull) ?
(nsIWebBrowserChrome::modal | nsIWebBrowserChrome::dependent) : 0; (nsIWebBrowserChrome::CHROME_MODAL | nsIWebBrowserChrome::CHROME_DEPENDENT) : 0;
chromeFlags |= WinHasOption(aFeatures, "dialog", 0, nsnull) ? chromeFlags |= WinHasOption(aFeatures, "dialog", 0, nsnull) ?
nsIWebBrowserChrome::openAsDialog : 0; nsIWebBrowserChrome::CHROME_OPENAS_DIALOG : 0;
/* and dialogs need to have the last word. assume dialogs are dialogs, /* and dialogs need to have the last word. assume dialogs are dialogs,
and opened as chrome, unless explicitly told otherwise. */ and opened as chrome, unless explicitly told otherwise. */
if (aDialog) { if (aDialog) {
if (!PL_strcasestr(aFeatures, "dialog")) if (!PL_strcasestr(aFeatures, "dialog"))
chromeFlags |= nsIWebBrowserChrome::openAsDialog; chromeFlags |= nsIWebBrowserChrome::CHROME_OPENAS_DIALOG;
if (!PL_strcasestr(aFeatures, "chrome")) if (!PL_strcasestr(aFeatures, "chrome"))
chromeFlags |= nsIWebBrowserChrome::openAsChrome; chromeFlags |= nsIWebBrowserChrome::CHROME_OPENAS_CHROME;
} }
/* missing /* missing
@ -3174,14 +3173,16 @@ PRUint32 GlobalWindowImpl::CalculateChromeFlags(char *aFeatures, PRBool aDialog)
nsresult res = nsresult res =
securityManager->IsCapabilityEnabled("UniversalBrowserWrite", &enabled); securityManager->IsCapabilityEnabled("UniversalBrowserWrite", &enabled);
res = securityManager->IsCapabilityEnabled("UniversalBrowserWrite", &enabled);
if (NS_FAILED(res) || !enabled) { if (NS_FAILED(res) || !enabled) {
//If priv check fails, set all elements to minimum reqs., else leave them alone. //If priv check fails, set all elements to minimum reqs., else leave them alone.
chromeFlags |= nsIWebBrowserChrome::titlebarOn; chromeFlags |= nsIWebBrowserChrome::CHROME_TITLEBAR;
chromeFlags &= ~nsIWebBrowserChrome::windowLowered; chromeFlags &= ~nsIWebBrowserChrome::CHROME_WINDOW_LOWERED;
chromeFlags &= ~nsIWebBrowserChrome::windowRaised; chromeFlags &= ~nsIWebBrowserChrome::CHROME_WINDOW_RAISED;
//XXX Temporarily removing this check to allow modal dialogs to be //XXX Temporarily removing this check to allow modal dialogs to be
//raised from script. A more complete security based fix is needed. //raised from script. A more complete security based fix is needed.
//chromeFlags &= ~nsIWebBrowserChrome::modal; //chromeFlags &= ~nsIWebBrowserChrome::CHROME_MODAL;
} }
return chromeFlags; return chromeFlags;

Просмотреть файл

@ -42,6 +42,8 @@
#include "nsIContentViewerFile.h" #include "nsIContentViewerFile.h"
#include "nsISelectionController.h" #include "nsISelectionController.h"
#include "nsIDOMWindow.h"
#include "nsEmbedAPI.h" #include "nsEmbedAPI.h"
// Macros to return errors from bad calls to the automation // Macros to return errors from bad calls to the automation
@ -428,13 +430,15 @@ LRESULT CMozillaBrowser::OnSaveAs(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL
char szFileTitle[256]; char szFileTitle[256];
BSTR pageName = NULL; BSTR pageName = NULL;
//TODO: The IE control allows you to also save as "Web Page, complete"
// where all of the page's images are saved in the same directory.
// For the moment, we're not allowing this option.
memset(&SaveFileName, 0, sizeof(SaveFileName));
SaveFileName.lStructSize = sizeof(SaveFileName); SaveFileName.lStructSize = sizeof(SaveFileName);
SaveFileName.hwndOwner = m_hWnd; SaveFileName.hwndOwner = m_hWnd;
SaveFileName.hInstance = NULL; SaveFileName.hInstance = NULL;
SaveFileName.lpstrFilter = "Web Page, HTML Only (*.htm;*.html)\0*.htm;*.html\0Text File (*.txt)\0*.txt\0"; SaveFileName.lpstrFilter = "Web Page, HTML Only (*.htm;*.html)\0*.htm;*.html\0Text File (*.txt)\0*.txt\0";
//TODO: The IE control allows you to also save as "Web Page, complete" where all of the page's images are saved
// in a directory along with the web page. This doesn't appear to be directly supported by Mozilla, but
// could be implemented here if deemed necessary. (Web Page, complete (*.htm;*.html)\0*.htm;*.html\0)
SaveFileName.lpstrCustomFilter = NULL; SaveFileName.lpstrCustomFilter = NULL;
SaveFileName.nMaxCustFilter = NULL; SaveFileName.nMaxCustFilter = NULL;
SaveFileName.nFilterIndex = 1; SaveFileName.nFilterIndex = 1;
@ -461,9 +465,9 @@ LRESULT CMozillaBrowser::OnSaveAs(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL
get_LocationName(&pageName); get_LocationName(&pageName);
strcpy(szTmp, OLE2A(pageName)); strcpy(szTmp, OLE2A(pageName));
//The SaveAs dialog will fail if szFile contains any "bad" characters. // The SaveAs dialog will fail if szFile contains any "bad" characters.
//This hunk of code attempts to mimick the IE way of replacing "bad" // This hunk of code attempts to mimick the IE way of replacing "bad"
//characters with "good" characters. // characters with "good" characters.
int j = 0; int j = 0;
for (int i=0; szTmp[i]!='\0'; i++) for (int i=0; szTmp[i]!='\0'; i++)
{ {
@ -497,42 +501,42 @@ LRESULT CMozillaBrowser::OnSaveAs(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL
szFile[j] = '\0'; szFile[j] = '\0';
HRESULT hr = S_OK; HRESULT hr = S_OK;
if ( GetSaveFileName(&SaveFileName) ) if (GetSaveFileName(&SaveFileName))
{ {
//Get the current DOM document // Get the current DOM document
nsIDOMDocument* pDocument = nsnull; nsIDOMDocument* pDocument = nsnull;
hr = GetDOMDocument(&pDocument); hr = GetDOMDocument(&pDocument);
if ( FAILED(hr) ) if (FAILED(hr))
{ {
return hr; return hr;
} }
//Get an nsIDiskDocument interface to the DOM document // Get an nsIDiskDocument interface to the DOM document
nsCOMPtr<nsIDiskDocument> diskDoc = do_QueryInterface(pDocument); nsCOMPtr<nsIDiskDocument> diskDoc = do_QueryInterface(pDocument);
if (!diskDoc) if (!diskDoc)
{ {
return E_NOINTERFACE; return E_NOINTERFACE;
} }
/* XXX fix to use new mime-ified version of SaveFile on nsIDiskDocument // Create an nsFilelSpec from the selected file path.
//Set the file type specified by the user
//Add the correct file extension if none is specified
nsIDiskDocument::ESaveFileType saveFileType;
if ( SaveFileName.nFilterIndex == 2 ) //SaveAs text file
{
saveFileType = nsIDiskDocument::eSaveFileText;
}
else //SaveAs html file
{
saveFileType = nsIDiskDocument::eSaveFileHTML;
}
//Create an nsFilelSpec from the selected file path.
nsFileSpec fileSpec(szFile, PR_FALSE); nsFileSpec fileSpec(szFile, PR_FALSE);
//Save the file. // Figure out the mime type from the selection
hr = diskDoc->SaveFile(&fileSpec, PR_TRUE, PR_TRUE, saveFileType, ""); nsAutoString mimeType;
*/ switch (SaveFileName.nFilterIndex)
{
case 1:
mimeType.AssignWithConversion("text/html");
break;
case 2:
default:
mimeType.AssignWithConversion("text/plain");
break;
}
// Save the file.
nsAutoString useDocCharset;
hr = diskDoc->SaveFile(&fileSpec, PR_TRUE, PR_TRUE, mimeType, useDocCharset, 0);
} }
return hr; return hr;
@ -549,9 +553,8 @@ LRESULT CMozillaBrowser::OnProperties(WORD wNotifyCode, WORD wID, HWND hWndCtl,
LRESULT CMozillaBrowser::OnCut(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) LRESULT CMozillaBrowser::OnCut(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{ {
NG_TRACE_METHOD(CMozillaBrowser::OnCut); NG_TRACE_METHOD(CMozillaBrowser::OnCut);
nsCOMPtr<nsIContentViewerEdit> contentViewerEdit; nsCOMPtr<nsIContentViewerEdit> contentViewerEdit(do_GetInterface(mWebBrowser));
nsresult rv = GetEditInterface(getter_AddRefs(contentViewerEdit)); if (contentViewerEdit)
if (NS_SUCCEEDED(rv))
{ {
contentViewerEdit->CutSelection(); contentViewerEdit->CutSelection();
} }
@ -561,9 +564,8 @@ LRESULT CMozillaBrowser::OnCut(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& b
LRESULT CMozillaBrowser::OnCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) LRESULT CMozillaBrowser::OnCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{ {
NG_TRACE_METHOD(CMozillaBrowser::OnCopy); NG_TRACE_METHOD(CMozillaBrowser::OnCopy);
nsCOMPtr<nsIContentViewerEdit> contentViewerEdit; nsCOMPtr<nsIContentViewerEdit> contentViewerEdit(do_GetInterface(mWebBrowser));
nsresult rv = GetEditInterface(getter_AddRefs(contentViewerEdit)); if (contentViewerEdit)
if (NS_SUCCEEDED(rv))
{ {
contentViewerEdit->CopySelection(); contentViewerEdit->CopySelection();
} }
@ -573,9 +575,8 @@ LRESULT CMozillaBrowser::OnCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL&
LRESULT CMozillaBrowser::OnPaste(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) LRESULT CMozillaBrowser::OnPaste(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{ {
NG_TRACE_METHOD(CMozillaBrowser::OnPaste); NG_TRACE_METHOD(CMozillaBrowser::OnPaste);
nsCOMPtr<nsIContentViewerEdit> contentViewerEdit; nsCOMPtr<nsIContentViewerEdit> contentViewerEdit(do_GetInterface(mWebBrowser));
nsresult rv = GetEditInterface(getter_AddRefs(contentViewerEdit)); if (contentViewerEdit)
if (NS_SUCCEEDED(rv))
{ {
contentViewerEdit->Paste(); contentViewerEdit->Paste();
} }
@ -585,9 +586,8 @@ LRESULT CMozillaBrowser::OnPaste(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL&
LRESULT CMozillaBrowser::OnSelectAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) LRESULT CMozillaBrowser::OnSelectAll(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{ {
NG_TRACE_METHOD(CMozillaBrowser::OnSelectAll); NG_TRACE_METHOD(CMozillaBrowser::OnSelectAll);
nsCOMPtr<nsIContentViewerEdit> contentViewerEdit; nsCOMPtr<nsIContentViewerEdit> contentViewerEdit(do_GetInterface(mWebBrowser));
nsresult rv = GetEditInterface(getter_AddRefs(contentViewerEdit)); if (contentViewerEdit)
if (NS_SUCCEEDED(rv))
{ {
contentViewerEdit->SelectAll(); contentViewerEdit->SelectAll();
} }
@ -881,7 +881,9 @@ HRESULT CMozillaBrowser::CreateBrowser()
return rv; return rv;
} }
mWebBrowser->QueryInterface(NS_GET_IID(nsIBaseWindow), (void **) &mWebBrowserAsWin); nsCOMPtr<nsIInterfaceRequestor> webBrowserAsReq(do_QueryInterface(mWebBrowser));
mWebBrowserAsWin = do_QueryInterface(mWebBrowser);
rv = mWebBrowserAsWin->InitWindow(nsNativeWidget(m_hWnd), nsnull, rv = mWebBrowserAsWin->InitWindow(nsNativeWidget(m_hWnd), nsnull,
0, 0, rcLocation.right - rcLocation.left, rcLocation.bottom - rcLocation.top); 0, 0, rcLocation.right - rcLocation.left, rcLocation.bottom - rcLocation.top);
@ -889,7 +891,13 @@ HRESULT CMozillaBrowser::CreateBrowser()
browserAsItem->SetItemType(nsIDocShellTreeItem::typeChromeWrapper); browserAsItem->SetItemType(nsIDocShellTreeItem::typeChromeWrapper);
rv = mWebBrowserAsWin->Create(); rv = mWebBrowserAsWin->Create();
rv = mWebBrowser->GetDocShell(&mRootDocShell);
// Configure what the web browser can and cannot do
// nsCOMPtr<nsIWebBrowserSetup> webBrowserAsSetup(do_QueryInterface(mWebBrowser));
// webBrowserAsSetup->SetProperty(nsIWebBrowserSetup::SETUP_ALLOW_PLUGINS, aAllowPlugins);
// XXX delete when docshell becomes inaccessible
mRootDocShell = do_GetInterface(mWebBrowser);
if (mRootDocShell == nsnull) if (mRootDocShell == nsnull)
{ {
NG_ASSERT(0); NG_ASSERT(0);
@ -897,7 +905,7 @@ HRESULT CMozillaBrowser::CreateBrowser()
SetStartupErrorMessage(IDS_CANNOTCREATEPREFS); SetStartupErrorMessage(IDS_CANNOTCREATEPREFS);
return rv; return rv;
} }
mRootDocShell->SetAllowPlugins(aAllowPlugins);
nsCOMPtr<nsIDocumentLoader> docLoader; nsCOMPtr<nsIDocumentLoader> docLoader;
// Create the container object // Create the container object
@ -939,15 +947,15 @@ HRESULT CMozillaBrowser::DestroyBrowser()
} }
// Destroy layout... // Destroy layout...
if (mWebBrowserAsWin != nsnull) if (mWebBrowserAsWin)
{ {
mWebBrowserAsWin->Destroy(); mWebBrowserAsWin->Destroy();
NS_RELEASE(mWebBrowserAsWin); mWebBrowserAsWin = nsnull;
} }
if (mRootDocShell != nsnull) if (mRootDocShell != nsnull)
{ {
NS_RELEASE(mRootDocShell); mRootDocShell = nsnull;
} }
if (mWebBrowserContainer) if (mWebBrowserContainer)
@ -971,58 +979,6 @@ HRESULT CMozillaBrowser::DestroyBrowser()
HRESULT CMozillaBrowser::SetEditorMode(BOOL bEnabled) HRESULT CMozillaBrowser::SetEditorMode(BOOL bEnabled)
{ {
NG_TRACE_METHOD(CMozillaBrowser::SetEditorMode); NG_TRACE_METHOD(CMozillaBrowser::SetEditorMode);
/*
mEditModeFlag = FALSE;
if (bEnabled && mEditor == nsnull)
{
if (!IsValid())
{
return E_UNEXPECTED;
}
nsresult result = nsComponentManager::CreateInstance(kHTMLEditorCID,
nsnull,
NS_GET_IID(nsIEditor),
(void **) &mEditor);
if (NS_FAILED(result))
{
return result;
}
if (!mEditor)
{
return E_OUTOFMEMORY;
}
nsIDOMDocument *pIDOMDocument = nsnull;
if (FAILED(GetDOMDocument(&pIDOMDocument)) || pIDOMDocument == nsnull)
{
return E_UNEXPECTED;
}
nsIPresShell* pIPresShell = nsnull;
if (FAILED(GetPresShell(&pIPresShell)) || pIPresShell == nsnull)
{
return E_UNEXPECTED;
}
result = mEditor->Init(pIDOMDocument, pIPresShell, 0);
if (NS_SUCCEEDED(result))
{
mEditModeFlag = TRUE;
}
NS_RELEASE(pIPresShell);
NS_RELEASE(pIDOMDocument);
}
else
{
if (mEditor)
{
mEditor->Release();
mEditor = nsnull;
}
}
*/
return S_OK; return S_OK;
} }
@ -1095,72 +1051,12 @@ HRESULT CMozillaBrowser::OnEditorCommand(DWORD nCmdID)
} }
// Returns the presentation shell
HRESULT CMozillaBrowser::GetPresShell(nsIPresShell **pPresShell)
{
NG_TRACE_METHOD(CMozillaBrowser::GetPresShell);
nsresult res;
// Test for stupid args
if (pPresShell == NULL)
{
NG_ASSERT(0);
return E_INVALIDARG;
}
*pPresShell = nsnull;
if (!IsValid())
{
NG_ASSERT(0);
return E_UNEXPECTED;
}
nsIContentViewer* pIContentViewer = nsnull;
res = mRootDocShell->GetContentViewer(&pIContentViewer);
if (NS_SUCCEEDED(res) && pIContentViewer)
{
nsIDocumentViewer* pIDocViewer = nsnull;
res = pIContentViewer->QueryInterface(NS_GET_IID(nsIDocumentViewer), (void**) &pIDocViewer);
if (NS_SUCCEEDED(res) && pIDocViewer)
{
nsIPresContext * pIPresContent = nsnull;
res = pIDocViewer->GetPresContext(pIPresContent);
if (NS_SUCCEEDED(res) && pIPresContent)
{
res = pIPresContent->GetShell(pPresShell);
NS_RELEASE(pIPresContent);
}
NS_RELEASE(pIDocViewer);
}
NS_RELEASE(pIContentViewer);
}
return res;
}
// Get the nsIContentViewEdit interface from the root docshell
HRESULT CMozillaBrowser::GetEditInterface(nsIContentViewerEdit** aEditInterface)
{
nsCOMPtr<nsIContentViewer> viewer;
mRootDocShell->GetContentViewer(getter_AddRefs(viewer));
nsCOMPtr<nsIContentViewerEdit> edit(do_QueryInterface(viewer));
NS_ENSURE_TRUE(edit, NS_ERROR_FAILURE);
*aEditInterface = edit;
NS_ADDREF(*aEditInterface);
return NS_OK;
}
// Return the root DOM document // Return the root DOM document
HRESULT CMozillaBrowser::GetDOMDocument(nsIDOMDocument **pDocument) HRESULT CMozillaBrowser::GetDOMDocument(nsIDOMDocument **pDocument)
{ {
NG_TRACE_METHOD(CMozillaBrowser::GetDOMDocument); NG_TRACE_METHOD(CMozillaBrowser::GetDOMDocument);
nsresult res; HRESULT hr = E_FAIL;
// Test for stupid args // Test for stupid args
if (pDocument == NULL) if (pDocument == NULL)
@ -1177,27 +1073,17 @@ HRESULT CMozillaBrowser::GetDOMDocument(nsIDOMDocument **pDocument)
return E_UNEXPECTED; return E_UNEXPECTED;
} }
nsIContentViewer * pCViewer = nsnull; // Get the DOM window from the webbrowser
res = mRootDocShell->GetContentViewer(&pCViewer); nsCOMPtr<nsIDOMWindow> window(do_GetInterface(mWebBrowser));
if (NS_SUCCEEDED(res) && pCViewer) if (window)
{ {
nsIDocumentViewer * pDViewer = nsnull; if (NS_SUCCEEDED(window->GetDocument(pDocument)) && *pDocument)
res = pCViewer->QueryInterface(NS_GET_IID(nsIDocumentViewer), (void**) &pDViewer); {
if (NS_SUCCEEDED(res) && pDViewer) hr = S_OK;
{ }
nsIDocument * pDoc = nsnull; }
res = pDViewer->GetDocument(pDoc);
if (NS_SUCCEEDED(res) && pDoc)
{
res = pDoc->QueryInterface(NS_GET_IID(nsIDOMDocument), (void**) pDocument);
NS_RELEASE(pDoc);
}
NS_RELEASE(pDViewer);
}
NS_RELEASE(pCViewer);
}
return res; return hr;
} }
@ -1674,7 +1560,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate(BSTR URL, VARIANT __RPC_FAR
// Load the URL // Load the URL
nsresult res = NS_ERROR_FAILURE; nsresult res = NS_ERROR_FAILURE;
nsCOMPtr<nsIWebNavigation> spIWebNavigation = do_QueryInterface(mRootDocShell); nsCOMPtr<nsIWebNavigation> spIWebNavigation = do_QueryInterface(mWebBrowser);
if (spIWebNavigation) if (spIWebNavigation)
{ {
res = spIWebNavigation->LoadURI(sUrl.c_str()); res = spIWebNavigation->LoadURI(sUrl.c_str());
@ -1745,7 +1631,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Refresh2(VARIANT __RPC_FAR *Level)
RETURN_E_UNEXPECTED(); RETURN_E_UNEXPECTED();
} }
nsCOMPtr<nsIWebNavigation> spIWebNavigation = do_QueryInterface(mRootDocShell); nsCOMPtr<nsIWebNavigation> spIWebNavigation = do_QueryInterface(mWebBrowser);
if (spIWebNavigation) if (spIWebNavigation)
{ {
spIWebNavigation->Reload(type); spIWebNavigation->Reload(type);
@ -1765,7 +1651,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Stop()
RETURN_E_UNEXPECTED(); RETURN_E_UNEXPECTED();
} }
nsCOMPtr<nsIWebNavigation> spIWebNavigation = do_QueryInterface(mRootDocShell); nsCOMPtr<nsIWebNavigation> spIWebNavigation = do_QueryInterface(mWebBrowser);
if (spIWebNavigation) if (spIWebNavigation)
{ {
spIWebNavigation->Stop(); spIWebNavigation->Stop();

Просмотреть файл

@ -328,8 +328,8 @@ protected:
// Mozilla interfaces // Mozilla interfaces
nsCOMPtr<nsIWebBrowser> mWebBrowser; nsCOMPtr<nsIWebBrowser> mWebBrowser;
nsIBaseWindow * mWebBrowserAsWin; nsCOMPtr<nsIBaseWindow> mWebBrowserAsWin;
nsIDocShell * mRootDocShell; nsCOMPtr<nsIDocShell> mRootDocShell; // XXX this is going soon
nsIPref * mPrefs; nsIPref * mPrefs;
nsIEditor * mEditor; nsIEditor * mEditor;
@ -365,8 +365,6 @@ protected:
virtual HRESULT CheckBinDirPath(); virtual HRESULT CheckBinDirPath();
virtual HRESULT SetStartupErrorMessage(UINT nStringID); virtual HRESULT SetStartupErrorMessage(UINT nStringID);
virtual HRESULT SetErrorInfo(LPCTSTR lpszDesc, HRESULT hr); virtual HRESULT SetErrorInfo(LPCTSTR lpszDesc, HRESULT hr);
virtual HRESULT GetPresShell(nsIPresShell **pPresShell);
virtual HRESULT GetEditInterface(nsIContentViewerEdit** aEditInterface);
virtual HRESULT GetDOMDocument(nsIDOMDocument **pDocument); virtual HRESULT GetDOMDocument(nsIDOMDocument **pDocument);
virtual HRESULT SetEditorMode(BOOL bEnabled); virtual HRESULT SetEditorMode(BOOL bEnabled);
virtual HRESULT OnEditorCommand(DWORD nCmdID); virtual HRESULT OnEditorCommand(DWORD nCmdID);

Просмотреть файл

@ -66,6 +66,7 @@
#include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeOwner.h" #include "nsIDocShellTreeOwner.h"
#include "nsIWebBrowserChrome.h" #include "nsIWebBrowserChrome.h"
#include "nsIWebBrowserSetup.h"
#include "nsIWebNavigation.h" #include "nsIWebNavigation.h"
#include "nsIWebProgress.h" #include "nsIWebProgress.h"
#include "nsIWebProgressListener.h" #include "nsIWebProgressListener.h"
@ -77,7 +78,6 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIDOMSelection.h" #include "nsIDOMSelection.h"
#include "nsIPresContext.h" #include "nsIPresContext.h"
#include "nsIPresShell.h"
#include "nsIPrompt.h" #include "nsIPrompt.h"
#include "nsEditorCID.h" #include "nsEditorCID.h"

Просмотреть файл

@ -63,6 +63,7 @@ NS_INTERFACE_MAP_BEGIN(CWebBrowserContainer)
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
NS_INTERFACE_MAP_ENTRY(nsIPrompt) NS_INTERFACE_MAP_ENTRY(nsIPrompt)
NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener) NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener)
// NS_INTERFACE_MAP_ENTRY(nsICommandHandler)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END
@ -199,15 +200,15 @@ NS_IMETHODIMP CWebBrowserContainer::OnStateChange(nsIWebProgress* aWebProgress,
{ {
NG_TRACE(_T("CWebBrowserContainer::OnStateChange(...)\n")); NG_TRACE(_T("CWebBrowserContainer::OnStateChange(...)\n"));
if (progressStateFlags & flag_is_network) if (progressStateFlags & STATE_IS_NETWORK)
{ {
if (progressStateFlags & flag_start) if (progressStateFlags & STATE_START)
{ {
// TODO // TODO
} }
if (progressStateFlags & flag_stop) if (progressStateFlags & STATE_STOP)
{ {
nsXPIDLCString aURI; nsXPIDLCString aURI;
if (m_pCurrentURI) if (m_pCurrentURI)
@ -486,11 +487,8 @@ NS_IMETHODIMP CWebBrowserContainer::GetNewWindow(PRInt32 aChromeFlags,
if ((bCancel == VARIANT_FALSE) && pDispNew) if ((bCancel == VARIANT_FALSE) && pDispNew)
{ {
CMozillaBrowser *pBrowser = (CMozillaBrowser *) pDispNew; CMozillaBrowser *pBrowser = (CMozillaBrowser *) pDispNew;
// XXXX what the hell is this supposed to mean?
nsIDocShell *docShell; nsCOMPtr<nsIDocShell> docShell(do_GetInterface(pBrowser->mWebBrowser));
pBrowser->mWebBrowser->GetDocShell(&docShell);
docShell->QueryInterface(NS_GET_IID(nsIDocShellTreeItem), (void **) aDocShellTreeItem);
docShell->Release();
pDispNew->Release(); pDispNew->Release();
return NS_OK; return NS_OK;
} }
@ -654,7 +652,7 @@ CWebBrowserContainer::SetTitle(const PRUnichar * aTitle)
// nsIWebBrowserChrome implementation // nsIWebBrowserChrome implementation
NS_IMETHODIMP NS_IMETHODIMP
CWebBrowserContainer::SetJSStatus(const PRUnichar *status) CWebBrowserContainer::SetStatus(PRUint32 statusType, const PRUnichar *status)
{ {
//Fire a StatusTextChange event //Fire a StatusTextChange event
BSTR bstrStatus = SysAllocString(status); BSTR bstrStatus = SysAllocString(status);
@ -665,30 +663,6 @@ CWebBrowserContainer::SetJSStatus(const PRUnichar *status)
} }
NS_IMETHODIMP
CWebBrowserContainer::SetJSDefaultStatus(const PRUnichar *status)
{
//Fire a StatusTextChange event
BSTR bstrStatus = SysAllocString(status);
m_pEvents1->Fire_StatusTextChange(bstrStatus);
m_pEvents2->Fire_StatusTextChange(bstrStatus);
SysFreeString(bstrStatus);
return NS_OK;
}
NS_IMETHODIMP
CWebBrowserContainer::SetOverLink(const PRUnichar *link)
{
//Fire a StatusTextChange event
BSTR bstrStatus = SysAllocString(link);
m_pEvents1->Fire_StatusTextChange(bstrStatus);
m_pEvents2->Fire_StatusTextChange(bstrStatus);
SysFreeString(bstrStatus);
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
CWebBrowserContainer::GetWebBrowser(nsIWebBrowser * *aWebBrowser) CWebBrowserContainer::GetWebBrowser(nsIWebBrowser * *aWebBrowser)
{ {
@ -704,21 +678,21 @@ CWebBrowserContainer::SetWebBrowser(nsIWebBrowser * aWebBrowser)
NS_IMETHODIMP NS_IMETHODIMP
CWebBrowserContainer::GetChromeMask(PRUint32 *aChromeMask) CWebBrowserContainer::GetChromeFlags(PRUint32 *aChromeFlags)
{ {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP NS_IMETHODIMP
CWebBrowserContainer::SetChromeMask(PRUint32 aChromeMask) CWebBrowserContainer::SetChromeFlags(PRUint32 aChromeFlags)
{ {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP NS_IMETHODIMP
CWebBrowserContainer::GetNewBrowser(PRUint32 chromeMask, nsIWebBrowser **_retval) CWebBrowserContainer::CreateBrowserWindow(PRUint32 chromeFlags, nsIWebBrowser **_retval)
{ {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -909,3 +883,17 @@ CWebBrowserContainer::OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channe
} }
///////////////////////////////////////////////////////////////////////////////
// nsICommandHandler implementation
/* void do (in string aCommand, in string aStatus); */
NS_IMETHODIMP CWebBrowserContainer::Exec(const char *aCommand, const char *aStatus, char **aResult)
{
return NS_OK;
}
/* void query (in string aCommand, in string aStatus); */
NS_IMETHODIMP CWebBrowserContainer::Query(const char *aCommand, const char *aStatus, char **aResult)
{
return NS_OK;
}

Просмотреть файл

@ -26,6 +26,7 @@
#define WEBBROWSERCONTAINER_H #define WEBBROWSERCONTAINER_H
#include "nsIContextMenuListener.h" #include "nsIContextMenuListener.h"
#include "nsICommandHandler.h"
// This is the class that handles the XPCOM side of things, callback // This is the class that handles the XPCOM side of things, callback
// interfaces into the web shell and so forth. // interfaces into the web shell and so forth.
@ -40,7 +41,8 @@ class CWebBrowserContainer :
public nsIDocShellTreeOwner, public nsIDocShellTreeOwner,
public nsIInterfaceRequestor, public nsIInterfaceRequestor,
public nsIPrompt, public nsIPrompt,
public nsIContextMenuListener public nsIContextMenuListener,
public nsICommandHandler
{ {
public: public:
CWebBrowserContainer(CMozillaBrowser *pOwner); CWebBrowserContainer(CMozillaBrowser *pOwner);
@ -70,6 +72,7 @@ public:
NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIWEBPROGRESSLISTENER NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSICONTEXTMENULISTENER NS_DECL_NSICONTEXTMENULISTENER
NS_DECL_NSICOMMANDHANDLER
// "Services" accessed through nsIInterfaceRequestor // "Services" accessed through nsIInterfaceRequestor
NS_DECL_NSIPROMPT NS_DECL_NSIPROMPT

Просмотреть файл

@ -38,7 +38,6 @@ CPPSRCS = \
SHARED_LIBRARY_LIBS= \ SHARED_LIBRARY_LIBS= \
$(DIST)/lib/libnsWebBrowser_s.$(LIB_SUFFIX) \ $(DIST)/lib/libnsWebBrowser_s.$(LIB_SUFFIX) \
$(DIST)/lib/libnsWebBrowserSetup_s.$(LIB_SUFFIX) \
$(NULL) $(NULL)
EXTRA_DSO_LDOPTS= \ EXTRA_DSO_LDOPTS= \

Просмотреть файл

@ -29,7 +29,7 @@ MAKE_OBJ_TYPE = DLL
DLLNAME = webbrwsr DLLNAME = webbrwsr
DLL=.\$(OBJDIR)\$(DLLNAME).dll DLL=.\$(OBJDIR)\$(DLLNAME).dll
LINCS=-I..\webBrowser -I..\setup LINCS=-I..\webBrowser
CPP_OBJS= \ CPP_OBJS= \
.\$(OBJDIR)\nsWebBrowserModule.obj \ .\$(OBJDIR)\nsWebBrowserModule.obj \
@ -38,7 +38,6 @@ CPP_OBJS= \
# These are the libraries we need to link with to create the dll # These are the libraries we need to link with to create the dll
LLIBS = \ LLIBS = \
$(DIST)\lib\nsWebBrowser_s.lib \ $(DIST)\lib\nsWebBrowser_s.lib \
$(DIST)\lib\nsWebBrowserSetup_s.lib \
$(DIST)\lib\xpcom.lib \ $(DIST)\lib\xpcom.lib \
$(DIST)\lib\gkgfxwin.lib \ $(DIST)\lib\gkgfxwin.lib \
$(LIBNSPR) $(LIBNSPR)

Просмотреть файл

@ -24,26 +24,26 @@
#include "nsIGenericFactory.h" #include "nsIGenericFactory.h"
#include "nsWebBrowser.h" #include "nsWebBrowser.h"
#include "nsWebBrowserSetup.h"
#include "nsCommandHandler.h" #include "nsCommandHandler.h"
// Factory Constructors // Factory Constructors
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebBrowser) NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebBrowser)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebBrowserSetup) //NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebBrowserSetup)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCommandHandler) NS_GENERIC_FACTORY_CONSTRUCTOR(nsCommandHandler)
// Component Table // Component Table
static nsModuleComponentInfo components[] = static nsModuleComponentInfo components[] =
{ {
{ "WebBrowser Component", NS_WEBBROWSER_CID, { "WebBrowser Component", NS_WEBBROWSER_CID,
NS_WEBBROWSER_PROGID, nsWebBrowserConstructor }, NS_WEBBROWSER_PROGID, nsWebBrowserConstructor },
{ "WebBrowserSetup Component", NS_WEBBROWSER_SETUP_CID,
NS_WEBBROWSER_SETUP_PROGID, nsWebBrowserSetupConstructor },
{ "CommandHandler Component", NS_COMMANDHANDLER_CID, { "CommandHandler Component", NS_COMMANDHANDLER_CID,
NS_COMMANDHANDLER_PROGID, nsCommandHandlerConstructor } NS_COMMANDHANDLER_PROGID, nsCommandHandlerConstructor }
// { "WebBrowserSetup Component", NS_WEBBROWSER_SETUP_CID,
// NS_WEBBROWSER_SETUP_PROGID, nsWebBrowserSetupConstructor }
}; };

Просмотреть файл

@ -318,33 +318,36 @@ NS_IMETHODIMP GtkMozEmbedChrome::GetInterface(const nsIID &aIID, void** aInstanc
// nsIWebBrowserChrome interface // nsIWebBrowserChrome interface
NS_IMETHODIMP GtkMozEmbedChrome::SetJSStatus(const PRUnichar *status) NS_IMETHODIMP GtkMozEmbedChrome::SetStatus(PRUint32 aType, const PRUnichar *status)
{ {
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::SetJSStatus\n")); PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::SetStatus\n"));
nsString jsStatusString(status);
mJSStatus = jsStatusString.ToNewCString();
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("js status is %s\n", (const char *)mJSStatus));
// let our chrome listener know that the JS message has changed.
if (mChromeListener)
mChromeListener->Message(GtkEmbedListener::MessageJSStatus, mJSStatus);
return NS_OK;
}
NS_IMETHODIMP GtkMozEmbedChrome::SetJSDefaultStatus(const PRUnichar *status) switch (aType)
{ {
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::SetJSDefaultStatus\n")); case STATUS_SCRIPT:
return NS_ERROR_NOT_IMPLEMENTED; {
} nsString jsStatusString(status);
mJSStatus = jsStatusString.ToNewCString();
NS_IMETHODIMP GtkMozEmbedChrome::SetOverLink(const PRUnichar *link) PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("js status is %s\n", (const char *)mJSStatus));
{ // let our chrome listener know that the JS message has changed.
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::SetOverLink\n")); if (mChromeListener)
nsString linkMessageString(link); mChromeListener->Message(GtkEmbedListener::MessageJSStatus, mJSStatus);
mLinkMessage = linkMessageString.ToNewCString(); }
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("message is %s\n", (const char *)mLinkMessage)); break;
// notify the chrome listener that the link message has changed case STATUS_SCRIPT_DEFAULT:
if (mChromeListener) // NOT IMPLEMENTED
mChromeListener->Message(GtkEmbedListener::MessageLink, mLinkMessage); break;
case STATUS_LINK:
{
nsString linkMessageString(status);
mLinkMessage = linkMessageString.ToNewCString();
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("message is %s\n", (const char *)mLinkMessage));
// notify the chrome listener that the link message has changed
if (mChromeListener)
mChromeListener->Message(GtkEmbedListener::MessageLink, mLinkMessage);
return NS_OK;
}
}
return NS_OK; return NS_OK;
} }
@ -370,22 +373,22 @@ NS_IMETHODIMP GtkMozEmbedChrome::SetWebBrowser(nsIWebBrowser * aWebBrowser)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP GtkMozEmbedChrome::GetChromeMask(PRUint32 *aChromeMask) NS_IMETHODIMP GtkMozEmbedChrome::GetChromeFlags(PRUint32 *aChromeFlags)
{ {
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::GetChromeMask\n")); PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::GetChromeFlags\n"));
NS_ENSURE_ARG_POINTER(aChromeMask); NS_ENSURE_ARG_POINTER(aChromeFlags);
*aChromeMask = mChromeMask; *aChromeFlags = mChromeMask;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP GtkMozEmbedChrome::SetChromeMask(PRUint32 aChromeMask) NS_IMETHODIMP GtkMozEmbedChrome::SetChromeFlags(PRUint32 aChromeFlags)
{ {
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::SetChromeMask\n")); PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::SetChromeFlags\n"));
mChromeMask = aChromeMask; mChromeMask = aChromeFlags;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP GtkMozEmbedChrome::GetNewBrowser(PRUint32 chromeMask, NS_IMETHODIMP GtkMozEmbedChrome::CreateBrowserWindow(PRUint32 chromeMask,
nsIWebBrowser **_retval) nsIWebBrowser **_retval)
{ {
PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::GetNewBrowser\n")); PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::GetNewBrowser\n"));

Просмотреть файл

@ -264,8 +264,8 @@ GtkMozEmbedPrivate::Init(GtkMozEmbed *aEmbed)
// get our hands on the browser chrome // get our hands on the browser chrome
nsCOMPtr<nsIWebBrowserChrome> browserChrome = do_QueryInterface(mEmbed); nsCOMPtr<nsIWebBrowserChrome> browserChrome = do_QueryInterface(mEmbed);
NS_ENSURE_TRUE(browserChrome, NS_ERROR_FAILURE); NS_ENSURE_TRUE(browserChrome, NS_ERROR_FAILURE);
// set the toplevel window // set the container window
mWebBrowser->SetTopLevelWindow(browserChrome); mWebBrowser->SetContainerWindow(browserChrome);
// set the widget as the owner of the object // set the widget as the owner of the object
mEmbed->Init(GTK_WIDGET(aEmbed)); mEmbed->Init(GTK_WIDGET(aEmbed));
@ -327,8 +327,7 @@ GtkMozEmbedPrivate::Realize(GtkWidget *aWidget)
mWebBrowser->SetParentURIContentListener(uriListener); mWebBrowser->SetParentURIContentListener(uriListener);
// get the nsIWebProgress object from the chrome docshell // get the nsIWebProgress object from the chrome docshell
nsCOMPtr <nsIDocShell> docShell; nsCOMPtr <nsIDocShell> docShell = do_GetInterface(mWebBrowser);
mWebBrowser->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr <nsIWebProgress> webProgress; nsCOMPtr <nsIWebProgress> webProgress;
webProgress = do_GetInterface(docShell); webProgress = do_GetInterface(docShell);
// add our chrome listener object // add our chrome listener object
@ -563,8 +562,7 @@ GtkMozEmbedPrivate::Destroy(void)
mWebBrowser->SetParentURIContentListener(nsnull); mWebBrowser->SetParentURIContentListener(nsnull);
// remove ourselves as the progress listener for the chrome object // remove ourselves as the progress listener for the chrome object
nsCOMPtr <nsIDocShell> docShell; nsCOMPtr <nsIDocShell> docShell = do_GetInterface(mWebBrowser);
mWebBrowser->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr <nsIWebProgress> webProgress; nsCOMPtr <nsIWebProgress> webProgress;
webProgress = do_GetInterface(docShell); webProgress = do_GetInterface(docShell);
webProgress->RemoveProgressListener(mChromeProgress); webProgress->RemoveProgressListener(mChromeProgress);
@ -1111,14 +1109,14 @@ gtk_moz_embed_set_chrome_mask (GtkMozEmbed *embed, guint32 flags)
nsCOMPtr<nsIWebBrowserChrome> browserChrome = nsCOMPtr<nsIWebBrowserChrome> browserChrome =
do_QueryInterface(embed_private->mEmbed); do_QueryInterface(embed_private->mEmbed);
g_return_if_fail(browserChrome); g_return_if_fail(browserChrome);
browserChrome->SetChromeMask(flags); browserChrome->SetChromeFlags(flags);
} }
guint32 guint32
gtk_moz_embed_get_chrome_mask (GtkMozEmbed *embed) gtk_moz_embed_get_chrome_mask (GtkMozEmbed *embed)
{ {
GtkMozEmbedPrivate *embed_private; GtkMozEmbedPrivate *embed_private;
PRUint32 curMask = 0; PRUint32 curFlags = 0;
g_return_val_if_fail ((embed != NULL), 0); g_return_val_if_fail ((embed != NULL), 0);
g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), 0); g_return_val_if_fail (GTK_IS_MOZ_EMBED(embed), 0);
@ -1127,8 +1125,8 @@ gtk_moz_embed_get_chrome_mask (GtkMozEmbed *embed)
nsCOMPtr<nsIWebBrowserChrome> browserChrome = nsCOMPtr<nsIWebBrowserChrome> browserChrome =
do_QueryInterface(embed_private->mEmbed); do_QueryInterface(embed_private->mEmbed);
g_return_val_if_fail(browserChrome, 0); g_return_val_if_fail(browserChrome, 0);
if (browserChrome->GetChromeMask(&curMask) == NS_OK) if (browserChrome->GetChromeFlags(&curFlags) == NS_OK)
return curMask; return curFlags;
else else
return 0; return 0;
} }

Просмотреть файл

@ -23,11 +23,12 @@ DEPTH=..\..\..
MODULE=webBrowser_core MODULE=webBrowser_core
XPIDLSRCS= \ XPIDLSRCS= \
.\nsIContextMenuListener.idl \ .\nsIContextMenuListener.idl \
.\nsCWebBrowser.idl \ .\nsCWebBrowser.idl \
.\nsIWebBrowser.idl \ .\nsIWebBrowser.idl \
.\nsIWebBrowserChrome.idl \ .\nsIWebBrowserChrome.idl \
.\nsICommandHandler.idl \ .\nsICommandHandler.idl \
.\nsIWebBrowserSetup.idl \
$(NULL) $(NULL)
LIBRARY_NAME=nsWebBrowser_s LIBRARY_NAME=nsWebBrowser_s

Просмотреть файл

@ -120,10 +120,11 @@ NS_IMETHODIMP nsCommandHandler::SetWindow(nsIDOMWindow * aWindow)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// nsICommandHandler implementation // nsICommandHandler implementation
/* void do (in string aCommand, in string aStatus); */ /* string exec (in string aCommand, in string aStatus); */
NS_IMETHODIMP nsCommandHandler::Exec(const char *aCommand, const char *aStatus) NS_IMETHODIMP nsCommandHandler::Exec(const char *aCommand, const char *aStatus, char **aResult)
{ {
NS_ENSURE_ARG_POINTER(aCommand); NS_ENSURE_ARG_POINTER(aCommand);
NS_ENSURE_ARG_POINTER(aResult);
nsCOMPtr<nsICommandHandler> commandHandler; nsCOMPtr<nsICommandHandler> commandHandler;
GetCommandHandler(getter_AddRefs(commandHandler)); GetCommandHandler(getter_AddRefs(commandHandler));
@ -131,13 +132,18 @@ NS_IMETHODIMP nsCommandHandler::Exec(const char *aCommand, const char *aStatus)
// Call the client's command handler to deal with this command // Call the client's command handler to deal with this command
if (commandHandler) if (commandHandler)
{ {
return commandHandler->Exec(aCommand, aStatus); *aResult = nsnull;
return commandHandler->Exec(aCommand, aStatus, aResult);
} }
// Return an empty string
const char szEmpty[] = "";
*aResult = (char *) nsAllocator::Clone(szEmpty, sizeof(szEmpty));
return NS_OK; return NS_OK;
} }
/* void query (in string aCommand, in string aStatus); */ /* string query (in string aCommand, in string aStatus); */
NS_IMETHODIMP nsCommandHandler::Query(const char *aCommand, const char *aStatus, char **aResult) NS_IMETHODIMP nsCommandHandler::Query(const char *aCommand, const char *aStatus, char **aResult)
{ {
NS_ENSURE_ARG_POINTER(aCommand); NS_ENSURE_ARG_POINTER(aCommand);

Просмотреть файл

@ -238,11 +238,11 @@ NS_IMETHODIMP nsDocShellTreeOwner::GetNewWindow(PRInt32 aChromeFlags,
nsCOMPtr<nsIWebBrowser> webBrowser; nsCOMPtr<nsIWebBrowser> webBrowser;
NS_ENSURE_TRUE(mWebBrowserChrome, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mWebBrowserChrome, NS_ERROR_FAILURE);
mWebBrowserChrome->GetNewBrowser(aChromeFlags, getter_AddRefs(webBrowser)); mWebBrowserChrome->CreateBrowserWindow(aChromeFlags, getter_AddRefs(webBrowser));
NS_ENSURE_TRUE(webBrowser, NS_ERROR_FAILURE); NS_ENSURE_TRUE(webBrowser, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShell> docShell; nsCOMPtr<nsIInterfaceRequestor> webBrowserAsReq(do_QueryInterface(webBrowser));
webBrowser->GetDocShell(getter_AddRefs(docShell)); nsCOMPtr<nsIDocShell> docShell(do_GetInterface(webBrowserAsReq));
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE); NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(CallQueryInterface(docShell, aDocShellTreeItem), NS_ENSURE_SUCCESS(CallQueryInterface(docShell, aDocShellTreeItem),
@ -750,3 +750,4 @@ nsresult nsDocShellTreeOwner::MouseOut(nsIDOMEvent* aMouseEvent)
{ {
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -33,11 +33,20 @@ interface nsICommandHandlerInit : nsISupports
[scriptable, uuid(34A4FCF0-66FC-11d4-9528-0020183BF181)] [scriptable, uuid(34A4FCF0-66FC-11d4-9528-0020183BF181)]
interface nsICommandHandler : nsISupports interface nsICommandHandler : nsISupports
{ {
void exec(in string aCommand, in string aStatus); /*
void query(in string aCommand, in string aStatus, [retval] out string aResult); * Execute the specified command with the specified parameters and return
* the result to the caller. The format of the command, parameters and
* the result are determined by the acutal implementation.
*/
string exec(in string aCommand, in string aParameters);
/*
* Query the status of the specified command with the specified parameters
* and return the result to the caller. The format of the command,
* parameters and the result are determined by the implementation.
*/
string query(in string aCommand, in string aParameters);
}; };
%{ C++ %{ C++
// {3A449110-66FD-11d4-9528-0020183BF181} - // {3A449110-66FD-11d4-9528-0020183BF181} -
#define NS_COMMANDHANDLER_CID \ #define NS_COMMANDHANDLER_CID \

Просмотреть файл

@ -22,7 +22,6 @@
#include "nsISupports.idl" #include "nsISupports.idl"
interface nsIDocShell;
interface nsIInterfaceRequestor; interface nsIInterfaceRequestor;
interface nsIWebBrowserChrome; interface nsIWebBrowserChrome;
interface nsIURIContentListener; interface nsIURIContentListener;
@ -75,17 +74,11 @@ interface nsIWebBrowser : nsISupports
window. That therefore means that when the topLevelWindow goes away, it window. That therefore means that when the topLevelWindow goes away, it
must set topLevelWindow to nsnull. must set topLevelWindow to nsnull.
*/ */
attribute nsIWebBrowserChrome topLevelWindow; attribute nsIWebBrowserChrome containerWindow;
/* /*
URI content listener parent. This is not refcounted and is assumed to be URI content listener parent. This is not refcounted and is assumed to be
nulled out by the parent when the parent is going away. nulled out by the parent when the parent is going away.
*/ */
attribute nsIURIContentListener parentURIContentListener; attribute nsIURIContentListener parentURIContentListener;
/*
The root docShell of the browserWindow.
*/
readonly attribute nsIDocShell docShell;
}; };

Просмотреть файл

@ -32,23 +32,16 @@ interface nsIDocShellTreeItem;
[scriptable, uuid(BA434C60-9D52-11d3-AFB0-00A024FFC08C)] [scriptable, uuid(BA434C60-9D52-11d3-AFB0-00A024FFC08C)]
interface nsIWebBrowserChrome : nsISupports interface nsIWebBrowserChrome : nsISupports
{ {
/* const unsigned long STATUS_SCRIPT = 0x00000001;
Called when the js status value changes. nsnull will be passed when const unsigned long STATUS_SCRIPT_DEFAULT = 0x00000002;
there is no longer any js Status. const unsigned long STATUS_LINK = 0x00000003;
*/
void setJSStatus(in wstring status);
/* /*
Called when the js default status value changes. nsnull will be passed Called when the status text in the chrome needs to be updated.
when there is no longer any js default status. The statusType indicates what is setting the text, the text is nsnull
*/ when there is no longer any status
void setJSDefaultStatus(in wstring status); */
void setStatus(in unsigned long statusType, in wstring status);
/*
Called when the current link the mouse is over changes. nsnull will
be passed when the mouse is no longer over a link.
*/
void setOverLink(in wstring link);
/* /*
This is the currently loaded webBrowser. The browser chrome may be This is the currently loaded webBrowser. The browser chrome may be
@ -63,33 +56,35 @@ interface nsIWebBrowserChrome : nsISupports
/* /*
Definitions for the chrome masks Definitions for the chrome masks
*/ */
const unsigned long defaultChrome = 0x00000001; const unsigned long CHROME_DEFAULT = 0x00000001;
const unsigned long windowBordersOn = 0x00000002; const unsigned long CHROME_WINDOW_BORDERS = 0x00000002;
const unsigned long windowCloseOn = 0x00000004; const unsigned long CHROME_WINDOW_CLOSE = 0x00000004;
const unsigned long windowResizeOn = 0x00000008; const unsigned long CHROME_WINDOW_RESIZE = 0x00000008;
const unsigned long menuBarOn = 0x00000010; const unsigned long CHROME_MENUBAR = 0x00000010;
const unsigned long toolBarOn = 0x00000020; const unsigned long CHROME_TOOLBAR = 0x00000020;
const unsigned long locationBarOn = 0x00000040; const unsigned long CHROME_LOCATIONBAR = 0x00000040;
const unsigned long statusBarOn = 0x00000080; const unsigned long CHROME_STATUSBAR = 0x00000080;
const unsigned long personalToolBarOn = 0x00000100; const unsigned long CHROME_PERSONAL_TOOLBAR = 0x00000100;
const unsigned long scrollbarsOn = 0x00000200; const unsigned long CHROME_SCROLLBARS = 0x00000200;
const unsigned long titlebarOn = 0x00000400; const unsigned long CHROME_TITLEBAR = 0x00000400;
const unsigned long extraChromeOn = 0x00000800; const unsigned long CHROME_EXTRA = 0x00000800;
const unsigned long windowRaised = 0x02000000; const unsigned long CHROME_WINDOW_RAISED = 0x02000000;
const unsigned long windowLowered = 0x04000000; const unsigned long CHROME_WINDOW_LOWERED = 0x04000000;
const unsigned long centerScreen = 0x08000000; const unsigned long CHROME_CENTER_SCREEN = 0x08000000;
const unsigned long dependent = 0x10000000; const unsigned long CHROME_DEPENDENT = 0x10000000;
const unsigned long modal = 0x20000000; // Note: The modal style bit just affects the way the window looks and does
const unsigned long openAsDialog = 0x40000000; // mean it's actually modal.
const unsigned long openAsChrome = 0x80000000; const unsigned long CHROME_MODAL = 0x20000000;
const unsigned long CHROME_OPENAS_DIALOG = 0x40000000;
const unsigned long CHROME_OPENAS_CHROME = 0x80000000;
const unsigned long allChrome = 0x00000ffe; const unsigned long CHROME_ALL = 0x00000ffe;
/* /*
The chrome mask for this browser chrome The chrome flags for this browser chrome
*/ */
attribute unsigned long chromeMask; attribute unsigned long chromeFlags;
/* /*
Tells the implementer of this interface to create a new webBrowserChrome Tells the implementer of this interface to create a new webBrowserChrome
@ -101,7 +96,8 @@ interface nsIWebBrowserChrome : nsISupports
setWebBrowser will be called with the new widget to instantiate in this setWebBrowser will be called with the new widget to instantiate in this
new window. new window.
*/ */
nsIWebBrowser getNewBrowser(in unsigned long chromeMask);
nsIWebBrowser createBrowserWindow(in unsigned long chromeFlags);
/* /*

Просмотреть файл

@ -0,0 +1,36 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications, Inc. Portions created by Netscape are
* Copyright (C) 1999, Mozilla. All Rights Reserved.
*
* Contributor(s):
* Travis Bogard <travis@netscape.com>
*/
#include "nsISupports.idl"
#include "nsIEnumerator.idl"
/**
* The nsIWebBrowserSetup
*/
[scriptable, uuid(F15398A0-8018-11d3-AF70-00A024FFC08C)]
interface nsIWebBrowserSetup : nsISupports
{
const unsigned long SETUP_ALLOW_PLUGINS = 1;
void setProperty(in unsigned long aId, in unsigned long aValue);
};

Просмотреть файл

@ -145,7 +145,7 @@ NS_IMETHODIMP nsWebBrowser::RemoveWebBrowserListener(nsIInterfaceRequestor* aLis
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsWebBrowser::GetTopLevelWindow(nsIWebBrowserChrome** aTopWindow) NS_IMETHODIMP nsWebBrowser::GetContainerWindow(nsIWebBrowserChrome** aTopWindow)
{ {
NS_ENSURE_ARG_POINTER(aTopWindow); NS_ENSURE_ARG_POINTER(aTopWindow);
@ -158,7 +158,7 @@ NS_IMETHODIMP nsWebBrowser::GetTopLevelWindow(nsIWebBrowserChrome** aTopWindow)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsWebBrowser::SetTopLevelWindow(nsIWebBrowserChrome* aTopWindow) NS_IMETHODIMP nsWebBrowser::SetContainerWindow(nsIWebBrowserChrome* aTopWindow)
{ {
NS_ENSURE_SUCCESS(EnsureDocShellTreeOwner(), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(EnsureDocShellTreeOwner(), NS_ERROR_FAILURE);
return mDocShellTreeOwner->SetWebBrowserChrome(aTopWindow); return mDocShellTreeOwner->SetWebBrowserChrome(aTopWindow);
@ -181,16 +181,6 @@ NS_IMETHODIMP nsWebBrowser::SetParentURIContentListener(nsIURIContentListener*
return mContentListener->SetParentContentListener(aParentContentListener); return mContentListener->SetParentContentListener(aParentContentListener);
} }
NS_IMETHODIMP nsWebBrowser::GetDocShell(nsIDocShell** aDocShell)
{
NS_ENSURE_ARG_POINTER(aDocShell);
*aDocShell = mDocShell;
NS_IF_ADDREF(*aDocShell);
return NS_OK;
}
//***************************************************************************** //*****************************************************************************
// nsWebBrowser::nsIDocShellTreeItem // nsWebBrowser::nsIDocShellTreeItem
//***************************************************************************** //*****************************************************************************
@ -322,15 +312,21 @@ NS_IMETHODIMP nsWebBrowser::FindItemWithName(const PRUnichar *aName,
NS_IMETHODIMP nsWebBrowser::GetTreeOwner(nsIDocShellTreeOwner** aTreeOwner) NS_IMETHODIMP nsWebBrowser::GetTreeOwner(nsIDocShellTreeOwner** aTreeOwner)
{ {
NS_ENSURE_ARG_POINTER(aTreeOwner); NS_ENSURE_ARG_POINTER(aTreeOwner);
*aTreeOwner = nsnull;
if(mDocShellTreeOwner) if(mDocShellTreeOwner)
*aTreeOwner = mDocShellTreeOwner->mTreeOwner; {
else if (mDocShellTreeOwner->mTreeOwner)
*aTreeOwner = nsnull; {
*aTreeOwner = mDocShellTreeOwner->mTreeOwner;
NS_IF_ADDREF(*aTreeOwner); }
return NS_OK; else
{
*aTreeOwner = mDocShellTreeOwner;
}
}
NS_IF_ADDREF(*aTreeOwner);
return NS_OK;
} }
NS_IMETHODIMP nsWebBrowser::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner) NS_IMETHODIMP nsWebBrowser::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner)
@ -411,20 +407,6 @@ NS_IMETHODIMP nsWebBrowser::Stop()
return mDocShellAsNav->Stop(); return mDocShellAsNav->Stop();
} }
NS_IMETHODIMP nsWebBrowser::SetDocument(nsIDOMDocument* aDocument,
const PRUnichar* aContentType)
{
NS_ENSURE_STATE(mDocShell);
return mDocShellAsNav->SetDocument(aDocument, aContentType);
}
NS_IMETHODIMP nsWebBrowser::GetDocument(nsIDOMDocument** aDocument)
{
NS_ENSURE_STATE(mDocShell);
return mDocShellAsNav->GetDocument(aDocument);
}
NS_IMETHODIMP nsWebBrowser::GetCurrentURI(PRUnichar** aCurrentURI) NS_IMETHODIMP nsWebBrowser::GetCurrentURI(PRUnichar** aCurrentURI)
{ {
NS_ENSURE_STATE(mDocShell); NS_ENSURE_STATE(mDocShell);
@ -455,6 +437,38 @@ NS_IMETHODIMP nsWebBrowser::GetSessionHistory(nsISHistory** aSessionHistory)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsWebBrowser::GetDocument(nsIDOMDocument** aDocument)
{
NS_ENSURE_STATE(mDocShell);
return mDocShellAsNav->GetDocument(aDocument);
}
//*****************************************************************************
// nsWebBrowser::nsIWebBrowserSetup
//*****************************************************************************
/* void setProperty (in unsigned long aId, in unsigned long aValue); */
NS_IMETHODIMP nsWebBrowser::SetProperty(PRUint32 aId, PRUint32 aValue)
{
switch (aId)
{
case nsIWebBrowserSetup::SETUP_ALLOW_PLUGINS:
{
NS_ENSURE_STATE(mDocShell);
NS_ENSURE_TRUE((aValue == PR_TRUE || aValue == PR_FALSE), NS_ERROR_INVALID_ARG);
mDocShell->SetAllowPlugins(aValue);
}
default:
return NS_ERROR_INVALID_ARG;
}
return NS_OK;
}
//***************************************************************************** //*****************************************************************************
// nsWebBrowser::nsIWebProgress // nsWebBrowser::nsIWebProgress
//***************************************************************************** //*****************************************************************************
@ -473,41 +487,6 @@ NS_IMETHODIMP nsWebBrowser::RemoveProgressListener(nsIWebProgressListener* aList
return mDocShellAsProgress->RemoveProgressListener(aListener); return mDocShellAsProgress->RemoveProgressListener(aListener);
} }
NS_IMETHODIMP nsWebBrowser::GetProgressStatusFlags(PRInt32* aProgressStatusFlags)
{
NS_ENSURE_STATE(mDocShell);
return mDocShellAsProgress->GetProgressStatusFlags(aProgressStatusFlags);
}
NS_IMETHODIMP nsWebBrowser::GetCurSelfProgress(PRInt32* aCurSelfProgress)
{
NS_ENSURE_STATE(mDocShell);
return mDocShellAsProgress->GetCurSelfProgress(aCurSelfProgress);
}
NS_IMETHODIMP nsWebBrowser::GetMaxSelfProgress(PRInt32* aMaxSelfProgress)
{
NS_ENSURE_STATE(mDocShell);
return mDocShellAsProgress->GetMaxSelfProgress(aMaxSelfProgress);
}
NS_IMETHODIMP nsWebBrowser::GetCurTotalProgress(PRInt32* aCurTotalProgress)
{
NS_ENSURE_STATE(mDocShell);
return mDocShellAsProgress->GetCurTotalProgress(aCurTotalProgress);
}
NS_IMETHODIMP nsWebBrowser::GetMaxTotalProgress(PRInt32* aMaxTotalProgress)
{
NS_ENSURE_STATE(mDocShell);
return mDocShellAsProgress->GetMaxTotalProgress(aMaxTotalProgress);
}
//***************************************************************************** //*****************************************************************************
// nsWebBrowser::nsIBaseWindow // nsWebBrowser::nsIBaseWindow
//***************************************************************************** //*****************************************************************************

Просмотреть файл

@ -45,6 +45,7 @@
#include "nsIWebBrowser.h" #include "nsIWebBrowser.h"
#include "nsIWebNavigation.h" #include "nsIWebNavigation.h"
#include "nsIWebProgress.h" #include "nsIWebProgress.h"
#include "nsIWebBrowserSetup.h"
class nsWebBrowserInitInfo class nsWebBrowserInitInfo
{ {
@ -63,6 +64,7 @@ public:
class nsWebBrowser : public nsIWebBrowser, class nsWebBrowser : public nsIWebBrowser,
public nsIWebNavigation, public nsIWebNavigation,
public nsIWebProgress, public nsIWebProgress,
public nsIWebBrowserSetup,
public nsIDocShellTreeItem, public nsIDocShellTreeItem,
public nsIBaseWindow, public nsIBaseWindow,
public nsIScrollable, public nsIScrollable,
@ -84,6 +86,7 @@ public:
NS_DECL_NSIWEBBROWSER NS_DECL_NSIWEBBROWSER
NS_DECL_NSIWEBNAVIGATION NS_DECL_NSIWEBNAVIGATION
NS_DECL_NSIWEBPROGRESS NS_DECL_NSIWEBPROGRESS
NS_DECL_NSIWEBBROWSERSETUP
protected: protected:
virtual ~nsWebBrowser(); virtual ~nsWebBrowser();

Просмотреть файл

@ -1,170 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Doug Turner <dougt@netscape.com>
*/
#include "WebBrowser.h"
#include "nsCWebBrowser.h"
#include "nsWidgetsCID.h"
#include "nsIGenericFactory.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsIURI.h"
#include "nsIWebProgress.h"
#include "nsIWebNavigation.h"
#include "nsIDocShell.h"
#include "nsIContentViewer.h"
#include "nsIContentViewerFile.h"
#include "nsIDocShell.h"
#include "nsIWebNavigation.h"
#include "nsIEditorShell.h"
#include "nsIDOMWindow.h"
#include "nsIScriptGlobalObject.h"
#include "nsIInterfaceRequestor.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeOwner.h"
nsresult
ConvertDocShellToDOMWindow(nsIDocShell* aDocShell, nsIDOMWindow** aDOMWindow)
{
if (!aDOMWindow)
return NS_ERROR_FAILURE;
*aDOMWindow = nsnull;
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject(do_GetInterface(aDocShell));
nsCOMPtr<nsIDOMWindow> domWindow(do_QueryInterface(scriptGlobalObject));
if (!domWindow)
return NS_ERROR_FAILURE;
*aDOMWindow = domWindow.get();
NS_ADDREF(*aDOMWindow);
return NS_OK;
}
WebBrowser::WebBrowser(){}
WebBrowser::~WebBrowser()
{
PRBool duh;
if (mEditor) // not good place for it!
mEditor->SaveDocument(PR_FALSE, PR_FALSE, &duh);
}
nsresult
WebBrowser::Init(nsNativeWidget widget, nsIWebBrowserChrome* aTopWindow)
{
nsresult rv;
mWebBrowser = do_CreateInstance(NS_WEBBROWSER_PROGID, &rv);
if (!mWebBrowser)
return NS_ERROR_FAILURE;
mBaseWindow = do_QueryInterface(mWebBrowser);
mTopWindow = aTopWindow;
mWebBrowser->SetTopLevelWindow(aTopWindow);
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(mWebBrowser);
dsti->SetItemType(nsIDocShellTreeItem::typeChromeWrapper);
rv = mBaseWindow->InitWindow( widget,
nsnull,
0,
0,
100,
100);
mBaseWindow->Create();
mBaseWindow->SetVisibility(PR_TRUE);
return rv;
}
nsresult
WebBrowser::GetWebBrowser(nsIWebBrowser **outBrowser)
{
*outBrowser = mWebBrowser;
NS_IF_ADDREF(*outBrowser);
return NS_OK;
}
nsresult
WebBrowser::GoTo(char* url)
{
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mWebBrowser));
return webNav->LoadURI(NS_ConvertASCIItoUCS2(url).GetUnicode());
}
nsresult
WebBrowser::Edit(char* url)
{
nsresult rv;
mEditor = do_CreateInstance("component://netscape/editor/editorshell", &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr <nsIDocShell> rootDocShell;
mWebBrowser->GetDocShell(getter_AddRefs(rootDocShell));
nsCOMPtr<nsIDOMWindow> domWindow;
ConvertDocShellToDOMWindow(rootDocShell, getter_AddRefs(domWindow));
mEditor->Init();
mEditor->SetEditorType(NS_ConvertASCIItoUCS2("html").GetUnicode());
mEditor->SetWebShellWindow(domWindow);
mEditor->SetContentWindow(domWindow);
return mEditor->LoadUrl(NS_ConvertASCIItoUCS2(url).GetUnicode());
}
nsresult
WebBrowser::Print(void)
{
nsCOMPtr <nsIDocShell> rootDocShell;
mWebBrowser->GetDocShell(getter_AddRefs(rootDocShell));
nsIContentViewer *pContentViewer = nsnull;
nsresult res = rootDocShell->GetContentViewer(&pContentViewer);
if (NS_SUCCEEDED(res))
{
nsCOMPtr<nsIContentViewerFile> spContentViewerFile = do_QueryInterface(pContentViewer);
spContentViewerFile->Print(PR_TRUE, nsnull);
NS_RELEASE(pContentViewer);
}
return NS_OK;
}
nsresult
WebBrowser::SetPositionAndSize(int x, int y, int cx, int cy)
{
return mBaseWindow->SetPositionAndSize(x, y, cx, cy, PR_TRUE);
}

Просмотреть файл

@ -75,17 +75,7 @@ NS_IMETHODIMP WebBrowserChrome::GetInterface(const nsIID &aIID, void** aInstance
// WebBrowserChrome::nsIWebBrowserChrome // WebBrowserChrome::nsIWebBrowserChrome
//***************************************************************************** //*****************************************************************************
NS_IMETHODIMP WebBrowserChrome::SetJSStatus(const PRUnichar* aStatus) NS_IMETHODIMP WebBrowserChrome::SetStatus(PRUint32 aType, const PRUnichar* aStatus)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::SetJSDefaultStatus(const PRUnichar* aStatus)
{
return NS_OK;
}
NS_IMETHODIMP WebBrowserChrome::SetOverLink(const PRUnichar* aLink)
{ {
return NS_OK; return NS_OK;
} }
@ -109,13 +99,13 @@ NS_IMETHODIMP WebBrowserChrome::SetWebBrowser(nsIWebBrowser* aWebBrowser)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP WebBrowserChrome::GetChromeMask(PRUint32* aChromeMask) NS_IMETHODIMP WebBrowserChrome::GetChromeFlags(PRUint32* aChromeMask)
{ {
NS_ERROR("Haven't Implemented this yet"); NS_ERROR("Haven't Implemented this yet");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP WebBrowserChrome::SetChromeMask(PRUint32 aChromeMask) NS_IMETHODIMP WebBrowserChrome::SetChromeFlags(PRUint32 aChromeMask)
{ {
NS_ERROR("Haven't Implemented this yet"); NS_ERROR("Haven't Implemented this yet");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -125,7 +115,7 @@ NS_IMETHODIMP WebBrowserChrome::SetChromeMask(PRUint32 aChromeMask)
// in winEmbed.cpp // in winEmbed.cpp
extern nativeWindow CreateNativeWindow(nsIWebBrowserChrome* chrome); extern nativeWindow CreateNativeWindow(nsIWebBrowserChrome* chrome);
NS_IMETHODIMP WebBrowserChrome::GetNewBrowser(PRUint32 chromeMask, nsIWebBrowser **aWebBrowser) NS_IMETHODIMP WebBrowserChrome::CreateBrowserWindow(PRUint32 chromeMask, nsIWebBrowser **aWebBrowser)
{ {
NS_ENSURE_ARG_POINTER(aWebBrowser); NS_ENSURE_ARG_POINTER(aWebBrowser);
*aWebBrowser = nsnull; *aWebBrowser = nsnull;
@ -135,7 +125,7 @@ NS_IMETHODIMP WebBrowserChrome::GetNewBrowser(PRUint32 chromeMask, nsIWebBrowser
if (!mWebBrowser) if (!mWebBrowser)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
mWebBrowser->SetTopLevelWindow(NS_STATIC_CAST(nsIWebBrowserChrome*, this)); mWebBrowser->SetContainerWindow(NS_STATIC_CAST(nsIWebBrowserChrome*, this));
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(mWebBrowser); nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(mWebBrowser);
dsti->SetItemType(nsIDocShellTreeItem::typeChromeWrapper); dsti->SetItemType(nsIDocShellTreeItem::typeChromeWrapper);
@ -221,7 +211,7 @@ NS_IMETHODIMP WebBrowserChrome::OnStateChange(nsIWebProgress *progress, nsIReque
PRInt32 progressStateFlags, PRUint32 status) PRInt32 progressStateFlags, PRUint32 status)
{ {
if ((progressStateFlags & flag_stop) && (progressStateFlags & flag_is_request)) if ((progressStateFlags & STATE_STOP) && (progressStateFlags & STATE_IS_REQUEST))
{ {
} }
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;

Просмотреть файл

@ -88,7 +88,7 @@ nsresult OpenWebPage(char* url)
NS_ADDREF(chrome); // native window will hold the addref. NS_ADDREF(chrome); // native window will hold the addref.
nsCOMPtr<nsIWebBrowser> newBrowser; nsCOMPtr<nsIWebBrowser> newBrowser;
chrome->GetNewBrowser(0, getter_AddRefs(newBrowser)); chrome->CreateBrowserWindow(0, getter_AddRefs(newBrowser));
if (!newBrowser) if (!newBrowser)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -254,9 +254,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
nsCOMPtr<nsIWebBrowser> wb; nsCOMPtr<nsIWebBrowser> wb;
chrome->GetWebBrowser(getter_AddRefs(wb)); chrome->GetWebBrowser(getter_AddRefs(wb));
nsCOMPtr <nsIDocShell> rootDocShell; nsCOMPtr <nsIDocShell> rootDocShell = do_GetInterface(wb);
wb->GetDocShell(getter_AddRefs(rootDocShell));
nsCOMPtr<nsIContentViewer> pContentViewer; nsCOMPtr<nsIContentViewer> pContentViewer;
nsresult res = rootDocShell->GetContentViewer(getter_AddRefs(pContentViewer)); nsresult res = rootDocShell->GetContentViewer(getter_AddRefs(pContentViewer));
@ -276,9 +274,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
nsCOMPtr<nsIWebBrowser> wb; nsCOMPtr<nsIWebBrowser> wb;
chrome->GetWebBrowser(getter_AddRefs(wb)); chrome->GetWebBrowser(getter_AddRefs(wb));
nsCOMPtr <nsIDocShell> rootDocShell; nsCOMPtr <nsIDocShell> rootDocShell = do_GetInterface(wb);
wb->GetDocShell(getter_AddRefs(rootDocShell));
nsCOMPtr<nsIContentViewer> pContentViewer; nsCOMPtr<nsIContentViewer> pContentViewer;
nsresult res = rootDocShell->GetContentViewer(getter_AddRefs(pContentViewer)); nsresult res = rootDocShell->GetContentViewer(getter_AddRefs(pContentViewer));
@ -300,9 +296,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
nsCOMPtr<nsIWebBrowser> wb; nsCOMPtr<nsIWebBrowser> wb;
chrome->GetWebBrowser(getter_AddRefs(wb)); chrome->GetWebBrowser(getter_AddRefs(wb));
nsCOMPtr <nsIDocShell> rootDocShell; nsCOMPtr <nsIDocShell> rootDocShell = do_GetInterface(wb);
wb->GetDocShell(getter_AddRefs(rootDocShell));
nsCOMPtr<nsIContentViewer> pContentViewer; nsCOMPtr<nsIContentViewer> pContentViewer;
nsresult res = rootDocShell->GetContentViewer(getter_AddRefs(pContentViewer)); nsresult res = rootDocShell->GetContentViewer(getter_AddRefs(pContentViewer));

Просмотреть файл

@ -318,8 +318,8 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
#endif #endif
// A Document is starting to load... // A Document is starting to load...
if ((aProgressStateFlags & flag_start) && if ((aProgressStateFlags & STATE_START) &&
(aProgressStateFlags & flag_is_network)) (aProgressStateFlags & STATE_IS_NETWORK))
{ {
// starting to load a webpage // starting to load a webpage
PR_FREEIF(mLastPSMStatus); mLastPSMStatus = nsnull; PR_FREEIF(mLastPSMStatus); mLastPSMStatus = nsnull;
@ -331,8 +331,8 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
} }
// A document has finished loading // A document has finished loading
if ((aProgressStateFlags & flag_stop) && if ((aProgressStateFlags & STATE_STOP) &&
(aProgressStateFlags & flag_is_network) && (aProgressStateFlags & STATE_IS_NETWORK) &&
mIsSecureDocument) mIsSecureDocument)
{ {
if (!mIsDocumentBroken) // and status is okay FIX if (!mIsDocumentBroken) // and status is okay FIX
@ -413,15 +413,15 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
return NS_OK; return NS_OK;
// A URL is starting to load... // A URL is starting to load...
if ((aProgressStateFlags & flag_start) && if ((aProgressStateFlags & STATE_START) &&
(aProgressStateFlags & flag_is_network)) (aProgressStateFlags & STATE_IS_NETWORK))
{ // check to see if we are going to mix content. { // check to see if we are going to mix content.
return CheckMixedContext(loadingURI); return CheckMixedContext(loadingURI);
} }
// A URL has finished loading... // A URL has finished loading...
if ((aProgressStateFlags & flag_stop) && if ((aProgressStateFlags & STATE_STOP) &&
(aProgressStateFlags & flag_is_network)) (aProgressStateFlags & STATE_IS_NETWORK))
{ {
if (1) // FIX status from the flag... if (1) // FIX status from the flag...
{ {

Просмотреть файл

@ -1761,7 +1761,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const char *aStatusMsg)
if(browserChrome) if(browserChrome)
{ {
nsAutoString msg; msg.AssignWithConversion(aStatusMsg); nsAutoString msg; msg.AssignWithConversion(aStatusMsg);
browserChrome->SetJSStatus(msg.GetUnicode()); browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_SCRIPT, msg.GetUnicode());
} }
} }
} }

Просмотреть файл

@ -1761,7 +1761,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const char *aStatusMsg)
if(browserChrome) if(browserChrome)
{ {
nsAutoString msg; msg.AssignWithConversion(aStatusMsg); nsAutoString msg; msg.AssignWithConversion(aStatusMsg);
browserChrome->SetJSStatus(msg.GetUnicode()); browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_SCRIPT, msg.GetUnicode());
} }
} }
} }

Просмотреть файл

@ -369,7 +369,7 @@ nsMathMLmactionFrame::ShowStatus(nsIPresContext* aPresContext,
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(treeOwner)); nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(treeOwner));
if(browserChrome) if(browserChrome)
browserChrome->SetJSStatus(aStatusMsg.GetUnicode()); browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_SCRIPT, aStatusMsg.GetUnicode());
} }
} }
} }

Просмотреть файл

@ -113,9 +113,9 @@ nsMsgStatusFeedback::OnStateChange(nsIWebProgress* aWebProgress,
nsresult aStatus) nsresult aStatus)
{ {
nsresult rv; nsresult rv;
if (aProgressStateFlags & flag_is_network) if (aProgressStateFlags & STATE_IS_NETWORK)
{ {
if (aProgressStateFlags & flag_start) if (aProgressStateFlags & STATE_START)
{ {
m_lastPercent = 0; m_lastPercent = 0;
StartMeteors(); StartMeteors();
@ -125,7 +125,7 @@ nsMsgStatusFeedback::OnStateChange(nsIWebProgress* aWebProgress,
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
ShowStatusString(loadingDocument); ShowStatusString(loadingDocument);
} }
else if (aProgressStateFlags & flag_stop) else if (aProgressStateFlags & STATE_STOP)
{ {
StopMeteors(); StopMeteors();
nsXPIDLString documentDone; nsXPIDLString documentDone;

Просмотреть файл

@ -883,7 +883,7 @@ NS_IMETHODIMP pluginInstanceOwner :: ShowStatus(const char *aStatusMsg)
if(browserChrome) if(browserChrome)
{ {
nsAutoString msg; msg.AssignWithConversion(aStatusMsg); nsAutoString msg; msg.AssignWithConversion(aStatusMsg);
browserChrome->SetJSStatus(msg.GetUnicode()); browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_SCRIPT, msg.GetUnicode());
} }
} }
} }

Просмотреть файл

@ -883,7 +883,7 @@ NS_IMETHODIMP pluginInstanceOwner :: ShowStatus(const char *aStatusMsg)
if(browserChrome) if(browserChrome)
{ {
nsAutoString msg; msg.AssignWithConversion(aStatusMsg); nsAutoString msg; msg.AssignWithConversion(aStatusMsg);
browserChrome->SetJSStatus(msg.GetUnicode()); browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_SCRIPT, msg.GetUnicode());
} }
} }
} }

Просмотреть файл

@ -69,7 +69,7 @@
#include "nsIPlatformCharset.h" #include "nsIPlatformCharset.h"
#undef NS_IMPL_IDS #undef NS_IMPL_IDS
#define CHROME_STYLE nsIWebBrowserChrome::allChrome | nsIWebBrowserChrome::centerScreen #define CHROME_STYLE nsIWebBrowserChrome::CHROME_ALL | nsIWebBrowserChrome::CHROME_CENTER_SCREEN
/* Network */ /* Network */

Просмотреть файл

@ -105,9 +105,9 @@
#define SHRIMP_PREF "shrimp.startup.enable" #define SHRIMP_PREF "shrimp.startup.enable"
#if defined (XP_MAC) #if defined (XP_MAC)
#define CHROME_STYLE nsIWebBrowserChrome::windowBordersOn | nsIWebBrowserChrome::windowCloseOn | nsIWebBrowserChrome::centerScreen #define CHROME_STYLE nsIWebBrowserChrome::CHROME_WINDOW_BORDERS | nsIWebBrowserChrome::CHROME_WINDOW_CLOSE | nsIWebBrowserChrome::CHROME_CENTER_SCREEN
#else /* the rest */ #else /* the rest */
#define CHROME_STYLE nsIWebBrowserChrome::allChrome | nsIWebBrowserChrome::centerScreen #define CHROME_STYLE nsIWebBrowserChrome::CHROME_ALL | nsIWebBrowserChrome::CHROME_CENTER_SCREEN
#endif #endif
// we want everyone to have the debugging info to the console for now // we want everyone to have the debugging info to the console for now

Просмотреть файл

@ -479,7 +479,7 @@ nsDocLoaderImpl::OnStartRequest(nsIChannel *aChannel, nsISupports *aCtxt)
mLoadGroup->SetDefaultLoadChannel(mDocumentChannel); mLoadGroup->SetDefaultLoadChannel(mDocumentChannel);
// Update the progress status state // Update the progress status state
mProgressStateFlags = nsIWebProgressListener::flag_start; mProgressStateFlags = nsIWebProgressListener::STATE_START;
doStartDocumentLoad(); doStartDocumentLoad();
FireOnStartDocumentLoad(this, aChannel); FireOnStartDocumentLoad(this, aChannel);
@ -592,7 +592,7 @@ void nsDocLoaderImpl::DocLoaderIsEmpty(nsresult aStatus)
mIsLoadingDocument = PR_FALSE; mIsLoadingDocument = PR_FALSE;
// Update the progress status state - the document is done // Update the progress status state - the document is done
mProgressStateFlags = nsIWebProgressListener::flag_stop; mProgressStateFlags = nsIWebProgressListener::STATE_STOP;
// //
// New code to break the circular reference between // New code to break the circular reference between
@ -628,15 +628,15 @@ void nsDocLoaderImpl::doStartDocumentLoad(void)
this, (const char *) buffer)); this, (const char *) buffer));
#endif /* DEBUG */ #endif /* DEBUG */
// Fire an OnStatus(...) notification flag_net_start. This indicates // Fire an OnStatus(...) notification STATE_START. This indicates
// that the document represented by mDocumentChannel has started to // that the document represented by mDocumentChannel has started to
// load... // load...
FireOnStateChange(this, FireOnStateChange(this,
mDocumentChannel, mDocumentChannel,
nsIWebProgressListener::flag_start | nsIWebProgressListener::STATE_START |
nsIWebProgressListener::flag_is_document | nsIWebProgressListener::STATE_IS_DOCUMENT |
nsIWebProgressListener::flag_is_request | nsIWebProgressListener::STATE_IS_REQUEST |
nsIWebProgressListener::flag_is_network, nsIWebProgressListener::STATE_IS_NETWORK,
NS_OK); NS_OK);
} }
@ -654,8 +654,8 @@ void nsDocLoaderImpl::doStartURLLoad(nsIChannel *aChannel)
FireOnStateChange(this, FireOnStateChange(this,
aChannel, aChannel,
nsIWebProgressListener::flag_start | nsIWebProgressListener::STATE_START |
nsIWebProgressListener::flag_is_request, nsIWebProgressListener::STATE_IS_REQUEST,
NS_OK); NS_OK);
} }
@ -673,8 +673,8 @@ void nsDocLoaderImpl::doStopURLLoad(nsIChannel *aChannel, nsresult aStatus)
FireOnStateChange(this, FireOnStateChange(this,
aChannel, aChannel,
nsIWebProgressListener::flag_stop | nsIWebProgressListener::STATE_STOP |
nsIWebProgressListener::flag_is_request, nsIWebProgressListener::STATE_IS_REQUEST,
aStatus); aStatus);
} }
@ -697,9 +697,9 @@ void nsDocLoaderImpl::doStopDocumentLoad(nsIChannel* aChannel,
// //
FireOnStateChange(this, FireOnStateChange(this,
aChannel, aChannel,
nsIWebProgressListener::flag_stop | nsIWebProgressListener::STATE_STOP |
nsIWebProgressListener::flag_is_document | nsIWebProgressListener::STATE_IS_DOCUMENT |
nsIWebProgressListener::flag_is_network, nsIWebProgressListener::STATE_IS_NETWORK,
aStatus); aStatus);
} }
@ -956,33 +956,31 @@ nsDocLoaderImpl::RemoveProgressListener(nsIWebProgressListener *aListener)
return rv; return rv;
} }
NS_IMETHODIMP nsDocLoaderImpl::GetProgressStatusFlags(PRInt32 *aProgressStateFlags) nsresult nsDocLoaderImpl::GetProgressStatusFlags(PRInt32 *aProgressStateFlags)
{ {
*aProgressStateFlags = mProgressStateFlags; *aProgressStateFlags = mProgressStateFlags;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocLoaderImpl::GetCurSelfProgress(PRInt32 *aCurSelfProgress) nsresult nsDocLoaderImpl::GetCurSelfProgress(PRInt32 *aCurSelfProgress)
{ {
*aCurSelfProgress = mCurrentSelfProgress; *aCurSelfProgress = mCurrentSelfProgress;
return NS_OK; return NS_OK;
} }
nsresult nsDocLoaderImpl::GetMaxSelfProgress(PRInt32 *aMaxSelfProgress)
NS_IMETHODIMP nsDocLoaderImpl::GetMaxSelfProgress(PRInt32 *aMaxSelfProgress)
{ {
*aMaxSelfProgress = mMaxSelfProgress; *aMaxSelfProgress = mMaxSelfProgress;
return NS_OK; return NS_OK;
} }
nsresult nsDocLoaderImpl::GetCurTotalProgress(PRInt32 *aCurTotalProgress)
NS_IMETHODIMP nsDocLoaderImpl::GetCurTotalProgress(PRInt32 *aCurTotalProgress)
{ {
*aCurTotalProgress = mCurrentTotalProgress; *aCurTotalProgress = mCurrentTotalProgress;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsDocLoaderImpl::GetMaxTotalProgress(PRInt32 *aMaxTotalProgress) nsresult nsDocLoaderImpl::GetMaxTotalProgress(PRInt32 *aMaxTotalProgress)
{ {
PRUint32 count = 0; PRUint32 count = 0;
nsresult rv = NS_OK; nsresult rv = NS_OK;
@ -1000,8 +998,8 @@ NS_IMETHODIMP nsDocLoaderImpl::GetMaxTotalProgress(PRInt32 *aMaxTotalProgress)
docloader = getter_AddRefs(mChildList->ElementAt(i)); docloader = getter_AddRefs(mChildList->ElementAt(i));
if (docloader) if (docloader)
{ {
webProgress = do_QueryInterface(docloader); // Cast is safe since all children are nsDocLoaderImpl too
webProgress->GetMaxTotalProgress(&invididualProgress); ((nsDocLoaderImpl *) docloader.get())->GetMaxTotalProgress(&invididualProgress);
} }
if (invididualProgress < 0) // if one of the elements doesn't know it's size if (invididualProgress < 0) // if one of the elements doesn't know it's size
// then none of them do // then none of them do
@ -1017,8 +1015,6 @@ NS_IMETHODIMP nsDocLoaderImpl::GetMaxTotalProgress(PRInt32 *aMaxTotalProgress)
} else { } else {
*aMaxTotalProgress = -1; *aMaxTotalProgress = -1;
} }
return NS_OK; return NS_OK;
} }
@ -1054,19 +1050,19 @@ NS_IMETHODIMP nsDocLoaderImpl::OnProgress(nsIChannel* aChannel, nsISupports* ctx
info->mMaxProgress = -1; info->mMaxProgress = -1;
} }
// Send a flag_transferring notification for the request. // Send a STATE_TRANSFERRING notification for the request.
PRInt32 flags; PRInt32 flags;
flags = nsIWebProgressListener::flag_transferring | flags = nsIWebProgressListener::STATE_TRANSFERRING |
nsIWebProgressListener::flag_is_request; nsIWebProgressListener::STATE_IS_REQUEST;
// //
// Move the WebProgress into the flag_transferring state if necessary... // Move the WebProgress into the STATE_TRANSFERRING state if necessary...
// //
if (mProgressStateFlags & nsIWebProgressListener::flag_start) { if (mProgressStateFlags & nsIWebProgressListener::STATE_START) {
mProgressStateFlags = nsIWebProgressListener::flag_transferring; mProgressStateFlags = nsIWebProgressListener::STATE_TRANSFERRING;
// Send flag_transferring for the document too... // Send STATE_TRANSFERRING for the document too...
flags |= nsIWebProgressListener::flag_is_document; flags |= nsIWebProgressListener::STATE_IS_DOCUMENT;
} }
FireOnStateChange(this, aChannel, flags, NS_OK); FireOnStateChange(this, aChannel, flags, NS_OK);
@ -1129,7 +1125,7 @@ void nsDocLoaderImpl::ClearInternalProgress()
mCurrentSelfProgress = mMaxSelfProgress = 0; mCurrentSelfProgress = mMaxSelfProgress = 0;
mCurrentTotalProgress = mMaxTotalProgress = 0; mCurrentTotalProgress = mMaxTotalProgress = 0;
mProgressStateFlags = nsIWebProgressListener::flag_stop; mProgressStateFlags = nsIWebProgressListener::STATE_STOP;
} }
@ -1202,16 +1198,16 @@ void nsDocLoaderImpl::FireOnStateChange(nsIWebProgress *aProgress,
PRInt32 count; PRInt32 count;
// //
// Remove the flag_is_network bit if necessary. // Remove the STATE_IS_NETWORK bit if necessary.
// //
// The rule is to remove this bit, if the notification has been passed // The rule is to remove this bit, if the notification has been passed
// up from a child WebProgress, and the current WebProgress is already // up from a child WebProgress, and the current WebProgress is already
// active... // active...
// //
if (mIsLoadingDocument && if (mIsLoadingDocument &&
(aStateFlags & nsIWebProgressListener::flag_is_network) && (aStateFlags & nsIWebProgressListener::STATE_IS_NETWORK) &&
(this != aProgress)) { (this != aProgress)) {
aStateFlags &= ~nsIWebProgressListener::flag_is_network; aStateFlags &= ~nsIWebProgressListener::STATE_IS_NETWORK;
} }
#if defined(DEBUG) #if defined(DEBUG)

Просмотреть файл

@ -162,6 +162,12 @@ protected:
nsVoidArray mChannelInfoList; nsVoidArray mChannelInfoList;
private: private:
nsresult GetProgressStatusFlags(PRInt32* aProgressStatusFlags);
nsresult GetCurSelfProgress(PRInt32* aCurSelfProgress);
nsresult GetMaxSelfProgress(PRInt32* aMaxSelfProgress);
nsresult GetCurTotalProgress(PRInt32* aCurTotalProgress);
nsresult GetMaxTotalProgress(PRInt32* aMaxTotalProgress);
nsresult AddChannelInfo(nsIChannel *aChannel); nsresult AddChannelInfo(nsIChannel *aChannel);
nsChannelInfo *GetChannelInfo(nsIChannel *aChannel); nsChannelInfo *GetChannelInfo(nsIChannel *aChannel);
nsresult ClearChannelInfoList(void); nsresult ClearChannelInfoList(void);

Просмотреть файл

@ -32,57 +32,6 @@ interface nsIWebProgressListener;
[scriptable, uuid(570F39D0-EFD0-11d3-B093-00A024FFC08C)] [scriptable, uuid(570F39D0-EFD0-11d3-B093-00A024FFC08C)]
interface nsIWebProgress : nsISupports interface nsIWebProgress : nsISupports
{ {
/*
Progress Status Flags. These flags show transition.
Bit Layout:
|31-22|21-20|19-12|11-0|
|11-0| - Network Transitions
|19-12| - Network Stop Reasons
|21-20| - Window Activity Transitions
|31-22| - Available
*/
/* Network Transitions bits |11-0|
flag_net_start - network activity is starting
flag_net_stop - network activity has stopped (this may include a stop
reason which would have the stop reasons bits set)
flag_net_dns - Looking up requested host.
flag_net_connecting - Connecting to requested host.
flag_net_redirecting - Connection is being redirected.
flag_net_negotiating - Negotiating connection to the server
(Authentication/ Authorization).
flag_net_transferring - Transferring data from host.
*/
const long flag_net_start = 0x00000001;
const long flag_net_stop = 0x00000002;
const long flag_net_dns = 0x00000004;
const long flag_net_connecting = 0x00000008;
const long flag_net_redirecting = 0x00000010;
const long flag_net_negotiating = 0x00000020;
const long flag_net_transferring = 0x00000040;
/* Network Stop Reasons bits |19-12|
flag_net_failedDNS - DNS lookup failed.
flag_net_failedConnect - Connecting to server failed.
flag_net_failedTransfer - Transfer failed.
flag_net_failedTimeout - connection timed out
flag_net_userCancelled - User cancelled load.
*/
const long flag_net_failedDNS = 0x00001000;
const long flag_net_failedConnect = 0x00002000;
const long flag_net_failedTransfer = 0x00004000;
const long flag_net_failedTimeout = 0x00008000;
const long flag_net_userCancelled = 0x00010000;
/* Window Activity bits |21-20|
flag_win_start - window activity is starting
flag_win_stop - window activity is stoping
*/
const long flag_win_start = 0x00100000;
const long flag_win_stop = 0x00200000;
/* /*
Registers a listener to be notified of Progress Events Registers a listener to be notified of Progress Events
@ -106,38 +55,4 @@ interface nsIWebProgress : nsISupports
to a previously registered listener. to a previously registered listener.
*/ */
void removeProgressListener(in nsIWebProgressListener listener); void removeProgressListener(in nsIWebProgressListener listener);
/*
Current progress Status of the browser. This will be a combination of the
progress status flags.
*/
readonly attribute long progressStatusFlags;
/*
The current position of progress. This is between 0 and maxSelfProgress.
This is the position of only this progress object. It doesn not include
the progress of all children.
*/
readonly attribute long curSelfProgress;
/*
The maximum position that progress will go to. This sets a relative
position point for the current progress to relate to. This is the max
position of only this progress object. It does not include the progress of
all the children.
*/
readonly attribute long maxSelfProgress;
/*
The current position of progress for this object and all children added
together. This is between 0 and maxTotalProgress.
*/
readonly attribute long curTotalProgress;
/*
The maximum position that progress will go to for the max of this progress
object and all children. This sets the relative position point for the
current progress to relate to.
*/
readonly attribute long maxTotalProgress;
}; };

Просмотреть файл

@ -40,21 +40,22 @@ interface nsIWebProgressListener : nsISupports
* These flags indicate the various states that documents and requests * These flags indicate the various states that documents and requests
* may transition through as they are being loaded. * may transition through as they are being loaded.
*/ */
const long flag_start = 0x00000001; const unsigned long STATE_START = 0x00000001;
const long flag_redirecting = 0x00000002; const unsigned long STATE_REDIRECTING = 0x00000002;
const long flag_transferring = 0x00000004; const unsigned long STATE_TRANSFERRING = 0x00000004;
const long flag_negotiating = 0x00000008; const unsigned long STATE_NEGOTIATING = 0x00000008;
const long flag_stop = 0x00000010; const unsigned long STATE_STOP = 0x00000010;
/** /**
* Progress type bits. * Progress type bits.
* These flags indicate whether the transition is occuring on a document * These flags indicate whether the transition is occuring on a document
* or an individual request within the document. * or an individual request within the document.
*/ */
const long flag_is_request = 0x00010000; const unsigned long STATE_IS_REQUEST = 0x00010000;
const long flag_is_document = 0x00020000; const unsigned long STATE_IS_DOCUMENT = 0x00020000;
const long flag_is_network = 0x00040000; const unsigned long STATE_IS_NETWORK = 0x00040000;
const long flag_is_window = 0x00080000; const unsigned long STATE_IS_WINDOW = 0x00080000;
/** /**
* Notification indicating the state has changed for one of the requests * Notification indicating the state has changed for one of the requests
* associated with the document loaded. * associated with the document loaded.
@ -70,7 +71,7 @@ interface nsIWebProgressListener : nsISupports
*/ */
void onStateChange(in nsIWebProgress aWebProgress, void onStateChange(in nsIWebProgress aWebProgress,
in nsIRequest aRequest, in nsIRequest aRequest,
in long aStateFlags, in long aStateFlags, // XXX TODO unsigned long
in unsigned long aStatus); in unsigned long aStatus);
/** /**

Просмотреть файл

@ -1421,10 +1421,11 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
nsCOMPtr<nsIBaseWindow> webBrowserWin(do_QueryInterface(mWebBrowser)); nsCOMPtr<nsIBaseWindow> webBrowserWin(do_QueryInterface(mWebBrowser));
rv = webBrowserWin->InitWindow(mWindow->GetNativeData(NS_NATIVE_WIDGET), nsnull, r.x, r.y, r.width, r.height); rv = webBrowserWin->InitWindow(mWindow->GetNativeData(NS_NATIVE_WIDGET), nsnull, r.x, r.y, r.width, r.height);
NS_ENSURE_SUCCESS(EnsureWebBrowserChrome(), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(EnsureWebBrowserChrome(), NS_ERROR_FAILURE);
mWebBrowser->SetTopLevelWindow(mWebBrowserChrome); mWebBrowser->SetContainerWindow(mWebBrowserChrome);
webBrowserWin->Create(); webBrowserWin->Create();
mWebBrowser->GetDocShell(&mDocShell); nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mWebBrowser);
mDocShell = docShell;
mDocShell->SetAllowPlugins(aAllowPlugins); mDocShell->SetAllowPlugins(aAllowPlugins);
nsCOMPtr<nsIDocumentLoader> docLoader; nsCOMPtr<nsIDocumentLoader> docLoader;
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell)); nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
@ -1436,7 +1437,7 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
} }
webBrowserWin->SetVisibility(PR_TRUE); webBrowserWin->SetVisibility(PR_TRUE);
if (nsIWebBrowserChrome::menuBarOn & aChromeMask) { if (nsIWebBrowserChrome::CHROME_MENUBAR & aChromeMask) {
rv = CreateMenuBar(r.width); rv = CreateMenuBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
@ -1445,14 +1446,14 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
r.x = r.y = 0; r.x = r.y = 0;
} }
if (nsIWebBrowserChrome::toolBarOn & aChromeMask) { if (nsIWebBrowserChrome::CHROME_TOOLBAR & aChromeMask) {
rv = CreateToolBar(r.width); rv = CreateToolBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
} }
} }
if (nsIWebBrowserChrome::statusBarOn & aChromeMask) { if (nsIWebBrowserChrome::CHROME_STATUSBAR & aChromeMask) {
rv = CreateStatusBar(r.width); rv = CreateStatusBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
@ -1514,7 +1515,7 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
docLoader->AddObserver(this); docLoader->AddObserver(this);
} }
if (nsIWebBrowserChrome::menuBarOn & aChromeMask) { if (nsIWebBrowserChrome::CHROME_MENUBAR & aChromeMask) {
rv = CreateMenuBar(r.width); rv = CreateMenuBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
@ -1523,14 +1524,14 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
r.x = r.y = 0; r.x = r.y = 0;
} }
if (nsIWebBrowserChrome::toolBarOn & aChromeMask) { if (nsIWebBrowserChrome::CHROME_TOOLBAR & aChromeMask) {
rv = CreateToolBar(r.width); rv = CreateToolBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
} }
} }
if (nsIWebBrowserChrome::statusBarOn & aChromeMask) { if (nsIWebBrowserChrome::CHROME_STATUSBAR & aChromeMask) {
rv = CreateStatusBar(r.width); rv = CreateStatusBar(r.width);
if (NS_OK != rv) { if (NS_OK != rv) {
return rv; return rv;
@ -1758,7 +1759,7 @@ nsBrowserWindow::Layout(PRInt32 aWidth, PRInt32 aHeight)
nsRect rr(0, 0, aWidth, aHeight); nsRect rr(0, 0, aWidth, aHeight);
// position location bar (it's stretchy) // position location bar (it's stretchy)
if (nsIWebBrowserChrome::toolBarOn & mChromeMask) { if (nsIWebBrowserChrome::CHROME_TOOLBAR & mChromeMask) {
nsIWidget* locationWidget = nsnull; nsIWidget* locationWidget = nsnull;
if (mLocation && if (mLocation &&
NS_SUCCEEDED(mLocation->QueryInterface(kIWidgetIID, NS_SUCCEEDED(mLocation->QueryInterface(kIWidgetIID,
@ -1825,7 +1826,7 @@ nsBrowserWindow::Layout(PRInt32 aWidth, PRInt32 aHeight)
nsIWidget* statusWidget = nsnull; nsIWidget* statusWidget = nsnull;
if (mStatus && NS_OK == mStatus->QueryInterface(kIWidgetIID,(void**)&statusWidget)) { if (mStatus && NS_OK == mStatus->QueryInterface(kIWidgetIID,(void**)&statusWidget)) {
if (mChromeMask & nsIWebBrowserChrome::statusBarOn) { if (mChromeMask & nsIWebBrowserChrome::CHROME_STATUSBAR) {
statusWidget->Resize(0, aHeight - txtHeight, statusWidget->Resize(0, aHeight - txtHeight,
aWidth, txtHeight, aWidth, txtHeight,
PR_TRUE); PR_TRUE);
@ -1842,7 +1843,7 @@ nsBrowserWindow::Layout(PRInt32 aWidth, PRInt32 aHeight)
// inset the web widget // inset the web widget
if (nsIWebBrowserChrome::toolBarOn & mChromeMask) { if (nsIWebBrowserChrome::CHROME_TOOLBAR & mChromeMask) {
rr.height -= BUTTON_HEIGHT; rr.height -= BUTTON_HEIGHT;
rr.y += BUTTON_HEIGHT; rr.y += BUTTON_HEIGHT;
} }
@ -2443,7 +2444,7 @@ nsBrowserWindow::ShowPrintPreview(PRInt32 aID)
nsBrowserWindow* bw = new nsNativeBrowserWindow; nsBrowserWindow* bw = new nsNativeBrowserWindow;
bw->SetApp(mApp); bw->SetApp(mApp);
bw->Init(mAppShell, nsRect(0, 0, 600, 400), bw->Init(mAppShell, nsRect(0, 0, 600, 400),
nsIWebBrowserChrome::menuBarOn, PR_TRUE, docv, printContext); nsIWebBrowserChrome::CHROME_MENUBAR, PR_TRUE, docv, printContext);
bw->SetVisibility(PR_TRUE); bw->SetVisibility(PR_TRUE);
NS_RELEASE(printContext); NS_RELEASE(printContext);

Просмотреть файл

@ -80,30 +80,21 @@ NS_IMETHODIMP nsWebBrowserChrome::GetInterface(const nsIID &aIID, void** aInstan
//***************************************************************************** //*****************************************************************************
// nsWebBrowserChrome::nsIWebBrowserChrome // nsWebBrowserChrome::nsIWebBrowserChrome
//***************************************************************************** //*****************************************************************************
NS_IMETHODIMP nsWebBrowserChrome::SetStatus(PRUint32 aStatusType, const PRUnichar* aStatus)
NS_IMETHODIMP nsWebBrowserChrome::SetJSStatus(const PRUnichar* aStatus)
{ {
NS_ENSURE_STATE(mBrowserWindow->mStatus); NS_ENSURE_STATE(mBrowserWindow->mStatus);
PRUint32 size; switch (aStatusType)
mBrowserWindow->mStatus->SetText(nsAutoString(aStatus), size); {
case STATUS_SCRIPT:
return NS_OK; case STATUS_LINK:
} {
NS_ENSURE_STATE(mBrowserWindow->mStatus);
NS_IMETHODIMP nsWebBrowserChrome::SetJSDefaultStatus(const PRUnichar* aStatus) PRUint32 size;
{ mBrowserWindow->mStatus->SetText(nsAutoString(aStatus), size);
return NS_OK; }
} break;
}
NS_IMETHODIMP nsWebBrowserChrome::SetOverLink(const PRUnichar* aLink)
{
if(!mBrowserWindow->mStatus)
return NS_OK;
PRUint32 size;
mBrowserWindow->mStatus->SetText(nsAutoString(aLink), size);
return NS_OK; return NS_OK;
} }
@ -119,19 +110,19 @@ NS_IMETHODIMP nsWebBrowserChrome::GetWebBrowser(nsIWebBrowser** aWebBrowser)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP nsWebBrowserChrome::SetChromeMask(PRUint32 aChromeMask) NS_IMETHODIMP nsWebBrowserChrome::SetChromeFlags(PRUint32 aChromeFlags)
{ {
NS_ERROR("Haven't Implemented this yet"); NS_ERROR("Haven't Implemented this yet");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP nsWebBrowserChrome::GetChromeMask(PRUint32* aChromeMask) NS_IMETHODIMP nsWebBrowserChrome::GetChromeFlags(PRUint32* aChromeFlags)
{ {
NS_ERROR("Haven't Implemented this yet"); NS_ERROR("Haven't Implemented this yet");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP nsWebBrowserChrome::GetNewBrowser(PRUint32 aChromeMask, NS_IMETHODIMP nsWebBrowserChrome::CreateBrowserWindow(PRUint32 aChromeMask,
nsIWebBrowser** aWebBrowser) nsIWebBrowser** aWebBrowser)
{ {
if(mBrowserWindow->mWebCrawler && (mBrowserWindow->mWebCrawler->Crawling() || if(mBrowserWindow->mWebCrawler && (mBrowserWindow->mWebCrawler->Crawling() ||
@ -402,18 +393,18 @@ nsWebBrowserChrome::OnStateChange(nsIWebProgress* aProgress,
PRInt32 aProgressStateFlags, PRInt32 aProgressStateFlags,
nsresult aStatus) nsresult aStatus)
{ {
if (aProgressStateFlags & flag_start) { if (aProgressStateFlags & STATE_START) {
if (aProgressStateFlags & flag_is_network) { if (aProgressStateFlags & STATE_IS_NETWORK) {
OnWindowActivityStart(); OnWindowActivityStart();
OnLoadStart(aRequest); OnLoadStart(aRequest);
} }
if (aProgressStateFlags & flag_is_request) { if (aProgressStateFlags & STATE_IS_REQUEST) {
mTotal += 1; mTotal += 1;
} }
} }
if (aProgressStateFlags & flag_stop) { if (aProgressStateFlags & STATE_STOP) {
if (aProgressStateFlags & flag_is_request) { if (aProgressStateFlags & STATE_IS_REQUEST) {
mCurrent += 1; mCurrent += 1;
if(mBrowserWindow->mStatus) { if(mBrowserWindow->mStatus) {
@ -434,13 +425,13 @@ nsWebBrowserChrome::OnStateChange(nsIWebProgress* aProgress,
} }
} }
if (aProgressStateFlags & flag_is_network) { if (aProgressStateFlags & STATE_IS_NETWORK) {
OnLoadFinished(aRequest, aProgressStateFlags); OnLoadFinished(aRequest, aProgressStateFlags);
OnWindowActivityFinished(); OnWindowActivityFinished();
} }
} }
if (aProgressStateFlags & flag_transferring) { if (aProgressStateFlags & STATE_TRANSFERRING) {
OnStatusTransferring(aRequest); OnStatusTransferring(aRequest);
} }

Просмотреть файл

@ -189,7 +189,7 @@ nsAppShellService::CreateHiddenWindow()
PRInt32 initialHeight = 0, initialWidth = 0; PRInt32 initialHeight = 0, initialWidth = 0;
#else #else
const char* hiddenWindowURL = "about:blank"; const char* hiddenWindowURL = "about:blank";
PRUint32 chromeMask = nsIWebBrowserChrome::allChrome; PRUint32 chromeMask = nsIWebBrowserChrome::CHROME_ALL;
PRInt32 initialHeight = 100, initialWidth = 100; PRInt32 initialHeight = 100, initialWidth = 100;
#endif #endif
@ -548,24 +548,24 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent,
else { else {
nsWidgetInitData widgetInitData; nsWidgetInitData widgetInitData;
widgetInitData.mWindowType = aChromeMask & nsIWebBrowserChrome::openAsDialog ? widgetInitData.mWindowType = aChromeMask & nsIWebBrowserChrome::CHROME_OPENAS_DIALOG ?
eWindowType_dialog : eWindowType_toplevel; eWindowType_dialog : eWindowType_toplevel;
// note default chrome overrides other OS chrome settings, but // note default chrome overrides other OS chrome settings, but
// not internal chrome // not internal chrome
if (aChromeMask & nsIWebBrowserChrome::defaultChrome) if (aChromeMask & nsIWebBrowserChrome::CHROME_DEFAULT)
widgetInitData.mBorderStyle = eBorderStyle_default; widgetInitData.mBorderStyle = eBorderStyle_default;
else if ((aChromeMask & nsIWebBrowserChrome::allChrome) == nsIWebBrowserChrome::allChrome) else if ((aChromeMask & nsIWebBrowserChrome::CHROME_ALL) == nsIWebBrowserChrome::CHROME_ALL)
widgetInitData.mBorderStyle = eBorderStyle_all; widgetInitData.mBorderStyle = eBorderStyle_all;
else { else {
widgetInitData.mBorderStyle = eBorderStyle_none; // assumes none == 0x00 widgetInitData.mBorderStyle = eBorderStyle_none; // assumes none == 0x00
if (aChromeMask & nsIWebBrowserChrome::windowBordersOn) if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_BORDERS)
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_border); widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_border);
if (aChromeMask & nsIWebBrowserChrome::titlebarOn) if (aChromeMask & nsIWebBrowserChrome::CHROME_TITLEBAR)
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_title); widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_title);
if (aChromeMask & nsIWebBrowserChrome::windowCloseOn) if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_CLOSE)
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_close); widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_close);
if (aChromeMask & nsIWebBrowserChrome::windowResizeOn) { if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) {
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_resizeh); widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_resizeh);
/* Associate the resize flag with min/max buttons and system menu. /* Associate the resize flag with min/max buttons and system menu.
but not for dialogs. This is logic better associated with the but not for dialogs. This is logic better associated with the
@ -573,18 +573,18 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent,
eBorderStyle_default style. But since I know of no platform eBorderStyle_default style. But since I know of no platform
that wants min/max buttons on dialogs, it works here, too. that wants min/max buttons on dialogs, it works here, too.
If you have such a platform, this is where the fun starts: */ If you have such a platform, this is where the fun starts: */
if (!(aChromeMask & nsIWebBrowserChrome::openAsDialog)) if (!(aChromeMask & nsIWebBrowserChrome::CHROME_OPENAS_DIALOG))
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_minimize | eBorderStyle_maximize | eBorderStyle_menu); widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_minimize | eBorderStyle_maximize | eBorderStyle_menu);
} }
} }
if (aChromeMask & nsIWebBrowserChrome::scrollbarsOn) if (aChromeMask & nsIWebBrowserChrome::CHROME_SCROLLBARS)
contentScrollbars = PR_TRUE; contentScrollbars = PR_TRUE;
zlevel = nsIXULWindow::normalZ; zlevel = nsIXULWindow::normalZ;
if (aChromeMask & nsIWebBrowserChrome::windowRaised) if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RAISED)
zlevel = nsIXULWindow::raisedZ; zlevel = nsIXULWindow::raisedZ;
else if (aChromeMask & nsIWebBrowserChrome::windowLowered) else if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_LOWERED)
zlevel = nsIXULWindow::loweredZ; zlevel = nsIXULWindow::loweredZ;
#ifdef XP_MAC #ifdef XP_MAC
/* Platforms on which modal windows are always application-modal, not /* Platforms on which modal windows are always application-modal, not
@ -596,7 +596,7 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent,
but the Mac, right?) know how to stack dependent windows. On these but the Mac, right?) know how to stack dependent windows. On these
platforms, give the dependent window the same level as its parent, platforms, give the dependent window the same level as its parent,
so we won't try to override the normal platform behaviour. */ so we won't try to override the normal platform behaviour. */
if ((aChromeMask & nsIWebBrowserChrome::dependent) && aParent) if ((aChromeMask & nsIWebBrowserChrome::CHROME_DEPENDENT) && aParent)
aParent->GetZlevel(&zlevel); aParent->GetZlevel(&zlevel);
#endif #endif
@ -629,7 +629,7 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent,
} }
if (aChromeMask & nsIWebBrowserChrome::centerScreen) if (aChromeMask & nsIWebBrowserChrome::CHROME_CENTER_SCREEN)
window->Center(nsnull, PR_TRUE, PR_FALSE); window->Center(nsnull, PR_TRUE, PR_FALSE);
} }

Просмотреть файл

@ -47,7 +47,7 @@ static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
nsContentTreeOwner::nsContentTreeOwner(PRBool fPrimary) : mXULWindow(nsnull), nsContentTreeOwner::nsContentTreeOwner(PRBool fPrimary) : mXULWindow(nsnull),
mPrimary(fPrimary), mContentTitleSetting(PR_FALSE), mPrimary(fPrimary), mContentTitleSetting(PR_FALSE),
mChromeMask(nsIWebBrowserChrome::allChrome) mChromeFlags(nsIWebBrowserChrome::CHROME_ALL)
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
} }
@ -198,25 +198,7 @@ NS_IMETHODIMP nsContentTreeOwner::GetNewWindow(PRInt32 aChromeFlags,
// nsContentTreeOwner::nsIWebBrowserChrome // nsContentTreeOwner::nsIWebBrowserChrome
//***************************************************************************** //*****************************************************************************
NS_IMETHODIMP nsContentTreeOwner::SetJSStatus(const PRUnichar* aStatus) NS_IMETHODIMP nsContentTreeOwner::SetStatus(PRUint32 aStatusType, const PRUnichar* aStatus)
{
nsCOMPtr<nsIDOMWindow> domWindow;
mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWindow));
nsCOMPtr<nsPIDOMWindow> piDOMWindow(do_QueryInterface(domWindow));
if(!piDOMWindow)
return NS_OK;
nsCOMPtr<nsISupports> xpConnectObj;
nsAutoString xulBrowserWinId; xulBrowserWinId.AssignWithConversion("XULBrowserWindow");
piDOMWindow->GetObjectProperty(xulBrowserWinId.GetUnicode(), getter_AddRefs(xpConnectObj));
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow(do_QueryInterface(xpConnectObj));
if(xulBrowserWindow)
xulBrowserWindow->SetJSStatus(aStatus);
return NS_OK;
}
NS_IMETHODIMP nsContentTreeOwner::SetJSDefaultStatus(const PRUnichar* aStatus)
{ {
nsCOMPtr<nsIDOMWindow> domWindow; nsCOMPtr<nsIDOMWindow> domWindow;
mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWindow)); mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWindow));
@ -229,26 +211,22 @@ NS_IMETHODIMP nsContentTreeOwner::SetJSDefaultStatus(const PRUnichar* aStatus)
piDOMWindow->GetObjectProperty(xulBrowserWinId.GetUnicode(), getter_AddRefs(xpConnectObj)); piDOMWindow->GetObjectProperty(xulBrowserWinId.GetUnicode(), getter_AddRefs(xpConnectObj));
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow(do_QueryInterface(xpConnectObj)); nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow(do_QueryInterface(xpConnectObj));
if(xulBrowserWindow) if (xulBrowserWindow)
xulBrowserWindow->SetJSDefaultStatus(aStatus); {
return NS_OK; switch(aStatusType)
} {
case STATUS_SCRIPT:
xulBrowserWindow->SetJSStatus(aStatus);
break;
case STATUS_SCRIPT_DEFAULT:
xulBrowserWindow->SetJSDefaultStatus(aStatus);
break;
case STATUS_LINK:
xulBrowserWindow->SetOverLink(aStatus);
break;
}
}
NS_IMETHODIMP nsContentTreeOwner::SetOverLink(const PRUnichar* aLink)
{
nsCOMPtr<nsIDOMWindow> domWindow;
mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWindow));
nsCOMPtr<nsPIDOMWindow> piDOMWindow(do_QueryInterface(domWindow));
if(!piDOMWindow)
return NS_OK;
nsCOMPtr<nsISupports> xpConnectObj;
nsAutoString xulBrowserWinId; xulBrowserWinId.AssignWithConversion("XULBrowserWindow");
piDOMWindow->GetObjectProperty(xulBrowserWinId.GetUnicode(), getter_AddRefs(xpConnectObj));
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow(do_QueryInterface(xpConnectObj));
if(xulBrowserWindow)
xulBrowserWindow->SetOverLink(aLink);
return NS_OK; return NS_OK;
} }
@ -264,23 +242,23 @@ NS_IMETHODIMP nsContentTreeOwner::GetWebBrowser(nsIWebBrowser** aWebBrowser)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP nsContentTreeOwner::SetChromeMask(PRUint32 aChromeMask) NS_IMETHODIMP nsContentTreeOwner::SetChromeFlags(PRUint32 aChromeFlags)
{ {
mChromeMask = aChromeMask; mChromeFlags = aChromeFlags;
NS_ENSURE_SUCCESS(ApplyChromeMask(), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(ApplyChromeFlags(), NS_ERROR_FAILURE);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsContentTreeOwner::GetChromeMask(PRUint32* aChromeMask) NS_IMETHODIMP nsContentTreeOwner::GetChromeFlags(PRUint32* aChromeFlags)
{ {
NS_ENSURE_ARG_POINTER(aChromeMask); NS_ENSURE_ARG_POINTER(aChromeFlags);
*aChromeMask = mChromeMask; *aChromeFlags = mChromeFlags;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsContentTreeOwner::GetNewBrowser(PRUint32 aChromeFlags, NS_IMETHODIMP nsContentTreeOwner::CreateBrowserWindow(PRUint32 aChromeFlags,
nsIWebBrowser** aWebBrowser) nsIWebBrowser** aWebBrowser)
{ {
NS_ERROR("Haven't Implemented this yet"); NS_ERROR("Haven't Implemented this yet");
@ -567,7 +545,7 @@ NS_IMETHODIMP nsContentTreeOwner::SetTitle(const PRUnichar* aTitle)
// nsContentTreeOwner: Helpers // nsContentTreeOwner: Helpers
//***************************************************************************** //*****************************************************************************
NS_IMETHODIMP nsContentTreeOwner::ApplyChromeMask() NS_IMETHODIMP nsContentTreeOwner::ApplyChromeFlags()
{ {
if(!mXULWindow->mChromeLoaded) if(!mXULWindow->mChromeLoaded)
return NS_OK; // We'll do this later when chrome is loaded return NS_OK; // We'll do this later when chrome is loaded
@ -576,8 +554,8 @@ NS_IMETHODIMP nsContentTreeOwner::ApplyChromeMask()
mXULWindow->GetWindowDOMElement(getter_AddRefs(window)); mXULWindow->GetWindowDOMElement(getter_AddRefs(window));
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE); NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
mXULWindow->mWindow->ShowMenuBar(mChromeMask & mXULWindow->mWindow->ShowMenuBar(mChromeFlags &
nsIWebBrowserChrome::menuBarOn ? nsIWebBrowserChrome::CHROME_MENUBAR ?
PR_TRUE : PR_FALSE); PR_TRUE : PR_FALSE);
// Construct the new value for the 'chromehidden' attribute that // Construct the new value for the 'chromehidden' attribute that
@ -586,22 +564,22 @@ NS_IMETHODIMP nsContentTreeOwner::ApplyChromeMask()
// 'chromehidden' attribute of the <window> tag. // 'chromehidden' attribute of the <window> tag.
nsAutoString newvalue; nsAutoString newvalue;
if (! (mChromeMask & nsIWebBrowserChrome::menuBarOn)) { if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_MENUBAR)) {
newvalue.AppendWithConversion("menubar "); newvalue.AppendWithConversion("menubar ");
} }
if (! (mChromeMask & nsIWebBrowserChrome::toolBarOn)) { if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_TOOLBAR)) {
newvalue.AppendWithConversion("toolbar "); newvalue.AppendWithConversion("toolbar ");
} }
if (! (mChromeMask & nsIWebBrowserChrome::locationBarOn)) { if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_LOCATIONBAR)) {
newvalue.AppendWithConversion("location "); newvalue.AppendWithConversion("location ");
} }
if (! (mChromeMask & nsIWebBrowserChrome::personalToolBarOn)) { if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR)) {
newvalue.AppendWithConversion("directories "); newvalue.AppendWithConversion("directories ");
} }
if (! (mChromeMask & nsIWebBrowserChrome::statusBarOn)) { if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_STATUSBAR)) {
newvalue.AppendWithConversion("status "); newvalue.AppendWithConversion("status ");
} }
if (! (mChromeMask & nsIWebBrowserChrome::extraChromeOn)) { if (! (mChromeFlags & nsIWebBrowserChrome::CHROME_EXTRA)) {
newvalue.AppendWithConversion("extrachrome"); newvalue.AppendWithConversion("extrachrome");
} }

Просмотреть файл

@ -57,13 +57,13 @@ protected:
void XULWindow(nsXULWindow* aXULWindow); void XULWindow(nsXULWindow* aXULWindow);
nsXULWindow* XULWindow(); nsXULWindow* XULWindow();
NS_IMETHOD ApplyChromeMask(); NS_IMETHOD ApplyChromeFlags();
protected: protected:
nsXULWindow* mXULWindow; nsXULWindow* mXULWindow;
PRBool mPrimary; PRBool mPrimary;
PRBool mContentTitleSetting; PRBool mContentTitleSetting;
PRUint32 mChromeMask; PRUint32 mChromeFlags;
nsString mWindowTitleModifier; nsString mWindowTitleModifier;
nsString mTitleSeparator; nsString mTitleSeparator;
nsString mTitlePreface; nsString mTitlePreface;

Просмотреть файл

@ -462,7 +462,7 @@ void nsSpecialFileSpec::operator = (Type aType)
break; break;
case App_ChromeDirectory: case App_ChromeDirectory:
{ {
*this = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_CurrentProcessDirectory); *this = nsSpecialSystemDirectory(nsSpecialSystemDirectory::Moz_BinDirectory);
#ifdef XP_MAC #ifdef XP_MAC
*this += "Chrome"; *this += "Chrome";
#else #else

Просмотреть файл

@ -630,7 +630,7 @@ void nsXULWindow::OnChromeLoaded()
mChromeLoaded = PR_TRUE; mChromeLoaded = PR_TRUE;
if(mContentTreeOwner) if(mContentTreeOwner)
mContentTreeOwner->ApplyChromeMask(); mContentTreeOwner->ApplyChromeFlags();
LoadTitleFromXUL(); LoadTitleFromXUL();
LoadPositionAndSizeFromXUL(PR_TRUE, PR_TRUE); LoadPositionAndSizeFromXUL(PR_TRUE, PR_TRUE);
@ -981,7 +981,7 @@ NS_IMETHODIMP nsXULWindow::GetNewWindow(PRInt32 aChromeFlags,
{ {
NS_ENSURE_ARG_POINTER(aDocShellTreeItem); NS_ENSURE_ARG_POINTER(aDocShellTreeItem);
if(aChromeFlags & nsIWebBrowserChrome::openAsChrome) if(aChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)
return CreateNewChromeWindow(aChromeFlags, aDocShellTreeItem); return CreateNewChromeWindow(aChromeFlags, aDocShellTreeItem);
else else
return CreateNewContentWindow(aChromeFlags, aDocShellTreeItem); return CreateNewContentWindow(aChromeFlags, aDocShellTreeItem);
@ -998,7 +998,7 @@ NS_IMETHODIMP nsXULWindow::CreateNewChromeWindow(PRInt32 aChromeFlags,
// Just do a normal create of a window and return. // Just do a normal create of a window and return.
//XXXTAB remove this when appshell talks in terms of nsIXULWindow //XXXTAB remove this when appshell talks in terms of nsIXULWindow
nsCOMPtr<nsIXULWindow> parent; nsCOMPtr<nsIXULWindow> parent;
if(aChromeFlags & nsIWebBrowserChrome::dependent) if(aChromeFlags & nsIWebBrowserChrome::CHROME_DEPENDENT)
parent = this; parent = this;
nsCOMPtr<nsIXULWindow> newWindow; nsCOMPtr<nsIXULWindow> newWindow;
@ -1011,7 +1011,7 @@ NS_IMETHODIMP nsXULWindow::CreateNewChromeWindow(PRInt32 aChromeFlags,
// XXX Ick, this should be able to go away..... // XXX Ick, this should be able to go away.....
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(newWindow)); nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(newWindow));
if(browserChrome) if(browserChrome)
browserChrome->SetChromeMask(aChromeFlags); browserChrome->SetChromeFlags(aChromeFlags);
nsCOMPtr<nsIDocShell> docShell; nsCOMPtr<nsIDocShell> docShell;
newWindow->GetDocShell(getter_AddRefs(docShell)); newWindow->GetDocShell(getter_AddRefs(docShell));
@ -1072,7 +1072,7 @@ NS_IMETHODIMP nsXULWindow::CreateNewContentWindow(PRInt32 aChromeFlags,
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(newWindow)); nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(newWindow));
if(browserChrome) if(browserChrome)
browserChrome->SetChromeMask(aChromeFlags); browserChrome->SetChromeFlags(aChromeFlags);
nsCOMPtr<nsIAppShell> subShell(do_CreateInstance(kAppShellCID)); nsCOMPtr<nsIAppShell> subShell(do_CreateInstance(kAppShellCID));
NS_ENSURE_TRUE(subShell, NS_ERROR_FAILURE); NS_ENSURE_TRUE(subShell, NS_ERROR_FAILURE);

Просмотреть файл

@ -266,7 +266,7 @@ static nsresult OpenChromeURL( const char * urlstr, PRInt32 height = NS_SIZETOCO
nsCOMPtr<nsIXULWindow> newWindow; nsCOMPtr<nsIXULWindow> newWindow;
rv = appShell->CreateTopLevelWindow(nsnull, url, rv = appShell->CreateTopLevelWindow(nsnull, url,
PR_TRUE, PR_TRUE, nsIWebBrowserChrome::allChrome, PR_TRUE, PR_TRUE, nsIWebBrowserChrome::CHROME_ALL,
width, height, width, height,
getter_AddRefs(newWindow)); getter_AddRefs(newWindow));
return rv; return rv;

Просмотреть файл

@ -42,7 +42,6 @@
#include "nsIWebShell.h" #include "nsIWebShell.h"
#include "nsIMarkupDocumentViewer.h" #include "nsIMarkupDocumentViewer.h"
#include "nsIClipboardCommands.h"
#include "pratom.h" #include "pratom.h"
#include "prprf.h" #include "prprf.h"
#include "nsIComponentManager.h" #include "nsIComponentManager.h"
@ -57,6 +56,8 @@
#include "nsIDOMWindow.h" #include "nsIDOMWindow.h"
#include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObject.h"
#include "nsIContentViewer.h"
#include "nsIContentViewerEdit.h"
#include "nsIWebShell.h" #include "nsIWebShell.h"
#include "nsIDocShell.h" #include "nsIDocShell.h"
#include "nsIWebShellWindow.h" #include "nsIWebShellWindow.h"
@ -1363,25 +1364,25 @@ nsBrowserInstance::Close()
NS_IMETHODIMP NS_IMETHODIMP
nsBrowserInstance::Copy() nsBrowserInstance::Copy()
{ {
nsCOMPtr<nsIPresShell> presShell; nsCOMPtr<nsIContentViewer> viewer;
GetContentAreaDocShell()->GetPresShell(getter_AddRefs(presShell)); GetContentAreaDocShell()->GetContentViewer(getter_AddRefs(viewer));
if (presShell) { nsCOMPtr<nsIContentViewerEdit> edit(do_QueryInterface(viewer));
presShell->DoCopy(); if (edit) {
} edit->CopySelection();
}
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsBrowserInstance::SelectAll() nsBrowserInstance::SelectAll()
{ {
nsresult rv; nsCOMPtr<nsIContentViewer> viewer;
nsCOMPtr<nsIClipboardCommands> clip(do_QueryInterface(GetContentAreaDocShell(),&rv)); GetContentAreaDocShell()->GetContentViewer(getter_AddRefs(viewer));
if ( NS_SUCCEEDED(rv) ) { nsCOMPtr<nsIContentViewerEdit> edit(do_QueryInterface(viewer));
rv = clip->SelectAll(); if (edit) {
} edit->SelectAll();
}
return rv; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -375,15 +375,6 @@ nsSHistory::Stop()
} }
NS_IMETHODIMP
nsSHistory::SetDocument(nsIDOMDocument* aDocument,
const PRUnichar* aContentType)
{
// Not implemented
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsSHistory::GetDocument(nsIDOMDocument** aDocument) nsSHistory::GetDocument(nsIDOMDocument** aDocument)
{ {

Просмотреть файл

@ -59,7 +59,7 @@ static nsresult DisplayURI(const char *urlStr, PRBool block)
URL, URL,
PR_TRUE, PR_TRUE,
PR_TRUE, PR_TRUE,
nsIWebBrowserChrome::allChrome, nsIWebBrowserChrome::CHROME_ALL,
NS_SIZETOCONTENT, // width NS_SIZETOCONTENT, // width
NS_SIZETOCONTENT, // height NS_SIZETOCONTENT, // height
getter_AddRefs(window)); getter_AddRefs(window));