Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/style/DocumentStyleRootIterator.cpp
Line
Count
Source (jump to first uncovered line)
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
DocumentStyleRootIterator::DocumentStyleRootIterator(nsINode* aStyleRoot)
15
  : mPosition(0)
16
0
{
17
0
  MOZ_COUNT_CTOR(DocumentStyleRootIterator);
18
0
  MOZ_ASSERT(aStyleRoot);
19
0
  if (aStyleRoot->IsElement()) {
20
0
    mStyleRoots.AppendElement(aStyleRoot->AsElement());
21
0
    return;
22
0
  }
23
0
24
0
  nsIDocument* doc = aStyleRoot->OwnerDoc();
25
0
  MOZ_ASSERT(doc == aStyleRoot);
26
0
  if (Element* root = doc->GetRootElement()) {
27
0
    mStyleRoots.AppendElement(root);
28
0
  }
29
0
  nsContentUtils::AppendDocumentLevelNativeAnonymousContentTo(
30
0
      doc, mStyleRoots);
31
0
}
32
33
Element*
34
DocumentStyleRootIterator::GetNextStyleRoot()
35
0
{
36
0
  for (;;) {
37
0
    if (mPosition >= mStyleRoots.Length()) {
38
0
      return nullptr;
39
0
    }
40
0
41
0
    nsIContent* next = mStyleRoots[mPosition];
42
0
    ++mPosition;
43
0
44
0
    if (next->IsElement()) {
45
0
      return next->AsElement();
46
0
    }
47
0
  }
48
0
}
49
50
} // namespace mozilla