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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "DocumentStyleRootIterator.h"
9 #include "mozilla/dom/Document.h"
10 #include "mozilla/dom/Element.h"
11 #include "nsContentUtils.h"
15 DocumentStyleRootIterator::DocumentStyleRootIterator(nsINode
* aStyleRoot
)
17 MOZ_COUNT_CTOR(DocumentStyleRootIterator
);
18 MOZ_ASSERT(aStyleRoot
);
19 if (aStyleRoot
->IsElement()) {
20 mStyleRoots
.AppendElement(aStyleRoot
->AsElement());
24 dom::Document
* doc
= aStyleRoot
->OwnerDoc();
25 MOZ_ASSERT(doc
== aStyleRoot
);
26 if (dom::Element
* root
= doc
->GetRootElement()) {
27 mStyleRoots
.AppendElement(root
);
29 nsContentUtils::AppendDocumentLevelNativeAnonymousContentTo(doc
, mStyleRoots
);
32 dom::Element
* DocumentStyleRootIterator::GetNextStyleRoot() {
34 if (mPosition
>= mStyleRoots
.Length()) {
38 nsIContent
* next
= mStyleRoots
[mPosition
];
41 if (next
->IsElement()) {
42 return next
->AsElement();
47 } // namespace mozilla