android/source/src/java/org/mozilla/gecko/gfx/Axis.java |   58 +++-------------
 1 file changed, 11 insertions(+), 47 deletions(-)

New commits:
commit d92f51f33899732898e52e4f6edf2e5061d394a0
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Nov 13 12:49:24 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Nov 14 11:57:54 2025 +0100

    android: Assign constant values right away
    
    Simplify this further after
    
        Change-Id: Icae6258fa4516348dc2c8978f42024d9884216f7
        Author: Michael Weghorn <[email protected]>
        Date:   Thu Nov 13 12:40:50 2025 +0100
    
            android: Skip (not) reading from null map
    
    Change-Id: I1c44456bc6e5a17e2dae0c03d1dfaf54dcbbea09
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193963
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/android/source/src/java/org/mozilla/gecko/gfx/Axis.java 
b/android/source/src/java/org/mozilla/gecko/gfx/Axis.java
index e0609e3f8874..93d876f4e24e 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/Axis.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/Axis.java
@@ -15,30 +15,32 @@ import org.mozilla.gecko.util.FloatUtils;
  * like displacement, velocity, viewport dimensions, etc. pertaining to
  * a particular axis.
  */
+
 abstract class Axis {
 
     // This fraction of velocity remains after every animation frame when the 
velocity is low.
-    private static float FRICTION_SLOW;
+    private static final float FRICTION_SLOW = getFrameAdjustedFriction(0.85f);
     // This fraction of velocity remains after every animation frame when the 
velocity is high.
-    private static float FRICTION_FAST;
+    private static final float FRICTION_FAST = getFrameAdjustedFriction(0.97f);
     // Below this velocity (in pixels per frame), the friction starts 
increasing from FRICTION_FAST
     // to FRICTION_SLOW.
-    private static float VELOCITY_THRESHOLD;
+
+    static final float MS_PER_FRAME = 4.0f;
+    private static final float FRAMERATE_MULTIPLIER = (1000f/60f) / 
MS_PER_FRAME;
+    private static final float VELOCITY_THRESHOLD = 10 / FRAMERATE_MULTIPLIER;
     // The maximum velocity change factor between events, per ms, in %.
     // Direction changes are excluded.
-    private static float MAX_EVENT_ACCELERATION;
+    private static final float MAX_EVENT_ACCELERATION = 0.012f;
 
     // The rate of deceleration when the surface has overscrolled.
-    private static float OVERSCROLL_DECEL_RATE;
+    private static final float OVERSCROLL_DECEL_RATE = 
getFrameAdjustedFriction(0.04f);
     // The percentage of the surface which can be overscrolled before it must 
snap back.
-    private static float SNAP_LIMIT;
+    private static final float SNAP_LIMIT = 0.3f;
 
     // The minimum amount of space that must be present for an axis to be 
considered scrollable,
     // in pixels.
-    private static float MIN_SCROLLABLE_DISTANCE;
+    private static final float MIN_SCROLLABLE_DISTANCE = 0.5f;
 
-    static final float MS_PER_FRAME = 4.0f;
-    private static final float FRAMERATE_MULTIPLIER = (1000f/60f) / 
MS_PER_FRAME;
 
     //  The values we use for friction are based on a 16.6ms frame, adjust 
them to MS_PER_FRAME:
     //  FRICTION^1 = FRICTION_ADJUSTED^(16/MS_PER_FRAME)
@@ -47,21 +49,6 @@ abstract class Axis {
         return (float)Math.pow(Math.E, (Math.log(baseFriction) / 
FRAMERATE_MULTIPLIER));
     }
 
-    static void setPrefs() {
-        FRICTION_SLOW = getFrameAdjustedFriction(0.85f);
-        FRICTION_FAST = getFrameAdjustedFriction(0.97f);
-        VELOCITY_THRESHOLD = 10 / FRAMERATE_MULTIPLIER;
-        MAX_EVENT_ACCELERATION = 0.012f;
-        OVERSCROLL_DECEL_RATE = getFrameAdjustedFriction(0.04f);
-        SNAP_LIMIT = 0.3f;
-        MIN_SCROLLABLE_DISTANCE = 0.5f;
-    }
-
-    static {
-        // set the scrolling parameters to default values on startup
-        setPrefs();
-    }
-
     private enum FlingStates {
         STOPPED,
         PANNING,
commit 77a4a8efc3f38c907032226ff919742a230042cc
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Nov 13 12:40:50 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Nov 14 11:57:45 2025 +0100

    android: Skip (not) reading from null map
    
    The only caller of setPrefs passes a null param.
    Therefore, drop the param and the logic that would
    only have been relevant for a non-null param.
    
    Change-Id: Icae6258fa4516348dc2c8978f42024d9884216f7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193962
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/android/source/src/java/org/mozilla/gecko/gfx/Axis.java 
b/android/source/src/java/org/mozilla/gecko/gfx/Axis.java
index e22dd9b73857..e0609e3f8874 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/Axis.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/Axis.java
@@ -5,13 +5,10 @@
 
 package org.mozilla.gecko.gfx;
 
-import android.util.Log;
 import android.view.View;
 
 import org.mozilla.gecko.util.FloatUtils;
 
-import java.util.Map;
-
 /**
  * This class represents the physics for one axis of movement (i.e. either
  * horizontal or vertical). It tracks the different properties of movement
@@ -19,14 +16,6 @@ import java.util.Map;
  * a particular axis.
  */
 abstract class Axis {
-    private static final String LOGTAG = "GeckoAxis";
-
-    private static final String PREF_SCROLLING_FRICTION_SLOW = 
"ui.scrolling.friction_slow";
-    private static final String PREF_SCROLLING_FRICTION_FAST = 
"ui.scrolling.friction_fast";
-    private static final String PREF_SCROLLING_MAX_EVENT_ACCELERATION = 
"ui.scrolling.max_event_acceleration";
-    private static final String PREF_SCROLLING_OVERSCROLL_DECEL_RATE = 
"ui.scrolling.overscroll_decel_rate";
-    private static final String PREF_SCROLLING_OVERSCROLL_SNAP_LIMIT = 
"ui.scrolling.overscroll_snap_limit";
-    private static final String PREF_SCROLLING_MIN_SCROLLABLE_DISTANCE = 
"ui.scrolling.min_scrollable_distance";
 
     // This fraction of velocity remains after every animation frame when the 
velocity is low.
     private static float FRICTION_SLOW;
@@ -48,16 +37,6 @@ abstract class Axis {
     // in pixels.
     private static float MIN_SCROLLABLE_DISTANCE;
 
-    private static float getFloatPref(Map<String, Integer> prefs, String 
prefName, int defaultValue) {
-        Integer value = (prefs == null ? null : prefs.get(prefName));
-        return (float)(value == null || value < 0 ? defaultValue : value) / 
1000f;
-    }
-
-    private static int getIntPref(Map<String, Integer> prefs, String prefName, 
int defaultValue) {
-        Integer value = (prefs == null ? null : prefs.get(prefName));
-        return (value == null || value < 0 ? defaultValue : value);
-    }
-
     static final float MS_PER_FRAME = 4.0f;
     private static final float FRAMERATE_MULTIPLIER = (1000f/60f) / 
MS_PER_FRAME;
 
@@ -68,21 +47,19 @@ abstract class Axis {
         return (float)Math.pow(Math.E, (Math.log(baseFriction) / 
FRAMERATE_MULTIPLIER));
     }
 
-    static void setPrefs(Map<String, Integer> prefs) {
-        FRICTION_SLOW = getFrameAdjustedFriction(getFloatPref(prefs, 
PREF_SCROLLING_FRICTION_SLOW, 850));
-        FRICTION_FAST = getFrameAdjustedFriction(getFloatPref(prefs, 
PREF_SCROLLING_FRICTION_FAST, 970));
+    static void setPrefs() {
+        FRICTION_SLOW = getFrameAdjustedFriction(0.85f);
+        FRICTION_FAST = getFrameAdjustedFriction(0.97f);
         VELOCITY_THRESHOLD = 10 / FRAMERATE_MULTIPLIER;
-        MAX_EVENT_ACCELERATION = getFloatPref(prefs, 
PREF_SCROLLING_MAX_EVENT_ACCELERATION, 12);
-        OVERSCROLL_DECEL_RATE = getFrameAdjustedFriction(getFloatPref(prefs, 
PREF_SCROLLING_OVERSCROLL_DECEL_RATE, 40));
-        SNAP_LIMIT = getFloatPref(prefs, PREF_SCROLLING_OVERSCROLL_SNAP_LIMIT, 
300);
-        MIN_SCROLLABLE_DISTANCE = getFloatPref(prefs, 
PREF_SCROLLING_MIN_SCROLLABLE_DISTANCE, 500);
-        Log.i(LOGTAG, "Prefs: " + FRICTION_SLOW + "," + FRICTION_FAST + "," + 
VELOCITY_THRESHOLD + ","
-                + MAX_EVENT_ACCELERATION + "," + OVERSCROLL_DECEL_RATE + "," + 
SNAP_LIMIT + "," + MIN_SCROLLABLE_DISTANCE);
+        MAX_EVENT_ACCELERATION = 0.012f;
+        OVERSCROLL_DECEL_RATE = getFrameAdjustedFriction(0.04f);
+        SNAP_LIMIT = 0.3f;
+        MIN_SCROLLABLE_DISTANCE = 0.5f;
     }
 
     static {
         // set the scrolling parameters to default values on startup
-        setPrefs(null);
+        setPrefs();
     }
 
     private enum FlingStates {

Reply via email to