Bug 1630935 - Add use counter and deprecation warning for STIXGeneral fonts. r=emilio

This patch adds the boolean pref mathml.stixgeneral_operator_stretching.disabled, which defaults to true iff nightly.

When the pref is true, stretched operators won’t be rendered with STIXGeneral, because we only use OpenType MATH tables (in fonts that have them) or the generic Unicode table.

When the pref is false, we continue to support STIXGeneral for stretched operators, but warn the author in devtools and bump the use counter (up to once per page). This only happens when a stretched operator actually uses STIXGeneral: not when we successfully render the operator with some other font earlier in the font-family stack, and not when STIXGeneral isn’t installed.

Differential Revision: https://phabricator.services.mozilla.com/D73833
This commit is contained in:
Delan Azabani 2020-06-25 04:20:57 +00:00
Родитель e623d5a1fe
Коммит 5dc229e516
7 изменённых файлов: 28 добавлений и 6 удалений

Просмотреть файл

@ -12216,8 +12216,9 @@ bool Document::HasWarnedAbout(DeprecatedOperations aOperation) const {
return mDeprecationWarnedAbout[aOperation];
}
void Document::WarnOnceAbout(DeprecatedOperations aOperation,
bool asError /* = false */) const {
void Document::WarnOnceAbout(
DeprecatedOperations aOperation, bool asError /* = false */,
const nsTArray<nsString>& aParams /* = empty array */) const {
MOZ_ASSERT(NS_IsMainThread());
if (HasWarnedAbout(aOperation)) {
return;
@ -12234,7 +12235,7 @@ void Document::WarnOnceAbout(DeprecatedOperations aOperation,
asError ? nsIScriptError::errorFlag : nsIScriptError::warningFlag;
nsContentUtils::ReportToConsole(flags, NS_LITERAL_CSTRING("DOM Core"), this,
nsContentUtils::eDOM_PROPERTIES,
kDeprecationWarnings[aOperation]);
kDeprecationWarnings[aOperation], aParams);
}
bool Document::HasWarnedAbout(DocumentWarnings aWarning) const {

Просмотреть файл

@ -3120,8 +3120,9 @@ class Document : public nsINode,
};
#undef DEPRECATED_OPERATION
bool HasWarnedAbout(DeprecatedOperations aOperation) const;
void WarnOnceAbout(DeprecatedOperations aOperation,
bool asError = false) const;
void WarnOnceAbout(
DeprecatedOperations aOperation, bool asError = false,
const nsTArray<nsString>& aParams = nsTArray<nsString>()) const;
#define DOCUMENT_WARNING(_op) e##_op,
enum DocumentWarnings {

Просмотреть файл

@ -53,3 +53,4 @@ DEPRECATED_OPERATION(MathML_DeprecatedMfencedElement)
DEPRECATED_OPERATION(MathML_DeprecatedScriptShiftAttributes)
DEPRECATED_OPERATION(MathML_DeprecatedStyleAttribute)
DEPRECATED_OPERATION(MathML_DeprecatedXLinkAttribute)
DEPRECATED_OPERATION(MathML_DeprecatedStixgeneralOperatorStretching)

Просмотреть файл

@ -384,6 +384,8 @@ MathML_DeprecatedScriptShiftAttributes=MathML attributes “subscriptshift” an
MathML_DeprecatedStyleAttributeWarning=MathML attributes “background”, “color”, “fontfamily”, “fontsize”, “fontstyle” and “fontweight” are deprecated and will be removed at a future date.
# LOCALIZATION NOTE: Do not translate MathML and XLink.
MathML_DeprecatedXLinkAttributeWarning=XLink attributes “href”, “type”, “show” and “actuate” are deprecated on MathML elements and will be removed at a future date.
# LOCALIZATION NOTE: Do not translate MathML and STIXGeneral. %S is a documentation URL.
MathML_DeprecatedStixgeneralOperatorStretchingWarning=Support for rendering stretched MathML operators with STIXGeneral fonts is deprecated and may be removed at a future date. For details about newer fonts that will continue to be supported, see %S
WebShareAPI_Failed=The share operation has failed.
WebShareAPI_Aborted=The share operation was aborted.
# LOCALIZATION NOTE (UnknownProtocolNavigationPrevented): %1$S is the destination URL.

Просмотреть файл

@ -14,6 +14,7 @@
#include "mozilla/MathAlgorithms.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/Unused.h"
#include "mozilla/StaticPrefs_mathml.h"
#include "nsCOMPtr.h"
#include "nsDeviceContext.h"
@ -1311,6 +1312,8 @@ bool nsMathMLChar::StretchEnumContext::EnumCallback(
openTypeTable = nsOpenTypeTable::Create(fontGroup->GetFirstValidFont());
if (openTypeTable) {
glyphTable = openTypeTable.get();
} else if (StaticPrefs::mathml_stixgeneral_operator_stretching_disabled()) {
glyphTable = &gGlyphTableList->mUnicodeTable;
} else {
// Otherwise try to find a .properties file corresponding to that font
// family or fallback to the Unicode table.
@ -1527,6 +1530,14 @@ nsresult nsMathMLChar::StretchInternal(
font.fontlist.GetFontlist()->mNames;
for (const FontFamilyName& name : fontlist) {
if (StretchEnumContext::EnumCallback(name, name.IsGeneric(), &enumData)) {
if (name.IsNamedFamily(NS_LITERAL_STRING("STIXGeneral"))) {
AutoTArray<nsString, 1> params{
NS_LITERAL_STRING("https://developer.mozilla.org/docs/Mozilla/"
"MathML_Project/Fonts")};
aForFrame->PresContext()->Document()->WarnOnceAbout(
dom::Document::eMathML_DeprecatedStixgeneralOperatorStretching,
false, params);
}
break;
}
}

Просмотреть файл

@ -120,7 +120,7 @@ pref(mathml.mfrac_bevelled_attribute.disabled,false) == table-width-1.xhtml tabl
== embellished-op-4-3.html embellished-op-4-3-ref.html
== embellished-op-5-1.html embellished-op-5-ref.html
== embellished-op-5-2.html embellished-op-5-ref.html
== semantics-1.xhtml semantics-1-ref.xhtml # bug 1309429
pref(mathml.stixgeneral_operator_stretching.disabled,false) == semantics-1.xhtml semantics-1-ref.xhtml # bug 1309429; bug 1648335
== semantics-2.html semantics-2-ref.html
== semantics-3.html semantics-3-ref.html
== semantics-4.html semantics-4-ref.html

Просмотреть файл

@ -6474,6 +6474,12 @@
value: @IS_NIGHTLY_BUILD@
mirror: always
# Whether to disable support for stretching operators with STIXGeneral fonts.
- name: mathml.stixgeneral_operator_stretching.disabled
type: bool
value: @IS_NIGHTLY_BUILD@
mirror: always
#---------------------------------------------------------------------------
# Prefs starting with "media."
#---------------------------------------------------------------------------