Merge mozilla-central to autoland.

This commit is contained in:
Cosmin Sabou 2018-12-30 11:36:05 +02:00
commit b0fa448775
56 changed files with 463 additions and 581 deletions

View File

@ -11066,14 +11066,7 @@ nsDocShell::AddState(JS::Handle<JS::Value> aData, const nsAString& aTitle,
}
} else {
// It's a file:// URI
nsCOMPtr<nsIScriptObjectPrincipal> docScriptObj =
do_QueryInterface(document);
if (!docScriptObj) {
return NS_ERROR_DOM_SECURITY_ERR;
}
nsCOMPtr<nsIPrincipal> principal = docScriptObj->GetPrincipal();
nsCOMPtr<nsIPrincipal> principal = document->GetPrincipal();
if (!principal ||
NS_FAILED(principal->CheckMayLoad(newURI, true, false))) {

View File

@ -41,7 +41,7 @@ class AnimationEffect : public nsISupports, public nsWrapperCache {
return nullptr;
}
nsISupports* GetParentObject() const { return mDocument; }
nsISupports* GetParentObject() const { return ToSupports(mDocument); }
bool IsCurrent() const;
bool IsInEffect() const;

View File

@ -11,6 +11,8 @@
namespace mozilla {
namespace dom {
AnimationTimeline::~AnimationTimeline() { mAnimationOrder.clear(); }
NS_IMPL_CYCLE_COLLECTION_CLASS(AnimationTimeline)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(AnimationTimeline)

View File

@ -31,7 +31,7 @@ class AnimationTimeline : public nsISupports, public nsWrapperCache {
}
protected:
virtual ~AnimationTimeline() { mAnimationOrder.clear(); }
virtual ~AnimationTimeline();
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS

View File

@ -19,6 +19,7 @@
#include "mozilla/dom/Attr.h"
#include "mozilla/dom/Flex.h"
#include "mozilla/dom/Grid.h"
#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/Text.h"
#include "mozilla/gfx/Matrix.h"
#include "nsAtom.h"

View File

@ -31,6 +31,7 @@
#include "nsAtom.h"
#include "mozilla/dom/NodeInfo.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/TouchEvent.h"
#include "nsIDocumentInlines.h"
#include "nsIDocumentEncoder.h"

View File

@ -911,11 +911,6 @@ nsresult nsContentSink::SelectDocAppCache(
*aAction = CACHE_SELECTION_NONE;
nsCOMPtr<nsIApplicationCacheContainer> applicationCacheDocument =
do_QueryInterface(mDocument);
NS_ASSERTION(applicationCacheDocument,
"mDocument must implement nsIApplicationCacheContainer.");
if (aLoadApplicationCache) {
nsCOMPtr<nsIURI> groupURI;
rv = aLoadApplicationCache->GetManifestURI(getter_AddRefs(groupURI));
@ -944,7 +939,7 @@ nsresult nsContentSink::SelectDocAppCache(
clientID.get(), docURISpec.get()));
#endif
rv = applicationCacheDocument->SetApplicationCache(aLoadApplicationCache);
rv = mDocument->SetApplicationCache(aLoadApplicationCache);
NS_ENSURE_SUCCESS(rv, rv);
// Document will be added as implicit entry to the cache as part of
@ -981,11 +976,6 @@ nsresult nsContentSink::SelectDocAppCacheNoManifest(
if (aLoadApplicationCache) {
// The document was loaded from an application cache, use that
// application cache as the document's application cache.
nsCOMPtr<nsIApplicationCacheContainer> applicationCacheDocument =
do_QueryInterface(mDocument);
NS_ASSERTION(applicationCacheDocument,
"mDocument must implement nsIApplicationCacheContainer.");
#ifdef DEBUG
nsAutoCString docURISpec, clientID;
mDocumentURI->GetAsciiSpec(docURISpec);
@ -996,7 +986,7 @@ nsresult nsContentSink::SelectDocAppCacheNoManifest(
clientID.get(), docURISpec.get()));
#endif
rv = applicationCacheDocument->SetApplicationCache(aLoadApplicationCache);
rv = mDocument->SetApplicationCache(aLoadApplicationCache);
NS_ENSURE_SUCCESS(rv, rv);
// Return the uri and invoke the update process for the selected
@ -1563,13 +1553,13 @@ void nsContentSink::NotifyDocElementCreated(nsIDocument* aDoc) {
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService) {
observerService->NotifyObservers(aDoc, "document-element-inserted",
EmptyString().get());
observerService->NotifyObservers(
ToSupports(aDoc), "document-element-inserted", EmptyString().get());
}
nsContentUtils::DispatchChromeEvent(
aDoc, aDoc, NS_LITERAL_STRING("DOMDocElementInserted"), CanBubble::eYes,
Cancelable::eNo);
aDoc, ToSupports(aDoc), NS_LITERAL_STRING("DOMDocElementInserted"),
CanBubble::eYes, Cancelable::eNo);
}
NS_IMETHODIMP

View File

@ -9,6 +9,7 @@
#include "mozilla/layers/CompositorBridgeChild.h"
#include "mozilla/layers/LayerTransactionChild.h"
#include "nsPresContext.h"
#include "nsContentList.h"
#include "nsError.h"
#include "nsQueryContentEventResult.h"
#include "nsGlobalWindow.h"

View File

@ -43,6 +43,7 @@
#include "nsCSSPseudoElements.h"
#include "nsIObserver.h"
#include "nsIBaseWindow.h"
#include "nsILayoutHistoryState.h"
#include "mozilla/css/Loader.h"
#include "mozilla/css/ImageLoader.h"
#include "nsDocShell.h"
@ -59,6 +60,7 @@
#include "mozilla/EventListenerManager.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/FullscreenChange.h"
#include "mozilla/PendingAnimationTracker.h"
#include "mozilla/dom/Attr.h"
#include "mozilla/dom/BindingDeclarations.h"
@ -69,7 +71,10 @@
#include "mozilla/dom/FramingChecker.h"
#include "mozilla/dom/HTMLSharedElement.h"
#include "mozilla/dom/Navigator.h"
#include "mozilla/dom/Performance.h"
#include "mozilla/dom/ServiceWorkerContainer.h"
#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/StyleSheetList.h"
#include "mozilla/dom/SVGUseElement.h"
#include "nsGenericHTMLElement.h"
#include "mozilla/dom/CDATASection.h"
@ -673,7 +678,17 @@ class SubDocMapEntry : public PLDHashEntryHdr {
nsIDocument* mSubDocument;
};
// nsOnloadBlocker implementation
class nsOnloadBlocker final : public nsIRequest {
public:
nsOnloadBlocker() {}
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUEST
private:
~nsOnloadBlocker() {}
};
NS_IMPL_ISUPPORTS(nsOnloadBlocker, nsIRequest)
NS_IMETHODIMP
@ -792,7 +807,7 @@ void nsExternalResourceMap::Traverse(
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*aCallback,
"mExternalResourceMap.mMap entry"
"->mDocument");
aCallback->NoteXPCOMChild(resource->mDocument);
aCallback->NoteXPCOMChild(ToSupports(resource->mDocument));
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*aCallback,
"mExternalResourceMap.mMap entry"
@ -899,7 +914,8 @@ nsresult nsExternalResourceMap::AddExternalResource(
const nsTArray<nsCOMPtr<nsIObserver>>& obs = load->Observers();
for (uint32_t i = 0; i < obs.Length(); ++i) {
obs[i]->Observe(doc, "external-resource-document-created", nullptr);
obs[i]->Observe(ToSupports(doc), "external-resource-document-created",
nullptr);
}
return rv;
@ -1624,31 +1640,31 @@ nsDocument::~nsDocument() {
mPlugins.Clear();
}
NS_INTERFACE_TABLE_HEAD(nsDocument)
NS_INTERFACE_TABLE_HEAD(nsIDocument)
NS_WRAPPERCACHE_INTERFACE_TABLE_ENTRY
NS_INTERFACE_TABLE_BEGIN
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(nsDocument, nsISupports, nsINode)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsINode)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDocument)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIScriptObjectPrincipal)
NS_INTERFACE_TABLE_ENTRY(nsDocument, mozilla::dom::EventTarget)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsISupportsWeakReference)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIRadioGroupContainer)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIMutationObserver)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIApplicationCacheContainer)
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(nsIDocument, nsISupports, nsINode)
NS_INTERFACE_TABLE_ENTRY(nsIDocument, nsINode)
NS_INTERFACE_TABLE_ENTRY(nsIDocument, nsIDocument)
NS_INTERFACE_TABLE_ENTRY(nsIDocument, nsIScriptObjectPrincipal)
NS_INTERFACE_TABLE_ENTRY(nsIDocument, mozilla::dom::EventTarget)
NS_INTERFACE_TABLE_ENTRY(nsIDocument, nsISupportsWeakReference)
NS_INTERFACE_TABLE_ENTRY(nsIDocument, nsIRadioGroupContainer)
NS_INTERFACE_TABLE_ENTRY(nsIDocument, nsIMutationObserver)
NS_INTERFACE_TABLE_ENTRY(nsIDocument, nsIApplicationCacheContainer)
NS_INTERFACE_TABLE_END
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsDocument)
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsIDocument)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDocument)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsIDocument)
NS_IMETHODIMP_(MozExternalRefCountType)
nsDocument::Release() {
nsIDocument::Release() {
MOZ_ASSERT(0 != mRefCnt, "dup release");
NS_ASSERT_OWNINGTHREAD(nsDocument);
nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(nsDocument)::Upcast(this);
NS_ASSERT_OWNINGTHREAD(nsIDocument);
nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(nsIDocument)::Upcast(this);
bool shouldDelete = false;
nsrefcnt count = mRefCnt.decr(base, &shouldDelete);
NS_LOG_RELEASE(this, count, "nsDocument");
NS_LOG_RELEASE(this, count, "nsIDocument");
if (count == 0) {
if (mStackRefCnt && !mNeedsReleaseAfterStackRefCntRelease) {
mNeedsReleaseAfterStackRefCntRelease = true;
@ -1667,9 +1683,9 @@ nsDocument::Release() {
}
NS_IMETHODIMP_(void)
nsDocument::DeleteCycleCollectable() { delete this; }
nsIDocument::DeleteCycleCollectable() { delete this; }
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsDocument)
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsIDocument)
if (Element::CanSkip(tmp, aRemovingAllowed)) {
EventListenerManager* elm = tmp->GetExistingListenerManager();
if (elm) {
@ -1679,11 +1695,11 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsDocument)
}
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(nsDocument)
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(nsIDocument)
return Element::CanSkipInCC(tmp);
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsDocument)
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsIDocument)
return Element::CanSkipThis(tmp);
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
@ -1691,7 +1707,7 @@ static const char* kNSURIs[] = {"([none])", "(xmlns)", "(xml)", "(xhtml)",
"(XLink)", "(XSLT)", "(XBL)", "(MathML)",
"(RDF)", "(XUL)"};
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsIDocument)
if (MOZ_UNLIKELY(cb.WantDebugInfo())) {
char name[512];
nsAutoCString loadedAsData;
@ -1704,14 +1720,14 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
nsAutoCString uri;
if (tmp->mDocumentURI) uri = tmp->mDocumentURI->GetSpecOrDefault();
if (nsid < ArrayLength(kNSURIs)) {
SprintfLiteral(name, "nsDocument %s %s %s", loadedAsData.get(),
SprintfLiteral(name, "nsIDocument %s %s %s", loadedAsData.get(),
kNSURIs[nsid], uri.get());
} else {
SprintfLiteral(name, "nsDocument %s %s", loadedAsData.get(), uri.get());
SprintfLiteral(name, "nsIDocument %s %s", loadedAsData.get(), uri.get());
}
cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
} else {
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsDocument, tmp->mRefCnt.get())
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsIDocument, tmp->mRefCnt.get())
}
if (!nsINode::Traverse(tmp, cb)) {
@ -1760,7 +1776,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChannel)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLayoutHistoryState)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOnloadBlocker)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFirstBaseNodeWithHref)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDOMImplementation)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mImageMaps)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOrientationPendingPromise)
@ -1804,7 +1819,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
cb.NoteXPCOMChild(entry->mKey);
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb,
"mSubDocuments entry->mSubDocument");
cb.NoteXPCOMChild(entry->mSubDocument);
cb.NoteXPCOMChild(ToSupports(entry->mSubDocument));
}
}
@ -1823,11 +1838,11 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDocument)
NS_IMPL_CYCLE_COLLECTION_CLASS(nsIDocument)
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(nsDocument)
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(nsIDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsIDocument)
tmp->mInUnlinkOrDeletion = true;
// Clear out our external resources
@ -1840,7 +1855,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
while (tmp->HasChildren()) {
// Hold a strong ref to the node when we remove it, because we may be
// the last reference to it.
// If this code changes, change the corresponding code in nsDocument's
// If this code changes, change the corresponding code in nsIDocument's
// unlink impl and ContentUnbinder::UnbindSubtree.
nsCOMPtr<nsIContent> child = tmp->GetLastChild();
tmp->DisconnectChild(child);
@ -1851,7 +1866,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
tmp->mCachedRootElement = nullptr; // Avoid a dangling pointer
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDisplayDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFirstBaseNodeWithHref)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMaybeEndOutermostXBLUpdateRunner)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDOMImplementation)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mImageMaps)
@ -1905,7 +1919,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
DocumentOrShadowRoot::Unlink(tmp);
// nsDocument has a pretty complex destructor, so we're going to
// nsIDocument has a pretty complex destructor, so we're going to
// assume that *most* cycles you actually want to break somewhere
// else, and not unlink an awful lot here.
@ -1936,7 +1950,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
tmp->mInUnlinkOrDeletion = false;
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
nsresult nsDocument::Init() {
nsresult nsIDocument::Init() {
if (mCSSLoader || mStyleImageLoader || mNodeInfoManager || mScriptLoader) {
return NS_ERROR_ALREADY_INITIALIZED;
}
@ -2461,18 +2475,18 @@ bool nsIDocument::IsSynthesized() {
}
// static
bool nsDocument::IsCallerChromeOrAddon(JSContext* aCx, JSObject* aObject) {
bool nsIDocument::IsCallerChromeOrAddon(JSContext* aCx, JSObject* aObject) {
nsIPrincipal* principal = nsContentUtils::SubjectPrincipal(aCx);
return principal && (nsContentUtils::IsSystemPrincipal(principal) ||
principal->GetIsAddonOrExpandedAddonPrincipal());
}
nsresult nsDocument::StartDocumentLoad(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
nsIStreamListener** aDocListener,
bool aReset, nsIContentSink* aSink) {
nsresult nsIDocument::StartDocumentLoad(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
nsIStreamListener** aDocListener,
bool aReset, nsIContentSink* aSink) {
if (MOZ_LOG_TEST(gDocumentLeakPRLog, LogLevel::Debug)) {
nsCOMPtr<nsIURI> uri;
aChannel->GetURI(getter_AddRefs(uri));
@ -2870,7 +2884,7 @@ nsresult nsIDocument::InitFeaturePolicy(nsIChannel* aChannel) {
return NS_OK;
}
void nsDocument::StopDocumentLoad() {
void nsIDocument::StopDocumentLoad() {
if (mParser) {
mParserAborted = true;
mParser->Terminate();
@ -2936,7 +2950,7 @@ void nsIDocument::GetLastModified(nsAString& aLastModified) const {
}
static void IncrementExpandoGeneration(nsIDocument& aDoc) {
++static_cast<nsDocument&>(aDoc).mExpandoAndGeneration.generation;
++aDoc.mExpandoAndGeneration.generation;
}
void nsIDocument::AddToNameTable(Element* aElement, nsAtom* aName) {
@ -3008,8 +3022,6 @@ void nsIDocument::RemoveFromIdTable(Element* aElement, nsAtom* aId) {
}
}
nsIPrincipal* nsDocument::GetPrincipal() { return NodePrincipal(); }
extern bool sDisablePrefetchHTTPSPref;
void nsIDocument::SetPrincipal(nsIPrincipal* aNewPrincipal) {
@ -3096,16 +3108,14 @@ bool nsIDocument::IsScriptTracking(const nsACString& aURL) const {
}
NS_IMETHODIMP
nsDocument::GetApplicationCache(nsIApplicationCache** aApplicationCache) {
nsIDocument::GetApplicationCache(nsIApplicationCache** aApplicationCache) {
NS_IF_ADDREF(*aApplicationCache = mApplicationCache);
return NS_OK;
}
NS_IMETHODIMP
nsDocument::SetApplicationCache(nsIApplicationCache* aApplicationCache) {
nsIDocument::SetApplicationCache(nsIApplicationCache* aApplicationCache) {
mApplicationCache = aApplicationCache;
return NS_OK;
}
@ -3153,7 +3163,7 @@ void nsIDocument::InitializeLocalization(nsTArray<nsString>& aResourceIds) {
DocumentL10n* nsIDocument::GetL10n() { return mDocumentL10n; }
bool nsDocument::DocumentSupportsL10n(JSContext* aCx, JSObject* aObject) {
bool nsIDocument::DocumentSupportsL10n(JSContext* aCx, JSObject* aObject) {
nsCOMPtr<nsIPrincipal> callerPrincipal =
nsContentUtils::SubjectPrincipal(aCx);
return PrincipalAllowsL10n(callerPrincipal);
@ -3232,22 +3242,22 @@ void nsIDocument::TriggerInitialDocumentTranslation() {
}
}
bool nsDocument::IsWebAnimationsEnabled(JSContext* aCx, JSObject* /*unused*/) {
bool nsIDocument::IsWebAnimationsEnabled(JSContext* aCx, JSObject* /*unused*/) {
MOZ_ASSERT(NS_IsMainThread());
return nsContentUtils::IsSystemCaller(aCx) ||
nsContentUtils::AnimationsAPICoreEnabled();
}
bool nsDocument::IsWebAnimationsEnabled(CallerType aCallerType) {
bool nsIDocument::IsWebAnimationsEnabled(CallerType aCallerType) {
MOZ_ASSERT(NS_IsMainThread());
return aCallerType == dom::CallerType::System ||
nsContentUtils::AnimationsAPICoreEnabled();
}
bool nsDocument::IsWebAnimationsGetAnimationsEnabled(JSContext* aCx,
JSObject* /*unused*/
bool nsIDocument::IsWebAnimationsGetAnimationsEnabled(JSContext* aCx,
JSObject* /*unused*/
) {
MOZ_ASSERT(NS_IsMainThread());
@ -3255,8 +3265,8 @@ bool nsDocument::IsWebAnimationsGetAnimationsEnabled(JSContext* aCx,
StaticPrefs::dom_animations_api_getAnimations_enabled();
}
bool nsDocument::AreWebAnimationsImplicitKeyframesEnabled(JSContext* aCx,
JSObject* /*unused*/
bool nsIDocument::AreWebAnimationsImplicitKeyframesEnabled(JSContext* aCx,
JSObject* /*unused*/
) {
MOZ_ASSERT(NS_IsMainThread());
@ -3264,8 +3274,8 @@ bool nsDocument::AreWebAnimationsImplicitKeyframesEnabled(JSContext* aCx,
StaticPrefs::dom_animations_api_implicit_keyframes_enabled();
}
bool nsDocument::AreWebAnimationsTimelinesEnabled(JSContext* aCx,
JSObject* /*unused*/
bool nsIDocument::AreWebAnimationsTimelinesEnabled(JSContext* aCx,
JSObject* /*unused*/
) {
MOZ_ASSERT(NS_IsMainThread());
@ -3580,10 +3590,10 @@ void nsIDocument::SetHeaderData(nsAtom* aHeaderField, const nsAString& aData) {
}
}
}
void nsDocument::TryChannelCharset(nsIChannel* aChannel,
int32_t& aCharsetSource,
NotNull<const Encoding*>& aEncoding,
nsHtml5TreeOpExecutor* aExecutor) {
void nsIDocument::TryChannelCharset(nsIChannel* aChannel,
int32_t& aCharsetSource,
NotNull<const Encoding*>& aEncoding,
nsHtml5TreeOpExecutor* aExecutor) {
if (aChannel) {
nsAutoCString charsetVal;
nsresult rv = aChannel->GetContentCharset(charsetVal);
@ -4094,7 +4104,7 @@ void nsIDocument::NotifyStyleSheetApplicableStateChanged() {
mozilla::services::GetObserverService();
if (observerService) {
observerService->NotifyObservers(
this, "style-sheet-applicable-state-changed", nullptr);
ToSupports(this), "style-sheet-applicable-state-changed", nullptr);
}
}
@ -4345,10 +4355,10 @@ void nsIDocument::SetContainer(nsDocShell* aContainer) {
"No document shell root tree item from document shell tree item!");
if (sameTypeRoot == aContainer) {
static_cast<nsDocument*>(this)->SetIsTopLevelContentDocument(true);
SetIsTopLevelContentDocument(true);
}
static_cast<nsDocument*>(this)->SetIsContentDocument(true);
SetIsContentDocument(true);
}
mAncestorPrincipals = aContainer->AncestorPrincipals();
@ -4636,7 +4646,7 @@ void nsIDocument::BeginUpdate() {
NS_DOCUMENT_NOTIFY_OBSERVERS(BeginUpdate, (this));
}
void nsDocument::EndUpdate() {
void nsIDocument::EndUpdate() {
NS_DOCUMENT_NOTIFY_OBSERVERS(EndUpdate, (this));
nsContentUtils::RemoveScriptBlocker();
@ -4653,7 +4663,7 @@ void nsDocument::EndUpdate() {
}
}
void nsDocument::BeginLoad() {
void nsIDocument::BeginLoad() {
MOZ_ASSERT(!mDidCallBeginLoad);
mDidCallBeginLoad = true;
@ -4706,7 +4716,7 @@ void nsIDocument::DispatchContentLoadedEvents() {
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os) {
nsIPrincipal* principal = NodePrincipal();
os->NotifyObservers(this,
os->NotifyObservers(ToSupports(this),
nsContentUtils::IsSystemPrincipal(principal)
? "chrome-document-interactive"
: "content-document-interactive",
@ -4716,7 +4726,7 @@ void nsIDocument::DispatchContentLoadedEvents() {
// Fire a DOM event notifying listeners that this document has been
// loaded (excluding images and other loads initiated by this
// document).
nsContentUtils::DispatchTrustedEvent(this, this,
nsContentUtils::DispatchTrustedEvent(this, ToSupports(this),
NS_LITERAL_STRING("DOMContentLoaded"),
CanBubble::eYes, Cancelable::eNo);
@ -4787,11 +4797,9 @@ void nsIDocument::DispatchContentLoadedEvents() {
if (innerEvent) {
nsEventStatus status = nsEventStatus_eIgnore;
RefPtr<nsPresContext> context = parent->GetPresContext();
if (context) {
EventDispatcher::Dispatch(parent, context, innerEvent, event,
&status);
if (RefPtr<nsPresContext> context = parent->GetPresContext()) {
EventDispatcher::Dispatch(ToSupports(parent), context, innerEvent,
event, &status);
}
}
}
@ -4805,7 +4813,7 @@ void nsIDocument::DispatchContentLoadedEvents() {
Element* root = GetRootElement();
if (root && root->HasAttr(kNameSpaceID_None, nsGkAtoms::manifest)) {
nsContentUtils::DispatchChromeEvent(
this, this, NS_LITERAL_STRING("MozApplicationManifest"),
this, ToSupports(this), NS_LITERAL_STRING("MozApplicationManifest"),
CanBubble::eYes, Cancelable::eYes);
}
@ -4904,7 +4912,7 @@ static void AssertAboutPageHasCSP(nsIURI* aDocumentURI,
}
#endif
void nsDocument::EndLoad() {
void nsIDocument::EndLoad() {
#if defined(DEBUG) && !defined(ANDROID)
// only assert if nothing stopped the load on purpose
if (!mParserAborted) {
@ -5920,7 +5928,7 @@ void nsIDocument::DoNotifyPossibleTitleChange() {
}
// Fire a DOM event for the title change.
nsContentUtils::DispatchChromeEvent(this, static_cast<nsIDocument*>(this),
nsContentUtils::DispatchChromeEvent(this, ToSupports(this),
NS_LITERAL_STRING("DOMTitleChanged"),
CanBubble::eYes, Cancelable::eYes);
}
@ -6491,7 +6499,7 @@ nsINode* nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv) {
// canonical scope. But we try to pass something sane anyway.
JSAutoRealm ar(cx, GetScopeObject()->GetGlobalJSObject());
JS::Rooted<JS::Value> v(cx);
rv = nsContentUtils::WrapNative(cx, this, this, &v,
rv = nsContentUtils::WrapNative(cx, ToSupports(this), this, &v,
/* aAllowWrapping = */ false);
if (rv.Failed()) return nullptr;
newScope = &v.toObject();
@ -6975,7 +6983,7 @@ void nsIDocument::UpdateViewportOverflowType(nscoord aScrolledWidth,
}
}
EventListenerManager* nsDocument::GetOrCreateListenerManager() {
EventListenerManager* nsIDocument::GetOrCreateListenerManager() {
if (!mListenerManager) {
mListenerManager =
new EventListenerManager(static_cast<EventTarget*>(this));
@ -6985,11 +6993,11 @@ EventListenerManager* nsDocument::GetOrCreateListenerManager() {
return mListenerManager;
}
EventListenerManager* nsDocument::GetExistingListenerManager() const {
EventListenerManager* nsIDocument::GetExistingListenerManager() const {
return mListenerManager;
}
void nsDocument::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
void nsIDocument::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
if (mDocGroup && aVisitor.mEvent->mMessage != eVoidEvent &&
!mIgnoreDocGroupMismatches) {
mDocGroup->ValidateAccess();
@ -7032,6 +7040,17 @@ void nsIDocument::FlushPendingNotifications(FlushType aType) {
FlushPendingNotifications(flush);
}
class nsDocumentOnStack {
public:
explicit nsDocumentOnStack(nsIDocument* aDoc) : mDoc(aDoc) {
mDoc->IncreaseStackRefCnt();
}
~nsDocumentOnStack() { mDoc->DecreaseStackRefCnt(); }
private:
nsIDocument* mDoc;
};
void nsIDocument::FlushPendingNotifications(mozilla::ChangesToFlush aFlush) {
FlushType flushType = aFlush.mFlushType;
@ -7179,7 +7198,7 @@ bool nsIDocument::IsScriptEnabled() {
return xpc::Scriptability::Get(globalObject->GetGlobalJSObject()).Allowed();
}
void nsDocument::RetrieveRelevantHeaders(nsIChannel* aChannel) {
void nsIDocument::RetrieveRelevantHeaders(nsIChannel* aChannel) {
PRTime modDate = 0;
nsresult rv;
@ -7512,7 +7531,7 @@ bool nsIDocument::CanSavePresentation(nsIRequest* aNewRequest) {
return true;
}
void nsDocument::Destroy() {
void nsIDocument::Destroy() {
// The ContentViewer wants to release the document now. So, tell our content
// to drop any references to the document so that it can be destroyed.
if (mIsGoingAway) return;
@ -7547,7 +7566,7 @@ void nsDocument::Destroy() {
mExternalResourceMap.Shutdown();
}
void nsDocument::RemovedFromDocShell() {
void nsIDocument::RemovedFromDocShell() {
if (mRemovedFromDocShell) return;
mRemovedFromDocShell = true;
@ -7600,14 +7619,14 @@ void nsIDocument::EnsureOnloadBlocker() {
}
}
void nsDocument::AsyncBlockOnload() {
void nsIDocument::AsyncBlockOnload() {
while (mAsyncOnloadBlockCount) {
--mAsyncOnloadBlockCount;
BlockOnload();
}
}
void nsDocument::BlockOnload() {
void nsIDocument::BlockOnload() {
if (mDisplayDocument) {
mDisplayDocument->BlockOnload();
return;
@ -7622,8 +7641,8 @@ void nsDocument::BlockOnload() {
++mAsyncOnloadBlockCount;
if (mAsyncOnloadBlockCount == 1) {
nsContentUtils::AddScriptRunner(
NewRunnableMethod("nsDocument::AsyncBlockOnload", this,
&nsDocument::AsyncBlockOnload));
NewRunnableMethod("nsIDocument::AsyncBlockOnload", this,
&nsIDocument::AsyncBlockOnload));
}
return;
}
@ -7635,7 +7654,7 @@ void nsDocument::BlockOnload() {
++mOnloadBlockCount;
}
void nsDocument::UnblockOnload(bool aFireSync) {
void nsIDocument::UnblockOnload(bool aFireSync) {
if (mDisplayDocument) {
mDisplayDocument->UnblockOnload(aFireSync);
return;
@ -7823,7 +7842,7 @@ void nsIDocument::OnPageShow(bool aPersisted, EventTarget* aDispatchStartTarget,
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os) {
nsIPrincipal* principal = NodePrincipal();
os->NotifyObservers(this,
os->NotifyObservers(ToSupports(this),
nsContentUtils::IsSystemPrincipal(principal)
? "chrome-page-shown"
: "content-page-shown",
@ -7920,7 +7939,7 @@ void nsIDocument::OnPageHide(bool aPersisted, EventTarget* aDispatchStartTarget,
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os) {
nsIPrincipal* principal = NodePrincipal();
os->NotifyObservers(this,
os->NotifyObservers(ToSupports(this),
nsContentUtils::IsSystemPrincipal(principal)
? "chrome-page-hidden"
: "content-page-hidden",
@ -8066,7 +8085,7 @@ void nsIDocument::RefreshLinkHrefs() {
}
}
nsresult nsDocument::CloneDocHelper(nsDocument* clone) const {
nsresult nsIDocument::CloneDocHelper(nsIDocument* clone) const {
clone->mIsStaticDocument = mCreatingStaticClone;
// Init document
@ -8103,7 +8122,7 @@ nsresult nsDocument::CloneDocHelper(nsDocument* clone) const {
// information came from the channel. So we override explicitly, and do it
// for all these properties, in case ResetToURI messes with any of the rest of
// them.
clone->nsDocument::SetDocumentURI(nsIDocument::GetDocumentURI());
clone->SetDocumentURI(nsIDocument::GetDocumentURI());
clone->SetChromeXHRDocURI(mChromeXHRDocURI);
clone->SetPrincipal(NodePrincipal());
clone->mDocumentBaseURI = mDocumentBaseURI;
@ -10887,7 +10906,7 @@ void nsIDocument::UpdateVisibilityState() {
dom::VisibilityState oldState = mVisibilityState;
mVisibilityState = ComputeVisibilityState();
if (oldState != mVisibilityState) {
nsContentUtils::DispatchTrustedEvent(this, static_cast<nsIDocument*>(this),
nsContentUtils::DispatchTrustedEvent(this, ToSupports(this),
NS_LITERAL_STRING("visibilitychange"),
CanBubble::eYes, Cancelable::eNo);
EnumerateActivityObservers(NotifyActivityChanged, nullptr);
@ -10929,32 +10948,63 @@ void nsIDocument::MaybeActiveMediaComponents() {
GetWindow()->MaybeActiveMediaComponents();
}
/* virtual */ void nsIDocument::DocAddSizeOfExcludingThis(
nsWindowSizes& aSizes) const {
if (mPresShell) {
mPresShell->AddSizeOfIncludingThis(aSizes);
void nsIDocument::DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const {
nsINode::AddSizeOfExcludingThis(aWindowSizes, &aWindowSizes.mDOMOtherSize);
for (nsIContent* kid = GetFirstChild(); kid; kid = kid->GetNextSibling()) {
AddSizeOfNodeTree(*kid, aWindowSizes);
}
aSizes.mPropertyTablesSize +=
mPropertyTable.SizeOfExcludingThis(aSizes.mState.mMallocSizeOf);
// IMPORTANT: for our ComputedValues measurements, we want to measure
// ComputedValues accessible from DOM elements before ComputedValues not
// accessible from DOM elements (i.e. accessible only from the frame tree).
//
// Therefore, the measurement of the nsIDocument superclass must happen after
// the measurement of DOM nodes (above), because nsIDocument contains the
// PresShell, which contains the frame tree.
if (mPresShell) {
mPresShell->AddSizeOfIncludingThis(aWindowSizes);
}
aWindowSizes.mPropertyTablesSize +=
mPropertyTable.SizeOfExcludingThis(aWindowSizes.mState.mMallocSizeOf);
if (EventListenerManager* elm = GetExistingListenerManager()) {
aSizes.mDOMEventListenersCount += elm->ListenerCount();
aWindowSizes.mDOMEventListenersCount += elm->ListenerCount();
}
if (mNodeInfoManager) {
mNodeInfoManager->AddSizeOfIncludingThis(aSizes);
mNodeInfoManager->AddSizeOfIncludingThis(aWindowSizes);
}
aSizes.mDOMMediaQueryLists +=
mDOMMediaQueryLists.sizeOfExcludingThis(aSizes.mState.mMallocSizeOf);
aWindowSizes.mDOMMediaQueryLists += mDOMMediaQueryLists.sizeOfExcludingThis(
aWindowSizes.mState.mMallocSizeOf);
for (const MediaQueryList* mql : mDOMMediaQueryLists) {
aSizes.mDOMMediaQueryLists +=
mql->SizeOfExcludingThis(aSizes.mState.mMallocSizeOf);
aWindowSizes.mDOMMediaQueryLists +=
mql->SizeOfExcludingThis(aWindowSizes.mState.mMallocSizeOf);
}
mContentBlockingLog.AddSizeOfExcludingThis(aSizes);
mContentBlockingLog.AddSizeOfExcludingThis(aWindowSizes);
DocumentOrShadowRoot::AddSizeOfExcludingThis(aWindowSizes);
for (auto& sheetArray : mAdditionalSheets) {
AddSizeOfOwnedSheetArrayExcludingThis(aWindowSizes, sheetArray);
}
// Lumping in the loader with the style-sheets size is not ideal,
// but most of the things in there are in fact stylesheets, so it
// doesn't seem worthwhile to separate it out.
aWindowSizes.mLayoutStyleSheetsSize +=
CSSLoader()->SizeOfIncludingThis(aWindowSizes.mState.mMallocSizeOf);
aWindowSizes.mDOMOtherSize += mAttrStyleSheet
? mAttrStyleSheet->DOMSizeOfIncludingThis(
aWindowSizes.mState.mMallocSizeOf)
: 0;
aWindowSizes.mDOMOtherSize += mStyledLinks.ShallowSizeOfExcludingThis(
aWindowSizes.mState.mMallocSizeOf);
// Measurement of the following members may be added later if DMD finds it
// is worthwhile:
@ -10966,8 +11016,8 @@ void nsIDocument::DocAddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const {
DocAddSizeOfExcludingThis(aWindowSizes);
}
void nsDocument::AddSizeOfExcludingThis(nsWindowSizes& aSizes,
size_t* aNodeSize) const {
void nsIDocument::AddSizeOfExcludingThis(nsWindowSizes& aSizes,
size_t* aNodeSize) const {
// This AddSizeOfExcludingThis() overrides the one from nsINode. But
// nsDocuments can only appear at the top of the DOM tree, and we use the
// specialized DocAddSizeOfExcludingThis() in that case. So this should never
@ -11036,45 +11086,6 @@ void nsDocument::AddSizeOfExcludingThis(nsWindowSizes& aSizes,
}
}
void nsDocument::DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const {
nsINode::AddSizeOfExcludingThis(aWindowSizes, &aWindowSizes.mDOMOtherSize);
for (nsIContent* kid = GetFirstChild(); kid; kid = kid->GetNextSibling()) {
AddSizeOfNodeTree(*kid, aWindowSizes);
}
// IMPORTANT: for our ComputedValues measurements, we want to measure
// ComputedValues accessible from DOM elements before ComputedValues not
// accessible from DOM elements (i.e. accessible only from the frame tree).
//
// Therefore, the measurement of the nsIDocument superclass must happen after
// the measurement of DOM nodes (above), because nsIDocument contains the
// PresShell, which contains the frame tree.
nsIDocument::DocAddSizeOfExcludingThis(aWindowSizes);
DocumentOrShadowRoot::AddSizeOfExcludingThis(aWindowSizes);
for (auto& sheetArray : mAdditionalSheets) {
AddSizeOfOwnedSheetArrayExcludingThis(aWindowSizes, sheetArray);
}
// Lumping in the loader with the style-sheets size is not ideal,
// but most of the things in there are in fact stylesheets, so it
// doesn't seem worthwhile to separate it out.
aWindowSizes.mLayoutStyleSheetsSize +=
CSSLoader()->SizeOfIncludingThis(aWindowSizes.mState.mMallocSizeOf);
aWindowSizes.mDOMOtherSize += mAttrStyleSheet
? mAttrStyleSheet->DOMSizeOfIncludingThis(
aWindowSizes.mState.mMallocSizeOf)
: 0;
aWindowSizes.mDOMOtherSize += mStyledLinks.ShallowSizeOfExcludingThis(
aWindowSizes.mState.mMallocSizeOf);
// Measurement of the following members may be added later if DMD finds it
// is worthwhile:
// - many!
}
already_AddRefed<nsIDocument> nsIDocument::Constructor(
const GlobalObject& aGlobal, ErrorResult& rv) {
nsCOMPtr<nsIScriptGlobalObject> global =
@ -11567,14 +11578,13 @@ already_AddRefed<Element> nsIDocument::CreateHTMLElement(nsAtom* aTag) {
}
bool MarkDocumentTreeToBeInSyncOperation(nsIDocument* aDoc, void* aData) {
nsCOMArray<nsIDocument>* documents =
static_cast<nsCOMArray<nsIDocument>*>(aData);
auto* documents = static_cast<nsTArray<nsCOMPtr<nsIDocument>>*>(aData);
if (aDoc) {
aDoc->SetIsInSyncOperation(true);
if (nsCOMPtr<nsPIDOMWindowInner> window = aDoc->GetInnerWindow()) {
window->TimeoutManager().BeginSyncOperation();
}
documents->AppendObject(aDoc);
documents->AppendElement(aDoc);
aDoc->EnumerateSubDocuments(MarkDocumentTreeToBeInSyncOperation, aData);
}
return true;
@ -11598,11 +11608,11 @@ nsAutoSyncOperation::nsAutoSyncOperation(nsIDocument* aDoc) {
}
nsAutoSyncOperation::~nsAutoSyncOperation() {
for (int32_t i = 0; i < mDocuments.Count(); ++i) {
if (nsCOMPtr<nsPIDOMWindowInner> window = mDocuments[i]->GetInnerWindow()) {
for (nsCOMPtr<nsIDocument>& doc : mDocuments) {
if (nsCOMPtr<nsPIDOMWindowInner> window = doc->GetInnerWindow()) {
window->TimeoutManager().EndSyncOperation();
}
mDocuments[i]->SetIsInSyncOperation(false);
doc->SetIsInSyncOperation(false);
}
CycleCollectedJSContext* ccjs = CycleCollectedJSContext::Get();
if (ccjs) {
@ -12533,14 +12543,7 @@ bool nsIDocument::IsThirdParty() {
}
nsCOMPtr<nsIPrincipal> principal = NodePrincipal();
nsCOMPtr<nsIScriptObjectPrincipal> sop =
do_QueryInterface(parentDocument, &rv);
if (NS_WARN_IF(NS_FAILED(rv) || !sop)) {
// Failure
mIsThirdParty.emplace(true);
return mIsThirdParty.value();
}
nsCOMPtr<nsIPrincipal> parentPrincipal = sop->GetPrincipal();
nsCOMPtr<nsIPrincipal> parentPrincipal = parentDocument->GetPrincipal();
bool principalsMatch = false;
rv = principal->Equals(parentPrincipal, &principalsMatch);

View File

@ -13,284 +13,23 @@
#include "nsIDocument.h"
#include "jsfriendapi.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsCRT.h"
#include "nsIWeakReferenceUtils.h"
#include "nsTArray.h"
#include "nsIdentifierMapEntry.h"
#include "nsStubDocumentObserver.h"
#include "nsIScriptGlobalObject.h"
#include "nsIContent.h"
#include "nsIPrincipal.h"
#include "nsIParser.h"
#include "nsBindingManager.h"
#include "nsRefPtrHashtable.h"
#include "nsJSThingHashtable.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIRadioGroupContainer.h"
#include "nsILayoutHistoryState.h"
#include "nsIRequest.h"
#include "nsILoadGroup.h"
#include "nsTObserverArray.h"
#include "nsStubMutationObserver.h"
#include "nsIChannel.h"
#include "nsCycleCollectionParticipant.h"
#include "nsContentList.h"
#include "nsGkAtoms.h"
#include "PLDHashTable.h"
#include "nsDOMAttributeMap.h"
#include "imgIRequest.h"
#include "mozilla/EventStates.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/PendingAnimationTracker.h"
#include "mozilla/dom/BoxObject.h"
#include "mozilla/dom/DOMImplementation.h"
#include "mozilla/dom/ScriptLoader.h"
#include "mozilla/dom/StyleSheetList.h"
#include "nsDataHashtable.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/Attributes.h"
#include "CustomElementRegistry.h"
#include "mozilla/dom/Performance.h"
#include "mozilla/Maybe.h"
#include "nsIURIClassifier.h"
#define XML_DECLARATION_BITS_DECLARATION_EXISTS (1 << 0)
#define XML_DECLARATION_BITS_ENCODING_EXISTS (1 << 1)
#define XML_DECLARATION_BITS_STANDALONE_EXISTS (1 << 2)
#define XML_DECLARATION_BITS_STANDALONE_YES (1 << 3)
class nsDOMStyleSheetSetList;
class nsDocument;
class nsIFormControl;
class nsOnloadBlocker;
class nsDOMNavigationTiming;
class nsWindowSizes;
class nsHtml5TreeOpExecutor;
class nsDocumentOnStack;
class nsISecurityConsoleMessage;
namespace mozilla {
class EventChainPreVisitor;
namespace dom {
class ImageTracker;
struct LifecycleCallbacks;
class CallbackFunction;
class DOMIntersectionObserver;
class Performance;
} // namespace dom
} // namespace mozilla
class nsOnloadBlocker final : public nsIRequest {
public:
nsOnloadBlocker() {}
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUEST
private:
~nsOnloadBlocker() {}
};
// Base class for our document implementations.
class nsDocument : public nsIDocument,
public nsSupportsWeakReference,
public nsIScriptObjectPrincipal,
public nsIRadioGroupContainer,
public nsIApplicationCacheContainer,
public nsStubMutationObserver {
friend class nsIDocument;
public:
typedef mozilla::dom::Element Element;
typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_ADDSIZEOFEXCLUDINGTHIS
// StartDocumentLoad is pure virtual so that subclasses must override it.
// The nsDocument StartDocumentLoad does some setup, but does NOT set
// *aDocListener; this is the job of subclasses.
virtual nsresult StartDocumentLoad(
const char* aCommand, nsIChannel* aChannel, nsILoadGroup* aLoadGroup,
nsISupports* aContainer, nsIStreamListener** aDocListener,
bool aReset = true, nsIContentSink* aContentSink = nullptr) override = 0;
virtual void StopDocumentLoad() override;
static bool DocumentSupportsL10n(JSContext* aCx, JSObject* aObject);
static bool IsWebAnimationsEnabled(JSContext* aCx, JSObject* aObject);
static bool IsWebAnimationsEnabled(mozilla::dom::CallerType aCallerType);
static bool IsWebAnimationsGetAnimationsEnabled(JSContext* aCx,
JSObject* aObject);
static bool AreWebAnimationsImplicitKeyframesEnabled(JSContext* aCx,
JSObject* aObject);
static bool AreWebAnimationsTimelinesEnabled(JSContext* aCx,
JSObject* aObject);
virtual void EndUpdate() override;
virtual void BeginLoad() override;
virtual void EndLoad() override;
// nsIRadioGroupContainer
NS_IMETHOD WalkRadioGroup(const nsAString& aName, nsIRadioVisitor* aVisitor,
bool aFlushContent) override {
return DocumentOrShadowRoot::WalkRadioGroup(aName, aVisitor, aFlushContent);
}
virtual void SetCurrentRadioButton(
const nsAString& aName, mozilla::dom::HTMLInputElement* aRadio) override {
DocumentOrShadowRoot::SetCurrentRadioButton(aName, aRadio);
}
virtual mozilla::dom::HTMLInputElement* GetCurrentRadioButton(
const nsAString& aName) override {
return DocumentOrShadowRoot::GetCurrentRadioButton(aName);
}
NS_IMETHOD
GetNextRadioButton(const nsAString& aName, const bool aPrevious,
mozilla::dom::HTMLInputElement* aFocusedRadio,
mozilla::dom::HTMLInputElement** aRadioOut) override {
return DocumentOrShadowRoot::GetNextRadioButton(aName, aPrevious,
aFocusedRadio, aRadioOut);
}
virtual void AddToRadioGroup(
const nsAString& aName, mozilla::dom::HTMLInputElement* aRadio) override {
DocumentOrShadowRoot::AddToRadioGroup(aName, aRadio);
}
virtual void RemoveFromRadioGroup(
const nsAString& aName, mozilla::dom::HTMLInputElement* aRadio) override {
DocumentOrShadowRoot::RemoveFromRadioGroup(aName, aRadio);
}
virtual uint32_t GetRequiredRadioCount(
const nsAString& aName) const override {
return DocumentOrShadowRoot::GetRequiredRadioCount(aName);
}
virtual void RadioRequiredWillChange(const nsAString& aName,
bool aRequiredAdded) override {
DocumentOrShadowRoot::RadioRequiredWillChange(aName, aRequiredAdded);
}
virtual bool GetValueMissingState(const nsAString& aName) const override {
return DocumentOrShadowRoot::GetValueMissingState(aName);
}
virtual void SetValueMissingState(const nsAString& aName,
bool aValue) override {
return DocumentOrShadowRoot::SetValueMissingState(aName, aValue);
}
// Check whether shadow DOM is enabled for the document this node belongs to.
// Same as above, but also checks that the caller is either chrome or some
// addon.
static bool IsCallerChromeOrAddon(JSContext* aCx, JSObject* aObject);
public:
using mozilla::dom::DocumentOrShadowRoot::GetElementById;
using mozilla::dom::DocumentOrShadowRoot::GetElementsByClassName;
using mozilla::dom::DocumentOrShadowRoot::GetElementsByTagName;
using mozilla::dom::DocumentOrShadowRoot::GetElementsByTagNameNS;
// EventTarget
void GetEventTargetParent(mozilla::EventChainPreVisitor& aVisitor) override;
virtual mozilla::EventListenerManager* GetOrCreateListenerManager() override;
virtual mozilla::EventListenerManager* GetExistingListenerManager()
const override;
// nsIScriptObjectPrincipal
virtual nsIPrincipal* GetPrincipal() override;
// nsIApplicationCacheContainer
NS_DECL_NSIAPPLICATIONCACHECONTAINER
virtual nsresult Init();
virtual void Destroy() override;
virtual void RemovedFromDocShell() override;
virtual void BlockOnload() override;
virtual void UnblockOnload(bool aFireSync) override;
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDocument,
nsIDocument)
void SetLoadedAsData(bool aLoadedAsData) { mLoadedAsData = aLoadedAsData; }
void SetLoadedAsInteractiveData(bool aLoadedAsInteractiveData) {
mLoadedAsInteractiveData = aLoadedAsInteractiveData;
}
nsresult CloneDocHelper(nsDocument* clone) const;
// Only BlockOnload should call this!
void AsyncBlockOnload();
virtual void DocAddSizeOfExcludingThis(
nsWindowSizes& aWindowSizes) const override;
// DocAddSizeOfIncludingThis is inherited from nsIDocument.
class nsDocument : public nsIDocument {
protected:
friend class nsNodeUtils;
void RetrieveRelevantHeaders(nsIChannel* aChannel);
void TryChannelCharset(nsIChannel* aChannel, int32_t& aCharsetSource,
NotNull<const Encoding*>& aEncoding,
nsHtml5TreeOpExecutor* aExecutor);
nsIContent* GetFirstBaseNodeWithHref();
nsresult SetFirstBaseNodeWithHref(nsIContent* node);
#define NS_DOCUMENT_NOTIFY_OBSERVERS(func_, params_) \
do { \
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mObservers, nsIDocumentObserver, \
func_, params_); \
/* FIXME(emilio): Apparently we can keep observing from the BFCache? That \
looks bogus. */ \
if (nsIPresShell* shell = GetObservingShell()) { \
shell->func_ params_; \
} \
} while (0)
#ifdef DEBUG
void VerifyRootContentState();
#endif
explicit nsDocument(const char* aContentType);
virtual ~nsDocument();
public:
// FIXME(emilio): This needs to be here instead of in nsIDocument because Rust
// can't represent alignas(8) values on 32-bit architectures, which would
// cause nsIDocument's layout to be wrong in the Rust side.
//
// This can be fixed after updating to rust 1.25 and updating bindgen to
// include https://github.com/rust-lang-nursery/rust-bindgen/pull/1271.
js::ExpandoAndGeneration mExpandoAndGeneration;
friend class nsCallRequestFullscreen;
// The application cache that this document is associated with, if
// any. This can change during the lifetime of the document.
nsCOMPtr<nsIApplicationCache> mApplicationCache;
nsCOMPtr<nsIContent> mFirstBaseNodeWithHref;
// Don't add stuff here, add to nsIDocument instead.
private:
friend class nsUnblockOnloadEvent;
// These are not implemented and not supported.
nsDocument(const nsDocument& aOther);
nsDocument& operator=(const nsDocument& aOther);
};
class nsDocumentOnStack {
public:
explicit nsDocumentOnStack(nsIDocument* aDoc) : mDoc(aDoc) {
mDoc->IncreaseStackRefCnt();
}
~nsDocumentOnStack() { mDoc->DecreaseStackRefCnt(); }
private:
nsIDocument* mDoc;
nsDocument(const nsDocument& aOther) = delete;
nsDocument& operator=(const nsDocument& aOther) = delete;
};
#endif /* nsDocument_h___ */

View File

@ -1687,7 +1687,8 @@ bool nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
// that the check is made for suppressed documents. Check to ensure that
// the document isn't null in case someone closed it during the blur above
nsIDocument* doc = window->GetExtantDoc();
if (doc) SendFocusOrBlurEvent(eBlur, presShell, doc, doc, 1, false);
if (doc)
SendFocusOrBlurEvent(eBlur, presShell, doc, ToSupports(doc), 1, false);
if (mFocusedWindow == nullptr)
SendFocusOrBlurEvent(eBlur, presShell, doc,
window->GetCurrentInnerWindow(), 1, false);
@ -1804,7 +1805,7 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
GetFocusMoveActionCause(aFlags));
}
if (doc) {
SendFocusOrBlurEvent(eFocus, presShell, doc, doc,
SendFocusOrBlurEvent(eFocus, presShell, doc, ToSupports(doc),
aFlags & FOCUSMETHOD_MASK, aWindowRaised);
}
if (mFocusedWindow == aWindow && mFocusedElement == nullptr) {

View File

@ -2059,7 +2059,7 @@ void nsGlobalWindowOuter::DispatchDOMWindowCreated() {
}
// Fire DOMWindowCreated at chrome event listeners
nsContentUtils::DispatchChromeEvent(mDoc, mDoc,
nsContentUtils::DispatchChromeEvent(mDoc, ToSupports(mDoc),
NS_LITERAL_STRING("DOMWindowCreated"),
CanBubble::eYes, Cancelable::eNo);

View File

@ -25,6 +25,8 @@
#include "nsIPresShell.h"
#include "nsIChannelEventSink.h"
#include "nsIProgressEventSink.h"
#include "nsIRadioGroupContainer.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsISecurityEventSink.h"
#include "nsIScriptGlobalObject.h" // for member (in nsCOMPtr)
#include "nsIServiceManager.h"
@ -35,6 +37,7 @@
#include "nsPIDOMWindow.h" // for use in inline functions
#include "nsPropertyTable.h" // for member
#include "nsStringFwd.h"
#include "nsStubMutationObserver.h"
#include "nsTHashtable.h" // for member
#include "nsURIHashKey.h"
#include "mozilla/net/ReferrerPolicy.h" // for member
@ -82,6 +85,7 @@ class nsDOMNavigationTiming;
class nsDOMStyleSheetSetList;
class nsFrameLoader;
class nsGlobalWindowInner;
class nsHtml5TreeOpExecutor;
class nsHTMLCSSStyleSheet;
class nsHTMLDocument;
class nsHTMLStyleSheet;
@ -434,6 +438,11 @@ class PrincipalFlashClassifier;
// Gecko.
class nsIDocument : public nsINode,
public mozilla::dom::DocumentOrShadowRoot,
public nsSupportsWeakReference,
public nsIRadioGroupContainer,
public nsIScriptObjectPrincipal,
public nsIApplicationCacheContainer,
public nsStubMutationObserver,
public mozilla::dom::DispatcherTrait {
typedef mozilla::dom::GlobalObject GlobalObject;
@ -451,10 +460,84 @@ class nsIDocument : public nsINode,
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_IID)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_ADDSIZEOFEXCLUDINGTHIS
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsIDocument,
nsINode)
#define NS_DOCUMENT_NOTIFY_OBSERVERS(func_, params_) \
do { \
NS_OBSERVER_ARRAY_NOTIFY_XPCOM_OBSERVERS(mObservers, nsIDocumentObserver, \
func_, params_); \
/* FIXME(emilio): Apparently we can keep observing from the BFCache? That \
looks bogus. */ \
if (nsIPresShell* shell = GetObservingShell()) { \
shell->func_ params_; \
} \
} while (0)
#ifdef MOZILLA_INTERNAL_API
nsIDocument();
#endif
// nsIApplicationCacheContainer
NS_DECL_NSIAPPLICATIONCACHECONTAINER
// nsIRadioGroupContainer
NS_IMETHOD WalkRadioGroup(const nsAString& aName, nsIRadioVisitor* aVisitor,
bool aFlushContent) final {
return DocumentOrShadowRoot::WalkRadioGroup(aName, aVisitor, aFlushContent);
}
void SetCurrentRadioButton(const nsAString& aName,
mozilla::dom::HTMLInputElement* aRadio) final {
DocumentOrShadowRoot::SetCurrentRadioButton(aName, aRadio);
}
mozilla::dom::HTMLInputElement* GetCurrentRadioButton(
const nsAString& aName) final {
return DocumentOrShadowRoot::GetCurrentRadioButton(aName);
}
NS_IMETHOD
GetNextRadioButton(const nsAString& aName, const bool aPrevious,
mozilla::dom::HTMLInputElement* aFocusedRadio,
mozilla::dom::HTMLInputElement** aRadioOut) final {
return DocumentOrShadowRoot::GetNextRadioButton(aName, aPrevious,
aFocusedRadio, aRadioOut);
}
void AddToRadioGroup(const nsAString& aName,
mozilla::dom::HTMLInputElement* aRadio) final {
DocumentOrShadowRoot::AddToRadioGroup(aName, aRadio);
}
void RemoveFromRadioGroup(const nsAString& aName,
mozilla::dom::HTMLInputElement* aRadio) final {
DocumentOrShadowRoot::RemoveFromRadioGroup(aName, aRadio);
}
uint32_t GetRequiredRadioCount(const nsAString& aName) const final {
return DocumentOrShadowRoot::GetRequiredRadioCount(aName);
}
void RadioRequiredWillChange(const nsAString& aName,
bool aRequiredAdded) final {
DocumentOrShadowRoot::RadioRequiredWillChange(aName, aRequiredAdded);
}
bool GetValueMissingState(const nsAString& aName) const final {
return DocumentOrShadowRoot::GetValueMissingState(aName);
}
void SetValueMissingState(const nsAString& aName, bool aValue) final {
return DocumentOrShadowRoot::SetValueMissingState(aName, aValue);
}
// nsIScriptObjectPrincipal
nsIPrincipal* GetPrincipal() final { return NodePrincipal(); }
// EventTarget
void GetEventTargetParent(mozilla::EventChainPreVisitor& aVisitor) override;
mozilla::EventListenerManager* GetOrCreateListenerManager() override;
mozilla::EventListenerManager* GetExistingListenerManager() const override;
// This helper class must be set when we dispatch beforeunload and unload
// events in order to avoid unterminate sync XHRs.
class MOZ_RAII PageUnloadingEventTimeStamp {
@ -510,6 +593,9 @@ class nsIDocument : public nsINode,
* MayStartLayout() until SetMayStartLayout(true) is called on it. Making
* sure this happens is the responsibility of the caller of
* StartDocumentLoad().
*
* This function has an implementation, and does some setup, but does NOT set
* *aDocListener; this is the job of subclasses.
*/
virtual nsresult StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
@ -517,7 +603,7 @@ class nsIDocument : public nsINode,
nsIStreamListener** aDocListener,
bool aReset,
nsIContentSink* aSink = nullptr) = 0;
virtual void StopDocumentLoad() = 0;
virtual void StopDocumentLoad();
virtual void SetSuppressParserErrorElement(bool aSuppress) {}
virtual bool SuppressParserErrorElement() { return false; }
@ -534,6 +620,7 @@ class nsIDocument : public nsINode,
nsINode** aResult) const override {
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult CloneDocHelper(nsIDocument* clone) const;
/**
* Signal that the document title may have changed
@ -788,6 +875,11 @@ class nsIDocument : public nsINode,
mIsInitialDocumentInWindow = aIsInitialDocument;
}
void SetLoadedAsData(bool aLoadedAsData) { mLoadedAsData = aLoadedAsData; }
void SetLoadedAsInteractiveData(bool aLoadedAsInteractiveData) {
mLoadedAsInteractiveData = aLoadedAsInteractiveData;
}
/**
* Normally we assert if a runnable labeled with one DocGroup touches data
* from another DocGroup. Calling IgnoreDocGroupMismatches() on a document
@ -1318,6 +1410,12 @@ class nsIDocument : public nsINode,
void MaybeEndOutermostXBLUpdate();
void RetrieveRelevantHeaders(nsIChannel* aChannel);
void TryChannelCharset(nsIChannel* aChannel, int32_t& aCharsetSource,
NotNull<const Encoding*>& aEncoding,
nsHtml5TreeOpExecutor* aExecutor);
void DispatchContentLoadedEvents();
void DispatchPageTransition(mozilla::dom::EventTarget* aDispatchTarget,
@ -1782,11 +1880,11 @@ class nsIDocument : public nsINode,
// content model or of style data, EndUpdate must be called afterward.
// To make this easy and painless, use the mozAutoDocUpdate helper class.
void BeginUpdate();
virtual void EndUpdate() = 0;
virtual void EndUpdate();
uint32_t UpdateNestingLevel() { return mUpdateNestLevel; }
virtual void BeginLoad() = 0;
virtual void EndLoad() = 0;
virtual void BeginLoad();
virtual void EndLoad();
enum ReadyState {
READYSTATE_UNINITIALIZED = 0,
@ -2036,12 +2134,14 @@ class nsIDocument : public nsINode,
*/
virtual bool CanSavePresentation(nsIRequest* aNewRequest);
virtual nsresult Init();
/**
* Notify the document that its associated ContentViewer is being destroyed.
* This releases circular references so that the document can go away.
* Destroy() is only called on documents that have a content viewer.
*/
virtual void Destroy() = 0;
virtual void Destroy();
/**
* Notify the document that its associated ContentViewer is no longer
@ -2049,7 +2149,7 @@ class nsIDocument : public nsINode,
* be rendered in "zombie state" until the next document is ready.
* The document should save form control state.
*/
virtual void RemovedFromDocShell() = 0;
virtual void RemovedFromDocShell();
/**
* Get the layout history state that should be used to save and restore state
@ -2065,14 +2165,17 @@ class nsIDocument : public nsINode,
* UnblockOnload() or the load has been stopped altogether (by the user
* pressing the Stop button, say).
*/
virtual void BlockOnload() = 0;
void BlockOnload();
/**
* @param aFireSync whether to fire onload synchronously. If false,
* onload will fire asynchronously after all onload blocks have been
* removed. It will NOT fire from inside UnblockOnload. If true,
* onload may fire from inside UnblockOnload.
*/
virtual void UnblockOnload(bool aFireSync) = 0;
void UnblockOnload(bool aFireSync);
// Only BlockOnload should call this!
void AsyncBlockOnload();
void BlockDOMContentLoaded() { ++mBlockDOMContentLoaded; }
@ -2995,6 +3098,17 @@ class nsIDocument : public nsINode,
void ExitPointerLock() { UnlockPointer(this); }
static bool IsUnprefixedFullscreenEnabled(JSContext* aCx, JSObject* aObject);
static bool DocumentSupportsL10n(JSContext* aCx, JSObject* aObject);
static bool IsWebAnimationsEnabled(JSContext* aCx, JSObject* aObject);
static bool IsWebAnimationsEnabled(mozilla::dom::CallerType aCallerType);
static bool IsWebAnimationsGetAnimationsEnabled(JSContext* aCx,
JSObject* aObject);
static bool AreWebAnimationsImplicitKeyframesEnabled(JSContext* aCx,
JSObject* aObject);
static bool AreWebAnimationsTimelinesEnabled(JSContext* aCx,
JSObject* aObject);
// Checks that the caller is either chrome or some addon.
static bool IsCallerChromeOrAddon(JSContext* aCx, JSObject* aObject);
#ifdef MOZILLA_INTERNAL_API
bool Hidden() const {
@ -3323,6 +3437,10 @@ class nsIDocument : public nsINode,
nsTArray<nsString> mL10nResources;
// The application cache that this document is associated with, if
// any. This can change during the lifetime of the document.
nsCOMPtr<nsIApplicationCache> mApplicationCache;
public:
bool IsThirdParty();
@ -4338,6 +4456,10 @@ class nsIDocument : public nsINode,
// Pres shell resolution saved before entering fullscreen mode.
float mSavedResolution;
public:
// Needs to be public because the bindings code pokes at it.
js::ExpandoAndGeneration mExpandoAndGeneration;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocument, NS_IDOCUMENT_IID)
@ -4384,7 +4506,7 @@ class MOZ_STACK_CLASS nsAutoSyncOperation {
~nsAutoSyncOperation();
private:
nsCOMArray<nsIDocument> mDocuments;
nsTArray<nsCOMPtr<nsIDocument>> mDocuments;
uint32_t mMicroTaskLevel;
};
@ -4497,4 +4619,8 @@ inline const nsIDocument* nsINode::AsDocument() const {
return static_cast<const nsIDocument*>(this);
}
inline nsISupports* ToSupports(nsIDocument* aDoc) {
return static_cast<nsINode*>(aDoc);
}
#endif /* nsIDocument_h___ */

View File

@ -788,8 +788,8 @@ nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
// Do the load.
RefPtr<imgRequestProxy>& req = PrepareNextRequest(eImageLoadType_Normal);
nsresult rv = loader->LoadImageWithChannel(aChannel, this, doc, aListener,
getter_AddRefs(req));
nsresult rv = loader->LoadImageWithChannel(aChannel, this, ToSupports(doc),
aListener, getter_AddRefs(req));
if (NS_SUCCEEDED(rv)) {
CloneScriptedRequests(req);
TrackImage(req);

View File

@ -35,6 +35,7 @@
#include "nsObjectLoadingContent.h"
#include "nsDOMMutationObserver.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/CustomElementRegistry.h"
#include "mozilla/dom/HTMLTemplateElement.h"
#include "mozilla/dom/ShadowRoot.h"

View File

@ -262,7 +262,7 @@ class nsSimplePluginEvent : public Runnable {
nsSimplePluginEvent(nsIDocument* aTarget, const nsAString& aEvent)
: mozilla::Runnable("nsSimplePluginEvent"),
mTarget(aTarget),
mTarget(ToSupports(aTarget)),
mDocument(aTarget),
mEvent(aEvent) {
MOZ_ASSERT(aTarget);

View File

@ -425,7 +425,7 @@ enum class ReflectionScope { Content, XBL, UAWidget };
struct MOZ_STACK_CLASS ParentObject {
template <class T>
MOZ_IMPLICIT ParentObject(T* aObject)
: mObject(aObject),
: mObject(ToSupports(aObject)),
mWrapperCache(GetWrapperCache(aObject)),
mReflectionScope(ReflectionScope::Content) {}

View File

@ -15,6 +15,7 @@
#include "mozilla/dom/File.h"
#include "mozilla/dom/FunctionBinding.h"
#include "mozilla/dom/Performance.h"
#include "mozilla/dom/PromiseBinding.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/StructuredCloneHolder.h"
#include "mozilla/dom/ToJSValue.h"

View File

@ -2102,7 +2102,7 @@ void EventStateManager::DoScrollZoom(nsIFrame* aTargetFrame,
ChangeTextSize(change);
}
nsContentUtils::DispatchChromeEvent(
mDocument, static_cast<nsIDocument*>(mDocument),
mDocument, ToSupports(mDocument),
NS_LITERAL_STRING("ZoomChangeUsingMouseWheel"), CanBubble::eYes,
Cancelable::eYes);
}

View File

@ -131,7 +131,7 @@ NS_IMETHODIMP
ImageListener::OnStopRequest(nsIRequest* aRequest, nsISupports* aCtxt,
nsresult aStatus) {
ImageDocument* imgDoc = static_cast<ImageDocument*>(mDocument.get());
nsContentUtils::DispatchChromeEvent(imgDoc, static_cast<nsIDocument*>(imgDoc),
nsContentUtils::DispatchChromeEvent(imgDoc, ToSupports(imgDoc),
NS_LITERAL_STRING("ImageContentLoaded"),
CanBubble::eYes, Cancelable::eYes);
return MediaDocumentStreamListener::OnStopRequest(aRequest, aCtxt, aStatus);

View File

@ -950,7 +950,7 @@ void HTMLContentSink::SetDocumentCharset(NotNull<const Encoding*> aEncoding) {
MOZ_ASSERT_UNREACHABLE("<meta charset> case doesn't occur with about:blank");
}
nsISupports* HTMLContentSink::GetTarget() { return mDocument; }
nsISupports* HTMLContentSink::GetTarget() { return ToSupports(mDocument); }
bool HTMLContentSink::IsScriptExecuting() { return IsScriptExecutingImpl(); }

View File

@ -7,6 +7,7 @@
#define nsHTMLDocument_h___
#include "mozilla/Attributes.h"
#include "nsContentList.h"
#include "nsDocument.h"
#include "nsIHTMLDocument.h"
#include "nsIHTMLCollection.h"
@ -33,6 +34,8 @@ class HTMLAllCollection;
} // namespace mozilla
class nsHTMLDocument : public nsDocument, public nsIHTMLDocument {
typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
public:
using nsDocument::GetPlugins;
using nsDocument::SetDocumentURI;

View File

@ -444,7 +444,7 @@ TabChild::Observe(nsISupports* aSubject, const char* aTopic,
nsCOMPtr<nsIDocument> subject(do_QueryInterface(aSubject));
nsCOMPtr<nsIDocument> doc(GetDocument());
if (SameCOMIdentity(subject, doc)) {
if (subject == doc) {
nsCOMPtr<nsIPresShell> shell(doc->GetShell());
if (shell) {
shell->SetIsFirstPaint(true);

View File

@ -16,6 +16,12 @@ NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(SVGAngle, mSVGElement)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(SVGAngle, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(SVGAngle, Release)
SVGAngle::SVGAngle(SVGElement* aSVGElement)
: mSVGElement(aSVGElement), mType(SVGAngle::CreatedValue) {
mVal = new nsSVGAngle();
mVal->Init();
}
JSObject* SVGAngle::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return SVGAngle_Binding::Wrap(aCx, this, aGivenProto);

View File

@ -23,9 +23,18 @@ class SVGAngle final : public nsWrapperCache {
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(SVGAngle)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(SVGAngle)
/**
* Generic ctor for SVGAngle objects that are created for an attribute.
*/
SVGAngle(nsSVGAngle* aVal, SVGElement* aSVGElement, AngleType aType)
: mVal(aVal), mSVGElement(aSVGElement), mType(aType) {}
/**
* Ctor for creating the objects returned by SVGSVGElement.createSVGAngle(),
* which do not initially belong to an attribute.
*/
explicit SVGAngle(SVGElement* aSVGElement);
// WebIDL
SVGElement* GetParentObject() { return mSVGElement; }
virtual JSObject* WrapObject(JSContext* aCx,

View File

@ -22,7 +22,6 @@
#include "nsIFrame.h"
#include "nsISVGSVGFrame.h"
#include "nsSMILTimeContainer.h"
#include "nsSVGAngle.h"
#include "SVGAngle.h"
#include "nsSVGDisplayableFrame.h"
#include "nsSVGUtils.h"
@ -263,10 +262,7 @@ already_AddRefed<DOMSVGLength> SVGSVGElement::CreateSVGLength() {
}
already_AddRefed<SVGAngle> SVGSVGElement::CreateSVGAngle() {
nsSVGAngle* angle = new nsSVGAngle();
angle->Init();
RefPtr<SVGAngle> svgangle = new SVGAngle(angle, this, SVGAngle::CreatedValue);
return svgangle.forget();
return do_AddRef(new SVGAngle(this));
}
already_AddRefed<nsISVGPoint> SVGSVGElement::CreateSVGPoint() {

View File

@ -17,6 +17,7 @@
#include "nsIURI.h"
#include "nsXBLSerialize.h"
#include "nsXBLPrototypeBinding.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/ElementBinding.h"
#include "mozilla/dom/ScriptSettings.h"

View File

@ -19,6 +19,7 @@
#include "nsIXPConnect.h"
#include "xpcpublic.h"
#include "nsXBLPrototypeBinding.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ScriptSettings.h"

View File

@ -24,6 +24,7 @@
#include "mozilla/dom/MutableBlobStorage.h"
#include "mozilla/dom/XMLDocument.h"
#include "mozilla/dom/URLSearchParams.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/PromiseNativeHandler.h"
#include "mozilla/Encoding.h"
#include "mozilla/EventDispatcher.h"
@ -709,7 +710,8 @@ void XMLHttpRequestMainThread::GetResponse(
return;
}
aRv = nsContentUtils::WrapNative(aCx, mResponseXML, aResponse);
aRv =
nsContentUtils::WrapNative(aCx, ToSupports(mResponseXML), aResponse);
return;
}
case XMLHttpRequestResponseType::Json: {

View File

@ -545,7 +545,7 @@ void XMLDocument::EndLoad() {
// document was loaded as pure data without any presentation
// attached to it.
WidgetEvent event(true, eLoad);
EventDispatcher::Dispatch(static_cast<nsIDocument*>(this), nullptr, &event);
EventDispatcher::Dispatch(ToSupports(this), nullptr, &event);
}
}

View File

@ -737,7 +737,7 @@ void nsXMLContentSink::SetDocumentCharset(NotNull<const Encoding*> aEncoding) {
}
}
nsISupports* nsXMLContentSink::GetTarget() { return mDocument; }
nsISupports* nsXMLContentSink::GetTarget() { return ToSupports(mDocument); }
bool nsXMLContentSink::IsScriptExecuting() { return IsScriptExecutingImpl(); }

View File

@ -168,7 +168,9 @@ void nsXMLFragmentContentSink::SetDocumentCharset(
MOZ_ASSERT_UNREACHABLE("fragments shouldn't set charset");
}
nsISupports* nsXMLFragmentContentSink::GetTarget() { return mTargetDocument; }
nsISupports* nsXMLFragmentContentSink::GetTarget() {
return ToSupports(mTargetDocument);
}
////////////////////////////////////////////////////////////////////////

View File

@ -78,6 +78,7 @@
#include "nsCCUncollectableMarker.h"
#include "nsURILoader.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/dom/DocumentL10n.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/NodeInfoInlines.h"
@ -989,9 +990,8 @@ nsresult XULDocument::DoneWalking() {
mDocumentL10n, true, false);
nsContentUtils::DispatchTrustedEvent(
this, static_cast<nsIDocument*>(this),
NS_LITERAL_STRING("MozBeforeInitialXULLayout"), CanBubble::eYes,
Cancelable::eNo);
this, ToSupports(this), NS_LITERAL_STRING("MozBeforeInitialXULLayout"),
CanBubble::eYes, Cancelable::eNo);
RemoveEventListener(NS_LITERAL_STRING("MozBeforeInitialXULLayout"),
mDocumentL10n, true);

View File

@ -232,7 +232,7 @@ void XULContentSinkImpl::SetDocumentCharset(
nsISupports* XULContentSinkImpl::GetTarget() {
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
return doc;
return ToSupports(doc);
}
//----------------------------------------------------------------------

View File

@ -735,6 +735,7 @@ mozilla::ipc::IPCResult WebRenderBridgeParent::RecvValidateFontDescriptor(
<< family << "\" has "
<< (attribs == INVALID_FILE_ATTRIBUTES ? "INVALID"
: "valid")
<< "(" << hexa(attribs) << ")"
<< " file \"" << files << "\"";
}
remaining -= fileLength + 1;

View File

@ -17,6 +17,7 @@
#include "mozilla/dom/SVGSVGElement.h"
#include "mozilla/dom/SVGDocument.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/PendingAnimationTracker.h"
#include "mozilla/RefPtr.h"
#include "mozilla/Tuple.h"
#include "nsIPresShell.h"
@ -36,7 +37,7 @@
#include "SVGDrawingParameters.h"
#include "nsIDOMEventListener.h"
#include "SurfaceCache.h"
#include "nsDocument.h"
#include "nsIDocument.h"
namespace mozilla {
@ -1479,9 +1480,8 @@ void VectorImage::PropagateUseCounters(nsIDocument* aParentDocument) {
}
void VectorImage::ReportUseCounters() {
nsIDocument* doc = mSVGDocumentWrapper->GetDocument();
if (doc) {
static_cast<nsDocument*>(doc)->ReportUseCounters();
if (nsIDocument* doc = mSVGDocumentWrapper->GetDocument()) {
doc->ReportUseCounters();
}
}

View File

@ -2155,11 +2155,11 @@ nsresult imgLoader::LoadImage(
if (cache.Get(key, getter_AddRefs(entry)) && entry) {
bool newChannelCreated = false;
if (ValidateEntry(entry, aURI, aInitialDocumentURI, aReferrerURI,
aReferrerPolicy, aLoadGroup, aObserver, aLoadingDocument,
aLoadingDocument, requestFlags, aContentPolicyType, true,
&newChannelCreated, _retval, aTriggeringPrincipal,
corsmode)) {
if (ValidateEntry(
entry, aURI, aInitialDocumentURI, aReferrerURI, aReferrerPolicy,
aLoadGroup, aObserver, ToSupports(aLoadingDocument),
aLoadingDocument, requestFlags, aContentPolicyType, true,
&newChannelCreated, _retval, aTriggeringPrincipal, corsmode)) {
request = entry->GetRequest();
// If this entry has no proxies, its request has no reference to the
@ -2185,9 +2185,10 @@ nsresult imgLoader::LoadImage(
// - we don't have cache. We are not in this if() stmt. A new channel is
// created and that triggers the CSP checks.
// - We have a cache entry and this is blocked by CSP directives.
DebugOnly<bool> shouldLoad = ShouldLoadCachedImage(
request, aLoadingDocument, aTriggeringPrincipal, aContentPolicyType,
/* aSendCSPViolationReports */ true);
DebugOnly<bool> shouldLoad =
ShouldLoadCachedImage(request, ToSupports(aLoadingDocument),
aTriggeringPrincipal, aContentPolicyType,
/* aSendCSPViolationReports */ true);
MOZ_ASSERT(shouldLoad);
}
} else {
@ -2244,8 +2245,9 @@ nsresult imgLoader::LoadImage(
nsCOMPtr<nsILoadGroup> channelLoadGroup;
newChannel->GetLoadGroup(getter_AddRefs(channelLoadGroup));
rv = request->Init(aURI, aURI, /* aHadInsecureRedirect = */ false,
channelLoadGroup, newChannel, entry, aLoadingDocument,
aTriggeringPrincipal, corsmode, aReferrerPolicy);
channelLoadGroup, newChannel, entry,
ToSupports(aLoadingDocument), aTriggeringPrincipal,
corsmode, aReferrerPolicy);
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}

View File

@ -157,12 +157,12 @@ static nsRect GetBoxRectForFrame(nsIFrame** aFrame, CSSBoxType aType) {
class AccumulateQuadCallback : public nsLayoutUtils::BoxCallback {
public:
AccumulateQuadCallback(nsISupports* aParentObject,
AccumulateQuadCallback(nsIDocument* aParentObject,
nsTArray<RefPtr<DOMQuad> >& aResult,
nsIFrame* aRelativeToFrame,
const nsPoint& aRelativeToBoxTopLeft,
CSSBoxType aBoxType)
: mParentObject(aParentObject),
: mParentObject(ToSupports(aParentObject)),
mResult(aResult),
mRelativeToFrame(aRelativeToFrame),
mRelativeToBoxTopLeft(aRelativeToBoxTopLeft),

View File

@ -159,7 +159,7 @@ MobileViewportManager::HandleEvent(dom::Event* event) {
NS_IMETHODIMP
MobileViewportManager::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) {
if (SameCOMIdentity(aSubject, mDocument) &&
if (SameCOMIdentity(aSubject, ToSupports(mDocument)) &&
BEFORE_FIRST_PAINT.EqualsASCII(aTopic)) {
MVM_LOG("%p: got a before-first-paint event\n", this);
if (!mPainted) {

View File

@ -520,8 +520,8 @@ class nsBeforeFirstPaintDispatcher : public Runnable {
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService) {
observerService->NotifyObservers(mDocument, "before-first-paint",
nullptr);
observerService->NotifyObservers(ToSupports(mDocument),
"before-first-paint", nullptr);
}
return NS_OK;
}
@ -1444,7 +1444,7 @@ void nsIPresShell::SetAuthorStyleDisabled(bool aStyleDisabled) {
mozilla::services::GetObserverService();
if (observerService) {
observerService->NotifyObservers(
mDocument, "author-style-disabled-changed", nullptr);
ToSupports(mDocument), "author-style-disabled-changed", nullptr);
}
}
}

View File

@ -144,7 +144,7 @@ ZoomConstraintsClient::HandleEvent(dom::Event* event) {
NS_IMETHODIMP
ZoomConstraintsClient::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) {
if (SameCOMIdentity(aSubject, mDocument) &&
if (SameCOMIdentity(aSubject, ToSupports(mDocument)) &&
BEFORE_FIRST_PAINT.EqualsASCII(aTopic)) {
ZCC_LOG("Got a before-first-paint event in %p\n", this);
RefreshZoomConstraints();

View File

@ -488,18 +488,19 @@ class AutoPrintEventDispatcher {
private:
void DispatchEventToWindowTree(const nsAString& aEvent) {
nsCOMArray<nsIDocument> targets;
nsTArray<nsCOMPtr<nsIDocument>> targets;
CollectDocuments(mTop, &targets);
for (int32_t i = 0; i < targets.Count(); ++i) {
nsIDocument* d = targets[i];
nsContentUtils::DispatchTrustedEvent(
d, d->GetWindow(), aEvent, CanBubble::eNo, Cancelable::eNo, nullptr);
for (nsCOMPtr<nsIDocument>& doc : targets) {
nsContentUtils::DispatchTrustedEvent(doc, doc->GetWindow(), aEvent,
CanBubble::eNo, Cancelable::eNo,
nullptr);
}
}
static bool CollectDocuments(nsIDocument* aDocument, void* aData) {
if (aDocument) {
static_cast<nsCOMArray<nsIDocument>*>(aData)->AppendObject(aDocument);
static_cast<nsTArray<nsCOMPtr<nsIDocument>>*>(aData)->AppendElement(
aDocument);
aDocument->EnumerateSubDocuments(CollectDocuments, aData);
}
return true;
@ -1085,7 +1086,7 @@ nsDocumentViewer::LoadComplete(nsresult aStatus) {
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os) {
nsIPrincipal* principal = d->NodePrincipal();
os->NotifyObservers(d,
os->NotifyObservers(ToSupports(d),
nsContentUtils::IsSystemPrincipal(principal)
? "chrome-document-loaded"
: "content-document-loaded",
@ -2851,9 +2852,9 @@ nsDocumentViewer::SetTextZoom(float aTextZoom) {
// Dispatch TextZoomChange event only if text zoom value has changed.
if (textZoomChange) {
nsContentUtils::DispatchChromeEvent(
mDocument, static_cast<nsIDocument*>(mDocument),
NS_LITERAL_STRING("TextZoomChange"), CanBubble::eYes, Cancelable::eYes);
nsContentUtils::DispatchChromeEvent(mDocument, ToSupports(mDocument),
NS_LITERAL_STRING("TextZoomChange"),
CanBubble::eYes, Cancelable::eYes);
}
return NS_OK;
@ -2968,9 +2969,9 @@ nsDocumentViewer::SetFullZoom(float aFullZoom) {
// Dispatch FullZoomChange event only if fullzoom value really was been
// changed
if (fullZoomChange) {
nsContentUtils::DispatchChromeEvent(
mDocument, static_cast<nsIDocument*>(mDocument),
NS_LITERAL_STRING("FullZoomChange"), CanBubble::eYes, Cancelable::eYes);
nsContentUtils::DispatchChromeEvent(mDocument, ToSupports(mDocument),
NS_LITERAL_STRING("FullZoomChange"),
CanBubble::eYes, Cancelable::eYes);
}
return NS_OK;
@ -4381,7 +4382,8 @@ nsDocumentShownDispatcher::Run() {
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService) {
observerService->NotifyObservers(mDocument, "document-shown", nullptr);
observerService->NotifyObservers(ToSupports(mDocument), "document-shown",
nullptr);
}
return NS_OK;
}

View File

@ -8572,8 +8572,8 @@ void MaybeSetupTransactionIdAllocator(layers::LayerManager* aManager,
if (nsIDocument* doc = aShell->GetDocument()) {
WidgetEvent event(true, eVoidEvent);
nsTArray<EventTarget*> targets;
nsresult rv = EventDispatcher::Dispatch(doc, nullptr, &event, nullptr,
nullptr, nullptr, &targets);
nsresult rv = EventDispatcher::Dispatch(
ToSupports(doc), nullptr, &event, nullptr, nullptr, nullptr, &targets);
NS_ENSURE_SUCCESS(rv, false);
for (size_t i = 0; i < targets.Length(); i++) {
if (targets[i]->IsApzAware()) {

View File

@ -4914,9 +4914,9 @@ void ScrollFrameHelper::FireScrollEvent() {
mozilla::layers::ScrollLinkedEffectDetector detector(
content->GetComposedDoc());
if (mIsRoot) {
nsIDocument* doc = content->GetUncomposedDoc();
if (doc) {
EventDispatcher::Dispatch(doc, prescontext, &event, nullptr, &status);
if (nsIDocument* doc = content->GetUncomposedDoc()) {
EventDispatcher::Dispatch(ToSupports(doc), prescontext, &event, nullptr,
&status);
}
} else {
// scroll events fired at elements don't bubble (although scroll events
@ -6193,10 +6193,8 @@ void ScrollFrameHelper::FireScrolledAreaEvent() {
nsIContent* content = mOuter->GetContent();
event.mArea = mScrolledFrame->GetScrollableOverflowRectRelativeToParent();
nsIDocument* doc = content->GetUncomposedDoc();
if (doc) {
EventDispatcher::Dispatch(doc, prescontext, &event, nullptr);
if (nsIDocument* doc = content->GetUncomposedDoc()) {
EventDispatcher::Dispatch(ToSupports(doc), prescontext, &event, nullptr);
}
}

View File

@ -143,7 +143,9 @@ void MediaQueryList::RecomputeMatches() {
mMatchesValid = true;
}
nsISupports* MediaQueryList::GetParentObject() const { return mDocument; }
nsISupports* MediaQueryList::GetParentObject() const {
return ToSupports(mDocument);
}
JSObject* MediaQueryList::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {

View File

@ -49,11 +49,6 @@ hide-types = [
"nsString",
".*char_traits",
".*incompatible_char_type",
# JS::Value uses alignas(8) which bindgen can't represent correctly on Linux
# 32-bit. See https://github.com/rust-lang-nursery/rust-bindgen/issues/917.
# It's also not used by Stylo. The following types are also hidden for
# making use of it and being similarly unused by Stylo.
"JS::Value",
"mozilla::binding_danger::TErrorResult.*",
"mozilla::ErrorResult.*", # Causes JSWhyMagic to be included & handled incorrectly.
"mozilla::dom::CallbackFunction",

View File

@ -234,7 +234,9 @@ void nsHtml5TreeOpExecutor::FlushPendingNotifications(FlushType aType) {
}
}
nsISupports* nsHtml5TreeOpExecutor::GetTarget() { return mDocument; }
nsISupports* nsHtml5TreeOpExecutor::GetTarget() {
return ToSupports(mDocument);
}
nsresult nsHtml5TreeOpExecutor::MarkAsBroken(nsresult aReason) {
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

View File

@ -887,7 +887,7 @@ nsWebBrowser::SaveDocument(nsISupports* aDocumentish, nsISupports* aFile,
} else {
nsCOMPtr<nsIDocument> domDoc;
GetDocument(getter_AddRefs(domDoc));
doc = domDoc.forget();
doc = already_AddRefed<nsISupports>(ToSupports(domDoc.forget().take()));
}
if (!doc) {
return NS_ERROR_FAILURE;

View File

@ -26,7 +26,7 @@ support-files =
[test_audiocontrols_dimensions.html]
[test_videocontrols.html]
tags = fullscreen
skip-if = toolkit == 'android' || (verify && debug && (os == 'linux')) #TIMED_OUT
skip-if = toolkit == 'android' || (verify && debug && (os == 'linux')) || (os == 'linux') #TIMED_OUT, Bug 1511256
[test_videocontrols_keyhandler.html]
skip-if = (toolkit == 'android') || (os == 'linux') #Bug 1366957
[test_videocontrols_vtt.html]

View File

@ -134,12 +134,8 @@ nsresult OfflineCacheUpdateChild::AssociateDocument(
// Check that the document that requested this update was
// previously associated with an application cache. If not, it
// should be associated with the new one.
nsCOMPtr<nsIApplicationCacheContainer> container =
do_QueryInterface(aDocument);
if (!container) return NS_OK;
nsCOMPtr<nsIApplicationCache> existingCache;
nsresult rv = container->GetApplicationCache(getter_AddRefs(existingCache));
nsresult rv = aDocument->GetApplicationCache(getter_AddRefs(existingCache));
NS_ENSURE_SUCCESS(rv, rv);
if (!existingCache) {
@ -152,7 +148,7 @@ nsresult OfflineCacheUpdateChild::AssociateDocument(
clientID.get(), aDocument));
}
rv = container->SetApplicationCache(aApplicationCache);
rv = aDocument->SetApplicationCache(aApplicationCache);
NS_ENSURE_SUCCESS(rv, rv);
}

View File

@ -183,12 +183,12 @@ OfflineCacheUpdateGlue::ApplicationCacheAvailable(
// Check that the document that requested this update was
// previously associated with an application cache. If not, it
// should be associated with the new one.
nsCOMPtr<nsIApplicationCacheContainer> container =
do_QueryInterface(mDocument);
if (!container) return NS_OK;
if (!mDocument) {
return NS_OK;
}
nsCOMPtr<nsIApplicationCache> existingCache;
nsresult rv = container->GetApplicationCache(getter_AddRefs(existingCache));
nsresult rv = mDocument->GetApplicationCache(getter_AddRefs(existingCache));
NS_ENSURE_SUCCESS(rv, rv);
if (!existingCache) {
@ -201,7 +201,7 @@ OfflineCacheUpdateGlue::ApplicationCacheAvailable(
clientID.get(), mDocument.get()));
}
rv = container->SetApplicationCache(aApplicationCache);
rv = mDocument->SetApplicationCache(aApplicationCache);
NS_ENSURE_SUCCESS(rv, rv);
}

View File

@ -166,9 +166,7 @@ nsOfflineCachePendingUpdate::OnStateChange(nsIWebProgress *aWebProgress,
nsPIDOMWindowInner *innerWindow = outerWindow->GetCurrentInnerWindow();
nsCOMPtr<nsIDocument> progressDoc = outerWindow->GetDoc();
if (!progressDoc) return NS_OK;
if (!SameCOMIdentity(progressDoc, updateDoc)) {
if (!progressDoc || progressDoc != updateDoc) {
return NS_OK;
}

View File

@ -164,7 +164,8 @@ template <typename T>
class MOZ_STACK_CLASS nsQueryInterface final
: public nsQueryInterfaceISupports {
public:
explicit nsQueryInterface(T* aRawPtr) : nsQueryInterfaceISupports(aRawPtr) {}
explicit nsQueryInterface(T* aRawPtr)
: nsQueryInterfaceISupports(ToSupports(aRawPtr)) {}
nsresult NS_FASTCALL operator()(const nsIID& aIID, void** aAnswer) const {
return nsQueryInterfaceISupports::operator()(aIID, aAnswer);
@ -190,7 +191,7 @@ class MOZ_STACK_CLASS nsQueryInterfaceWithError final
: public nsQueryInterfaceISupportsWithError {
public:
explicit nsQueryInterfaceWithError(T* aRawPtr, nsresult* aError)
: nsQueryInterfaceISupportsWithError(aRawPtr, aError) {}
: nsQueryInterfaceISupportsWithError(ToSupports(aRawPtr), aError) {}
nsresult NS_FASTCALL operator()(const nsIID& aIID, void** aAnswer) const {
return nsQueryInterfaceISupportsWithError::operator()(aIID, aAnswer);
@ -198,19 +199,6 @@ class MOZ_STACK_CLASS nsQueryInterfaceWithError final
};
#endif // #ifndef NSCAP_FEATURE_USE_BASE
#ifdef NSCAP_FEATURE_USE_BASE
inline nsQueryInterfaceISupports do_QueryInterface(nsISupports* aRawPtr) {
return nsQueryInterfaceISupports(aRawPtr);
}
inline nsQueryInterfaceISupportsWithError do_QueryInterface(
nsISupports* aRawPtr, nsresult* aError) {
return nsQueryInterfaceISupportsWithError(aRawPtr, aError);
}
#else
namespace mozilla {
// PointedToType<> is needed so that do_QueryInterface() will work with a
// variety of smart pointer types in addition to raw pointers. These types
@ -220,6 +208,20 @@ using PointedToType =
typename mozilla::RemovePointer<decltype(&*mozilla::DeclVal<T>())>::Type;
} // namespace mozilla
#ifdef NSCAP_FEATURE_USE_BASE
template <class T>
inline nsQueryInterfaceISupports do_QueryInterface(T aPtr) {
return nsQueryInterfaceISupports(
ToSupports(static_cast<mozilla::PointedToType<T>*>(aPtr)));
}
template <class T>
inline nsQueryInterfaceISupportsWithError do_QueryInterface(T aPtr,
nsresult* aError) {
return nsQueryInterfaceISupportsWithError(
ToSupports(static_cast<mozilla::PointedToType<T>*>(aPtr)), aError);
}
#else
template <class T>
inline nsQueryInterface<mozilla::PointedToType<T> > do_QueryInterface(T aPtr) {
return nsQueryInterface<mozilla::PointedToType<T> >(aPtr);
@ -230,6 +232,7 @@ inline nsQueryInterfaceWithError<mozilla::PointedToType<T> > do_QueryInterface(
T aRawPtr, nsresult* aError) {
return nsQueryInterfaceWithError<mozilla::PointedToType<T> >(aRawPtr, aError);
}
#endif // ! #ifdef NSCAP_FEATURE_USE_BASE
template <class T>
@ -380,13 +383,15 @@ class MOZ_IS_REFPTR nsCOMPtr final
: private nsCOMPtr_base
#endif
{
private:
#ifdef NSCAP_FEATURE_USE_BASE
#define NSCAP_CTOR_BASE(x) nsCOMPtr_base(x)
#define NSCAP_CTOR_BASE(x) nsCOMPtr_base(ToSupports(x))
void assign_assuming_AddRef(T* aNewPtr) {
nsCOMPtr_base::assign_assuming_AddRef(ToSupports(aNewPtr));
}
#else
#define NSCAP_CTOR_BASE(x) mRawPtr(x)
private:
void assign_with_AddRef(nsISupports*);
template <typename U>
void assign_from_qi(const nsQueryInterface<U>, const nsIID&);
@ -635,7 +640,7 @@ class MOZ_IS_REFPTR nsCOMPtr final
// Assignment operators
nsCOMPtr<T>& operator=(const nsCOMPtr<T>& aRhs) {
assign_with_AddRef(aRhs.mRawPtr);
assign_with_AddRef(ToSupports(aRhs.mRawPtr));
return *this;
}
@ -644,7 +649,7 @@ class MOZ_IS_REFPTR nsCOMPtr final
// Make sure that U actually inherits from T
static_assert(mozilla::IsBaseOf<T, U>::value,
"U should be a subclass of T");
assign_with_AddRef(static_cast<T*>(aRhs.get()));
assign_with_AddRef(ToSupports(static_cast<T*>(aRhs.get())));
return *this;
}
@ -664,7 +669,7 @@ class MOZ_IS_REFPTR nsCOMPtr final
}
nsCOMPtr<T>& operator=(T* aRhs) {
assign_with_AddRef(aRhs);
assign_with_AddRef(ToSupports(aRhs));
NSCAP_ASSERT_NO_QUERY_NEEDED();
return *this;
}
@ -780,7 +785,7 @@ class MOZ_IS_REFPTR nsCOMPtr final
// Exchange ownership with |aRhs|; can save a pair of refcount operations.
void swap(T*& aRhs) {
#ifdef NSCAP_FEATURE_USE_BASE
nsISupports* temp = aRhs;
nsISupports* temp = ToSupports(aRhs);
#else
T* temp = aRhs;
#endif

View File

@ -34,6 +34,8 @@
" should not have a public destructor. " \
"Make this class's destructor non-public");
inline nsISupports* ToSupports(decltype(nullptr)) { return nullptr; }
inline nsISupports* ToSupports(nsISupports* aSupports) { return aSupports; }
////////////////////////////////////////////////////////////////////////////////
@ -147,10 +149,10 @@ class nsAutoOwningThread {
* Note: The explicit comparison to nullptr is needed to avoid warnings
* when _p is a nullptr itself. */
#define NSCAP_LOG_ASSIGNMENT(_c, _p) \
if (_p != nullptr) NS_LogCOMPtrAddRef((_c), static_cast<nsISupports*>(_p))
if (_p != nullptr) NS_LogCOMPtrAddRef((_c), ToSupports(_p))
#define NSCAP_LOG_RELEASE(_c, _p) \
if (_p) NS_LogCOMPtrRelease((_c), static_cast<nsISupports*>(_p))
if (_p) NS_LogCOMPtrRelease((_c), ToSupports(_p))
#else /* !NS_BUILD_REFCNT_LOGGING */

View File

@ -649,8 +649,7 @@ NS_IMETHODIMP nsContentTreeOwner::SetTitle(const nsAString& aTitle) {
//
nsCOMPtr<nsIDocShellTreeItem> dsitem;
GetPrimaryContentShell(getter_AddRefs(dsitem));
nsCOMPtr<nsIScriptObjectPrincipal> doc =
do_QueryInterface(dsitem ? dsitem->GetDocument() : nullptr);
nsCOMPtr<nsIDocument> doc = dsitem ? dsitem->GetDocument() : nullptr;
if (doc) {
nsCOMPtr<nsIURI> uri;
nsIPrincipal* principal = doc->GetPrincipal();

View File

@ -7,6 +7,7 @@
#include "nsLayoutCID.h"
#include "nsContentCID.h"
#include "nsContentList.h"
#include "nsIWeakReference.h"
#include "nsIContentViewer.h"
#include "nsIComponentManager.h"