Loading dom/base/ScreenOrientation.cpp +27 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ #include "mozilla/Preferences.h" #include "mozilla/dom/Promise.h" #include "nsContentUtils.h" using namespace mozilla; using namespace mozilla::dom; Loading Loading @@ -403,18 +404,23 @@ ScreenOrientation::UnlockDeviceOrientation() OrientationType ScreenOrientation::DeviceType() const { return mType; return ShouldResistFingerprinting() ? OrientationType::Landscape_primary : mType; } uint16_t ScreenOrientation::DeviceAngle() const { return mAngle; return ShouldResistFingerprinting() ? 0 : mAngle; } OrientationType ScreenOrientation::GetType(ErrorResult& aRv) const { if (ShouldResistFingerprinting()) { return OrientationType::Landscape_primary; } nsIDocument* doc = GetResponsibleDocument(); if (!doc) { aRv.Throw(NS_ERROR_UNEXPECTED); Loading @@ -427,6 +433,10 @@ ScreenOrientation::GetType(ErrorResult& aRv) const uint16_t ScreenOrientation::GetAngle(ErrorResult& aRv) const { if (ShouldResistFingerprinting()) { return 0; } nsIDocument* doc = GetResponsibleDocument(); if (!doc) { aRv.Throw(NS_ERROR_UNEXPECTED); Loading Loading @@ -489,6 +499,10 @@ ScreenOrientation::GetResponsibleDocument() const void ScreenOrientation::Notify(const hal::ScreenConfiguration& aConfiguration) { if (ShouldResistFingerprinting()) { return; } nsIDocument* doc = GetResponsibleDocument(); if (!doc) { return; Loading Loading @@ -564,6 +578,17 @@ ScreenOrientation::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) return ScreenOrientationBinding::Wrap(aCx, this, aGivenProto); } bool ScreenOrientation::ShouldResistFingerprinting() const { bool resist = false; nsCOMPtr<nsPIDOMWindow> owner = GetOwner(); if (owner) { resist = nsContentUtils::ShouldResistFingerprinting(owner->GetDocShell()); } return resist; } NS_IMPL_ISUPPORTS(ScreenOrientation::VisibleEventListener, nsIDOMEventListener) NS_IMETHODIMP Loading dom/base/ScreenOrientation.h +2 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,8 @@ private: void DispatchChangeEvent(); bool ShouldResistFingerprinting() const; LockPermission GetLockOrientationPermission(bool aCheckSandbox) const; // Gets the responsible document as defined in the spec. Loading dom/base/nsGlobalWindow.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -12821,8 +12821,8 @@ void nsGlobalWindow::EnableOrientationChangeListener() { MOZ_ASSERT(IsInnerWindow()); if (!mOrientationChangeObserver) { if (!nsContentUtils::ShouldResistFingerprinting(mDocShell) && !mOrientationChangeObserver) { mOrientationChangeObserver = new WindowOrientationObserver(this); } Loading Loading @@ -13672,7 +13672,8 @@ nsGlobalWindow::IsModalContentWindow(JSContext* aCx, JSObject* aGlobal) int16_t nsGlobalWindow::Orientation() const { return WindowOrientationObserver::OrientationAngle(); return nsContentUtils::ShouldResistFingerprinting(mDocShell) ? 0 : WindowOrientationObserver::OrientationAngle(); } #endif Loading dom/base/nsScreen.cpp +20 −18 Original line number Diff line number Diff line Loading @@ -166,9 +166,6 @@ nsScreen::Orientation() const void nsScreen::GetMozOrientation(nsString& aOrientation) const { if (ShouldResistFingerprinting()) { aOrientation.AssignLiteral("landscape-primary"); } else { switch (mScreenOrientation->DeviceType()) { case OrientationType::Portrait_primary: aOrientation.AssignLiteral("portrait-primary"); Loading @@ -186,7 +183,6 @@ nsScreen::GetMozOrientation(nsString& aOrientation) const MOZ_CRASH("Unacceptable screen orientation type."); } } } NS_IMETHODIMP nsScreen::GetSlowMozOrientation(nsAString& aOrientation) Loading Loading @@ -236,6 +232,9 @@ bool nsScreen::MozLockOrientation(const Sequence<nsString>& aOrientations, ErrorResult& aRv) { if (ShouldResistFingerprinting()) { return false; } ScreenOrientationInternal orientation = eScreenOrientation_None; for (uint32_t i = 0; i < aOrientations.Length(); ++i) { Loading Loading @@ -283,6 +282,9 @@ nsScreen::MozLockOrientation(const Sequence<nsString>& aOrientations, void nsScreen::MozUnlockOrientation() { if (ShouldResistFingerprinting()) { return; } UpdateDocShellOrientationLock(GetOwner(), eScreenOrientation_None); mScreenOrientation->UnlockDeviceOrientation(); } Loading Loading
dom/base/ScreenOrientation.cpp +27 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ #include "mozilla/Preferences.h" #include "mozilla/dom/Promise.h" #include "nsContentUtils.h" using namespace mozilla; using namespace mozilla::dom; Loading Loading @@ -403,18 +404,23 @@ ScreenOrientation::UnlockDeviceOrientation() OrientationType ScreenOrientation::DeviceType() const { return mType; return ShouldResistFingerprinting() ? OrientationType::Landscape_primary : mType; } uint16_t ScreenOrientation::DeviceAngle() const { return mAngle; return ShouldResistFingerprinting() ? 0 : mAngle; } OrientationType ScreenOrientation::GetType(ErrorResult& aRv) const { if (ShouldResistFingerprinting()) { return OrientationType::Landscape_primary; } nsIDocument* doc = GetResponsibleDocument(); if (!doc) { aRv.Throw(NS_ERROR_UNEXPECTED); Loading @@ -427,6 +433,10 @@ ScreenOrientation::GetType(ErrorResult& aRv) const uint16_t ScreenOrientation::GetAngle(ErrorResult& aRv) const { if (ShouldResistFingerprinting()) { return 0; } nsIDocument* doc = GetResponsibleDocument(); if (!doc) { aRv.Throw(NS_ERROR_UNEXPECTED); Loading Loading @@ -489,6 +499,10 @@ ScreenOrientation::GetResponsibleDocument() const void ScreenOrientation::Notify(const hal::ScreenConfiguration& aConfiguration) { if (ShouldResistFingerprinting()) { return; } nsIDocument* doc = GetResponsibleDocument(); if (!doc) { return; Loading Loading @@ -564,6 +578,17 @@ ScreenOrientation::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) return ScreenOrientationBinding::Wrap(aCx, this, aGivenProto); } bool ScreenOrientation::ShouldResistFingerprinting() const { bool resist = false; nsCOMPtr<nsPIDOMWindow> owner = GetOwner(); if (owner) { resist = nsContentUtils::ShouldResistFingerprinting(owner->GetDocShell()); } return resist; } NS_IMPL_ISUPPORTS(ScreenOrientation::VisibleEventListener, nsIDOMEventListener) NS_IMETHODIMP Loading
dom/base/ScreenOrientation.h +2 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,8 @@ private: void DispatchChangeEvent(); bool ShouldResistFingerprinting() const; LockPermission GetLockOrientationPermission(bool aCheckSandbox) const; // Gets the responsible document as defined in the spec. Loading
dom/base/nsGlobalWindow.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -12821,8 +12821,8 @@ void nsGlobalWindow::EnableOrientationChangeListener() { MOZ_ASSERT(IsInnerWindow()); if (!mOrientationChangeObserver) { if (!nsContentUtils::ShouldResistFingerprinting(mDocShell) && !mOrientationChangeObserver) { mOrientationChangeObserver = new WindowOrientationObserver(this); } Loading Loading @@ -13672,7 +13672,8 @@ nsGlobalWindow::IsModalContentWindow(JSContext* aCx, JSObject* aGlobal) int16_t nsGlobalWindow::Orientation() const { return WindowOrientationObserver::OrientationAngle(); return nsContentUtils::ShouldResistFingerprinting(mDocShell) ? 0 : WindowOrientationObserver::OrientationAngle(); } #endif Loading
dom/base/nsScreen.cpp +20 −18 Original line number Diff line number Diff line Loading @@ -166,9 +166,6 @@ nsScreen::Orientation() const void nsScreen::GetMozOrientation(nsString& aOrientation) const { if (ShouldResistFingerprinting()) { aOrientation.AssignLiteral("landscape-primary"); } else { switch (mScreenOrientation->DeviceType()) { case OrientationType::Portrait_primary: aOrientation.AssignLiteral("portrait-primary"); Loading @@ -186,7 +183,6 @@ nsScreen::GetMozOrientation(nsString& aOrientation) const MOZ_CRASH("Unacceptable screen orientation type."); } } } NS_IMETHODIMP nsScreen::GetSlowMozOrientation(nsAString& aOrientation) Loading Loading @@ -236,6 +232,9 @@ bool nsScreen::MozLockOrientation(const Sequence<nsString>& aOrientations, ErrorResult& aRv) { if (ShouldResistFingerprinting()) { return false; } ScreenOrientationInternal orientation = eScreenOrientation_None; for (uint32_t i = 0; i < aOrientations.Length(); ++i) { Loading Loading @@ -283,6 +282,9 @@ nsScreen::MozLockOrientation(const Sequence<nsString>& aOrientations, void nsScreen::MozUnlockOrientation() { if (ShouldResistFingerprinting()) { return; } UpdateDocShellOrientationLock(GetOwner(), eScreenOrientation_None); mScreenOrientation->UnlockDeviceOrientation(); } Loading