Teaching windows to check their enclosing chrome documents for capture

(and bubbling).
This commit is contained in:
hyatt%netscape.com 1999-05-27 21:06:51 +00:00
Родитель 54d0661872
Коммит 73c0eaeb2e
2 изменённых файлов: 34 добавлений и 4 удалений

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

@ -116,6 +116,8 @@ GlobalWindowImpl::GlobalWindowImpl()
mListenerManager = nsnull; mListenerManager = nsnull;
mFirstDocumentLoad = PR_TRUE; mFirstDocumentLoad = PR_TRUE;
mChromeDocument = nsnull;
} }
GlobalWindowImpl::~GlobalWindowImpl() GlobalWindowImpl::~GlobalWindowImpl()
@ -279,6 +281,27 @@ GlobalWindowImpl::SetWebShell(nsIWebShell *aWebShell)
if (nsnull != mFrames) { if (nsnull != mFrames) {
mFrames->SetWebShell(aWebShell); mFrames->SetWebShell(aWebShell);
} }
// Get our enclosing chrome shell and retrieve its global window impl, so that we can
// do some forwarding to the chrome document.
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
}
}
}
}
} }
NS_IMETHODIMP_(void) // XXX This may be temporary - rods NS_IMETHODIMP_(void) // XXX This may be temporary - rods
@ -2005,9 +2028,10 @@ GlobalWindowImpl::HandleDOMEvent(nsIPresContext& aPresContext,
} }
//Capturing stage //Capturing stage
/*if (mEventCapturer) { if (NS_EVENT_FLAG_BUBBLE != aFlags && mChromeDocument) {
mEventCapturer->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags, aEventStatus); // Check chrome document capture here
}*/ mChromeDocument->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_CAPTURE, aEventStatus);
}
//Local handling stage //Local handling stage
if (nsnull != mListenerManager) { if (nsnull != mListenerManager) {
@ -2015,7 +2039,10 @@ GlobalWindowImpl::HandleDOMEvent(nsIPresContext& aPresContext,
} }
//Bubbling stage //Bubbling stage
/*Up to frames?*/ if (NS_EVENT_FLAG_CAPTURE != aFlags && mChromeDocument) {
// Bubble to a chrome document if it exists
mChromeDocument->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, NS_EVENT_FLAG_BUBBLE, aEventStatus);
}
if (NS_EVENT_FLAG_INIT == aFlags) { if (NS_EVENT_FLAG_INIT == aFlags) {
// We're leaving the DOM event loop so if we created a DOM event, release here. // We're leaving the DOM event loop so if we created a DOM event, release here.

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

@ -40,6 +40,7 @@
class nsIEventListenerManager; class nsIEventListenerManager;
class nsIDOMDocument; class nsIDOMDocument;
class nsIDocument;
class nsIPresContext; class nsIPresContext;
class nsIDOMEvent; class nsIDOMEvent;
class nsIBrowserWindow; class nsIBrowserWindow;
@ -226,6 +227,8 @@ protected:
nsIWebShell *mWebShell; nsIWebShell *mWebShell;
nsIDOMWindow *mOpener; nsIDOMWindow *mOpener;
nsIDocument* mChromeDocument;
nsTimeoutImpl *mTimeouts; nsTimeoutImpl *mTimeouts;
nsTimeoutImpl **mTimeoutInsertionPoint; nsTimeoutImpl **mTimeoutInsertionPoint;
nsTimeoutImpl *mRunningTimeout; nsTimeoutImpl *mRunningTimeout;