Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsSprocketLayout_h___ |
michael@0 | 7 | #define nsSprocketLayout_h___ |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/Attributes.h" |
michael@0 | 10 | #include "nsBoxLayout.h" |
michael@0 | 11 | #include "nsCOMPtr.h" |
michael@0 | 12 | #include "nsIFrame.h" |
michael@0 | 13 | |
michael@0 | 14 | class nsBoxSize |
michael@0 | 15 | { |
michael@0 | 16 | public: |
michael@0 | 17 | |
michael@0 | 18 | nsBoxSize(); |
michael@0 | 19 | |
michael@0 | 20 | nscoord pref; |
michael@0 | 21 | nscoord min; |
michael@0 | 22 | nscoord max; |
michael@0 | 23 | nscoord flex; |
michael@0 | 24 | nscoord left; |
michael@0 | 25 | nscoord right; |
michael@0 | 26 | bool collapsed; |
michael@0 | 27 | bool bogus; |
michael@0 | 28 | |
michael@0 | 29 | nsBoxSize* next; |
michael@0 | 30 | |
michael@0 | 31 | void* operator new(size_t sz, nsBoxLayoutState& aState) CPP_THROW_NEW; |
michael@0 | 32 | void operator delete(void* aPtr, size_t sz); |
michael@0 | 33 | }; |
michael@0 | 34 | |
michael@0 | 35 | class nsComputedBoxSize |
michael@0 | 36 | { |
michael@0 | 37 | public: |
michael@0 | 38 | nsComputedBoxSize(); |
michael@0 | 39 | |
michael@0 | 40 | nscoord size; |
michael@0 | 41 | bool valid; |
michael@0 | 42 | bool resized; |
michael@0 | 43 | nsComputedBoxSize* next; |
michael@0 | 44 | |
michael@0 | 45 | void* operator new(size_t sz, nsBoxLayoutState& aState) CPP_THROW_NEW; |
michael@0 | 46 | void operator delete(void* aPtr, size_t sz); |
michael@0 | 47 | }; |
michael@0 | 48 | |
michael@0 | 49 | #define GET_WIDTH(size, isHorizontal) (isHorizontal ? size.width : size.height) |
michael@0 | 50 | #define GET_HEIGHT(size, isHorizontal) (isHorizontal ? size.height : size.width) |
michael@0 | 51 | #define GET_X(size, isHorizontal) (isHorizontal ? size.x : size.y) |
michael@0 | 52 | #define GET_Y(size, isHorizontal) (isHorizontal ? size.y : size.x) |
michael@0 | 53 | #define GET_COORD(aX, aY, isHorizontal) (isHorizontal ? aX : aY) |
michael@0 | 54 | |
michael@0 | 55 | #define SET_WIDTH(size, coord, isHorizontal) if (isHorizontal) { (size).width = (coord); } else { (size).height = (coord); } |
michael@0 | 56 | #define SET_HEIGHT(size, coord, isHorizontal) if (isHorizontal) { (size).height = (coord); } else { (size).width = (coord); } |
michael@0 | 57 | #define SET_X(size, coord, isHorizontal) if (isHorizontal) { (size).x = (coord); } else { (size).y = (coord); } |
michael@0 | 58 | #define SET_Y(size, coord, isHorizontal) if (isHorizontal) { (size).y = (coord); } else { (size).x = (coord); } |
michael@0 | 59 | |
michael@0 | 60 | #define SET_COORD(aX, aY, coord, isHorizontal) if (isHorizontal) { aX = (coord); } else { aY = (coord); } |
michael@0 | 61 | |
michael@0 | 62 | nsresult NS_NewSprocketLayout(nsIPresShell* aPresShell, nsCOMPtr<nsBoxLayout>& aNewLayout); |
michael@0 | 63 | |
michael@0 | 64 | class nsSprocketLayout : public nsBoxLayout { |
michael@0 | 65 | |
michael@0 | 66 | public: |
michael@0 | 67 | |
michael@0 | 68 | friend nsresult NS_NewSprocketLayout(nsIPresShell* aPresShell, nsCOMPtr<nsBoxLayout>& aNewLayout); |
michael@0 | 69 | static void Shutdown(); |
michael@0 | 70 | |
michael@0 | 71 | NS_IMETHOD Layout(nsIFrame* aBox, nsBoxLayoutState& aState) MOZ_OVERRIDE; |
michael@0 | 72 | |
michael@0 | 73 | virtual nsSize GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; |
michael@0 | 74 | virtual nsSize GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; |
michael@0 | 75 | virtual nsSize GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; |
michael@0 | 76 | virtual nscoord GetAscent(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; |
michael@0 | 77 | |
michael@0 | 78 | nsSprocketLayout(); |
michael@0 | 79 | |
michael@0 | 80 | static bool IsHorizontal(nsIFrame* aBox); |
michael@0 | 81 | |
michael@0 | 82 | static void SetLargestSize(nsSize& aSize1, const nsSize& aSize2, bool aIsHorizontal); |
michael@0 | 83 | static void SetSmallestSize(nsSize& aSize1, const nsSize& aSize2, bool aIsHorizontal); |
michael@0 | 84 | |
michael@0 | 85 | static void AddLargestSize(nsSize& aSize, const nsSize& aSizeToAdd, bool aIsHorizontal); |
michael@0 | 86 | static void AddSmallestSize(nsSize& aSize, const nsSize& aSizeToAdd, bool aIsHorizontal); |
michael@0 | 87 | static void AddCoord(nscoord& aCoord, nscoord aCoordToAdd); |
michael@0 | 88 | |
michael@0 | 89 | protected: |
michael@0 | 90 | |
michael@0 | 91 | |
michael@0 | 92 | void ComputeChildsNextPosition(nsIFrame* aBox, |
michael@0 | 93 | const nscoord& aCurX, |
michael@0 | 94 | const nscoord& aCurY, |
michael@0 | 95 | nscoord& aNextX, |
michael@0 | 96 | nscoord& aNextY, |
michael@0 | 97 | const nsRect& aChildSize); |
michael@0 | 98 | |
michael@0 | 99 | void ChildResized(nsIFrame* aBox, |
michael@0 | 100 | nsBoxLayoutState& aState, |
michael@0 | 101 | nsIFrame* aChild, |
michael@0 | 102 | nsBoxSize* aChildBoxSize, |
michael@0 | 103 | nsComputedBoxSize* aChildComputedBoxSize, |
michael@0 | 104 | nsBoxSize* aBoxSizes, |
michael@0 | 105 | nsComputedBoxSize* aComputedBoxSizes, |
michael@0 | 106 | const nsRect& aChildLayoutRect, |
michael@0 | 107 | nsRect& aChildActualRect, |
michael@0 | 108 | nsRect& aContainingRect, |
michael@0 | 109 | int32_t aFlexes, |
michael@0 | 110 | bool& aFinished); |
michael@0 | 111 | |
michael@0 | 112 | void AlignChildren(nsIFrame* aBox, |
michael@0 | 113 | nsBoxLayoutState& aState); |
michael@0 | 114 | |
michael@0 | 115 | virtual void ComputeChildSizes(nsIFrame* aBox, |
michael@0 | 116 | nsBoxLayoutState& aState, |
michael@0 | 117 | nscoord& aGivenSize, |
michael@0 | 118 | nsBoxSize* aBoxSizes, |
michael@0 | 119 | nsComputedBoxSize*& aComputedBoxSizes); |
michael@0 | 120 | |
michael@0 | 121 | |
michael@0 | 122 | virtual void PopulateBoxSizes(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState, |
michael@0 | 123 | nsBoxSize*& aBoxSizes, nscoord& aMinSize, |
michael@0 | 124 | nscoord& aMaxSize, int32_t& aFlexes); |
michael@0 | 125 | |
michael@0 | 126 | virtual void InvalidateComputedSizes(nsComputedBoxSize* aComputedBoxSizes); |
michael@0 | 127 | |
michael@0 | 128 | virtual bool GetDefaultFlex(int32_t& aFlex); |
michael@0 | 129 | |
michael@0 | 130 | virtual void GetFrameState(nsIFrame* aBox, nsFrameState& aState); |
michael@0 | 131 | |
michael@0 | 132 | private: |
michael@0 | 133 | |
michael@0 | 134 | |
michael@0 | 135 | // because the sprocket layout manager has no instance variables. We |
michael@0 | 136 | // can make a static one and reuse it everywhere. |
michael@0 | 137 | static nsBoxLayout* gInstance; |
michael@0 | 138 | |
michael@0 | 139 | }; |
michael@0 | 140 | |
michael@0 | 141 | #endif |
michael@0 | 142 |