Bug 1388939, part 2 - Pair up and document the various nsFrameManager methods for keeping track of "undisplayed" style contexts. r=dholbert
authorJonathan Watt <jwatt@jwatt.org>
Tue, 01 Aug 2017 14:43:15 +0100
changeset 373927 031a3b30aadf80eb786605f670e89e72e63ac727
parent 373926 5615257eb337ff70f1b246e5db61b4404b116120
child 373928 0090af474246367f802c432c08664a7697f41c44
push id32311
push userkwierso@gmail.com
push dateFri, 11 Aug 2017 01:14:57 +0000
treeherdermozilla-central@253a8560dc34 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1388939
milestone57.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 1388939, part 2 - Pair up and document the various nsFrameManager methods for keeping track of "undisplayed" style contexts. r=dholbert MozReview-Commit-ID: F8GvrXdvLEm
layout/base/nsFrameManager.h
--- a/layout/base/nsFrameManager.h
+++ b/layout/base/nsFrameManager.h
@@ -58,101 +58,131 @@ struct UndisplayedNode : public LinkedLi
  *
  * Do not add virtual methods (a vtable pointer) or members to this class, or
  * else you'll break the validity of the reinterpret_cast in nsIPresShell's
  * FrameManager() method.
  */
 class nsFrameManager : public nsFrameManagerBase
 {
   typedef mozilla::layout::FrameChildListID ChildListID;
+  typedef mozilla::UndisplayedNode UndisplayedNode;
 
 public:
   explicit nsFrameManager(nsIPresShell* aPresShell) {
     mPresShell = aPresShell;
     MOZ_ASSERT(mPresShell, "need a pres shell");
   }
   ~nsFrameManager();
 
   /*
    * After Destroy is called, it is an error to call any FrameManager methods.
    * Destroy should be called when the frame tree managed by the frame
    * manager is no longer being displayed.
    */
   void Destroy();
 
-  // Mapping undisplayed content
+
+  // display:none and display:contents content does not get an nsIFrame.  To
+  // enable the style context for such content to be obtained we store the
+  // contexts in a couple of hash tables.  The following methods provide the
+  // API that's used to set, reset, obtain and clear these style contexts.
+
+  /**
+   * Register the style context for the display:none content, aContent.
+   */
+  void SetUndisplayedContent(nsIContent* aContent,
+                             nsStyleContext* aStyleContext);
+
+  /**
+   * Register the style context for the display:contents content, aContent.
+   */
+  void SetDisplayContents(nsIContent* aContent, nsStyleContext* aStyleContext);
+
+  /**
+   * Change the style context for the display:none content, aContent.
+   */
+  void ChangeUndisplayedContent(nsIContent* aContent,
+                                nsStyleContext* aStyleContext)
+  {
+    ChangeStyleContextInMap(mDisplayNoneMap, aContent, aStyleContext);
+  }
+
+  /**
+   * Change the style context for the display:contents content, aContent.
+   */
+  void ChangeDisplayContents(nsIContent* aContent,
+                             nsStyleContext* aStyleContext)
+  {
+    ChangeStyleContextInMap(mDisplayContentsMap, aContent, aStyleContext);
+  }
+
+  /**
+   * Get the style context for the display:none content, aContent, if any.
+   */
   nsStyleContext* GetUndisplayedContent(const nsIContent* aContent)
   {
     if (!mDisplayNoneMap) {
       return nullptr;
     }
     return GetStyleContextInMap(mDisplayNoneMap, aContent);
   }
-  mozilla::UndisplayedNode*
-    GetAllUndisplayedContentIn(nsIContent* aParentContent);
-  void SetUndisplayedContent(nsIContent* aContent,
-                             nsStyleContext* aStyleContext);
-  void ChangeUndisplayedContent(nsIContent* aContent,
-                                nsStyleContext* aStyleContext)
-  {
-    ChangeStyleContextInMap(mDisplayNoneMap, aContent, aStyleContext);
-  }
 
-  void ClearUndisplayedContentIn(nsIContent* aContent,
-                                 nsIContent* aParentContent);
-
-  // display:contents related methods:
   /**
-   * Return the registered display:contents style context for aContent, if any.
+   * Get the style context for the display:contents content, aContent, if any.
    */
   nsStyleContext* GetDisplayContentsStyleFor(const nsIContent* aContent)
   {
     if (!mDisplayContentsMap) {
       return nullptr;
     }
     return GetStyleContextInMap(mDisplayContentsMap, aContent);
   }
 
   /**
-   * Return the linked list of UndisplayedNodes containing the registered
-   * display:contents children of aParentContent, if any.
+   * Return the linked list of UndisplayedNodes that contain the style contexts
+   * that have been registered for the display:none children of
+   * aParentContent.
    */
-  mozilla::UndisplayedNode* GetAllDisplayContentsIn(nsIContent* aParentContent);
+  UndisplayedNode* GetAllUndisplayedContentIn(nsIContent* aParentContent);
+
+  /**
+   * Return the linked list of UndisplayedNodes that contain the style contexts
+   * that have been registered for the display:contents children of
+   * aParentContent.
+   */
+  UndisplayedNode* GetAllDisplayContentsIn(nsIContent* aParentContent);
 
   /**
    * Return the relevant undisplayed node for a given content with display:
    * contents style.
    */
-  mozilla::UndisplayedNode* GetDisplayContentsNodeFor(
-      const nsIContent* aContent) {
+  UndisplayedNode* GetDisplayContentsNodeFor(const nsIContent* aContent)
+  {
     if (!mDisplayContentsMap) {
       return nullptr;
     }
     return GetUndisplayedNodeInMapFor(mDisplayContentsMap, aContent);
   }
 
   /**
-   * Register aContent having a display:contents style context.
-   */
-  void SetDisplayContents(nsIContent* aContent, nsStyleContext* aStyleContext);
-  /**
-   * Change the registered style context for aContent to aStyleContext.
+   * Unregister the style context for the display:none content, aContent,
+   * if any.  If found, then this method also unregisters the style contexts
+   * for any display:contents and display:none descendants of aContent.
    */
-  void ChangeDisplayContents(nsIContent* aContent,
-                             nsStyleContext* aStyleContext)
-  {
-    ChangeStyleContextInMap(mDisplayContentsMap, aContent, aStyleContext);
-  }
+  void ClearUndisplayedContentIn(nsIContent* aContent,
+                                 nsIContent* aParentContent);
 
   /**
-   * Unregister the display:contents style context for aContent, if any.
-   * If found, then also unregister any display:contents and display:none
-   * style contexts for its descendants.
+   * Unregister the style context for the display:contents content, aContent,
+   * if any.  If found, then this method also unregisters the style contexts
+   * for any display:contents and display:none descendants of aContent.
    */
-  void ClearDisplayContentsIn(nsIContent* aContent, nsIContent* aParentContent);
+  void ClearDisplayContentsIn(nsIContent* aContent,
+                              nsIContent* aParentContent);
+
 
   // Functions for manipulating the frame model
   void AppendFrames(nsContainerFrame* aParentFrame,
                     ChildListID aListID,
                     nsFrameList& aFrameList);
 
   void InsertFrames(nsContainerFrame* aParentFrame,
                     ChildListID aListID,