Bug 461212 - deCOM frame traversal (relanding) r=mats.palmgren sr=roc
[wine-gecko.git] / layout / generic / nsBlockBandData.h
blob5303b735ad2c8acf5f7ee51e43e96a236f047534
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
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/
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.
15 * The Original Code is Mozilla Communicator client code.
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.
22 * Contributor(s):
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.
36 * ***** END LICENSE BLOCK ***** */
38 /* code for management of floats that implements space manager interfaces */
40 #ifndef nsBlockBandData_h___
41 #define nsBlockBandData_h___
43 #include "nsSpaceManager.h"
45 class nsPresContext;
47 // Number of builtin nsBandTrapezoid's
48 #define NS_BLOCK_BAND_DATA_TRAPS 6
50 /**
51 * Class used to manage processing of the space-manager band data.
52 * Provides HTML/CSS specific behavior to the raw data.
54 class nsBlockBandData : public nsBandData {
55 public:
56 nsBlockBandData();
57 ~nsBlockBandData();
59 // Initialize. This must be called before any of the other methods.
60 nsresult Init(nsSpaceManager* aSpaceManager, const nsSize& aSpace);
62 // Get some available space. Note that aY is relative to the current
63 // space manager translation.
64 nsresult GetAvailableSpace(nscoord aY, PRBool aRelaxHeightConstraint,
65 nsRect& aResult);
67 // Get the raw trapezoid count for this band.
68 PRInt32 GetTrapezoidCount() const {
69 return mCount;
72 const nsBandTrapezoid* GetTrapezoid(PRInt32 aIndex) const {
73 return &mTrapezoids[aIndex];
76 // Get the number of floats that are impacting the current
77 // band. Note that this value is relative to the current translation
78 // in the space manager which means that some floats may be hidden
79 // by the translation and therefore won't be in the count.
80 PRInt32 GetFloatCount() const {
81 return mLeftFloats + mRightFloats;
83 PRInt32 GetLeftFloatCount() const {
84 return mLeftFloats;
86 PRInt32 GetRightFloatCount() const {
87 return mRightFloats;
90 #ifdef DEBUG
91 void List();
92 #endif
94 protected:
96 /** utility method to calculate the band data at aY.
97 * nsBlockBandData methods should never call
98 * mSpaceManager->GetBandData directly.
99 * They should always call this method instead so data members
100 * mTrapezoid, mCount, and mSize all get managed properly.
102 nsresult GetBandData(nscoord aY, PRBool aRelaxHeightConstraint);
104 // The spacemanager we are getting space from
105 nsSpaceManager* mSpaceManager;
106 nscoord mSpaceManagerX, mSpaceManagerY;
108 // Limit to the available space (set by Init)
109 nsSize mSpace;
111 // Trapezoids used during band processing
112 nsBandTrapezoid mData[NS_BLOCK_BAND_DATA_TRAPS];
114 // Bounding rect of available space between any left and right floats
115 nsRect mAvailSpace;
117 // Number of left/right floats in the current band. Note that this
118 // number may be less than the total number of floats present in
119 // the band, if our translation in the space manager "hides" some
120 // floats.
121 PRInt32 mLeftFloats, mRightFloats;
123 void ComputeAvailSpaceRect();
126 #endif /* nsBlockBandData_h___ */