Bug 1624359 - Remove Document::mVisibleContentHeuristic. r=smaug
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 24 Mar 2020 12:27:54 +0000
changeset 520210 8794663e89e0cff217fed41ea79b60c3de94bfb1
parent 520209 b9b0ad80cd8b538b8802ed6cb9c7be50ad14bc44
child 520211 6f13cd068474c9cdb5cc2ee81b854cd2feb5998a
push id37245
push useropoprus@mozilla.com
push dateTue, 24 Mar 2020 21:46:41 +0000
treeherdermozilla-central@dbabf2e388fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1624359
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1624359 - Remove Document::mVisibleContentHeuristic. r=smaug We added it so the perf team could run some experiments, and they were done but the code was left... Differential Revision: https://phabricator.services.mozilla.com/D67897
dom/base/BindContext.h
dom/base/CharacterData.cpp
dom/base/Document.h
dom/base/Element.cpp
--- a/dom/base/BindContext.h
+++ b/dom/base/BindContext.h
@@ -47,93 +47,52 @@ struct MOZ_STACK_CLASS BindContext final
   // Whether our subtree root is changing as a result of this operation.
   bool SubtreeRootChanges() const { return mSubtreeRootChanges; }
 
   // This constructor should be used for regular appends to content.
   explicit BindContext(nsINode& aParent)
       : mDoc(*aParent.OwnerDoc()),
         mInComposedDoc(aParent.IsInComposedDoc()),
         mInUncomposedDoc(aParent.IsInUncomposedDoc()),
-        mSubtreeRootChanges(true),
-        mCollectingDisplayedNodeDataDuringLoad(
-            ShouldCollectDisplayedNodeDataDuringLoad(mInComposedDoc, mDoc,
-                                                     aParent)) {}
+        mSubtreeRootChanges(true) {}
 
   // When re-binding a shadow host into a tree, we re-bind all the shadow tree
   // from the root. In that case, the shadow tree contents remain within the
   // same subtree root.  So children should avoid doing silly things like adding
   // themselves to the ShadowRoot's id table twice or what not.
   //
   // This constructor is only meant to be used in that situation.
   explicit BindContext(ShadowRoot& aShadowRoot)
       : mDoc(*aShadowRoot.OwnerDoc()),
         mInComposedDoc(aShadowRoot.IsInComposedDoc()),
         mInUncomposedDoc(false),
-        mSubtreeRootChanges(false),
-        mCollectingDisplayedNodeDataDuringLoad(
-            ShouldCollectDisplayedNodeDataDuringLoad(mInComposedDoc, mDoc,
-                                                     aShadowRoot)) {}
+        mSubtreeRootChanges(false) {}
 
   // This constructor is meant to be used when inserting native-anonymous
   // children into a subtree.
   enum ForNativeAnonymous { ForNativeAnonymous };
   BindContext(Element& aParentElement, enum ForNativeAnonymous)
       : mDoc(*aParentElement.OwnerDoc()),
         mInComposedDoc(aParentElement.IsInComposedDoc()),
         mInUncomposedDoc(aParentElement.IsInUncomposedDoc()),
-        mSubtreeRootChanges(true),
-        mCollectingDisplayedNodeDataDuringLoad(
-            ShouldCollectDisplayedNodeDataDuringLoad(mInComposedDoc, mDoc,
-                                                     aParentElement)) {
+        mSubtreeRootChanges(true) {
     MOZ_ASSERT(mInComposedDoc, "Binding NAC in a disconnected subtree?");
   }
 
-  bool CollectingDisplayedNodeDataDuringLoad() const {
-    return mCollectingDisplayedNodeDataDuringLoad;
-  }
-
  private:
   static bool IsLikelyUndisplayed(const nsINode& aParent) {
     return aParent.IsAnyOfHTMLElements(nsGkAtoms::style, nsGkAtoms::script);
   }
 
-  static bool ShouldCollectDisplayedNodeDataDuringLoad(bool aConnected,
-                                                       Document& aDoc,
-                                                       nsINode& aParent) {
-    return aDoc.GetReadyStateEnum() == Document::READYSTATE_LOADING &&
-           aConnected && !IsLikelyUndisplayed(aParent);
-  }
-
   Document& mDoc;
 
   const bool mInComposedDoc;
   const bool mInUncomposedDoc;
 
   // Whether the bind operation will change the subtree root of the content
   // we're binding.
   const bool mSubtreeRootChanges;
-
-  // Whether it's likely that we're in an undisplayed part of the DOM.
-  //
-  // NOTE(emilio): We don't inherit this in BindContext's for Shadow DOM or XBL
-  // or such. This means that if you have a shadow tree inside an undisplayed
-  // element it will be incorrectly counted.  But given our current definition
-  // of undisplayed element this is not likely to matter in practice.
-  bool mCollectingDisplayedNodeDataDuringLoad;
-};
-
-struct MOZ_STACK_CLASS BindContext::NestingLevel {
-  explicit NestingLevel(BindContext& aContext, const Element& aParent)
-      : mRestoreCollecting(aContext.mCollectingDisplayedNodeDataDuringLoad) {
-    if (aContext.mCollectingDisplayedNodeDataDuringLoad) {
-      aContext.mCollectingDisplayedNodeDataDuringLoad =
-          BindContext::IsLikelyUndisplayed(aParent);
-    }
-  }
-
- private:
-  AutoRestore<bool> mRestoreCollecting;
 };
 
 }  // namespace dom
 }  // namespace mozilla
 
 #endif
--- a/dom/base/CharacterData.cpp
+++ b/dom/base/CharacterData.cpp
@@ -433,23 +433,18 @@ nsresult CharacterData::BindToTree(BindC
     } else {
       SetFlags(NODE_IS_IN_SHADOW_TREE);
       MOZ_ASSERT(aParent.IsContent() &&
                  aParent.AsContent()->GetContainingShadow());
       ExtendedContentSlots()->mContainingShadow =
           aParent.AsContent()->GetContainingShadow();
     }
 
-    if (IsInComposedDoc()) {
-      if (mText.IsBidi()) {
-        aContext.OwnerDoc().SetBidiEnabled();
-      }
-      if (aContext.CollectingDisplayedNodeDataDuringLoad()) {
-        aContext.OwnerDoc().AddToVisibleContentHeuristic(mText.GetLength());
-      }
+    if (IsInComposedDoc() && mText.IsBidi()) {
+      aContext.OwnerDoc().SetBidiEnabled();
     }
 
     // Clear the lazy frame construction bits.
     UnsetFlags(NODE_NEEDS_FRAME | NODE_DESCENDANTS_NEED_FRAMES);
   } else {
     // If we're not in the doc and not in a shadow tree,
     // update our subtree pointer.
     SetSubtreeRootPointer(aParent.SubtreeRoot());
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -3520,24 +3520,16 @@ class Document : public nsINode,
 
   const StyleUseCounters* GetStyleUseCounters() {
     return mStyleUseCounters.get();
   }
 
   void PropagateUseCountersToPage();
   void PropagateUseCounters(Document* aParentDocument);
 
-  void AddToVisibleContentHeuristic(uint32_t aNumber) {
-    mVisibleContentHeuristic += aNumber;
-  }
-
-  uint32_t GetVisibleContentHeuristic() const {
-    return mVisibleContentHeuristic.value();
-  }
-
   // Called to track whether this document has had any interaction.
   // This is used to track whether we should permit "beforeunload".
   void SetUserHasInteracted();
   bool UserHasInteracted() { return mUserHasInteracted; }
   void ResetUserInteractionTimer();
 
   // This method would return current autoplay policy, it would be "allowed"
   // , "allowed-muted" or "disallowed".
@@ -4807,26 +4799,16 @@ class Document : public nsINode,
   // Flags for use counters used directly by this document.
   std::bitset<eUseCounter_Count> mUseCounters;
   // Flags for use counters used by any child documents of this document.
   std::bitset<eUseCounter_Count> mChildDocumentUseCounters;
 
   // The CSS property use counters.
   UniquePtr<StyleUseCounters> mStyleUseCounters;
 
-  // An ever-increasing heuristic number that is higher the more content is
-  // likely to be visible in the page.
-  //
-  // Right now it effectively measures amount of text content that has ever been
-  // connected to the document in some way, and is not under a <script> or
-  // <style>.
-  //
-  // Note that this is only measured during load.
-  SaturateUint32 mVisibleContentHeuristic{0};
-
   // Whether the user has interacted with the document or not:
   bool mUserHasInteracted;
 
   // We constantly update the user-interaction anti-tracking permission at any
   // user-interaction using a timer. This boolean value is set to true when this
   // timer is scheduled.
   bool mHasUserInteractionTimerScheduled;
 
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1583,17 +1583,16 @@ nsresult Element::BindToTree(BindContext
   if (ShadowRoot* shadowRoot = GetShadowRoot()) {
     rv = shadowRoot->Bind();
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // Now recurse into our kids. Ensure this happens after binding the shadow
   // root so that directionality of slots is updated.
   {
-    BindContext::NestingLevel level(aContext, *this);
     for (nsIContent* child = GetFirstChild(); child;
          child = child->GetNextSibling()) {
       rv = child->BindToTree(aContext, *this);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   MutationObservers::NotifyParentChainChanged(this);