Bug 1446568: Move UseCounter stuff and IsSynthesized to nsIDocument. r=smaug
MozReview-Commit-ID: IeKzmi31e8d
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -2682,17 +2682,17 @@ WarnIfSandboxIneffective(nsIDocShell* aD
parentDocument,
nsContentUtils::eSECURITY_PROPERTIES,
"BothAllowScriptsAndSameOriginPresent",
nullptr, 0, iframeUri);
}
}
bool
-nsDocument::IsSynthesized() {
+nsIDocument::IsSynthesized() {
nsCOMPtr<nsIHttpChannelInternal> internalChan = do_QueryInterface(mChannel);
bool synthesized = false;
if (internalChan) {
DebugOnly<nsresult> rv = internalChan->GetResponseSynthesized(&synthesized);
MOZ_ASSERT(NS_SUCCEEDED(rv), "GetResponseSynthesized shouldn't fail.");
}
return synthesized;
}
@@ -12230,17 +12230,17 @@ ReportExternalResourceUseCounters(nsIDoc
{
const auto reportKind
= nsDocument::UseCounterReportKind::eIncludeExternalResources;
static_cast<nsDocument*>(aDocument)->ReportUseCounters(reportKind);
return true;
}
void
-nsDocument::ReportUseCounters(UseCounterReportKind aKind)
+nsIDocument::ReportUseCounters(UseCounterReportKind aKind)
{
static const bool sDebugUseCounters = false;
if (mReportedUseCounters) {
return;
}
mReportedUseCounters = true;
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -201,32 +201,16 @@ public:
bool aRequiredAdded) override;
virtual bool GetValueMissingState(const nsAString& aName) const override;
virtual void SetValueMissingState(const nsAString& aName, bool aValue) override;
// for radio group
nsRadioGroupStruct* GetRadioGroup(const nsAString& aName) const;
nsRadioGroupStruct* GetOrCreateRadioGroup(const nsAString& aName);
- enum class UseCounterReportKind {
- // Flush the document's use counters only; the use counters for any
- // external resource documents will be flushed when the external
- // resource documents themselves are destroyed.
- eDefault,
-
- // Flush use counters for the document and for its external resource
- // documents. (Should only be necessary for tests, where we need
- // flushing to happen synchronously and deterministically.)
- eIncludeExternalResources,
- };
-
- void ReportUseCounters(UseCounterReportKind aKind = UseCounterReportKind::eDefault);
-
- bool IsSynthesized();
-
// Check whether shadow DOM is enabled for the global of aObject.
static bool IsShadowDOMEnabled(JSContext* aCx, JSObject* aObject);
// Check whether shadow DOM is enabled for the document this node belongs to.
static bool IsShadowDOMEnabled(const nsINode* aNode);
public:
// nsIDOMDocument
NS_DECL_NSIDOMDOCUMENT
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -3489,16 +3489,32 @@ public:
void MarkUserFontSetDirty();
mozilla::dom::FontFaceSet* GetFonts() { return mFontFaceSet; }
// FontFaceSource
mozilla::dom::FontFaceSet* Fonts();
bool DidFireDOMContentLoaded() const { return mDidFireDOMContentLoaded; }
+ bool IsSynthesized();
+
+ enum class UseCounterReportKind {
+ // Flush the document's use counters only; the use counters for any
+ // external resource documents will be flushed when the external
+ // resource documents themselves are destroyed.
+ eDefault,
+
+ // Flush use counters for the document and for its external resource
+ // documents. (Should only be necessary for tests, where we need
+ // flushing to happen synchronously and deterministically.)
+ eIncludeExternalResources,
+ };
+
+ void ReportUseCounters(UseCounterReportKind aKind = UseCounterReportKind::eDefault);
+
void SetDocumentUseCounter(mozilla::UseCounter aUseCounter)
{
if (!mUseCounters[aUseCounter]) {
mUseCounters[aUseCounter] = true;
}
}
void SetPageUseCounter(mozilla::UseCounter aUseCounter);