1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef NSFRAMETRAVERSAL_H
8 #define NSFRAMETRAVERSAL_H
11 #include "mozilla/Attributes.h"
16 class MOZ_STACK_CLASS nsFrameIterator final
{
20 nsIFrame
* CurrentItem();
26 inline nsIFrame
* Traverse(bool aForward
) {
35 enum class Type
: uint8_t {
43 nsFrameIterator(nsPresContext
* aPresContext
, nsIFrame
* aStart
, Type aType
,
44 bool aVisual
, bool aLockInScrollView
, bool aFollowOOFs
,
45 bool aSkipPopupChecks
, nsIFrame
* aLimiter
= nullptr);
46 ~nsFrameIterator() = default;
49 void SetCurrent(nsIFrame
* aFrame
) { mCurrent
= aFrame
; }
50 nsIFrame
* GetCurrent() { return mCurrent
; }
51 nsIFrame
* GetStart() { return mStart
; }
52 nsIFrame
* GetLast() { return mLast
; }
53 void SetLast(nsIFrame
* aFrame
) { mLast
= aFrame
; }
54 int8_t GetOffEdge() { return mOffEdge
; }
55 void SetOffEdge(int8_t aOffEdge
) { mOffEdge
= aOffEdge
; }
58 Our own versions of the standard frame tree navigation
59 methods, which, if the iterator is following out-of-flows,
60 apply the following rules for placeholder frames:
62 - If a frame HAS a placeholder frame, getting its parent
63 gets the placeholder's parent.
65 - If a frame's first child or next/prev sibling IS a
66 placeholder frame, then we instead return the real frame.
68 - If a frame HAS a placeholder frame, getting its next/prev
69 sibling gets the placeholder frame's next/prev sibling.
71 These are all applied recursively to support multiple levels of
75 nsIFrame
* GetParentFrame(nsIFrame
* aFrame
);
76 // like GetParentFrame but returns null once a popup frame is reached
77 nsIFrame
* GetParentFrameNotPopup(nsIFrame
* aFrame
);
79 nsIFrame
* GetFirstChild(nsIFrame
* aFrame
);
80 nsIFrame
* GetLastChild(nsIFrame
* aFrame
);
82 nsIFrame
* GetNextSibling(nsIFrame
* aFrame
);
83 nsIFrame
* GetPrevSibling(nsIFrame
* aFrame
);
86 These methods are overridden by the bidi visual iterator to have the
87 semantics of "get first child in visual order", "get last child in visual
88 order", "get next sibling in visual order" and "get previous sibling in
92 nsIFrame
* GetFirstChildInner(nsIFrame
* aFrame
);
93 nsIFrame
* GetLastChildInner(nsIFrame
* aFrame
);
95 nsIFrame
* GetNextSiblingInner(nsIFrame
* aFrame
);
96 nsIFrame
* GetPrevSiblingInner(nsIFrame
* aFrame
);
99 * Return the placeholder frame for aFrame if it has one, otherwise return
102 nsIFrame
* GetPlaceholderFrame(nsIFrame
* aFrame
);
103 bool IsPopupFrame(nsIFrame
* aFrame
);
105 bool IsInvokerOpenPopoverFrame(nsIFrame
* aFrame
);
107 nsPresContext
* const mPresContext
;
108 const bool mLockScroll
;
109 const bool mFollowOOFs
;
110 const bool mSkipPopupChecks
;
115 nsIFrame
* const mStart
;
117 nsIFrame
* mLast
; // the last one that was in current;
119 int8_t mOffEdge
; // 0= no -1 to far prev, 1 to far next;
122 #endif // NSFRAMETRAVERSAL_H