mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1575713 - Use atoms for font-feature-values. r=boris
Differential Revision: https://phabricator.services.mozilla.com/D42984 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
ad930b523d
commit
dca2b09c76
@ -349,7 +349,7 @@ static void LookupAlternateValues(gfxFontFeatureValueSet& aFeatureLookup,
|
||||
// FIXME(emilio): Use atoms directly.
|
||||
aFeatureLookup.GetFontFeatureValuesFor(
|
||||
aFamily, NS_FONT_VARIANT_ALTERNATES_CHARACTER_VARIANT,
|
||||
nsDependentAtomString(ident.AsAtom()), values);
|
||||
ident.AsAtom(), values);
|
||||
// nothing defined, skip
|
||||
if (values.IsEmpty()) {
|
||||
continue;
|
||||
@ -375,7 +375,7 @@ static void LookupAlternateValues(gfxFontFeatureValueSet& aFeatureLookup,
|
||||
// FIXME(emilio): Use atoms directly.
|
||||
aFeatureLookup.GetFontFeatureValuesFor(
|
||||
aFamily, NS_FONT_VARIANT_ALTERNATES_STYLESET,
|
||||
nsDependentAtomString(ident.AsAtom()), values);
|
||||
ident.AsAtom(), values);
|
||||
|
||||
// styleset(1 2 7) ==> 'ss01' = 1, 'ss02' = 1, 'ss07' = 1
|
||||
feature.mValue = 1;
|
||||
@ -415,8 +415,7 @@ static void LookupAlternateValues(gfxFontFeatureValueSet& aFeatureLookup,
|
||||
}
|
||||
|
||||
AutoTArray<uint32_t, 4> values;
|
||||
aFeatureLookup.GetFontFeatureValuesFor(aFamily, constant,
|
||||
nsDependentAtomString(name), values);
|
||||
aFeatureLookup.GetFontFeatureValuesFor(aFamily, constant, name, values);
|
||||
if (values.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "gfxFontFeatures.h"
|
||||
#include "nsAtom.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsHashKeys.h"
|
||||
|
||||
@ -13,7 +14,7 @@ gfxFontFeatureValueSet::gfxFontFeatureValueSet() : mFontFeatureValues(8) {}
|
||||
|
||||
bool gfxFontFeatureValueSet::GetFontFeatureValuesFor(
|
||||
const nsACString& aFamily, uint32_t aVariantProperty,
|
||||
const nsAString& aName, nsTArray<uint32_t>& aValues) {
|
||||
nsAtom* aName, nsTArray<uint32_t>& aValues) {
|
||||
nsAutoCString family(aFamily);
|
||||
ToLowerCase(family);
|
||||
FeatureValueHashKey key(family, aVariantProperty, aName);
|
||||
@ -31,7 +32,7 @@ bool gfxFontFeatureValueSet::GetFontFeatureValuesFor(
|
||||
}
|
||||
|
||||
nsTArray<uint32_t>* gfxFontFeatureValueSet::AppendFeatureValueHashEntry(
|
||||
const nsACString& aFamily, const nsAString& aName, uint32_t aAlternate) {
|
||||
const nsACString& aFamily, nsAtom* aName, uint32_t aAlternate) {
|
||||
FeatureValueHashKey key(aFamily, aAlternate, aName);
|
||||
FeatureValueHashEntry* entry = mFontFeatureValues.PutEntry(key);
|
||||
entry->mKey = key;
|
||||
@ -41,11 +42,12 @@ nsTArray<uint32_t>* gfxFontFeatureValueSet::AppendFeatureValueHashEntry(
|
||||
bool gfxFontFeatureValueSet::FeatureValueHashEntry::KeyEquals(
|
||||
const KeyTypePointer aKey) const {
|
||||
return aKey->mPropVal == mKey.mPropVal &&
|
||||
aKey->mFamily.Equals(mKey.mFamily) && aKey->mName.Equals(mKey.mName);
|
||||
aKey->mName == mKey.mName &&
|
||||
aKey->mFamily.Equals(mKey.mFamily);
|
||||
}
|
||||
|
||||
PLDHashNumber gfxFontFeatureValueSet::FeatureValueHashEntry::HashKey(
|
||||
const KeyTypePointer aKey) {
|
||||
return HashString(aKey->mFamily) + HashString(aKey->mName) +
|
||||
return HashString(aKey->mFamily) + aKey->mName->hash() +
|
||||
aKey->mPropVal * uint32_t(0xdeadbeef);
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ inline bool operator==(const gfxFontFeature& a, const gfxFontFeature& b) {
|
||||
return (a.mTag == b.mTag) && (a.mValue == b.mValue);
|
||||
}
|
||||
|
||||
class nsAtom;
|
||||
|
||||
class gfxFontFeatureValueSet final {
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(gfxFontFeatureValueSet)
|
||||
@ -48,13 +50,13 @@ class gfxFontFeatureValueSet final {
|
||||
// returns true if found, false otherwise
|
||||
bool GetFontFeatureValuesFor(const nsACString& aFamily,
|
||||
uint32_t aVariantProperty,
|
||||
const nsAString& aName,
|
||||
nsAtom* aName,
|
||||
nsTArray<uint32_t>& aValues);
|
||||
|
||||
// Appends a new hash entry with given key values and returns a pointer to
|
||||
// mValues array to fill. This should be filled first.
|
||||
nsTArray<uint32_t>* AppendFeatureValueHashEntry(const nsACString& aFamily,
|
||||
const nsAString& aName,
|
||||
nsAtom* aName,
|
||||
uint32_t aAlternate);
|
||||
|
||||
private:
|
||||
@ -64,11 +66,11 @@ class gfxFontFeatureValueSet final {
|
||||
struct FeatureValueHashKey {
|
||||
nsCString mFamily;
|
||||
uint32_t mPropVal;
|
||||
nsString mName;
|
||||
RefPtr<nsAtom> mName;
|
||||
|
||||
FeatureValueHashKey() : mPropVal(0) {}
|
||||
FeatureValueHashKey(const nsACString& aFamily, uint32_t aPropVal,
|
||||
const nsAString& aName)
|
||||
nsAtom* aName)
|
||||
: mFamily(aFamily), mPropVal(aPropVal), mName(aName) {}
|
||||
FeatureValueHashKey(const FeatureValueHashKey& aKey)
|
||||
: mFamily(aKey.mFamily), mPropVal(aKey.mPropVal), mName(aKey.mName) {}
|
||||
|
@ -1028,14 +1028,12 @@ gfxFontFeatureValueSet* Gecko_ConstructFontFeatureValueSet() {
|
||||
return new gfxFontFeatureValueSet();
|
||||
}
|
||||
|
||||
nsTArray<unsigned int>* Gecko_AppendFeatureValueHashEntry(
|
||||
nsTArray<uint32_t>* Gecko_AppendFeatureValueHashEntry(
|
||||
gfxFontFeatureValueSet* aFontFeatureValues, nsAtom* aFamily,
|
||||
uint32_t aAlternate, nsAtom* aName) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
static_assert(sizeof(unsigned int) == sizeof(uint32_t),
|
||||
"sizeof unsigned int and uint32_t must be the same");
|
||||
return aFontFeatureValues->AppendFeatureValueHashEntry(
|
||||
nsAtomCString(aFamily), nsDependentAtomString(aName), aAlternate);
|
||||
nsAtomCString(aFamily), aName, aAlternate);
|
||||
}
|
||||
|
||||
float Gecko_FontStretch_ToFloat(FontStretch aStretch) {
|
||||
|
@ -295,7 +295,7 @@ void Gecko_nsFont_Destroy(nsFont* dst);
|
||||
// The gfxFontFeatureValueSet returned from this function has zero reference.
|
||||
gfxFontFeatureValueSet* Gecko_ConstructFontFeatureValueSet();
|
||||
|
||||
nsTArray<unsigned int>* Gecko_AppendFeatureValueHashEntry(
|
||||
nsTArray<uint32_t>* Gecko_AppendFeatureValueHashEntry(
|
||||
gfxFontFeatureValueSet* value_set, nsAtom* family, uint32_t alternate,
|
||||
nsAtom* name);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user