Skip to content

Commit c75baab

Browse files
committedMar 4, 2025·
Workaround to restore custom match media without disabling HiDPI
1 parent aeae79f commit c75baab

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed
 

‎patches/screen-hijacker.patch

+22-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ index a2b3e60fe5..faa0c113bc 100644
2828
+LOCAL_INCLUDES += ["/camoucfg"]
2929
\ No newline at end of file
3030
diff --git a/gfx/src/nsDeviceContext.cpp b/gfx/src/nsDeviceContext.cpp
31-
index 7a4fa8d48f..1f560937a3 100644
31+
index 7a4fa8d48f..408b754d92 100644
3232
--- a/gfx/src/nsDeviceContext.cpp
3333
+++ b/gfx/src/nsDeviceContext.cpp
3434
@@ -5,6 +5,7 @@
@@ -39,19 +39,36 @@ index 7a4fa8d48f..1f560937a3 100644
3939
#include <algorithm> // for max
4040
#include "gfxContext.h"
4141
#include "gfxPoint.h" // for gfxSize
42-
@@ -177,6 +178,15 @@ bool nsDeviceContext::GetScreenIsHDR() {
42+
@@ -177,6 +178,13 @@ bool nsDeviceContext::GetScreenIsHDR() {
4343
}
4444

4545
nsSize nsDeviceContext::GetDeviceSurfaceDimensions() {
4646
+ // Check for height and width overrides from MaskConfig
4747
+ if (auto height = MaskConfig::GetInt32("screen.height"),
4848
+ width = MaskConfig::GetInt32("screen.width");
4949
+ height && width) {
50-
+ nsRect outRect = LayoutDeviceIntRect::ToAppUnits(
51-
+ LayoutDeviceIntRect(0, 0, width.value(), height.value()),
52-
+ AppUnitsPerDevPixel());
50+
+ nsRect outRect = CSSPixel::ToAppUnits(CSSIntRect(0, 0, width.value(), height.value()));
5351
+ return outRect.Size();
5452
+ }
5553
return GetRect().Size();
5654
}
5755

56+
diff --git a/layout/style/nsMediaFeatures.cpp b/layout/style/nsMediaFeatures.cpp
57+
index f83e2c21ca..5362dd77d4 100644
58+
--- a/layout/style/nsMediaFeatures.cpp
59+
+++ b/layout/style/nsMediaFeatures.cpp
60+
@@ -66,14 +66,6 @@ static nsSize GetDeviceSize(const Document& aDocument) {
61+
return GetSize(aDocument);
62+
}
63+
64+
- // Media queries in documents in an RDM pane should use the simulated
65+
- // device size.
66+
- Maybe<CSSIntSize> deviceSize =
67+
- nsGlobalWindowOuter::GetRDMDeviceSize(aDocument);
68+
- if (deviceSize.isSome()) {
69+
- return CSSPixel::ToAppUnits(deviceSize.value());
70+
- }
71+
-
72+
nsPresContext* pc = aDocument.GetPresContext();
73+
// NOTE(emilio): We should probably figure out how to return an appropriate
74+
// device size here, though in a multi-screen world that makes no sense

‎settings/camoufox.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ defaultPref(
3838
"https://raw.githubusercontent.com/daijro/camoufox/refs/heads/main/assets/uBOAssets.json"
3939
);
4040

41-
// Disable hidpi by default
42-
defaultPref("layout.css.devPixelsPerPx", "1");
43-
4441
// Tweaks that undo Playwright:
4542

4643
// Enable content isolation (WAFs can detect this!)

0 commit comments

Comments
 (0)
Please sign in to comment.