[tbb-commits] [Git][tpo/applications/tor-browser][base-browser-128.2.0esr-14.0-1] 4 commits: Bug 1834307: Change StaticPrefs::general_smoothScroll() calls with...

morgan (@morgan) git at gitlab.torproject.org
Mon Sep 23 18:30:37 UTC 2024



morgan pushed to branch base-browser-128.2.0esr-14.0-1 at The Tor Project / Applications / Tor Browser


Commits:
48f96fa9 by Fatih at 2024-09-23T18:30:04+00:00
Bug 1834307: Change StaticPrefs::general_smoothScroll() calls with nsLayoutUtils::IsSmoothScrollingEnabled. r=tjr

Differential Revision: https://phabricator.services.mozilla.com/D221363
- - - - -
1ecf44c0 by Fatih at 2024-09-23T18:30:05+00:00
Bug 1834307: Check RFPTarget::CSSPrefersReducedMotion in nsLayoutUtils::IsSmoothScrollingEnabled. r=tjr

Differential Revision: https://phabricator.services.mozilla.com/D221364
- - - - -
708222bf by Morgan at 2024-09-23T18:30:05+00:00
Bug 42070: Hide "Use smooth scrolling" from settings

- - - - -
f93056fe by Morgan at 2024-09-23T18:30:05+00:00
fixup! Bug 42027: Base Browser migration procedures.

Bug 42078: Hide Smoothscroll UX

- - - - -


9 changed files:

- browser/components/BrowserGlue.sys.mjs
- browser/components/preferences/main.inc.xhtml
- gfx/layers/apz/src/APZInputBridge.cpp
- gfx/layers/apz/src/APZPublicUtils.cpp
- gfx/layers/apz/src/GenericScrollAnimation.cpp
- gfx/layers/apz/src/WheelScrollAnimation.cpp
- layout/base/nsLayoutUtils.cpp
- layout/xul/nsSliderFrame.cpp
- widget/cocoa/nsChildView.mm


Changes:

=====================================
browser/components/BrowserGlue.sys.mjs
=====================================
@@ -4668,7 +4668,8 @@ BrowserGlue.prototype = {
     //            the security level anymore (tor-browser#42149).
     //            Also, reset security.xfocsp.errorReporting.automatic since we
     //            hid its neterror checkbox. tor-browser#42653.
-    const MIGRATION_VERSION = 2;
+    // Version 3: 14.0a7: Reset general.smoothScroll. tor-browser#42070.
+    const MIGRATION_VERSION = 3;
     const MIGRATION_PREF = "basebrowser.migration.version";
     // We do not care whether this is a new or old profile, since in version 1
     // we just quickly clear a user preference, which should not do anything to
@@ -4696,6 +4697,11 @@ BrowserGlue.prototype = {
         Services.prefs.clearUserPref(prefName);
       }
     }
+    if (currentVersion < 3) {
+      Services.prefs.clearUserPref(
+        "general.smoothScroll"
+      );
+    }
     Services.prefs.setIntPref(MIGRATION_PREF, MIGRATION_VERSION);
   },
 


=====================================
browser/components/preferences/main.inc.xhtml
=====================================
@@ -731,7 +731,8 @@
             preference="general.autoScroll"/>
   <checkbox id="useSmoothScrolling"
             data-l10n-id="browsing-use-smooth-scrolling"
-            preference="general.smoothScroll"/>
+            preference="general.smoothScroll"
+            hidden="true"/>
 #ifdef MOZ_WIDGET_GTK
   <checkbox id="useOverlayScrollbars"
             data-l10n-id="browsing-gtk-use-non-overlay-scrollbars"


=====================================
gfx/layers/apz/src/APZInputBridge.cpp
=====================================
@@ -10,6 +10,7 @@
 #include "InputData.h"               // for MouseInput, etc
 #include "InputBlockState.h"         // for InputBlockState
 #include "OverscrollHandoffState.h"  // for OverscrollHandoffState
+#include "nsLayoutUtils.h"           // for IsSmoothScrollingEnabled
 #include "mozilla/EventForwards.h"
 #include "mozilla/dom/WheelEventBinding.h"  // for WheelEvent constants
 #include "mozilla/EventStateManager.h"      // for EventStateManager
@@ -270,7 +271,7 @@ APZEventResult APZInputBridge::ReceiveInputEvent(
       if (Maybe<APZWheelAction> action = ActionForWheelEvent(&wheelEvent)) {
         ScrollWheelInput::ScrollMode scrollMode =
             ScrollWheelInput::SCROLLMODE_INSTANT;
-        if (StaticPrefs::general_smoothScroll() &&
+        if (nsLayoutUtils::IsSmoothScrollingEnabled() &&
             ((wheelEvent.mDeltaMode ==
                   dom::WheelEvent_Binding::DOM_DELTA_LINE &&
               StaticPrefs::general_smoothScroll_mouseWheel()) ||


=====================================
gfx/layers/apz/src/APZPublicUtils.cpp
=====================================
@@ -7,6 +7,7 @@
 #include "mozilla/layers/APZPublicUtils.h"
 
 #include "AsyncPanZoomController.h"
+#include "nsLayoutUtils.h"
 #include "mozilla/HelperMacros.h"
 #include "mozilla/StaticPrefs_general.h"
 
@@ -36,9 +37,10 @@ ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin(
   int32_t minMS = 0;
   int32_t maxMS = 0;
   bool isOriginSmoothnessEnabled = false;
+  bool isGeneralSmoothnessEnabled = nsLayoutUtils::IsSmoothScrollingEnabled();
 
 #define READ_DURATIONS(prefbase)                                              \
-  isOriginSmoothnessEnabled = StaticPrefs::general_smoothScroll() &&          \
+  isOriginSmoothnessEnabled = isGeneralSmoothnessEnabled &&                   \
                               StaticPrefs::general_smoothScroll_##prefbase(); \
   if (isOriginSmoothnessEnabled) {                                            \
     minMS = StaticPrefs::general_smoothScroll_##prefbase##_durationMinMS();   \
@@ -88,7 +90,8 @@ ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin(
 }
 
 ScrollMode GetScrollModeForOrigin(ScrollOrigin origin) {
-  if (!StaticPrefs::general_smoothScroll()) return ScrollMode::Instant;
+  bool isSmoothScrollingEnabled = nsLayoutUtils::IsSmoothScrollingEnabled();
+  if (!isSmoothScrollingEnabled) return ScrollMode::Instant;
   switch (origin) {
     case ScrollOrigin::Lines:
       return StaticPrefs::general_smoothScroll_lines() ? ScrollMode::Smooth
@@ -101,8 +104,8 @@ ScrollMode GetScrollModeForOrigin(ScrollOrigin origin) {
                                                        : ScrollMode::Instant;
     default:
       MOZ_ASSERT(false, "Unknown keyboard scroll origin");
-      return StaticPrefs::general_smoothScroll() ? ScrollMode::Smooth
-                                                 : ScrollMode::Instant;
+      return isSmoothScrollingEnabled ? ScrollMode::Smooth
+                                      : ScrollMode::Instant;
   }
 }
 


=====================================
gfx/layers/apz/src/GenericScrollAnimation.cpp
=====================================
@@ -8,6 +8,7 @@
 
 #include "AsyncPanZoomController.h"
 #include "FrameMetrics.h"
+#include "nsLayoutUtils.h"
 #include "mozilla/layers/APZPublicUtils.h"
 #include "nsPoint.h"
 #include "ScrollAnimationPhysics.h"
@@ -28,7 +29,7 @@ GenericScrollAnimation::GenericScrollAnimation(AsyncPanZoomController& aApzc,
   // ScrollAnimationBezierPhysics (despite its name) handles the case of
   // general.smoothScroll being disabled whereas ScrollAnimationMSDPhysics does
   // not (ie it scrolls smoothly).
-  if (StaticPrefs::general_smoothScroll() &&
+  if (nsLayoutUtils::IsSmoothScrollingEnabled() &&
       StaticPrefs::general_smoothScroll_msdPhysics_enabled()) {
     mAnimationPhysics = MakeUnique<ScrollAnimationMSDPhysics>(aInitialPosition);
   } else {


=====================================
gfx/layers/apz/src/WheelScrollAnimation.cpp
=====================================
@@ -8,6 +8,7 @@
 
 #include <tuple>
 #include "AsyncPanZoomController.h"
+#include "nsLayoutUtils.h"
 #include "mozilla/StaticPrefs_general.h"
 #include "mozilla/layers/APZPublicUtils.h"
 #include "nsPoint.h"
@@ -35,7 +36,7 @@ WheelScrollAnimation::WheelScrollAnimation(
     ScrollWheelInput::ScrollDeltaType aDeltaType)
     : GenericScrollAnimation(aApzc, aInitialPosition,
                              OriginForDeltaType(aDeltaType)) {
-  MOZ_ASSERT(StaticPrefs::general_smoothScroll(),
+  MOZ_ASSERT(nsLayoutUtils::IsSmoothScrollingEnabled(),
              "We shouldn't be creating a WheelScrollAnimation if smooth "
              "scrolling is disabled");
   mDirectionForcedToOverscroll =


=====================================
layout/base/nsLayoutUtils.cpp
=====================================
@@ -7765,28 +7765,23 @@ size_t nsLayoutUtils::SizeOfTextRunsForFrames(nsIFrame* aFrame,
 
 /* static */
 void nsLayoutUtils::RecomputeSmoothScrollDefault() {
+  // 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.
+  Preferences::SetBool(
+      StaticPrefs::GetPrefName_general_smoothScroll(),
+      !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)) {
-    // 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.
-    Preferences::SetBool(
-        StaticPrefs::GetPrefName_general_smoothScroll(),
-        !LookAndFeel::GetInt(LookAndFeel::IntID::PrefersReducedMotion, 0),
-        PrefValueKind::Default);
+    return true;
   }
-}
-
-/* static */
-bool nsLayoutUtils::IsSmoothScrollingEnabled() {
   return StaticPrefs::general_smoothScroll();
 }
 


=====================================
layout/xul/nsSliderFrame.cpp
=====================================
@@ -1535,7 +1535,7 @@ void nsSliderFrame::PageScroll(bool aClickAndHold) {
 
     mCurrentClickHoldDestination = Some(pos);
     sf->ScrollTo(pos,
-                 StaticPrefs::general_smoothScroll() &&
+                 nsLayoutUtils::IsSmoothScrollingEnabled() &&
                          StaticPrefs::general_smoothScroll_pages()
                      ? ScrollMode::Smooth
                      : ScrollMode::Instant,


=====================================
widget/cocoa/nsChildView.mm
=====================================
@@ -3266,7 +3266,7 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) {
   } else {
     ScrollWheelInput::ScrollMode scrollMode =
         ScrollWheelInput::SCROLLMODE_INSTANT;
-    if (StaticPrefs::general_smoothScroll() &&
+    if (nsLayoutUtils::IsSmoothScrollingEnabled() &&
         StaticPrefs::general_smoothScroll_mouseWheel()) {
       scrollMode = ScrollWheelInput::SCROLLMODE_SMOOTH;
     }



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/26180332375f16d957383c69b69200a6604d0c28...f93056fefb0118067f3c052887243f2865f08359

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/26180332375f16d957383c69b69200a6604d0c28...f93056fefb0118067f3c052887243f2865f08359
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20240923/22bd0b64/attachment-0001.htm>


More information about the tbb-commits mailing list