1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
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
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 2002
20
* the Initial Developer. All Rights Reserved.
23
* Mike Shaver <shaver@mozilla.org>
24
* Randell Jesup <rjesup@wgate.com>
25
* Chris Waterson <waterson@netscape.com>
27
* Alternatively, the contents of this file may be used under the terms of
28
* either the GNU General Public License Version 2 or later (the "GPL"), or
29
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30
* in which case the provisions of the GPL or the LGPL are applicable instead
31
* of those above. If you wish to allow use of your version of this file only
32
* under the terms of either the GPL or the LGPL, and not to allow others to
33
* use your version of this file under the terms of the NPL, indicate your
34
* decision by deleting the provisions above and replace them with the notice
35
* and other provisions required by the GPL or the LGPL. If you do not delete
36
* the provisions above, a recipient may use your version of this file under
37
* the terms of any one of the NPL, the GPL or the LGPL.
39
* ***** END LICENSE BLOCK ***** */
41
#ifndef nsReflowPath_h__
42
#define nsReflowPath_h__
46
#include "nsReflowType.h"
47
#include "nsVoidArray.h"
54
class nsHTMLReflowCommand;
58
* A reflow `path' that is a sparse tree the parallels the frame
59
* hierarchy. This is used during an incremental reflow to record the
60
* path which the reflow must trace through the frame hierarchy.
66
* Construct a reflow path object that parallels the specified
69
nsReflowPath(nsIFrame *aFrame)
71
mReflowCommand(nsnull) {}
76
* An iterator for enumerating the reflow path's immediate
85
friend class nsReflowPath;
87
iterator(nsReflowPath *aNode, PRInt32 aIndex)
88
: mNode(aNode), mIndex(aIndex) {}
91
Advance() { --mIndex; }
97
iterator(const iterator &iter)
98
: mNode(iter.mNode), mIndex(iter.mIndex) {}
101
operator=(const iterator &iter) {
103
mIndex = iter.mIndex;
108
return NS_STATIC_CAST(nsReflowPath *, mNode->mChildren[mIndex]); }
112
return NS_STATIC_CAST(nsReflowPath *, mNode->mChildren[mIndex]); }
116
return get()->mFrame; }
120
return get()->mFrame; }
123
operator++() { Advance(); return *this; }
127
iterator temp(*this);
132
operator==(const iterator &iter) const {
133
return (mNode == iter.mNode) && (mIndex == iter.mIndex); }
136
operator!=(const iterator &iter) const {
137
return !iter.operator==(*this); }
141
* Return an iterator that points to the first immediate child of
144
iterator FirstChild() { return iterator(this, mChildren.Count() - 1); }
147
* Return an iterator that points `one past the end' of the
148
* immediate children of the reflow path.
150
iterator EndChildren() { return iterator(this, -1); }
153
* Determine if the reflow path contains the specified frame as
154
* one of its immediate children.
157
HasChild(nsIFrame *aFrame) const {
158
return GetSubtreeFor(aFrame) != nsnull; }
161
* Return an iterator over the current reflow path that
162
* corresponds to the specified child frame. Returns EndChildren
163
* if aFrame is not an immediate child of the reflow path.
166
FindChild(nsIFrame *aFrame);
169
* Remove the specified child frame from the reflow path, along
170
* with any of its descendants. Does nothing if aFrame is not an
171
* immediate child of the reflow path.
174
RemoveChild(nsIFrame *aFrame) {
175
iterator iter = FindChild(aFrame);
179
* Return the child reflow path that corresponds to the specified
180
* frame, or null if the frame is not an immediate descendant.
183
GetSubtreeFor(nsIFrame *aFrame) const;
186
* Return the child reflow path that corresponds to the specified
187
* frame, constructing a new child reflow path if one doesn't
191
EnsureSubtreeFor(nsIFrame *aFrame);
194
* Remove the child reflow path that corresponds to the specified
198
Remove(iterator &aIterator);
202
* Recursively dump the reflow path object and its descendants.
205
Dump(nsIPresContext *aPresContext, FILE *aFile, int aDepth);
209
* The frame that this reflow path object is associated with.
214
* If mFrame is the immediate target of an incremental reflow,
215
* this contains the reflow command that targeted it. Otherwise,
216
* this is null (and mFrame simply lies along the path to a target
217
* frame). The reflow path object assumes ownership of the reflow
220
nsHTMLReflowCommand *mReflowCommand;
224
* The children of this reflow path; also contains pointers to
225
* nsReflowPath objects.
227
nsSmallVoidArray mChildren;
229
friend class iterator;