added 'content' property to JS window
git-svn-id: svn://10.0.0.236/trunk@37057 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -58,6 +58,8 @@ public:
|
||||
|
||||
NS_IMETHOD GetTop(nsIDOMWindow** aTop)=0;
|
||||
|
||||
NS_IMETHOD GetContent(nsIDOMWindow** aContent)=0;
|
||||
|
||||
NS_IMETHOD GetMenubar(nsIDOMBarProp** aMenubar)=0;
|
||||
|
||||
NS_IMETHOD GetToolbar(nsIDOMBarProp** aToolbar)=0;
|
||||
@@ -173,6 +175,7 @@ public:
|
||||
NS_IMETHOD GetHistory(nsIDOMHistory** aHistory); \
|
||||
NS_IMETHOD GetParent(nsIDOMWindow** aParent); \
|
||||
NS_IMETHOD GetTop(nsIDOMWindow** aTop); \
|
||||
NS_IMETHOD GetContent(nsIDOMWindow** aContent); \
|
||||
NS_IMETHOD GetMenubar(nsIDOMBarProp** aMenubar); \
|
||||
NS_IMETHOD GetToolbar(nsIDOMBarProp** aToolbar); \
|
||||
NS_IMETHOD GetLocationbar(nsIDOMBarProp** aLocationbar); \
|
||||
@@ -243,6 +246,7 @@ public:
|
||||
NS_IMETHOD GetHistory(nsIDOMHistory** aHistory) { return _to GetHistory(aHistory); } \
|
||||
NS_IMETHOD GetParent(nsIDOMWindow** aParent) { return _to GetParent(aParent); } \
|
||||
NS_IMETHOD GetTop(nsIDOMWindow** aTop) { return _to GetTop(aTop); } \
|
||||
NS_IMETHOD GetContent(nsIDOMWindow** aContent) { return _to GetContent(aContent); } \
|
||||
NS_IMETHOD GetMenubar(nsIDOMBarProp** aMenubar) { return _to GetMenubar(aMenubar); } \
|
||||
NS_IMETHOD GetToolbar(nsIDOMBarProp** aToolbar) { return _to GetToolbar(aToolbar); } \
|
||||
NS_IMETHOD GetLocationbar(nsIDOMBarProp** aLocationbar) { return _to GetLocationbar(aLocationbar); } \
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
readonly attribute History history;
|
||||
readonly attribute Window parent;
|
||||
readonly attribute Window top;
|
||||
readonly attribute Window content;
|
||||
readonly attribute BarProp menubar;
|
||||
readonly attribute BarProp toolbar;
|
||||
readonly attribute BarProp locationbar;
|
||||
@@ -56,11 +57,11 @@
|
||||
long setTimeout(/* ... */);
|
||||
long setInterval(/* ... */);
|
||||
|
||||
void createPopup(in Element element, in Element popupContent,
|
||||
in long xPos, in long yPos,
|
||||
in DOMString popupType, in DOMString anchorAlignment,
|
||||
in DOMString popupAlignment);
|
||||
|
||||
void createPopup(in Element element, in Element popupContent,
|
||||
in long xPos, in long yPos,
|
||||
in DOMString popupType, in DOMString anchorAlignment,
|
||||
in DOMString popupAlignment);
|
||||
|
||||
Window open(/* ... */);
|
||||
Window openDialog(/* ... */);
|
||||
};
|
||||
|
||||
@@ -330,19 +330,13 @@ GlobalWindowImpl::SetWebShell(nsIWebShell *aWebShell)
|
||||
nsCOMPtr<nsIWebShell> chromeShell;
|
||||
mWebShell->GetContainingChromeShell(getter_AddRefs(chromeShell));
|
||||
if (chromeShell) {
|
||||
// Convert the chrome shell to a DOM window.
|
||||
nsCOMPtr<nsIScriptContextOwner> contextOwner = do_QueryInterface(chromeShell);
|
||||
if (contextOwner) {
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
||||
if (NS_OK == contextOwner->GetScriptGlobalObject(getter_AddRefs(globalObject))) {
|
||||
nsCOMPtr<nsIDOMWindow> chromeWindow = do_QueryInterface(globalObject);
|
||||
if (chromeWindow) {
|
||||
nsCOMPtr<nsIDOMDocument> chromeDoc;
|
||||
chromeWindow->GetDocument(getter_AddRefs(chromeDoc));
|
||||
nsCOMPtr<nsIDocument> realDoc = do_QueryInterface(chromeDoc);
|
||||
mChromeDocument = realDoc.get(); // Don't addref it
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIDOMWindow> chromeWindow;
|
||||
WebShellToDOMWindow(chromeShell, getter_AddRefs(chromeWindow));
|
||||
if (chromeWindow) {
|
||||
nsCOMPtr<nsIDOMDocument> chromeDoc;
|
||||
chromeWindow->GetDocument(getter_AddRefs(chromeDoc));
|
||||
nsCOMPtr<nsIDocument> realDoc = do_QueryInterface(chromeDoc);
|
||||
mChromeDocument = realDoc.get(); // Don't addref it
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -591,20 +585,12 @@ GlobalWindowImpl::GetParent(nsIDOMWindow** aParent)
|
||||
|
||||
*aParent = nsnull;
|
||||
if (nsnull != mWebShell) {
|
||||
nsIWebShell *mParentWebShell;
|
||||
mWebShell->GetParent(mParentWebShell);
|
||||
nsIWebShell *parentWebShell;
|
||||
mWebShell->GetParent(parentWebShell);
|
||||
|
||||
if (nsnull != mParentWebShell) {
|
||||
nsIScriptContextOwner *mParentContextOwner;
|
||||
if (NS_OK == mParentWebShell->QueryInterface(kIScriptContextOwnerIID, (void**)&mParentContextOwner)) {
|
||||
nsIScriptGlobalObject *mParentGlobalObject;
|
||||
if (NS_OK == mParentContextOwner->GetScriptGlobalObject(&mParentGlobalObject)) {
|
||||
ret = mParentGlobalObject->QueryInterface(kIDOMWindowIID, (void**)aParent);
|
||||
NS_RELEASE(mParentGlobalObject);
|
||||
}
|
||||
NS_RELEASE(mParentContextOwner);
|
||||
}
|
||||
NS_RELEASE(mParentWebShell);
|
||||
if (nsnull != parentWebShell) {
|
||||
ret = WebShellToDOMWindow(parentWebShell, aParent);
|
||||
NS_RELEASE(parentWebShell);
|
||||
}
|
||||
else {
|
||||
*aParent = this;
|
||||
@@ -636,27 +622,35 @@ GlobalWindowImpl::GetTop(nsIDOMWindow** aTop)
|
||||
|
||||
*aTop = nsnull;
|
||||
if (nsnull != mWebShell) {
|
||||
nsIWebShell *mRootWebShell;
|
||||
mWebShell->GetRootWebShell(mRootWebShell);
|
||||
|
||||
|
||||
if (nsnull != mRootWebShell) {
|
||||
nsIScriptContextOwner *mRootContextOwner;
|
||||
if (NS_OK == mRootWebShell->QueryInterface(kIScriptContextOwnerIID, (void**)&mRootContextOwner)) {
|
||||
nsIScriptGlobalObject *mRootGlobalObject;
|
||||
if (NS_OK == mRootContextOwner->GetScriptGlobalObject(&mRootGlobalObject)) {
|
||||
ret = mRootGlobalObject->QueryInterface(kIDOMWindowIID, (void**)aTop);
|
||||
NS_RELEASE(mRootGlobalObject);
|
||||
}
|
||||
NS_RELEASE(mRootContextOwner);
|
||||
}
|
||||
NS_RELEASE(mRootWebShell);
|
||||
nsIWebShell *rootWebShell;
|
||||
mWebShell->GetRootWebShell(rootWebShell);
|
||||
if (nsnull != rootWebShell) {
|
||||
WebShellToDOMWindow(rootWebShell, aTop);
|
||||
NS_RELEASE(rootWebShell);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::GetContent(nsIDOMWindow** aContent)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
*aContent = nsnull;
|
||||
|
||||
nsCOMPtr<nsIBrowserWindow> browser;
|
||||
rv = GetBrowserWindowInterface(*getter_AddRefs(browser));
|
||||
if (NS_SUCCEEDED(rv) && browser) {
|
||||
nsCOMPtr<nsIWebShell> contentShell;
|
||||
rv = browser->GetContentWebShell(getter_AddRefs(contentShell));
|
||||
if (NS_SUCCEEDED(rv) && contentShell)
|
||||
rv = WebShellToDOMWindow(contentShell, aContent);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::GetClosed(PRBool* aClosed)
|
||||
{
|
||||
@@ -2060,6 +2054,27 @@ GlobalWindowImpl::ReadyOpenedWebShell(nsIWebShell *aWebShell, nsIDOMWindow **aDO
|
||||
return res;
|
||||
}
|
||||
|
||||
// simple utility conversion routine
|
||||
nsresult
|
||||
GlobalWindowImpl::WebShellToDOMWindow(nsIWebShell *aWebShell, nsIDOMWindow **aDOMWindow)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_ASSERTION(aWebShell, "null in param to WebShellToDOMWindow");
|
||||
NS_ASSERTION(aDOMWindow, "null out param to WebShellToDOMWindow");
|
||||
|
||||
*aDOMWindow = nsnull;
|
||||
|
||||
nsCOMPtr<nsIScriptContextOwner> owner = do_QueryInterface(aWebShell, &rv);
|
||||
if (owner) {
|
||||
nsCOMPtr<nsIScriptGlobalObject> scriptobj;
|
||||
rv = owner->GetScriptGlobalObject(getter_AddRefs(scriptobj));
|
||||
if (NS_SUCCEEDED(rv) && scriptobj)
|
||||
rv = scriptobj->QueryInterface(nsIDOMWindow::GetIID(), (void **) aDOMWindow);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent,
|
||||
PRInt32 aXPos, PRInt32 aYPos,
|
||||
|
||||
@@ -85,6 +85,7 @@ public:
|
||||
NS_IMETHOD GetLocation(nsIDOMLocation** aLocation);
|
||||
NS_IMETHOD GetParent(nsIDOMWindow** aOpener);
|
||||
NS_IMETHOD GetTop(nsIDOMWindow** aTop);
|
||||
NS_IMETHOD GetContent(nsIDOMWindow** aContent);
|
||||
NS_IMETHOD GetClosed(PRBool* aClosed);
|
||||
NS_IMETHOD GetMenubar(nsIDOMBarProp** aMenubar);
|
||||
NS_IMETHOD GetToolbar(nsIDOMBarProp** aToolbar);
|
||||
@@ -225,6 +226,8 @@ protected:
|
||||
nsresult SizeAndShowOpenedWebShell(nsIWebShell *aOuterShell, char *aFeatures);
|
||||
nsresult ReadyOpenedWebShell(nsIWebShell *aWebShell, nsIDOMWindow **aDOMWindow);
|
||||
|
||||
static nsresult WebShellToDOMWindow(nsIWebShell *aWebShell, nsIDOMWindow **aDOMWindow);
|
||||
|
||||
nsIScriptContext *mContext;
|
||||
void *mScriptObject;
|
||||
nsIDOMDocument *mDocument;
|
||||
|
||||
@@ -79,27 +79,28 @@ enum Window_slots {
|
||||
WINDOW_HISTORY = -6,
|
||||
WINDOW_PARENT = -7,
|
||||
WINDOW_TOP = -8,
|
||||
WINDOW_MENUBAR = -9,
|
||||
WINDOW_TOOLBAR = -10,
|
||||
WINDOW_LOCATIONBAR = -11,
|
||||
WINDOW_PERSONALBAR = -12,
|
||||
WINDOW_STATUSBAR = -13,
|
||||
WINDOW_SCROLLBARS = -14,
|
||||
WINDOW_DIRECTORIES = -15,
|
||||
WINDOW_CLOSED = -16,
|
||||
WINDOW_FRAMES = -17,
|
||||
WINDOW_OPENER = -18,
|
||||
WINDOW_STATUS = -19,
|
||||
WINDOW_DEFAULTSTATUS = -20,
|
||||
WINDOW_NAME = -21,
|
||||
WINDOW_INNERWIDTH = -22,
|
||||
WINDOW_INNERHEIGHT = -23,
|
||||
WINDOW_OUTERWIDTH = -24,
|
||||
WINDOW_OUTERHEIGHT = -25,
|
||||
WINDOW_SCREENX = -26,
|
||||
WINDOW_SCREENY = -27,
|
||||
WINDOW_PAGEXOFFSET = -28,
|
||||
WINDOW_PAGEYOFFSET = -29
|
||||
WINDOW_CONTENT = -9,
|
||||
WINDOW_MENUBAR = -10,
|
||||
WINDOW_TOOLBAR = -11,
|
||||
WINDOW_LOCATIONBAR = -12,
|
||||
WINDOW_PERSONALBAR = -13,
|
||||
WINDOW_STATUSBAR = -14,
|
||||
WINDOW_SCROLLBARS = -15,
|
||||
WINDOW_DIRECTORIES = -16,
|
||||
WINDOW_CLOSED = -17,
|
||||
WINDOW_FRAMES = -18,
|
||||
WINDOW_OPENER = -19,
|
||||
WINDOW_STATUS = -20,
|
||||
WINDOW_DEFAULTSTATUS = -21,
|
||||
WINDOW_NAME = -22,
|
||||
WINDOW_INNERWIDTH = -23,
|
||||
WINDOW_INNERHEIGHT = -24,
|
||||
WINDOW_OUTERWIDTH = -25,
|
||||
WINDOW_OUTERHEIGHT = -26,
|
||||
WINDOW_SCREENX = -27,
|
||||
WINDOW_SCREENY = -28,
|
||||
WINDOW_PAGEXOFFSET = -29,
|
||||
WINDOW_PAGEYOFFSET = -30
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -260,6 +261,23 @@ GetWindowProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WINDOW_CONTENT:
|
||||
{
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "window.content", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsIDOMWindow* prop;
|
||||
if (NS_OK == a->GetContent(&prop)) {
|
||||
// get the js object
|
||||
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WINDOW_MENUBAR:
|
||||
{
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "window.menubar", &ok);
|
||||
@@ -2537,6 +2555,7 @@ static JSPropertySpec WindowProperties[] =
|
||||
{"history", WINDOW_HISTORY, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"parent", WINDOW_PARENT, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"top", WINDOW_TOP, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"content", WINDOW_CONTENT, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"menubar", WINDOW_MENUBAR, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"toolbar", WINDOW_TOOLBAR, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"locationbar", WINDOW_LOCATIONBAR, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
|
||||
@@ -808,20 +808,32 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext& aPresContext,
|
||||
nsWebShellType parentType;
|
||||
outerShell->GetWebShellType(parentType);
|
||||
nsIAtom* typeAtom = NS_NewAtom("type");
|
||||
nsAutoString value;
|
||||
content->GetAttribute(kNameSpaceID_None, typeAtom, value);
|
||||
if (value.EqualsIgnoreCase("content")) {
|
||||
// The web shell's type is content.
|
||||
mWebShell->SetWebShellType(nsWebShellContent);
|
||||
nsCOMPtr<nsIWebShellContainer> shellAsContainer;
|
||||
shellAsContainer = do_QueryInterface(mWebShell);
|
||||
shellAsContainer->ContentShellAdded(mWebShell, content);
|
||||
nsAutoString value, valuePiece;
|
||||
PRBool isContent;
|
||||
|
||||
isContent = PR_FALSE;
|
||||
if (NS_SUCCEEDED(content->GetAttribute(kNameSpaceID_None, typeAtom, value))) {
|
||||
|
||||
// we accept "content" and "content-xxx" values.
|
||||
// at time of writing, we expect "xxx" to be "primary", but
|
||||
// someday it might be an integer expressing priority
|
||||
value.Left(valuePiece, 7);
|
||||
if (valuePiece.EqualsIgnoreCase("content") &&
|
||||
(value.Length() == 7 ||
|
||||
value.Mid(valuePiece, 7, 1) == 1 && valuePiece.Equals("-")))
|
||||
isContent = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
if (isContent) {
|
||||
// The web shell's type is content.
|
||||
mWebShell->SetWebShellType(nsWebShellContent);
|
||||
nsCOMPtr<nsIWebShellContainer> shellAsContainer;
|
||||
shellAsContainer = do_QueryInterface(mWebShell);
|
||||
shellAsContainer->ContentShellAdded(mWebShell, content);
|
||||
} else {
|
||||
// Inherit our type from our parent webshell. If it is
|
||||
// chrome, we'll be chrome. If it is content, we'll be
|
||||
// content.
|
||||
mWebShell->SetWebShellType(parentType);
|
||||
// chrome, we'll be chrome. If it is content, we'll be
|
||||
// content.
|
||||
mWebShell->SetWebShellType(parentType);
|
||||
}
|
||||
|
||||
// Make sure all shells have links back to the nearest enclosing chrome
|
||||
@@ -832,8 +844,9 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext& aPresContext,
|
||||
outerShell->GetWebShellType(chromeShellType);
|
||||
if (chromeShellType == nsWebShellChrome)
|
||||
chromeShell = dont_QueryInterface(outerShell);
|
||||
else outerShell->GetContainingChromeShell(getter_AddRefs(chromeShell));
|
||||
|
||||
else
|
||||
outerShell->GetContainingChromeShell(getter_AddRefs(chromeShell));
|
||||
|
||||
mWebShell->SetContainingChromeShell(chromeShell);
|
||||
|
||||
#endif // INCLUDE_XUL
|
||||
|
||||
@@ -808,20 +808,32 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext& aPresContext,
|
||||
nsWebShellType parentType;
|
||||
outerShell->GetWebShellType(parentType);
|
||||
nsIAtom* typeAtom = NS_NewAtom("type");
|
||||
nsAutoString value;
|
||||
content->GetAttribute(kNameSpaceID_None, typeAtom, value);
|
||||
if (value.EqualsIgnoreCase("content")) {
|
||||
// The web shell's type is content.
|
||||
mWebShell->SetWebShellType(nsWebShellContent);
|
||||
nsCOMPtr<nsIWebShellContainer> shellAsContainer;
|
||||
shellAsContainer = do_QueryInterface(mWebShell);
|
||||
shellAsContainer->ContentShellAdded(mWebShell, content);
|
||||
nsAutoString value, valuePiece;
|
||||
PRBool isContent;
|
||||
|
||||
isContent = PR_FALSE;
|
||||
if (NS_SUCCEEDED(content->GetAttribute(kNameSpaceID_None, typeAtom, value))) {
|
||||
|
||||
// we accept "content" and "content-xxx" values.
|
||||
// at time of writing, we expect "xxx" to be "primary", but
|
||||
// someday it might be an integer expressing priority
|
||||
value.Left(valuePiece, 7);
|
||||
if (valuePiece.EqualsIgnoreCase("content") &&
|
||||
(value.Length() == 7 ||
|
||||
value.Mid(valuePiece, 7, 1) == 1 && valuePiece.Equals("-")))
|
||||
isContent = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
if (isContent) {
|
||||
// The web shell's type is content.
|
||||
mWebShell->SetWebShellType(nsWebShellContent);
|
||||
nsCOMPtr<nsIWebShellContainer> shellAsContainer;
|
||||
shellAsContainer = do_QueryInterface(mWebShell);
|
||||
shellAsContainer->ContentShellAdded(mWebShell, content);
|
||||
} else {
|
||||
// Inherit our type from our parent webshell. If it is
|
||||
// chrome, we'll be chrome. If it is content, we'll be
|
||||
// content.
|
||||
mWebShell->SetWebShellType(parentType);
|
||||
// chrome, we'll be chrome. If it is content, we'll be
|
||||
// content.
|
||||
mWebShell->SetWebShellType(parentType);
|
||||
}
|
||||
|
||||
// Make sure all shells have links back to the nearest enclosing chrome
|
||||
@@ -832,8 +844,9 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext& aPresContext,
|
||||
outerShell->GetWebShellType(chromeShellType);
|
||||
if (chromeShellType == nsWebShellChrome)
|
||||
chromeShell = dont_QueryInterface(outerShell);
|
||||
else outerShell->GetContainingChromeShell(getter_AddRefs(chromeShell));
|
||||
|
||||
else
|
||||
outerShell->GetContainingChromeShell(getter_AddRefs(chromeShell));
|
||||
|
||||
mWebShell->SetContainingChromeShell(chromeShell);
|
||||
|
||||
#endif // INCLUDE_XUL
|
||||
|
||||
@@ -95,6 +95,7 @@ public:
|
||||
NS_IMETHOD IsMenuBarVisible(PRBool *aVisible) = 0;
|
||||
|
||||
NS_IMETHOD GetWebShell(nsIWebShell*& aResult) = 0;
|
||||
NS_IMETHOD GetContentWebShell(nsIWebShell **aResult) = 0;
|
||||
|
||||
// XXX minimize, maximize
|
||||
// XXX event control: enable/disable window close box, stick to glass, modal
|
||||
|
||||
@@ -1607,6 +1607,14 @@ nsBrowserWindow::GetWebShell(nsIWebShell*& aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserWindow::GetContentWebShell(nsIWebShell **aResult)
|
||||
{
|
||||
*aResult = mWebShell;
|
||||
NS_IF_ADDREF(mWebShell);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
@@ -95,6 +95,7 @@ public:
|
||||
NS_IMETHOD ShowMenuBar(PRBool aShow);
|
||||
NS_IMETHOD IsMenuBarVisible(PRBool *aVisible);
|
||||
NS_IMETHOD GetWebShell(nsIWebShell*& aResult);
|
||||
NS_IMETHOD GetContentWebShell(nsIWebShell **aResult);
|
||||
|
||||
// nsIStreamObserver
|
||||
NS_IMETHOD OnStartBinding(nsIURI* aURL, const char *aContentType);
|
||||
|
||||
@@ -44,12 +44,12 @@ public:
|
||||
NS_IMETHOD GetWidget(nsIWidget *& aWidget) = 0;
|
||||
NS_IMETHOD ConvertWebShellToDOMWindow(nsIWebShell* aShell, nsIDOMWindow** aDOMWindow) = 0;
|
||||
|
||||
NS_IMETHOD AddWebShellInfo(const nsString& aID, nsIWebShell* aChildShell) = 0;
|
||||
NS_IMETHOD AddWebShellInfo(const nsString& aID, PRBool aPrimary, nsIWebShell* aChildShell) = 0;
|
||||
|
||||
NS_IMETHOD GetContentShellById(const nsString& anID, nsIWebShell** aResult) = 0;
|
||||
NS_IMETHOD GetContentShellById(const nsString& anID, nsIWebShell** aResult) = 0;
|
||||
|
||||
NS_IMETHOD LockUntilChromeLoad() = 0;
|
||||
NS_IMETHOD GetLockedState(PRBool& aResult) = 0;
|
||||
NS_IMETHOD LockUntilChromeLoad() = 0;
|
||||
NS_IMETHOD GetLockedState(PRBool& aResult) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -161,6 +161,7 @@ static NS_DEFINE_CID(kXULPopupListenerCID, NS_XULPOPUPLISTENER_CID);
|
||||
|
||||
const char * kThrobberOnStr = "resource:/res/throbber/anims07.gif";
|
||||
const char * kThrobberOffStr = "resource:/res/throbber/anims00.gif";
|
||||
const char * kPrimaryContentTypeValue = "content-primary";
|
||||
|
||||
struct ThreadedWindowEvent {
|
||||
PLEvent event;
|
||||
@@ -171,11 +172,13 @@ struct ThreadedWindowEvent {
|
||||
// subsequently be filled in when we receive a webshell added notification.
|
||||
struct nsWebShellInfo {
|
||||
nsString id; // The identifier of the iframe or frame node in the XUL tree.
|
||||
PRBool primary; // whether it's considered a/the primary content
|
||||
nsIWebShell* child; // The child web shell that will end up being used for the content area.
|
||||
|
||||
nsWebShellInfo(const nsString& anID, nsIWebShell* aChildShell)
|
||||
nsWebShellInfo(const nsString& anID, PRBool aPrimary, nsIWebShell* aChildShell)
|
||||
{
|
||||
id = anID;
|
||||
primary = aPrimary;
|
||||
child = aChildShell;
|
||||
NS_IF_ADDREF(aChildShell);
|
||||
}
|
||||
@@ -947,10 +950,11 @@ nsWebShellWindow::GetContentShellById(const nsString& aID, nsIWebShell** aChildS
|
||||
//------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsWebShellWindow::AddWebShellInfo(const nsString& aID,
|
||||
PRBool aPrimary,
|
||||
nsIWebShell* aChildShell)
|
||||
{
|
||||
|
||||
nsWebShellInfo* webShellInfo = new nsWebShellInfo(aID,
|
||||
nsWebShellInfo* webShellInfo = new nsWebShellInfo(aID, aPrimary,
|
||||
aChildShell);
|
||||
|
||||
if (mContentShells == nsnull)
|
||||
@@ -1229,10 +1233,21 @@ NS_IMETHODIMP
|
||||
nsWebShellWindow::ContentShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode)
|
||||
{
|
||||
// Find out the id of the frameNode in question
|
||||
nsIAtom* idAtom = NS_NewAtom("id");
|
||||
nsIAtom *idAtom = NS_NewAtom("id");
|
||||
nsIAtom *typeAtom = NS_NewAtom("type");
|
||||
PRBool isPrimary;
|
||||
nsAutoString value;
|
||||
frameNode->GetAttribute(kNameSpaceID_None, idAtom, value);
|
||||
AddWebShellInfo(value, aChildShell);
|
||||
|
||||
// right now, any webshell with type "content" or "content-XXX" is
|
||||
// considered a content webshell. but only "content-primary" is
|
||||
// considered primary.
|
||||
frameNode->GetAttribute(kNameSpaceID_None, typeAtom, value);
|
||||
isPrimary = value.EqualsIgnoreCase(kPrimaryContentTypeValue) ? PR_TRUE : PR_FALSE;
|
||||
frameNode->GetAttribute(kNameSpaceID_None, idAtom, value);
|
||||
|
||||
AddWebShellInfo(value, isPrimary, aChildShell);
|
||||
|
||||
NS_RELEASE(typeAtom);
|
||||
NS_RELEASE(idAtom);
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1489,6 +1504,7 @@ nsWebShellWindow::ShowModalInternal()
|
||||
}
|
||||
|
||||
|
||||
/* return the main, outermost webshell in this window */
|
||||
NS_IMETHODIMP
|
||||
nsWebShellWindow::GetWebShell(nsIWebShell *& aWebShell)
|
||||
{
|
||||
@@ -1497,6 +1513,51 @@ nsWebShellWindow::GetWebShell(nsIWebShell *& aWebShell)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* return the webshell intended to hold (html) content. In a simple
|
||||
browser window, that would be the main content area. If no such
|
||||
webshell was found for any reason, the outermost webshell will be
|
||||
returned. (Note that is the main chrome webshell, and probably
|
||||
not what you wanted, but at least it's a webshell.)
|
||||
Also note that if no content webshell was marked "primary,"
|
||||
we return the chrome webshell, even if (non-primary) content webshells
|
||||
do exist. Thas was done intentionally. The selection would be
|
||||
nondeterministic, and it seems dangerous to set a precedent like that.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsWebShellWindow::GetContentWebShell(nsIWebShell **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIWebShell *content;
|
||||
|
||||
content = nsnull;
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
// first, try looking in the webshell list
|
||||
// (note this list isn't dynamic: it's set up when the webshell is added,
|
||||
// but not updated when its attributes are poked. could be a problem...)
|
||||
if (mContentShells) {
|
||||
PRInt32 count = mContentShells->Count();
|
||||
for (PRInt32 ctr = 0; ctr < count; ctr++) {
|
||||
nsWebShellInfo* webInfo = (nsWebShellInfo*)(mContentShells->ElementAt(ctr));
|
||||
if (webInfo->primary) {
|
||||
content = webInfo->child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!content)
|
||||
// couldn't find it? then return our chrome webshell
|
||||
content = mWebShell;
|
||||
|
||||
if (content) {
|
||||
NS_ADDREF(content);
|
||||
rv = NS_OK;
|
||||
}
|
||||
*aResult = content;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShellWindow::GetWidget(nsIWidget *& aWidget)
|
||||
{
|
||||
|
||||
@@ -97,10 +97,11 @@ public:
|
||||
nsIWebShell *&aNewWebShell);
|
||||
|
||||
NS_IMETHOD AddWebShellInfo(const nsString& aID,
|
||||
nsIWebShell* aChildShell);
|
||||
PRBool aPrimary,
|
||||
nsIWebShell* aChildShell);
|
||||
|
||||
NS_IMETHOD GetContentShellById(const nsString& anID, nsIWebShell** aResult);
|
||||
NS_IMETHOD LockUntilChromeLoad() { mLockedUntilChromeLoad = PR_TRUE; return NS_OK; }
|
||||
NS_IMETHOD GetContentShellById(const nsString& anID, nsIWebShell** aResult);
|
||||
NS_IMETHOD LockUntilChromeLoad() { mLockedUntilChromeLoad = PR_TRUE; return NS_OK; }
|
||||
NS_IMETHOD GetLockedState(PRBool& aResult) { aResult = mLockedUntilChromeLoad; return NS_OK; }
|
||||
|
||||
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName,
|
||||
@@ -113,6 +114,7 @@ public:
|
||||
NS_IMETHOD ShowModal();
|
||||
NS_IMETHOD Close();
|
||||
NS_IMETHOD GetWebShell(nsIWebShell *& aWebShell);
|
||||
NS_IMETHOD GetContentWebShell(nsIWebShell **aResult);
|
||||
NS_IMETHOD GetWidget(nsIWidget *& aWidget);
|
||||
NS_IMETHOD ConvertWebShellToDOMWindow(nsIWebShell* aShell, nsIDOMWindow** aDOMWindow);
|
||||
// nsWebShellWindow methods...
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
<titledbutton id="grippy" class="grippy" onclick="toggleOpenClose();"
|
||||
flex="100%" />
|
||||
</box>
|
||||
<html:iframe type="content" id="content" src="about:blank" flex="100%" />
|
||||
<!-- type attribute is used by frame construction to locate iframes
|
||||
intended to hold (html) content -->
|
||||
<!-- id's use is a mystery -->
|
||||
<html:iframe type="content-primary" id="content" src="about:blank" flex="100%" />
|
||||
</box>
|
||||
</window>
|
||||
|
||||
Reference in New Issue
Block a user