2016-01-13 01:54:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_PseudoElementHashEntry_h
|
|
|
|
#define mozilla_PseudoElementHashEntry_h
|
|
|
|
|
|
|
|
#include "mozilla/dom/Element.h"
|
2016-04-28 18:22:43 +03:00
|
|
|
#include "mozilla/AnimationTarget.h"
|
2016-01-13 01:54:53 +03:00
|
|
|
#include "mozilla/HashFunctions.h"
|
|
|
|
#include "PLDHashTable.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2016-02-17 23:37:00 +03:00
|
|
|
// A hash entry that uses a RefPtr<dom::Element>, CSSPseudoElementType pair
|
2016-01-13 01:54:53 +03:00
|
|
|
class PseudoElementHashEntry : public PLDHashEntryHdr
|
|
|
|
{
|
|
|
|
public:
|
2016-03-21 11:49:50 +03:00
|
|
|
typedef NonOwningAnimationTarget KeyType;
|
|
|
|
typedef const NonOwningAnimationTarget* KeyTypePointer;
|
2016-01-13 01:54:53 +03:00
|
|
|
|
|
|
|
explicit PseudoElementHashEntry(KeyTypePointer aKey)
|
|
|
|
: mElement(aKey->mElement)
|
|
|
|
, mPseudoType(aKey->mPseudoType) { }
|
|
|
|
explicit PseudoElementHashEntry(const PseudoElementHashEntry& aCopy)=default;
|
|
|
|
|
|
|
|
~PseudoElementHashEntry() = default;
|
|
|
|
|
2016-03-21 11:49:50 +03:00
|
|
|
KeyType GetKey() const { return { mElement, mPseudoType }; }
|
2016-01-13 01:54:53 +03:00
|
|
|
bool KeyEquals(KeyTypePointer aKey) const
|
|
|
|
{
|
|
|
|
return mElement == aKey->mElement &&
|
|
|
|
mPseudoType == aKey->mPseudoType;
|
|
|
|
}
|
|
|
|
|
|
|
|
static KeyTypePointer KeyToPointer(KeyType& aKey) { return &aKey; }
|
|
|
|
static PLDHashNumber HashKey(KeyTypePointer aKey)
|
|
|
|
{
|
|
|
|
if (!aKey)
|
|
|
|
return 0;
|
|
|
|
|
2016-02-17 01:07:00 +03:00
|
|
|
// Convert the scoped enum into an integer while adding it to hash.
|
2016-02-18 21:18:00 +03:00
|
|
|
// Note: CSSPseudoElementTypeBase is uint8_t, so we convert it into
|
|
|
|
// uint8_t directly to avoid including the header.
|
2016-02-17 01:07:00 +03:00
|
|
|
return mozilla::HashGeneric(aKey->mElement,
|
|
|
|
static_cast<uint8_t>(aKey->mPseudoType));
|
2016-01-13 01:54:53 +03:00
|
|
|
}
|
|
|
|
enum { ALLOW_MEMMOVE = true };
|
|
|
|
|
|
|
|
RefPtr<dom::Element> mElement;
|
2016-02-17 23:37:00 +03:00
|
|
|
CSSPseudoElementType mPseudoType;
|
2016-01-13 01:54:53 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_PseudoElementHashEntry_h
|