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 #include "DepthOrderedFrameList.h"
9 #include "nsContainerFrame.h"
13 void DepthOrderedFrameList::Add(nsIFrame
* aFrame
) {
14 // Is this root already scheduled for reflow?
15 // FIXME: This could possibly be changed to a uniqueness assertion, with some
16 // work in ResizeReflowIgnoreOverride (and maybe others?)
17 // FIXME(emilio): Should probably reuse the traversal for insertion.
18 if (Contains(aFrame
)) {
19 // We don't expect frame to change depths.
20 MOZ_ASSERT(aFrame
->GetDepthInFrameTree() ==
21 mList
[mList
.IndexOf(aFrame
)].mDepth
);
25 mList
.InsertElementSorted(
26 FrameAndDepth
{aFrame
, aFrame
->GetDepthInFrameTree()},
27 FrameAndDepth::CompareByReverseDepth
{});
30 void DepthOrderedFrameList::Remove(nsIFrame
* aFrame
) {
31 mList
.RemoveElement(aFrame
);
34 nsIFrame
* DepthOrderedFrameList::PopShallowestRoot() {
35 // List is sorted in order of decreasing depth, so there are no shallower
36 // frames than the last one.
37 const FrameAndDepth
& lastFAD
= mList
.PopLastElement();
38 nsIFrame
* frame
= lastFAD
.mFrame
;
39 // We don't expect frame to change depths.
40 MOZ_ASSERT(frame
->GetDepthInFrameTree() == lastFAD
.mDepth
);
44 bool DepthOrderedFrameList::FrameIsAncestorOfAnyElement(
45 nsIFrame
* aFrame
) const {
48 // Look for a path from any element to aFrame, following GetParent(). This
49 // check mirrors what FrameNeedsReflow() would have done if the reflow root
50 // didn't get in the way.
51 for (nsIFrame
* f
: mList
) {
63 } // namespace mozilla