Commits:
-
f34bff1e
by Pier Angelo Vendrame at 2024-05-30T11:44:22+00:00
fixup! Bug 40175: Add origin attributes to about:reader top-level requests
Revert "Bug 40175: Add origin attributes to about:reader top-level requests"
This reverts commit 2718a926fd331a0df2ad8cc90c6c9633f3630243.
-
7684ec07
by Pier Angelo Vendrame at 2024-05-30T11:44:22+00:00
fixup! Bug 41116: Normalize system fonts.
Revert "fixup! Bug 41116: Normalize system fonts."
This reverts commit 2c1a8f5261873f3c2435b9de1f83c07d5933748e.
-
aff5ec0f
by Pier Angelo Vendrame at 2024-05-30T11:44:22+00:00
fixup! Bug 41116: Normalize system fonts.
Revert "Bug 41116: Normalize system fonts."
This reverts commit df3f350e810ebe79c0823a124e6a555baf812f55.
-
6ebf41c3
by Pier Angelo Vendrame at 2024-05-30T11:44:23+00:00
Bug 1787790: Normalize system fonts with RFP on. r=emilio
System fonts can leak any user customization of system fonts, or user's
locale (e.g., en-US and ja Windows have different system fonts).
Also, Linux distributions/desktop environments set default fonts in
different ways.
Customization can be detected either with font metrics, the font allowed
list is not enabled or the font is included in it, or with
getComputedStyle, that leaks the name of the font that Firefox tries to
apply.
This patch try to prevent these leaks by using a generic "sans-serif"
for all system fonts, except on macOS, where it uses "-apple-system",
and on Android, where these fonts always use Roboto.
Differential Revision: https://phabricator.services.mozilla.com/D163576
-
1b026291
by cypherpunks1 at 2024-05-30T11:44:23+00:00
Bug 1892046 - Add origin attributes to about:reader requests. r=reader-mode-reviewers,cmkm
Differential Revision: https://phabricator.services.mozilla.com/D207759
5 changed files:
Changes:
gfx/thebes/gfxPlatformFontList.cpp
... |
... |
@@ -1973,19 +1973,17 @@ static void GetSystemUIFontFamilies(const nsPresContext* aPresContext, |
1973
|
1973
|
nsFont systemFont;
|
1974
|
1974
|
gfxFontStyle fontStyle;
|
1975
|
1975
|
nsAutoString systemFontName;
|
1976
|
|
- if (aPresContext && aPresContext->Document()
|
1977
|
|
- ? aPresContext->Document()->ShouldResistFingerprinting(
|
1978
|
|
- RFPTarget::Unknown)
|
1979
|
|
- : nsContentUtils::ShouldResistFingerprinting(
|
1980
|
|
- "aPresContext not available", RFPTarget::Unknown)) {
|
1981
|
|
-#ifdef XP_MACOSX
|
|
1976
|
+ if (aPresContext ? aPresContext->Document()->ShouldResistFingerprinting(
|
|
1977
|
+ RFPTarget::Unknown)
|
|
1978
|
+ : nsContentUtils::ShouldResistFingerprinting(
|
|
1979
|
+ "aPresContext not available", RFPTarget::Unknown)) {
|
|
1980
|
+#if defined(XP_MACOSX) || defined(MOZ_WIDGET_UIKIT)
|
1982
|
1981
|
*aFamilies.AppendElement() = "-apple-system"_ns;
|
1983
|
1982
|
return;
|
1984
|
1983
|
#elif !defined(MOZ_WIDGET_ANDROID)
|
1985
|
1984
|
*aFamilies.AppendElement() = "sans-serif"_ns;
|
1986
|
1985
|
return;
|
1987
|
1986
|
#endif
|
1988
|
|
- // Android uses already fixed fonts.
|
1989
|
1987
|
}
|
1990
|
1988
|
if (!LookAndFeel::GetFont(StyleSystemFont::Menu, systemFontName, fontStyle)) {
|
1991
|
1989
|
return;
|
layout/base/nsLayoutUtils.cpp
... |
... |
@@ -9680,7 +9680,7 @@ already_AddRefed<nsFontMetrics> nsLayoutUtils::GetMetricsFor( |
9680
|
9680
|
|
9681
|
9681
|
static void GetSpoofedSystemFontForRFP(LookAndFeel::FontID aFontID,
|
9682
|
9682
|
gfxFontStyle& aStyle, nsAString& aName) {
|
9683
|
|
-#if defined(XP_MACOSX)
|
|
9683
|
+#if defined(XP_MACOSX) || defined(MOZ_WIDGET_UIKIT)
|
9684
|
9684
|
aName = u"-apple-system"_ns;
|
9685
|
9685
|
// Values taken from a macOS 10.15 system.
|
9686
|
9686
|
switch (aFontID) {
|
... |
... |
@@ -9690,7 +9690,8 @@ static void GetSpoofedSystemFontForRFP(LookAndFeel::FontID aFontID, |
9690
|
9690
|
break;
|
9691
|
9691
|
case LookAndFeel::FontID::SmallCaption:
|
9692
|
9692
|
aStyle.weight = gfxFontStyle::FontWeight::BOLD;
|
9693
|
|
- // fall-through
|
|
9693
|
+ // fall-through for font-size
|
|
9694
|
+ [[fallthrough]];
|
9694
|
9695
|
case LookAndFeel::FontID::MessageBox:
|
9695
|
9696
|
case LookAndFeel::FontID::StatusBar:
|
9696
|
9697
|
aStyle.size = 11;
|
... |
... |
@@ -9704,14 +9705,13 @@ static void GetSpoofedSystemFontForRFP(LookAndFeel::FontID aFontID, |
9704
|
9705
|
// languages, so we fallback to sans-serif to fall back to the user's
|
9705
|
9706
|
// default sans-serif. Size is 12px for all system fonts (tried in an en-US
|
9706
|
9707
|
// system).
|
9707
|
|
- // Several Android systems reported Roboto 12px, so similar to what Windows
|
9708
|
|
- // does.
|
9709
|
9708
|
aName = u"sans-serif"_ns;
|
9710
|
9709
|
aStyle.size = 12;
|
9711
|
9710
|
#elif defined(MOZ_WIDGET_ANDROID)
|
|
9711
|
+ // Keep consistency with nsLookAndFeel::NativeGetFont.
|
9712
|
9712
|
aName = u"Roboto"_ns;
|
9713
|
9713
|
aStyle.size = 12;
|
9714
|
|
-#else
|
|
9714
|
+#elif defined(MOZ_WIDGET_GTK)
|
9715
|
9715
|
// On Linux, there is not a default. For example, GNOME on Debian uses
|
9716
|
9716
|
// Cantarell, 14.667px. Ubuntu Mate uses the Ubuntu font, but also 14.667px.
|
9717
|
9717
|
// Fedora with KDE uses Noto Sans, 13.3333px, but it uses Noto Sans on
|
... |
... |
@@ -9721,6 +9721,8 @@ static void GetSpoofedSystemFontForRFP(LookAndFeel::FontID aFontID, |
9721
|
9721
|
// UI font-size.
|
9722
|
9722
|
aName = u"sans-serif"_ns;
|
9723
|
9723
|
aStyle.size = 15;
|
|
9724
|
+#else
|
|
9725
|
+# error "Unknown platform"
|
9724
|
9726
|
#endif
|
9725
|
9727
|
}
|
9726
|
9728
|
|
layout/reftests/font-matching/reftest.list
... |
... |
@@ -195,3 +195,6 @@ pref(ui.font.menu,"serif") test-pref(ui.font.menu.weight,"800") != system-font-p |
195
|
195
|
|
196
|
196
|
# Reset default prefs.
|
197
|
197
|
defaults
|
|
198
|
+
|
|
199
|
+# Bug 1787790 - Normalize system fonts when using RFP
|
|
200
|
+test-pref(privacy.resistFingerprinting,true) == system-font-rfp.html system-font-rfp-ref.html |
layout/reftests/font-matching/system-font-rfp-ref.html
|
1
|
+<!DOCTYPE html>
|
|
2
|
+<meta charset="utf-8">
|
|
3
|
+<style>
|
|
4
|
+body {
|
|
5
|
+ font-family: -apple-system, sans-serif;
|
|
6
|
+ font-size: 12px;
|
|
7
|
+}
|
|
8
|
+
|
|
9
|
+.android {
|
|
10
|
+ font-family: Roboto;
|
|
11
|
+}
|
|
12
|
+
|
|
13
|
+.linux {
|
|
14
|
+ font-size: 15px;
|
|
15
|
+}
|
|
16
|
+
|
|
17
|
+.mac {
|
|
18
|
+ .caption, .menu {
|
|
19
|
+ font-size: 13px;
|
|
20
|
+ }
|
|
21
|
+ .message-box, .status-bar {
|
|
22
|
+ font-size: 11px;
|
|
23
|
+ }
|
|
24
|
+ .small-caption {
|
|
25
|
+ font-size: 11px;
|
|
26
|
+ font-weight: 700;
|
|
27
|
+ }
|
|
28
|
+}
|
|
29
|
+</style>
|
|
30
|
+<div class="caption">Caption</div>
|
|
31
|
+<div class="icon">Icon</div>
|
|
32
|
+<div class="menu">Menu</div>
|
|
33
|
+<div class="message-box">Message box</div>
|
|
34
|
+<div class="small-caption">Small caption</div>
|
|
35
|
+<div class="status-bar">Status bar</div>
|
|
36
|
+<script>
|
|
37
|
+if (navigator.platform.startsWith("Mac")) {
|
|
38
|
+ document.querySelector("body").className = "mac";
|
|
39
|
+} else if (navigator.userAgent.includes("Android")) {
|
|
40
|
+ document.querySelector("body").className = "android";
|
|
41
|
+} else if (navigator.platform.startsWith("Linux")) {
|
|
42
|
+ document.querySelector("body").className = "linux";
|
|
43
|
+}
|
|
44
|
+</script> |
layout/reftests/font-matching/system-font-rfp.html
|
1
|
+<!DOCTYPE html>
|
|
2
|
+<meta charset="utf-8">
|
|
3
|
+<div style="font: caption">Caption</div>
|
|
4
|
+<div style="font: icon">Icon</div>
|
|
5
|
+<div style="font: menu">Menu</div>
|
|
6
|
+<div style="font: message-box">Message box</div>
|
|
7
|
+<div style="font: small-caption">Small caption</div>
|
|
8
|
+<div style="font: status-bar">Status bar</div> |
|