Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 nsFrameList_h___ |
michael@0 | 7 | #define nsFrameList_h___ |
michael@0 | 8 | |
michael@0 | 9 | #include <stdio.h> /* for FILE* */ |
michael@0 | 10 | #include "nsDebug.h" |
michael@0 | 11 | #include "nsTArrayForwardDeclare.h" |
michael@0 | 12 | |
michael@0 | 13 | #if defined(DEBUG) || defined(MOZ_DUMP_PAINTING) |
michael@0 | 14 | // DEBUG_FRAME_DUMP enables nsIFrame::List and related methods. |
michael@0 | 15 | // You can also define this in a non-DEBUG build if you need frame dumps. |
michael@0 | 16 | #define DEBUG_FRAME_DUMP 1 |
michael@0 | 17 | #endif |
michael@0 | 18 | |
michael@0 | 19 | class nsIFrame; |
michael@0 | 20 | class nsIPresShell; |
michael@0 | 21 | class nsPresContext; |
michael@0 | 22 | |
michael@0 | 23 | namespace mozilla { |
michael@0 | 24 | namespace layout { |
michael@0 | 25 | class FrameChildList; |
michael@0 | 26 | enum FrameChildListID { |
michael@0 | 27 | // The individual concrete child lists. |
michael@0 | 28 | kPrincipalList = 0x1, |
michael@0 | 29 | kPopupList = 0x2, |
michael@0 | 30 | kCaptionList = 0x4, |
michael@0 | 31 | kColGroupList = 0x8, |
michael@0 | 32 | kSelectPopupList = 0x10, |
michael@0 | 33 | kAbsoluteList = 0x20, |
michael@0 | 34 | kFixedList = 0x40, |
michael@0 | 35 | kOverflowList = 0x80, |
michael@0 | 36 | kOverflowContainersList = 0x100, |
michael@0 | 37 | kExcessOverflowContainersList = 0x200, |
michael@0 | 38 | kOverflowOutOfFlowList = 0x400, |
michael@0 | 39 | kFloatList = 0x800, |
michael@0 | 40 | kBulletList = 0x1000, |
michael@0 | 41 | kPushedFloatsList = 0x2000, |
michael@0 | 42 | // A special alias for kPrincipalList that suppress the reflow request that |
michael@0 | 43 | // is normally done when manipulating child lists. |
michael@0 | 44 | kNoReflowPrincipalList = 0x4000 |
michael@0 | 45 | }; |
michael@0 | 46 | } |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | // Uncomment this to enable expensive frame-list integrity checking |
michael@0 | 50 | // #define DEBUG_FRAME_LIST |
michael@0 | 51 | |
michael@0 | 52 | /** |
michael@0 | 53 | * A class for managing a list of frames. |
michael@0 | 54 | */ |
michael@0 | 55 | class nsFrameList { |
michael@0 | 56 | public: |
michael@0 | 57 | nsFrameList() : |
michael@0 | 58 | mFirstChild(nullptr), mLastChild(nullptr) |
michael@0 | 59 | { |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | nsFrameList(nsIFrame* aFirstFrame, nsIFrame* aLastFrame) : |
michael@0 | 63 | mFirstChild(aFirstFrame), mLastChild(aLastFrame) |
michael@0 | 64 | { |
michael@0 | 65 | VerifyList(); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | nsFrameList(const nsFrameList& aOther) : |
michael@0 | 69 | mFirstChild(aOther.mFirstChild), mLastChild(aOther.mLastChild) |
michael@0 | 70 | { |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | /** |
michael@0 | 74 | * Allocate a nsFrameList from the shell arena. |
michael@0 | 75 | */ |
michael@0 | 76 | void* operator new(size_t sz, nsIPresShell* aPresShell) CPP_THROW_NEW; |
michael@0 | 77 | |
michael@0 | 78 | /** |
michael@0 | 79 | * Deallocate this list that was allocated from the shell arena. |
michael@0 | 80 | * The list is required to be empty. |
michael@0 | 81 | */ |
michael@0 | 82 | void Delete(nsIPresShell* aPresShell); |
michael@0 | 83 | |
michael@0 | 84 | /** |
michael@0 | 85 | * For each frame in this list: remove it from the list then call |
michael@0 | 86 | * Destroy() on it. |
michael@0 | 87 | */ |
michael@0 | 88 | void DestroyFrames(); |
michael@0 | 89 | |
michael@0 | 90 | /** |
michael@0 | 91 | * For each frame in this list: remove it from the list then call |
michael@0 | 92 | * DestroyFrom(aDestructRoot) on it. |
michael@0 | 93 | */ |
michael@0 | 94 | void DestroyFramesFrom(nsIFrame* aDestructRoot); |
michael@0 | 95 | |
michael@0 | 96 | void Clear() { mFirstChild = mLastChild = nullptr; } |
michael@0 | 97 | |
michael@0 | 98 | void SetFrames(nsIFrame* aFrameList); |
michael@0 | 99 | |
michael@0 | 100 | void SetFrames(nsFrameList& aFrameList) { |
michael@0 | 101 | NS_PRECONDITION(!mFirstChild, "Losing frames"); |
michael@0 | 102 | |
michael@0 | 103 | mFirstChild = aFrameList.FirstChild(); |
michael@0 | 104 | mLastChild = aFrameList.LastChild(); |
michael@0 | 105 | aFrameList.Clear(); |
michael@0 | 106 | } |
michael@0 | 107 | |
michael@0 | 108 | class Slice; |
michael@0 | 109 | |
michael@0 | 110 | /** |
michael@0 | 111 | * Append aFrameList to this list. If aParent is not null, |
michael@0 | 112 | * reparents the newly added frames. Clears out aFrameList and |
michael@0 | 113 | * returns a list slice represening the newly-appended frames. |
michael@0 | 114 | */ |
michael@0 | 115 | Slice AppendFrames(nsIFrame* aParent, nsFrameList& aFrameList) { |
michael@0 | 116 | return InsertFrames(aParent, LastChild(), aFrameList); |
michael@0 | 117 | } |
michael@0 | 118 | |
michael@0 | 119 | |
michael@0 | 120 | /** |
michael@0 | 121 | * Append aFrame to this list. If aParent is not null, |
michael@0 | 122 | * reparents the newly added frame. |
michael@0 | 123 | */ |
michael@0 | 124 | void AppendFrame(nsIFrame* aParent, nsIFrame* aFrame) { |
michael@0 | 125 | nsFrameList temp(aFrame, aFrame); |
michael@0 | 126 | AppendFrames(aParent, temp); |
michael@0 | 127 | } |
michael@0 | 128 | |
michael@0 | 129 | /** |
michael@0 | 130 | * Take aFrame out of the frame list. This also disconnects aFrame |
michael@0 | 131 | * from the sibling list. The frame must be non-null and present on |
michael@0 | 132 | * this list. |
michael@0 | 133 | */ |
michael@0 | 134 | void RemoveFrame(nsIFrame* aFrame); |
michael@0 | 135 | |
michael@0 | 136 | /** |
michael@0 | 137 | * Take the frames after aAfterFrame out of the frame list. If |
michael@0 | 138 | * aAfterFrame is null, removes the entire list. |
michael@0 | 139 | * @param aAfterFrame a frame in this list, or null |
michael@0 | 140 | * @return the removed frames, if any |
michael@0 | 141 | */ |
michael@0 | 142 | nsFrameList RemoveFramesAfter(nsIFrame* aAfterFrame); |
michael@0 | 143 | |
michael@0 | 144 | /** |
michael@0 | 145 | * Take the first frame (if any) out of the frame list. |
michael@0 | 146 | * @return the first child, or nullptr if the list is empty |
michael@0 | 147 | */ |
michael@0 | 148 | nsIFrame* RemoveFirstChild(); |
michael@0 | 149 | |
michael@0 | 150 | /** |
michael@0 | 151 | * The following two functions are intended to be used in concert for |
michael@0 | 152 | * removing a frame from its frame list when the set of possible frame |
michael@0 | 153 | * lists is known in advance, but the exact frame list is unknown. |
michael@0 | 154 | * aFrame must be non-null. |
michael@0 | 155 | * Example use: |
michael@0 | 156 | * bool removed = frameList1.StartRemoveFrame(aFrame) || |
michael@0 | 157 | * frameList2.ContinueRemoveFrame(aFrame) || |
michael@0 | 158 | * frameList3.ContinueRemoveFrame(aFrame); |
michael@0 | 159 | * MOZ_ASSERT(removed); |
michael@0 | 160 | * |
michael@0 | 161 | * @note One of the frame lists MUST contain aFrame, if it's on some other |
michael@0 | 162 | * frame list then the example above will likely lead to crashes. |
michael@0 | 163 | * This function is O(1). |
michael@0 | 164 | * @return true iff aFrame was removed from /some/ list, not necessarily |
michael@0 | 165 | * this one. If it was removed from a different list then it is |
michael@0 | 166 | * guaranteed that that list is still non-empty. |
michael@0 | 167 | * (this method is implemented in nsIFrame.h to be able to inline) |
michael@0 | 168 | */ |
michael@0 | 169 | inline bool StartRemoveFrame(nsIFrame* aFrame); |
michael@0 | 170 | |
michael@0 | 171 | /** |
michael@0 | 172 | * Precondition: StartRemoveFrame MUST be called before this. |
michael@0 | 173 | * This function is O(1). |
michael@0 | 174 | * @see StartRemoveFrame |
michael@0 | 175 | * @return true iff aFrame was removed from this list |
michael@0 | 176 | * (this method is implemented in nsIFrame.h to be able to inline) |
michael@0 | 177 | */ |
michael@0 | 178 | inline bool ContinueRemoveFrame(nsIFrame* aFrame); |
michael@0 | 179 | |
michael@0 | 180 | /** |
michael@0 | 181 | * Take aFrame out of the frame list and then destroy it. |
michael@0 | 182 | * The frame must be non-null and present on this list. |
michael@0 | 183 | */ |
michael@0 | 184 | void DestroyFrame(nsIFrame* aFrame); |
michael@0 | 185 | |
michael@0 | 186 | /** |
michael@0 | 187 | * Insert aFrame right after aPrevSibling, or prepend it to this |
michael@0 | 188 | * list if aPrevSibling is null. If aParent is not null, also |
michael@0 | 189 | * reparents newly-added frame. Note that this method always |
michael@0 | 190 | * sets the frame's nextSibling pointer. |
michael@0 | 191 | */ |
michael@0 | 192 | void InsertFrame(nsIFrame* aParent, nsIFrame* aPrevSibling, |
michael@0 | 193 | nsIFrame* aFrame) { |
michael@0 | 194 | nsFrameList temp(aFrame, aFrame); |
michael@0 | 195 | InsertFrames(aParent, aPrevSibling, temp); |
michael@0 | 196 | } |
michael@0 | 197 | |
michael@0 | 198 | |
michael@0 | 199 | /** |
michael@0 | 200 | * Inserts aFrameList into this list after aPrevSibling (at the beginning if |
michael@0 | 201 | * aPrevSibling is null). If aParent is not null, reparents the newly added |
michael@0 | 202 | * frames. Clears out aFrameList and returns a list slice representing the |
michael@0 | 203 | * newly-inserted frames. |
michael@0 | 204 | */ |
michael@0 | 205 | Slice InsertFrames(nsIFrame* aParent, nsIFrame* aPrevSibling, |
michael@0 | 206 | nsFrameList& aFrameList); |
michael@0 | 207 | |
michael@0 | 208 | class FrameLinkEnumerator; |
michael@0 | 209 | |
michael@0 | 210 | /** |
michael@0 | 211 | * Split this frame list such that all the frames before the link pointed to |
michael@0 | 212 | * by aLink end up in the returned list, while the remaining frames stay in |
michael@0 | 213 | * this list. After this call, aLink points to the beginning of this list. |
michael@0 | 214 | */ |
michael@0 | 215 | nsFrameList ExtractHead(FrameLinkEnumerator& aLink); |
michael@0 | 216 | |
michael@0 | 217 | /** |
michael@0 | 218 | * Split this frame list such that all the frames coming after the link |
michael@0 | 219 | * pointed to by aLink end up in the returned list, while the frames before |
michael@0 | 220 | * that link stay in this list. After this call, aLink is at end. |
michael@0 | 221 | */ |
michael@0 | 222 | nsFrameList ExtractTail(FrameLinkEnumerator& aLink); |
michael@0 | 223 | |
michael@0 | 224 | nsIFrame* FirstChild() const { |
michael@0 | 225 | return mFirstChild; |
michael@0 | 226 | } |
michael@0 | 227 | |
michael@0 | 228 | nsIFrame* LastChild() const { |
michael@0 | 229 | return mLastChild; |
michael@0 | 230 | } |
michael@0 | 231 | |
michael@0 | 232 | nsIFrame* FrameAt(int32_t aIndex) const; |
michael@0 | 233 | int32_t IndexOf(nsIFrame* aFrame) const; |
michael@0 | 234 | |
michael@0 | 235 | bool IsEmpty() const { |
michael@0 | 236 | return nullptr == mFirstChild; |
michael@0 | 237 | } |
michael@0 | 238 | |
michael@0 | 239 | bool NotEmpty() const { |
michael@0 | 240 | return nullptr != mFirstChild; |
michael@0 | 241 | } |
michael@0 | 242 | |
michael@0 | 243 | bool ContainsFrame(const nsIFrame* aFrame) const; |
michael@0 | 244 | |
michael@0 | 245 | int32_t GetLength() const; |
michael@0 | 246 | |
michael@0 | 247 | /** |
michael@0 | 248 | * If this frame list has only one frame, return that frame. |
michael@0 | 249 | * Otherwise, return null. |
michael@0 | 250 | */ |
michael@0 | 251 | nsIFrame* OnlyChild() const { |
michael@0 | 252 | if (FirstChild() == LastChild()) { |
michael@0 | 253 | return FirstChild(); |
michael@0 | 254 | } |
michael@0 | 255 | return nullptr; |
michael@0 | 256 | } |
michael@0 | 257 | |
michael@0 | 258 | /** |
michael@0 | 259 | * Call SetParent(aParent) for each frame in this list. |
michael@0 | 260 | * @param aParent the new parent frame, must be non-null |
michael@0 | 261 | */ |
michael@0 | 262 | void ApplySetParent(nsIFrame* aParent) const; |
michael@0 | 263 | |
michael@0 | 264 | /** |
michael@0 | 265 | * If this frame list is non-empty then append it to aLists as the |
michael@0 | 266 | * aListID child list. |
michael@0 | 267 | * (this method is implemented in FrameChildList.h for dependency reasons) |
michael@0 | 268 | */ |
michael@0 | 269 | inline void AppendIfNonempty(nsTArray<mozilla::layout::FrameChildList>* aLists, |
michael@0 | 270 | mozilla::layout::FrameChildListID aListID) const; |
michael@0 | 271 | |
michael@0 | 272 | /** |
michael@0 | 273 | * Return the frame before this frame in visual order (after Bidi reordering). |
michael@0 | 274 | * If aFrame is null, return the last frame in visual order. |
michael@0 | 275 | */ |
michael@0 | 276 | nsIFrame* GetPrevVisualFor(nsIFrame* aFrame) const; |
michael@0 | 277 | |
michael@0 | 278 | /** |
michael@0 | 279 | * Return the frame after this frame in visual order (after Bidi reordering). |
michael@0 | 280 | * If aFrame is null, return the first frame in visual order. |
michael@0 | 281 | */ |
michael@0 | 282 | nsIFrame* GetNextVisualFor(nsIFrame* aFrame) const; |
michael@0 | 283 | |
michael@0 | 284 | #ifdef DEBUG_FRAME_DUMP |
michael@0 | 285 | void List(FILE* out) const; |
michael@0 | 286 | #endif |
michael@0 | 287 | |
michael@0 | 288 | static inline const nsFrameList& EmptyList(); |
michael@0 | 289 | |
michael@0 | 290 | class Enumerator; |
michael@0 | 291 | |
michael@0 | 292 | /** |
michael@0 | 293 | * A class representing a slice of a frame list. |
michael@0 | 294 | */ |
michael@0 | 295 | class Slice { |
michael@0 | 296 | friend class Enumerator; |
michael@0 | 297 | |
michael@0 | 298 | public: |
michael@0 | 299 | // Implicit on purpose, so that we can easily create enumerators from |
michael@0 | 300 | // nsFrameList via this impicit constructor. |
michael@0 | 301 | Slice(const nsFrameList& aList) : |
michael@0 | 302 | #ifdef DEBUG |
michael@0 | 303 | mList(aList), |
michael@0 | 304 | #endif |
michael@0 | 305 | mStart(aList.FirstChild()), |
michael@0 | 306 | mEnd(nullptr) |
michael@0 | 307 | {} |
michael@0 | 308 | |
michael@0 | 309 | Slice(const nsFrameList& aList, nsIFrame* aStart, nsIFrame* aEnd) : |
michael@0 | 310 | #ifdef DEBUG |
michael@0 | 311 | mList(aList), |
michael@0 | 312 | #endif |
michael@0 | 313 | mStart(aStart), |
michael@0 | 314 | mEnd(aEnd) |
michael@0 | 315 | {} |
michael@0 | 316 | |
michael@0 | 317 | Slice(const Slice& aOther) : |
michael@0 | 318 | #ifdef DEBUG |
michael@0 | 319 | mList(aOther.mList), |
michael@0 | 320 | #endif |
michael@0 | 321 | mStart(aOther.mStart), |
michael@0 | 322 | mEnd(aOther.mEnd) |
michael@0 | 323 | {} |
michael@0 | 324 | |
michael@0 | 325 | private: |
michael@0 | 326 | #ifdef DEBUG |
michael@0 | 327 | const nsFrameList& mList; |
michael@0 | 328 | #endif |
michael@0 | 329 | nsIFrame* const mStart; // our starting frame |
michael@0 | 330 | const nsIFrame* const mEnd; // The first frame that is NOT in the slice. |
michael@0 | 331 | // May be null. |
michael@0 | 332 | }; |
michael@0 | 333 | |
michael@0 | 334 | class Enumerator { |
michael@0 | 335 | public: |
michael@0 | 336 | Enumerator(const Slice& aSlice) : |
michael@0 | 337 | #ifdef DEBUG |
michael@0 | 338 | mSlice(aSlice), |
michael@0 | 339 | #endif |
michael@0 | 340 | mFrame(aSlice.mStart), |
michael@0 | 341 | mEnd(aSlice.mEnd) |
michael@0 | 342 | {} |
michael@0 | 343 | |
michael@0 | 344 | Enumerator(const Enumerator& aOther) : |
michael@0 | 345 | #ifdef DEBUG |
michael@0 | 346 | mSlice(aOther.mSlice), |
michael@0 | 347 | #endif |
michael@0 | 348 | mFrame(aOther.mFrame), |
michael@0 | 349 | mEnd(aOther.mEnd) |
michael@0 | 350 | {} |
michael@0 | 351 | |
michael@0 | 352 | bool AtEnd() const { |
michael@0 | 353 | // Can't just check mEnd, because some table code goes and destroys the |
michael@0 | 354 | // tail of the frame list (including mEnd!) while iterating over the |
michael@0 | 355 | // frame list. |
michael@0 | 356 | return !mFrame || mFrame == mEnd; |
michael@0 | 357 | } |
michael@0 | 358 | |
michael@0 | 359 | /* Next() needs to know about nsIFrame, and nsIFrame will need to |
michael@0 | 360 | know about nsFrameList methods, so in order to inline this put |
michael@0 | 361 | the implementation in nsIFrame.h */ |
michael@0 | 362 | inline void Next(); |
michael@0 | 363 | |
michael@0 | 364 | /** |
michael@0 | 365 | * Get the current frame we're pointing to. Do not call this on an |
michael@0 | 366 | * iterator that is at end! |
michael@0 | 367 | */ |
michael@0 | 368 | nsIFrame* get() const { |
michael@0 | 369 | NS_PRECONDITION(!AtEnd(), "Enumerator is at end"); |
michael@0 | 370 | return mFrame; |
michael@0 | 371 | } |
michael@0 | 372 | |
michael@0 | 373 | /** |
michael@0 | 374 | * Get an enumerator that is just like this one, but not limited in terms of |
michael@0 | 375 | * the part of the list it will traverse. |
michael@0 | 376 | */ |
michael@0 | 377 | Enumerator GetUnlimitedEnumerator() const { |
michael@0 | 378 | return Enumerator(*this, nullptr); |
michael@0 | 379 | } |
michael@0 | 380 | |
michael@0 | 381 | #ifdef DEBUG |
michael@0 | 382 | const nsFrameList& List() const { return mSlice.mList; } |
michael@0 | 383 | #endif |
michael@0 | 384 | |
michael@0 | 385 | protected: |
michael@0 | 386 | Enumerator(const Enumerator& aOther, const nsIFrame* const aNewEnd): |
michael@0 | 387 | #ifdef DEBUG |
michael@0 | 388 | mSlice(aOther.mSlice), |
michael@0 | 389 | #endif |
michael@0 | 390 | mFrame(aOther.mFrame), |
michael@0 | 391 | mEnd(aNewEnd) |
michael@0 | 392 | {} |
michael@0 | 393 | |
michael@0 | 394 | #ifdef DEBUG |
michael@0 | 395 | /* Has to be an object, not a reference, since the slice could |
michael@0 | 396 | well be a temporary constructed from an nsFrameList */ |
michael@0 | 397 | const Slice mSlice; |
michael@0 | 398 | #endif |
michael@0 | 399 | nsIFrame* mFrame; // our current frame. |
michael@0 | 400 | const nsIFrame* const mEnd; // The first frame we should NOT enumerate. |
michael@0 | 401 | // May be null. |
michael@0 | 402 | }; |
michael@0 | 403 | |
michael@0 | 404 | /** |
michael@0 | 405 | * A class that can be used to enumerate links between frames. When created |
michael@0 | 406 | * from an nsFrameList, it points to the "link" immediately before the first |
michael@0 | 407 | * frame. It can then be advanced until it points to the "link" immediately |
michael@0 | 408 | * after the last frame. At any position, PrevFrame() and NextFrame() are |
michael@0 | 409 | * the frames before and after the given link. This means PrevFrame() is |
michael@0 | 410 | * null when the enumerator is at the beginning of the list and NextFrame() |
michael@0 | 411 | * is null when it's AtEnd(). |
michael@0 | 412 | */ |
michael@0 | 413 | class FrameLinkEnumerator : private Enumerator { |
michael@0 | 414 | public: |
michael@0 | 415 | friend class nsFrameList; |
michael@0 | 416 | |
michael@0 | 417 | FrameLinkEnumerator(const nsFrameList& aList) : |
michael@0 | 418 | Enumerator(aList), |
michael@0 | 419 | mPrev(nullptr) |
michael@0 | 420 | {} |
michael@0 | 421 | |
michael@0 | 422 | FrameLinkEnumerator(const FrameLinkEnumerator& aOther) : |
michael@0 | 423 | Enumerator(aOther), |
michael@0 | 424 | mPrev(aOther.mPrev) |
michael@0 | 425 | {} |
michael@0 | 426 | |
michael@0 | 427 | /* This constructor needs to know about nsIFrame, and nsIFrame will need to |
michael@0 | 428 | know about nsFrameList methods, so in order to inline this put |
michael@0 | 429 | the implementation in nsIFrame.h */ |
michael@0 | 430 | inline FrameLinkEnumerator(const nsFrameList& aList, nsIFrame* aPrevFrame); |
michael@0 | 431 | |
michael@0 | 432 | void operator=(const FrameLinkEnumerator& aOther) { |
michael@0 | 433 | NS_PRECONDITION(&List() == &aOther.List(), "Different lists?"); |
michael@0 | 434 | mFrame = aOther.mFrame; |
michael@0 | 435 | mPrev = aOther.mPrev; |
michael@0 | 436 | } |
michael@0 | 437 | |
michael@0 | 438 | inline void Next(); |
michael@0 | 439 | |
michael@0 | 440 | bool AtEnd() const { return Enumerator::AtEnd(); } |
michael@0 | 441 | |
michael@0 | 442 | nsIFrame* PrevFrame() const { return mPrev; } |
michael@0 | 443 | nsIFrame* NextFrame() const { return mFrame; } |
michael@0 | 444 | |
michael@0 | 445 | protected: |
michael@0 | 446 | nsIFrame* mPrev; |
michael@0 | 447 | }; |
michael@0 | 448 | |
michael@0 | 449 | private: |
michael@0 | 450 | void operator delete(void*) MOZ_DELETE; |
michael@0 | 451 | |
michael@0 | 452 | #ifdef DEBUG_FRAME_LIST |
michael@0 | 453 | void VerifyList() const; |
michael@0 | 454 | #else |
michael@0 | 455 | void VerifyList() const {} |
michael@0 | 456 | #endif |
michael@0 | 457 | |
michael@0 | 458 | protected: |
michael@0 | 459 | /** |
michael@0 | 460 | * Disconnect aFrame from its siblings. This must only be called if aFrame |
michael@0 | 461 | * is NOT the first or last sibling, because otherwise its nsFrameList will |
michael@0 | 462 | * have a stale mFirst/LastChild pointer. This precondition is asserted. |
michael@0 | 463 | * This function is O(1). |
michael@0 | 464 | */ |
michael@0 | 465 | static void UnhookFrameFromSiblings(nsIFrame* aFrame); |
michael@0 | 466 | |
michael@0 | 467 | nsIFrame* mFirstChild; |
michael@0 | 468 | nsIFrame* mLastChild; |
michael@0 | 469 | }; |
michael@0 | 470 | |
michael@0 | 471 | namespace mozilla { |
michael@0 | 472 | namespace layout { |
michael@0 | 473 | |
michael@0 | 474 | /** |
michael@0 | 475 | * Simple "auto_ptr" for nsFrameLists allocated from the shell arena. |
michael@0 | 476 | * The frame list given to the constructor will be deallocated (if non-null) |
michael@0 | 477 | * in the destructor. The frame list must then be empty. |
michael@0 | 478 | */ |
michael@0 | 479 | class AutoFrameListPtr { |
michael@0 | 480 | public: |
michael@0 | 481 | AutoFrameListPtr(nsPresContext* aPresContext, nsFrameList* aFrameList) |
michael@0 | 482 | : mPresContext(aPresContext), mFrameList(aFrameList) {} |
michael@0 | 483 | ~AutoFrameListPtr(); |
michael@0 | 484 | operator nsFrameList*() const { return mFrameList; } |
michael@0 | 485 | nsFrameList* operator->() const { return mFrameList; } |
michael@0 | 486 | private: |
michael@0 | 487 | nsPresContext* mPresContext; |
michael@0 | 488 | nsFrameList* mFrameList; |
michael@0 | 489 | }; |
michael@0 | 490 | |
michael@0 | 491 | namespace detail { |
michael@0 | 492 | union AlignedFrameListBytes { |
michael@0 | 493 | void* ptr; |
michael@0 | 494 | char bytes[sizeof(nsFrameList)]; |
michael@0 | 495 | }; |
michael@0 | 496 | extern const AlignedFrameListBytes gEmptyFrameListBytes; |
michael@0 | 497 | } |
michael@0 | 498 | } |
michael@0 | 499 | } |
michael@0 | 500 | |
michael@0 | 501 | /* static */ inline const nsFrameList& |
michael@0 | 502 | nsFrameList::EmptyList() |
michael@0 | 503 | { |
michael@0 | 504 | return *reinterpret_cast<const nsFrameList*>(&mozilla::layout::detail::gEmptyFrameListBytes); |
michael@0 | 505 | } |
michael@0 | 506 | |
michael@0 | 507 | #endif /* nsFrameList_h___ */ |