Bug 1320801 part 5. Switch from ShouldResistFingerprinting to ResistFingerprinting (use the caller type, not the document principal) in nsGlobalWindow's devicePixelRatio getter. r=bkelly

This commit is contained in:
Boris Zbarsky 2016-12-22 11:05:54 -08:00
Родитель fe08a55fa4
Коммит d22d7aafa4
6 изменённых файлов: 20 добавлений и 19 удалений

Просмотреть файл

@ -18,6 +18,7 @@
#include "nsFocusManager.h"
#include "nsFrameManager.h"
#include "nsRefreshDriver.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/BlobBinding.h"
#include "mozilla/dom/Touch.h"
#include "mozilla/PendingAnimationTracker.h"
@ -1848,7 +1849,8 @@ nsDOMWindowUtils::GetScreenPixelsPerCSSPixel(float* aScreenPixels)
{
nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
return window->GetDevicePixelRatio(aScreenPixels);
*aScreenPixels = window->GetDevicePixelRatio(CallerType::System);
return NS_OK;
}
NS_IMETHODIMP

Просмотреть файл

@ -5572,7 +5572,7 @@ nsGlobalWindow::GetMozInnerScreenY(CallerType aCallerType, ErrorResult& aError)
}
float
nsGlobalWindow::GetDevicePixelRatioOuter()
nsGlobalWindow::GetDevicePixelRatioOuter(CallerType aCallerType)
{
MOZ_RELEASE_ASSERT(IsOuterWindow());
@ -5586,7 +5586,7 @@ nsGlobalWindow::GetDevicePixelRatioOuter()
return 1.0;
}
if (nsContentUtils::ShouldResistFingerprinting(mDocShell)) {
if (nsContentUtils::ResistFingerprinting(aCallerType)) {
return 1.0;
}
@ -5601,20 +5601,15 @@ nsGlobalWindow::GetDevicePixelRatioOuter()
}
float
nsGlobalWindow::GetDevicePixelRatio(ErrorResult& aError)
nsGlobalWindow::GetDevicePixelRatio(CallerType aCallerType, ErrorResult& aError)
{
FORWARD_TO_OUTER_OR_THROW(GetDevicePixelRatioOuter, (), aError, 0.0);
FORWARD_TO_OUTER_OR_THROW(GetDevicePixelRatioOuter, (aCallerType), aError, 0.0);
}
nsresult
nsGlobalWindow::GetDevicePixelRatio(float* aRatio)
float
nsPIDOMWindowOuter::GetDevicePixelRatio(CallerType aCallerType)
{
FORWARD_TO_INNER(GetDevicePixelRatio, (aRatio), NS_ERROR_UNEXPECTED);
ErrorResult rv;
*aRatio = GetDevicePixelRatio(rv);
return rv.StealNSResult();
return nsGlobalWindow::Cast(this)->GetDevicePixelRatioOuter(aCallerType);
}
uint64_t

Просмотреть файл

@ -1118,9 +1118,9 @@ public:
float GetMozInnerScreenYOuter(mozilla::dom::CallerType aCallerType);
float GetMozInnerScreenY(mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aError);
float GetDevicePixelRatioOuter();
float GetDevicePixelRatio(mozilla::ErrorResult& aError);
nsresult GetDevicePixelRatio(float* aRatio) override;
float GetDevicePixelRatioOuter(mozilla::dom::CallerType aCallerType);
float GetDevicePixelRatio(mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aError);
int32_t GetScrollMinX(mozilla::ErrorResult& aError);
int32_t GetScrollMinY(mozilla::ErrorResult& aError);
int32_t GetScrollMaxX(mozilla::ErrorResult& aError);

Просмотреть файл

@ -51,6 +51,7 @@ class ServiceWorkerRegistration;
class Timeout;
class TimeoutManager;
class CustomElementRegistry;
enum class CallerType : uint32_t;
} // namespace dom
} // namespace mozilla
@ -557,7 +558,6 @@ public:
nsISupports* aExtraArgument,
nsPIDOMWindowOuter** _retval) = 0;
virtual nsresult GetDevicePixelRatio(float* aRatio) = 0;
virtual nsresult GetInnerWidth(int32_t* aWidth) = 0;
virtual nsresult GetInnerHeight(int32_t* aHeight) = 0;
virtual already_AddRefed<nsICSSDeclaration>
@ -936,6 +936,8 @@ public:
void SetServiceWorkersTestingEnabled(bool aEnabled);
bool GetServiceWorkersTestingEnabled();
float GetDevicePixelRatio(mozilla::dom::CallerType aCallerType);
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMWindowOuter, NS_PIDOMWINDOWOUTER_IID)

Просмотреть файл

@ -8,6 +8,7 @@
#include "mozilla/gfx/2D.h"
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtrExtensions.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "nsGlobalWindow.h"
#include "nsIDOMClientRect.h"
#include "nsIDocShell.h"
@ -284,7 +285,7 @@ MediaEngineTabVideoSource::Draw() {
{
float pixelRatio;
if (mWindow) {
mWindow->GetDevicePixelRatio(&pixelRatio);
pixelRatio = mWindow->GetDevicePixelRatio(CallerType::System);
} else {
pixelRatio = 1.0f;
}

Просмотреть файл

@ -287,7 +287,8 @@ partial interface Window {
readonly attribute float mozInnerScreenX;
[Throws, NeedsCallerType]
readonly attribute float mozInnerScreenY;
[Replaceable, Throws] readonly attribute float devicePixelRatio;
[Replaceable, Throws, NeedsCallerType]
readonly attribute float devicePixelRatio;
/* The maximum offset that the window can be scrolled to
(i.e., the document width/height minus the scrollport width/height) */