author | Kartikaya Gupta <kgupta@mozilla.com> |
Fri, 24 Oct 2014 13:29:35 -0400 | |
changeset 212296 | b6d24dc1b01f8904165b5278363f7d67235384f8 |
parent 212295 | a5e6dce29017c3c95f9d4519b867743205759713 |
child 212297 | 1090f3645eb3c17beeddfc22ee2a441ba781c93b |
push id | 27704 |
push user | kwierso@gmail.com |
push date | Sat, 25 Oct 2014 01:25:30 +0000 |
treeherder | mozilla-central@e37231060eb4 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | botond |
bugs | 1083395 |
milestone | 36.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -1006,20 +1006,16 @@ AsyncPanZoomController::ArePointerEvents bool consumable = (aTouchPoints == 1 ? pannable : zoomable); if (!consumable) { return false; } return true; } -nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent, uint64_t* aOutInputBlockId) { - return GetInputQueue()->ReceiveInputEvent(this, aEvent, aOutInputBlockId); -} - nsEventStatus AsyncPanZoomController::HandleInputEvent(const InputData& aEvent) { AssertOnControllerThread(); nsEventStatus rv = nsEventStatus_eIgnore; switch (aEvent.mInputType) { case MULTITOUCH_INPUT: { const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput(); @@ -2847,26 +2843,16 @@ void AsyncPanZoomController::ZoomToRect( endZoomToMetrics.GetZoom())); // Schedule a repaint now, so the new displayport will be painted before the // animation finishes. RequestContentRepaint(endZoomToMetrics); } } -void -AsyncPanZoomController::ContentReceivedTouch(uint64_t aInputBlockId, bool aPreventDefault) { - GetInputQueue()->ContentReceivedTouch(aInputBlockId, aPreventDefault); -} - -void -AsyncPanZoomController::SetAllowedTouchBehavior(uint64_t aInputBlockId, const nsTArray<TouchBehaviorFlags>& aBehaviors) { - GetInputQueue()->SetAllowedTouchBehavior(aInputBlockId, aBehaviors); -} - bool AsyncPanZoomController::NeedToWaitForContent() const { return (mFrameMetrics.GetMayHaveTouchListeners() || mFrameMetrics.GetMayHaveTouchCaret()); } TouchBlockState* AsyncPanZoomController::CurrentTouchBlock()
--- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -111,26 +111,16 @@ public: */ static void InitializeGlobalState(); // -------------------------------------------------------------------------- // These methods must only be called on the controller/UI thread. // /** - * General handler for incoming input events. Manipulates the frame metrics - * based on what type of input it is. For example, a PinchGestureEvent will - * cause scaling. This should only be called externally to this class. - * HandleInputEvent() should be used internally. - * See the documentation on APZCTreeManager::ReceiveInputEvent for info on - * return values from this function. - */ - nsEventStatus ReceiveInputEvent(const InputData& aEvent, uint64_t* aOutInputBlockId); - - /** * Kicks an animation to zoom to a rect. This may be either a zoom out or zoom * in. The actual animation is done on the compositor thread after being set * up. */ void ZoomToRect(CSSRect aRect); /** * Updates any zoom constraints contained in the <meta name="viewport"> tag. @@ -573,16 +563,21 @@ protected: /** * Gets the pointer to the apzc tree manager. All the access to tree manager * should be made via this method and not via private variable since this method * ensures that no lock is set. */ APZCTreeManager* GetApzcTreeManager() const; /** + * Gets a ref to the input queue that is shared across the entire tree manager. + */ + const nsRefPtr<InputQueue>& GetInputQueue() const; + + /** * Timeout function for mozbrowserasyncscroll event. Because we throttle * mozbrowserasyncscroll events in some conditions, this function ensures * that the last mozbrowserasyncscroll event will be fired after a period of * time. */ void FireAsyncScrollOnTimeout(); /** @@ -626,17 +621,16 @@ protected: compositor thread. */ nsRefPtr<GeckoContentController> mGeckoContentController; nsRefPtr<GestureEventListener> mGestureEventListener; mutable Monitor mRefPtrMonitor; /* Utility functions that return a addrefed pointer to the corresponding fields. */ already_AddRefed<GeckoContentController> GetGeckoContentController() const; already_AddRefed<GestureEventListener> GetGestureEventListener() const; - const nsRefPtr<InputQueue>& GetInputQueue() const; // If we are sharing our frame metrics with content across processes bool mSharingFrameMetricsAcrossProcesses; /* Utility function to get the Compositor with which we share the FrameMetrics. This function is only callable from the compositor thread. */ PCompositorParent* GetSharedFrameMetricsCompositor(); protected: @@ -770,26 +764,16 @@ private: /* =================================================================== * The functions and members in this section are used to manage * blocks of touch events and the state needed to deal with content * listeners. */ public: /** - * See InputQueue::ContentReceivedTouch - */ - void ContentReceivedTouch(uint64_t aInputBlockId, bool aPreventDefault); - - /** - * See InputQueue::SetAllowedTouchBehavior - */ - void SetAllowedTouchBehavior(uint64_t aInputBlockId, const nsTArray<TouchBehaviorFlags>& aBehaviors); - - /** * Flush a repaint request if one is needed, without throttling it with the * paint throttler. */ void FlushRepaintForNewInputBlock(); /** * Given the number of touch points in an input event and touch block they * belong to, check if the event can result in a panning/zooming behavior.
--- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp +++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp @@ -129,16 +129,28 @@ public: class TestAsyncPanZoomController : public AsyncPanZoomController { public: TestAsyncPanZoomController(uint64_t aLayersId, MockContentController* aMcc, TestAPZCTreeManager* aTreeManager, GestureBehavior aBehavior = DEFAULT_GESTURES) : AsyncPanZoomController(aLayersId, aTreeManager, aTreeManager->GetInputQueue(), aMcc, aBehavior) {} + nsEventStatus ReceiveInputEvent(const InputData& aEvent, uint64_t* aOutInputBlockId) { + return GetInputQueue()->ReceiveInputEvent(this, aEvent, aOutInputBlockId); + } + + void ContentReceivedTouch(uint64_t aInputBlockId, bool aPreventDefault) { + GetInputQueue()->ContentReceivedTouch(aInputBlockId, aPreventDefault); + } + + void SetAllowedTouchBehavior(uint64_t aInputBlockId, const nsTArray<TouchBehaviorFlags>& aBehaviors) { + GetInputQueue()->SetAllowedTouchBehavior(aInputBlockId, aBehaviors); + } + void SetFrameMetrics(const FrameMetrics& metrics) { ReentrantMonitorAutoEnter lock(mMonitor); mFrameMetrics = metrics; } FrameMetrics& GetFrameMetrics() { ReentrantMonitorAutoEnter lock(mMonitor); return mFrameMetrics; @@ -242,57 +254,57 @@ class APZCGestureDetectorTester : public public: APZCGestureDetectorTester() : APZCBasicTester(AsyncPanZoomController::USE_GESTURE_DETECTOR) { } }; static nsEventStatus -ApzcDown(AsyncPanZoomController* apzc, int aX, int aY, int aTime, uint64_t* aOutInputBlockId = nullptr) +ApzcDown(TestAsyncPanZoomController* apzc, int aX, int aY, int aTime, uint64_t* aOutInputBlockId = nullptr) { MultiTouchInput mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_START, aTime, TimeStamp(), 0); mti.mTouches.AppendElement(SingleTouchData(0, ScreenIntPoint(aX, aY), ScreenSize(0, 0), 0, 0)); return apzc->ReceiveInputEvent(mti, aOutInputBlockId); } static nsEventStatus -ApzcUp(AsyncPanZoomController* apzc, int aX, int aY, int aTime) +ApzcUp(TestAsyncPanZoomController* apzc, int aX, int aY, int aTime) { MultiTouchInput mti = MultiTouchInput(MultiTouchInput::MULTITOUCH_END, aTime, TimeStamp(), 0); mti.mTouches.AppendElement(SingleTouchData(0, ScreenIntPoint(aX, aY), ScreenSize(0, 0), 0, 0)); return apzc->ReceiveInputEvent(mti, nullptr); } static void -ApzcTap(AsyncPanZoomController* aApzc, int aX, int aY, int& aTime, int aTapLength, +ApzcTap(TestAsyncPanZoomController* aApzc, int aX, int aY, int& aTime, int aTapLength, nsEventStatus (*aOutEventStatuses)[2] = nullptr) { nsEventStatus status = ApzcDown(aApzc, aX, aY, aTime); if (aOutEventStatuses) { (*aOutEventStatuses)[0] = status; } aTime += aTapLength; status = ApzcUp(aApzc, aX, aY, aTime); if (aOutEventStatuses) { (*aOutEventStatuses)[1] = status; } } static void -ApzcTapAndCheckStatus(AsyncPanZoomController* aApzc, int aX, int aY, int& aTime, int aTapLength) +ApzcTapAndCheckStatus(TestAsyncPanZoomController* aApzc, int aX, int aY, int& aTime, int aTapLength) { nsEventStatus statuses[2]; ApzcTap(aApzc, aX, aY, aTime, aTapLength, &statuses); EXPECT_EQ(nsEventStatus_eConsumeDoDefault, statuses[0]); EXPECT_EQ(nsEventStatus_eConsumeDoDefault, statuses[1]); } static void -ApzcPan(AsyncPanZoomController* aApzc, +ApzcPan(TestAsyncPanZoomController* aApzc, int& aTime, int aTouchStartY, int aTouchEndY, bool aKeepFingerDown = false, nsTArray<uint32_t>* aAllowedTouchBehaviors = nullptr, nsEventStatus (*aOutEventStatuses)[4] = nullptr, uint64_t* aOutInputBlockId = nullptr) { @@ -349,17 +361,17 @@ ApzcPan(AsyncPanZoomController* aApzc, aTime += TIME_BETWEEN_TOUCH_EVENT; } /* * Dispatches mock touch events to the apzc and checks whether apzc properly * consumed them and triggered scrolling behavior. */ static void -ApzcPanAndCheckStatus(AsyncPanZoomController* aApzc, +ApzcPanAndCheckStatus(TestAsyncPanZoomController* aApzc, int& aTime, int aTouchStartY, int aTouchEndY, bool aExpectConsumed, nsTArray<uint32_t>* aAllowedTouchBehaviors, uint64_t* aOutInputBlockId = nullptr) { nsEventStatus statuses[4]; // down, move, move, up @@ -373,28 +385,28 @@ ApzcPanAndCheckStatus(AsyncPanZoomContro } else { touchMoveStatus = nsEventStatus_eIgnore; } EXPECT_EQ(touchMoveStatus, statuses[1]); EXPECT_EQ(touchMoveStatus, statuses[2]); } static void -ApzcPanNoFling(AsyncPanZoomController* aApzc, +ApzcPanNoFling(TestAsyncPanZoomController* aApzc, int& aTime, int aTouchStartY, int aTouchEndY, uint64_t* aOutInputBlockId = nullptr) { ApzcPan(aApzc, aTime, aTouchStartY, aTouchEndY, false, nullptr, nullptr, aOutInputBlockId); aApzc->CancelAnimation(); } static void -ApzcPinchWithPinchInput(AsyncPanZoomController* aApzc, +ApzcPinchWithPinchInput(TestAsyncPanZoomController* aApzc, int aFocusX, int aFocusY, float aScale, nsEventStatus (*aOutEventStatuses)[3] = nullptr) { nsEventStatus actualStatus = aApzc->HandleGestureEvent( PinchGestureInput(PinchGestureInput::PINCHGESTURE_START, 0, TimeStamp(), ScreenPoint(aFocusX, aFocusY), 10.0, 10.0, 0)); if (aOutEventStatuses) { @@ -414,32 +426,32 @@ ApzcPinchWithPinchInput(AsyncPanZoomCont // not to turn the pinch into a pan -1.0, -1.0, 0)); if (aOutEventStatuses) { (*aOutEventStatuses)[2] = actualStatus; } } static void -ApzcPinchWithPinchInputAndCheckStatus(AsyncPanZoomController* aApzc, +ApzcPinchWithPinchInputAndCheckStatus(TestAsyncPanZoomController* aApzc, int aFocusX, int aFocusY, float aScale, bool aShouldTriggerPinch) { nsEventStatus statuses[3]; // scalebegin, scale, scaleend ApzcPinchWithPinchInput(aApzc, aFocusX, aFocusY, aScale, &statuses); nsEventStatus expectedStatus = aShouldTriggerPinch ? nsEventStatus_eConsumeNoDefault : nsEventStatus_eIgnore; EXPECT_EQ(expectedStatus, statuses[0]); EXPECT_EQ(expectedStatus, statuses[1]); } static void -ApzcPinchWithTouchInput(AsyncPanZoomController* aApzc, +ApzcPinchWithTouchInput(TestAsyncPanZoomController* aApzc, int aFocusX, int aFocusY, float aScale, int& inputId, nsTArray<uint32_t>* aAllowedTouchBehaviors = nullptr, nsEventStatus (*aOutEventStatuses)[4] = nullptr, uint64_t* aOutInputBlockId = nullptr) { // Having pinch coordinates in float type may cause problems with high-precision scale values // since SingleTouchData accepts integer value. But for trivial tests it should be ok. @@ -488,17 +500,17 @@ ApzcPinchWithTouchInput(AsyncPanZoomCont if (aOutEventStatuses) { (*aOutEventStatuses)[3] = status; } inputId += 2; } static void -ApzcPinchWithTouchInputAndCheckStatus(AsyncPanZoomController* aApzc, +ApzcPinchWithTouchInputAndCheckStatus(TestAsyncPanZoomController* aApzc, int aFocusX, int aFocusY, float aScale, int& inputId, bool aShouldTriggerPinch, nsTArray<uint32_t>* aAllowedTouchBehaviors) { nsEventStatus statuses[4]; // down, move, move, up ApzcPinchWithTouchInput(aApzc, aFocusX, aFocusY, aScale, inputId, aAllowedTouchBehaviors, &statuses); nsEventStatus expectedMoveStatus = aShouldTriggerPinch @@ -1391,17 +1403,17 @@ TEST_F(APZCLongPressTester, LongPressPre TEST_F(APZCLongPressTester, LongPressPreventDefaultWithTouchAction) { SCOPED_GFX_PREF(TouchActionEnabled, bool, true); DoLongPressPreventDefaultTest(mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN | mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN | mozilla::layers::AllowedTouchBehavior::PINCH_ZOOM); } static void -ApzcDoubleTap(AsyncPanZoomController* aApzc, int aX, int aY, int& aTime, +ApzcDoubleTap(TestAsyncPanZoomController* aApzc, int aX, int aY, int& aTime, nsEventStatus (*aOutEventStatuses)[4] = nullptr, uint64_t (*aOutInputBlockIds)[2] = nullptr) { uint64_t blockId; nsEventStatus status = ApzcDown(aApzc, aX, aY, aTime, &blockId); if (aOutEventStatuses) { (*aOutEventStatuses)[0] = status; } @@ -1424,17 +1436,17 @@ ApzcDoubleTap(AsyncPanZoomController* aA aTime += 10; status = ApzcUp(aApzc, aX, aY, aTime); if (aOutEventStatuses) { (*aOutEventStatuses)[3] = status; } } static void -ApzcDoubleTapAndCheckStatus(AsyncPanZoomController* aApzc, int aX, int aY, int& aTime, uint64_t (*aOutInputBlockIds)[2] = nullptr) +ApzcDoubleTapAndCheckStatus(TestAsyncPanZoomController* aApzc, int aX, int aY, int& aTime, uint64_t (*aOutInputBlockIds)[2] = nullptr) { nsEventStatus statuses[4]; ApzcDoubleTap(aApzc, aX, aY, aTime, &statuses, aOutInputBlockIds); EXPECT_EQ(nsEventStatus_eConsumeDoDefault, statuses[0]); EXPECT_EQ(nsEventStatus_eConsumeDoDefault, statuses[1]); EXPECT_EQ(nsEventStatus_eConsumeDoDefault, statuses[2]); EXPECT_EQ(nsEventStatus_eConsumeDoDefault, statuses[3]); } @@ -1781,17 +1793,17 @@ protected: // A simple hit testing test that doesn't involve any transforms on layers. TEST_F(APZHitTestingTester, HitTesting1) { CreateHitTesting1LayerTree(); ScopedLayerTreeRegistration registration(0, root, mcc); // No APZC attached so hit testing will return no APZC at (20,20) nsRefPtr<AsyncPanZoomController> hit = GetTargetAPZC(ScreenPoint(20, 20)); - AsyncPanZoomController* nullAPZC = nullptr; + TestAsyncPanZoomController* nullAPZC = nullptr; EXPECT_EQ(nullAPZC, hit.get()); EXPECT_EQ(Matrix4x4(), transformToApzc); EXPECT_EQ(Matrix4x4(), transformToGecko); uint32_t paintSequenceNumber = 0; // Now we have a root APZC that will match the page SetScrollableFrameMetrics(root, FrameMetrics::START_SCROLL_ID); @@ -1852,19 +1864,19 @@ TEST_F(APZHitTestingTester, HitTesting2) manager->UpdatePanZoomControllerTree(nullptr, root, false, 0, 0); // At this point, the following holds (all coordinates in screen pixels): // layers[0] has content from (0,0)-(200,200), clipped by composition bounds (0,0)-(100,100) // layers[1] has content from (10,10)-(90,90), clipped by composition bounds (10,10)-(50,50) // layers[2] has content from (20,60)-(100,100). no clipping as it's not a scrollable layer // layers[3] has content from (20,60)-(180,140), clipped by composition bounds (20,60)-(100,100) - AsyncPanZoomController* apzcroot = ApzcOf(root); - AsyncPanZoomController* apzc1 = ApzcOf(layers[1]); - AsyncPanZoomController* apzc3 = ApzcOf(layers[3]); + TestAsyncPanZoomController* apzcroot = ApzcOf(root); + TestAsyncPanZoomController* apzc1 = ApzcOf(layers[1]); + TestAsyncPanZoomController* apzc3 = ApzcOf(layers[3]); // Hit an area that's clearly on the root layer but not any of the child layers. nsRefPtr<AsyncPanZoomController> hit = GetTargetAPZC(ScreenPoint(75, 25)); EXPECT_EQ(apzcroot, hit.get()); EXPECT_EQ(Point(75, 25), transformToApzc * Point(75, 25)); EXPECT_EQ(Point(75, 25), transformToGecko * Point(75, 25)); // Hit an area on the root that would be on layers[3] if layers[2] @@ -1962,17 +1974,17 @@ TEST_F(APZCTreeManagerTester, Scrollable CreateSimpleMultiLayerTree(); ScopedLayerTreeRegistration registration(0, root, mcc); // both layers have the same scrollId SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID); SetScrollableFrameMetrics(layers[2], FrameMetrics::START_SCROLL_ID); manager->UpdatePanZoomControllerTree(nullptr, root, false, 0, 0); - AsyncPanZoomController* nullAPZC = nullptr; + TestAsyncPanZoomController* nullAPZC = nullptr; // so they should have the same APZC EXPECT_FALSE(layers[0]->HasScrollableFrameMetrics()); EXPECT_NE(nullAPZC, ApzcOf(layers[1])); EXPECT_NE(nullAPZC, ApzcOf(layers[2])); EXPECT_EQ(ApzcOf(layers[1]), ApzcOf(layers[2])); // Change the scrollId of layers[1], and verify the APZC changes SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID + 1); @@ -2003,17 +2015,17 @@ TEST_F(APZCTreeManagerTester, Bug1068268 EXPECT_EQ(ApzcOf(layers[2]), ApzcOf(layers[6])->GetParent()); } TEST_F(APZHitTestingTester, ComplexMultiLayerTree) { CreateComplexMultiLayerTree(); ScopedLayerTreeRegistration registration(0, root, mcc); manager->UpdatePanZoomControllerTree(nullptr, root, false, 0, 0); - AsyncPanZoomController* nullAPZC = nullptr; + TestAsyncPanZoomController* nullAPZC = nullptr; // Ensure all the scrollable layers have an APZC EXPECT_FALSE(layers[0]->HasScrollableFrameMetrics()); EXPECT_NE(nullAPZC, ApzcOf(layers[1])); EXPECT_NE(nullAPZC, ApzcOf(layers[2])); EXPECT_FALSE(layers[3]->HasScrollableFrameMetrics()); EXPECT_NE(nullAPZC, ApzcOf(layers[4])); EXPECT_FALSE(layers[5]->HasScrollableFrameMetrics()); EXPECT_NE(nullAPZC, ApzcOf(layers[6])); @@ -2028,20 +2040,20 @@ TEST_F(APZHitTestingTester, ComplexMulti EXPECT_NE(ApzcOf(layers[1]), ApzcOf(layers[4])); EXPECT_NE(ApzcOf(layers[1]), ApzcOf(layers[7])); EXPECT_NE(ApzcOf(layers[1]), ApzcOf(layers[9])); EXPECT_NE(ApzcOf(layers[4]), ApzcOf(layers[7])); EXPECT_NE(ApzcOf(layers[4]), ApzcOf(layers[9])); EXPECT_NE(ApzcOf(layers[7]), ApzcOf(layers[9])); // Ensure the shape of the APZC tree is as expected - AsyncPanZoomController* layers1_2 = ApzcOf(layers[1]); - AsyncPanZoomController* layers4_6_8 = ApzcOf(layers[4]); - AsyncPanZoomController* layer7 = ApzcOf(layers[7]); - AsyncPanZoomController* layer9 = ApzcOf(layers[9]); + TestAsyncPanZoomController* layers1_2 = ApzcOf(layers[1]); + TestAsyncPanZoomController* layers4_6_8 = ApzcOf(layers[4]); + TestAsyncPanZoomController* layer7 = ApzcOf(layers[7]); + TestAsyncPanZoomController* layer9 = ApzcOf(layers[9]); EXPECT_EQ(nullptr, layers1_2->GetParent()); EXPECT_EQ(nullptr, layers4_6_8->GetParent()); EXPECT_EQ(layers4_6_8, layer7->GetParent()); EXPECT_EQ(nullptr, layer9->GetParent()); EXPECT_EQ(nullptr, layers1_2->GetPrevSibling()); EXPECT_EQ(layers1_2, layers4_6_8->GetPrevSibling()); EXPECT_EQ(nullptr, layer7->GetPrevSibling()); EXPECT_EQ(layers4_6_8, layer9->GetPrevSibling()); @@ -2058,17 +2070,17 @@ TEST_F(APZHitTestingTester, TestRepaintF // The main purpose of this test is to verify that touch-start events (or anything // that starts a new input block) don't ever get untransformed. This should always // hold because the APZ code should flush repaints when we start a new input block // and the transform to gecko space should be empty. CreateSimpleScrollingLayer(); ScopedLayerTreeRegistration registration(0, root, mcc); manager->UpdatePanZoomControllerTree(nullptr, root, false, 0, 0); - AsyncPanZoomController* apzcroot = ApzcOf(root); + TestAsyncPanZoomController* apzcroot = ApzcOf(root); // At this point, the following holds (all coordinates in screen pixels): // layers[0] has content from (0,0)-(500,500), clipped by composition bounds (0,0)-(200,200) MockFunction<void(std::string checkPointName)> check; { InSequence s;