/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
class ScrollVelocityQueue final { public: explicit ScrollVelocityQueue(nsPresContext* aPresContext)
: mPresContext(aPresContext) {}
// Sample() is to be called periodically when scroll movement occurs, to // record samples of scroll position used later by GetVelocity(). void Sample(const nsPoint& aScrollPosition);
// Discards velocity samples, resulting in velocity of 0 returned by // GetVelocity until move scroll position updates. void Reset();
// Get scroll velocity averaged from recent movement, in appunits / second
nsPoint GetVelocity();
private: // A queue of (duration, velocity) pairs; these are the historical average // velocities over the given durations. Durations are in milliseconds, // velocities are in app units per second.
nsTArray<std::pair<uint32_t, nsPoint> > mQueue;
// Accumulates the distance and direction travelled by the scroll frame since // mSampleTime.
nsPoint mAccumulator;
// Time that mAccumulator was last reset and began accumulating.
TimeStamp mSampleTime;
// Scroll offset at the mAccumulator was last reset and began // accumulating.
nsPoint mLastPosition;
// PresContext of the containing frame, used to get timebase
nsPresContext* mPresContext;
// Remove samples from mQueue that no longer contribute to GetVelocity() // due to their age void TrimQueue();
};
} // namespace layout
} // namespace mozilla
#endif/* !defined(ScrollVelocityQueue_h_) */
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.