Commit a4888732 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
Browse files

Bug 2059471: Do not spoof screen orientation when it is locked. r=tjr

parent 05919873
Loading
Loading
Loading
Loading
+10 −3
Changes for dom/base/ScreenOrientation.cpp: 10 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -700,8 +700,11 @@ OrientationType ScreenOrientation::DeviceType(CallerType aCallerType) const {
    if (!bc) {
      return nsRFPService::GetDefaultOrientationType();
    }
    if (bc->GetOrientationLock() == hal::ScreenOrientation::None) {
      CSSIntSize size = bc->TopInnerSizeSpoofedForRFP();
    return nsRFPService::ViewportSizeToOrientationType(size.width, size.height);
      return nsRFPService::ViewportSizeToOrientationType(size.width,
                                                         size.height);
    }
  }
  return mType;
}
@@ -714,9 +717,11 @@ uint16_t ScreenOrientation::DeviceAngle(CallerType aCallerType) const {
    if (!bc) {
      return 0;
    }
    if (bc->GetOrientationLock() == hal::ScreenOrientation::None) {
      CSSIntSize size = bc->TopInnerSizeSpoofedForRFP();
      return nsRFPService::ViewportSizeToAngle(size.width, size.height);
    }
  }
  return mAngle;
}

@@ -731,7 +736,8 @@ OrientationType ScreenOrientation::GetType(CallerType aCallerType,

  OrientationType orientation = bc->GetCurrentOrientationType();
  if (nsContentUtils::ShouldResistFingerprinting(
          aCallerType, GetRelevantGlobal(), RFPTarget::ScreenOrientation)) {
          aCallerType, GetRelevantGlobal(), RFPTarget::ScreenOrientation) &&
      bc->GetOrientationLock() == hal::ScreenOrientation::None) {
    CSSIntSize size = bc->TopInnerSizeSpoofedForRFP();
    return nsRFPService::ViewportSizeToOrientationType(size.width, size.height);
  }
@@ -749,7 +755,8 @@ uint16_t ScreenOrientation::GetAngle(CallerType aCallerType,

  uint16_t angle = static_cast<uint16_t>(bc->GetCurrentOrientationAngle());
  if (nsContentUtils::ShouldResistFingerprinting(
          aCallerType, GetRelevantGlobal(), RFPTarget::ScreenOrientation)) {
          aCallerType, GetRelevantGlobal(), RFPTarget::ScreenOrientation) &&
      bc->GetOrientationLock() == hal::ScreenOrientation::None) {
    CSSIntSize size = bc->TopInnerSizeSpoofedForRFP();
    return nsRFPService::ViewportSizeToAngle(size.width, size.height);
  }