LCOV - code coverage report
Current view: top level - layout/base - nsFrameManager.h (source / functions) Hit Total Coverage
Test: output.info Lines: 19 28 67.9 %
Date: 2017-07-14 16:53:18 Functions: 6 8 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  * vim:cindent:ts=2:et:sw=2:
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * This Original Code has been modified by IBM Corporation. Modifications made
       9             :  * by IBM described herein are Copyright (c) International Business Machines
      10             :  * Corporation, 2000. Modifications to Mozilla code or documentation identified
      11             :  * per MPL Section 3.3
      12             :  *
      13             :  * Date             Modified by     Description of modification
      14             :  * 04/20/2000       IBM Corp.      OS/2 VisualAge build.
      15             :  */
      16             : 
      17             : /* storage of the frame tree and information about it */
      18             : 
      19             : #ifndef _nsFrameManager_h_
      20             : #define _nsFrameManager_h_
      21             : 
      22             : #include "nsFrameManagerBase.h"
      23             : 
      24             : #include "nsFrameList.h"
      25             : #include "nsIContent.h"
      26             : #include "nsStyleContext.h"
      27             : 
      28             : class nsContainerFrame;
      29             : class nsPlaceholderFrame;
      30             : 
      31             : namespace mozilla {
      32             : /**
      33             :  * Node in a linked list, containing the style for an element that
      34             :  * does not have a frame but whose parent does have a frame.
      35             :  */
      36             : struct UndisplayedNode : public LinkedListElement<UndisplayedNode>
      37             : {
      38         294 :   UndisplayedNode(nsIContent* aContent, nsStyleContext* aStyle)
      39         294 :     : mContent(aContent)
      40         294 :     , mStyle(aStyle)
      41             :   {
      42         294 :     MOZ_COUNT_CTOR(mozilla::UndisplayedNode);
      43         294 :   }
      44             : 
      45          73 :   ~UndisplayedNode() { MOZ_COUNT_DTOR(mozilla::UndisplayedNode); }
      46             : 
      47             :   nsCOMPtr<nsIContent> mContent;
      48             :   RefPtr<nsStyleContext> mStyle;
      49             : };
      50             : 
      51             : } // namespace mozilla
      52             : 
      53             : /**
      54             :  * Frame manager interface. The frame manager serves one purpose:
      55             :  * <li>handles structural modifications to the frame model. If the frame model
      56             :  * lock can be acquired, then the changes are processed immediately; otherwise,
      57             :  * they're queued and processed later.
      58             :  *
      59             :  * Do not add virtual methods (a vtable pointer) or members to this class, or
      60             :  * else you'll break the validity of the reinterpret_cast in nsIPresShell's
      61             :  * FrameManager() method.
      62             :  */
      63             : class nsFrameManager : public nsFrameManagerBase
      64             : {
      65             :   typedef mozilla::layout::FrameChildListID ChildListID;
      66             : 
      67             : public:
      68          28 :   explicit nsFrameManager(nsIPresShell* aPresShell) {
      69          28 :     mPresShell = aPresShell;
      70          28 :     MOZ_ASSERT(mPresShell, "need a pres shell");
      71          28 :   }
      72             :   ~nsFrameManager();
      73             : 
      74             :   /*
      75             :    * After Destroy is called, it is an error to call any FrameManager methods.
      76             :    * Destroy should be called when the frame tree managed by the frame
      77             :    * manager is no longer being displayed.
      78             :    */
      79             :   void Destroy();
      80             : 
      81             :   // Mapping undisplayed content
      82          61 :   nsStyleContext* GetUndisplayedContent(const nsIContent* aContent)
      83             :   {
      84          61 :     if (!mUndisplayedMap) {
      85           0 :       return nullptr;
      86             :     }
      87          61 :     return GetStyleContextInMap(mUndisplayedMap, aContent);
      88             :   }
      89             :   mozilla::UndisplayedNode*
      90             :     GetAllUndisplayedContentIn(nsIContent* aParentContent);
      91             :   void SetUndisplayedContent(nsIContent* aContent,
      92             :                              nsStyleContext* aStyleContext);
      93           8 :   void ChangeUndisplayedContent(nsIContent* aContent,
      94             :                                 nsStyleContext* aStyleContext)
      95             :   {
      96           8 :     ChangeStyleContextInMap(mUndisplayedMap, aContent, aStyleContext);
      97           8 :   }
      98             : 
      99             :   void ClearUndisplayedContentIn(nsIContent* aContent,
     100             :                                  nsIContent* aParentContent);
     101             : 
     102             :   // display:contents related methods:
     103             :   /**
     104             :    * Return the registered display:contents style context for aContent, if any.
     105             :    */
     106        4313 :   nsStyleContext* GetDisplayContentsStyleFor(const nsIContent* aContent)
     107             :   {
     108        4313 :     if (!mDisplayContentsMap) {
     109        4313 :       return nullptr;
     110             :     }
     111           0 :     return GetStyleContextInMap(mDisplayContentsMap, aContent);
     112             :   }
     113             : 
     114             :   /**
     115             :    * Return the linked list of UndisplayedNodes containing the registered
     116             :    * display:contents children of aParentContent, if any.
     117             :    */
     118             :   mozilla::UndisplayedNode* GetAllDisplayContentsIn(nsIContent* aParentContent);
     119             : 
     120             :   /**
     121             :    * Return the relevant undisplayed node for a given content with display:
     122             :    * contents style.
     123             :    */
     124           0 :   mozilla::UndisplayedNode* GetDisplayContentsNodeFor(
     125             :       const nsIContent* aContent) {
     126           0 :     if (!mDisplayContentsMap) {
     127           0 :       return nullptr;
     128             :     }
     129           0 :     return GetUndisplayedNodeInMapFor(mDisplayContentsMap, aContent);
     130             :   }
     131             : 
     132             :   /**
     133             :    * Register aContent having a display:contents style context.
     134             :    */
     135             :   void SetDisplayContents(nsIContent* aContent, nsStyleContext* aStyleContext);
     136             :   /**
     137             :    * Change the registered style context for aContent to aStyleContext.
     138             :    */
     139           0 :   void ChangeDisplayContents(nsIContent* aContent,
     140             :                              nsStyleContext* aStyleContext)
     141             :   {
     142           0 :     ChangeStyleContextInMap(mDisplayContentsMap, aContent, aStyleContext);
     143           0 :   }
     144             : 
     145             :   /**
     146             :    * Unregister the display:contents style context for aContent, if any.
     147             :    * If found, then also unregister any display:contents and display:none
     148             :    * style contexts for its descendants.
     149             :    */
     150             :   void ClearDisplayContentsIn(nsIContent* aContent, nsIContent* aParentContent);
     151             : 
     152             :   // Functions for manipulating the frame model
     153             :   void AppendFrames(nsContainerFrame* aParentFrame,
     154             :                     ChildListID aListID,
     155             :                     nsFrameList& aFrameList);
     156             : 
     157             :   void InsertFrames(nsContainerFrame* aParentFrame,
     158             :                     ChildListID aListID,
     159             :                     nsIFrame* aPrevFrame,
     160             :                     nsFrameList& aFrameList);
     161             : 
     162             :   void RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame);
     163             : 
     164             :   /*
     165             :    * Notification that a frame is about to be destroyed. This allows any
     166             :    * outstanding references to the frame to be cleaned up.
     167             :    */
     168             :   void NotifyDestroyingFrame(nsIFrame* aFrame);
     169             : 
     170             :   /*
     171             :    * Capture/restore frame state for the frame subtree rooted at aFrame.
     172             :    * aState is the document state storage object onto which each frame
     173             :    * stores its state.  Callers of CaptureFrameState are responsible for
     174             :    * traversing next continuations of special siblings of aFrame as
     175             :    * needed; this method will only work with actual frametree descendants
     176             :    * of aFrame.
     177             :    */
     178             : 
     179             :   void CaptureFrameState(nsIFrame* aFrame, nsILayoutHistoryState* aState);
     180             : 
     181             :   void RestoreFrameState(nsIFrame* aFrame, nsILayoutHistoryState* aState);
     182             : 
     183             :   /*
     184             :    * Add/restore state for one frame
     185             :    */
     186             :   void CaptureFrameStateFor(nsIFrame* aFrame, nsILayoutHistoryState* aState);
     187             : 
     188             :   void RestoreFrameStateFor(nsIFrame* aFrame, nsILayoutHistoryState* aState);
     189             : 
     190             : protected:
     191             :   void ClearAllMapsFor(nsIContent* aParentContent);
     192             : 
     193             :   static nsStyleContext* GetStyleContextInMap(UndisplayedMap* aMap,
     194             :                                               const nsIContent* aContent);
     195             :   static mozilla::UndisplayedNode*
     196             :     GetUndisplayedNodeInMapFor(UndisplayedMap* aMap,
     197             :                                const nsIContent* aContent);
     198             :   static mozilla::UndisplayedNode*
     199             :     GetAllUndisplayedNodesInMapFor(UndisplayedMap* aMap,
     200             :                                    nsIContent* aParentContent);
     201             :   static void SetStyleContextInMap(UndisplayedMap* aMap,
     202             :                                    nsIContent* aContent,
     203             :                                    nsStyleContext* aStyleContext);
     204             :   static void ChangeStyleContextInMap(UndisplayedMap* aMap,
     205             :                                       nsIContent* aContent,
     206             :                                       nsStyleContext* aStyleContext);
     207             : };
     208             : 
     209             : #endif

Generated by: LCOV version 1.13