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/Element.h"
10 #include "nsContentUtils.h"
14 DocumentStyleRootIterator::DocumentStyleRootIterator(nsINode
* aStyleRoot
)
16 MOZ_COUNT_CTOR(DocumentStyleRootIterator
);
17 MOZ_ASSERT(aStyleRoot
);
18 if (aStyleRoot
->IsElement()) {
19 mStyleRoots
.AppendElement(aStyleRoot
->AsElement());
23 dom::Document
* doc
= aStyleRoot
->OwnerDoc();
24 MOZ_ASSERT(doc
== aStyleRoot
);
25 if (Element
* root
= doc
->GetRootElement()) {
26 mStyleRoots
.AppendElement(root
);
28 nsContentUtils::AppendDocumentLevelNativeAnonymousContentTo(doc
, mStyleRoots
);
31 Element
* DocumentStyleRootIterator::GetNextStyleRoot() {
33 if (mPosition
>= mStyleRoots
.Length()) {
37 nsIContent
* next
= mStyleRoots
[mPosition
];
40 if (next
->IsElement()) {
41 return next
->AsElement();
46 } // namespace mozilla