Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/style/nsHTMLCSSStyleSheet.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
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
/*
8
 * style sheet and style rule processor representing style attributes
9
 */
10
11
#include "nsHTMLCSSStyleSheet.h"
12
#include "mozilla/MemoryReporting.h"
13
#include "mozilla/DeclarationBlock.h"
14
#include "nsPresContext.h"
15
#include "mozilla/dom/Element.h"
16
#include "nsAttrValue.h"
17
#include "nsAttrValueInlines.h"
18
#include "nsCSSPseudoElements.h"
19
#include "mozilla/RestyleManager.h"
20
21
using namespace mozilla;
22
using namespace mozilla::dom;
23
24
nsHTMLCSSStyleSheet::nsHTMLCSSStyleSheet()
25
0
{
26
0
}
27
28
nsHTMLCSSStyleSheet::~nsHTMLCSSStyleSheet()
29
0
{
30
0
  // We may go away before all of our cached style attributes do,
31
0
  // so clean up any that are left.
32
0
  for (auto iter = mCachedStyleAttrs.Iter(); !iter.Done(); iter.Next()) {
33
0
    MiscContainer*& value = iter.Data();
34
0
35
0
    // Ideally we'd just call MiscContainer::Evict, but we can't do that since
36
0
    // we're iterating the hashtable.
37
0
    if (value->mType == nsAttrValue::eCSSDeclaration) {
38
0
      DeclarationBlock* declaration = value->mValue.mCSSDeclaration;
39
0
      declaration->SetHTMLCSSStyleSheet(nullptr);
40
0
    } else {
41
0
      MOZ_ASSERT_UNREACHABLE("unexpected cached nsAttrValue type");
42
0
    }
43
0
44
0
    value->mValue.mCached = 0;
45
0
    iter.Remove();
46
0
  }
47
0
}
48
49
50
void
51
nsHTMLCSSStyleSheet::CacheStyleAttr(const nsAString& aSerialized,
52
                                    MiscContainer* aValue)
53
0
{
54
0
  mCachedStyleAttrs.Put(aSerialized, aValue);
55
0
}
56
57
void
58
nsHTMLCSSStyleSheet::EvictStyleAttr(const nsAString& aSerialized,
59
                                    MiscContainer* aValue)
60
0
{
61
#ifdef DEBUG
62
  {
63
    NS_ASSERTION(aValue == mCachedStyleAttrs.Get(aSerialized),
64
                 "Cached value does not match?!");
65
  }
66
#endif
67
  mCachedStyleAttrs.Remove(aSerialized);
68
0
}
69
70
MiscContainer*
71
nsHTMLCSSStyleSheet::LookupStyleAttr(const nsAString& aSerialized)
72
0
{
73
0
  return mCachedStyleAttrs.Get(aSerialized);
74
0
}