1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "gfxFontFeatures.h"
8 #include "nsUnicharUtils.h"
9 #include "nsHashKeys.h"
11 using namespace mozilla
;
13 gfxFontFeatureValueSet::gfxFontFeatureValueSet() : mFontFeatureValues(8) {}
15 Span
<const uint32_t> gfxFontFeatureValueSet::GetFontFeatureValuesFor(
16 const nsACString
& aFamily
, uint32_t aVariantProperty
, nsAtom
* aName
) const {
17 nsAutoCString
family(aFamily
);
19 FeatureValueHashKey
key(family
, aVariantProperty
, aName
);
20 FeatureValueHashEntry
* entry
= mFontFeatureValues
.GetEntry(key
);
24 NS_ASSERTION(entry
->mValues
.Length() > 0,
25 "null array of font feature values");
26 return {entry
->mValues
};
29 nsTArray
<uint32_t>* gfxFontFeatureValueSet::AppendFeatureValueHashEntry(
30 const nsACString
& aFamily
, nsAtom
* aName
, uint32_t aAlternate
) {
31 FeatureValueHashKey
key(aFamily
, aAlternate
, aName
);
32 FeatureValueHashEntry
* entry
= mFontFeatureValues
.PutEntry(key
);
34 return &entry
->mValues
;
37 bool gfxFontFeatureValueSet::FeatureValueHashEntry::KeyEquals(
38 const KeyTypePointer aKey
) const {
39 return aKey
->mPropVal
== mKey
.mPropVal
&& aKey
->mName
== mKey
.mName
&&
40 aKey
->mFamily
.Equals(mKey
.mFamily
);
43 PLDHashNumber
gfxFontFeatureValueSet::FeatureValueHashEntry::HashKey(
44 const KeyTypePointer aKey
) {
45 return HashString(aKey
->mFamily
) + aKey
->mName
->hash() +
46 aKey
->mPropVal
* uint32_t(0xdeadbeef);