Bug 982118 - Move ui.click_hold_context_menus.delay to gfxPrefs. r=kats
authorOleg Romashin <romaxa@gmail.com>
Tue, 11 Mar 2014 09:10:50 -0700
changeset 173201 2d55a9a8785a27934f2444e775b492971f75d6c4
parent 173200 fedc1d467cf319282e31233cd6026655182a6f3f
child 173202 e9bf2f094cb233295ce0deb41a1dce730a058b5d
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerskats
bugs982118
milestone30.0a1
Bug 982118 - Move ui.click_hold_context_menus.delay to gfxPrefs. r=kats
gfx/layers/ipc/GestureEventListener.cpp
gfx/tests/gtest/TestAsyncPanZoomController.cpp
gfx/thebes/gfxPrefs.h
--- a/gfx/layers/ipc/GestureEventListener.cpp
+++ b/gfx/layers/ipc/GestureEventListener.cpp
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "GestureEventListener.h"
 #include <math.h>                       // for fabsf
 #include <stddef.h>                     // for size_t
 #include "AsyncPanZoomController.h"     // for AsyncPanZoomController
 #include "mozilla/layers/APZCTreeManager.h"  // for APZCTreeManager
 #include "base/task.h"                  // for CancelableTask, etc
-#include "mozilla/Preferences.h"        // for Preferences
+#include "gfxPrefs.h"                   // for gfxPrefs
 #include "mozilla/gfx/BasePoint.h"      // for BasePoint
 #include "mozilla/mozalloc.h"           // for operator new
 #include "nsDebug.h"                    // for NS_WARN_IF_FALSE
 #include "nsMathUtils.h"                // for NS_hypot
 
 namespace mozilla {
 namespace layers {
 
@@ -80,17 +80,17 @@ nsEventStatus GestureEventListener::Hand
       if (mState == GESTURE_NONE) {
         mState = GESTURE_WAITING_SINGLE_TAP;
 
         mLongTapTimeoutTask =
           NewRunnableMethod(this, &GestureEventListener::TimeoutLongTap);
 
         mAsyncPanZoomController->PostDelayedTask(
           mLongTapTimeoutTask,
-          Preferences::GetInt("ui.click_hold_context_menus.delay", 500));
+          gfxPrefs::UiClickHoldContextMenusDelay());
       }
     } else if (length == 2) {
       // Another finger has been added; it can't be a tap anymore.
       HandleTapCancel(aEvent);
     }
 
     break;
   }
--- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp
+++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp
@@ -681,17 +681,17 @@ TEST_F(AsyncPanZoomControllerTester, Ove
   ViewTransform viewTransformOut;
 
   // Pan down
   ApzcPan(apzc, tm, time, touchStart, touchEnd);
   apzc->SampleContentTransformForFrame(testStartTime+TimeDuration::FromMilliseconds(1000), &viewTransformOut, pointOut);
   EXPECT_EQ(pointOut, ScreenPoint(0, 90));
 }
 
-TEST(AsyncPanZoomController, ShortPress) {
+TEST_F(AsyncPanZoomControllerTester, ShortPress) {
   nsRefPtr<MockContentControllerDelayed> mcc = new NiceMock<MockContentControllerDelayed>();
   nsRefPtr<TestAPZCTreeManager> tm = new TestAPZCTreeManager();
   nsRefPtr<TestAsyncPanZoomController> apzc = new TestAsyncPanZoomController(
     0, mcc, tm, AsyncPanZoomController::USE_GESTURE_DETECTOR);
 
   apzc->SetFrameMetrics(TestFrameMetrics());
   apzc->NotifyLayersUpdated(TestFrameMetrics(), true);
   apzc->UpdateZoomConstraints(ZoomConstraints(false, false, CSSToScreenScale(1.0), CSSToScreenScale(1.0)));
@@ -705,17 +705,17 @@ TEST(AsyncPanZoomController, ShortPress)
   mcc->CheckHasDelayedTask();
 
   EXPECT_CALL(*mcc, HandleSingleTap(CSSIntPoint(10, 10), 0, apzc->GetGuid())).Times(1);
   mcc->RunDelayedTask();
 
   apzc->Destroy();
 }
 
-TEST(AsyncPanZoomController, MediumPress) {
+TEST_F(AsyncPanZoomControllerTester, MediumPress) {
   nsRefPtr<MockContentControllerDelayed> mcc = new NiceMock<MockContentControllerDelayed>();
   nsRefPtr<TestAPZCTreeManager> tm = new TestAPZCTreeManager();
   nsRefPtr<TestAsyncPanZoomController> apzc = new TestAsyncPanZoomController(
     0, mcc, tm, AsyncPanZoomController::USE_GESTURE_DETECTOR);
 
   apzc->SetFrameMetrics(TestFrameMetrics());
   apzc->NotifyLayersUpdated(TestFrameMetrics(), true);
   apzc->UpdateZoomConstraints(ZoomConstraints(false, false, CSSToScreenScale(1.0), CSSToScreenScale(1.0)));
@@ -786,17 +786,17 @@ DoLongPressTest(bool aShouldUseTouchActi
   // mechanism.
   check.Call("preHandleLongTapUp");
   apzc->ContentReceivedTouch(false);
   check.Call("postHandleLongTapUp");
 
   apzc->Destroy();
 }
 
-TEST(AsyncPanZoomController, LongPressPreventDefault) {
+TEST_F(AsyncPanZoomControllerTester, LongPressPreventDefault) {
   // We have to initialize both an integer time and TimeStamp time because
   // TimeStamp doesn't have any ToXXX() functions for converting back to
   // primitives.
   TimeStamp testStartTime = TimeStamp::Now();
   int time = 0;
   AsyncPanZoomController::SetFrameTime(testStartTime);
 
   nsRefPtr<MockContentControllerDelayed> mcc = new MockContentControllerDelayed();
@@ -861,21 +861,21 @@ TEST(AsyncPanZoomController, LongPressPr
   apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
 
   EXPECT_EQ(pointOut, ScreenPoint());
   EXPECT_EQ(viewTransformOut, ViewTransform());
 
   apzc->Destroy();
 }
 
-TEST(AsyncPanZoomController, LongPress) {
+TEST_F(AsyncPanZoomControllerTester, LongPress) {
   DoLongPressTest(false, mozilla::layers::AllowedTouchBehavior::NONE);
 }
 
-TEST(AsyncPanZoomController, LongPressPanAndZoom) {
+TEST_F(AsyncPanZoomControllerTester, LongPressPanAndZoom) {
   DoLongPressTest(true, mozilla::layers::AllowedTouchBehavior::HORIZONTAL_PAN
                       | mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN
                       | mozilla::layers::AllowedTouchBehavior::ZOOM);
 }
 
 
 // Layer tree for HitTesting1
 static already_AddRefed<mozilla::layers::Layer>
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -173,16 +173,18 @@ private:
   DECL_GFX_PREF(Once, "layers.prefer-opengl",                  LayersPreferOpenGL, bool, false);
   DECL_GFX_PREF(Once, "layers.progressive-paint",              UseProgressiveTilePainting, bool, false);
   DECL_GFX_PREF(Once, "layers.scroll-graph",                   LayersScrollGraph, bool, false);
 
   DECL_GFX_PREF(Once, "layout.frame_rate",                     LayoutFrameRate, int32_t, -1);
 
   DECL_GFX_PREF(Live, "nglayout.debug.widget_update_flashing", WidgetUpdateFlashing, bool, false);
 
+  DECL_GFX_PREF(Live, "ui.click_hold_context_menus.delay",     UiClickHoldContextMenusDelay, int32_t, 500);
+
   DECL_GFX_PREF(Once, "webgl.force-layers-readback",           WebGLForceLayersReadback, bool, false);
 
 public:
   // Manage the singleton:
   static gfxPrefs& GetSingleton()
   {
     if (!sInstance) {
       sInstance = new gfxPrefs;