Use GetWindow() in more places where we want a window instead of going through
GetScriptGlobalObject. Bug 311830, r=bryner, sr=jst
This commit is contained in:
Родитель
bc14fdae79
Коммит
c871457818
|
@ -3106,22 +3106,13 @@ nsDocument::CreateTreeWalker(nsIDOMNode *aRoot,
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocument::GetDefaultView(nsIDOMAbstractView** aDefaultView)
|
nsDocument::GetDefaultView(nsIDOMAbstractView** aDefaultView)
|
||||||
{
|
{
|
||||||
*aDefaultView = nsnull;
|
nsPIDOMWindow* win = GetWindow();
|
||||||
|
|
||||||
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(mScriptGlobalObject));
|
|
||||||
|
|
||||||
if (win) {
|
if (win) {
|
||||||
// The default view is our outer window.
|
return CallQueryInterface(win, aDefaultView);
|
||||||
nsPIDOMWindow *outer = win->GetOuterWindow();
|
|
||||||
|
|
||||||
if (outer) {
|
|
||||||
return CallQueryInterface(outer, aDefaultView);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fall through here and return null in case our window no longer
|
|
||||||
// has an outer window.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*aDefaultView = nsnull;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -744,6 +744,8 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
|
||||||
else global = do_QueryInterface(mTarget);
|
else global = do_QueryInterface(mTarget);
|
||||||
if (global) {
|
if (global) {
|
||||||
nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(global));
|
nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(global));
|
||||||
|
NS_ASSERTION(window->IsInnerWindow(),
|
||||||
|
"Setting mutation listener bits on outer window?");
|
||||||
window->SetMutationListeners(aSubType);
|
window->SetMutationListeners(aSubType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2221,7 +2223,7 @@ nsEventListenerManager::FixContextMenuEvent(nsPresContext* aPresContext,
|
||||||
if (aEvent->message == NS_CONTEXTMENU_KEY) {
|
if (aEvent->message == NS_CONTEXTMENU_KEY) {
|
||||||
nsIDocument *doc = shell->GetDocument();
|
nsIDocument *doc = shell->GetDocument();
|
||||||
if (doc) {
|
if (doc) {
|
||||||
nsCOMPtr<nsPIDOMWindow> privWindow = do_QueryInterface(doc->GetScriptGlobalObject());
|
nsPIDOMWindow* privWindow = doc->GetWindow();
|
||||||
if (privWindow) {
|
if (privWindow) {
|
||||||
nsIFocusController *focusController =
|
nsIFocusController *focusController =
|
||||||
privWindow->GetRootFocusController();
|
privWindow->GetRootFocusController();
|
||||||
|
|
|
@ -172,26 +172,6 @@ enum {
|
||||||
MOUSE_SCROLL_TEXTSIZE
|
MOUSE_SCROLL_TEXTSIZE
|
||||||
};
|
};
|
||||||
|
|
||||||
static nsIScriptGlobalObject *
|
|
||||||
GetDocumentOuterWindow(nsIDocument *aDocument)
|
|
||||||
{
|
|
||||||
if (aDocument) {
|
|
||||||
nsIScriptGlobalObject *sgo = aDocument->GetScriptGlobalObject();
|
|
||||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(sgo);
|
|
||||||
|
|
||||||
if (win) {
|
|
||||||
nsCOMPtr<nsIScriptGlobalObject> outersgo =
|
|
||||||
do_QueryInterface(win->GetOuterWindow());
|
|
||||||
|
|
||||||
return outersgo;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sgo;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nsnull;
|
|
||||||
}
|
|
||||||
|
|
||||||
static nsIDocument *
|
static nsIDocument *
|
||||||
GetDocumentFromWindow(nsIDOMWindow *aWindow)
|
GetDocumentFromWindow(nsIDOMWindow *aWindow)
|
||||||
{
|
{
|
||||||
|
@ -558,7 +538,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||||
if (mDocument) {
|
if (mDocument) {
|
||||||
if (gLastFocusedDocument && gLastFocusedPresContext) {
|
if (gLastFocusedDocument && gLastFocusedPresContext) {
|
||||||
nsCOMPtr<nsPIDOMWindow> ourWindow =
|
nsCOMPtr<nsPIDOMWindow> ourWindow =
|
||||||
do_QueryInterface(GetDocumentOuterWindow(gLastFocusedDocument));
|
gLastFocusedDocument->GetWindow();
|
||||||
|
|
||||||
// If the focus controller is already suppressed, it means that we
|
// If the focus controller is already suppressed, it means that we
|
||||||
// are in the middle of an activate sequence. In this case, we do
|
// are in the middle of an activate sequence. In this case, we do
|
||||||
|
@ -638,7 +618,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||||
// then the content node, then the window.
|
// then the content node, then the window.
|
||||||
|
|
||||||
nsCOMPtr<nsIScriptGlobalObject> globalObject =
|
nsCOMPtr<nsIScriptGlobalObject> globalObject =
|
||||||
GetDocumentOuterWindow(mDocument);
|
do_QueryInterface(mDocument->GetWindow());
|
||||||
|
|
||||||
if (globalObject) {
|
if (globalObject) {
|
||||||
// We don't want there to be a focused content node while we're
|
// We don't want there to be a focused content node while we're
|
||||||
|
@ -675,14 +655,12 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||||
if (gLastFocusedDocument && gLastFocusedDocument != mDocument) {
|
if (gLastFocusedDocument && gLastFocusedDocument != mDocument) {
|
||||||
|
|
||||||
nsIFocusController *lastController = nsnull;
|
nsIFocusController *lastController = nsnull;
|
||||||
nsCOMPtr<nsPIDOMWindow> lastWindow =
|
nsPIDOMWindow* lastWindow = gLastFocusedDocument->GetWindow();
|
||||||
do_QueryInterface(GetDocumentOuterWindow(gLastFocusedDocument));
|
|
||||||
if (lastWindow)
|
if (lastWindow)
|
||||||
lastController = lastWindow->GetRootFocusController();
|
lastController = lastWindow->GetRootFocusController();
|
||||||
|
|
||||||
nsIFocusController *nextController = nsnull;
|
nsIFocusController *nextController = nsnull;
|
||||||
nsCOMPtr<nsPIDOMWindow> nextWindow =
|
nsPIDOMWindow* nextWindow = mDocument->GetWindow();
|
||||||
do_QueryInterface(GetDocumentOuterWindow(mDocument));
|
|
||||||
if (nextWindow)
|
if (nextWindow)
|
||||||
nextController = nextWindow->GetRootFocusController();
|
nextController = nextWindow->GetRootFocusController();
|
||||||
|
|
||||||
|
@ -723,22 +701,8 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||||
|
|
||||||
EnsureDocument(aPresContext);
|
EnsureDocument(aPresContext);
|
||||||
|
|
||||||
// We can get a deactivate on an Ender (editor) widget. In this
|
if (gLastFocusedContent && !gLastFocusedContent->IsInDoc()) {
|
||||||
// case, we would like to obtain the DOM Window to start
|
NS_RELEASE(gLastFocusedContent);
|
||||||
// with by looking at gLastFocusedContent.
|
|
||||||
nsCOMPtr<nsIScriptGlobalObject> ourGlobal;
|
|
||||||
if (gLastFocusedContent) {
|
|
||||||
nsIDocument* doc = gLastFocusedContent->GetDocument();
|
|
||||||
|
|
||||||
if (doc) {
|
|
||||||
ourGlobal = GetDocumentOuterWindow(doc);
|
|
||||||
} else {
|
|
||||||
ourGlobal = GetDocumentOuterWindow(mDocument);
|
|
||||||
NS_RELEASE(gLastFocusedContent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ourGlobal = GetDocumentOuterWindow(mDocument);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now fire blurs. We fire a blur on the focused document, element,
|
// Now fire blurs. We fire a blur on the focused document, element,
|
||||||
|
@ -776,7 +740,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||||
// gLastFocusedDocument to change.
|
// gLastFocusedDocument to change.
|
||||||
|
|
||||||
nsCOMPtr<nsIScriptGlobalObject> globalObject =
|
nsCOMPtr<nsIScriptGlobalObject> globalObject =
|
||||||
GetDocumentOuterWindow(gLastFocusedDocument);
|
do_QueryInterface(gLastFocusedDocument->GetWindow());
|
||||||
|
|
||||||
gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext,
|
gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext,
|
||||||
&event, nsnull,
|
&event, nsnull,
|
||||||
|
@ -806,8 +770,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||||
|
|
||||||
EnsureDocument(aPresContext);
|
EnsureDocument(aPresContext);
|
||||||
|
|
||||||
nsCOMPtr<nsPIDOMWindow> win =
|
nsCOMPtr<nsPIDOMWindow> win = mDocument->GetWindow();
|
||||||
do_QueryInterface(GetDocumentOuterWindow(mDocument));
|
|
||||||
|
|
||||||
if (!win) {
|
if (!win) {
|
||||||
NS_ERROR("win is null. this happens [often on xlib builds]. see bug #79213");
|
NS_ERROR("win is null. this happens [often on xlib builds]. see bug #79213");
|
||||||
|
@ -885,7 +848,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||||
EnsureDocument(aPresContext);
|
EnsureDocument(aPresContext);
|
||||||
|
|
||||||
nsCOMPtr<nsIScriptGlobalObject> ourGlobal =
|
nsCOMPtr<nsIScriptGlobalObject> ourGlobal =
|
||||||
GetDocumentOuterWindow(mDocument);
|
do_QueryInterface(mDocument->GetWindow());
|
||||||
|
|
||||||
// Suppress the focus controller for the duration of the
|
// Suppress the focus controller for the duration of the
|
||||||
// de-activation. This will cause it to remember the last
|
// de-activation. This will cause it to remember the last
|
||||||
|
@ -1608,8 +1571,7 @@ nsEventStateManager::ChangeTextSize(PRInt32 change)
|
||||||
{
|
{
|
||||||
if(!gLastFocusedDocument) return NS_ERROR_FAILURE;
|
if(!gLastFocusedDocument) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsCOMPtr<nsPIDOMWindow> ourWindow =
|
nsPIDOMWindow* ourWindow = gLastFocusedDocument->GetWindow();
|
||||||
do_QueryInterface(GetDocumentOuterWindow(gLastFocusedDocument));
|
|
||||||
if(!ourWindow) return NS_ERROR_FAILURE;
|
if(!ourWindow) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsIDOMWindowInternal *rootWindow = ourWindow->GetPrivateRoot();
|
nsIDOMWindowInternal *rootWindow = ourWindow->GetPrivateRoot();
|
||||||
|
@ -3054,8 +3016,7 @@ nsEventStateManager::ChangeFocusWith(nsIContent* aFocusContent,
|
||||||
// Get focus controller.
|
// Get focus controller.
|
||||||
EnsureDocument(mPresContext);
|
EnsureDocument(mPresContext);
|
||||||
nsCOMPtr<nsIFocusController> focusController = nsnull;
|
nsCOMPtr<nsIFocusController> focusController = nsnull;
|
||||||
nsCOMPtr<nsPIDOMWindow> window =
|
nsCOMPtr<nsPIDOMWindow> window = mDocument->GetWindow();
|
||||||
do_QueryInterface(GetDocumentOuterWindow(mDocument));
|
|
||||||
if (window)
|
if (window)
|
||||||
focusController = window->GetRootFocusController();
|
focusController = window->GetRootFocusController();
|
||||||
|
|
||||||
|
@ -3117,8 +3078,7 @@ PrintDocTree(nsIDocShellTreeNode * aParentNode, int aLevel)
|
||||||
parentAsDocShell->GetPresContext(getter_AddRefs(presContext));
|
parentAsDocShell->GetPresContext(getter_AddRefs(presContext));
|
||||||
nsIDocument *doc = presShell->GetDocument();
|
nsIDocument *doc = presShell->GetDocument();
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMWindowInternal> domwin =
|
nsCOMPtr<nsIDOMWindowInternal> domwin = doc->GetWindow();
|
||||||
do_QueryInterface(GetDocumentOuterWindow(doc));
|
|
||||||
|
|
||||||
nsCOMPtr<nsIWidget> widget;
|
nsCOMPtr<nsIWidget> widget;
|
||||||
nsIViewManager* vm = presShell->GetViewManager();
|
nsIViewManager* vm = presShell->GetViewManager();
|
||||||
|
@ -3883,8 +3843,7 @@ nsEventStateManager::SetContentState(nsIContent *aContent, PRInt32 aState)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_aleventhal
|
#ifdef DEBUG_aleventhal
|
||||||
nsCOMPtr<nsPIDOMWindow> currentWindow =
|
nsCOMPtr<nsPIDOMWindow> currentWindow = mDocument->GetWindow();
|
||||||
do_QueryInterface(GetDocumentOuterWindow(mDocument));
|
|
||||||
if (currentWindow) {
|
if (currentWindow) {
|
||||||
nsIFocusController *fc = currentWindow->GetRootFocusController();
|
nsIFocusController *fc = currentWindow->GetRootFocusController();
|
||||||
if (fc) {
|
if (fc) {
|
||||||
|
@ -4143,13 +4102,12 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
|
||||||
// Make sure we're not switching command dispatchers, if so,
|
// Make sure we're not switching command dispatchers, if so,
|
||||||
// surpress the blurred one
|
// surpress the blurred one
|
||||||
if(gLastFocusedDocument && mDocument) {
|
if(gLastFocusedDocument && mDocument) {
|
||||||
nsCOMPtr<nsPIDOMWindow> newWindow =
|
nsCOMPtr<nsPIDOMWindow> newWindow = mDocument->GetWindow();
|
||||||
do_QueryInterface(GetDocumentOuterWindow(mDocument));
|
|
||||||
if (newWindow) {
|
if (newWindow) {
|
||||||
nsIFocusController *newFocusController =
|
nsIFocusController *newFocusController =
|
||||||
newFocusController = newWindow->GetRootFocusController();
|
newFocusController = newWindow->GetRootFocusController();
|
||||||
nsCOMPtr<nsPIDOMWindow> oldWindow =
|
nsCOMPtr<nsPIDOMWindow> oldWindow =
|
||||||
do_QueryInterface(GetDocumentOuterWindow(gLastFocusedDocument));
|
gLastFocusedDocument->GetWindow();
|
||||||
if (oldWindow) {
|
if (oldWindow) {
|
||||||
nsIFocusController *suppressed = oldWindow->GetRootFocusController();
|
nsIFocusController *suppressed = oldWindow->GetRootFocusController();
|
||||||
if (suppressed != newFocusController) {
|
if (suppressed != newFocusController) {
|
||||||
|
@ -4191,7 +4149,7 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
|
||||||
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
||||||
|
|
||||||
if(gLastFocusedDocument)
|
if(gLastFocusedDocument)
|
||||||
globalObject = GetDocumentOuterWindow(gLastFocusedDocument);
|
globalObject = do_QueryInterface(gLastFocusedDocument->GetWindow());
|
||||||
|
|
||||||
EnsureDocument(presShell);
|
EnsureDocument(presShell);
|
||||||
|
|
||||||
|
@ -4202,12 +4160,10 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext,
|
||||||
// Make sure we're not switching command dispatchers, if so,
|
// Make sure we're not switching command dispatchers, if so,
|
||||||
// suppress the blurred one if it isn't already suppressed
|
// suppress the blurred one if it isn't already suppressed
|
||||||
if (mDocument && !oldFocusSuppressor.Suppressing()) {
|
if (mDocument && !oldFocusSuppressor.Suppressing()) {
|
||||||
nsCOMPtr<nsPIDOMWindow> newWindow =
|
nsCOMPtr<nsPIDOMWindow> newWindow = mDocument->GetWindow();
|
||||||
do_QueryInterface(GetDocumentOuterWindow(mDocument));
|
|
||||||
|
|
||||||
if (newWindow) {
|
if (newWindow) {
|
||||||
nsCOMPtr<nsPIDOMWindow> oldWindow =
|
nsCOMPtr<nsPIDOMWindow> oldWindow = do_QueryInterface(globalObject);
|
||||||
do_QueryInterface(GetDocumentOuterWindow(gLastFocusedDocument));
|
|
||||||
nsIFocusController *newFocusController = newWindow->GetRootFocusController();
|
nsIFocusController *newFocusController = newWindow->GetRootFocusController();
|
||||||
if (oldWindow) {
|
if (oldWindow) {
|
||||||
nsIFocusController *suppressed = oldWindow->GetRootFocusController();
|
nsIFocusController *suppressed = oldWindow->GetRootFocusController();
|
||||||
|
@ -4356,8 +4312,7 @@ void nsEventStateManager::EnsureFocusSynchronization()
|
||||||
// cannot get out of sync.
|
// cannot get out of sync.
|
||||||
// See Bug 304751, calling FireOnChange() inside
|
// See Bug 304751, calling FireOnChange() inside
|
||||||
// nsComboboxControlFrame::SetFocus() is bad
|
// nsComboboxControlFrame::SetFocus() is bad
|
||||||
nsCOMPtr<nsPIDOMWindow> currentWindow =
|
nsCOMPtr<nsPIDOMWindow> currentWindow = mDocument->GetWindow();
|
||||||
do_QueryInterface(GetDocumentOuterWindow(mDocument));
|
|
||||||
if (currentWindow) {
|
if (currentWindow) {
|
||||||
nsIFocusController *fc = currentWindow->GetRootFocusController();
|
nsIFocusController *fc = currentWindow->GetRootFocusController();
|
||||||
if (fc) {
|
if (fc) {
|
||||||
|
|
|
@ -406,14 +406,7 @@ nsFocusController::GetWindowFromDocument(nsIDOMDocument* aDocument)
|
||||||
if (!doc)
|
if (!doc)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
nsCOMPtr<nsPIDOMWindow> win =
|
return doc->GetWindow();
|
||||||
do_QueryInterface(doc->GetScriptGlobalObject());
|
|
||||||
|
|
||||||
if (win && win->IsInnerWindow()) {
|
|
||||||
return win->GetOuterWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
return win;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
Загрузка…
Ссылка в новой задаче