Bug 1446568: Move the blocked tracking nodes methods to nsIDocument. r=smaug draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 15 Mar 2018 18:41:34 +0100
changeset 768876 f5cad5baa6b49d388673d1d0c6a41cacd4592649
parent 768875 beeee5c7b288ad3567ce3a3372eddf3fe1ff833b
child 768877 6c5d2cd2e61b92ad2933395fea891a995136f255
push id102997
push userbmo:emilio@crisal.io
push dateSat, 17 Mar 2018 00:00:09 +0000
reviewerssmaug
bugs1446568
milestone61.0a1
Bug 1446568: Move the blocked tracking nodes methods to nsIDocument. r=smaug MozReview-Commit-ID: LuvoFP8UyNg
dom/base/nsDocument.cpp
dom/base/nsDocument.h
dom/base/nsIDocument.h
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -5946,24 +5946,18 @@ nsIDocument::ResolveScheduledSVGPresAttr
 {
   for (auto iter = mLazySVGPresElements.Iter(); !iter.Done(); iter.Next()) {
     nsSVGElement* svg = iter.Get()->GetKey();
     svg->UpdateContentDeclarationBlock(StyleBackendType::Servo);
   }
   mLazySVGPresElements.Clear();
 }
 
-long
-nsDocument::BlockedTrackingNodeCount() const
-{
-  return mBlockedTrackingNodes.Length();
-}
-
 already_AddRefed<nsSimpleContentList>
-nsDocument::BlockedTrackingNodes() const
+nsIDocument::BlockedTrackingNodes() const
 {
   RefPtr<nsSimpleContentList> list = new nsSimpleContentList(nullptr);
 
   nsTArray<nsWeakPtr> blockedTrackingNodes;
   blockedTrackingNodes = mBlockedTrackingNodes;
 
   for (unsigned long i = 0; i < blockedTrackingNodes.Length(); i++) {
     nsWeakPtr weakNode = blockedTrackingNodes[i];
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -287,42 +287,16 @@ public:
 
   nsresult CloneDocHelper(nsDocument* clone, bool aPreallocateChildren) const;
 
   void MaybeEndOutermostXBLUpdate();
 
   // Only BlockOnload should call this!
   void AsyncBlockOnload();
 
-  // Returns the size of the mBlockedTrackingNodes array. (nsIDocument.h)
-  //
-  // This array contains nodes that have been blocked to prevent
-  // user tracking. They most likely have had their nsIChannel
-  // canceled by the URL classifier (Safebrowsing).
-  //
-  // A script can subsequently use GetBlockedTrackingNodes()
-  // to get a list of references to these nodes.
-  //
-  // Note:
-  // This expresses how many tracking nodes have been blocked for this
-  // document since its beginning, not how many of them are still around
-  // in the DOM tree. Weak references to blocked nodes are added in the
-  // mBlockedTrackingNodesArray but they are not removed when those nodes
-  // are removed from the tree or even garbage collected.
-  long BlockedTrackingNodeCount() const;
-
-  //
-  // Returns strong references to mBlockedTrackingNodes. (nsIDocument.h)
-  //
-  // This array contains nodes that have been blocked to prevent
-  // user tracking. They most likely have had their nsIChannel
-  // canceled by the URL classifier (Safebrowsing).
-  //
-  already_AddRefed<nsSimpleContentList> BlockedTrackingNodes() const;
-
   virtual void DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const override;
   // DocAddSizeOfIncludingThis is inherited from nsIDocument.
 
   virtual nsIDOMNode* AsDOMNode() override { return this; }
 
 protected:
   friend class nsNodeUtils;
 
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -1400,16 +1400,45 @@ public:
 
   // Resolve all SVG pres attrs scheduled in ScheduleSVGForPresAttrEvaluation
   void ResolveScheduledSVGPresAttrs();
 
   mozilla::Maybe<mozilla::dom::ClientInfo> GetClientInfo() const;
   mozilla::Maybe<mozilla::dom::ClientState> GetClientState() const;
   mozilla::Maybe<mozilla::dom::ServiceWorkerDescriptor> GetController() const;
 
+  // Returns the size of the mBlockedTrackingNodes array.
+  //
+  // This array contains nodes that have been blocked to prevent
+  // user tracking. They most likely have had their nsIChannel
+  // canceled by the URL classifier (Safebrowsing).
+  //
+  // A script can subsequently use GetBlockedTrackingNodes()
+  // to get a list of references to these nodes.
+  //
+  // Note:
+  // This expresses how many tracking nodes have been blocked for this
+  // document since its beginning, not how many of them are still around
+  // in the DOM tree. Weak references to blocked nodes are added in the
+  // mBlockedTrackingNodesArray but they are not removed when those nodes
+  // are removed from the tree or even garbage collected.
+  long BlockedTrackingNodeCount() const
+  {
+    return mBlockedTrackingNodes.Length();
+  }
+
+  //
+  // Returns strong references to mBlockedTrackingNodes. (nsIDocument.h)
+  //
+  // This array contains nodes that have been blocked to prevent
+  // user tracking. They most likely have had their nsIChannel
+  // canceled by the URL classifier (Safebrowsing).
+  //
+  already_AddRefed<nsSimpleContentList> BlockedTrackingNodes() const;
+
 protected:
   void DispatchContentLoadedEvents();
 
   void DispatchPageTransition(mozilla::dom::EventTarget* aDispatchTarget,
                               const nsAString& aType,
                               bool aPersisted);
 
   // Call this before the document does something that will unbind all content.