Bug 562181 - Add support for MozOrientation on Qt. r=dougt
authorMike Kristoffersen <mkristoffersen@mozilla.com>>
Fri, 25 Jun 2010 14:25:31 +0200
changeset 46218 1d4e2804796a185c1a7b0e83813c88c80916fe3e
parent 46217 fbfc0ca2eb6ee854f0aa3bad310851a1a94c0deb
child 46219 4886e4b9058ee94c2914cc1b017da3f4d8573361
push id14073
push userdgottwald@mozilla.com
push dateFri, 25 Jun 2010 12:31:42 +0000
treeherdermozilla-central@43b5dea56661 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt
bugs562181
milestone1.9.3a6pre
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
Bug 562181 - Add support for MozOrientation on Qt. r=dougt
dom/Makefile.in
dom/base/nsGlobalWindow.cpp
dom/system/Makefile.in
dom/system/android/Makefile.in
dom/system/android/nsAccelerometerSystem.cpp
dom/system/android/nsAccelerometerSystem.h
dom/system/cocoa/Makefile.in
dom/system/cocoa/nsAccelerometerSystem.h
dom/system/cocoa/nsAccelerometerSystem.mm
dom/system/nsAccelerometer.cpp
dom/system/nsAccelerometer.h
dom/system/unix/Makefile.in
dom/system/unix/nsAccelerometerSystem.cpp
dom/system/unix/nsAccelerometerSystem.h
dom/system/windows/Makefile.in
dom/system/windows/nsAccelerometerSystem.cpp
dom/system/windows/nsAccelerometerSystem.h
layout/build/Makefile.in
layout/build/nsLayoutModule.cpp
widget/public/Makefile.in
widget/public/nsIAccelerometer.idl
widget/public/nsWidgetsCID.h
widget/src/android/Makefile.in
widget/src/android/nsAccelerometerAndroid.cpp
widget/src/android/nsAccelerometerAndroid.h
widget/src/android/nsAppShell.cpp
widget/src/android/nsWidgetFactory.cpp
widget/src/build/nsWinWidgetFactory.cpp
widget/src/cocoa/Makefile.in
widget/src/cocoa/nsAccelerometerX.h
widget/src/cocoa/nsAccelerometerX.mm
widget/src/cocoa/nsWidgetFactory.mm
widget/src/gtk2/Makefile.in
widget/src/gtk2/nsAccelerometerUnix.cpp
widget/src/gtk2/nsAccelerometerUnix.h
widget/src/gtk2/nsWidgetFactory.cpp
widget/src/windows/Makefile.in
widget/src/windows/nsAccelerometerWin.cpp
widget/src/windows/nsAccelerometerWin.h
widget/src/xpwidgets/Makefile.in
widget/src/xpwidgets/nsAccelerometer.cpp
widget/src/xpwidgets/nsAccelerometer.h
xpcom/system/Makefile.in
xpcom/system/nsIAccelerometer.idl
--- a/dom/Makefile.in
+++ b/dom/Makefile.in
@@ -76,16 +76,17 @@ endif
 
 DIRS += \
   public/coreEvents \
   base \
   src \
   locales \
   plugins \
   indexedDB \
+  system \
   $(NULL)
 
 ifdef ENABLE_TESTS
 DIRS += tests
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -81,18 +81,17 @@
 #include "nsDOMThreadService.h"
 #include "nsAutoJSValHolder.h"
 
 // Interfaces Needed
 #include "nsIFrame.h"
 #include "nsCanvasFrame.h"
 #include "nsIWidget.h"
 #include "nsIBaseWindow.h"
-#include "nsIAccelerometer.h"
-#include "nsWidgetsCID.h"
+#include "nsAccelerometer.h"
 #include "nsIContent.h"
 #include "nsIContentViewerEdit.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellLoadInfo.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeNode.h"
 #include "nsIEditorDocShell.h"
 #include "nsIDocCharset.h"
new file mode 100644
--- /dev/null
+++ b/dom/system/Makefile.in
@@ -0,0 +1,80 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Mozilla Foundation.
+# Portions created by the Initial Developer are Copyright (C) 2010
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either of the GNU General Public License Version 2 or later (the "GPL"),
+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH       = ../..
+topsrcdir   = @top_srcdir@
+srcdir      = @srcdir@
+VPATH       = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE          = dom
+LIBRARY_NAME    = domsystem_s
+LIBXUL_LIBRARY  = 1
+
+ifneq (,$(filter qt gtk2,$(MOZ_WIDGET_TOOLKIT)))
+DIRS = unix
+endif
+
+ifneq (,$(filter windows,$(MOZ_WIDGET_TOOLKIT)))
+DIRS = windows
+endif
+
+ifneq (,$(filter cocoa,$(MOZ_WIDGET_TOOLKIT)))
+DIRS = cocoa
+endif
+
+ifneq (,$(filter android,$(MOZ_WIDGET_TOOLKIT)))
+DIRS = android
+endif
+
+CPPSRCS     = \
+    nsAccelerometer.cpp \
+    $(NULL)
+
+EXPORTS     = \
+    nsAccelerometer.h \
+    $(NULL)
+
+include $(topsrcdir)/config/config.mk
+
+# we don't want the shared lib, but we want to force the creation of a static lib.
+LIBXUL_LIBRARY   = 1
+FORCE_STATIC_LIB = 1
+EXPORT_LIBRARY = 1
+
+include $(topsrcdir)/config/rules.mk
+
new file mode 100644
--- /dev/null
+++ b/dom/system/android/Makefile.in
@@ -0,0 +1,59 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org build system.
+#
+# The Initial Developer of the Original Code is Mozilla Foundation
+# Portions created by the Initial Developer are Copyright (C) 2010
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#  Mike Kristoffersen <mikek@mikek.dk>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH       = ../../..
+topsrcdir   = @top_srcdir@
+srcdir      = @srcdir@
+VPATH       = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE      = dom
+LIBRARY_NAME    = domsystemandroid_s
+
+# we don't want the shared lib, but we want to force the creation of a static lib.
+LIBXUL_LIBRARY   = 1
+FORCE_STATIC_LIB = 1
+EXPORT_LIBRARY = 1
+
+include $(topsrcdir)/config/config.mk
+
+CPPSRCS     = \
+        nsAccelerometerSystem.cpp \
+        $(NULL)
+
+include $(topsrcdir)/config/rules.mk
+
rename from widget/src/android/nsAccelerometerAndroid.cpp
rename to dom/system/android/nsAccelerometerSystem.cpp
--- a/widget/src/android/nsAccelerometerAndroid.cpp
+++ b/dom/system/android/nsAccelerometerSystem.cpp
@@ -29,34 +29,34 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsAccelerometerAndroid.h"
+#include "nsAccelerometerSystem.h"
 
 #include "AndroidBridge.h"
 
 using namespace mozilla;
 
-extern nsAccelerometerAndroid *gAccel;
+extern nsAccelerometerSystem *gAccel;
 
-nsAccelerometerAndroid::nsAccelerometerAndroid()
+nsAccelerometerSystem::nsAccelerometerSystem()
 {
     gAccel = this;
 }
 
-nsAccelerometerAndroid::~nsAccelerometerAndroid()
+nsAccelerometerSystem::~nsAccelerometerSystem()
 {
 }
 
-void nsAccelerometerAndroid::Startup()
+void nsAccelerometerSystem::Startup()
 {
     AndroidBridge::Bridge()->EnableAccelerometer(true);
 }
 
-void nsAccelerometerAndroid::Shutdown()
+void nsAccelerometerSystem::Shutdown()
 {
     AndroidBridge::Bridge()->EnableAccelerometer(false);
 }
rename from widget/src/android/nsAccelerometerAndroid.h
rename to dom/system/android/nsAccelerometerSystem.h
--- a/widget/src/android/nsAccelerometerAndroid.h
+++ b/dom/system/android/nsAccelerometerSystem.h
@@ -29,26 +29,26 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifndef nsAccelerometerAndroid_h
-#define nsAccelerometerAndroid_h
+#ifndef nsAccelerometerSystem_h
+#define nsAccelerometerSystem_h
 
 #include "nsAccelerometer.h"
 
-class nsAccelerometerAndroid : public nsAccelerometer
+class nsAccelerometerSystem : public nsAccelerometer
 {
 public:
-  nsAccelerometerAndroid();
-  virtual ~nsAccelerometerAndroid();
+  nsAccelerometerSystem();
+  virtual ~nsAccelerometerSystem();
 
 private:
   virtual void Startup();
   virtual void Shutdown();
 };
 
-#endif /* nsAccelerometerAndroid_h */
+#endif /* nsAccelerometerSystem_h */
 
new file mode 100644
--- /dev/null
+++ b/dom/system/cocoa/Makefile.in
@@ -0,0 +1,58 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org build system.
+#
+# The Initial Developer of the Original Code is Mozilla Foundation
+# Portions created by the Initial Developer are Copyright (C) 2010
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#  Mike Kristoffersen <mikek@mikek.dk>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH       = ../../..
+topsrcdir   = @top_srcdir@
+srcdir      = @srcdir@
+VPATH       = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE      = dom
+LIBRARY_NAME    = domsystemcocoa_s
+
+# we don't want the shared lib, but we want to force the creation of a static lib.
+LIBXUL_LIBRARY   = 1
+FORCE_STATIC_LIB = 1
+EXPORT_LIBRARY = 1
+
+include $(topsrcdir)/config/config.mk
+
+CMMSRCS     = \
+        nsAccelerometerSystem.mm \
+        $(NULL)
+
+include $(topsrcdir)/config/rules.mk
rename from widget/src/cocoa/nsAccelerometerX.h
rename to dom/system/cocoa/nsAccelerometerSystem.h
--- a/widget/src/cocoa/nsAccelerometerX.h
+++ b/dom/system/cocoa/nsAccelerometerSystem.h
@@ -29,29 +29,29 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifndef nsAccelerometerX_h
-#define nsAccelerometerX_h
+#ifndef nsAccelerometerSystem_h
+#define nsAccelerometerSystem_h
 
 #include <IOKit/IOKitLib.h>
 #include <mach/mach_port.h>
 
 #include "nsAccelerometer.h"
 
-class nsAccelerometerX : public nsAccelerometer
+class nsAccelerometerSystem : public nsAccelerometer
 {
  public:
-  nsAccelerometerX();
-  ~nsAccelerometerX();
+  nsAccelerometerSystem();
+  ~nsAccelerometerSystem();
 
   void Startup();
   void Shutdown();
 
   io_connect_t mSmsConnection;
   nsCOMPtr<nsITimer> mUpdateTimer;
   static void UpdateHandler(nsITimer *aTimer, void *aClosure);
 };
rename from widget/src/cocoa/nsAccelerometerX.mm
rename to dom/system/cocoa/nsAccelerometerSystem.mm
--- a/widget/src/cocoa/nsAccelerometerX.mm
+++ b/dom/system/cocoa/nsAccelerometerSystem.mm
@@ -29,32 +29,32 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsAccelerometerX.h"
+#include "nsAccelerometerSystem.h"
 #include "nsIServiceManager.h"
 #include "stdlib.h"
 
 #include <sys/sysctl.h>
 #include <sys/resource.h>
 #include <sys/vm.h>
 
 #define MODEL_NAME_LENGTH 64
 static char gModelName[MODEL_NAME_LENGTH];
 
-nsAccelerometerX::nsAccelerometerX()
+nsAccelerometerSystem::nsAccelerometerSystem()
 {
 }
 
-nsAccelerometerX::~nsAccelerometerX()
+nsAccelerometerSystem::~nsAccelerometerSystem()
 {
 }
 
 // Data format returned from IOConnectMethodStructureIStructureO.
 // I am not sure what the other bits in this structure are,
 // or if there are any, but this has to be 40 bytes long or
 // the call to read fails.
 //
@@ -67,32 +67,32 @@ typedef struct
   PRInt16 x;
   PRInt16 y;
   PRInt16 z;
   PRInt8  unknown[SMSDATA_PADDING_SIZE];
 } SmsData;
 #define SMSDATA_USED_SIZE (sizeof(SmsData) - SMSDATA_PADDING_SIZE)
 
 void
-nsAccelerometerX::UpdateHandler(nsITimer *aTimer, void *aClosure)
+nsAccelerometerSystem::UpdateHandler(nsITimer *aTimer, void *aClosure)
 {
-  nsAccelerometerX *self = reinterpret_cast<nsAccelerometerX *>(aClosure);
+  nsAccelerometerSystem *self = reinterpret_cast<nsAccelerometerSystem *>(aClosure);
   if (!self) {
     NS_ERROR("no self");
     return;
   }
 
   size_t bufferLen = sizeof(SmsData);
 
   void * input = malloc(bufferLen);
   void * output = malloc(bufferLen);
 
   if (!input || !output)
     return;
-    
+
   memset(input, 0, bufferLen);
   memset(output, 0, bufferLen);
 
   size_t structureOutputSize = bufferLen;
 #if (MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4)
   kern_return_t result = ::IOConnectMethodStructureIStructureO(self->mSmsConnection,
                                                                5, /* Magic number for SMCMotionSensor */
                                                                bufferLen,
@@ -110,24 +110,24 @@ nsAccelerometerX::UpdateHandler(nsITimer
 
   if ((result != kIOReturnSuccess) || (structureOutputSize < SMSDATA_USED_SIZE)) {
     free(input);
     free(output);
     return;
   }
 
   SmsData *data = (SmsData*) output;
-  
+
   float xf, yf, zf;
 
   // we want to normalize the return result from the chip to
   // something between -1 and 1 where 0 is the balance point.
 
   const int normalizeFactor = 250.5;
-  
+
   if (!strcmp(gModelName, "MacBookPro5,1")) {
     xf = ((float)data->x) / normalizeFactor;
     yf = (((float)data->y) / normalizeFactor) * -1;
     zf = ((float)data->z) / normalizeFactor;
   }
   else if (!strcmp(gModelName, "MacBookPro5,3")) {
     xf = ((float)data->y) / normalizeFactor;
     yf = (((float)data->x) / normalizeFactor) * -1;
@@ -141,67 +141,67 @@ nsAccelerometerX::UpdateHandler(nsITimer
   }
 
   free(input);
   free(output);
 
   self->AccelerationChanged( xf, yf, zf );
 }
 
-void nsAccelerometerX::Startup()
+void nsAccelerometerSystem::Startup()
 {
   // we can fail, and that just means the caller will not see any changes.
 
   mach_port_t port;
   kern_return_t result = ::IOMasterPort(MACH_PORT_NULL, &port);
   if (result != kIOReturnSuccess)
     return;
-  
+
   CFMutableDictionaryRef  dict = ::IOServiceMatching("SMCMotionSensor");
   if (!dict)
     return;
-  
+
   io_iterator_t iter;
   result = ::IOServiceGetMatchingServices(port, dict, &iter);
   if (result != kIOReturnSuccess)
     return;
-  
+
   io_object_t device = ::IOIteratorNext(iter);
 
   ::IOObjectRelease(iter);
-  
+
   if (!device)
     return;
-  
+
   result = ::IOServiceOpen(device, mach_task_self(), 0, &mSmsConnection);
   ::IOObjectRelease(device);
-  
+
   if (result != kIOReturnSuccess)
     return;
-  
+
   mach_port_deallocate(mach_task_self(), port);
-  
+
   /* get the version of the hardware we are running on. */
   int mib[2];
   size_t len = MODEL_NAME_LENGTH;
   mib[0] = CTL_HW;
   mib[1] = HW_MODEL;
   sysctl(mib, 2, gModelName, &len, NULL, 0);
 
   mUpdateTimer = do_CreateInstance("@mozilla.org/timer;1");
   if (mUpdateTimer)
     mUpdateTimer->InitWithFuncCallback(UpdateHandler,
                                        this,
                                        mUpdateInterval,
                                        nsITimer::TYPE_REPEATING_SLACK);
 }
 
-void nsAccelerometerX::Shutdown()
+void nsAccelerometerSystem::Shutdown()
 {
   if (mSmsConnection)
     ::IOServiceClose(mSmsConnection);
-  
+
   if (mUpdateTimer) {
     mUpdateTimer->Cancel();
     mUpdateTimer = nsnull;
   }
 }
 
rename from widget/src/xpwidgets/nsAccelerometer.cpp
rename to dom/system/nsAccelerometer.cpp
rename from widget/src/xpwidgets/nsAccelerometer.h
rename to dom/system/nsAccelerometer.h
--- a/widget/src/xpwidgets/nsAccelerometer.h
+++ b/dom/system/nsAccelerometer.h
@@ -37,16 +37,22 @@
 #ifndef nsAccelerometer_h
 #define nsAccelerometer_h
 
 #include "nsIAccelerometer.h"
 #include "nsCOMArray.h"
 #include "nsCOMPtr.h"
 #include "nsITimer.h"
 
+#define NS_ACCELEROMETER_CID \
+{ 0xecba5203, 0x77da, 0x465a, \
+{ 0x86, 0x5e, 0x78, 0xb7, 0xaf, 0x10, 0xd8, 0xf7 } }
+
+#define NS_ACCELEROMETER_CONTRACTID "@mozilla.org/accelerometer;1"
+
 class nsIDOMWindow;
 
 class nsAccelerometer : public nsIAccelerometer
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIACCELEROMETER
 
new file mode 100644
--- /dev/null
+++ b/dom/system/unix/Makefile.in
@@ -0,0 +1,58 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org build system.
+#
+# The Initial Developer of the Original Code is Mozilla Foundation
+# Portions created by the Initial Developer are Copyright (C) 2010
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#  Mike Kristoffersen <mikek@mikek.dk>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH       = ../../..
+topsrcdir   = @top_srcdir@
+srcdir      = @srcdir@
+VPATH       = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE      = dom
+LIBRARY_NAME    = domsystemunix_s
+
+# we don't want the shared lib, but we want to force the creation of a static lib.
+LIBXUL_LIBRARY   = 1
+FORCE_STATIC_LIB = 1
+EXPORT_LIBRARY = 1
+
+include $(topsrcdir)/config/config.mk
+
+CPPSRCS     = \
+        nsAccelerometerSystem.cpp \
+        $(NULL)
+
+include $(topsrcdir)/config/rules.mk
\ No newline at end of file
rename from widget/src/gtk2/nsAccelerometerUnix.cpp
rename to dom/system/unix/nsAccelerometerSystem.cpp
--- a/widget/src/gtk2/nsAccelerometerUnix.cpp
+++ b/dom/system/unix/nsAccelerometerSystem.cpp
@@ -31,23 +31,23 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include <unistd.h>
-#include "nsAccelerometerUnix.h"
+#include "nsAccelerometerSystem.h"
 #include "nsIServiceManager.h"
 
 typedef struct {
   const char* mPosition;
   const char* mCalibrate;
-  nsAccelerometerUnixDriver mToken;
+  nsAccelerometerSystemDriver mToken;
 } Accelerometer;
 
 static const Accelerometer gAccelerometers[] = {
   // MacBook
   {"/sys/devices/platform/applesmc.768/position",
    "/sys/devices/platform/applesmc.768/calibrate",
    eAppleSensor},
   // Thinkpad
@@ -59,31 +59,31 @@ static const Accelerometer gAcceleromete
    NULL,
    eMaemoSensor},
   // HP Pavilion dv7
   {"/sys/devices/platform/lis3lv02d/position",
    "/sys/devices/platform/lis3lv02d/calibrate",
    eHPdv7Sensor},
 };
 
-nsAccelerometerUnix::nsAccelerometerUnix() :
+nsAccelerometerSystem::nsAccelerometerSystem() :
   mPositionFile(NULL),
   mCalibrateFile(NULL),
   mType(eNoSensor)
 {
 }
 
-nsAccelerometerUnix::~nsAccelerometerUnix()
+nsAccelerometerSystem::~nsAccelerometerSystem()
 {
 }
 
 void
-nsAccelerometerUnix::UpdateHandler(nsITimer *aTimer, void *aClosure)
+nsAccelerometerSystem::UpdateHandler(nsITimer *aTimer, void *aClosure)
 {
-  nsAccelerometerUnix *self = reinterpret_cast<nsAccelerometerUnix *>(aClosure);
+  nsAccelerometerSystem *self = reinterpret_cast<nsAccelerometerSystem *>(aClosure);
   if (!self) {
     NS_ERROR("no self");
     return;
   }
 
   float xf, yf, zf;
 
   switch (self->mType) {
@@ -185,17 +185,17 @@ nsAccelerometerUnix::UpdateHandler(nsITi
     case eNoSensor:
     default:
       return;
   }
 
   self->AccelerationChanged( xf, yf, zf );
 }
 
-void nsAccelerometerUnix::Startup()
+void nsAccelerometerSystem::Startup()
 {
   // Accelerometers in Linux are used by reading a file (yay UNIX!), which is
   // in a slightly different location depending on the driver.
   for (unsigned int i = 0; i < NS_ARRAY_LENGTH(gAccelerometers); i++) {
     if (!(mPositionFile = fopen(gAccelerometers[i].mPosition, "r")))
       continue;
 
     mType = gAccelerometers[i].mToken;
@@ -208,26 +208,26 @@ void nsAccelerometerUnix::Startup()
       }
     }
 
     break;
   }
 
   if (mType == eNoSensor)
     return;
-  
+
   mUpdateTimer = do_CreateInstance("@mozilla.org/timer;1");
   if (mUpdateTimer)
     mUpdateTimer->InitWithFuncCallback(UpdateHandler,
                                        this,
                                        mUpdateInterval,
                                        nsITimer::TYPE_REPEATING_SLACK);
 }
 
-void nsAccelerometerUnix::Shutdown()
+void nsAccelerometerSystem::Shutdown()
 {
   if (mPositionFile) {
     fclose(mPositionFile);
     mPositionFile = nsnull;
   }
 
   // Fun fact: writing to the calibrate file causes the
   // driver to re-calibrate the accelerometer
rename from widget/src/gtk2/nsAccelerometerUnix.h
rename to dom/system/unix/nsAccelerometerSystem.h
--- a/widget/src/gtk2/nsAccelerometerUnix.h
+++ b/dom/system/unix/nsAccelerometerSystem.h
@@ -30,41 +30,41 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifndef nsAccelerometerUnix_h
-#define nsAccelerometerUnix_h
+#ifndef nsAccelerometerSystem_h
+#define nsAccelerometerSystem_h
 
 #include <unistd.h>
 #include "nsAccelerometer.h"
 
-enum nsAccelerometerUnixDriver
+enum nsAccelerometerSystemDriver
 {
   eNoSensor,
   eAppleSensor,
   eIBMSensor,
   eMaemoSensor,
   eHPdv7Sensor
 };
 
-class nsAccelerometerUnix : public nsAccelerometer
+class nsAccelerometerSystem : public nsAccelerometer
 {
  public:
-  nsAccelerometerUnix();
-  ~nsAccelerometerUnix();
+  nsAccelerometerSystem();
+  ~nsAccelerometerSystem();
 
   void Startup();
   void Shutdown();
 
   FILE* mPositionFile;
   FILE* mCalibrateFile;
-  nsAccelerometerUnixDriver mType;
+  nsAccelerometerSystemDriver mType;
 
   nsCOMPtr<nsITimer> mUpdateTimer;
   static void UpdateHandler(nsITimer *aTimer, void *aClosure);
 };
 
 #endif
new file mode 100644
--- /dev/null
+++ b/dom/system/windows/Makefile.in
@@ -0,0 +1,58 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org build system.
+#
+# The Initial Developer of the Original Code is Mozilla Foundation
+# Portions created by the Initial Developer are Copyright (C) 2010
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#  Mike Kristoffersen <mikek@mikek.dk>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH       = ../../..
+topsrcdir   = @top_srcdir@
+srcdir      = @srcdir@
+VPATH       = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE      = dom
+LIBRARY_NAME    = domsystemwindows_s
+
+# we don't want the shared lib, but we want to force the creation of a static lib.
+LIBXUL_LIBRARY   = 1
+FORCE_STATIC_LIB = 1
+EXPORT_LIBRARY = 1
+
+include $(topsrcdir)/config/config.mk
+
+CPPSRCS     = \
+        nsAccelerometerSystem.cpp \
+        $(NULL)
+
+include $(topsrcdir)/config/rules.mk
rename from widget/src/windows/nsAccelerometerWin.cpp
rename to dom/system/windows/nsAccelerometerSystem.cpp
--- a/widget/src/windows/nsAccelerometerWin.cpp
+++ b/dom/system/windows/nsAccelerometerSystem.cpp
@@ -30,24 +30,24 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsAccelerometerWin.h"
+#include "nsAccelerometerSystem.h"
 #include "nsIServiceManager.h"
 #include "windows.h"
 
 #ifdef WINCE_WINDOWS_MOBILE
 
 ////////////////////////////
-// HTC 
+// HTC
 ////////////////////////////
 
 
 typedef struct _SENSORDATA
 {
     SHORT   TiltX;          // From -1000 to 1000 (about), 0 is flat
     SHORT   TiltY;          // From -1000 to 1000 (about), 0 is flat
     SHORT   Orientation;    // From -1000 to 1000 (about)
@@ -86,17 +86,17 @@ HTCSensor::HTCSensor()
 HTCSensor::~HTCSensor()
 {
 }
 
 PRBool
 HTCSensor::Startup()
 {
   HMODULE hSensorLib = LoadLibraryW(L"HTCSensorSDK.dll");
-  
+
   if (!hSensorLib)
     return PR_FALSE;
 
   gHTCSensorOpen = (HTCSensorOpen) GetProcAddressW(hSensorLib, L"HTCSensorOpen");
   gHTCSensorClose = (HTCSensorClose) GetProcAddressW(hSensorLib, L"HTCSensorClose");
   gHTCSensorGetDataOutput = (HTCSensorGetDataOutput) GetProcAddressW(hSensorLib,
                                                                            L"HTCSensorGetDataOutput");
 
@@ -178,18 +178,18 @@ typedef enum
  */
 typedef struct
 {
   FLOAT x;     /**< X-direction value */
   FLOAT y;     /**< Y-direction value */
   FLOAT z;     /**< Z-direction value */
 } SmiAccelerometerVector;
 
-/** 
- *  Specifies the capabilities of the Accelerometer device. 
+/**
+ *  Specifies the capabilities of the Accelerometer device.
  */
 typedef struct
 {
   UINT callbackPeriod;     /**<The unit of the vector sampling time, in milliseconds. */
 } SmiAccelerometerCapabilities;
 
 typedef SMI_RESULT (WINAPI * SmiAccelerometerGetVector)(SmiAccelerometerVector *);
 typedef void (*SmiAccelerometerHandler)(SmiAccelerometerVector accel);
@@ -445,33 +445,33 @@ ThinkPadSensor::GetValues(double *x, dou
   // Balance point (526, 528) and 90 degree tilt (144) determined experimentally.
   *x = ((double)(accelData.y - 526)) / 144;
   *y = ((double)(accelData.x - 528)) / 144;
   *z = 1.0;
 }
 
 #endif
 
-nsAccelerometerWin::nsAccelerometerWin(){}
-nsAccelerometerWin::~nsAccelerometerWin(){}
+nsAccelerometerSystem::nsAccelerometerSystem(){}
+nsAccelerometerSystem::~nsAccelerometerSystem(){}
 
 void
-nsAccelerometerWin::UpdateHandler(nsITimer *aTimer, void *aClosure)
+nsAccelerometerSystem::UpdateHandler(nsITimer *aTimer, void *aClosure)
 {
-  nsAccelerometerWin *self = reinterpret_cast<nsAccelerometerWin *>(aClosure);
+  nsAccelerometerSystem *self = reinterpret_cast<nsAccelerometerSystem *>(aClosure);
   if (!self || !self->mSensor) {
     NS_ERROR("no self or sensor");
     return;
   }
   double x, y, z;
   self->mSensor->GetValues(&x, &y, &z);
   self->AccelerationChanged(x, y, z);
 }
 
-void nsAccelerometerWin::Startup()
+void nsAccelerometerSystem::Startup()
 {
   NS_ASSERTION(!mSensor, "mSensor should be null.  Startup called twice?");
 
   PRBool started = PR_FALSE;
 
 #ifdef WINCE_WINDOWS_MOBILE
 
   mSensor = new SMISensor();
@@ -494,29 +494,29 @@ void nsAccelerometerWin::Startup()
 
 #if !defined(WINCE) && !defined(WINCE_WINDOWS_MOBILE) // normal windows.
 
   mSensor = new ThinkPadSensor();
   if (mSensor)
     started = mSensor->Startup();
 
 #endif
-  
+
   if (!started)
     return;
 
   mUpdateTimer = do_CreateInstance("@mozilla.org/timer;1");
   if (mUpdateTimer)
     mUpdateTimer->InitWithFuncCallback(UpdateHandler,
                                        this,
                                        mUpdateInterval,
                                        nsITimer::TYPE_REPEATING_SLACK);
 }
 
-void nsAccelerometerWin::Shutdown()
+void nsAccelerometerSystem::Shutdown()
 {
   if (mUpdateTimer) {
     mUpdateTimer->Cancel();
     mUpdateTimer = nsnull;
   }
 
   if (mSensor)
     mSensor->Shutdown();
rename from widget/src/windows/nsAccelerometerWin.h
rename to dom/system/windows/nsAccelerometerSystem.h
--- a/widget/src/windows/nsAccelerometerWin.h
+++ b/dom/system/windows/nsAccelerometerSystem.h
@@ -29,35 +29,35 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifndef nsAccelerometerWin_h
-#define nsAccelerometerWin_h
+#ifndef nsAccelerometerSystem_h
+#define nsAccelerometerSystem_h
 
 #include "nsAccelerometer.h"
 #include "nsAutoPtr.h"
 
 class Sensor
 {
  public:
   virtual PRBool Startup() = 0;
   virtual void Shutdown()  = 0;
   virtual void GetValues(double *x, double *y, double *z) = 0;
 };
 
-class nsAccelerometerWin : public nsAccelerometer
+class nsAccelerometerSystem : public nsAccelerometer
 {
  public:
-  nsAccelerometerWin();
-  ~nsAccelerometerWin();
+  nsAccelerometerSystem();
+  ~nsAccelerometerSystem();
 
   void Startup();
   void Shutdown();
 
   nsCOMPtr<nsITimer> mUpdateTimer;
   static void UpdateHandler(nsITimer *aTimer, void *aClosure);
 
   nsAutoPtr<Sensor> mSensor;
--- a/layout/build/Makefile.in
+++ b/layout/build/Makefile.in
@@ -99,24 +99,55 @@ SHARED_LIBRARY_LIBS = \
 	$(DEPTH)/view/src/$(LIB_PREFIX)gkview_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/base/$(LIB_PREFIX)jsdombase_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/src/events/$(LIB_PREFIX)jsdomevents_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/src/json/$(LIB_PREFIX)json_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/src/jsurl/$(LIB_PREFIX)jsurl_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/src/storage/$(LIB_PREFIX)jsdomstorage_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/src/offline/$(LIB_PREFIX)jsdomoffline_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/src/geolocation/$(LIB_PREFIX)jsdomgeolocation_s.$(LIB_SUFFIX) \
+	$(DEPTH)/dom/system/$(LIB_PREFIX)domsystem_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/src/threads/$(LIB_PREFIX)domthreads_s.$(LIB_SUFFIX) \
 	$(DEPTH)/dom/indexedDB/$(LIB_PREFIX)dom_indexeddb_s.$(LIB_SUFFIX) \
 	$(DEPTH)/editor/libeditor/text/$(LIB_PREFIX)texteditor_s.$(LIB_SUFFIX) \
 	$(DEPTH)/editor/libeditor/base/$(LIB_PREFIX)editorbase_s.$(LIB_SUFFIX) \
 	$(DEPTH)/parser/html/$(LIB_PREFIX)html5p_s.$(LIB_SUFFIX) \
 	$(DEPTH)/caps/src/$(LIB_PREFIX)caps_s.$(LIB_SUFFIX) \
 	$(NULL)
 
+ifneq (,$(filter qt gtk2,$(MOZ_WIDGET_TOOLKIT)))
+SHARED_LIBRARY_LIBS += \
+	$(DEPTH)/dom/system/unix/$(LIB_PREFIX)domsystemunix_s.$(LIB_SUFFIX) \
+	$(NULL)
+LOCAL_INCLUDES	+= \
+	-I$(topsrcdir)/dom/system/unix \
+	$(NULL)
+else ifneq (,$(filter windows,$(MOZ_WIDGET_TOOLKIT)))
+SHARED_LIBRARY_LIBS += \
+	$(DEPTH)/dom/system/windows/$(LIB_PREFIX)domsystemwindows_s.$(LIB_SUFFIX) \
+	$(NULL)
+LOCAL_INCLUDES	+= \
+	-I$(topsrcdir)/dom/system/windows \
+	$(NULL)
+else ifneq (,$(filter cocoa,$(MOZ_WIDGET_TOOLKIT)))
+SHARED_LIBRARY_LIBS += \
+	$(DEPTH)/dom/system/cocoa/$(LIB_PREFIX)domsystemcocoa_s.$(LIB_SUFFIX) \
+ 	$(NULL)
+LOCAL_INCLUDES	+= \
+	-I$(topsrcdir)/dom/system/cocoa \
+	$(NULL)
+else ifneq (,$(filter android,$(MOZ_WIDGET_TOOLKIT)))
+SHARED_LIBRARY_LIBS += \
+	$(DEPTH)/dom/system/android/$(LIB_PREFIX)domsystemandroid_s.$(LIB_SUFFIX) \
+ 	$(NULL)
+LOCAL_INCLUDES	+= \
+	-I$(topsrcdir)/dom/system/android \
+	$(NULL)
+endif
+
 ifdef MOZ_VORBIS
 SHARED_LIBRARY_LIBS 	+= \
 	$(DEPTH)/media/libvorbis/lib/$(LIB_PREFIX)vorbis.$(LIB_SUFFIX) \
 	$(DEPTH)/media/libogg/src/$(LIB_PREFIX)ogg.$(LIB_SUFFIX) \
 	$(NULL)
 endif
 
 ifdef MOZ_MEDIA
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -274,16 +274,22 @@ NS_NewXULTreeBuilder(nsISupports* aOuter
 static void Shutdown();
 
 #ifdef MOZ_XTF
 #include "nsIXTFService.h"
 #include "nsIXMLContentBuilder.h"
 #endif
 
 #include "nsGeolocation.h"
+#if defined(XP_UNIX)    || \
+    defined(_WINDOWS)   || \
+    defined(machintosh) || \
+    defined(android)
+#include "nsAccelerometerSystem.h"
+#endif
 #include "nsCSPService.h"
 
 // Transformiix
 /* {0C351177-0159-4500-86B0-A219DFDE4258} */
 #define TRANSFORMIIX_XPATH1_SCHEME_CID \
 { 0xc351177, 0x159, 0x4500, { 0x86, 0xb0, 0xa2, 0x19, 0xdf, 0xde, 0x42, 0x58 } }
 
 /* 5d5d92cd-6bf8-11d9-bf4a-000a95dc234c */
@@ -306,16 +312,22 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsWSProto
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsWSSProtocolHandler)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDOMFileReader, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFormData)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileDataProtocolHandler)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMParser)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsDOMStorageManager,
                                          nsDOMStorageManager::GetInstance)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsChannelPolicy)
+#if defined(XP_UNIX)    || \
+    defined(_WINDOWS)   || \
+    defined(machintosh) || \
+    defined(android)
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsAccelerometerSystem)
+#endif
 
 //-----------------------------------------------------------------------------
 
 // Per bug 209804, it is necessary to observe the "xpcom-shutdown" event and
 // perform shutdown of the layout modules at that time instead of waiting for
 // our module destructor to run.  If we do not do this, then we risk holding
 // references to objects in other component libraries that have already been
 // shutdown (and possibly unloaded if 60709 is ever fixed).
@@ -1634,16 +1646,27 @@ static const nsModuleComponentInfo gLayo
       CSPServiceRegistration,
       CSPServiceUnregistration },
 
     { "Event Listener Service",
       NS_EVENTLISTENERSERVICE_CID,
       NS_EVENTLISTENERSERVICE_CONTRACTID,
       CreateEventListenerService },
 
+#if defined(XP_UNIX)    || \
+    defined(_WINDOWS)   || \
+    defined(machintosh) || \
+    defined(android)
+    { "Accelerometer",
+       NS_ACCELEROMETER_CID,
+       NS_ACCELEROMETER_CONTRACTID,
+       nsAccelerometerSystemConstructor
+     },
+#endif
+
     { "Global Message Manager",
       NS_GLOBALMESSAGEMANAGER_CID,
       NS_GLOBALMESSAGEMANAGER_CONTRACTID,
       CreateGlobalMessageManager },
 
     { "Channel Policy",
       NSCHANNELPOLICY_CID,
       NSCHANNELPOLICY_CONTRACTID,
--- a/widget/public/Makefile.in
+++ b/widget/public/Makefile.in
@@ -79,17 +79,16 @@ endif
 ifneq (,$(filter qt gtk2,$(MOZ_WIDGET_TOOLKIT)))
 EXPORTS		+= \
 		nsIDragSessionGTK.h \
 		nsIPrintDialogService.h \
 		$(NULL)
 endif
 
 XPIDLSRCS	= \
-		nsIAccelerometer.idl \
 		nsIAppShell.idl \
 		nsIFilePicker.idl \
 		nsIToolkit.idl \
 		nsISound.idl \
 		nsITransferable.idl \
 		nsIClipboardDragDropHooks.idl \
 		nsIClipboardDragDropHookList.idl \
 		nsIDragSession.idl \
--- a/widget/public/nsWidgetsCID.h
+++ b/widget/public/nsWidgetsCID.h
@@ -189,14 +189,8 @@
 #define NS_PRINTSESSION_CID \
 { 0x2f977d53, 0x5485, 0x11d4, \
 { 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 } }
 
 #define NS_PRINTDIALOGSERVICE_CID \
 { 0x06beec76, 0xa183, 0x4d9f, \
 { 0x85, 0xdd, 0x08, 0x5f, 0x26, 0xda, 0x56, 0x5a } }
 
-#define NS_ACCELEROMETER_CID \
-{ 0xecba5203, 0x77da, 0x465a, \
-{ 0x86, 0x5e, 0x78, 0xb7, 0xaf, 0x10, 0xd8, 0xf7 } }
-
-#define NS_ACCELEROMETER_CONTRACTID "@mozilla.org/accelerometer;1"
-
--- a/widget/src/android/Makefile.in
+++ b/widget/src/android/Makefile.in
@@ -57,17 +57,16 @@ CPPSRCS	= \
 	nsToolkit.cpp \
 	AndroidJavaWrappers.cpp \
 	AndroidBridge.cpp \
 	AndroidJNI.cpp \
 	nsWindow.cpp \
 	nsLookAndFeel.cpp \
 	nsScreenManagerAndroid.cpp \
 	nsIdleServiceAndroid.cpp \
-	nsAccelerometerAndroid.cpp \
 	$(NULL)
 
 NOT_THERE_YET_CPPSRCS = \
 	nsQtKeyUtils.cpp \
 	nsClipboard.cpp \
 	nsBidiKeyboard.cpp \
 	nsDragService.cpp \
 	nsNativeThemeQt.cpp \
@@ -93,11 +92,12 @@ EXPORTS = AndroidBridge.h AndroidJavaWra
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES += -D_IMPL_NS_WIDGET
 #DEFINES += -DDEBUG_WIDGETS
 
 LOCAL_INCLUDES += \
 	-I$(topsrcdir)/widget/src/xpwidgets \
+	-I$(topsrcdir)/dom/system/android \
 	-I$(srcdir) \
 	$(NULL)
 
--- a/widget/src/android/nsAppShell.cpp
+++ b/widget/src/android/nsAppShell.cpp
@@ -44,17 +44,17 @@
 #include "nsIAppStartup.h"
 #include "nsIGeolocationProvider.h"
 #include "nsIPrefService.h"
 
 #include "mozilla/Services.h"
 #include "prenv.h"
 
 #include "AndroidBridge.h"
-#include "nsAccelerometerAndroid.h"
+#include "nsAccelerometerSystem.h"
 #include <android/log.h>
 #include <pthread.h>
 
 #ifdef MOZ_LOGGING
 #define FORCE_PR_LOG
 #include "prlog.h"
 #endif
 
@@ -65,17 +65,17 @@
 #endif
 
 using namespace mozilla;
 
 #ifdef PR_LOGGING
 PRLogModuleInfo *gWidgetLog = nsnull;
 #endif
 
-nsAccelerometerAndroid *gAccel = nsnull;
+nsAccelerometerSystem *gAccel = nsnull;
 nsIGeolocationUpdate *gLocationCallback = nsnull;
 
 nsAppShell *nsAppShell::gAppShell = nsnull;
 AndroidGeckoEvent *nsAppShell::gEarlyEvent = nsnull;
 
 nsAppShell::nsAppShell()
     : mQueueLock(nsnull),
       mCondLock(nsnull),
--- a/widget/src/android/nsWidgetFactory.cpp
+++ b/widget/src/android/nsWidgetFactory.cpp
@@ -44,24 +44,22 @@
 #include "nsAppShell.h"
 #include "nsToolkit.h"
 
 #include "nsWindow.h"
 #include "nsLookAndFeel.h"
 #include "nsAppShellSingleton.h"
 #include "nsScreenManagerAndroid.h"
 
-#include "nsAccelerometerAndroid.h"
 #include "nsIdleServiceAndroid.h"
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerAndroid)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsAccelerometerAndroid)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceAndroid)
 
 
 static const nsModuleComponentInfo components[] =
 {
     { "Android Toolkit",
       NS_TOOLKIT_CID,
       "@mozilla.org/widget/toolkit/android;1",
@@ -84,22 +82,17 @@ static const nsModuleComponentInfo compo
       nsLookAndFeelConstructor },
     { "Android Screen Manager",
       NS_SCREENMANAGER_CID,
       "@mozilla.org/gfx/screenmanager;1",
       nsScreenManagerAndroidConstructor },
     { "Android Idle Service",
       NS_IDLE_SERVICE_CID,
       "@mozilla.org/widget/idleservice;1",
-      nsIdleServiceAndroidConstructor },
-    { "Accelerometer",
-      NS_ACCELEROMETER_CID,
-      NS_ACCELEROMETER_CONTRACTID,
-      nsAccelerometerAndroidConstructor },
-
+      nsIdleServiceAndroidConstructor }
 };
 
 static void
 nsWidgetAndroidModuleDtor(nsIModule *aSelf)
 {
     nsAppShellShutdown(aSelf);
 }
 
--- a/widget/src/build/nsWinWidgetFactory.cpp
+++ b/widget/src/build/nsWinWidgetFactory.cpp
@@ -73,19 +73,16 @@
 #include "nsHTMLFormatConverter.h"
 
 #ifdef NS_PRINTING
 #include "nsDeviceContextSpecWin.h"
 #include "nsPrintOptionsWin.h"
 #include "nsPrintSession.h"
 #endif
 
-#include "nsAccelerometerWin.h"
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsAccelerometerWin)
-
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
 NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerWin)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceWin)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
@@ -208,21 +205,16 @@ static const nsModuleComponentInfo compo
     "@mozilla.org/widget/dragservice;1",
     nsDragServiceConstructor },
   { "Bidi Keyboard",
     NS_BIDIKEYBOARD_CID,
     "@mozilla.org/widget/bidikeyboard;1",
     nsBidiKeyboardConstructor },
 #endif
 
-  { "Accelerometer",
-    NS_ACCELEROMETER_CID,
-    NS_ACCELEROMETER_CONTRACTID,
-    nsAccelerometerWinConstructor },
-
 #ifdef NS_PRINTING
   { "nsPrintOptionsWin",
     NS_PRINTSETTINGSSERVICE_CID,
     "@mozilla.org/gfx/printsettings-service;1",
     nsPrintOptionsWinConstructor },
   { "Win Printer Enumerator",
     NS_PRINTER_ENUMERATOR_CID,
     "@mozilla.org/gfx/printerenumerator;1",
--- a/widget/src/cocoa/Makefile.in
+++ b/widget/src/cocoa/Makefile.in
@@ -83,17 +83,16 @@ CMMSRCS = \
 		nsSound.mm \
 		nsLookAndFeel.mm \
 		nsNativeThemeCocoa.mm \
 		nsDeviceContextSpecX.mm \
 		nsPrintDialogX.mm \
 		nsPrintOptionsX.mm \
 		nsPrintSettingsX.mm \
 		nsIdleServiceX.mm \
-		nsAccelerometerX.mm \
 		nsCocoaTextInputHandler.mm \
 		nsMacDockSupport.mm \
 		nsStandaloneNativeMenu.mm \
 		$(NULL)
 
 ifeq (x86_64,$(TARGET_CPU))
 CMMSRCS += ComplexTextInputPanel.mm
 endif
--- a/widget/src/cocoa/nsWidgetFactory.mm
+++ b/widget/src/cocoa/nsWidgetFactory.mm
@@ -52,33 +52,31 @@
 #include "nsClipboard.h"
 #include "nsClipboardHelper.h"
 #include "nsTransferable.h"
 #include "nsHTMLFormatConverter.h"
 #include "nsDragService.h"
 
 #include "nsLookAndFeel.h"
 
-#include "nsAccelerometerX.h"
 #include "nsSound.h"
 #include "nsIdleServiceX.h"
 
 #include "nsScreenManagerCocoa.h"
 #include "nsDeviceContextSpecX.h"
 #include "nsPrintOptionsX.h"
 #include "nsPrintDialogX.h"
 #include "nsPrintSession.h"
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCocoaWindow)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsChildView)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsAccelerometerX)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerCocoa)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsX, Init)
@@ -130,20 +128,16 @@ static const nsModuleComponentInfo gComp
   { "Look And Feel",
     NS_LOOKANDFEEL_CID,
     "@mozilla.org/widget/lookandfeel;1",
     nsLookAndFeelConstructor },
   { "Sound",
     NS_SOUND_CID,
     "@mozilla.org/sound;1",
     nsSoundConstructor },
-  { "Accelerometer",
-    NS_ACCELEROMETER_CID,
-    NS_ACCELEROMETER_CONTRACTID,
-    nsAccelerometerXConstructor },
   { "Transferable",
     NS_TRANSFERABLE_CID,
     "@mozilla.org/widget/transferable;1",
     nsTransferableConstructor },
   { "HTML Format Converter",
     NS_HTMLFORMATCONVERTER_CID,
     "@mozilla.org/widget/htmlformatconverter;1",
     nsHTMLFormatConverterConstructor },
--- a/widget/src/gtk2/Makefile.in
+++ b/widget/src/gtk2/Makefile.in
@@ -73,17 +73,16 @@ CPPSRCS		= \
 		nsGtkKeyUtils.cpp \
 		nsFilePicker.cpp \
 		nsSound.cpp \
 		nsNativeKeyBindings.cpp \
 		nsScreenGtk.cpp \
 		nsScreenManagerGtk.cpp \
 		nsImageToPixbuf.cpp \
 		nsAccessibilityHelper.cpp \
-		nsAccelerometerUnix.cpp \
 		nsGtkIMModule.cpp \
 		$(NULL)
 
 ifdef MOZ_X11
 CPPSRCS         += nsIdleServiceGTK.cpp
 endif
 
 ifdef NS_PRINTING
--- a/widget/src/gtk2/nsWidgetFactory.cpp
+++ b/widget/src/gtk2/nsWidgetFactory.cpp
@@ -50,17 +50,16 @@
 #include "nsClipboard.h"
 #include "nsDragService.h"
 #endif
 #include "nsFilePicker.h"
 #include "nsSound.h"
 #include "nsBidiKeyboard.h"
 #include "nsNativeKeyBindings.h"
 #include "nsScreenManagerGtk.h"
-#include "nsAccelerometerUnix.h"
 
 #ifdef NS_PRINTING
 #include "nsPrintOptionsGTK.h"
 #include "nsPrintSession.h"
 #include "nsDeviceContextSpecG.h"
 #endif
 
 #include "nsIPrefService.h"
@@ -97,17 +96,16 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFor
 #ifdef MOZ_X11
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsClipboard, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
 #endif
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerGtk)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageToPixbuf)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsAccelerometerUnix)
 
 
 #ifdef NATIVE_THEME_SUPPORT
 // from nsWindow.cpp
 extern PRBool gDisableNativeTheme;
 
 static NS_IMETHODIMP
 nsNativeThemeGTKConstructor(nsISupports *aOuter, REFNSIID aIID,
@@ -249,20 +247,16 @@ static const nsModuleComponentInfo compo
     { "Gtk2 File Picker",
       NS_FILEPICKER_CID,
       "@mozilla.org/filepicker;1",
       nsFilePickerConstructor },
     { "Gtk2 Sound",
       NS_SOUND_CID,
       "@mozilla.org/sound;1",
       nsSoundConstructor },
-    { "Accelerometer",
-       NS_ACCELEROMETER_CID,
-       NS_ACCELEROMETER_CONTRACTID,
-       nsAccelerometerUnixConstructor },
     { "Transferable",
       NS_TRANSFERABLE_CID,
       "@mozilla.org/widget/transferable;1",
       nsTransferableConstructor },
 
 #ifdef MOZ_X11
   { "Gtk Clipboard",
     NS_CLIPBOARD_CID,
--- a/widget/src/windows/Makefile.in
+++ b/widget/src/windows/Makefile.in
@@ -59,17 +59,16 @@ CPPSRCS		= \
 	nsLookAndFeel.cpp \
 	nsUXThemeData.cpp \
 	nsNativeThemeWin.cpp \
 	nsWinGesture.cpp \
 	nsIdleServiceWin.cpp \
 	nsSound.cpp \
 	nsIMM32Handler.cpp \
 	WindowHook.cpp \
-	nsAccelerometerWin.cpp \
 	WinTaskbar.cpp \
 	TaskbarPreview.cpp \
 	TaskbarTabPreview.cpp \
 	TaskbarWindowPreview.cpp \
 	TaskbarPreviewButton.cpp \
  	JumpListBuilder.cpp \
  	JumpListItem.cpp \
 	$(NULL)
--- a/widget/src/xpwidgets/Makefile.in
+++ b/widget/src/xpwidgets/Makefile.in
@@ -63,17 +63,16 @@ CPPSRCS		= \
 		nsXPLookAndFeel.cpp \
 		nsClipboardHelper.cpp \
 		nsPrintOptionsImpl.cpp \
 		nsPrintSettingsImpl.cpp \
 		nsPrintSession.cpp \
 		nsWidgetAtoms.cpp \
 		nsIdleService.cpp \
 		nsClipboardPrivacyHandler.cpp \
-		nsAccelerometer.cpp \
 		$(NULL)
 
 ifneq (,$(filter beos os2 cocoa windows,$(MOZ_WIDGET_TOOLKIT)))
 CPPSRCS += nsBaseClipboard.cpp
 endif
 
 ifneq (,$(filter beos qt gtk2 os2 cocoa windows,$(MOZ_WIDGET_TOOLKIT)))
 CPPSRCS += nsBaseFilePicker.cpp
--- a/xpcom/system/Makefile.in
+++ b/xpcom/system/Makefile.in
@@ -47,15 +47,16 @@ XPIDL_MODULE    = xpcom_system
 
 XPIDLSRCS = \
         nsIXULAppInfo.idl \
         nsIXULRuntime.idl \
         nsIGConfService.idl \
         nsIGnomeVFSService.idl \
         nsIBlocklistService.idl \
         nsIGIOService.idl \
+        nsIAccelerometer.idl \
         $(NULL)
 
 ifdef MOZ_CRASHREPORTER
 XPIDLSRCS += nsICrashReporter.idl
 endif
 
 include $(topsrcdir)/config/rules.mk
rename from widget/public/nsIAccelerometer.idl
rename to xpcom/system/nsIAccelerometer.idl