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 /* Iterator class for frame lists that respect CSS "order" during layout */
9 #include "CSSOrderAwareFrameIterator.h"
10 #include "nsIFrameInlines.h"
12 static bool CanUse(const nsIFrame
* aFrame
) {
13 return aFrame
->IsFlexOrGridContainer() ||
14 (aFrame
->GetContent() && aFrame
->GetContent()->IsAnyOfXULElements(
15 nsGkAtoms::treecols
, nsGkAtoms::treecol
));
21 bool CSSOrderAwareFrameIterator::CanUse(const nsIFrame
* aFrame
) {
22 return ::CanUse(aFrame
);
26 bool ReverseCSSOrderAwareFrameIterator::CanUse(const nsIFrame
* aFrame
) {
27 return ::CanUse(aFrame
);
31 int CSSOrderAwareFrameIterator::CSSOrderComparator(nsIFrame
* const& a
,
33 return a
->StylePosition()->mOrder
- b
->StylePosition()->mOrder
;
37 int CSSOrderAwareFrameIterator::CSSBoxOrdinalGroupComparator(
38 nsIFrame
* const& a
, nsIFrame
* const& b
) {
39 return a
->StyleXUL()->mBoxOrdinal
- b
->StyleXUL()->mBoxOrdinal
;
43 bool CSSOrderAwareFrameIterator::IsForward() const {
48 nsFrameList::iterator
CSSOrderAwareFrameIterator::begin(
49 const nsFrameList
& aList
) {
54 nsFrameList::iterator
CSSOrderAwareFrameIterator::end(
55 const nsFrameList
& aList
) {
60 int ReverseCSSOrderAwareFrameIterator::CSSOrderComparator(nsIFrame
* const& a
,
62 return b
->StylePosition()->mOrder
- a
->StylePosition()->mOrder
;
66 int ReverseCSSOrderAwareFrameIterator::CSSBoxOrdinalGroupComparator(
67 nsIFrame
* const& a
, nsIFrame
* const& b
) {
68 return b
->StyleXUL()->mBoxOrdinal
- a
->StyleXUL()->mBoxOrdinal
;
72 bool ReverseCSSOrderAwareFrameIterator::IsForward() const {
77 nsFrameList::reverse_iterator
ReverseCSSOrderAwareFrameIterator::begin(
78 const nsFrameList
& aList
) {
79 return aList
.rbegin();
83 nsFrameList::reverse_iterator
ReverseCSSOrderAwareFrameIterator::end(
84 const nsFrameList
& aList
) {
88 } // namespace mozilla