LCOV - code coverage report
Current view: directory - layout/xul/base/src - nsSprocketLayout.h (source / functions) Found Hit Coverage
Test: app.info Lines: 1 0 0.0 %
Date: 2012-06-02 Functions: 2 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is Mozilla Communicator client code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #ifndef nsSprocketLayout_h___
      39                 : #define nsSprocketLayout_h___
      40                 : 
      41                 : #include "nsBoxLayout.h"
      42                 : #include "nsCOMPtr.h"
      43                 : 
      44                 : class nsBoxSize
      45                 : {
      46                 : public:
      47                 : 
      48                 :   nsBoxSize();
      49                 : 
      50                 :   nscoord pref;
      51                 :   nscoord min;
      52                 :   nscoord max;
      53                 :   nscoord flex;
      54                 :   nscoord left;
      55                 :   nscoord right;
      56                 :   bool    collapsed;
      57                 :   bool    bogus;
      58                 : 
      59                 :   nsBoxSize* next;
      60                 : 
      61                 :   void* operator new(size_t sz, nsBoxLayoutState& aState) CPP_THROW_NEW;
      62                 :   void operator delete(void* aPtr, size_t sz);
      63                 : };
      64                 : 
      65                 : class nsComputedBoxSize
      66                 : {
      67                 : public:
      68                 :   nsComputedBoxSize();
      69                 : 
      70                 :   nscoord size;
      71                 :   bool    valid;
      72                 :   bool    resized;
      73                 :   nsComputedBoxSize* next;
      74                 : 
      75                 :   void* operator new(size_t sz, nsBoxLayoutState& aState) CPP_THROW_NEW;
      76                 :   void operator delete(void* aPtr, size_t sz);
      77                 : };
      78                 : 
      79                 : #define GET_WIDTH(size, isHorizontal) (isHorizontal ? size.width : size.height)
      80                 : #define GET_HEIGHT(size, isHorizontal) (isHorizontal ? size.height : size.width)
      81                 : #define GET_X(size, isHorizontal) (isHorizontal ? size.x : size.y)
      82                 : #define GET_Y(size, isHorizontal) (isHorizontal ? size.y : size.x)
      83                 : #define GET_COORD(aX, aY, isHorizontal) (isHorizontal ? aX : aY)
      84                 : 
      85                 : #define SET_WIDTH(size, coord, isHorizontal)  if (isHorizontal) { (size).width  = (coord); } else { (size).height = (coord); }
      86                 : #define SET_HEIGHT(size, coord, isHorizontal) if (isHorizontal) { (size).height = (coord); } else { (size).width  = (coord); }
      87                 : #define SET_X(size, coord, isHorizontal) if (isHorizontal) { (size).x = (coord); } else { (size).y  = (coord); }
      88                 : #define SET_Y(size, coord, isHorizontal) if (isHorizontal) { (size).y = (coord); } else { (size).x  = (coord); }
      89                 : 
      90                 : #define SET_COORD(aX, aY, coord, isHorizontal) if (isHorizontal) { aX = (coord); } else { aY  = (coord); }
      91                 : 
      92                 : nsresult NS_NewSprocketLayout(nsIPresShell* aPresShell, nsCOMPtr<nsBoxLayout>& aNewLayout);
      93                 : 
      94               0 : class nsSprocketLayout : public nsBoxLayout {
      95                 : 
      96                 : public:
      97                 : 
      98                 :   friend nsresult NS_NewSprocketLayout(nsIPresShell* aPresShell, nsCOMPtr<nsBoxLayout>& aNewLayout);
      99                 :   static void Shutdown();
     100                 : 
     101                 :   NS_IMETHOD Layout(nsIBox* aBox, nsBoxLayoutState& aState);
     102                 : 
     103                 :   virtual nsSize GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
     104                 :   virtual nsSize GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
     105                 :   virtual nsSize GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
     106                 :   virtual nscoord GetAscent(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
     107                 : 
     108                 :   nsSprocketLayout();
     109                 : 
     110                 :   static bool IsHorizontal(nsIBox* aBox);
     111                 : 
     112                 :   static void SetLargestSize(nsSize& aSize1, const nsSize& aSize2, bool aIsHorizontal);
     113                 :   static void SetSmallestSize(nsSize& aSize1, const nsSize& aSize2, bool aIsHorizontal);
     114                 : 
     115                 :   static void AddLargestSize(nsSize& aSize, const nsSize& aSizeToAdd, bool aIsHorizontal);
     116                 :   static void AddSmallestSize(nsSize& aSize, const nsSize& aSizeToAdd, bool aIsHorizontal);
     117                 :   static void AddCoord(nscoord& aCoord, nscoord aCoordToAdd);
     118                 : 
     119                 : protected:
     120                 : 
     121                 : 
     122                 :   void ComputeChildsNextPosition(nsIBox* aBox,
     123                 :                                  const nscoord& aCurX, 
     124                 :                                  const nscoord& aCurY, 
     125                 :                                  nscoord& aNextX, 
     126                 :                                  nscoord& aNextY, 
     127                 :                                  const nsRect& aChildSize);
     128                 : 
     129                 :   void ChildResized(nsIBox* aBox,
     130                 :                     nsBoxLayoutState& aState, 
     131                 :                     nsIBox* aChild,
     132                 :                     nsBoxSize* aChildBoxSize, 
     133                 :                     nsComputedBoxSize* aChildComputedBoxSize, 
     134                 :                     nsBoxSize* aBoxSizes, 
     135                 :                     nsComputedBoxSize* aComputedBoxSizes, 
     136                 :                     const nsRect& aChildLayoutRect, 
     137                 :                     nsRect& aChildActualRect, 
     138                 :                     nsRect& aContainingRect, 
     139                 :                     PRInt32 aFlexes, 
     140                 :                     bool& aFinished);
     141                 : 
     142                 :   void AlignChildren(nsIBox* aBox,
     143                 :                      nsBoxLayoutState& aState,
     144                 :                      bool* aNeedsRedraw);
     145                 : 
     146                 :   virtual void ComputeChildSizes(nsIBox* aBox, 
     147                 :                          nsBoxLayoutState& aState, 
     148                 :                          nscoord& aGivenSize, 
     149                 :                          nsBoxSize* aBoxSizes, 
     150                 :                          nsComputedBoxSize*& aComputedBoxSizes);
     151                 : 
     152                 : 
     153                 :   virtual void PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsBoxSize*& aBoxSizes, nscoord& aMinSize, nscoord& aMaxSize, PRInt32& aFlexes);
     154                 : 
     155                 :   virtual void InvalidateComputedSizes(nsComputedBoxSize* aComputedBoxSizes);
     156                 : 
     157                 :   virtual bool GetDefaultFlex(PRInt32& aFlex);
     158                 : 
     159                 :   virtual void GetFrameState(nsIBox* aBox, nsFrameState& aState);
     160                 : 
     161                 : private:
     162                 : 
     163                 : 
     164                 :   // because the sprocket layout manager has no instance variables. We 
     165                 :   // can make a static one and reuse it everywhere.
     166                 :   static nsBoxLayout* gInstance;
     167                 : 
     168                 : };
     169                 : 
     170                 : #endif
     171                 : 

Generated by: LCOV version 1.7