Bug 1866777 - Disable test_race_cache_with_network.js on windows opt for frequent...
[gecko.git] / gfx / thebes / gfxFontFeatures.cpp
blob4d1d82927a0993b8246f263ef598aa20b4d7335e
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"
7 #include "nsAtom.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);
18 ToLowerCase(family);
19 FeatureValueHashKey key(family, aVariantProperty, aName);
20 FeatureValueHashEntry* entry = mFontFeatureValues.GetEntry(key);
21 if (!entry) {
22 return {};
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);
33 entry->mKey = 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);