зеркало из https://github.com/mozilla/pjs.git
adding partial (for DOM elements) chromemask support to apprunner
This commit is contained in:
Родитель
dc1b16fd0a
Коммит
f8b9684c67
|
@ -1554,7 +1554,7 @@ GlobalWindowImpl::CalculateChromeFlags(char *aFeatures) {
|
|||
PRUint32 chromeFlags = 0;
|
||||
|
||||
if (nsnull == aFeatures)
|
||||
return (PRUint32)~0; // default is fully chromed (but don't copy history?)
|
||||
return NS_CHROME_ALL_CHROME;
|
||||
|
||||
chromeFlags |= WinHasOption(aFeatures, "toolbar") ? NS_CHROME_TOOL_BAR_ON : 0;
|
||||
chromeFlags |= WinHasOption(aFeatures, "location") ? NS_CHROME_LOCATION_BAR_ON : 0;
|
||||
|
|
|
@ -36,17 +36,18 @@ struct nsRect;
|
|||
{ 0xa6cf905d, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
// Chrome mask
|
||||
#define NS_CHROME_WINDOW_BORDERS_ON 0x001
|
||||
#define NS_CHROME_WINDOW_CLOSE_ON 0x002
|
||||
#define NS_CHROME_WINDOW_RESIZE_ON 0x004
|
||||
#define NS_CHROME_MENU_BAR_ON 0x008
|
||||
#define NS_CHROME_TOOL_BAR_ON 0x010
|
||||
#define NS_CHROME_LOCATION_BAR_ON 0x020
|
||||
#define NS_CHROME_STATUS_BAR_ON 0x040
|
||||
#define NS_CHROME_PERSONAL_TOOLBAR_ON 0x080
|
||||
#define NS_CHROME_SCROLLBARS_ON 0x100
|
||||
#define NS_CHROME_TITLEBAR_ON 0x200
|
||||
#define NS_CHROME_OPEN_AS_CHROME 0x400
|
||||
#define NS_CHROME_WINDOW_BORDERS_ON 0x00000001
|
||||
#define NS_CHROME_WINDOW_CLOSE_ON 0x00000002
|
||||
#define NS_CHROME_WINDOW_RESIZE_ON 0x00000004
|
||||
#define NS_CHROME_MENU_BAR_ON 0x00000008
|
||||
#define NS_CHROME_TOOL_BAR_ON 0x00000010
|
||||
#define NS_CHROME_LOCATION_BAR_ON 0x00000020
|
||||
#define NS_CHROME_STATUS_BAR_ON 0x00000040
|
||||
#define NS_CHROME_PERSONAL_TOOLBAR_ON 0x00000080
|
||||
#define NS_CHROME_SCROLLBARS_ON 0x00000100
|
||||
#define NS_CHROME_TITLEBAR_ON 0x00000200
|
||||
#define NS_CHROME_OPEN_AS_CHROME 0x80000000
|
||||
#define NS_CHROME_ALL_CHROME 0x000003FF
|
||||
|
||||
/**
|
||||
* API to a "browser window". A browser window contains a toolbar, a web shell
|
||||
|
|
|
@ -189,6 +189,7 @@ nsWebShellWindow::nsWebShellWindow()
|
|||
mChromeInitialized = PR_FALSE;
|
||||
mLockedUntilChromeLoad = PR_FALSE;
|
||||
mContentShells = nsnull;
|
||||
mChromeMask = NS_CHROME_ALL_CHROME;
|
||||
}
|
||||
|
||||
|
||||
|
@ -367,7 +368,7 @@ nsWebShellWindow::Close()
|
|||
ExitModalLoop();
|
||||
if (mWebShell) {
|
||||
mWebShell->Destroy();
|
||||
NS_IF_RELEASE(mWebShell);
|
||||
NS_RELEASE(mWebShell);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(mWindow);
|
||||
|
@ -1125,10 +1126,15 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible,
|
|||
if ((aChromeMask & NS_CHROME_OPEN_AS_CHROME) != 0) {
|
||||
// Just do a nice normal create of a web shell and
|
||||
// return it immediately.
|
||||
appShell->CreateTopLevelWindow(nsnull, nsnull, PR_FALSE, *getter_AddRefs(newWindow),
|
||||
rv = appShell->CreateTopLevelWindow(nsnull, nsnull, PR_FALSE, *getter_AddRefs(newWindow),
|
||||
nsnull, nsnull, 615, 480);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIBrowserWindow> browser(do_QueryInterface(newWindow));
|
||||
if (browser)
|
||||
browser->SetChrome(aChromeMask);
|
||||
newWindow->GetWebShell(aNewWebShell); // GetWebShell does the addref.
|
||||
return NS_OK;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef XP_PC // XXX: Won't work on any other platforms yet. Sigh.
|
||||
|
@ -1148,17 +1154,22 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible,
|
|||
|
||||
nsCOMPtr<nsIURL> urlObj;
|
||||
rv = NS_NewURL(getter_AddRefs(urlObj), "chrome://navigator/content/");
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
appShell->CreateTopLevelWindow(nsnull, urlObj, PR_FALSE, *getter_AddRefs(newWindow),
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = appShell->CreateTopLevelWindow(nsnull, urlObj, PR_FALSE, *getter_AddRefs(newWindow),
|
||||
nsnull, nsnull, 615, 480);
|
||||
|
||||
// Spin into the modal loop.
|
||||
nsIAppShell *subshell;
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIBrowserWindow> browser(do_QueryInterface(newWindow));
|
||||
if (browser)
|
||||
browser->SetChrome(aChromeMask);
|
||||
|
||||
// Spin into the modal loop.
|
||||
rv = nsComponentManager::CreateInstance(kAppShellCID, nsnull, kIAppShellIID, (void**)&subshell);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
||||
subshell->Create(0, nsnull);
|
||||
subshell->Spinup(); // Spin up
|
||||
|
@ -1167,12 +1178,13 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible,
|
|||
newWindow->LockUntilChromeLoad();
|
||||
|
||||
PRBool locked = PR_FALSE;
|
||||
nsresult looprv = NS_OK;
|
||||
newWindow->GetLockedState(locked);
|
||||
while (NS_SUCCEEDED(rv) && locked) {
|
||||
while (NS_SUCCEEDED(looprv) && locked) {
|
||||
void *data;
|
||||
PRBool isRealEvent;
|
||||
|
||||
rv = subshell->GetNativeEvent(isRealEvent, data);
|
||||
looprv = subshell->GetNativeEvent(isRealEvent, data);
|
||||
subshell->DispatchNativeEvent(isRealEvent, data);
|
||||
|
||||
newWindow->GetLockedState(locked);
|
||||
|
@ -1183,18 +1195,22 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible,
|
|||
|
||||
subshell->Spindown();
|
||||
NS_RELEASE(subshell);
|
||||
}
|
||||
|
||||
// We're out of the nested loop.
|
||||
// During the layout of the new window, all content shells were located and placed
|
||||
// into the new window's content shell array. Locate the "content area" content
|
||||
// shell.
|
||||
if (NS_FAILED(rv = newWindow->GetContentShellById("content", &aNewWebShell))) {
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = newWindow->GetContentShellById("content", &aNewWebShell);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Unable to obtain a browser content shell.");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
#endif // XP_PC
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1391,6 +1407,7 @@ nsWebShellWindow::OnEndDocumentLoad(nsIDocumentLoader* loader,
|
|||
|
||||
SetSizeFromXUL();
|
||||
SetTitleFromXUL();
|
||||
ShowAppropriateChrome();
|
||||
|
||||
#if 0
|
||||
nsCOMPtr<nsIDOMDocument> toolbarDOMDoc(GetNamedDOMDoc(nsAutoString("browser.toolbar")));
|
||||
|
@ -1810,7 +1827,6 @@ void nsWebShellWindow::SetSizeFromXUL()
|
|||
}
|
||||
}
|
||||
mWindow->GetBounds(currentSize);
|
||||
windowWidget->Resize(currentSize.width, specHeight, PR_TRUE);
|
||||
}
|
||||
#endif
|
||||
} // SetSizeFromXUL
|
||||
|
@ -1831,6 +1847,66 @@ void nsWebShellWindow::SetTitleFromXUL()
|
|||
} // SetTitleFromXUL
|
||||
|
||||
|
||||
#include "nsIDOMXULElement.h"
|
||||
// show/hide contents according to the current chrome mask
|
||||
void nsWebShellWindow::ShowAppropriateChrome()
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> rootElement;
|
||||
nsCOMPtr<nsIDOMXULElement> xulRoot;
|
||||
nsCOMPtr<nsIDOMDocument> chromeDoc;
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
|
||||
// get this window's document
|
||||
if (NS_FAILED(ConvertWebShellToDOMWindow(mWebShell, getter_AddRefs(domWindow))))
|
||||
return;
|
||||
if (NS_FAILED(domWindow->GetDocument(getter_AddRefs(chromeDoc))))
|
||||
return;
|
||||
if (NS_FAILED(chromeDoc->GetDocumentElement(getter_AddRefs(rootElement))))
|
||||
return;
|
||||
|
||||
// get a list of this document's elements with the chromeclass attribute specified
|
||||
xulRoot = do_QueryInterface(rootElement);
|
||||
if (xulRoot) { // todo (maybe) the longer, straight DOM (not RDF) version?
|
||||
nsCOMPtr<nsIDOMNodeList> chromeNodes;
|
||||
if (NS_SUCCEEDED(xulRoot->GetElementsByAttribute("chromeclass", "*",
|
||||
getter_AddRefs(chromeNodes)))) {
|
||||
PRUint32 nodeCtr, nodeCount;
|
||||
chromeNodes->GetLength(&nodeCount);
|
||||
for (nodeCtr = 0; nodeCtr < nodeCount; nodeCtr++) {
|
||||
nsCOMPtr<nsIDOMNode> domNode;
|
||||
nsCOMPtr<nsIDOMElement> domElement;
|
||||
chromeNodes->Item(nodeCtr, getter_AddRefs(domNode));
|
||||
domElement = do_QueryInterface(domNode);
|
||||
if (domElement) {
|
||||
nsAutoString chromeClass;
|
||||
PRBool makeChange;
|
||||
PRUint32 flag;
|
||||
// show or hide the element according to its chromeclass and the chromemask
|
||||
domElement->GetAttribute("chromeclass", chromeClass);
|
||||
makeChange = PR_FALSE;
|
||||
if (chromeClass == "location") {
|
||||
makeChange = PR_TRUE;
|
||||
flag = mChromeMask & NS_CHROME_LOCATION_BAR_ON;
|
||||
} else if (chromeClass == "menubar") {
|
||||
makeChange = PR_TRUE;
|
||||
flag = mChromeMask & NS_CHROME_MENU_BAR_ON;
|
||||
} else if (chromeClass == "status") {
|
||||
makeChange = PR_TRUE;
|
||||
flag = mChromeMask & NS_CHROME_STATUS_BAR_ON;
|
||||
} else if (chromeClass == "toolbar") {
|
||||
makeChange = PR_TRUE;
|
||||
flag = mChromeMask & NS_CHROME_TOOL_BAR_ON;
|
||||
}
|
||||
if (makeChange)
|
||||
domElement->SetAttribute("chromehidden", "");
|
||||
else
|
||||
domElement->RemoveAttribute("chromehidden");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
//-- nsIDocumentObserver
|
||||
//----------------------------------------------------------------
|
||||
|
@ -2017,7 +2093,6 @@ NS_IMETHODIMP nsWebShellWindow::Init(nsIAppShell* aAppShell,
|
|||
nsresult rv;
|
||||
nsCOMPtr<nsIURL> urlObj;
|
||||
|
||||
// (temporary)
|
||||
rv = NS_NewURL(getter_AddRefs(urlObj), "chrome://navigator/content/");
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
@ -2027,6 +2102,7 @@ NS_IMETHODIMP nsWebShellWindow::Init(nsIAppShell* aAppShell,
|
|||
// a generic browser appcore here someday.
|
||||
rv = Initialize(nsnull, aAppShell, urlObj,
|
||||
nsnull, nsnull, aBounds.width, aBounds.height);
|
||||
mChromeMask = aChromeMask;
|
||||
if (NS_SUCCEEDED(rv))
|
||||
MoveTo(aBounds.x, aBounds.y);
|
||||
return rv;
|
||||
|
@ -2058,20 +2134,14 @@ NS_IMETHODIMP nsWebShellWindow::GetWindowBounds(nsRect& aResult)
|
|||
|
||||
NS_IMETHODIMP nsWebShellWindow::SetChrome(PRUint32 aNewChromeMask)
|
||||
{
|
||||
// yeah sure. we got your chrome changes.
|
||||
mChromeMask = aNewChromeMask;
|
||||
ShowAppropriateChrome();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebShellWindow::GetChrome(PRUint32& aChromeMaskResult)
|
||||
{
|
||||
// Do our best to fake an interesting, rather inapplicable concept from the old world.
|
||||
// We can't tell what sort of chrome features we have until we invent a standard
|
||||
// for XUL chrome elements, and then go looking for them. For now, take a guess...
|
||||
aChromeMaskResult = NS_CHROME_WINDOW_BORDERS_ON | NS_CHROME_WINDOW_CLOSE_ON |
|
||||
NS_CHROME_WINDOW_RESIZE_ON | NS_CHROME_MENU_BAR_ON |
|
||||
NS_CHROME_TOOL_BAR_ON | NS_CHROME_LOCATION_BAR_ON |
|
||||
NS_CHROME_STATUS_BAR_ON | NS_CHROME_PERSONAL_TOOLBAR_ON |
|
||||
NS_CHROME_SCROLLBARS_ON | NS_CHROME_TITLEBAR_ON;
|
||||
aChromeMaskResult = mChromeMask;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ protected:
|
|||
void ExecuteStartupCode();
|
||||
void SetSizeFromXUL();
|
||||
void SetTitleFromXUL();
|
||||
|
||||
void ShowAppropriateChrome();
|
||||
|
||||
virtual ~nsWebShellWindow();
|
||||
|
||||
|
@ -255,6 +255,7 @@ protected:
|
|||
PRBool mContinueModalLoop;
|
||||
PRBool mLockedUntilChromeLoad;
|
||||
PRBool mChromeInitialized;
|
||||
PRUint32 mChromeMask;
|
||||
|
||||
nsVoidArray mMenuDelegates;
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
/** Contains style definitions for the navigator application
|
||||
**/
|
||||
|
||||
[chromehidden] { /* what to do if chrome requests you be invisible */
|
||||
display: none;
|
||||
}
|
||||
|
||||
titledbutton#print-button {
|
||||
list-style-image:url(resource:/res/toolbar/TB_Print.gif);
|
||||
}
|
||||
|
|
|
@ -265,8 +265,7 @@
|
|||
<broadcaster id="Browser:Throbber" busy="false"/>
|
||||
<broadcaster id="args" value="http://www.mozilla.org/quality/smoketests/"/>
|
||||
|
||||
|
||||
<menubar>
|
||||
<menubar chromeclass="menubar">
|
||||
<menu name="&fileMenu.label;">
|
||||
<menuitem name="&browserCmd.label;" onclick="BrowserNewWindow();"/>
|
||||
<menu name="New">
|
||||
|
@ -551,7 +550,7 @@
|
|||
|
||||
<box id="outer-box" align="vertical">
|
||||
<toolbox>
|
||||
<toolbar class="main-bar">
|
||||
<toolbar class="main-bar" chromeclass="toolbar">
|
||||
<titledbutton id="back-button" align="bottom" value="&backButton.label;" onclick="BrowserBack()">
|
||||
<observes element="canGoBack" attribute="disabled" onChange="BrowserSetBack()"/>
|
||||
</titledbutton>
|
||||
|
@ -573,7 +572,7 @@
|
|||
|
||||
<box align="vertical" flex="100%">
|
||||
<spring flex="100%"/>
|
||||
<html:input id="urlbar" type="text" style="min-width: 100px; min-height: 25px"
|
||||
<html:input id="urlbar" type="text" chromeclass="location" style="min-width: 100px; min-height: 25px"
|
||||
onkeyup="if (event.which == 13) { BrowserLoadURL(); }"/>
|
||||
<spring flex="100%"/>
|
||||
</box>
|
||||
|
@ -587,7 +586,7 @@
|
|||
</titledbutton>
|
||||
</toolbar>
|
||||
|
||||
<toolbar class="main-bar">
|
||||
<toolbar class="main-bar" chromeclass="toolbar">
|
||||
<titledbutton id="home-button" align="right" value="&homeButton.label;"
|
||||
onclick="BrowserHome()"/>
|
||||
<titledbutton id="netscape-button" align="right" value="&netscapeButton.label;"
|
||||
|
@ -633,7 +632,7 @@
|
|||
</box>
|
||||
|
||||
<toolbox>
|
||||
<toolbar id="taskbar">
|
||||
<toolbar id="taskbar" chromeclass="status">
|
||||
<box align="horizontal">
|
||||
<titledbutton align="left" class="popup" value="&webButton.label;" />
|
||||
<titledbutton align="left" class="popup" value="&mailButton.label;" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче