Backed out 8 changesets (bug 1445662) for bustage at build/src/gfx/layers/apz/util/ChromeProcessController.cp on a CLOSED TREE

Backed out changeset d514b05d1f6a (bug 1445662)
Backed out changeset 13f4f51d7bd1 (bug 1445662)
Backed out changeset 20c79dee1905 (bug 1445662)
Backed out changeset ca1e29c9b439 (bug 1445662)
Backed out changeset 8fadda7d555e (bug 1445662)
Backed out changeset b5f2ceda75bd (bug 1445662)
Backed out changeset 41d8b7a6b339 (bug 1445662)
Backed out changeset 121cd3a0490f (bug 1445662)
This commit is contained in:
Coroiu Cristina 2018-03-15 20:37:10 +02:00
Родитель 45c410eacb
Коммит fbaf1d233a
19 изменённых файлов: 104 добавлений и 294 удалений

Просмотреть файл

@ -190,6 +190,13 @@ public:
*/ */
virtual void SetLongTapEnabled(bool aTapGestureEnabled) = 0; virtual void SetLongTapEnabled(bool aTapGestureEnabled) = 0;
/**
* Process touch velocity.
* Sometimes the touch move event will have a velocity even though no scrolling
* is occurring such as when the toolbar is being hidden/shown in Fennec.
* This function can be called to have the y axis' velocity queue updated.
*/
virtual void ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY) = 0;
// Returns whether or not a wheel event action will be (or was) performed by // Returns whether or not a wheel event action will be (or was) performed by
// APZ. If this returns true, the event must not perform a synchronous // APZ. If this returns true, the event must not perform a synchronous

Просмотреть файл

@ -65,6 +65,8 @@ typedef mozilla::gfx::Matrix4x4 Matrix4x4;
typedef CompositorBridgeParent::LayerTreeState LayerTreeState; typedef CompositorBridgeParent::LayerTreeState LayerTreeState;
float APZCTreeManager::sDPI = 160.0;
struct APZCTreeManager::TreeBuildingState { struct APZCTreeManager::TreeBuildingState {
TreeBuildingState(uint64_t aRootLayersId, TreeBuildingState(uint64_t aRootLayersId,
bool aIsFirstPaint, uint64_t aOriginatingLayersId, bool aIsFirstPaint, uint64_t aOriginatingLayersId,
@ -228,8 +230,7 @@ APZCTreeManager::APZCTreeManager(uint64_t aRootLayersId)
mRetainedTouchIdentifier(-1), mRetainedTouchIdentifier(-1),
mInScrollbarTouchDrag(false), mInScrollbarTouchDrag(false),
mApzcTreeLog("apzctree"), mApzcTreeLog("apzctree"),
mTestDataLock("APZTestDataLock"), mTestDataLock("APZTestDataLock")
mDPI(160.0)
{ {
RefPtr<APZCTreeManager> self(this); RefPtr<APZCTreeManager> self(this);
NS_DispatchToMainThread( NS_DispatchToMainThread(
@ -306,8 +307,6 @@ void
APZCTreeManager::SetAllowedTouchBehavior(uint64_t aInputBlockId, APZCTreeManager::SetAllowedTouchBehavior(uint64_t aInputBlockId,
const nsTArray<TouchBehaviorFlags> &aValues) const nsTArray<TouchBehaviorFlags> &aValues)
{ {
APZThreadUtils::AssertOnControllerThread();
mInputQueue->SetAllowedTouchBehavior(aInputBlockId, aValues); mInputQueue->SetAllowedTouchBehavior(aInputBlockId, aValues);
} }
@ -733,8 +732,6 @@ void
APZCTreeManager::StartScrollbarDrag(const ScrollableLayerGuid& aGuid, APZCTreeManager::StartScrollbarDrag(const ScrollableLayerGuid& aGuid,
const AsyncDragMetrics& aDragMetrics) const AsyncDragMetrics& aDragMetrics)
{ {
APZThreadUtils::AssertOnControllerThread();
RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid); RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid);
if (!apzc) { if (!apzc) {
NotifyScrollbarDragRejected(aGuid); NotifyScrollbarDragRejected(aGuid);
@ -749,8 +746,6 @@ bool
APZCTreeManager::StartAutoscroll(const ScrollableLayerGuid& aGuid, APZCTreeManager::StartAutoscroll(const ScrollableLayerGuid& aGuid,
const ScreenPoint& aAnchorLocation) const ScreenPoint& aAnchorLocation)
{ {
APZThreadUtils::AssertOnControllerThread();
RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid); RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid);
if (!apzc) { if (!apzc) {
if (XRE_IsGPUProcess()) { if (XRE_IsGPUProcess()) {
@ -770,8 +765,6 @@ APZCTreeManager::StartAutoscroll(const ScrollableLayerGuid& aGuid,
void void
APZCTreeManager::StopAutoscroll(const ScrollableLayerGuid& aGuid) APZCTreeManager::StopAutoscroll(const ScrollableLayerGuid& aGuid)
{ {
APZThreadUtils::AssertOnControllerThread();
if (RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid)) { if (RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid)) {
apzc->StopAutoscroll(); apzc->StopAutoscroll();
} }
@ -1072,7 +1065,7 @@ template<typename PanGestureOrScrollWheelInput>
static bool static bool
WillHandleInput(const PanGestureOrScrollWheelInput& aPanInput) WillHandleInput(const PanGestureOrScrollWheelInput& aPanInput)
{ {
if (!XRE_IsParentProcess() || !NS_IsMainThread()) { if (!NS_IsMainThread()) {
return true; return true;
} }
@ -1803,8 +1796,6 @@ void
APZCTreeManager::UpdateWheelTransaction(LayoutDeviceIntPoint aRefPoint, APZCTreeManager::UpdateWheelTransaction(LayoutDeviceIntPoint aRefPoint,
EventMessage aEventMessage) EventMessage aEventMessage)
{ {
APZThreadUtils::AssertOnControllerThread();
WheelBlockState* txn = mInputQueue->GetActiveWheelTransaction(); WheelBlockState* txn = mInputQueue->GetActiveWheelTransaction();
if (!txn) { if (!txn) {
return; return;
@ -1850,8 +1841,6 @@ APZCTreeManager::ProcessUnhandledEvent(LayoutDeviceIntPoint* aRefPoint,
ScrollableLayerGuid* aOutTargetGuid, ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutFocusSequenceNumber) uint64_t* aOutFocusSequenceNumber)
{ {
APZThreadUtils::AssertOnControllerThread();
// Transform the aRefPoint. // Transform the aRefPoint.
// If the event hits an overscrolled APZC, instruct the caller to ignore it. // If the event hits an overscrolled APZC, instruct the caller to ignore it.
CompositorHitTestInfo hitResult = CompositorHitTestInfo::eInvisibleToHitTest; CompositorHitTestInfo hitResult = CompositorHitTestInfo::eInvisibleToHitTest;
@ -1889,8 +1878,6 @@ APZCTreeManager::ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY)
void void
APZCTreeManager::SetKeyboardMap(const KeyboardMap& aKeyboardMap) APZCTreeManager::SetKeyboardMap(const KeyboardMap& aKeyboardMap)
{ {
APZThreadUtils::AssertOnControllerThread();
mKeyboardMap = aKeyboardMap; mKeyboardMap = aKeyboardMap;
} }
@ -1899,11 +1886,6 @@ APZCTreeManager::ZoomToRect(const ScrollableLayerGuid& aGuid,
const CSSRect& aRect, const CSSRect& aRect,
const uint32_t aFlags) const uint32_t aFlags)
{ {
// We could probably move this to run on the sampler thread if needed, but
// either way we should restrict it to a single thread. For now let's use the
// controller thread.
APZThreadUtils::AssertOnControllerThread();
RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid); RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid);
if (apzc) { if (apzc) {
apzc->ZoomToRect(aRect, aFlags); apzc->ZoomToRect(aRect, aFlags);
@ -1948,24 +1930,6 @@ void
APZCTreeManager::UpdateZoomConstraints(const ScrollableLayerGuid& aGuid, APZCTreeManager::UpdateZoomConstraints(const ScrollableLayerGuid& aGuid,
const Maybe<ZoomConstraints>& aConstraints) const Maybe<ZoomConstraints>& aConstraints)
{ {
if (!APZThreadUtils::IsSamplerThread()) {
// This can happen if we're in the UI process and got a call directly from
// nsBaseWidget (as opposed to over PAPZCTreeManager). We want this function
// to run on the sampler thread, so bounce it over.
MOZ_ASSERT(XRE_IsParentProcess());
APZThreadUtils::RunOnSamplerThread(
NewRunnableMethod<ScrollableLayerGuid, Maybe<ZoomConstraints>>(
"APZCTreeManager::UpdateZoomConstraints",
this,
&APZCTreeManager::UpdateZoomConstraints,
aGuid,
aConstraints));
return;
}
APZThreadUtils::AssertOnSamplerThread();
RecursiveMutexAutoLock lock(mTreeLock); RecursiveMutexAutoLock lock(mTreeLock);
RefPtr<HitTestingTreeNode> node = GetTargetNode(aGuid, nullptr); RefPtr<HitTestingTreeNode> node = GetTargetNode(aGuid, nullptr);
MOZ_ASSERT(!node || node->GetApzc()); // any node returned must have an APZC MOZ_ASSERT(!node || node->GetApzc()); // any node returned must have an APZC
@ -3187,20 +3151,6 @@ APZCTreeManager::ComputeTransformForScrollThumb(
return transform; return transform;
} }
void
APZCTreeManager::SetDPI(float aDpiValue)
{
APZThreadUtils::AssertOnControllerThread();
mDPI = aDpiValue;
}
float
APZCTreeManager::GetDPI() const
{
APZThreadUtils::AssertOnControllerThread();
return mDPI;
}
#if defined(MOZ_WIDGET_ANDROID) #if defined(MOZ_WIDGET_ANDROID)
AndroidDynamicToolbarAnimator* AndroidDynamicToolbarAnimator*
APZCTreeManager::GetAndroidDynamicToolbarAnimator() APZCTreeManager::GetAndroidDynamicToolbarAnimator()

Просмотреть файл

@ -340,16 +340,15 @@ public:
bool HitTestAPZC(const ScreenIntPoint& aPoint); bool HitTestAPZC(const ScreenIntPoint& aPoint);
/** /**
* Sets the dpi value used by all AsyncPanZoomControllers attached to this * Sets the dpi value used by all AsyncPanZoomControllers.
* tree manager. * DPI defaults to 72 if not set using SetDPI() at any point.
* DPI defaults to 160 if not set using SetDPI() at any point.
*/ */
void SetDPI(float aDpiValue) override; void SetDPI(float aDpiValue) override { sDPI = aDpiValue; }
/** /**
* Returns the current dpi value in use. * Returns the current dpi value in use.
*/ */
float GetDPI() const; static float GetDPI() { return sDPI; }
/** /**
* Find the hit testing node for the scrollbar thumb that matches these * Find the hit testing node for the scrollbar thumb that matches these
@ -552,7 +551,7 @@ public:
* is occurring such as when the toolbar is being hidden/shown in Fennec. * is occurring such as when the toolbar is being hidden/shown in Fennec.
* This function can be called to have the y axis' velocity queue updated. * This function can be called to have the y axis' velocity queue updated.
*/ */
void ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY); void ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY) override;
private: private:
typedef bool (*GuidComparator)(const ScrollableLayerGuid&, const ScrollableLayerGuid&); typedef bool (*GuidComparator)(const ScrollableLayerGuid&, const ScrollableLayerGuid&);
@ -691,17 +690,15 @@ private:
* isolation (that is, if its tree pointers are not being accessed or mutated). The * isolation (that is, if its tree pointers are not being accessed or mutated). The
* lock also needs to be held when accessing the mRootNode instance variable, as that * lock also needs to be held when accessing the mRootNode instance variable, as that
* is considered part of the APZC tree management state. * is considered part of the APZC tree management state.
* Finally, the lock needs to be held when accessing mZoomConstraints.
* IMPORTANT: See the note about lock ordering at the top of this file. */ * IMPORTANT: See the note about lock ordering at the top of this file. */
mutable mozilla::RecursiveMutex mTreeLock; mutable mozilla::RecursiveMutex mTreeLock;
RefPtr<HitTestingTreeNode> mRootNode; RefPtr<HitTestingTreeNode> mRootNode;
/* Holds the zoom constraints for scrollable layers, as determined by the /* Holds the zoom constraints for scrollable layers, as determined by the
* the main-thread gecko code. This can only be accessed on the sampler * the main-thread gecko code. */
* thread. */
std::unordered_map<ScrollableLayerGuid, ZoomConstraints, ScrollableLayerGuidHash> mZoomConstraints; std::unordered_map<ScrollableLayerGuid, ZoomConstraints, ScrollableLayerGuidHash> mZoomConstraints;
/* A list of keyboard shortcuts to use for translating keyboard inputs into /* A list of keyboard shortcuts to use for translating keyboard inputs into
* keyboard actions. This is gathered on the main thread from XBL bindings. * keyboard actions. This is gathered on the main thread from XBL bindings.
* This must only be accessed on the controller thread.
*/ */
KeyboardMap mKeyboardMap; KeyboardMap mKeyboardMap;
/* This tracks the focus targets of chrome and content and whether we have /* This tracks the focus targets of chrome and content and whether we have
@ -749,8 +746,7 @@ private:
std::unordered_map<uint64_t, UniquePtr<APZTestData>> mTestData; std::unordered_map<uint64_t, UniquePtr<APZTestData>> mTestData;
mutable mozilla::Mutex mTestDataLock; mutable mozilla::Mutex mTestDataLock;
// This must only be touched on the controller thread. static float sDPI;
float mDPI;
#if defined(MOZ_WIDGET_ANDROID) #if defined(MOZ_WIDGET_ANDROID)
public: public:

Просмотреть файл

@ -868,34 +868,16 @@ AsyncPanZoomController::IsDestroyed() const
return mTreeManager == nullptr; return mTreeManager == nullptr;
} }
float /* static */ScreenCoord
AsyncPanZoomController::GetDPI() const AsyncPanZoomController::GetTouchStartTolerance()
{ {
if (APZCTreeManager* localPtr = mTreeManager) { return (gfxPrefs::APZTouchStartTolerance() * APZCTreeManager::GetDPI());
return localPtr->GetDPI();
}
// If this APZC has been destroyed then this value is not going to be
// used for anything that the user will end up seeing, so we can just
// return 0.
return 0.0;
} }
ScreenCoord /* static */ScreenCoord
AsyncPanZoomController::GetTouchStartTolerance() const AsyncPanZoomController::GetSecondTapTolerance()
{ {
return (gfxPrefs::APZTouchStartTolerance() * GetDPI()); return (gfxPrefs::APZSecondTapTolerance() * APZCTreeManager::GetDPI());
}
ScreenCoord
AsyncPanZoomController::GetTouchMoveTolerance() const
{
return (gfxPrefs::APZTouchMoveTolerance() * GetDPI());
}
ScreenCoord
AsyncPanZoomController::GetSecondTapTolerance() const
{
return (gfxPrefs::APZSecondTapTolerance() * GetDPI());
} }
/* static */AsyncPanZoomController::AxisLockMode AsyncPanZoomController::GetAxisLockMode() /* static */AsyncPanZoomController::AxisLockMode AsyncPanZoomController::GetAxisLockMode()
@ -2664,7 +2646,7 @@ void AsyncPanZoomController::HandlePanningUpdate(const ScreenPoint& aPanDistance
double angle = atan2(aPanDistance.y, aPanDistance.x); // range [-pi, pi] double angle = atan2(aPanDistance.y, aPanDistance.x); // range [-pi, pi]
angle = fabs(angle); // range [0, pi] angle = fabs(angle); // range [0, pi]
float breakThreshold = gfxPrefs::APZAxisBreakoutThreshold() * GetDPI(); float breakThreshold = gfxPrefs::APZAxisBreakoutThreshold() * APZCTreeManager::GetDPI();
if (fabs(aPanDistance.x) > breakThreshold || fabs(aPanDistance.y) > breakThreshold) { if (fabs(aPanDistance.x) > breakThreshold || fabs(aPanDistance.y) > breakThreshold) {
if (mState == PANNING_LOCKED_X) { if (mState == PANNING_LOCKED_X) {
@ -2685,13 +2667,13 @@ void AsyncPanZoomController::HandlePanningUpdate(const ScreenPoint& aPanDistance
void AsyncPanZoomController::HandlePinchLocking(ScreenCoord spanDistance, ScreenPoint focusChange) { void AsyncPanZoomController::HandlePinchLocking(ScreenCoord spanDistance, ScreenPoint focusChange) {
if (mPinchLocked) { if (mPinchLocked) {
if (GetPinchLockMode() == PINCH_STICKY) { if (GetPinchLockMode() == PINCH_STICKY) {
ScreenCoord spanBreakoutThreshold = gfxPrefs::APZPinchLockSpanBreakoutThreshold() * GetDPI(); ScreenCoord spanBreakoutThreshold = gfxPrefs::APZPinchLockSpanBreakoutThreshold() * APZCTreeManager::GetDPI();
mPinchLocked = !(spanDistance > spanBreakoutThreshold); mPinchLocked = !(spanDistance > spanBreakoutThreshold);
} }
} else { } else {
if (GetPinchLockMode() != PINCH_FREE) { if (GetPinchLockMode() != PINCH_FREE) {
ScreenCoord spanLockThreshold = gfxPrefs::APZPinchLockSpanLockThreshold() * GetDPI(); ScreenCoord spanLockThreshold = gfxPrefs::APZPinchLockSpanLockThreshold() * APZCTreeManager::GetDPI();
ScreenCoord scrollLockThreshold = gfxPrefs::APZPinchLockScrollLockThreshold() * GetDPI(); ScreenCoord scrollLockThreshold = gfxPrefs::APZPinchLockScrollLockThreshold() * APZCTreeManager::GetDPI();
if (spanDistance < spanLockThreshold && focusChange.Length() > scrollLockThreshold) { if (spanDistance < spanLockThreshold && focusChange.Length() > scrollLockThreshold) {
mPinchLocked = true; mPinchLocked = true;

Просмотреть файл

@ -152,11 +152,6 @@ public:
USE_GESTURE_DETECTOR USE_GESTURE_DETECTOR
}; };
/**
* Gets the DPI from the tree manager.
*/
float GetDPI() const;
/** /**
* Constant describing the tolerance in distance we use, multiplied by the * Constant describing the tolerance in distance we use, multiplied by the
* device DPI, before we start panning the screen. This is to prevent us from * device DPI, before we start panning the screen. This is to prevent us from
@ -165,19 +160,13 @@ public:
* Note: It's an abuse of the 'Coord' class to use it to represent a 2D * Note: It's an abuse of the 'Coord' class to use it to represent a 2D
* distance, but it's the closest thing we currently have. * distance, but it's the closest thing we currently have.
*/ */
ScreenCoord GetTouchStartTolerance() const; static ScreenCoord GetTouchStartTolerance();
/**
* Same as GetTouchStartTolerance, but the tolerance for how far the touch
* has to move before it starts allowing touchmove events to be dispatched
* to content, for non-scrollable content.
*/
ScreenCoord GetTouchMoveTolerance() const;
/** /**
* Same as GetTouchStartTolerance, but the tolerance for how close the second * Same as GetTouchStartTolerance, but the tolerance for how close the second
* tap has to be to the first tap in order to be counted as part of a multi-tap * tap has to be to the first tap in order to be counted as part of a multi-tap
* gesture (double-tap or one-touch-pinch). * gesture (double-tap or one-touch-pinch).
*/ */
ScreenCoord GetSecondTapTolerance() const; static ScreenCoord GetSecondTapTolerance();
AsyncPanZoomController(uint64_t aLayersId, AsyncPanZoomController(uint64_t aLayersId,
APZCTreeManager* aTreeManager, APZCTreeManager* aTreeManager,

Просмотреть файл

@ -60,7 +60,7 @@ Axis::Axis(AsyncPanZoomController* aAsyncPanZoomController)
} }
float Axis::ToLocalVelocity(float aVelocityInchesPerMs) const { float Axis::ToLocalVelocity(float aVelocityInchesPerMs) const {
ScreenPoint velocity = MakePoint(aVelocityInchesPerMs * mAsyncPanZoomController->GetDPI()); ScreenPoint velocity = MakePoint(aVelocityInchesPerMs * APZCTreeManager::GetDPI());
// Use ToScreenCoordinates() to convert a point rather than a vector by // Use ToScreenCoordinates() to convert a point rather than a vector by
// treating the point as a vector, and using (0, 0) as the anchor. // treating the point as a vector, and using (0, 0) as the anchor.
ScreenPoint panStart = mAsyncPanZoomController->ToScreenCoordinates( ScreenPoint panStart = mAsyncPanZoomController->ToScreenCoordinates(

Просмотреть файл

@ -263,7 +263,7 @@ bool GestureEventListener::MoveDistanceExceeds(ScreenCoord aThreshold) const
bool GestureEventListener::MoveDistanceIsLarge() const bool GestureEventListener::MoveDistanceIsLarge() const
{ {
return MoveDistanceExceeds(mAsyncPanZoomController->GetTouchStartTolerance()); return MoveDistanceExceeds(AsyncPanZoomController::GetTouchStartTolerance());
} }
bool GestureEventListener::SecondTapIsFar() const bool GestureEventListener::SecondTapIsFar() const
@ -271,7 +271,7 @@ bool GestureEventListener::SecondTapIsFar() const
// Allow a little more room here, because the is actually lifting their finger // Allow a little more room here, because the is actually lifting their finger
// off the screen before replacing it, and that tends to have more error than // off the screen before replacing it, and that tends to have more error than
// wiggling the finger while on the screen. // wiggling the finger while on the screen.
return MoveDistanceExceeds(mAsyncPanZoomController->GetSecondTapTolerance()); return MoveDistanceExceeds(AsyncPanZoomController::GetSecondTapTolerance());
} }
nsEventStatus GestureEventListener::HandleInputTouchMove() nsEventStatus GestureEventListener::HandleInputTouchMove()

Просмотреть файл

@ -6,6 +6,7 @@
#include "InputBlockState.h" #include "InputBlockState.h"
#include "APZCTreeManager.h" // for APZCTreeManager::GetDPI
#include "AsyncPanZoomController.h" // for AsyncPanZoomController #include "AsyncPanZoomController.h" // for AsyncPanZoomController
#include "ScrollAnimationPhysics.h" // for kScrollSeriesTimeoutMs #include "ScrollAnimationPhysics.h" // for kScrollSeriesTimeoutMs
#include "gfxPrefs.h" // for gfxPrefs #include "gfxPrefs.h" // for gfxPrefs
@ -889,13 +890,9 @@ TouchBlockState::UpdateSlopState(const MultiTouchInput& aInput,
return false; return false;
} }
if (mInSlop) { if (mInSlop) {
ScreenCoord threshold = 0; ScreenCoord threshold = aApzcCanConsumeEvents
// If the target was confirmed to null then the threshold doesn't ? AsyncPanZoomController::GetTouchStartTolerance()
// matter anyway since the events will never be processed. : ScreenCoord(gfxPrefs::APZTouchMoveTolerance() * APZCTreeManager::GetDPI());
if (const RefPtr<AsyncPanZoomController>& apzc = GetTargetApzc()) {
threshold = aApzcCanConsumeEvents ? apzc->GetTouchStartTolerance()
: apzc->GetTouchMoveTolerance();
}
bool stayInSlop = (aInput.mType == MultiTouchInput::MULTITOUCH_MOVE) && bool stayInSlop = (aInput.mType == MultiTouchInput::MULTITOUCH_MOVE) &&
(aInput.mTouches.Length() == 1) && (aInput.mTouches.Length() == 1) &&
((aInput.mTouches[0].mScreenPoint - mSlopOrigin).Length() < threshold); ((aInput.mTouches[0].mScreenPoint - mSlopOrigin).Length() < threshold);

Просмотреть файл

@ -42,6 +42,14 @@ APZThreadUtils::AssertOnControllerThread() {
MOZ_ASSERT(sControllerThread == MessageLoop::current()); MOZ_ASSERT(sControllerThread == MessageLoop::current());
} }
/*static*/ void
APZThreadUtils::AssertOnSamplerThread()
{
if (GetThreadAssertionsEnabled()) {
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
}
}
/*static*/ void /*static*/ void
APZThreadUtils::RunOnControllerThread(already_AddRefed<Runnable> aTask) APZThreadUtils::RunOnControllerThread(already_AddRefed<Runnable> aTask)
{ {
@ -66,39 +74,6 @@ APZThreadUtils::IsControllerThread()
return sControllerThread == MessageLoop::current(); return sControllerThread == MessageLoop::current();
} }
/*static*/ void
APZThreadUtils::AssertOnSamplerThread()
{
if (GetThreadAssertionsEnabled()) {
MOZ_ASSERT(IsSamplerThread());
}
}
/*static*/ void
APZThreadUtils::RunOnSamplerThread(already_AddRefed<Runnable> aTask)
{
RefPtr<Runnable> task = aTask;
MessageLoop* loop = CompositorThreadHolder::Loop();
if (!loop) {
// Could happen during startup
NS_WARNING("Dropping task posted to sampler thread");
return;
}
if (IsSamplerThread()) {
task->Run();
} else {
loop->PostTask(task.forget());
}
}
/*static*/ bool
APZThreadUtils::IsSamplerThread()
{
return CompositorThreadHolder::IsInCompositorThread();
}
NS_IMPL_ISUPPORTS(GenericNamedTimerCallbackBase, nsITimerCallback, nsINamed) NS_IMPL_ISUPPORTS(GenericNamedTimerCallbackBase, nsITimerCallback, nsINamed)
} // namespace layers } // namespace layers

Просмотреть файл

@ -40,6 +40,13 @@ public:
*/ */
static void AssertOnControllerThread(); static void AssertOnControllerThread();
/**
* This can be used to assert that the current thread is the
* sampler thread (which samples the async transform).
* This does nothing if thread assertions are disabled.
*/
static void AssertOnSamplerThread();
/** /**
* Run the given task on the APZ "controller thread" for this platform. If * Run the given task on the APZ "controller thread" for this platform. If
* this function is called from the controller thread itself then the task is * this function is called from the controller thread itself then the task is
@ -51,25 +58,6 @@ public:
* Returns true if currently on APZ "controller thread". * Returns true if currently on APZ "controller thread".
*/ */
static bool IsControllerThread(); static bool IsControllerThread();
/**
* This can be used to assert that the current thread is the
* sampler thread (which samples the async transform).
* This does nothing if thread assertions are disabled.
*/
static void AssertOnSamplerThread();
/**
* Runs the given task on the APZ "sampler thread" for this platform. If
* this function is called from the sampler thread itself then the task is
* run immediately without getting queued.
*/
static void RunOnSamplerThread(already_AddRefed<Runnable> aTask);
/**
* Returns true if currently on the APZ "sampler thread".
*/
static bool IsSamplerThread();
}; };
// A base class for GenericNamedTimerCallback<Function>. // A base class for GenericNamedTimerCallback<Function>.

Просмотреть файл

@ -158,14 +158,8 @@ ChromeProcessController::HandleDoubleTap(const mozilla::CSSPoint& aPoint,
FrameMetrics::ViewID viewId; FrameMetrics::ViewID viewId;
if (APZCCallbackHelper::GetOrCreateScrollIdentifiers( if (APZCCallbackHelper::GetOrCreateScrollIdentifiers(
document->GetDocumentElement(), &presShellId, &viewId)) { document->GetDocumentElement(), &presShellId, &viewId)) {
APZThreadUtils::RunOnControllerThread( mAPZCTreeManager->ZoomToRect(
NewRunnableMethod<ScrollableLayerGuid, CSSRect, uint32_t>( ScrollableLayerGuid(aGuid.mLayersId, presShellId, viewId), zoomToRect);
"IAPZCTreeManager::ZoomToRect",
mAPZCTreeManager,
&IAPZCTreeManager::ZoomToRect,
ScrollableLayerGuid(aGuid.mLayersId, presShellId, viewId),
zoomToRect,
ZoomToRectBehavior::DEFAULT_BEHAVIOR));
} }
} }

Просмотреть файл

@ -221,6 +221,12 @@ APZCTreeManagerChild::SetLongTapEnabled(bool aTapGestureEnabled)
SendSetLongTapEnabled(aTapGestureEnabled); SendSetLongTapEnabled(aTapGestureEnabled);
} }
void
APZCTreeManagerChild::ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY)
{
SendProcessTouchVelocity(aTimestampMs, aSpeedY);
}
void void
APZCTreeManagerChild::UpdateWheelTransaction( APZCTreeManagerChild::UpdateWheelTransaction(
LayoutDeviceIntPoint aRefPoint, LayoutDeviceIntPoint aRefPoint,

Просмотреть файл

@ -78,6 +78,9 @@ public:
void void
SetLongTapEnabled(bool aTapGestureEnabled) override; SetLongTapEnabled(bool aTapGestureEnabled) override;
void
ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY) override;
void void
ProcessUnhandledEvent( ProcessUnhandledEvent(
LayoutDeviceIntPoint* aRefPoint, LayoutDeviceIntPoint* aRefPoint,

Просмотреть файл

@ -166,11 +166,7 @@ APZCTreeManagerParent::RecvReceiveKeyboardInputEvent(
mozilla::ipc::IPCResult mozilla::ipc::IPCResult
APZCTreeManagerParent::RecvSetKeyboardMap(const KeyboardMap& aKeyboardMap) APZCTreeManagerParent::RecvSetKeyboardMap(const KeyboardMap& aKeyboardMap)
{ {
APZThreadUtils::RunOnControllerThread(NewRunnableMethod<KeyboardMap>( mTreeManager->SetKeyboardMap(aKeyboardMap);
"layers::IAPZCTreeManager::SetKeyboardMap",
mTreeManager,
&IAPZCTreeManager::SetKeyboardMap,
aKeyboardMap));
return IPC_OK(); return IPC_OK();
} }
@ -187,12 +183,7 @@ APZCTreeManagerParent::RecvZoomToRect(
return IPC_FAIL_NO_REASON(this); return IPC_FAIL_NO_REASON(this);
} }
APZThreadUtils::RunOnControllerThread( mTreeManager->ZoomToRect(aGuid, aRect, aFlags);
NewRunnableMethod<ScrollableLayerGuid, CSSRect, uint32_t>(
"layers::IAPZCTreeManager::ZoomToRect",
mTreeManager,
&IAPZCTreeManager::ZoomToRect,
aGuid, aRect, aFlags));
return IPC_OK(); return IPC_OK();
} }
@ -253,11 +244,7 @@ APZCTreeManagerParent::RecvUpdateZoomConstraints(
mozilla::ipc::IPCResult mozilla::ipc::IPCResult
APZCTreeManagerParent::RecvSetDPI(const float& aDpiValue) APZCTreeManagerParent::RecvSetDPI(const float& aDpiValue)
{ {
APZThreadUtils::RunOnControllerThread(NewRunnableMethod<float>( mTreeManager->SetDPI(aDpiValue);
"layers::IAPZCTreeManager::SetDPI",
mTreeManager,
&IAPZCTreeManager::SetDPI,
aDpiValue));
return IPC_OK(); return IPC_OK();
} }
@ -344,6 +331,15 @@ APZCTreeManagerParent::RecvSetLongTapEnabled(const bool& aTapGestureEnabled)
return IPC_OK(); return IPC_OK();
} }
mozilla::ipc::IPCResult
APZCTreeManagerParent::RecvProcessTouchVelocity(
const uint32_t& aTimestampMs,
const float& aSpeedY)
{
mTreeManager->ProcessTouchVelocity(aTimestampMs, aSpeedY);
return IPC_OK();
}
mozilla::ipc::IPCResult mozilla::ipc::IPCResult
APZCTreeManagerParent::RecvUpdateWheelTransaction( APZCTreeManagerParent::RecvUpdateWheelTransaction(
const LayoutDeviceIntPoint& aRefPoint, const LayoutDeviceIntPoint& aRefPoint,

Просмотреть файл

@ -134,6 +134,11 @@ public:
mozilla::ipc::IPCResult mozilla::ipc::IPCResult
RecvSetLongTapEnabled(const bool& aTapGestureEnabled) override; RecvSetLongTapEnabled(const bool& aTapGestureEnabled) override;
mozilla::ipc::IPCResult
RecvProcessTouchVelocity(
const uint32_t& aTimestampMs,
const float& aSpeedY) override;
mozilla::ipc::IPCResult mozilla::ipc::IPCResult
RecvUpdateWheelTransaction( RecvUpdateWheelTransaction(
const LayoutDeviceIntPoint& aRefPoint, const LayoutDeviceIntPoint& aRefPoint,

Просмотреть файл

@ -85,6 +85,8 @@ parent:
async SetLongTapEnabled(bool aTapGestureEnabled); async SetLongTapEnabled(bool aTapGestureEnabled);
async ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY);
// The following messages are used to // The following messages are used to
// implement the ReceiveInputEvent methods // implement the ReceiveInputEvent methods

Просмотреть файл

@ -59,25 +59,6 @@ RemoteContentController::HandleTapOnMainThread(TapType aTapType,
} }
} }
void
RemoteContentController::HandleTapOnCompositorThread(TapType aTapType,
LayoutDevicePoint aPoint,
Modifiers aModifiers,
ScrollableLayerGuid aGuid,
uint64_t aInputBlockId)
{
MOZ_ASSERT(XRE_IsGPUProcess());
MOZ_ASSERT(MessageLoop::current() == mCompositorThread);
// The raw pointer to APZCTreeManagerParent is ok here because we are on the
// compositor thread.
APZCTreeManagerParent* apzctmp =
CompositorBridgeParent::GetApzcTreeManagerParentForRoot(aGuid.mLayersId);
if (apzctmp) {
Unused << apzctmp->SendHandleTap(aTapType, aPoint, aModifiers, aGuid, aInputBlockId);
}
}
void void
RemoteContentController::HandleTap(TapType aTapType, RemoteContentController::HandleTap(TapType aTapType,
const LayoutDevicePoint& aPoint, const LayoutDevicePoint& aPoint,
@ -88,24 +69,16 @@ RemoteContentController::HandleTap(TapType aTapType,
APZThreadUtils::AssertOnControllerThread(); APZThreadUtils::AssertOnControllerThread();
if (XRE_GetProcessType() == GeckoProcessType_GPU) { if (XRE_GetProcessType() == GeckoProcessType_GPU) {
if (MessageLoop::current() == mCompositorThread) { MOZ_ASSERT(MessageLoop::current() == mCompositorThread);
HandleTapOnCompositorThread(aTapType, aPoint, aModifiers, aGuid, aInputBlockId);
} else { // The raw pointer to APZCTreeManagerParent is ok here because we are on the
// We have to send messages from the compositor thread // compositor thread.
mCompositorThread->PostTask(NewRunnableMethod<TapType, APZCTreeManagerParent* apzctmp =
LayoutDevicePoint, CompositorBridgeParent::GetApzcTreeManagerParentForRoot(aGuid.mLayersId);
Modifiers, if (apzctmp) {
ScrollableLayerGuid, Unused << apzctmp->SendHandleTap(aTapType, aPoint, aModifiers, aGuid, aInputBlockId);
uint64_t>(
"layers::RemoteContentController::HandleTapOnCompositorThread",
this,
&RemoteContentController::HandleTapOnCompositorThread,
aTapType,
aPoint,
aModifiers,
aGuid,
aInputBlockId));
} }
return; return;
} }
@ -132,24 +105,6 @@ RemoteContentController::HandleTap(TapType aTapType,
} }
} }
void
RemoteContentController::NotifyPinchGestureOnCompositorThread(
PinchGestureInput::PinchGestureType aType,
const ScrollableLayerGuid& aGuid,
LayoutDeviceCoord aSpanChange,
Modifiers aModifiers)
{
MOZ_ASSERT(MessageLoop::current() == mCompositorThread);
// The raw pointer to APZCTreeManagerParent is ok here because we are on the
// compositor thread.
APZCTreeManagerParent* apzctmp =
CompositorBridgeParent::GetApzcTreeManagerParentForRoot(aGuid.mLayersId);
if (apzctmp) {
Unused << apzctmp->SendNotifyPinchGesture(aType, aGuid, aSpanChange, aModifiers);
}
}
void void
RemoteContentController::NotifyPinchGesture(PinchGestureInput::PinchGestureType aType, RemoteContentController::NotifyPinchGesture(PinchGestureInput::PinchGestureType aType,
const ScrollableLayerGuid& aGuid, const ScrollableLayerGuid& aGuid,
@ -164,22 +119,16 @@ RemoteContentController::NotifyPinchGesture(PinchGestureInput::PinchGestureType
// If we're in the GPU process, try to find a handle to the parent process // If we're in the GPU process, try to find a handle to the parent process
// and send it there. // and send it there.
if (XRE_IsGPUProcess()) { if (XRE_IsGPUProcess()) {
if (MessageLoop::current() == mCompositorThread) { MOZ_ASSERT(MessageLoop::current() == mCompositorThread);
NotifyPinchGestureOnCompositorThread(aType, aGuid, aSpanChange, aModifiers);
} else { // The raw pointer to APZCTreeManagerParent is ok here because we are on the
mCompositorThread->PostTask(NewRunnableMethod<PinchGestureInput::PinchGestureType, // compositor thread.
ScrollableLayerGuid, APZCTreeManagerParent* apzctmp =
LayoutDeviceCoord, CompositorBridgeParent::GetApzcTreeManagerParentForRoot(aGuid.mLayersId);
Modifiers>( if (apzctmp) {
"layers::RemoteContentController::NotifyPinchGestureOnCompositorThread", Unused << apzctmp->SendNotifyPinchGesture(aType, aGuid, aSpanChange, aModifiers);
this, return;
&RemoteContentController::NotifyPinchGestureOnCompositorThread,
aType,
aGuid,
aSpanChange,
aModifiers));
} }
return;
} }
// If we're in the parent process, handle it directly. We don't have a handle // If we're in the parent process, handle it directly. We don't have a handle

Просмотреть файл

@ -90,15 +90,6 @@ private:
Modifiers aModifiers, Modifiers aModifiers,
ScrollableLayerGuid aGuid, ScrollableLayerGuid aGuid,
uint64_t aInputBlockId); uint64_t aInputBlockId);
void HandleTapOnCompositorThread(TapType aType,
LayoutDevicePoint aPoint,
Modifiers aModifiers,
ScrollableLayerGuid aGuid,
uint64_t aInputBlockId);
void NotifyPinchGestureOnCompositorThread(PinchGestureInput::PinchGestureType aType,
const ScrollableLayerGuid& aGuid,
LayoutDeviceCoord aSpanChange,
Modifiers aModifiers);
void CancelAutoscrollInProcess(const ScrollableLayerGuid& aScrollId); void CancelAutoscrollInProcess(const ScrollableLayerGuid& aScrollId);
void CancelAutoscrollCrossProcess(const ScrollableLayerGuid& aScrollId); void CancelAutoscrollCrossProcess(const ScrollableLayerGuid& aScrollId);

Просмотреть файл

@ -933,27 +933,14 @@ nsBaseWidget::CreateRootContentController()
void nsBaseWidget::ConfigureAPZCTreeManager() void nsBaseWidget::ConfigureAPZCTreeManager()
{ {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mAPZC); MOZ_ASSERT(mAPZC);
ConfigureAPZControllerThread(); ConfigureAPZControllerThread();
float dpi = GetDPI(); mAPZC->SetDPI(GetDPI());
// On Android the main thread is not the controller thread
APZThreadUtils::RunOnControllerThread(NewRunnableMethod<float>(
"layers::IAPZCTreeManager::SetDPI",
mAPZC,
&IAPZCTreeManager::SetDPI,
dpi));
if (gfxPrefs::APZKeyboardEnabled()) { if (gfxPrefs::APZKeyboardEnabled()) {
KeyboardMap map = nsXBLWindowKeyHandler::CollectKeyboardShortcuts(); mAPZC->SetKeyboardMap(nsXBLWindowKeyHandler::CollectKeyboardShortcuts());
// On Android the main thread is not the controller thread
APZThreadUtils::RunOnControllerThread(NewRunnableMethod<KeyboardMap>(
"layers::IAPZCTreeManager::SetKeyboardMap",
mAPZC,
&IAPZCTreeManager::SetKeyboardMap,
map));
} }
RefPtr<IAPZCTreeManager> treeManager = mAPZC; // for capture by the lambdas RefPtr<IAPZCTreeManager> treeManager = mAPZC; // for capture by the lambdas
@ -1933,14 +1920,7 @@ nsBaseWidget::ZoomToRect(const uint32_t& aPresShellId,
return; return;
} }
uint64_t layerId = mCompositorSession->RootLayerTreeId(); uint64_t layerId = mCompositorSession->RootLayerTreeId();
APZThreadUtils::RunOnControllerThread( mAPZC->ZoomToRect(ScrollableLayerGuid(layerId, aPresShellId, aViewId), aRect, aFlags);
NewRunnableMethod<ScrollableLayerGuid, CSSRect, uint32_t>(
"layers::IAPZCTreeManager::ZoomToRect",
mAPZC,
&IAPZCTreeManager::ZoomToRect,
ScrollableLayerGuid(layerId, aPresShellId, aViewId),
aRect,
aFlags));
} }
#ifdef ACCESSIBILITY #ifdef ACCESSIBILITY