Commit 9a15523f authored by Fatih's avatar Fatih Committed by morgan
Browse files

Bug 1834307: Check RFPTarget::CSSPrefersReducedMotion in...

Bug 1834307: Check RFPTarget::CSSPrefersReducedMotion in nsLayoutUtils::IsSmoothScrollingEnabled. r=tjr

Differential Revision: https://phabricator.services.mozilla.com/D221364
parent a6a8e4e6
Loading
Loading
Loading
Loading
+12 −17
Original line number Diff line number Diff line
@@ -7765,16 +7765,6 @@ size_t nsLayoutUtils::SizeOfTextRunsForFrames(nsIFrame* aFrame,

/* static */
void nsLayoutUtils::RecomputeSmoothScrollDefault() {
  if (nsContentUtils::ShouldResistFingerprinting(
          "We use the global RFP pref to maintain consistent scroll behavior "
          "in the browser.",
          RFPTarget::CSSPrefersReducedMotion)) {
    // When resist fingerprinting is enabled, we should not default disable
    // smooth scrolls when the user prefers-reduced-motion to avoid leaking
    // the value of the OS pref to sites.
    Preferences::SetBool(StaticPrefs::GetPrefName_general_smoothScroll(), true,
                         PrefValueKind::Default);
  } else {
  // We want prefers-reduced-motion to determine the default
  // value of the general.smoothScroll pref. If the user
  // changed the pref we want to respect the change.
@@ -7783,10 +7773,15 @@ void nsLayoutUtils::RecomputeSmoothScrollDefault() {
      !LookAndFeel::GetInt(LookAndFeel::IntID::PrefersReducedMotion, 0),
      PrefValueKind::Default);
}
}

/* static */
bool nsLayoutUtils::IsSmoothScrollingEnabled() {
  if (nsContentUtils::ShouldResistFingerprinting(
          "We use the global RFP pref to maintain consistent scroll behavior "
          "in the browser.",
          RFPTarget::CSSPrefersReducedMotion)) {
    return true;
  }
  return StaticPrefs::general_smoothScroll();
}