Bug 1434215: Simplify some ResistFingerprinting callers in nsMediaFeatures. r=xidorn

The docshell version just redirects to the document one, so no need to
ping-pong.

MozReview-Commit-ID: AggEoLubCIF
This commit is contained in:
Emilio Cobos Álvarez 2018-01-18 15:41:37 +01:00
parent 8ab35c14ad
commit 75e0e25aeb

View File

@ -137,12 +137,6 @@ GetHeight(nsIDocument* aDocument, const nsMediaFeature*,
aResult.SetFloatValue(CSSPixel::FromAppUnits(size.height), eCSSUnit_Pixel);
}
static bool
ShouldResistFingerprinting(nsIDocument* aDocument)
{
return nsContentUtils::ShouldResistFingerprinting(aDocument->GetDocShell());
}
static bool
IsDeviceSizePageSize(nsIDocument* aDocument)
{
@ -157,7 +151,8 @@ IsDeviceSizePageSize(nsIDocument* aDocument)
static nsSize
GetDeviceSize(nsIDocument* aDocument)
{
if (ShouldResistFingerprinting(aDocument) || IsDeviceSizePageSize(aDocument)) {
if (nsContentUtils::ShouldResistFingerprinting(aDocument) ||
IsDeviceSizePageSize(aDocument)) {
return GetSize(aDocument);
}
@ -274,7 +269,7 @@ GetColor(nsIDocument* aDocument, const nsMediaFeature*,
// rendered.
uint32_t depth = 24;
if (!ShouldResistFingerprinting(aDocument)) {
if (!nsContentUtils::ShouldResistFingerprinting(aDocument)) {
if (nsDeviceContext* dx = GetDeviceContextFor(aDocument)) {
// FIXME: On a monochrome device, return 0!
dx->GetDepth(depth);
@ -323,7 +318,7 @@ GetResolution(nsIDocument* aDocument, const nsMediaFeature*,
float dppx = 1.;
if (nsDeviceContext* dx = GetDeviceContextFor(aDocument)) {
if (ShouldResistFingerprinting(aDocument)) {
if (nsContentUtils::ShouldResistFingerprinting(aDocument)) {
dppx = dx->GetFullZoom();
} else {
// Get the actual device pixel ratio, which also takes zoom into account.
@ -397,7 +392,7 @@ static void
GetDevicePixelRatio(nsIDocument* aDocument, const nsMediaFeature*,
nsCSSValue& aResult)
{
if (ShouldResistFingerprinting(aDocument)) {
if (nsContentUtils::ShouldResistFingerprinting(aDocument)) {
aResult.SetFloatValue(1.0, eCSSUnit_Number);
return;
}
@ -454,7 +449,8 @@ GetSystemMetric(nsIDocument* aDocument, const nsMediaFeature* aFeature,
MOZ_ASSERT(!isAccessibleFromContentPages ||
*aFeature->mName == nsGkAtoms::_moz_touch_enabled);
if (isAccessibleFromContentPages && ShouldResistFingerprinting(aDocument)) {
if (isAccessibleFromContentPages &&
nsContentUtils::ShouldResistFingerprinting(aDocument)) {
// If "privacy.resistFingerprinting" is enabled, then we simply don't
// return any system-backed media feature values. (No spoofed values
// returned.)
@ -476,7 +472,7 @@ GetWindowsTheme(nsIDocument* aDocument, const nsMediaFeature* aFeature,
aResult.Reset();
MOZ_ASSERT(aFeature->mReqFlags & nsMediaFeature::eUserAgentAndChromeOnly);
if (ShouldResistFingerprinting(aDocument)) {
if (nsContentUtils::ShouldResistFingerprinting(aDocument)) {
return;
}
@ -505,7 +501,7 @@ GetOperatingSystemVersion(nsIDocument* aDocument, const nsMediaFeature* aFeature
aResult.Reset();
MOZ_ASSERT(aFeature->mReqFlags & nsMediaFeature::eUserAgentAndChromeOnly);
if (ShouldResistFingerprinting(aDocument)) {
if (nsContentUtils::ShouldResistFingerprinting(aDocument)) {
return;
}