Bug 1323743 - patch 2 - Add a getVariationAxes() method to InspectorFontFace for potential devtools use. r=dholbert,bz

This commit is contained in:
Jonathan Kew 2018-01-26 15:47:20 +00:00
parent 455fe3a96e
commit a223c0105f
3 changed files with 37 additions and 0 deletions

View File

@ -93,6 +93,14 @@ dictionary InspectorRGBATuple {
double a = 1;
};
dictionary InspectorVariationAxis {
required DOMString tag;
required DOMString name;
required float minValue;
required float maxValue;
required float defaultValue;
};
[ChromeOnly]
interface InspectorFontFace {
// An indication of how we found this font during font-matching.
@ -107,6 +115,8 @@ interface InspectorFontFace {
// (not necessarily the actual name that was used,
// due to aliases, generics, localized names, etc)
[NewObject] sequence<InspectorVariationAxis> getVariationAxes();
// meaningful only when the font is a user font defined using @font-face
readonly attribute CSSFontFaceRule? rule; // null if no associated @font-face rule
readonly attribute long srcIndex; // index in the rule's src list, -1 if no @font-face rule

View File

@ -189,5 +189,30 @@ InspectorFontFace::GetMetadata(nsAString& aMetadata)
}
}
void
InspectorFontFace::GetVariationAxes(nsTArray<InspectorVariationAxis>& aResult)
{
if (!mFontEntry->HasVariations()) {
return;
}
AutoTArray<gfxFontVariationAxis,4> axes;
mFontEntry->GetVariationAxes(axes);
MOZ_ASSERT(!axes.IsEmpty());
for (auto a : axes) {
// Turn the uint32_t OpenType tag into a 4-ASCII-character string
nsAutoStringN<4> tag;
tag.AppendPrintf("%c%c%c%c", (a.mTag >> 24) & 0xff,
(a.mTag >> 16) & 0xff,
(a.mTag >> 8) & 0xff,
a.mTag & 0xff);
InspectorVariationAxis& axis = *aResult.AppendElement();
axis.mTag = tag;
axis.mName = a.mName;
axis.mMinValue = a.mMinValue;
axis.mMaxValue = a.mMaxValue;
axis.mDefaultValue = a.mDefaultValue;
}
}
} // namespace dom
} // namespace mozilla

View File

@ -55,6 +55,8 @@ public:
void GetFormat(nsAString& aFormat);
void GetMetadata(nsAString& aMetadata);
void GetVariationAxes(nsTArray<InspectorVariationAxis>& aResult);
bool WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto,
JS::MutableHandle<JSObject*> aReflector)