Backout part of Bug 895116 for not building on Windows on CLOSED TREE
authorDavid Zbarsky <dzbarsky@gmail.com>
Tue, 23 Jul 2013 18:03:40 -0700
changeset 152024 c68b8da6ec5a1a42e03e0866c908e560ea29f5ef
parent 152023 03cef3d7e96d7bca56637d22f129c96ff97adffd
child 152025 64b83068144f387a22fa41ab004fa4047b6560c7
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs895116
milestone25.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
Backout part of Bug 895116 for not building on Windows on CLOSED TREE
dom/system/nsDeviceSensors.cpp
dom/system/nsDeviceSensors.h
--- a/dom/system/nsDeviceSensors.cpp
+++ b/dom/system/nsDeviceSensors.cpp
@@ -3,37 +3,33 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Hal.h"
 #include "mozilla/HalSensor.h"
 
 #include "nsDeviceSensors.h"
 
 #include "nsAutoPtr.h"
-#include "nsIDocument.h"
 #include "nsIDOMEvent.h"
 #include "nsIDOMWindow.h"
 #include "nsPIDOMWindow.h"
+#include "nsIDOMDocument.h"
 #include "nsIServiceManager.h"
 #include "nsIServiceManager.h"
 #include "GeneratedEvents.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Attributes.h"
 #include "nsIPermissionManager.h"
 
-
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace hal;
 
 #undef near
 
-// Microsoft's API Name hackery sucks
-#undef CreateEvent
-
 // also see sDefaultSensorHint in mobile/android/base/GeckoAppShell.java
 #define DEFAULT_SENSOR_POLL 100
 
 static const nsTArray<nsIDOMWindow*>::index_type NoIndex =
   nsTArray<nsIDOMWindow*>::NoIndex;
 
 class nsDeviceSensorData MOZ_FINAL : public nsIDeviceSensorData
 {
@@ -211,26 +207,27 @@ nsDeviceSensors::Notify(const mozilla::h
   for (uint32_t i = windowListeners.Count(); i > 0 ; ) {
     --i;
 
     nsCOMPtr<nsPIDOMWindow> pwindow = do_QueryInterface(windowListeners[i]);
     if (WindowCannotReceiveSensorEvent(pwindow)) {
         continue;
     }
 
-    nsCOMPtr<nsIDocument> doc = pwindow->GetDoc();
+    nsCOMPtr<nsIDOMDocument> domdoc;
+    windowListeners[i]->GetDocument(getter_AddRefs(domdoc));
 
-    if (doc) {
+    if (domdoc) {
       nsCOMPtr<mozilla::dom::EventTarget> target = do_QueryInterface(windowListeners[i]);
       if (type == nsIDeviceSensorData::TYPE_ACCELERATION ||
         type == nsIDeviceSensorData::TYPE_LINEAR_ACCELERATION ||
         type == nsIDeviceSensorData::TYPE_GYROSCOPE)
-        FireDOMMotionEvent(doc, target, type, x, y, z);
+        FireDOMMotionEvent(domdoc, target, type, x, y, z);
       else if (type == nsIDeviceSensorData::TYPE_ORIENTATION)
-        FireDOMOrientationEvent(doc, target, x, y, z);
+        FireDOMOrientationEvent(domdoc, target, x, y, z);
       else if (type == nsIDeviceSensorData::TYPE_PROXIMITY)
         FireDOMProximityEvent(target, x, y, z);
       else if (type == nsIDeviceSensorData::TYPE_LIGHT)
         FireDOMLightEvent(target, x);
 
     }
   }
 }
@@ -303,27 +300,27 @@ nsDeviceSensors::FireDOMUserProximityEve
 
   event->SetTrusted(true);
 
   bool defaultActionEnabled;
   aTarget->DispatchEvent(event, &defaultActionEnabled);
 }
 
 void
-nsDeviceSensors::FireDOMOrientationEvent(nsIDocument* doc,
+nsDeviceSensors::FireDOMOrientationEvent(nsIDOMDocument* domdoc,
                                          EventTarget* target,
                                          double alpha,
                                          double beta,
                                          double gamma)
 {
-  ErrorResult rv;
-  nsRefPtr<nsDOMEvent> event = doc->CreateEvent(NS_LITERAL_STRING("DeviceOrientationEvent"), rv);
+  nsCOMPtr<nsIDOMEvent> event;
   bool defaultActionEnabled = true;
+  domdoc->CreateEvent(NS_LITERAL_STRING("DeviceOrientationEvent"), getter_AddRefs(event));
 
-  nsCOMPtr<nsIDOMDeviceOrientationEvent> oe = do_QueryObject(event);
+  nsCOMPtr<nsIDOMDeviceOrientationEvent> oe = do_QueryInterface(event);
 
   if (!oe) {
     return;
   }
 
   oe->InitDeviceOrientationEvent(NS_LITERAL_STRING("deviceorientation"),
                                  true,
                                  false,
@@ -334,17 +331,17 @@ nsDeviceSensors::FireDOMOrientationEvent
 
   event->SetTrusted(true);
 
   target->DispatchEvent(event, &defaultActionEnabled);
 }
 
 
 void
-nsDeviceSensors::FireDOMMotionEvent(nsIDocument* doc,
+nsDeviceSensors::FireDOMMotionEvent(nsIDOMDocument *domdoc,
                                     EventTarget* target,
                                     uint32_t type,
                                     double x,
                                     double y,
                                     double z)
 {
   // Attempt to coalesce events
   bool fireEvent = TimeStamp::Now() > mLastDOMMotionEventTime + TimeDuration::FromMilliseconds(DEFAULT_SENSOR_POLL);
@@ -360,20 +357,20 @@ nsDeviceSensors::FireDOMMotionEvent(nsID
     mLastRotationRate = new nsDOMDeviceRotationRate(x, y, z);
     break;
   }
 
   if (!fireEvent && (!mLastAcceleration || !mLastAccelerationIncluduingGravity || !mLastRotationRate)) {
     return;
   }
 
-  ErrorResult rv;
-  nsRefPtr<nsDOMEvent> event = doc->CreateEvent(NS_LITERAL_STRING("DeviceMotionEvent"), rv);
+  nsCOMPtr<nsIDOMEvent> event;
+  domdoc->CreateEvent(NS_LITERAL_STRING("DeviceMotionEvent"), getter_AddRefs(event));
 
-  nsCOMPtr<nsIDOMDeviceMotionEvent> me = do_QueryObject(event);
+  nsCOMPtr<nsIDOMDeviceMotionEvent> me = do_QueryInterface(event);
 
   if (!me)
     return;
 
   me->InitDeviceMotionEvent(NS_LITERAL_STRING("devicemotion"),
                             true,
                             false,
                             mLastAcceleration,
--- a/dom/system/nsDeviceSensors.h
+++ b/dom/system/nsDeviceSensors.h
@@ -22,17 +22,16 @@
 #include "nsDataHashtable.h"
 
 #define NS_DEVICE_SENSORS_CID \
 { 0xecba5203, 0x77da, 0x465a, \
 { 0x86, 0x5e, 0x78, 0xb7, 0xaf, 0x10, 0xd8, 0xf7 } }
 
 #define NS_DEVICE_SENSORS_CONTRACTID "@mozilla.org/devicesensors;1"
 
-class nsIDocument;
 class nsIDOMWindow;
 
 namespace mozilla {
 namespace dom {
 class EventTarget;
 }
 }
 
@@ -58,23 +57,23 @@ private:
   void FireDOMProximityEvent(mozilla::dom::EventTarget* aTarget,
                              double aValue,
                              double aMin,
                              double aMax);
 
   void FireDOMUserProximityEvent(mozilla::dom::EventTarget* aTarget,
                                  bool aNear);
 
-  void FireDOMOrientationEvent(nsIDocument* doc,
+  void FireDOMOrientationEvent(class nsIDOMDocument *domDoc,
                                mozilla::dom::EventTarget* target,
                                double alpha,
                                double beta,
                                double gamma);
 
-  void FireDOMMotionEvent(nsIDocument* doc,
+  void FireDOMMotionEvent(class nsIDOMDocument *domDoc,
                           mozilla::dom::EventTarget* target,
                           uint32_t type,
                           double x,
                           double y,
                           double z);
 
   bool mEnabled;