Bug 1874684 - Part 20: Tag stack classes with MOZ_STACK_CLASS. r=allstarschh
[gecko.git] / layout / generic / CSSOrderAwareFrameIterator.cpp
blob0c9520f378fb53c58593437ce8cc07ab785f4c1c
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));
18 namespace mozilla {
20 template <>
21 bool CSSOrderAwareFrameIterator::CanUse(const nsIFrame* aFrame) {
22 return ::CanUse(aFrame);
25 template <>
26 bool ReverseCSSOrderAwareFrameIterator::CanUse(const nsIFrame* aFrame) {
27 return ::CanUse(aFrame);
30 template <>
31 int CSSOrderAwareFrameIterator::CSSOrderComparator(nsIFrame* const& a,
32 nsIFrame* const& b) {
33 return a->StylePosition()->mOrder - b->StylePosition()->mOrder;
36 template <>
37 int CSSOrderAwareFrameIterator::CSSBoxOrdinalGroupComparator(
38 nsIFrame* const& a, nsIFrame* const& b) {
39 return a->StyleXUL()->mBoxOrdinal - b->StyleXUL()->mBoxOrdinal;
42 template <>
43 bool CSSOrderAwareFrameIterator::IsForward() const {
44 return true;
47 template <>
48 nsFrameList::iterator CSSOrderAwareFrameIterator::begin(
49 const nsFrameList& aList) {
50 return aList.begin();
53 template <>
54 nsFrameList::iterator CSSOrderAwareFrameIterator::end(
55 const nsFrameList& aList) {
56 return aList.end();
59 template <>
60 int ReverseCSSOrderAwareFrameIterator::CSSOrderComparator(nsIFrame* const& a,
61 nsIFrame* const& b) {
62 return b->StylePosition()->mOrder - a->StylePosition()->mOrder;
65 template <>
66 int ReverseCSSOrderAwareFrameIterator::CSSBoxOrdinalGroupComparator(
67 nsIFrame* const& a, nsIFrame* const& b) {
68 return b->StyleXUL()->mBoxOrdinal - a->StyleXUL()->mBoxOrdinal;
71 template <>
72 bool ReverseCSSOrderAwareFrameIterator::IsForward() const {
73 return false;
76 template <>
77 nsFrameList::reverse_iterator ReverseCSSOrderAwareFrameIterator::begin(
78 const nsFrameList& aList) {
79 return aList.rbegin();
82 template <>
83 nsFrameList::reverse_iterator ReverseCSSOrderAwareFrameIterator::end(
84 const nsFrameList& aList) {
85 return aList.rend();
88 } // namespace mozilla