From c9a0f65ceb1f22805a8570a15a19a948e7ec56c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 1 Dec 2022 09:23:19 +0000 Subject: [PATCH] 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 --- .../shared/css/generated/properties-db.js | 6 ---- gfx/thebes/gfxMacPlatformFontList.mm | 4 --- .../test/test_unstyled_control_height.html | 6 ++-- layout/style/crashtests/1382672.html | 2 +- layout/style/test/property_database.js | 11 ------- .../test_non_content_accessible_values.html | 6 ++++ layout/style/test/test_value_storage.html | 32 ++++++++----------- .../style/properties/shorthands/font.mako.rs | 2 +- .../components/style/values/specified/font.rs | 22 +++++++++---- .../themes/osx/reftests/checkboxsize.xhtml | 4 +-- toolkit/themes/osx/reftests/radiosize.xhtml | 4 +-- widget/cocoa/nsLookAndFeel.mm | 14 -------- widget/gtk/nsLookAndFeel.cpp | 6 ---- widget/windows/nsLookAndFeel.cpp | 1 - 14 files changed, 43 insertions(+), 77 deletions(-) diff --git a/devtools/shared/css/generated/properties-db.js b/devtools/shared/css/generated/properties-db.js index 8227254aae92..957ef7944b13 100644 --- a/devtools/shared/css/generated/properties-db.js +++ b/devtools/shared/css/generated/properties-db.js @@ -6756,15 +6756,9 @@ exports.CSS_PROPERTIES = { "supports": [], "values": [ "-moz-button", - "-moz-desktop", - "-moz-dialog", - "-moz-document", "-moz-field", - "-moz-info", "-moz-list", "-moz-pull-down-menu", - "-moz-window", - "-moz-workspace", "all-petite-caps", "all-small-caps", "bold", diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index 9284a96fe603..5fa1b977dcbb 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -1866,9 +1866,6 @@ void gfxMacPlatformFontList::LookupSystemFont(LookAndFeel::FontID aSystemFontID, break; 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]; systemFontName = (char*)kSystemFont_system; break; @@ -1880,7 +1877,6 @@ void gfxMacPlatformFontList::LookupSystemFont(LookAndFeel::FontID aSystemFontID, case LookAndFeel::FontID::Caption: case LookAndFeel::FontID::Menu: - case LookAndFeel::FontID::MozDialog: default: font = [NSFont systemFontOfSize:0.0]; systemFontName = (char*)kSystemFont_system; diff --git a/layout/forms/test/test_unstyled_control_height.html b/layout/forms/test/test_unstyled_control_height.html index 9b0b33763ce6..ad5cd125d25f 100644 --- a/layout/forms/test/test_unstyled_control_height.html +++ b/layout/forms/test/test_unstyled_control_height.html @@ -10,9 +10,9 @@ /* Reduce the width so that container can fit all its children in 600px viewport width. */ width: 100px; } - input[type=date] { - /* date by default uses a monospace font, which might have different metrics */ - font: -moz-field; + /* date by default uses a monospace font, which might have different metrics */ + input, button, select { + font: Menu; } .small-font * { font-size: 8px !important; /* important to override rule above */ diff --git a/layout/style/crashtests/1382672.html b/layout/style/crashtests/1382672.html index 9e8eea5baec6..86526e840eb8 100644 --- a/layout/style/crashtests/1382672.html +++ b/layout/style/crashtests/1382672.html @@ -4,7 +4,7 @@ diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index e27fc0b9dd88..db30f627cf1e 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -5544,17 +5544,6 @@ var gCSSProperties = { "message-box", "small-caption", "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() "condensed bold italic small-caps 24px/calc(2px) Times New Roman, serif", "condensed bold italic small-caps 24px/calc(50%) Times New Roman, serif", diff --git a/layout/style/test/test_non_content_accessible_values.html b/layout/style/test/test_non_content_accessible_values.html index 2e0786fc3f71..7ba1cf9f05e1 100644 --- a/layout/style/test/test_non_content_accessible_values.html +++ b/layout/style/test/test_non_content_accessible_values.html @@ -22,6 +22,12 @@ const NON_CONTENT_ACCESSIBLE_VALUES = { "-moz-box", "-moz-inline-box", ], + "font": [ + "-moz-pull-down-menu", + "-moz-button", + "-moz-list", + "-moz-field", + ], "-moz-appearance": [ "button-arrow-down", "button-arrow-next", diff --git a/layout/style/test/test_value_storage.html b/layout/style/test/test_value_storage.html index b1d483d92b74..542cad91ed42 100644 --- a/layout/style/test/test_value_storage.html +++ b/layout/style/test/test_value_storage.html @@ -48,24 +48,18 @@ * cserialize. */ -var gSystemFont = { - "caption": true, - "icon": true, - "menu": true, - "message-box": true, - "small-caption": true, - "status-bar": true, - "-moz-window": true, - "-moz-document": true, - "-moz-desktop": true, - "-moz-info": true, - "-moz-dialog": true, - "-moz-button": true, - "-moz-pull-down-menu": true, - "-moz-list": true, - "-moz-field": true, - "-moz-workspace": true, -}; +var gSystemFont = [ + "caption", + "icon", + "menu", + "message-box", + "small-caption", + "status-bar", + "-moz-button", + "-moz-pull-down-menu", + "-moz-list", + "-moz-field", +]; var gBadCompute = { // output wrapped around to positive, in exponential notation @@ -154,7 +148,7 @@ function test_property(property) function test_value(value, resolved_value) { 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 = ": "; gDeclaration.setProperty(property, value, ""); diff --git a/servo/components/style/properties/shorthands/font.mako.rs b/servo/components/style/properties/shorthands/font.mako.rs index 4faa1b98076e..d373204220ed 100644 --- a/servo/components/style/properties/shorthands/font.mako.rs +++ b/servo/components/style/properties/shorthands/font.mako.rs @@ -69,7 +69,7 @@ let mut stretch = None; let size; % 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! { % for name in SYSTEM_FONT_LONGHANDS: ${name}: ${name}::SpecifiedValue::system_font(sys), diff --git a/servo/components/style/values/specified/font.rs b/servo/components/style/values/specified/font.rs index 1a37f26c250c..cd61737bf085 100644 --- a/servo/components/style/values/specified/font.rs +++ b/servo/components/style/values/specified/font.rs @@ -70,21 +70,29 @@ macro_rules! system_font_methods { )] #[allow(missing_docs)] pub enum SystemFont { + /// https://drafts.csswg.org/css-fonts/#valdef-font-caption Caption, + /// https://drafts.csswg.org/css-fonts/#valdef-font-icon Icon, + /// https://drafts.csswg.org/css-fonts/#valdef-font-menu Menu, + /// https://drafts.csswg.org/css-fonts/#valdef-font-message-box MessageBox, + /// https://drafts.csswg.org/css-fonts/#valdef-font-small-caption SmallCaption, + /// https://drafts.csswg.org/css-fonts/#valdef-font-status-bar StatusBar, - MozWindow, - MozDocument, - MozWorkspace, - MozDesktop, - MozInfo, - MozDialog, - MozButton, + /// Internal system font, used by the ``s on macOS. + #[parse(condition = "ParserContext::in_ua_or_chrome_sheet")] MozPullDownMenu, + /// Internal system font, used for `