forked from mirrors/gecko-dev
Bug 1476470: Remove dead code from nsStyleUtil. r=jwatt
This is dead since we started serializing the relevant stuff with Servo. Differential Revision: https://phabricator.services.mozilla.com/D2208 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
2fa716ed4d
commit
f206e569cd
2 changed files with 0 additions and 372 deletions
|
|
@ -179,79 +179,6 @@ nsStyleUtil::AppendEscapedCSSIdent(const nsAString& aIdent, nsAString& aReturn)
|
|||
}
|
||||
}
|
||||
|
||||
// unquoted family names must be a sequence of idents
|
||||
// so escape any parts that require escaping
|
||||
static void
|
||||
AppendUnquotedFamilyName(const nsAString& aFamilyName, nsAString& aResult)
|
||||
{
|
||||
const char16_t *p, *p_end;
|
||||
aFamilyName.BeginReading(p);
|
||||
aFamilyName.EndReading(p_end);
|
||||
|
||||
bool moreThanOne = false;
|
||||
while (p < p_end) {
|
||||
const char16_t* identStart = p;
|
||||
while (++p != p_end && *p != ' ')
|
||||
/* nothing */ ;
|
||||
|
||||
nsDependentSubstring ident(identStart, p);
|
||||
if (!ident.IsEmpty()) {
|
||||
if (moreThanOne) {
|
||||
aResult.Append(' ');
|
||||
}
|
||||
nsStyleUtil::AppendEscapedCSSIdent(ident, aResult);
|
||||
moreThanOne = true;
|
||||
}
|
||||
|
||||
++p;
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsStyleUtil::AppendEscapedCSSFontFamilyList(
|
||||
const nsTArray<mozilla::FontFamilyName>& aNames,
|
||||
nsAString& aResult)
|
||||
{
|
||||
size_t i, len = aNames.Length();
|
||||
for (i = 0; i < len; i++) {
|
||||
if (i != 0) {
|
||||
aResult.AppendLiteral(", ");
|
||||
}
|
||||
const FontFamilyName& name = aNames[i];
|
||||
switch (name.mType) {
|
||||
case eFamily_named:
|
||||
AppendUnquotedFamilyName(name.mName, aResult);
|
||||
break;
|
||||
case eFamily_named_quoted:
|
||||
AppendEscapedCSSString(name.mName, aResult);
|
||||
break;
|
||||
default:
|
||||
name.AppendToString(aResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsStyleUtil::AppendEscapedCSSFontFamilyList(
|
||||
const mozilla::FontFamilyList& aFamilyList,
|
||||
nsAString& aResult)
|
||||
{
|
||||
if (aFamilyList.IsEmpty()) {
|
||||
FontFamilyType defaultGeneric = aFamilyList.GetDefaultFontType();
|
||||
// If the font list is empty, then serialize the default generic.
|
||||
// See also: gfxFontGroup::BuildFontList()
|
||||
if (defaultGeneric != eFamily_none) {
|
||||
FontFamilyName(defaultGeneric).AppendToString(aResult);
|
||||
} else {
|
||||
MOZ_ASSERT_UNREACHABLE("No fonts to serialize");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
AppendEscapedCSSFontFamilyList(aFamilyList.GetFontlist().get(), aResult);
|
||||
}
|
||||
|
||||
|
||||
/* static */ void
|
||||
nsStyleUtil::AppendBitmaskCSSValue(const nsCSSKTableEntry aTable[],
|
||||
int32_t aMaskedValue,
|
||||
|
|
@ -350,260 +277,6 @@ nsStyleUtil::AppendPaintOrderValue(uint8_t aValue,
|
|||
}
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsStyleUtil::AppendFontTagAsString(uint32_t aTag, nsAString& aResult)
|
||||
{
|
||||
// A font tag (for feature/variation settings) is a 4-char code interpreted
|
||||
// as a bigendian 32-bit value and stored/processed as a uint32_t.
|
||||
// To serialize it, we put the four bytes (which are all guaranteed to be
|
||||
// printable ASCII values) into a string, starting from the high byte of the
|
||||
// value, then append that to the result with CSS escaping and quotes.
|
||||
nsAutoString tagStr;
|
||||
for (int shiftAmount = 24; shiftAmount >= 0; shiftAmount -= 8) {
|
||||
char c = (aTag >> shiftAmount) & 0xff;
|
||||
MOZ_ASSERT(isascii(c) && isprint(c),
|
||||
"parser should have restricted tag to printable ASCII chars");
|
||||
tagStr.Append(c);
|
||||
}
|
||||
AppendEscapedCSSString(tagStr, aResult);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsStyleUtil::AppendFontFeatureSettings(const nsTArray<gfxFontFeature>& aFeatures,
|
||||
nsAString& aResult)
|
||||
{
|
||||
for (uint32_t i = 0, numFeat = aFeatures.Length(); i < numFeat; i++) {
|
||||
const gfxFontFeature& feat = aFeatures[i];
|
||||
|
||||
if (i != 0) {
|
||||
aResult.AppendLiteral(", ");
|
||||
}
|
||||
|
||||
AppendFontTagAsString(feat.mTag, aResult);
|
||||
|
||||
// omit value if it's 1, implied by default
|
||||
if (feat.mValue != 1) {
|
||||
aResult.Append(' ');
|
||||
aResult.AppendInt(feat.mValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsStyleUtil::AppendFontFeatureSettings(const nsCSSValue& aSrc,
|
||||
nsAString& aResult)
|
||||
{
|
||||
nsCSSUnit unit = aSrc.GetUnit();
|
||||
|
||||
if (unit == eCSSUnit_Normal) {
|
||||
aResult.AppendLiteral("normal");
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(unit == eCSSUnit_PairList || unit == eCSSUnit_PairListDep,
|
||||
"improper value unit for font-feature-settings:");
|
||||
|
||||
nsTArray<gfxFontFeature> featureSettings;
|
||||
nsLayoutUtils::ComputeFontFeatures(aSrc.GetPairListValue(), featureSettings);
|
||||
AppendFontFeatureSettings(featureSettings, aResult);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsStyleUtil::AppendFontVariationSettings(const nsTArray<gfxFontVariation>& aVariations,
|
||||
nsAString& aResult)
|
||||
{
|
||||
for (uint32_t i = 0, numVars = aVariations.Length(); i < numVars; i++) {
|
||||
const gfxFontVariation& var = aVariations[i];
|
||||
|
||||
if (i != 0) {
|
||||
aResult.AppendLiteral(", ");
|
||||
}
|
||||
|
||||
// output tag
|
||||
AppendFontTagAsString(var.mTag, aResult);
|
||||
|
||||
// output value
|
||||
aResult.Append(' ');
|
||||
aResult.AppendFloat(var.mValue);
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsStyleUtil::AppendFontVariationSettings(const nsCSSValue& aSrc,
|
||||
nsAString& aResult)
|
||||
{
|
||||
nsCSSUnit unit = aSrc.GetUnit();
|
||||
|
||||
if (unit == eCSSUnit_Normal) {
|
||||
aResult.AppendLiteral("normal");
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(unit == eCSSUnit_PairList || unit == eCSSUnit_PairListDep,
|
||||
"improper value unit for font-variation-settings:");
|
||||
|
||||
nsTArray<gfxFontVariation> variationSettings;
|
||||
nsLayoutUtils::ComputeFontVariations(aSrc.GetPairListValue(),
|
||||
variationSettings);
|
||||
AppendFontVariationSettings(variationSettings, aResult);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsStyleUtil::GetFunctionalAlternatesName(int32_t aFeature,
|
||||
nsAString& aFeatureName)
|
||||
{
|
||||
aFeatureName.Truncate();
|
||||
nsCSSKeyword key =
|
||||
nsCSSProps::ValueToKeywordEnum(aFeature,
|
||||
nsCSSProps::kFontVariantAlternatesFuncsKTable);
|
||||
|
||||
NS_ASSERTION(key != eCSSKeyword_UNKNOWN, "bad alternate feature type");
|
||||
AppendUTF8toUTF16(nsCSSKeywords::GetStringValue(key), aFeatureName);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsStyleUtil::SerializeFunctionalAlternates(
|
||||
const nsTArray<gfxAlternateValue>& aAlternates,
|
||||
nsAString& aResult)
|
||||
{
|
||||
nsAutoString funcName, funcParams;
|
||||
uint32_t numValues = aAlternates.Length();
|
||||
|
||||
uint32_t feature = 0;
|
||||
for (uint32_t i = 0; i < numValues; i++) {
|
||||
const gfxAlternateValue& v = aAlternates.ElementAt(i);
|
||||
if (feature != v.alternate) {
|
||||
feature = v.alternate;
|
||||
if (!funcName.IsEmpty() && !funcParams.IsEmpty()) {
|
||||
if (!aResult.IsEmpty()) {
|
||||
aResult.Append(char16_t(' '));
|
||||
}
|
||||
|
||||
// append the previous functional value
|
||||
aResult.Append(funcName);
|
||||
aResult.Append(char16_t('('));
|
||||
aResult.Append(funcParams);
|
||||
aResult.Append(char16_t(')'));
|
||||
}
|
||||
|
||||
// function name
|
||||
GetFunctionalAlternatesName(v.alternate, funcName);
|
||||
NS_ASSERTION(!funcName.IsEmpty(), "unknown property value name");
|
||||
|
||||
// function params
|
||||
funcParams.Truncate();
|
||||
AppendEscapedCSSIdent(v.value, funcParams);
|
||||
} else {
|
||||
if (!funcParams.IsEmpty()) {
|
||||
funcParams.AppendLiteral(", ");
|
||||
}
|
||||
AppendEscapedCSSIdent(v.value, funcParams);
|
||||
}
|
||||
}
|
||||
|
||||
// append the previous functional value
|
||||
if (!funcName.IsEmpty() && !funcParams.IsEmpty()) {
|
||||
if (!aResult.IsEmpty()) {
|
||||
aResult.Append(char16_t(' '));
|
||||
}
|
||||
|
||||
aResult.Append(funcName);
|
||||
aResult.Append(char16_t('('));
|
||||
aResult.Append(funcParams);
|
||||
aResult.Append(char16_t(')'));
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsStyleUtil::ComputeFunctionalAlternates(const nsCSSValueList* aList,
|
||||
nsTArray<gfxAlternateValue>& aAlternateValues)
|
||||
{
|
||||
gfxAlternateValue v;
|
||||
|
||||
aAlternateValues.Clear();
|
||||
for (const nsCSSValueList* curr = aList; curr != nullptr; curr = curr->mNext) {
|
||||
// list contains function units
|
||||
if (curr->mValue.GetUnit() != eCSSUnit_Function) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// element 0 is the propval in ident form
|
||||
const nsCSSValue::Array *func = curr->mValue.GetArrayValue();
|
||||
|
||||
// lookup propval
|
||||
nsCSSKeyword key = func->Item(0).GetKeywordValue();
|
||||
NS_ASSERTION(key != eCSSKeyword_UNKNOWN, "unknown alternate property value");
|
||||
|
||||
int32_t alternate;
|
||||
if (!nsCSSProps::FindKeyword(key,
|
||||
nsCSSProps::kFontVariantAlternatesFuncsKTable,
|
||||
alternate)) {
|
||||
MOZ_ASSERT_UNREACHABLE("keyword not a font-variant-alternates value");
|
||||
continue;
|
||||
}
|
||||
v.alternate = alternate;
|
||||
|
||||
// other elements are the idents associated with the propval
|
||||
// append one alternate value for each one
|
||||
uint32_t numElems = func->Count();
|
||||
for (uint32_t i = 1; i < numElems; i++) {
|
||||
const nsCSSValue& value = func->Item(i);
|
||||
NS_ASSERTION(value.GetUnit() == eCSSUnit_Ident,
|
||||
"weird unit found in variant alternate");
|
||||
if (value.GetUnit() != eCSSUnit_Ident) {
|
||||
continue;
|
||||
}
|
||||
value.GetStringValue(v.value);
|
||||
aAlternateValues.AppendElement(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
AppendSerializedUnicodePoint(uint32_t aCode, nsACString& aBuf)
|
||||
{
|
||||
aBuf.Append(nsPrintfCString("%0X", aCode));
|
||||
}
|
||||
|
||||
// A unicode-range: descriptor is represented as an array of integers,
|
||||
// to be interpreted as a sequence of pairs: min max min max ...
|
||||
// It is in source order. (Possibly it should be sorted and overlaps
|
||||
// consolidated, but right now we don't do that.)
|
||||
/* static */ void
|
||||
nsStyleUtil::AppendUnicodeRange(const nsCSSValue& aValue, nsAString& aResult)
|
||||
{
|
||||
MOZ_ASSERT(aValue.GetUnit() == eCSSUnit_Null ||
|
||||
aValue.GetUnit() == eCSSUnit_Array,
|
||||
"improper value unit for unicode-range:");
|
||||
|
||||
aResult.Truncate();
|
||||
if (aValue.GetUnit() != eCSSUnit_Array)
|
||||
return;
|
||||
|
||||
nsCSSValue::Array const & sources = *aValue.GetArrayValue();
|
||||
nsAutoCString buf;
|
||||
|
||||
MOZ_ASSERT(sources.Count() % 2 == 0,
|
||||
"odd number of entries in a unicode-range: array");
|
||||
|
||||
for (uint32_t i = 0; i < sources.Count(); i += 2) {
|
||||
uint32_t min = sources[i].GetIntValue();
|
||||
uint32_t max = sources[i+1].GetIntValue();
|
||||
|
||||
// We don't try to replicate the U+XX?? notation.
|
||||
buf.AppendLiteral("U+");
|
||||
AppendSerializedUnicodePoint(min, buf);
|
||||
|
||||
if (min != max) {
|
||||
buf.Append('-');
|
||||
AppendSerializedUnicodePoint(max, buf);
|
||||
}
|
||||
buf.AppendLiteral(", ");
|
||||
}
|
||||
buf.Truncate(buf.Length() - 2); // remove the last comma-space
|
||||
CopyASCIItoUTF16(buf, aResult);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
nsStyleUtil::AppendStepsTimingFunction(nsTimingFunction::Type aType,
|
||||
uint32_t aSteps,
|
||||
|
|
|
|||
|
|
@ -56,24 +56,9 @@ public:
|
|||
static void AppendEscapedCSSIdent(const nsAString& aIdent,
|
||||
nsAString& aResult);
|
||||
|
||||
static void
|
||||
AppendEscapedCSSFontFamilyList(const mozilla::FontFamilyList& aFamilyList,
|
||||
nsAString& aResult);
|
||||
static void
|
||||
AppendEscapedCSSFontFamilyList(mozilla::SharedFontList* aFontlist,
|
||||
nsAString& aResult)
|
||||
{
|
||||
AppendEscapedCSSFontFamilyList(aFontlist->mNames, aResult);
|
||||
}
|
||||
|
||||
static void
|
||||
AppendFontSlantStyle(const mozilla::FontSlantStyle&, nsAString& aResult);
|
||||
|
||||
private:
|
||||
static void
|
||||
AppendEscapedCSSFontFamilyList(const nsTArray<mozilla::FontFamilyName>& aNames,
|
||||
nsAString& aResult);
|
||||
|
||||
public:
|
||||
// Append a bitmask-valued property's value(s) (space-separated) to aResult.
|
||||
static void AppendBitmaskCSSValue(const nsCSSKTableEntry aTable[],
|
||||
|
|
@ -86,22 +71,6 @@ public:
|
|||
|
||||
static void AppendPaintOrderValue(uint8_t aValue, nsAString& aResult);
|
||||
|
||||
static void AppendFontTagAsString(uint32_t aTag, nsAString& aResult);
|
||||
|
||||
static void AppendFontFeatureSettings(const nsTArray<gfxFontFeature>& aFeatures,
|
||||
nsAString& aResult);
|
||||
|
||||
static void AppendFontFeatureSettings(const nsCSSValue& src,
|
||||
nsAString& aResult);
|
||||
|
||||
static void AppendFontVariationSettings(const nsTArray<gfxFontVariation>& aVariations,
|
||||
nsAString& aResult);
|
||||
|
||||
static void AppendFontVariationSettings(const nsCSSValue& src,
|
||||
nsAString& aResult);
|
||||
|
||||
static void AppendUnicodeRange(const nsCSSValue& aValue, nsAString& aResult);
|
||||
|
||||
static void AppendCSSNumber(float aNumber, nsAString& aResult)
|
||||
{
|
||||
aResult.AppendFloat(aNumber);
|
||||
|
|
@ -119,20 +88,6 @@ public:
|
|||
nsTimingFunction::Type aType,
|
||||
nsAString& aResult);
|
||||
|
||||
// convert bitmask value to keyword name for a functional alternate
|
||||
static void GetFunctionalAlternatesName(int32_t aFeature,
|
||||
nsAString& aFeatureName);
|
||||
|
||||
// Append functional font-variant-alternates values to string
|
||||
static void
|
||||
SerializeFunctionalAlternates(const nsTArray<gfxAlternateValue>& aAlternates,
|
||||
nsAString& aResult);
|
||||
|
||||
// List of functional font-variant-alternates values to feature/value pairs
|
||||
static void
|
||||
ComputeFunctionalAlternates(const nsCSSValueList* aList,
|
||||
nsTArray<gfxAlternateValue>& aAlternateValues);
|
||||
|
||||
/*
|
||||
* Convert an author-provided floating point number to an integer (0
|
||||
* ... 255) appropriate for use in the alpha component of a color.
|
||||
|
|
|
|||
Loading…
Reference in a new issue