Bug 1446568: Move UseCounter stuff and IsSynthesized to nsIDocument. r=smaug draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 15 Mar 2018 19:37:02 +0100
changeset 768882 496598da9d2fbeeeb4056b518c66f69495333dae
parent 768881 8370ff3b312f1968b1a61f9a60a81796ed9fb600
child 768883 b2e82a4a4e85f67e37e94e1d0a875b1457aeb8f7
push id102997
push userbmo:emilio@crisal.io
push dateSat, 17 Mar 2018 00:00:09 +0000
reviewerssmaug
bugs1446568
milestone61.0a1
Bug 1446568: Move UseCounter stuff and IsSynthesized to nsIDocument. r=smaug MozReview-Commit-ID: IeKzmi31e8d
dom/base/nsDocument.cpp
dom/base/nsDocument.h
dom/base/nsIDocument.h
--- 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);