Line data Source code
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/. */
6 :
7 : #include "DocumentStyleRootIterator.h"
8 :
9 : #include "mozilla/dom/Element.h"
10 : #include "nsContentUtils.h"
11 :
12 : namespace mozilla {
13 :
14 0 : DocumentStyleRootIterator::DocumentStyleRootIterator(nsIDocument* aDocument)
15 0 : : mPosition(0)
16 : {
17 0 : MOZ_COUNT_CTOR(DocumentStyleRootIterator);
18 0 : if (Element* root = aDocument->GetRootElement()) {
19 0 : mStyleRoots.AppendElement(root);
20 : }
21 0 : nsContentUtils::AppendDocumentLevelNativeAnonymousContentTo(
22 0 : aDocument, mStyleRoots);
23 0 : }
24 :
25 : Element*
26 0 : DocumentStyleRootIterator::GetNextStyleRoot()
27 : {
28 : for (;;) {
29 0 : if (mPosition >= mStyleRoots.Length()) {
30 0 : return nullptr;
31 : }
32 :
33 0 : nsIContent* next = mStyleRoots[mPosition];
34 0 : ++mPosition;
35 :
36 0 : if (next->IsElement()) {
37 0 : return next->AsElement();
38 : }
39 0 : }
40 : }
41 :
42 : } // namespace mozilla
|