diff options
author | Moonchild <moonchild@palemoon.org> | 2019-12-28 10:14:29 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-28 10:14:29 +0000 |
commit | 357405f6356e28e5fa94cecc078b65c20433d236 (patch) | |
tree | 9716965ca2d9d03446fc9290d37e5ef42f80558e /dom/base/nsDocument.cpp | |
parent | f60bbaf9e49733e61aaec675276fcd898ef6bc73 (diff) | |
parent | 8b88623463bf30ae7e5fcc64ef7d8d5fb62354c9 (diff) | |
download | UXP-357405f6356e28e5fa94cecc078b65c20433d236.tar UXP-357405f6356e28e5fa94cecc078b65c20433d236.tar.gz UXP-357405f6356e28e5fa94cecc078b65c20433d236.tar.lz UXP-357405f6356e28e5fa94cecc078b65c20433d236.tar.xz UXP-357405f6356e28e5fa94cecc078b65c20433d236.zip |
Merge pull request #1335 from MoonchildProductions/document_open
Align document.open() with the overhauled specification
Diffstat (limited to 'dom/base/nsDocument.cpp')
-rw-r--r-- | dom/base/nsDocument.cpp | 62 |
1 files changed, 29 insertions, 33 deletions
diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index e2be6b664..afe88a454 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -1968,22 +1968,10 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) } void -nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup, - nsIPrincipal* aPrincipal) -{ - NS_PRECONDITION(aURI, "Null URI passed to ResetToURI"); - - if (gDocumentLeakPRLog && MOZ_LOG_TEST(gDocumentLeakPRLog, LogLevel::Debug)) { - PR_LogPrint("DOCUMENT %p ResetToURI %s", this, - aURI->GetSpecOrDefault().get()); - } - - mSecurityInfo = nullptr; - - mDocumentLoadGroup = nullptr; - +nsDocument::DisconnectNodeTree() { // Delete references to sub-documents and kill the subdocument map, - // if any. It holds strong references + // if any. This is not strictly needed, but makes the node tree + // teardown a bit faster. delete mSubDocuments; mSubDocuments = nullptr; @@ -2019,6 +2007,22 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup, "After removing all children, there should be no root elem"); } mInUnlinkOrDeletion = oldVal; +} + +void +nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup, + nsIPrincipal* aPrincipal) +{ + NS_PRECONDITION(aURI, "Null URI passed to ResetToURI"); + + if (gDocumentLeakPRLog && MOZ_LOG_TEST(gDocumentLeakPRLog, LogLevel::Debug)) { + PR_LogPrint("DOCUMENT %p ResetToURI %s", this, + aURI->GetSpecOrDefault().get()); + } + + mSecurityInfo = nullptr; + + mDocumentLoadGroup = nullptr; // Reset our stylesheets ResetStylesheetsToURI(aURI); @@ -2029,6 +2033,8 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup, mListenerManager = nullptr; } + DisconnectNodeTree(); + // Release the stylesheets list. mDOMStyleSheets = nullptr; @@ -4506,18 +4512,6 @@ nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject) mLayoutHistoryState = nullptr; SetScopeObject(aScriptGlobalObject); mHasHadDefaultView = true; -#ifdef DEBUG - if (!mWillReparent) { - // We really shouldn't have a wrapper here but if we do we need to make sure - // it has the correct parent. - JSObject *obj = GetWrapperPreserveColor(); - if (obj) { - JSObject *newScope = aScriptGlobalObject->GetGlobalJSObject(); - NS_ASSERTION(js::GetGlobalForObjectCrossCompartment(obj) == newScope, - "Wrong scope, this is really bad!"); - } - } -#endif if (mAllowDNSPrefetch) { nsCOMPtr<nsIDocShell> docShell(mDocumentContainer); @@ -9077,7 +9071,8 @@ nsDocument::CloneDocHelper(nsDocument* clone) const } void -nsDocument::SetReadyStateInternal(ReadyState rs) +nsDocument::SetReadyStateInternal(ReadyState rs, + bool updateTimingInformation) { mReadyState = rs; if (rs == READYSTATE_UNINITIALIZED) { @@ -9086,7 +9081,12 @@ nsDocument::SetReadyStateInternal(ReadyState rs) // transition undetectable by Web content. return; } - if (mTiming) { + + if (updateTimingInformation && READYSTATE_LOADING == rs) { + mLoadingTimeStamp = mozilla::TimeStamp::Now(); + } + + if (updateTimingInformation && mTiming) { switch (rs) { case READYSTATE_LOADING: mTiming->NotifyDOMLoading(nsIDocument::GetDocumentURI()); @@ -9102,10 +9102,6 @@ nsDocument::SetReadyStateInternal(ReadyState rs) break; } } - // At the time of loading start, we don't have timing object, record time. - if (READYSTATE_LOADING == rs) { - mLoadingTimeStamp = mozilla::TimeStamp::Now(); - } RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher(this, NS_LITERAL_STRING("readystatechange"), |