Bug 1802957 - Remove non-standard and unused system font values. r=jfkthame

And hide internal but used values. System fonts are not exposed in the
computed style so this should be fine.

If we need the old values for some obscure reason, it's trivial to alias
them to e.g., menu or so.

Differential Revision: https://phabricator.services.mozilla.com/D163269
This commit is contained in:
Emilio Cobos Álvarez 2022-12-01 09:23:19 +00:00
Родитель ea44d8c7fb
Коммит c9a0f65ceb
14 изменённых файлов: 43 добавлений и 77 удалений

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

@ -6756,15 +6756,9 @@ exports.CSS_PROPERTIES = {
"supports": [], "supports": [],
"values": [ "values": [
"-moz-button", "-moz-button",
"-moz-desktop",
"-moz-dialog",
"-moz-document",
"-moz-field", "-moz-field",
"-moz-info",
"-moz-list", "-moz-list",
"-moz-pull-down-menu", "-moz-pull-down-menu",
"-moz-window",
"-moz-workspace",
"all-petite-caps", "all-petite-caps",
"all-small-caps", "all-small-caps",
"bold", "bold",

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

@ -1866,9 +1866,6 @@ void gfxMacPlatformFontList::LookupSystemFont(LookAndFeel::FontID aSystemFontID,
break; break;
case LookAndFeel::FontID::Icon: // used in urlbar; tried labelFont, but too small case LookAndFeel::FontID::Icon: // used in urlbar; tried labelFont, but too small
case LookAndFeel::FontID::MozWorkspace:
case LookAndFeel::FontID::MozDesktop:
case LookAndFeel::FontID::MozInfo:
font = [NSFont controlContentFontOfSize:0.0]; font = [NSFont controlContentFontOfSize:0.0];
systemFontName = (char*)kSystemFont_system; systemFontName = (char*)kSystemFont_system;
break; break;
@ -1880,7 +1877,6 @@ void gfxMacPlatformFontList::LookupSystemFont(LookAndFeel::FontID aSystemFontID,
case LookAndFeel::FontID::Caption: case LookAndFeel::FontID::Caption:
case LookAndFeel::FontID::Menu: case LookAndFeel::FontID::Menu:
case LookAndFeel::FontID::MozDialog:
default: default:
font = [NSFont systemFontOfSize:0.0]; font = [NSFont systemFontOfSize:0.0];
systemFontName = (char*)kSystemFont_system; systemFontName = (char*)kSystemFont_system;

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

@ -10,9 +10,9 @@
/* Reduce the width so that container can fit all its children in 600px viewport width. */ /* Reduce the width so that container can fit all its children in 600px viewport width. */
width: 100px; width: 100px;
} }
input[type=date] {
/* date by default uses a monospace font, which might have different metrics */ /* date by default uses a monospace font, which might have different metrics */
font: -moz-field; input, button, select {
font: Menu;
} }
.small-font * { .small-font * {
font-size: 8px !important; /* important to override rule above */ font-size: 8px !important; /* important to override rule above */

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

@ -4,7 +4,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<script> <script>
window.onload = () => { window.onload = () => {
document.documentElement.animate([ { "font": "-moz-desktop" }, { "font": "message-box" } ]) document.documentElement.animate([ { "font": "menu" }, { "font": "message-box" } ])
} }
</script> </script>
</head> </head>

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

@ -5544,17 +5544,6 @@ var gCSSProperties = {
"message-box", "message-box",
"small-caption", "small-caption",
"status-bar", "status-bar",
// Gecko-specific system fonts
"-moz-window",
"-moz-document",
"-moz-desktop",
"-moz-info",
"-moz-dialog",
"-moz-button",
"-moz-pull-down-menu",
"-moz-list",
"-moz-field",
"-moz-workspace",
// line-height with calc() // line-height with calc()
"condensed bold italic small-caps 24px/calc(2px) Times New Roman, serif", "condensed bold italic small-caps 24px/calc(2px) Times New Roman, serif",
"condensed bold italic small-caps 24px/calc(50%) Times New Roman, serif", "condensed bold italic small-caps 24px/calc(50%) Times New Roman, serif",

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

@ -22,6 +22,12 @@ const NON_CONTENT_ACCESSIBLE_VALUES = {
"-moz-box", "-moz-box",
"-moz-inline-box", "-moz-inline-box",
], ],
"font": [
"-moz-pull-down-menu",
"-moz-button",
"-moz-list",
"-moz-field",
],
"-moz-appearance": [ "-moz-appearance": [
"button-arrow-down", "button-arrow-down",
"button-arrow-next", "button-arrow-next",

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

@ -48,24 +48,18 @@
* cserialize. * cserialize.
*/ */
var gSystemFont = { var gSystemFont = [
"caption": true, "caption",
"icon": true, "icon",
"menu": true, "menu",
"message-box": true, "message-box",
"small-caption": true, "small-caption",
"status-bar": true, "status-bar",
"-moz-window": true, "-moz-button",
"-moz-document": true, "-moz-pull-down-menu",
"-moz-desktop": true, "-moz-list",
"-moz-info": true, "-moz-field",
"-moz-dialog": true, ];
"-moz-button": true,
"-moz-pull-down-menu": true,
"-moz-list": true,
"-moz-field": true,
"-moz-workspace": true,
};
var gBadCompute = { var gBadCompute = {
// output wrapped around to positive, in exponential notation // output wrapped around to positive, in exponential notation
@ -154,7 +148,7 @@ function test_property(property)
function test_value(value, resolved_value) { function test_value(value, resolved_value) {
var value_has_variable_reference = resolved_value != null; var value_has_variable_reference = resolved_value != null;
var is_system_font = property == "font" && value in gSystemFont; var is_system_font = property == "font" && gSystemFont.includes(value);
var colon = ": "; var colon = ": ";
gDeclaration.setProperty(property, value, ""); gDeclaration.setProperty(property, value, "");

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

@ -69,7 +69,7 @@
let mut stretch = None; let mut stretch = None;
let size; let size;
% if engine == "gecko": % if engine == "gecko":
if let Ok(sys) = input.try_parse(SystemFont::parse) { if let Ok(sys) = input.try_parse(|i| SystemFont::parse(context, i)) {
return Ok(expanded! { return Ok(expanded! {
% for name in SYSTEM_FONT_LONGHANDS: % for name in SYSTEM_FONT_LONGHANDS:
${name}: ${name}::SpecifiedValue::system_font(sys), ${name}: ${name}::SpecifiedValue::system_font(sys),

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

@ -70,21 +70,29 @@ macro_rules! system_font_methods {
)] )]
#[allow(missing_docs)] #[allow(missing_docs)]
pub enum SystemFont { pub enum SystemFont {
/// https://drafts.csswg.org/css-fonts/#valdef-font-caption
Caption, Caption,
/// https://drafts.csswg.org/css-fonts/#valdef-font-icon
Icon, Icon,
/// https://drafts.csswg.org/css-fonts/#valdef-font-menu
Menu, Menu,
/// https://drafts.csswg.org/css-fonts/#valdef-font-message-box
MessageBox, MessageBox,
/// https://drafts.csswg.org/css-fonts/#valdef-font-small-caption
SmallCaption, SmallCaption,
/// https://drafts.csswg.org/css-fonts/#valdef-font-status-bar
StatusBar, StatusBar,
MozWindow, /// Internal system font, used by the `<menupopup>`s on macOS.
MozDocument, #[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
MozWorkspace,
MozDesktop,
MozInfo,
MozDialog,
MozButton,
MozPullDownMenu, MozPullDownMenu,
/// Internal system font, used for `<button>` elements.
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
MozButton,
/// Internal font, used by `<select>` elements.
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
MozList, MozList,
/// Internal font, used by `<input>` elements.
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
MozField, MozField,
#[css(skip)] #[css(skip)]
End, // Just for indexing purposes. End, // Just for indexing purposes.

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

@ -16,7 +16,7 @@ checkbox {
<vbox style="font: message-box"> <vbox style="font: message-box">
<hbox><checkbox native="true" label="Small"/></hbox> <hbox><checkbox native="true" label="Small"/></hbox>
</vbox> </vbox>
<vbox style="font: -moz-dialog"> <vbox style="font: menu">
<hbox><checkbox native="true" label="Regular"/></hbox> <hbox><checkbox native="true" label="Regular"/></hbox>
</vbox> </vbox>
<vbox style="font-size: 9px"> <vbox style="font-size: 9px">
@ -25,7 +25,7 @@ checkbox {
<vbox style="font: message-box"> <vbox style="font: message-box">
<hbox><checkbox native="true" label="Small" checked="true"/></hbox> <hbox><checkbox native="true" label="Small" checked="true"/></hbox>
</vbox> </vbox>
<vbox style="font: -moz-dialog"> <vbox style="font: menu">
<hbox><checkbox native="true" label="Regular" checked="true"/></hbox> <hbox><checkbox native="true" label="Regular" checked="true"/></hbox>
</vbox> </vbox>
</window> </window>

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

@ -16,7 +16,7 @@ radio {
<vbox style="font: message-box"> <vbox style="font: message-box">
<hbox><radio label="Small"/></hbox> <hbox><radio label="Small"/></hbox>
</vbox> </vbox>
<vbox style="font: -moz-dialog"> <vbox style="font: menu">
<hbox><radio label="Regular"/></hbox> <hbox><radio label="Regular"/></hbox>
</vbox> </vbox>
<vbox style="font-size: 9px"> <vbox style="font-size: 9px">
@ -25,7 +25,7 @@ radio {
<vbox style="font: message-box"> <vbox style="font: message-box">
<hbox><radio label="Small" selected="true"/></hbox> <hbox><radio label="Small" selected="true"/></hbox>
</vbox> </vbox>
<vbox style="font: -moz-dialog"> <vbox style="font: menu">
<hbox><radio label="Regular" selected="true"/></hbox> <hbox><radio label="Regular" selected="true"/></hbox>
</vbox> </vbox>
</window> </window>

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

@ -557,20 +557,6 @@ bool nsLookAndFeel::IsSystemOrientationRTL() {
bool nsLookAndFeel::NativeGetFont(FontID aID, nsString& aFontName, gfxFontStyle& aFontStyle) { bool nsLookAndFeel::NativeGetFont(FontID aID, nsString& aFontName, gfxFontStyle& aFontStyle) {
NS_OBJC_BEGIN_TRY_BLOCK_RETURN; NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
// hack for now
if (aID == FontID::MozWindow || aID == FontID::MozDocument) {
aFontStyle.style = mozilla::FontSlantStyle::NORMAL;
aFontStyle.weight = mozilla::FontWeight::NORMAL;
aFontStyle.stretch = mozilla::FontStretch::NORMAL;
aFontStyle.size = 14;
aFontStyle.systemFont = true;
aFontName.AssignLiteral("sans-serif");
return true;
}
// TODO: Add caching? Note that it needs to be thread-safe for stylo use.
nsAutoCString name; nsAutoCString name;
gfxPlatformMac::LookupSystemFont(aID, name, aFontStyle); gfxPlatformMac::LookupSystemFont(aID, name, aFontStyle);
aFontName.Append(NS_ConvertUTF8toUTF16(name)); aFontName.Append(NS_ConvertUTF8toUTF16(name));

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

@ -1090,12 +1090,6 @@ bool nsLookAndFeel::PerThemeData::GetFont(FontID aID, nsString& aFontName,
case FontID::MessageBox: // css2 case FontID::MessageBox: // css2
case FontID::SmallCaption: // css2 case FontID::SmallCaption: // css2
case FontID::StatusBar: // css2 case FontID::StatusBar: // css2
case FontID::MozWindow: // css3
case FontID::MozDocument: // css3
case FontID::MozWorkspace: // css3
case FontID::MozDesktop: // css3
case FontID::MozInfo: // css3
case FontID::MozDialog: // css3
default: default:
aFontName = mDefaultFontName; aFontName = mDefaultFontName;
aFontStyle = mDefaultFontStyle; aFontStyle = mDefaultFontStyle;

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

@ -744,7 +744,6 @@ LookAndFeelFont nsLookAndFeel::GetLookAndFeelFont(LookAndFeel::FontID anID) {
case LookAndFeel::FontID::StatusBar: case LookAndFeel::FontID::StatusBar:
result = GetLookAndFeelFontInternal(ncm.lfStatusFont, false); result = GetLookAndFeelFontInternal(ncm.lfStatusFont, false);
break; break;
case LookAndFeel::FontID::MozDialog:
case LookAndFeel::FontID::MozButton: case LookAndFeel::FontID::MozButton:
case LookAndFeel::FontID::MozField: case LookAndFeel::FontID::MozField:
case LookAndFeel::FontID::MozList: case LookAndFeel::FontID::MozList: