android/source/src/java/org/mozilla/gecko/gfx/TouchEventHandler.java |  117 
----------
 1 file changed, 117 deletions(-)

New commits:
commit 5bf1d4905d01fef38210d2b592fff8ea84a77007
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Nov 12 22:49:53 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Nov 14 11:54:12 2025 +0100

    android: Drop ListenerTimeoutProcessor
    
    As has become clear with
    
        Change-Id: Iae8392bc6e8edd7cafae0602b94c270c23f1f7bd
        Author: Michael Weghorn <[email protected]>
        Date:   Wed Nov 12 16:41:57 2025 +0100
    
            android: Drop queue logic in TouchEventHandler
    
    , that class doesn't actually do anything useful
    anymore at this point in time, so drop and correspoinding
    logic altogether.
    
    Change-Id: I4ed7816f3dc1c63a2b6a7974544878c02fa9acfe
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193923
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git 
a/android/source/src/java/org/mozilla/gecko/gfx/TouchEventHandler.java 
b/android/source/src/java/org/mozilla/gecko/gfx/TouchEventHandler.java
index 6bc17c7e4fbf..118162e3e8a4 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/TouchEventHandler.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/TouchEventHandler.java
@@ -48,64 +48,17 @@ import java.util.Queue;
 public final class TouchEventHandler {
     private static final String LOGTAG = "GeckoTouchEventHandler";
 
-    // The time limit for listeners to respond with preventDefault on 
touchevents
-    // before we begin panning the page
-    private static final int EVENT_LISTENER_TIMEOUT = 200;
-
     private final View mView;
     private final GestureDetector mGestureDetector;
     private final SimpleScaleGestureDetector mScaleGestureDetector;
     private final JavaPanZoomController mPanZoomController;
 
-    private final ListenerTimeoutProcessor mListenerTimeoutProcessor;
-
-    // this next variable requires some explanation. strap yourself in.
-    //
-    // for each block of events, we do two things: (1) send the events to 
gecko and expect
-    // exactly one default-prevented notification in return, and (2) kick off 
a delayed
-    // ListenerTimeoutProcessor that triggers in case we don't hear from the 
listener in
-    // a timely fashion.
-    // since events are constantly coming in, we need to be able to handle 
more than one
-    // block of events in the queue.
-    //
-    // this means that there are ordering restrictions on these that we can 
take advantage of,
-    // and need to abide by. blocks of events in the queue will always be in 
the order that
-    // the user generated them. default-prevented notifications we get from 
gecko will be in
-    // the same order as the blocks of events in the queue. the 
ListenerTimeoutProcessors that
-    // have been posted will also fire in the same order as the blocks of 
events in the queue.
-    // HOWEVER, we may get multiple default-prevented notifications 
interleaved with multiple
-    // ListenerTimeoutProcessor firings, and that interleaving is not 
predictable.
-    //
-    // therefore, we need to make sure that for each block of events, we 
process the queued
-    // events exactly once, either when we get the default-prevented 
notification, or when the
-    // timeout expires (whichever happens first). there is no way to associate 
the
-    // default-prevented notification with a particular block of events other 
than via ordering,
-    //
-    // so what we do to accomplish this is to track a "processing balance", 
which is the number
-    // of default-prevented notifications that we have received, minus the 
number of ListenerTimeoutProcessors
-    // that have fired. (think "balance" as in teeter-totter balance). this 
value is:
-    // - zero when we are in a state where the next default-prevented 
notification we expect
-    //   to receive and the next ListenerTimeoutProcessor we expect to fire 
both correspond to
-    //   the next block of events in the queue.
-    // - positive when we are in a state where we have received more 
default-prevented notifications
-    //   than ListenerTimeoutProcessors. This means that the next 
default-prevented notification
-    //   does correspond to the block at the head of the queue, but the next n 
ListenerTimeoutProcessors
-    //   need to be ignored as they are for blocks we have already processed. 
(n is the absolute value
-    //   of the balance.)
-    // - negative when we are in a state where we have received more 
ListenerTimeoutProcessors than
-    //   default-prevented notifications. This means that the next 
ListenerTimeoutProcessor that
-    //   we receive does correspond to the block at the head of the queue, but 
the next n
-    //   default-prevented notifications need to be ignored as they are for 
blocks we have already
-    //   processed. (n is the absolute value of the balance.)
-    private int mProcessingBalance;
-
     TouchEventHandler(Context context, View view, JavaPanZoomController 
panZoomController) {
         mView = view;
 
         mPanZoomController = panZoomController;
         mGestureDetector = new GestureDetector(context, mPanZoomController);
         mScaleGestureDetector = new 
SimpleScaleGestureDetector(mPanZoomController);
-        mListenerTimeoutProcessor = new ListenerTimeoutProcessor();
 
         mGestureDetector.setOnDoubleTapListener(mPanZoomController);
     }
@@ -118,10 +71,6 @@ public final class TouchEventHandler {
         if (isDownEvent(event)) {
             // this is the start of a new block of events! whee!
             mPanZoomController.startingNewEventBlock(event, false);
-
-            // set the timeout so that we dispatch these events and update 
mProcessingBalance
-            // if we don't get a default-prevented notification
-            mView.postDelayed(mListenerTimeoutProcessor, 
EVENT_LISTENER_TIMEOUT);
         }
 
         dispatchEvent(event);
@@ -152,22 +101,4 @@ public final class TouchEventHandler {
         }
         mPanZoomController.handleEvent(event);
     }
-
-    private void processEventBlock() {
-        // no more logic here
-    }
-
-    private class ListenerTimeoutProcessor implements Runnable {
-        /* This MUST be run on the UI thread */
-        public void run() {
-            if (mProcessingBalance < 0) {
-                // gecko already responded with default-prevented 
notification, and so
-                // the block of events this ListenerTimeoutProcessor 
corresponds to have
-                // already been removed from the queue.
-            } else {
-                processEventBlock();
-            }
-            mProcessingBalance++;
-        }
-    }
 }
commit 5d1efdfa5dd208db49d4d2d57b579a7f89c4a644
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Nov 12 16:41:57 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Nov 14 11:53:59 2025 +0100

    android: Drop queue logic in TouchEventHandler
    
    Earlier commit
    
        Change-Id: I145531e23f9d076f79bdb6c0d886f33e05d818f9
        Author: Michael Weghorn <[email protected]>
        Date:   Wed Nov 12 16:08:56 2025 +0100
    
            android: Drop two TouchEventHandler members that are always false
    
    dropped the last `mEventQueue.add` call adding something
    other than null to the event queue.
    
    Therefore, the queue can by now either be empty or
    contain only null values, both of which results in
    the processEventBlock() logic not doing anything
    relevant.
    
    Therefore, drop the event queue and the
    processEventBlock() logic altogether.
    
    Further simplification/cleanup can happen in upcoming commits.
    
    Change-Id: Iae8392bc6e8edd7cafae0602b94c270c23f1f7bd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193922
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git 
a/android/source/src/java/org/mozilla/gecko/gfx/TouchEventHandler.java 
b/android/source/src/java/org/mozilla/gecko/gfx/TouchEventHandler.java
index 22b9b71ccc89..6bc17c7e4fbf 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/TouchEventHandler.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/TouchEventHandler.java
@@ -57,9 +57,6 @@ public final class TouchEventHandler {
     private final SimpleScaleGestureDetector mScaleGestureDetector;
     private final JavaPanZoomController mPanZoomController;
 
-    // the queue of events that we are holding on to while waiting for a 
preventDefault
-    // notification
-    private final Queue<MotionEvent> mEventQueue;
     private final ListenerTimeoutProcessor mListenerTimeoutProcessor;
 
     // this next variable requires some explanation. strap yourself in.
@@ -105,7 +102,6 @@ public final class TouchEventHandler {
     TouchEventHandler(Context context, View view, JavaPanZoomController 
panZoomController) {
         mView = view;
 
-        mEventQueue = new LinkedList<MotionEvent>();
         mPanZoomController = panZoomController;
         mGestureDetector = new GestureDetector(context, mPanZoomController);
         mScaleGestureDetector = new 
SimpleScaleGestureDetector(mPanZoomController);
@@ -121,12 +117,6 @@ public final class TouchEventHandler {
     public boolean handleEvent(MotionEvent event) {
         if (isDownEvent(event)) {
             // this is the start of a new block of events! whee!
-
-            // we're not going to be holding this block of events in the 
queue, but we need
-            // a marker of some sort so that the processEventBlock loop deals 
with the blocks
-            // in the right order as notifications come in. we use a single 
null event in
-            // the queue as a placeholder for a block of events that has 
already been dispatched.
-            mEventQueue.add(null);
             mPanZoomController.startingNewEventBlock(event, false);
 
             // set the timeout so that we dispatch these events and update 
mProcessingBalance
@@ -163,46 +153,8 @@ public final class TouchEventHandler {
         mPanZoomController.handleEvent(event);
     }
 
-    /**
-     * Process the block of events at the head of the queue now that we know
-     * whether it has been default-prevented or not.
-     */
     private void processEventBlock() {
-        if (mEventQueue.isEmpty()) {
-            Log.e(LOGTAG, "Unexpected empty event queue in 
processEventBlock!", new Exception());
-            return;
-        }
-
-        // the odd loop condition is because the first event in the queue will
-        // always be a DOWN or POINTER_DOWN event, and we want to process all
-        // the events in the queue starting at that one, up to but not 
including
-        // the next DOWN or POINTER_DOWN event.
-
-        MotionEvent event = mEventQueue.poll();
-        while (true) {
-            // event being null here is valid and represents a block of events
-            // that has already been dispatched.
-
-            if (event != null) {
-                dispatchEvent(event);
-            }
-            if (mEventQueue.isEmpty()) {
-                // we have processed the backlog of events, and are all caught 
up.
-                break;
-            }
-            event = mEventQueue.peek();
-            if (event == null || isDownEvent(event)) {
-                // we have finished processing the block we were interested in.
-                // now we wait for the next call to processEventBlock
-                if (event != null) {
-                    mPanZoomController.startingNewEventBlock(event, true);
-                }
-                break;
-            }
-            // pop the event we peeked above, as it is still part of the block 
and
-            // we want to keep processing
-            mEventQueue.remove();
-        }
+        // no more logic here
     }
 
     private class ListenerTimeoutProcessor implements Runnable {

Reply via email to