Bug 1425702 - Part 1: Add some docs for nsIDocument::{mIsTopLevelContentDocument,mIsContentDocument}. r?bz draft
authorCameron McCormack <cam@mcc.id.au>
Sat, 16 Dec 2017 17:13:06 -0600
changeset 712521 a19a3798913ddc7a272355e1ff5a5998e4735eed
parent 712520 7cb064f0d25e9de7c77589a9459da1ade502b4bb
child 712522 dc7edf4c175d1fe3adc74c0a21f13e1cdc0bd2d1
push id93352
push userbmo:cam@mcc.id.au
push dateSat, 16 Dec 2017 23:49:44 +0000
reviewersbz
bugs1425702
milestone59.0a1
Bug 1425702 - Part 1: Add some docs for nsIDocument::{mIsTopLevelContentDocument,mIsContentDocument}. r?bz MozReview-Commit-ID: Ahmg0dULmlY
dom/base/nsIDocument.h
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -1850,29 +1850,64 @@ public:
   }
   bool LoadsFullXULStyleSheetUpFront()
   {
     return IsXULDocument() || AllowXULXBL();
   }
 
   virtual bool IsScriptEnabled() = 0;
 
-  bool IsTopLevelContentDocument() const { return mIsTopLevelContentDocument; }
+  /**
+   * Returns whether this document is loaded in a content docshell that does not
+   * have another content docshell as a parent.
+   */
+  bool IsTopLevelContentDocument() const
+  {
+    // We use this flag rather than inspecting the current docshell to avoid a
+    // bunch of virtual function calls, since we need to look this up every time
+    // we use some Web platform feature that has a use counter.
+    return mIsTopLevelContentDocument;
+  }
+
+  /**
+   * Updates the flag that records whether this document is loaded in a content
+   * docshell that does not have another content docshell as a parent.
+   *
+   * XXX This is only called from nsIDocument::SetContainer, and ideally
+   * wouldn't be public.
+   */
   void SetIsTopLevelContentDocument(bool aIsTopLevelContentDocument)
   {
     mIsTopLevelContentDocument = aIsTopLevelContentDocument;
     // When a document is set as TopLevelContentDocument, it must be
     // allowpaymentrequest. We handle the false case while a document is appended
     // in SetSubDocumentFor
     if (aIsTopLevelContentDocument) {
       SetAllowPaymentRequest(true);
     }
   }
 
-  bool IsContentDocument() const { return mIsContentDocument; }
+  /**
+   * Returns whether this document is loaded in a content docshell.
+   */
+  bool IsContentDocument() const
+  {
+    // We use this flag rather than inspecting the current docshell to avoid a
+    // bunch of virtual function calls, since we need to look this up every time
+    // we use some Web platform feature that has a use counter.
+    return mIsContentDocument;
+  }
+
+  /**
+   * Updates the flag that records whether this document is loaded in a content
+   * docshell.
+   *
+   * XXX This is only called from nsIDocument::SetContainer, and ideally
+   * wouldn't be public.
+   */
   void SetIsContentDocument(bool aIsContentDocument)
   {
     mIsContentDocument = aIsContentDocument;
   }
 
   /**
    * Create an element with the specified name, prefix and namespace ID.
    * Returns null if element name parsing failed.
@@ -3577,18 +3612,23 @@ protected:
   // True if ReportHasScrollLinkedEffect() has been called.
   bool mHasScrollLinkedEffect : 1;
 
   // True if we have frame request callbacks scheduled with the refresh driver.
   // This should generally be updated only via
   // UpdateFrameRequestCallbackSchedulingState.
   bool mFrameRequestCallbacksScheduled : 1;
 
+  // True if this document is loaded in a content docshell, and that docshell
+  // does not have a parent content docshell.  This flag is updated by
+  // nsIDocument::SetContainer.
   bool mIsTopLevelContentDocument : 1;
 
+  // True if this document is loaded in a content docshell.  This flag is
+  // updated by nsIDocument::SetContainer.
   bool mIsContentDocument : 1;
 
   // True if we have called BeginLoad and are expecting a paired EndLoad call.
   bool mDidCallBeginLoad : 1;
 
   // True if any CSP violation reports for this doucment will be buffered in
   // mBufferedCSPViolations instead of being sent immediately.
   bool mBufferingCSPViolations : 1;