mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 861729 - Remove nsPIDOMWindow::mDocument r=Ms2ger
This commit is contained in:
parent
691abfe5eb
commit
ee718a17ce
@ -1213,7 +1213,6 @@ nsGlobalWindow::~nsGlobalWindow()
|
||||
}
|
||||
}
|
||||
|
||||
mDocument = nullptr; // Forces Release
|
||||
mDoc = nullptr;
|
||||
|
||||
NS_ASSERTION(!mArguments, "mArguments wasn't cleaned up properly!");
|
||||
@ -1465,9 +1464,7 @@ nsGlobalWindow::FreeInnerObjects()
|
||||
mScreen = nullptr;
|
||||
}
|
||||
|
||||
if (mDocument) {
|
||||
NS_ASSERTION(mDoc, "Why is mDoc null?");
|
||||
|
||||
if (mDoc) {
|
||||
// Remember the document's principal and URI.
|
||||
mDocumentPrincipal = mDoc->NodePrincipal();
|
||||
mDocumentURI = mDoc->GetDocumentURI();
|
||||
@ -1475,7 +1472,6 @@ nsGlobalWindow::FreeInnerObjects()
|
||||
}
|
||||
|
||||
// Remove our reference to the document and the document principal.
|
||||
mDocument = nullptr;
|
||||
mDoc = nullptr;
|
||||
mFocusedNode = nullptr;
|
||||
|
||||
@ -1647,7 +1643,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindow)
|
||||
// Traverse stuff from nsPIDOMWindow
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeEventHandler)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFrameElement)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFocusedNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAudioContexts)
|
||||
@ -1694,7 +1689,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow)
|
||||
// Unlink stuff from nsPIDOMWindow
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParentTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFrameElement)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFocusedNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAudioContexts)
|
||||
@ -2144,7 +2138,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
|
||||
NS_ASSERTION(!GetCurrentInnerWindow() ||
|
||||
GetCurrentInnerWindow()->GetExtantDoc() == mDoc,
|
||||
"Uh, mDocument doesn't match the current inner window "
|
||||
"Uh, mDoc doesn't match the current inner window "
|
||||
"document!");
|
||||
|
||||
bool wouldReuseInnerWindow = WouldReuseInnerWindow(aDocument);
|
||||
@ -2156,7 +2150,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> oldDoc(do_QueryInterface(mDocument));
|
||||
nsCOMPtr<nsIDocument> oldDoc = mDoc;
|
||||
|
||||
nsIScriptContext *scx = GetContextInternal();
|
||||
NS_ENSURE_TRUE(scx, NS_ERROR_NOT_INITIALIZED);
|
||||
@ -2171,7 +2165,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!mDocument) {
|
||||
if (!mDoc) {
|
||||
// First document load.
|
||||
|
||||
// Get our private root. If it is equal to us, then we need to
|
||||
@ -2198,10 +2192,9 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Set mDocument even if this is an outer window to avoid
|
||||
// Set mDoc even if this is an outer window to avoid
|
||||
// having to *always* reach into the inner window to find the
|
||||
// document.
|
||||
mDocument = do_QueryInterface(aDocument);
|
||||
mDoc = aDocument;
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -2471,7 +2464,6 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
if (!aState) {
|
||||
if (reUseInnerWindow) {
|
||||
if (newInnerWindow->mDoc != aDocument) {
|
||||
newInnerWindow->mDocument = do_QueryInterface(aDocument);
|
||||
newInnerWindow->mDoc = aDocument;
|
||||
|
||||
// We're reusing the inner window for a new document. In this
|
||||
@ -2559,12 +2551,12 @@ nsGlobalWindow::PreloadLocalStorage()
|
||||
void
|
||||
nsGlobalWindow::DispatchDOMWindowCreated()
|
||||
{
|
||||
if (!mDoc || !mDocument) {
|
||||
if (!mDoc) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Fire DOMWindowCreated at chrome event listeners
|
||||
nsContentUtils::DispatchChromeEvent(mDoc, mDocument, NS_LITERAL_STRING("DOMWindowCreated"),
|
||||
nsContentUtils::DispatchChromeEvent(mDoc, mDoc, NS_LITERAL_STRING("DOMWindowCreated"),
|
||||
true /* bubbles */,
|
||||
false /* not cancellable */);
|
||||
|
||||
@ -2606,7 +2598,6 @@ nsGlobalWindow::InnerSetNewDocument(nsIDocument* aDocument)
|
||||
}
|
||||
#endif
|
||||
|
||||
mDocument = do_QueryInterface(aDocument);
|
||||
mDoc = aDocument;
|
||||
mFocusedNode = nullptr;
|
||||
mLocalStorage = nullptr;
|
||||
@ -2702,14 +2693,13 @@ nsGlobalWindow::DetachFromDocShell()
|
||||
|
||||
if (currentInner) {
|
||||
NS_ASSERTION(mDoc, "Must have doc!");
|
||||
|
||||
|
||||
// Remember the document's principal and URI.
|
||||
mDocumentPrincipal = mDoc->NodePrincipal();
|
||||
mDocumentURI = mDoc->GetDocumentURI();
|
||||
mDocBaseURI = mDoc->GetDocBaseURI();
|
||||
|
||||
// Release our document reference
|
||||
mDocument = nullptr;
|
||||
mDoc = nullptr;
|
||||
mFocusedNode = nullptr;
|
||||
}
|
||||
@ -3044,8 +3034,7 @@ nsGlobalWindow::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
aVisitor.mEvent->mFlags.mIsTrusted) {
|
||||
// Execute bindingdetached handlers before we tear ourselves
|
||||
// down.
|
||||
if (mDocument) {
|
||||
NS_ASSERTION(mDoc, "Must have doc");
|
||||
if (mDoc) {
|
||||
mDoc->BindingManager()->ExecuteDetachedHandlers();
|
||||
}
|
||||
mIsDocumentLoaded = false;
|
||||
@ -3230,7 +3219,7 @@ nsPIDOMWindow::MaybeCreateDoc()
|
||||
{
|
||||
MOZ_ASSERT(!mDoc);
|
||||
if (nsIDocShell* docShell = GetDocShell()) {
|
||||
// Note that |document| here is the same thing as our mDocument, but we
|
||||
// Note that |document| here is the same thing as our mDoc, but we
|
||||
// don't have to explicitly set the member variable because the docshell
|
||||
// has already called SetNewDocument().
|
||||
nsCOMPtr<nsIDocument> document = do_GetInterface(docShell);
|
||||
@ -3746,9 +3735,8 @@ nsGlobalWindow::GetApplicationCache(nsIDOMOfflineResourceList **aApplicationCach
|
||||
nsresult rv = webNav->GetCurrentURI(getter_AddRefs(uri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
|
||||
nsCOMPtr<nsIURI> manifestURI;
|
||||
nsContentUtils::GetOfflineAppManifest(doc, getter_AddRefs(manifestURI));
|
||||
nsContentUtils::GetOfflineAppManifest(mDoc, getter_AddRefs(manifestURI));
|
||||
|
||||
nsRefPtr<nsDOMOfflineResourceList> applicationCache =
|
||||
new nsDOMOfflineResourceList(manifestURI, uri, this);
|
||||
@ -4558,8 +4546,7 @@ nsGlobalWindow::CheckSecurityWidthAndHeight(int32_t* aWidth, int32_t* aHeight)
|
||||
#ifdef MOZ_XUL
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
// if attempting to resize the window, hide any open popups
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
||||
nsContentUtils::HidePopupsInDocument(doc);
|
||||
nsContentUtils::HidePopupsInDocument(mDoc);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -4624,8 +4611,7 @@ nsGlobalWindow::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop)
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
#ifdef MOZ_XUL
|
||||
// if attempting to move the window, hide any open popups
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
||||
nsContentUtils::HidePopupsInDocument(doc);
|
||||
nsContentUtils::HidePopupsInDocument(mDoc);
|
||||
#endif
|
||||
|
||||
nsGlobalWindow* rootWindow =
|
||||
@ -4836,8 +4822,7 @@ bool
|
||||
nsGlobalWindow::DispatchCustomEvent(const char *aEventName)
|
||||
{
|
||||
bool defaultActionEnabled = true;
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
||||
nsContentUtils::DispatchTrustedEvent(doc,
|
||||
nsContentUtils::DispatchTrustedEvent(mDoc,
|
||||
GetOuterWindow(),
|
||||
NS_ConvertASCIItoUTF16(aEventName),
|
||||
true, true, &defaultActionEnabled);
|
||||
@ -4999,8 +4984,7 @@ nsGlobalWindow::SetFullScreenInternal(bool aFullScreen, bool aRequireTrust)
|
||||
// DOM full-screen mode and the user exits full-screen mode with
|
||||
// the browser full-screen mode toggle keyboard-shortcut, we'll detect
|
||||
// that and leave DOM API full-screen mode too.
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
||||
nsIDocument::ExitFullscreen(doc, /* async */ false);
|
||||
nsIDocument::ExitFullscreen(mDoc, /* async */ false);
|
||||
}
|
||||
|
||||
if (!mWakeLock && mFullScreen) {
|
||||
@ -5554,10 +5538,8 @@ nsGlobalWindow::Focus()
|
||||
mDocShell->GetItemType(&itemType);
|
||||
if (itemType == nsIDocShellTreeItem::typeChrome &&
|
||||
GetPrivateRoot() == static_cast<nsIDOMWindow*>(this) &&
|
||||
mDocument) {
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
||||
NS_ASSERTION(doc, "Bogus doc?");
|
||||
nsIURI* ourURI = doc->GetDocumentURI();
|
||||
mDoc) {
|
||||
nsIURI* ourURI = mDoc->GetDocumentURI();
|
||||
if (ourURI) {
|
||||
lookForPresShell = !NS_IsAboutBlank(ourURI);
|
||||
}
|
||||
@ -5580,8 +5562,7 @@ nsGlobalWindow::Focus()
|
||||
if (!parentdoc)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
|
||||
nsIContent* frame = parentdoc->FindContentForSubDocument(doc);
|
||||
nsIContent* frame = parentdoc->FindContentForSubDocument(mDoc);
|
||||
nsCOMPtr<nsIDOMElement> frameElement = do_QueryInterface(frame);
|
||||
if (frameElement) {
|
||||
uint32_t flags = nsIFocusManager::FLAG_NOSCROLL;
|
||||
@ -5623,12 +5604,11 @@ nsGlobalWindow::Blur()
|
||||
|
||||
// if the root is focused, clear the focus
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
|
||||
if (fm && mDocument) {
|
||||
if (fm && mDoc) {
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
fm->GetFocusedElementForWindow(this, false, nullptr, getter_AddRefs(element));
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(element);
|
||||
if (content == doc->GetRootElement())
|
||||
if (content == mDoc->GetRootElement())
|
||||
fm->ClearFocus(this);
|
||||
}
|
||||
}
|
||||
@ -6178,7 +6158,7 @@ nsGlobalWindow::DisableExternalCapture()
|
||||
}
|
||||
|
||||
static
|
||||
bool IsPopupBlocked(nsIDOMDocument* aDoc)
|
||||
bool IsPopupBlocked(nsIDocument* aDoc)
|
||||
{
|
||||
nsCOMPtr<nsIPopupWindowManager> pm =
|
||||
do_GetService(NS_POPUPWINDOWMANAGER_CONTRACTID);
|
||||
@ -6187,15 +6167,13 @@ bool IsPopupBlocked(nsIDOMDocument* aDoc)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool blocked = true;
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(aDoc));
|
||||
|
||||
if (doc) {
|
||||
uint32_t permission = nsIPopupWindowManager::ALLOW_POPUP;
|
||||
pm->TestPermission(doc->NodePrincipal(), &permission);
|
||||
blocked = (permission == nsIPopupWindowManager::DENY_POPUP);
|
||||
if (!aDoc) {
|
||||
return true;
|
||||
}
|
||||
return blocked;
|
||||
|
||||
uint32_t permission = nsIPopupWindowManager::ALLOW_POPUP;
|
||||
pm->TestPermission(aDoc->NodePrincipal(), &permission);
|
||||
return permission == nsIPopupWindowManager::DENY_POPUP;
|
||||
}
|
||||
|
||||
/* static */
|
||||
@ -6251,7 +6229,7 @@ nsGlobalWindow::CanSetProperty(const char *aPrefName)
|
||||
bool
|
||||
nsGlobalWindow::PopupWhitelisted()
|
||||
{
|
||||
if (!IsPopupBlocked(mDocument))
|
||||
if (!IsPopupBlocked(mDoc))
|
||||
return true;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> parent;
|
||||
@ -6795,16 +6773,16 @@ PostMessageEvent::Run()
|
||||
}
|
||||
|
||||
// Create the event
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(targetWindow->mDocument);
|
||||
if (!domDoc)
|
||||
nsIDocument* doc = targetWindow->mDoc;
|
||||
if (!doc)
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
domDoc->CreateEvent(NS_LITERAL_STRING("MessageEvent"),
|
||||
getter_AddRefs(event));
|
||||
|
||||
ErrorResult res;
|
||||
nsRefPtr<nsDOMEvent> event = doc->CreateEvent(NS_LITERAL_STRING("MessageEvent"), res);
|
||||
if (!event)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMMessageEvent> message = do_QueryInterface(event);
|
||||
nsCOMPtr<nsIDOMMessageEvent> message = do_QueryObject(event);
|
||||
nsresult rv = message->InitMessageEvent(NS_LITERAL_STRING("message"),
|
||||
false /* non-bubbling */,
|
||||
true /* cancelable */,
|
||||
@ -8733,11 +8711,10 @@ nsGlobalWindow::UpdateCanvasFocus(bool aFocusChanged, nsIContent* aNewContent)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
|
||||
if (!presShell || !mDocument)
|
||||
if (!presShell || !mDoc)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
||||
Element *rootElement = doc->GetRootElement();
|
||||
Element *rootElement = mDoc->GetRootElement();
|
||||
if (rootElement) {
|
||||
if ((mHasFocus || aFocusChanged) &&
|
||||
(mFocusedNode == rootElement || aNewContent == rootElement)) {
|
||||
@ -8875,8 +8852,8 @@ nsGlobalWindow::GetSessionStorage(nsIDOMStorage ** aSessionStorage)
|
||||
*aSessionStorage = nullptr;
|
||||
|
||||
nsString documentURI;
|
||||
if (mDocument) {
|
||||
mDocument->GetDocumentURI(documentURI);
|
||||
if (mDoc) {
|
||||
mDoc->GetDocumentURI(documentURI);
|
||||
}
|
||||
|
||||
// If the document has the sandboxed origin flag set
|
||||
@ -8960,8 +8937,8 @@ nsGlobalWindow::GetLocalStorage(nsIDOMStorage ** aLocalStorage)
|
||||
}
|
||||
|
||||
nsString documentURI;
|
||||
if (mDocument) {
|
||||
mDocument->GetDocumentURI(documentURI);
|
||||
if (mDoc) {
|
||||
mDoc->GetDocumentURI(documentURI);
|
||||
}
|
||||
|
||||
nsIDocShell* docShell = GetDocShell();
|
||||
@ -9116,9 +9093,8 @@ nsGlobalWindow::FireOfflineStatusEvent()
|
||||
}
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDOMElement> documentElement;
|
||||
mDocument->GetDocumentElement(getter_AddRefs(documentElement));
|
||||
if(documentElement) {
|
||||
Element* documentElement = mDoc->GetDocumentElement();
|
||||
if(documentElement) {
|
||||
eventTarget = documentElement;
|
||||
}
|
||||
}
|
||||
@ -10016,7 +9992,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
|
||||
|
||||
// If we don't have a document (we could have been unloaded since
|
||||
// the call to setTimeout was made), do nothing.
|
||||
if (!mDocument) {
|
||||
if (!mDoc) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -10839,8 +10815,8 @@ nsGlobalWindow::BuildURIfromBase(const char *aURL, nsIURI **aBuiltURI,
|
||||
|
||||
// get JSContext
|
||||
NS_ASSERTION(scx, "opening window missing its context");
|
||||
NS_ASSERTION(mDocument, "opening window missing its document");
|
||||
if (!scx || !mDocument)
|
||||
NS_ASSERTION(mDoc, "opening window missing its document");
|
||||
if (!scx || !mDoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMChromeWindow> chrome_win = do_QueryObject(this);
|
||||
|
@ -670,8 +670,7 @@ protected:
|
||||
// value on both the outer window and the current inner window. Make
|
||||
// sure you keep them in sync!
|
||||
nsCOMPtr<mozilla::dom::EventTarget> mChromeEventHandler; // strong
|
||||
nsCOMPtr<nsIDOMDocument> mDocument; // strong
|
||||
nsCOMPtr<nsIDocument> mDoc; // strong, for fast access
|
||||
nsCOMPtr<nsIDocument> mDoc; // strong
|
||||
// Cache the URI when mDoc is cleared.
|
||||
nsCOMPtr<nsIURI> mDocumentURI; // strong
|
||||
nsCOMPtr<nsIURI> mDocBaseURI; // strong
|
||||
|
Loading…
Reference in New Issue
Block a user