2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2013-05-20 07:47:32 +04:00
|
|
|
* 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/. */
|
|
|
|
|
|
|
|
#include "gfxFontFeatures.h"
|
2019-08-22 03:24:44 +03:00
|
|
|
#include "nsAtom.h"
|
2013-05-20 07:47:32 +04:00
|
|
|
#include "nsUnicharUtils.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
|
|
|
|
gfxFontFeatureValueSet::gfxFontFeatureValueSet() : mFontFeatureValues(8) {}
|
|
|
|
|
2019-08-22 03:24:47 +03:00
|
|
|
Span<const uint32_t> gfxFontFeatureValueSet::GetFontFeatureValuesFor(
|
|
|
|
const nsACString& aFamily, uint32_t aVariantProperty, nsAtom* aName) const {
|
2018-09-12 22:34:57 +03:00
|
|
|
nsAutoCString family(aFamily);
|
2013-05-20 07:47:32 +04:00
|
|
|
ToLowerCase(family);
|
2018-05-14 12:05:25 +03:00
|
|
|
FeatureValueHashKey key(family, aVariantProperty, aName);
|
2013-05-20 07:47:32 +04:00
|
|
|
FeatureValueHashEntry* entry = mFontFeatureValues.GetEntry(key);
|
2019-08-22 03:24:47 +03:00
|
|
|
if (!entry) {
|
|
|
|
return {};
|
2013-05-20 07:47:32 +04:00
|
|
|
}
|
2019-08-22 03:24:47 +03:00
|
|
|
NS_ASSERTION(entry->mValues.Length() > 0,
|
|
|
|
"null array of font feature values");
|
2020-08-07 10:42:50 +03:00
|
|
|
return {entry->mValues};
|
2013-05-20 07:47:32 +04:00
|
|
|
}
|
|
|
|
|
2018-09-12 22:34:57 +03:00
|
|
|
nsTArray<uint32_t>* gfxFontFeatureValueSet::AppendFeatureValueHashEntry(
|
2019-08-22 03:24:44 +03:00
|
|
|
const nsACString& aFamily, nsAtom* aName, uint32_t aAlternate) {
|
2018-05-14 12:05:25 +03:00
|
|
|
FeatureValueHashKey key(aFamily, aAlternate, aName);
|
2017-08-24 04:05:53 +03:00
|
|
|
FeatureValueHashEntry* entry = mFontFeatureValues.PutEntry(key);
|
|
|
|
entry->mKey = key;
|
|
|
|
return &entry->mValues;
|
|
|
|
}
|
|
|
|
|
2013-05-20 07:47:32 +04:00
|
|
|
bool gfxFontFeatureValueSet::FeatureValueHashEntry::KeyEquals(
|
|
|
|
const KeyTypePointer aKey) const {
|
|
|
|
return aKey->mPropVal == mKey.mPropVal && aKey->mName == mKey.mName &&
|
2019-08-22 03:24:44 +03:00
|
|
|
aKey->mFamily.Equals(mKey.mFamily);
|
2013-05-20 07:47:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PLDHashNumber gfxFontFeatureValueSet::FeatureValueHashEntry::HashKey(
|
|
|
|
const KeyTypePointer aKey) {
|
2019-08-22 03:24:44 +03:00
|
|
|
return HashString(aKey->mFamily) + aKey->mName->hash() +
|
2013-05-20 07:47:32 +04:00
|
|
|
aKey->mPropVal * uint32_t(0xdeadbeef);
|
|
|
|
}
|