Bug 1237343 - Replace uses of mozilla::Vector with nsTArray. r?botond
MozReview-Commit-ID: BBLWj3GJ3dE
--- a/gfx/layers/apz/src/APZCTreeManager.h
+++ b/gfx/layers/apz/src/APZCTreeManager.h
@@ -14,17 +14,16 @@
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
#include "mozilla/EventForwards.h" // for WidgetInputEvent, nsEventStatus
#include "mozilla/gfx/Logging.h" // for gfx::TreeLog
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
#include "mozilla/layers/APZUtils.h" // for HitTestResult
#include "mozilla/layers/TouchCounter.h"// for TouchCounter
#include "mozilla/Mutex.h" // for Mutex
#include "mozilla/TimeStamp.h" // for mozilla::TimeStamp
-#include "mozilla/Vector.h" // for mozilla::Vector
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
#include "nsTArrayForwardDeclare.h" // for nsTArray, nsTArray_Impl, etc
#include "Units.h" // for CSSPoint, CSSRect, etc
namespace mozilla {
class InputData;
--- a/gfx/layers/apz/src/AsyncPanZoomAnimation.h
+++ b/gfx/layers/apz/src/AsyncPanZoomAnimation.h
@@ -5,19 +5,19 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_layers_AsyncPanZoomAnimation_h_
#define mozilla_layers_AsyncPanZoomAnimation_h_
#include "base/message_loop.h"
#include "mozilla/RefPtr.h"
#include "mozilla/TimeStamp.h"
-#include "mozilla/Vector.h"
#include "FrameMetrics.h"
#include "nsISupportsImpl.h"
+#include "nsTArray.h"
namespace mozilla {
namespace layers {
class WheelScrollAnimation;
class SmoothScrollAnimation;
class AsyncPanZoomAnimation {
@@ -41,17 +41,17 @@ public:
return DoSample(aFrameMetrics, aDelta);
}
/**
* Get the deferred tasks in |mDeferredTasks| and place them in |aTasks|. See
* |mDeferredTasks| for more information. Clears |mDeferredTasks|.
*/
- Vector<Task*> TakeDeferredTasks() {
+ nsTArray<Task*> TakeDeferredTasks() {
return Move(mDeferredTasks);
}
virtual WheelScrollAnimation* AsWheelScrollAnimation() {
return nullptr;
}
virtual SmoothScrollAnimation* AsSmoothScrollAnimation() {
return nullptr;
@@ -66,15 +66,15 @@ protected:
virtual ~AsyncPanZoomAnimation()
{ }
/**
* Tasks scheduled for execution after the APZC's mMonitor is released.
* Derived classes can add tasks here in Sample(), and the APZC can call
* ExecuteDeferredTasks() to execute them.
*/
- Vector<Task*> mDeferredTasks;
+ nsTArray<Task*> mDeferredTasks;
};
} // namespace layers
} // namespace mozilla
#endif // mozilla_layers_AsyncPanZoomAnimation_h_
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -511,21 +511,20 @@ public:
APZC_LOG("%p ending fling animation. overscrolled=%d\n", &mApzc, mApzc.IsOverscrolled());
// This APZC or an APZC further down the handoff chain may be be overscrolled.
// Start a snap-back animation on the overscrolled APZC.
// Note:
// This needs to be a deferred task even though it can safely run
// while holding mMonitor, because otherwise, if the overscrolled APZC
// is this one, then the SetState(NOTHING) in UpdateAnimation will
// stomp on the SetState(SNAP_BACK) it does.
- if (!mDeferredTasks.append(NewRunnableMethod(mOverscrollHandoffChain.get(),
- &OverscrollHandoffChain::SnapBackOverscrolledApzc,
- &mApzc))) {
- MOZ_CRASH();
- }
+ mDeferredTasks.AppendElement(
+ NewRunnableMethod(mOverscrollHandoffChain.get(),
+ &OverscrollHandoffChain::SnapBackOverscrolledApzc,
+ &mApzc));
return false;
}
// AdjustDisplacement() zeroes out the Axis velocity if we're in overscroll.
// Since we need to hand off the velocity to the tree manager in such a case,
// we save it here. Would be ParentLayerVector instead of ParentLayerPoint
// if we had vector classes.
ParentLayerPoint velocity = mApzc.GetVelocityVector();
@@ -564,23 +563,22 @@ public:
// there is an APZC further in the handoff chain which is pannable; if
// there isn't, we take the new fling ourselves, entering an overscrolled
// state.
// Note: APZC is holding mMonitor, so directly calling
// HandleFlingOverscroll() (which acquires the tree lock) would violate
// the lock ordering. Instead we schedule HandleFlingOverscroll() to be
// called after mMonitor is released.
APZC_LOG("%p fling went into overscroll, handing off with velocity %s\n", &mApzc, Stringify(velocity).c_str());
- if (!mDeferredTasks.append(NewRunnableMethod(&mApzc,
- &AsyncPanZoomController::HandleFlingOverscroll,
- velocity,
- mOverscrollHandoffChain,
- mScrolledApzc))) {
- MOZ_CRASH();
- }
+ mDeferredTasks.AppendElement(
+ NewRunnableMethod(&mApzc,
+ &AsyncPanZoomController::HandleFlingOverscroll,
+ velocity,
+ mOverscrollHandoffChain,
+ mScrolledApzc));
// If there is a remaining velocity on this APZC, continue this fling
// as well. (This fling and the handed-off fling will run concurrently.)
// Note that AdjustDisplacement() will have zeroed out the velocity
// along the axes where we're overscrolled.
return !IsZero(mApzc.GetVelocityVector());
}
@@ -698,20 +696,19 @@ public:
// animation too early. We do still want to request a fling snap, though,
// in case the end of the axis at which we're overscrolled is not a valid
// snap point, so we request one now. If there are no snap points, this will
// do nothing. If there are snap points, we'll get a scrollTo that snaps us
// back to the nearest valid snap point.
// The scroll snapping is done in a deferred task, otherwise the state
// change to NOTHING caused by the overscroll animation ending would
// clobber a possible state change to SMOOTH_SCROLL in ScrollSnap().
- if (!mDeferredTasks.append(NewRunnableMethod(&mApzc,
- &AsyncPanZoomController::ScrollSnap))) {
- MOZ_CRASH();
- }
+ mDeferredTasks.AppendElement(
+ NewRunnableMethod(&mApzc,
+ &AsyncPanZoomController::ScrollSnap));
return false;
}
return true;
}
virtual bool WantsRepaints() override
{
return false;
@@ -817,22 +814,20 @@ public:
// that this is not noticeable. The target APZC is chosen by seeing if
// there is an APZC further in the handoff chain which is pannable; if
// there isn't, we take the new fling ourselves, entering an overscrolled
// state.
// Note: APZC is holding mMonitor, so directly calling
// HandleSmoothScrollOverscroll() (which acquires the tree lock) would violate
// the lock ordering. Instead we schedule HandleSmoothScrollOverscroll() to be
// called after mMonitor is released.
- if (!mDeferredTasks.append(NewRunnableMethod(&mApzc,
- &AsyncPanZoomController::HandleSmoothScrollOverscroll,
- velocity))) {
- MOZ_CRASH();
- }
-
+ mDeferredTasks.AppendElement(
+ NewRunnableMethod(&mApzc,
+ &AsyncPanZoomController::HandleSmoothScrollOverscroll,
+ velocity));
return false;
}
return true;
}
void SetDestination(const nsPoint& aNewDestination) {
mXAxisModel.SetDestination(static_cast<int32_t>(aNewDestination.x));
@@ -3060,17 +3055,17 @@ AsyncPanZoomController::RequestContentRe
}
controller->RequestContentRepaint(aFrameMetrics);
mExpectedGeckoMetrics = aFrameMetrics;
mLastPaintRequestMetrics = aFrameMetrics;
}
bool AsyncPanZoomController::UpdateAnimation(const TimeStamp& aSampleTime,
- Vector<Task*>* aOutDeferredTasks)
+ nsTArray<Task*>* aOutDeferredTasks)
{
APZThreadUtils::AssertOnCompositorThread();
// This function may get called multiple with the same sample time, because
// there may be multiple layers with this APZC, and each layer invokes this
// function during composition. However we only want to do one animation step
// per composition so we need to deduplicate these calls first.
if (mLastSampleTime == aSampleTime) {
@@ -3161,17 +3156,17 @@ bool AsyncPanZoomController::AdvanceAnim
// The eventual return value of this function. The compositor needs to know
// whether or not to advance by a frame as soon as it can. For example, if a
// fling is happening, it has to keep compositing so that the animation is
// smooth. If an animation frame is requested, it is the compositor's
// responsibility to schedule a composite.
mAsyncTransformAppliedToContent = false;
bool requestAnimationFrame = false;
- Vector<Task*> deferredTasks;
+ nsTArray<Task*> deferredTasks;
{
ReentrantMonitorAutoEnter lock(mMonitor);
requestAnimationFrame = UpdateAnimation(aSampleTime, &deferredTasks);
{ // scope lock
MutexAutoLock lock(mCheckerboardEventLock);
@@ -3183,17 +3178,17 @@ bool AsyncPanZoomController::AdvanceAnim
}
}
}
// Execute any deferred tasks queued up by mAnimation's Sample() (called by
// UpdateAnimation()). This needs to be done after the monitor is released
// since the tasks are allowed to call APZCTreeManager methods which can grab
// the tree lock.
- for (uint32_t i = 0; i < deferredTasks.length(); ++i) {
+ for (uint32_t i = 0; i < deferredTasks.Length(); ++i) {
deferredTasks[i]->Run();
delete deferredTasks[i];
}
// One of the deferred tasks may have started a new animation. In this case,
// we want to ask the compositor to schedule a new composite.
requestAnimationFrame |= (mAnimation != nullptr);
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -22,16 +22,17 @@
#include "Axis.h"
#include "InputQueue.h"
#include "APZUtils.h"
#include "Layers.h" // for Layer::ScrollDirection
#include "LayersTypes.h"
#include "mozilla/gfx/Matrix.h"
#include "nsIScrollableFrame.h"
#include "nsRegion.h"
+#include "nsTArray.h"
#include "PotentialCheckerboardDurationTracker.h"
#include "base/message_loop.h"
namespace mozilla {
namespace ipc {
@@ -156,17 +157,17 @@ public:
* This may be called multiple times with the same timestamp.
*
* The return value indicates whether or not any currently running animation
* should continue. If true, the compositor should schedule another composite.
*/
bool AdvanceAnimations(const TimeStamp& aSampleTime);
bool UpdateAnimation(const TimeStamp& aSampleTime,
- Vector<Task*>* aOutDeferredTasks);
+ nsTArray<Task*>* aOutDeferredTasks);
/**
* A shadow layer update has arrived. |aScrollMetdata| is the new ScrollMetadata
* for the container layer corresponding to this APZC.
* |aIsFirstPaint| is a flag passed from the shadow
* layers code indicating that the scroll metadata being sent with this call are
* the initial metadata and the initial paint of the frame has just happened.
*/