Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/PseudoElementHashEntry.h
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
#ifndef mozilla_PseudoElementHashEntry_h
8
#define mozilla_PseudoElementHashEntry_h
9
10
#include "mozilla/dom/Element.h"
11
#include "mozilla/AnimationTarget.h"
12
#include "mozilla/HashFunctions.h"
13
#include "PLDHashTable.h"
14
15
namespace mozilla {
16
17
// A hash entry that uses a RefPtr<dom::Element>, CSSPseudoElementType pair
18
class PseudoElementHashEntry : public PLDHashEntryHdr
19
{
20
public:
21
  typedef NonOwningAnimationTarget KeyType;
22
  typedef const NonOwningAnimationTarget* KeyTypePointer;
23
24
  explicit PseudoElementHashEntry(KeyTypePointer aKey)
25
    : mElement(aKey->mElement)
26
0
    , mPseudoType(aKey->mPseudoType) { }
27
  PseudoElementHashEntry(PseudoElementHashEntry&& aOther) = default;
28
29
0
  ~PseudoElementHashEntry() = default;
30
31
0
  KeyType GetKey() const { return { mElement, mPseudoType }; }
32
  bool KeyEquals(KeyTypePointer aKey) const
33
0
  {
34
0
    return mElement == aKey->mElement &&
35
0
           mPseudoType == aKey->mPseudoType;
36
0
  }
37
38
0
  static KeyTypePointer KeyToPointer(KeyType& aKey) { return &aKey; }
39
  static PLDHashNumber HashKey(KeyTypePointer aKey)
40
0
  {
41
0
    if (!aKey)
42
0
      return 0;
43
0
44
0
    // Convert the scoped enum into an integer while adding it to hash.
45
0
    // Note: CSSPseudoElementTypeBase is uint8_t, so we convert it into
46
0
    //       uint8_t directly to avoid including the header.
47
0
    return mozilla::HashGeneric(aKey->mElement,
48
0
                                static_cast<uint8_t>(aKey->mPseudoType));
49
0
  }
50
  enum { ALLOW_MEMMOVE = true };
51
52
  RefPtr<dom::Element> mElement;
53
  CSSPseudoElementType mPseudoType;
54
};
55
56
} // namespace mozilla
57
58
#endif // mozilla_PseudoElementHashEntry_h