Bug 1280162 - patch 2 - Add a getFeatures() method to InspectorFontFace to expose the OpenType features supported by a font. r=dholbert,bz

This commit is contained in:
Jonathan Kew 2018-01-30 09:57:39 +00:00
parent 8ddd714a33
commit 3b1dc9e5ec
3 changed files with 30 additions and 0 deletions

View File

@ -111,6 +111,12 @@ dictionary InspectorVariationInstance {
required sequence<InspectorVariationValue> values;
};
dictionary InspectorFontFeature {
required DOMString tag;
required DOMString script;
required DOMString languageSystem;
};
[ChromeOnly]
interface InspectorFontFace {
// An indication of how we found this font during font-matching.
@ -127,6 +133,7 @@ interface InspectorFontFace {
[NewObject,Throws] sequence<InspectorVariationAxis> getVariationAxes();
[NewObject,Throws] sequence<InspectorVariationInstance> getVariationInstances();
[NewObject,Throws] sequence<InspectorFontFeature> getFeatures();
// meaningful only when the font is a user font defined using @font-face
readonly attribute CSSFontFaceRule? rule; // null if no associated @font-face rule

View File

@ -259,5 +259,26 @@ InspectorFontFace::GetVariationInstances(
}
}
void
InspectorFontFace::GetFeatures(nsTArray<InspectorFontFeature>& aResult,
ErrorResult& aRV)
{
AutoTArray<gfxFontFeatureInfo,64> features;
mFontEntry->GetFeatureInfo(features);
if (features.IsEmpty()) {
return;
}
if (!aResult.SetCapacity(features.Length(), mozilla::fallible)) {
aRV.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
for (auto& f : features) {
InspectorFontFeature& feat = *aResult.AppendElement();
AppendTagAsASCII(feat.mTag, f.mTag);
AppendTagAsASCII(feat.mScript, f.mScript);
AppendTagAsASCII(feat.mLanguageSystem, f.mLangSys);
}
}
} // namespace dom
} // namespace mozilla

View File

@ -59,6 +59,8 @@ public:
ErrorResult& aRV);
void GetVariationInstances(nsTArray<InspectorVariationInstance>& aResult,
ErrorResult& aRV);
void GetFeatures(nsTArray<InspectorFontFeature>& aResult,
ErrorResult& aRV);
bool WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto,