Files
roytam1 bb3c92a4bb import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1229623 - Remove compilation/database.py from mach_bootstrap.py. r=mshal (16de324bd5)
- Bug 1228208 - Make sure ICU flags are prepended before system flags. r=glandium (77a099bb4a)
- Bug 1176968 part 2: Add "requirement flags" field to media query features, and logic for ignoring the feature if requirements aren't met. r=heycam (f2fb438cc7)
- Bug 1176968 part 3: Add support for "-webkit-device-pixel-ratio" media query, along with its min/max variants (behind a pref). r=heycam (d9cf15f3f3)
- Bug 1176968 part 4: Add tests for -webkit-device-pixel-ratio, based on existing -moz tests. r=heycam (7a143f1310)
- Bug 1230863 - Remove unused nsPresContext args from many functions. r=roc. (8f3ca74bb8)
- Add APZ support for mousewheel.acceleration prefs. (bug 1214170 part 1, r=kats) (f9ead80db9)
- Add APZ support for mousewheel delta multiplier prefs. (bug 1214170 part 2, r=kats) (111d111124)
- Bug 1143618 - Follow-up to fix static analysis build bustage. r=me on a CLOSED TREE (57c395593f)
- Bug 1021845 - Before compositing, clip the visible region of a layer to the layer's clip rect. r=mattwoodrow (493ad91934)
- Bug 1152046 - move ClosingService::Start/Shutdown to nsIOService. r=mayhemer (4d078b7611)
- Bug 1226909 part 1: Do security checks in a redirect handler rather than when opening the redirected channel. r=ckerschb (30d23ad2ee)
- Bug 1226909 part 2: Let CORS preflight logic grab information from nsILoadInfo rather than duplicate it. r=ckerschb (04ece9d251)
- Bug 1214361 Test final response types after redirect. r=sicking a=abillings (3f288cae02)
- Bug 1210302 - Part 4: Add automated tests; r=sicking (b43a9a02c4)
- Bug 1226909 part 3: Move logic of when to initiate CORS preflight into channels. Allow CORS preflight to happen when doing a same-origin to cross-origin redirect. r=ckerschb (816498fdb5)
- Bug 1216793 - check against tracking protection list in fetch(). r=gcp (1ddeb07832)
- Bug 1228342 - initialize mTainting by all constructors. r=bkelly (60e63d22bd)
- Bug 1226909 part 4: Make AsyncOpen2 set taining information on channels. Use this information in XHR and fetch(). r=bkelly (3b0bc77efc)
- Bug 1214819. Add support for @crossorigin to <link rel=prefetch> so resources can be prefetched via anonymous CORS, for example. r=hurley (de8b0aef94)
- Bug 1216687: Add nsILoadInfo flags for cookie policies. r=ckerschb (f2634fd5b0)
- Bug 1213443 - Parallelism for <link rel=prefetch> r=bz (f5ee458126)
2023-05-12 10:38:28 +08:00

106 lines
3.5 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_layout_AsyncScrollBase_h_
#define mozilla_layout_AsyncScrollBase_h_
#include "mozilla/TimeStamp.h"
#include "nsPoint.h"
#include "nsSMILKeySpline.h"
namespace mozilla {
// This is the base class for driving scroll wheel animation on both the
// compositor and main thread.
class AsyncScrollBase
{
public:
typedef mozilla::TimeStamp TimeStamp;
typedef mozilla::TimeDuration TimeDuration;
explicit AsyncScrollBase(nsPoint aStartPos);
void Update(TimeStamp aTime,
nsPoint aDestination,
const nsSize& aCurrentVelocity);
// Get the velocity at a point in time in nscoords/sec.
nsSize VelocityAt(TimeStamp aTime) const;
// Returns the expected scroll position at a given point in time, in app
// units, relative to the scroll frame.
nsPoint PositionAt(TimeStamp aTime) const;
bool IsFinished(TimeStamp aTime) {
return aTime > mStartTime + mDuration;
}
protected:
double ProgressAt(TimeStamp aTime) const {
return clamped((aTime - mStartTime) / mDuration, 0.0, 1.0);
}
nscoord VelocityComponent(double aTimeProgress,
const nsSMILKeySpline& aTimingFunction,
nscoord aStart, nscoord aDestination) const;
// Calculate duration, possibly dynamically according to events rate and
// event origin. (also maintain previous timestamps - which are only used
// here).
TimeDuration ComputeDuration(TimeStamp aTime);
// Initialize event history.
void InitializeHistory(TimeStamp aTime);
// Initializes the timing function in such a way that the current velocity is
// preserved.
void InitTimingFunction(nsSMILKeySpline& aTimingFunction,
nscoord aCurrentPos, nscoord aCurrentVelocity,
nscoord aDestination);
// mPrevEventTime holds previous 3 timestamps for intervals averaging (to
// reduce duration fluctuations). When AsyncScroll is constructed and no
// previous timestamps are available (indicated with mIsFirstIteration),
// initialize mPrevEventTime using imaginary previous timestamps with maximum
// relevant intervals between them.
TimeStamp mPrevEventTime[3];
bool mIsFirstIteration;
TimeStamp mStartTime;
// Cached Preferences value.
//
// These values are minimum and maximum animation duration per event origin,
// and a global ratio which defines how longer is the animation's duration
// compared to the average recent events intervals (such that for a relatively
// consistent events rate, the next event arrives before current animation ends)
int32_t mOriginMinMS;
int32_t mOriginMaxMS;
double mIntervalRatio;
nsPoint mStartPos;
TimeDuration mDuration;
nsPoint mDestination;
nsSMILKeySpline mTimingFunctionX;
nsSMILKeySpline mTimingFunctionY;
};
// Helper for accelerated wheel deltas. This can be called from the main thread
// or the APZ Controller thread.
static inline double
ComputeAcceleratedWheelDelta(double aDelta, int32_t aCounter, int32_t aFactor)
{
if (!aDelta) {
return aDelta;
}
return (aDelta * aCounter * double(aFactor) / 10);
}
static const uint32_t kScrollSeriesTimeoutMs = 80; // in milliseconds
} // namespace mozilla
#endif // mozilla_layout_AsyncScrollBase_h_