Backed out changeset 83f811be5016 (bug 1207221) for B2G JB emulator bustage due to warning
authorNigel Babu <nigelbabu@gmail.com>
Fri, 13 Nov 2015 16:01:26 +0530
changeset 272651 fa99f07ef603692363a70eebee9b198144bbd62a
parent 272650 e65a537f8ac3ae3320554d09bc0fd3589fef3d1c
child 272652 10c8a0633e3e5b4c52414f138bd58955d883c6c4
push id16262
push userkwierso@gmail.com
push dateTue, 17 Nov 2015 01:28:37 +0000
treeherderfx-team@31c31342f1ea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1207221
milestone45.0a1
backs out83f811be5016f0c18e9bc75e86fe6d2b356b599b
Backed out changeset 83f811be5016 (bug 1207221) for B2G JB emulator bustage due to warning
dom/base/Navigator.cpp
hal/Hal.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -769,35 +769,23 @@ private:
   nsWeakPtr mWindow;
   nsWeakPtr mDocument;
 };
 
 NS_IMPL_ISUPPORTS(VibrateWindowListener, nsIDOMEventListener)
 
 StaticRefPtr<VibrateWindowListener> gVibrateWindowListener;
 
-static bool
-MayVibrate(nsIDocument* doc) {
-#if MOZ_WIDGET_GONK
-  if (XRE_IsParentProcess()) {
-    return true; // The system app can always vibrate
-  }
-#endif // MOZ_WIDGET_GONK
-
-  // Hidden documents cannot start or stop a vibration.
-  return (doc && !doc->Hidden());
-}
-
 NS_IMETHODIMP
 VibrateWindowListener::HandleEvent(nsIDOMEvent* aEvent)
 {
   nsCOMPtr<nsIDocument> doc =
     do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget());
 
-  if (!MayVibrate(doc)) {
+  if (!doc || doc->Hidden()) {
     // It's important that we call CancelVibrate(), not Vibrate() with an
     // empty list, because Vibrate() will fail if we're no longer focused, but
     // CancelVibrate() will succeed, so long as nobody else has started a new
     // vibration pattern.
     nsCOMPtr<nsIDOMWindow> window = do_QueryReferent(mWindow);
     hal::CancelVibrate(window);
     RemoveListener();
     gVibrateWindowListener = nullptr;
@@ -860,18 +848,22 @@ Navigator::Vibrate(uint32_t aDuration)
 bool
 Navigator::Vibrate(const nsTArray<uint32_t>& aPattern)
 {
   if (!mWindow) {
     return false;
   }
 
   nsCOMPtr<nsIDocument> doc = mWindow->GetExtantDoc();
-
-  if (!MayVibrate(doc)) {
+  if (!doc) {
+    return false;
+  }
+
+  if (doc->Hidden()) {
+    // Hidden documents cannot start or stop a vibration.
     return false;
   }
 
   nsTArray<uint32_t> pattern(aPattern);
 
   if (pattern.Length() > sMaxVibrateListLen) {
     pattern.SetLength(sMaxVibrateListLen);
   }
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -119,28 +119,26 @@ Vibrate(const nsTArray<uint32_t>& patter
   Vibrate(pattern, WindowIdentifier(window));
 }
 
 void
 Vibrate(const nsTArray<uint32_t>& pattern, const WindowIdentifier &id)
 {
   AssertMainThread();
 
-#if !defined(MOZ_WIDGET_GONK)
   // Only active windows may start vibrations.  If |id| hasn't gone
   // through the IPC layer -- that is, if our caller is the outside
   // world, not hal_proxy -- check whether the window is active.  If
   // |id| has gone through IPC, don't check the window's visibility;
   // only the window corresponding to the bottommost process has its
   // visibility state set correctly.
   if (!id.HasTraveledThroughIPC() && !WindowIsActive(id.GetWindow())) {
     HAL_LOG("Vibrate: Window is inactive, dropping vibrate.");
     return;
   }
-#endif // !defined(MOZ_WIDGET_GONK)
 
   if (!InSandbox()) {
     if (!gLastIDToVibrate) {
       InitLastIDToVibrate();
     }
     *gLastIDToVibrate = id.AsArray();
   }