Files
lbmk/config/firefox/default/patches/0014-fpp-canvas-fix.patch.patch
T
Leah Rowe 2b34aeea5d WIP: convert to lwmk
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-08 06:44:40 +01:00

106 lines
5.4 KiB
Diff

From 09f40f3935428b5046ea866e09dfbf739684ce6f Mon Sep 17 00:00:00 2001
From: LibreWolf Developers <noreply@librewolf.net>
Date: Sun, 6 Sep 2026 10:09:59 +0100
Subject: [PATCH 14/52] fpp-canvas-fix.patch
---
dom/canvas/CanvasRenderingContext2D.cpp | 11 ++++++++---
dom/canvas/ClientWebGLContext.cpp | 10 +++++++---
.../components/resistfingerprinting/nsRFPService.cpp | 2 ++
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp
index 596eb44f3992..2018528600f7 100644
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -2288,7 +2288,9 @@ UniquePtr<uint8_t[]> CanvasRenderingContext2D::GetImageBuffer(
PrincipalOrNull(), ret.get(), out_imageSize->width,
out_imageSize->height,
out_imageSize->width * out_imageSize->height * 4);
- if (aExtractionBehavior == CanvasUtils::ImageExtraction::Randomize) {
+ if (aExtractionBehavior == CanvasUtils::ImageExtraction::Randomize ||
+ aExtractionBehavior ==
+ CanvasUtils::ImageExtraction::EfficientRandomize) {
nsRFPService::RandomizePixels(
GetCookieJarSettings(), PrincipalOrNull(), ret.get(),
out_imageSize->width, out_imageSize->height,
@@ -6682,7 +6684,8 @@ nsresult CanvasRenderingContext2D::GetImageDataArray(
//
// Note that we don't need to clone if we will use the place holder because
// the place holder doesn't use actual image data.
- if (extractionBehavior == CanvasUtils::ImageExtraction::Randomize) {
+ if (extractionBehavior == CanvasUtils::ImageExtraction::Randomize ||
+ extractionBehavior == CanvasUtils::ImageExtraction::EfficientRandomize) {
if (readback) {
readback = CreateDataSourceSurfaceByCloning(readback);
}
@@ -6704,7 +6707,9 @@ nsresult CanvasRenderingContext2D::GetImageDataArray(
// service) after we call JS_GetUint8ClampedArrayData, we will
// pre-generate the randomness required for GeneratePlaceholderCanvasData.
randomData = TryToGenerateRandomDataForPlaceholderCanvasData();
- } else if (extractionBehavior == CanvasUtils::ImageExtraction::Randomize) {
+ } else if (extractionBehavior == CanvasUtils::ImageExtraction::Randomize ||
+ extractionBehavior ==
+ CanvasUtils::ImageExtraction::EfficientRandomize) {
// Apply the random noises if canvan randomization is enabled. We don't
// need to calculate random noises if we are going to use the place
// holder.
diff --git a/dom/canvas/ClientWebGLContext.cpp b/dom/canvas/ClientWebGLContext.cpp
index f56f1107070e..afed0c39f23a 100644
--- a/dom/canvas/ClientWebGLContext.cpp
+++ b/dom/canvas/ClientWebGLContext.cpp
@@ -1367,7 +1367,8 @@ UniquePtr<uint8_t[]> ClientWebGLContext::GetImageBuffer(
*out_imageSize = dataSurface->GetSize();
nsRFPService::PotentiallyDumpImage(PrincipalOrNull(), dataSurface);
- if (aExtractionBehavior == CanvasUtils::ImageExtraction::Randomize) {
+ if (aExtractionBehavior == CanvasUtils::ImageExtraction::Randomize ||
+ aExtractionBehavior == CanvasUtils::ImageExtraction::EfficientRandomize) {
return gfxUtils::GetImageBufferWithRandomNoise(
dataSurface, premultAlpha, GetCookieJarSettings(), PrincipalOrNull(),
out_format);
@@ -3680,7 +3681,9 @@ void ClientWebGLContext::GetBufferSubData(GLenum target, GLintptr srcByteOffset,
if (extraction == CanvasUtils::ImageExtraction::Placeholder) {
dom::GeneratePlaceholderCanvasData(destView->size_bytes(),
destView->Elements());
- } else if (extraction == CanvasUtils::ImageExtraction::Randomize) {
+ } else if (extraction == CanvasUtils::ImageExtraction::Randomize ||
+ extraction ==
+ CanvasUtils::ImageExtraction::EfficientRandomize) {
// We have no idea what's in the buffer. So, we randomize it as if each
// elemSize bytes is a single element.
uint8_t elementsPerGroup = 1,
@@ -5455,7 +5458,8 @@ void ClientWebGLContext::ReadPixels(GLint x, GLint y, GLsizei width,
} else {
RecordCanvasUsage(CanvasExtractionAPI::ReadPixels,
CSSIntSize(width, height));
- if (extraction == CanvasUtils::ImageExtraction::Randomize) {
+ if (extraction == CanvasUtils::ImageExtraction::Randomize ||
+ extraction == CanvasUtils::ImageExtraction::EfficientRandomize) {
const auto pii = webgl::PackingInfoInfo::For(desc.pi);
// DoReadPixels() requres pii to be Some().
MOZ_ASSERT(pii.isSome());
diff --git a/toolkit/components/resistfingerprinting/nsRFPService.cpp b/toolkit/components/resistfingerprinting/nsRFPService.cpp
index ea47718beff8..ccc9f21c9bf2 100644
--- a/toolkit/components/resistfingerprinting/nsRFPService.cpp
+++ b/toolkit/components/resistfingerprinting/nsRFPService.cpp
@@ -1890,6 +1890,7 @@ nsresult nsRFPService::RandomizeElements(
return NS_OK;
}
+ /*
// Don't randomize if all groups are uniform.
const bool allGroupsMatch = [&]() {
auto itr = RangedPtr<const uint8_t>(aData, aSizeInBytes);
@@ -1904,6 +1905,7 @@ nsresult nsRFPService::RandomizeElements(
if (allGroupsMatch) {
return NS_OK;
}
+ */
auto timerId =
glean::fingerprinting_protection::canvas_noise_calculate_time_2.Start();
--
2.47.3