Skip to content

Commit c03d19a

Browse files
committed
Add back basic css version support and native controls os faking
1 parent c0be168 commit c03d19a

File tree

7 files changed

+50
-5
lines changed

7 files changed

+50
-5
lines changed

browser/base/content/test/forms/browser_selectpopup_large.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,12 @@ async function performLargePopupTests(win) {
249249
// might return floating point values. We don't care about sub-pixel
250250
// accuracy, and only care about the final pixel value, so we add a
251251
// fuzz-factor of 1.
252-
const fuzzFactor = 1;
252+
//
253+
// FIXME(emilio): In win7 scroll position is off by 20px more, but that's
254+
// not reproducible in win10 even with the win7 "native" menus enabled.
255+
const fuzzFactor = matchMedia("(-moz-platform: windows-win7)").matches
256+
? 21
257+
: 1;
253258
SimpleTest.isfuzzy(
254259
selectPopup.children[selectedOption].getBoundingClientRect().bottom,
255260
selectPopup.getBoundingClientRect().bottom - bpBottom + marginBottom,

browser/base/content/test/static/browser_parsable_css.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,12 @@ let customPropsDefinitionFileMap = new Map();
309309
function neverMatches(mediaList) {
310310
const perPlatformMediaQueryMap = {
311311
macosx: ["(-moz-platform: macos)"],
312-
win: ["(-moz-platform: windows)"],
312+
win: [
313+
"(-moz-platform: windows)",
314+
"(-moz-platform: windows-win7)",
315+
"(-moz-platform: windows-win8)",
316+
"(-moz-platform: windows-win10)",
317+
],
313318
linux: ["(-moz-platform: linux)"],
314319
android: ["(-moz-platform: android)"],
315320
};

layout/style/nsMediaFeatures.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
# include "mozilla/WindowsVersion.h"
3434
#endif
3535

36+
// -- native controls patch includes --
37+
#include "mozilla/StaticPrefs_widget.h"
38+
// -- end native controls patch includes --
39+
3640
using namespace mozilla;
3741
using mozilla::dom::DisplayMode;
3842
using mozilla::dom::Document;
@@ -252,10 +256,24 @@ bool Gecko_MediaFeatures_MatchesPlatform(StylePlatform aPlatform) {
252256
#if defined(XP_WIN)
253257
case StylePlatform::Windows:
254258
return true;
255-
case StylePlatform::WindowsWinXP: {
256-
if (!IsVistaOrLater()) {
259+
case StylePlatform::WindowsWin10:
260+
case StylePlatform::WindowsWinXP:
261+
case StylePlatform::WindowsWin7:
262+
case StylePlatform::WindowsWin8: {
263+
int overridePref =
264+
StaticPrefs::widget_ev_native_controls_patch_override_win_version();
265+
bool doesOverride = overridePref > 0;
266+
267+
if ((!doesOverride && IsWin10OrLater()) || overridePref == 10) {
268+
return aPlatform == StylePlatform::WindowsWin10;
269+
}
270+
if ((!doesOverride && IsWin8OrLater()) || overridePref == 8) {
271+
return aPlatform == StylePlatform::WindowsWin8;
272+
}
273+
if ((!doesOverride && !IsVistaOrLater()) || overridePref == 5) {
257274
return aPlatform == StylePlatform::WindowsWinXP;
258275
}
276+
return aPlatform == StylePlatform::WindowsWin7;
259277
}
260278
#elif defined(ANDROID)
261279
case StylePlatform::Android:

layout/style/test/chrome/chrome-only-media-queries.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ const CHROME_ONLY_QUERIES = [
3434
"(-moz-platform: windows)",
3535
"(-moz-platform: macos)",
3636
"(-moz-platform: android)",
37+
"(-moz-platform: windows-win7)",
38+
"(-moz-platform: windows-win8)",
39+
"(-moz-platform: windows-win10)",
3740
"(-moz-content-prefers-color-scheme: dark)",
3841
"(-moz-content-prefers-color-scheme: light)",
3942
"(-moz-gtk-theme-family: unknown)",

modules/libpref/init/StaticPrefList.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17510,6 +17510,11 @@
1751017510
value: false
1751117511
mirror: always
1751217512

17513+
- name: widget.ev-native-controls-patch.override-win-version
17514+
type: int32_t
17515+
value: 0
17516+
mirror: always
17517+
1751317518
- name: widget.native-controls.force-dwm-report-off
1751417519
type: bool
1751517520
value: false

servo/components/style/gecko/media_features.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,12 @@ pub enum Platform {
561561
Windows,
562562
/// Matches only Windows XP.
563563
WindowsWinXP,
564+
/// Matches only Windows 7.
565+
WindowsWin7,
566+
/// Matches only Windows 8.
567+
WindowsWin8,
568+
/// Matches windows 10 and actually matches windows 11 too, as of right now.
569+
WindowsWin10,
564570
}
565571

566572
fn eval_moz_platform(_: &Context, query_value: Option<Platform>) -> bool {

xpcom/ds/StaticAtoms.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2262,8 +2262,11 @@
22622262
Atom("forcemessagemanager", "forcemessagemanager"),
22632263
Atom("initialBrowsingContextGroupId", "initialBrowsingContextGroupId"),
22642264
Atom("manualactiveness", "manualactiveness"),
2265-
# Windows XP media query name because I'm too r3tard to do it properly
2265+
# windows media query names
22662266
Atom("windows_winxp", "windows-winxp"),
2267+
Atom("windows_win7", "windows-win7"),
2268+
Atom("windows_win8", "windows-win8"),
2269+
Atom("windows_win10", "windows-win10"),
22672270
# Names for system metrics.
22682271
Atom("_moz_bool_pref", "-moz-bool-pref"),
22692272
Atom("_moz_scrollbar_start_backward", "-moz-scrollbar-start-backward"),

0 commit comments

Comments
 (0)