Bug 745145, part 1: Generalize ScreenOrientation into ScreenConfiguration, and add screen rect and color+pixel depth to it. r=mounir
authorChris Jones <jones.chris.g@gmail.com>
Tue, 08 May 2012 14:36:07 -0700
changeset 97585 251188d5a55c0fe0cc323505678d041db855bc53
parent 97584 61ce3cbe0ca12c2aed7e799865815da521e631d2
child 97586 727b2eb545bd4ba23192777c3387f2878ab91d5f
push idunknown
push userunknown
push dateunknown
reviewersmounir
bugs745145
milestone15.0a1
Bug 745145, part 1: Generalize ScreenOrientation into ScreenConfiguration, and add screen rect and color+pixel depth to it. r=mounir
dom/base/ScreenOrientation.h
dom/base/nsScreen.cpp
dom/base/nsScreen.h
hal/Hal.cpp
hal/Hal.h
hal/HalInternal.h
hal/android/AndroidHal.cpp
hal/fallback/FallbackScreenOrientation.cpp
hal/sandbox/PHal.ipdl
hal/sandbox/SandboxHal.cpp
widget/android/AndroidBridge.cpp
widget/android/AndroidBridge.h
widget/android/nsAppShell.cpp
--- a/dom/base/ScreenOrientation.h
+++ b/dom/base/ScreenOrientation.h
@@ -1,15 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_ScreenOrientation_h
 #define mozilla_dom_ScreenOrientation_h
 
+#include "IPC/IPCMessageUtils.h"
+
 namespace mozilla {
 namespace dom {
 
 // Make sure that any change here is also made in
 // * mobile/android/base/GeckoScreenOrientationListener.java
 // * embedding/android/GeckoScreenOrientationListener.java
 enum ScreenOrientation {
   eScreenOrientation_None               = 0,
@@ -17,34 +19,16 @@ enum ScreenOrientation {
   eScreenOrientation_PortraitSecondary  = 2,  // 00000010
   eScreenOrientation_Portrait           = 3,  // 00000011
   eScreenOrientation_LandscapePrimary   = 4,  // 00000100
   eScreenOrientation_LandscapeSecondary = 8,  // 00001000
   eScreenOrientation_Landscape          = 12, // 00001100
   eScreenOrientation_EndGuard
 };
 
-/**
- * ScreenOrientationWrapper is a class wrapping ScreenOrientation so it can be
- * used with Observer<T> which is taking a class, not an enum.
- * C++11 should make this useless.
- */
-class ScreenOrientationWrapper {
-public:
-  ScreenOrientationWrapper()
-    : orientation(eScreenOrientation_None)
-  {}
-
-  ScreenOrientationWrapper(ScreenOrientation aOrientation)
-    : orientation(aOrientation)
-  {}
-
-  ScreenOrientation orientation;
-};
-
 } // namespace dom
 } // namespace mozilla
 
 namespace IPC {
 
 /**
  * Screen orientation serializer.
  * Note that technically, 5, 6, 7, 9, 10 and 11 are illegal values but will
--- a/dom/base/nsScreen.cpp
+++ b/dom/base/nsScreen.cpp
@@ -77,30 +77,32 @@ nsScreen::Create(nsPIDOMWindow* aWindow)
 
   nsCOMPtr<nsIScriptGlobalObject> sgo =
     do_QueryInterface(static_cast<nsPIDOMWindow*>(aWindow));
   NS_ENSURE_TRUE(sgo, nsnull);
 
   nsRefPtr<nsScreen> screen = new nsScreen();
   screen->BindToOwner(aWindow);
 
-  hal::RegisterScreenOrientationObserver(screen);
-  hal::GetCurrentScreenOrientation(&(screen->mOrientation));
+  hal::RegisterScreenConfigurationObserver(screen);
+  hal::ScreenConfiguration config;
+  hal::GetCurrentScreenConfiguration(&config);
+  screen->mOrientation = config.orientation();
 
   return screen.forget();
 }
 
 nsScreen::nsScreen()
   : mEventListener(nsnull)
 {
 }
 
 nsScreen::~nsScreen()
 {
-  hal::UnregisterScreenOrientationObserver(this);
+  hal::UnregisterScreenConfigurationObserver(this);
 }
 
 
 DOMCI_DATA(Screen, nsScreen)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsScreen)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsScreen,
@@ -280,20 +282,20 @@ nsScreen::GetAvailRect(nsRect& aRect)
   aRect.y = nsPresContext::AppUnitsToIntCSSPixels(aRect.y);
   aRect.height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height);
   aRect.width = nsPresContext::AppUnitsToIntCSSPixels(aRect.width);
 
   return NS_OK;
 }
 
 void
-nsScreen::Notify(const ScreenOrientationWrapper& aOrientation)
+nsScreen::Notify(const hal::ScreenConfiguration& aConfiguration)
 {
   ScreenOrientation previousOrientation = mOrientation;
-  mOrientation = aOrientation.orientation;
+  mOrientation = aConfiguration.orientation();
 
   NS_ASSERTION(mOrientation != eScreenOrientation_None &&
                mOrientation != eScreenOrientation_EndGuard &&
                mOrientation != eScreenOrientation_Portrait &&
                mOrientation != eScreenOrientation_Landscape,
                "Invalid orientation value passed to notify method!");
 
   if (mOrientation != previousOrientation) {
--- a/dom/base/nsScreen.h
+++ b/dom/base/nsScreen.h
@@ -32,47 +32,46 @@
  * 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 nsScreen_h___
 #define nsScreen_h___
 
+#include "mozilla/dom/ScreenOrientation.h"
 #include "mozilla/Hal.h"
 #include "nsIDOMScreen.h"
 #include "nsISupports.h"
 #include "nsIScriptContext.h"
 #include "nsCOMPtr.h"
-#include "mozilla/dom/ScreenOrientation.h"
 #include "nsDOMEventTargetHelper.h"
-#include "mozilla/Observer.h"
 
 class nsIDocShell;
 class nsDeviceContext;
 struct nsRect;
 
 // Script "screen" object
 class nsScreen : public nsDOMEventTargetHelper
                , public nsIDOMScreen
-               , public mozilla::hal::ScreenOrientationObserver
+               , public mozilla::hal::ScreenConfigurationObserver
 {
 public:
   static already_AddRefed<nsScreen> Create(nsPIDOMWindow* aWindow);
 
   void Invalidate();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMSCREEN
   NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsScreen,
                                            nsDOMEventTargetHelper)
 
-  void Notify(const mozilla::dom::ScreenOrientationWrapper& aOrientation);
+  void Notify(const mozilla::hal::ScreenConfiguration& aConfiguration);
 
 protected:
   nsDeviceContext* GetDeviceContext();
   nsresult GetRect(nsRect& aRect);
   nsresult GetAvailRect(nsRect& aRect);
 
   mozilla::dom::ScreenOrientation mOrientation;
 
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -299,33 +299,33 @@ protected:
 
   void DisableNotifications() {
     PROXY_IF_SANDBOXED(DisableWakeLockNotifications());
   }
 };
 
 static WakeLockObserversManager sWakeLockObservers;
 
-class ScreenOrientationObserversManager : public CachingObserversManager<dom::ScreenOrientationWrapper>
+class ScreenConfigurationObserversManager : public CachingObserversManager<ScreenConfiguration>
 {
 protected:
   void EnableNotifications() {
-    PROXY_IF_SANDBOXED(EnableScreenOrientationNotifications());
+    PROXY_IF_SANDBOXED(EnableScreenConfigurationNotifications());
   }
 
   void DisableNotifications() {
-    PROXY_IF_SANDBOXED(DisableScreenOrientationNotifications());
+    PROXY_IF_SANDBOXED(DisableScreenConfigurationNotifications());
   }
 
-  void GetCurrentInformationInternal(dom::ScreenOrientationWrapper* aInfo) {
-    PROXY_IF_SANDBOXED(GetCurrentScreenOrientation(&(aInfo->orientation)));
+  void GetCurrentInformationInternal(ScreenConfiguration* aInfo) {
+    PROXY_IF_SANDBOXED(GetCurrentScreenConfiguration(aInfo));
   }
 };
 
-static ScreenOrientationObserversManager sScreenOrientationObservers;
+static ScreenConfigurationObserversManager sScreenConfigurationObservers;
 
 void
 RegisterBatteryObserver(BatteryObserver* aObserver)
 {
   AssertMainThread();
   sBatteryObservers.AddObserver(aObserver);
 }
 
@@ -550,41 +550,41 @@ GetWakeLockInfo(const nsAString &aTopic,
 void
 NotifyWakeLockChange(const WakeLockInformation& aInfo)
 {
   AssertMainThread();
   sWakeLockObservers.BroadcastInformation(aInfo);
 }
 
 void
-RegisterScreenOrientationObserver(hal::ScreenOrientationObserver* aObserver)
+RegisterScreenConfigurationObserver(ScreenConfigurationObserver* aObserver)
 {
   AssertMainThread();
-  sScreenOrientationObservers.AddObserver(aObserver);
+  sScreenConfigurationObservers.AddObserver(aObserver);
 }
 
 void
-UnregisterScreenOrientationObserver(hal::ScreenOrientationObserver* aObserver)
+UnregisterScreenConfigurationObserver(ScreenConfigurationObserver* aObserver)
 {
   AssertMainThread();
-  sScreenOrientationObservers.RemoveObserver(aObserver);
+  sScreenConfigurationObservers.RemoveObserver(aObserver);
 }
 
 void
-GetCurrentScreenOrientation(dom::ScreenOrientation* aScreenOrientation)
+GetCurrentScreenConfiguration(ScreenConfiguration* aScreenConfiguration)
 {
   AssertMainThread();
-  *aScreenOrientation = sScreenOrientationObservers.GetCurrentInformation().orientation;
+  *aScreenConfiguration = sScreenConfigurationObservers.GetCurrentInformation();
 }
 
 void
-NotifyScreenOrientationChange(const dom::ScreenOrientation& aScreenOrientation)
+NotifyScreenConfigurationChange(const ScreenConfiguration& aScreenConfiguration)
 {
-  sScreenOrientationObservers.CacheInformation(dom::ScreenOrientationWrapper(aScreenOrientation));
-  sScreenOrientationObservers.BroadcastCachedInformation();
+  sScreenConfigurationObservers.CacheInformation(aScreenConfiguration);
+  sScreenConfigurationObservers.BroadcastCachedInformation();
 }
 
 bool
 LockScreenOrientation(const dom::ScreenOrientation& aOrientation)
 {
   AssertMainThread();
   RETURN_PROXY_IF_SANDBOXED(LockScreenOrientation(aOrientation));
 }
--- a/hal/Hal.h
+++ b/hal/Hal.h
@@ -35,23 +35,19 @@ class nsIDOMWindow;
 # define MOZ_DEFINED_HAL_NAMESPACE 1
 #endif
 
 namespace mozilla {
 
 template <class T>
 class Observer;
 
-namespace dom {
-class ScreenOrientationWrapper;
-}
-
 namespace hal {
 
-typedef Observer<dom::ScreenOrientationWrapper> ScreenOrientationObserver;
+typedef Observer<ScreenConfiguration> ScreenConfigurationObserver;
 
 class WindowIdentifier;
 
 extern PRLogModuleInfo *sHalLog;
 #define HAL_LOG(msg) PR_LOG(mozilla::hal::sHalLog, PR_LOG_DEBUG, msg)
 
 } // namespace hal
 
@@ -307,37 +303,37 @@ void GetWakeLockInfo(const nsAString &aT
 
 /**
  * Notify of a change in the wake lock state.
  * @param aWakeLockInfo The new wake lock information.
  */
 void NotifyWakeLockChange(const hal::WakeLockInformation& aWakeLockInfo);
 
 /**
- * Inform the backend there is a new screen orientation observer.
- * @param aScreenOrientationObserver The observer that should be added.
+ * Inform the backend there is a new screen configuration observer.
+ * @param aScreenConfigurationObserver The observer that should be added.
  */
-void RegisterScreenOrientationObserver(hal::ScreenOrientationObserver* aScreenOrientationObserver);
+void RegisterScreenConfigurationObserver(hal::ScreenConfigurationObserver* aScreenConfigurationObserver);
 
 /**
- * Inform the backend a screen orientation observer unregistered.
- * @param aScreenOrientationObserver The observer that should be removed.
+ * Inform the backend a screen configuration observer unregistered.
+ * @param aScreenConfigurationObserver The observer that should be removed.
  */
-void UnregisterScreenOrientationObserver(hal::ScreenOrientationObserver* aScreenOrientationObserver);
+void UnregisterScreenConfigurationObserver(hal::ScreenConfigurationObserver* aScreenConfigurationObserver);
 
 /**
- * Returns the current screen orientation.
+ * Returns the current screen configuration.
  */
-void GetCurrentScreenOrientation(dom::ScreenOrientation* aScreenOrientation);
+void GetCurrentScreenConfiguration(hal::ScreenConfiguration* aScreenConfiguration);
 
 /**
- * Notify of a change in the screen orientation.
- * @param aScreenOrientation The new screen orientation.
+ * Notify of a change in the screen configuration.
+ * @param aScreenConfiguration The new screen orientation.
  */
-void NotifyScreenOrientationChange(const dom::ScreenOrientation& aScreenOrientation);
+void NotifyScreenConfigurationChange(const hal::ScreenConfiguration& aScreenConfiguration);
 
 /**
  * Lock the screen orientation to the specific orientation.
  * @return Whether the lock has been accepted.
  */
 bool LockScreenOrientation(const dom::ScreenOrientation& aOrientation);
 
 /**
--- a/hal/HalInternal.h
+++ b/hal/HalInternal.h
@@ -75,22 +75,22 @@ void EnableNetworkNotifications();
 /**
  * Disables network notifications from the backend.
  */
 void DisableNetworkNotifications();
 
 /**
  * Enables screen orientation notifications from the backend.
  */
-void EnableScreenOrientationNotifications();
+void EnableScreenConfigurationNotifications();
 
 /**
  * Disables screen orientation notifications from the backend.
  */
-void DisableScreenOrientationNotifications();
+void DisableScreenConfigurationNotifications();
 
 /**
  * Enable switch notifications from the backend
  */
 void EnableSwitchNotifications(hal::SwitchDevice aDevice);
 
 /**
  * Disable switch notifications from the backend
--- a/hal/android/AndroidHal.cpp
+++ b/hal/android/AndroidHal.cpp
@@ -36,18 +36,20 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "Hal.h"
 #include "HalImpl.h"
 #include "WindowIdentifier.h"
 #include "AndroidBridge.h"
 #include "mozilla/dom/network/Constants.h"
 #include "mozilla/dom/ScreenOrientation.h"
+#include "nsIScreenManager.h"
 
-using mozilla::hal::WindowIdentifier;
+using namespace mozilla::dom;
+using namespace mozilla::hal;
 
 namespace mozilla {
 namespace hal_impl {
 
 void
 Vibrate(const nsTArray<uint32> &pattern, const WindowIdentifier &)
 {
   // Ignore the WindowIdentifier parameter; it's here only because hal::Vibrate,
@@ -150,59 +152,77 @@ GetCurrentNetworkInformation(hal::Networ
   if (!bridge) {
     return;
   }
 
   bridge->GetCurrentNetworkInformation(aNetworkInfo);
 }
 
 void
-EnableScreenOrientationNotifications()
+EnableScreenConfigurationNotifications()
 {
   AndroidBridge* bridge = AndroidBridge::Bridge();
   if (!bridge) {
     return;
   }
 
   bridge->EnableScreenOrientationNotifications();
 }
 
 void
-DisableScreenOrientationNotifications()
+DisableScreenConfigurationNotifications()
 {
   AndroidBridge* bridge = AndroidBridge::Bridge();
   if (!bridge) {
     return;
   }
 
   bridge->DisableScreenOrientationNotifications();
 }
 
 void
-GetCurrentScreenOrientation(dom::ScreenOrientation* aScreenOrientation)
+GetCurrentScreenConfiguration(ScreenConfiguration* aScreenConfiguration)
 {
   AndroidBridge* bridge = AndroidBridge::Bridge();
   if (!bridge) {
     return;
   }
 
-  dom::ScreenOrientationWrapper orientationWrapper;
-  bridge->GetScreenOrientation(orientationWrapper);
-  *aScreenOrientation = orientationWrapper.orientation;
+  nsresult rv;
+  nsCOMPtr<nsIScreenManager> screenMgr =
+    do_GetService("@mozilla.org/gfx/screenmanager;1", &rv);
+  if (NS_FAILED(rv)) {
+    NS_ERROR("Can't find nsIScreenManager!");
+    return;
+  }
+
+  nsIntRect rect;
+  PRInt32 colorDepth, pixelDepth;
+  ScreenOrientation orientation;
+  nsCOMPtr<nsIScreen> screen;
+
+  screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
+  screen->GetRect(&rect.x, &rect.y, &rect.width, &rect.height);
+  screen->GetColorDepth(&colorDepth);
+  screen->GetPixelDepth(&pixelDepth);
+  orientation = static_cast<ScreenOrientation>(bridge->GetScreenOrientation());
+
+  *aScreenConfiguration =
+    hal::ScreenConfiguration(rect, orientation, colorDepth, pixelDepth);
 }
 
 bool
-LockScreenOrientation(const dom::ScreenOrientation& aOrientation)
+LockScreenOrientation(const ScreenOrientation& aOrientation)
 {
   AndroidBridge* bridge = AndroidBridge::Bridge();
   if (!bridge) {
     return false;
   }
 
-  bridge->LockScreenOrientation(dom::ScreenOrientationWrapper(aOrientation));
+  bridge->LockScreenOrientation(aOrientation);
   return true;
 }
 
 void
 UnlockScreenOrientation()
 {
   AndroidBridge* bridge = AndroidBridge::Bridge();
   if (!bridge) {
--- a/hal/fallback/FallbackScreenOrientation.cpp
+++ b/hal/fallback/FallbackScreenOrientation.cpp
@@ -5,45 +5,51 @@
 #include "Hal.h"
 #include "mozilla/dom/ScreenOrientation.h"
 #include "nsIScreenManager.h"
 
 namespace mozilla {
 namespace hal_impl {
 
 void
-EnableScreenOrientationNotifications()
+EnableScreenConfigurationNotifications()
 {
 }
 
 void
-DisableScreenOrientationNotifications()
+DisableScreenConfigurationNotifications()
 {
 }
 
 void
-GetCurrentScreenOrientation(dom::ScreenOrientation* aScreenOrientation)
+GetCurrentScreenConfiguration(hal::ScreenConfiguration* aScreenConfiguration)
 {
-  nsresult result;
+  nsresult rv;
   nsCOMPtr<nsIScreenManager> screenMgr =
-    do_GetService("@mozilla.org/gfx/screenmanager;1", &result);
-  if (NS_FAILED(result)) {
+    do_GetService("@mozilla.org/gfx/screenmanager;1", &rv);
+  if (NS_FAILED(rv)) {
     NS_ERROR("Can't find nsIScreenManager!");
     return;
   }
 
-  PRInt32 screenLeft, screenTop, screenWidth, screenHeight;
+  nsIntRect rect;
+  PRInt32 colorDepth, pixelDepth;
+  dom::ScreenOrientation orientation;
   nsCOMPtr<nsIScreen> screen;
 
   screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
-  screen->GetRect(&screenLeft, &screenTop, &screenWidth, &screenHeight);
+  screen->GetRect(&rect.x, &rect.y, &rect.width, &rect.height);
+  screen->GetColorDepth(&colorDepth);
+  screen->GetPixelDepth(&pixelDepth);
+  orientation = rect.width >= rect.height
+      ? dom::eScreenOrientation_LandscapePrimary
+      : dom::eScreenOrientation_PortraitPrimary;
 
-  *aScreenOrientation = screenWidth >= screenHeight
-                          ? dom::eScreenOrientation_LandscapePrimary
-                          : dom::eScreenOrientation_PortraitPrimary;
+  *aScreenConfiguration =
+      hal::ScreenConfiguration(rect, orientation, colorDepth, pixelDepth);
 }
 
 bool
 LockScreenOrientation(const dom::ScreenOrientation& aOrientation)
 {
   return false;
 }
 
--- a/hal/sandbox/PHal.ipdl
+++ b/hal/sandbox/PHal.ipdl
@@ -38,82 +38,89 @@
  * ***** END LICENSE BLOCK ***** */
 
 include protocol PContent;
 include protocol PBrowser;
 include "prtime.h";
 include "mozilla/HalSensor.h";
 include "mozilla/HalTypes.h";
 include "mozilla/dom/ScreenOrientation.h";
+include "nsRect.h";
 
-using PRTime;
+using mozilla::dom::ScreenOrientation;
 using mozilla::hal::FlashMode;
 using mozilla::hal::LightType;
 using mozilla::hal::LightMode;
 using mozilla::hal::SensorType;
 using mozilla::hal::SensorAccuracyType;
 using mozilla::hal::WakeLockControl;
-using mozilla::dom::ScreenOrientation;
 using mozilla::hal::SwitchState;
 using mozilla::hal::SwitchDevice;
+using nsIntRect;
+using PRTime;
 
 namespace mozilla {
 
 namespace hal {
-  struct BatteryInformation {
-    double level;
-    bool   charging;
-    double remainingTime;
-  };
+struct BatteryInformation {
+  double level;
+  bool   charging;
+  double remainingTime;
+};
 
-  struct LightConfiguration {
-    LightType light;
-    LightMode mode;
-    FlashMode flash;
-    uint32_t flashOnMS;
-    uint32_t flashOffMS;
-    uint32_t color;
-  };
+struct LightConfiguration {
+  LightType light;
+  LightMode mode;
+  FlashMode flash;
+  uint32_t flashOnMS;
+  uint32_t flashOffMS;
+  uint32_t color;
+};
+
+struct SensorData {
+  SensorType sensor;
+  PRTime timestamp;
+  float[] values;
+  SensorAccuracyType accuracy;
+};
 
-  struct SensorData {
-    SensorType sensor;
-    PRTime timestamp;
-    float[] values;
-    SensorAccuracyType accuracy;
-  };
+struct NetworkInformation {
+  double bandwidth;
+  bool   canBeMetered;
+};
 
-  struct NetworkInformation {
-    double bandwidth;
-    bool   canBeMetered;
-  };
+struct SwitchEvent {
+  SwitchDevice device;
+  SwitchState status;
+};
 
-  struct SwitchEvent {
-    SwitchDevice device;
-    SwitchState status;
-  };
-}
+struct WakeLockInformation {
+  uint32_t numLocks;
+  uint32_t numHidden;
+  nsString topic;
+};
 
-namespace hal {
-  struct WakeLockInformation {
-    uint32_t numLocks;
-    uint32_t numHidden;
-    nsString topic;
-  };
+struct ScreenConfiguration {
+  nsIntRect rect;
+  ScreenOrientation orientation;
+  uint32_t colorDepth;
+  uint32_t pixelDepth;
+};
 }
 
 namespace hal_sandbox {
 
 sync protocol PHal {
     manager PContent;
 
 child:
     NotifyBatteryChange(BatteryInformation aBatteryInfo);
     NotifyNetworkChange(NetworkInformation aNetworkInfo);
     NotifyWakeLockChange(WakeLockInformation aWakeLockInfo);
-    NotifyScreenOrientationChange(ScreenOrientation aScreenOrientation);
+    NotifyScreenConfigurationChange(ScreenConfiguration aScreenOrientation);
     NotifySwitchChange(SwitchEvent aEvent);
 
 parent:
     Vibrate(uint32[] pattern, uint64[] id, PBrowser browser);
     CancelVibrate(uint64[] id, PBrowser browser);
 
     EnableBatteryNotifications();
     DisableBatteryNotifications();
@@ -146,20 +153,20 @@ parent:
     PowerOff();
 
     ModifyWakeLock(nsString aTopic, WakeLockControl aLockAdjust, WakeLockControl aHiddenAdjust);
     EnableWakeLockNotifications();
     DisableWakeLockNotifications();
     sync GetWakeLockInfo(nsString aTopic)
       returns (WakeLockInformation aWakeLockInfo);
 
-    EnableScreenOrientationNotifications();
-    DisableScreenOrientationNotifications();
-    sync GetCurrentScreenOrientation()
-      returns (ScreenOrientation aScreenOrientation);
+    EnableScreenConfigurationNotifications();
+    DisableScreenConfigurationNotifications();
+    sync GetCurrentScreenConfiguration()
+      returns (ScreenConfiguration aScreenConfiguration);
     sync LockScreenOrientation(ScreenOrientation aOrientation)
       returns (bool allowed);
     UnlockScreenOrientation();
  
     EnableSwitchNotifications(SwitchDevice aDevice);
     DisableSwitchNotifications(SwitchDevice aDevice);
     sync GetCurrentSwitchState(SwitchDevice aDevice)
       returns (SwitchState aState);
--- a/hal/sandbox/SandboxHal.cpp
+++ b/hal/sandbox/SandboxHal.cpp
@@ -88,31 +88,31 @@ DisableNetworkNotifications()
 
 void
 GetCurrentNetworkInformation(NetworkInformation* aNetworkInfo)
 {
   Hal()->SendGetCurrentNetworkInformation(aNetworkInfo);
 }
 
 void
-EnableScreenOrientationNotifications()
+EnableScreenConfigurationNotifications()
 {
-  Hal()->SendEnableScreenOrientationNotifications();
+  Hal()->SendEnableScreenConfigurationNotifications();
 }
 
 void
-DisableScreenOrientationNotifications()
+DisableScreenConfigurationNotifications()
 {
-  Hal()->SendDisableScreenOrientationNotifications();
+  Hal()->SendDisableScreenConfigurationNotifications();
 }
 
 void
-GetCurrentScreenOrientation(ScreenOrientation* aScreenOrientation)
+GetCurrentScreenConfiguration(ScreenConfiguration* aScreenConfiguration)
 {
-  Hal()->SendGetCurrentScreenOrientation(aScreenOrientation);
+  Hal()->SendGetCurrentScreenConfiguration(aScreenConfiguration);
 }
 
 bool
 LockScreenOrientation(const dom::ScreenOrientation& aOrientation)
 {
   bool allowed;
   Hal()->SendLockScreenOrientation(aOrientation, &allowed);
   return allowed;
@@ -260,17 +260,17 @@ GetCurrentSwitchState(SwitchDevice aDevi
   return state;
 }
 
 class HalParent : public PHalParent
                 , public BatteryObserver
                 , public NetworkObserver
                 , public ISensorObserver
                 , public WakeLockObserver
-                , public ScreenOrientationObserver
+                , public ScreenConfigurationObserver
                 , public SwitchObserver
 {
 public:
   NS_OVERRIDE virtual bool
   RecvVibrate(const InfallibleTArray<unsigned int>& pattern,
               const InfallibleTArray<uint64> &id,
               PBrowserParent *browserParent)
   {
@@ -348,30 +348,30 @@ public:
     return true;
   }
 
   void Notify(const NetworkInformation& aNetworkInfo) {
     unused << SendNotifyNetworkChange(aNetworkInfo);
   }
 
   NS_OVERRIDE virtual bool
-  RecvEnableScreenOrientationNotifications() {
-    hal::RegisterScreenOrientationObserver(this);
+  RecvEnableScreenConfigurationNotifications() {
+    hal::RegisterScreenConfigurationObserver(this);
     return true;
   }
 
   NS_OVERRIDE virtual bool
-  RecvDisableScreenOrientationNotifications() {
-    hal::UnregisterScreenOrientationObserver(this);
+  RecvDisableScreenConfigurationNotifications() {
+    hal::UnregisterScreenConfigurationObserver(this);
     return true;
   }
 
   NS_OVERRIDE virtual bool
-  RecvGetCurrentScreenOrientation(ScreenOrientation* aScreenOrientation) {
-    hal::GetCurrentScreenOrientation(aScreenOrientation);
+  RecvGetCurrentScreenConfiguration(ScreenConfiguration* aScreenConfiguration) {
+    hal::GetCurrentScreenConfiguration(aScreenConfiguration);
     return true;
   }
 
   NS_OVERRIDE virtual bool
   RecvLockScreenOrientation(const dom::ScreenOrientation& aOrientation, bool* aAllowed)
   {
     *aAllowed = hal::LockScreenOrientation(aOrientation);
     return true;
@@ -379,18 +379,18 @@ public:
 
   NS_OVERRIDE virtual bool
   RecvUnlockScreenOrientation()
   {
     hal::UnlockScreenOrientation();
     return true;
   }
 
-  void Notify(const ScreenOrientationWrapper& aScreenOrientation) {
-    unused << SendNotifyScreenOrientationChange(aScreenOrientation.orientation);
+  void Notify(const ScreenConfiguration& aScreenConfiguration) {
+    unused << SendNotifyScreenConfigurationChange(aScreenConfiguration);
   }
 
   NS_OVERRIDE virtual bool
   RecvGetScreenEnabled(bool *enabled)
   {
     *enabled = hal::GetScreenEnabled();
     return true;
   }
@@ -569,18 +569,18 @@ public:
 
   NS_OVERRIDE virtual bool
   RecvNotifyWakeLockChange(const WakeLockInformation& aWakeLockInfo) {
     hal::NotifyWakeLockChange(aWakeLockInfo);
     return true;
   }
 
   NS_OVERRIDE virtual bool
-  RecvNotifyScreenOrientationChange(const ScreenOrientation& aScreenOrientation) {
-    hal::NotifyScreenOrientationChange(aScreenOrientation);
+  RecvNotifyScreenConfigurationChange(const ScreenConfiguration& aScreenConfiguration) {
+    hal::NotifyScreenConfigurationChange(aScreenConfiguration);
     return true;
   }
 
   NS_OVERRIDE virtual bool
   RecvNotifySwitchChange(const mozilla::hal::SwitchEvent& aEvent) {
     hal::NotifySwitchChange(aEvent);
     return true;
   }
--- a/widget/android/AndroidBridge.cpp
+++ b/widget/android/AndroidBridge.cpp
@@ -2255,31 +2255,31 @@ AndroidBridge::HideSurface(jobject surfa
         return;
 
     AutoLocalJNIFrame jniFrame(env, 0);
 
     env->CallStaticVoidMethod(mGeckoAppShellClass, jHideSurface, surface);
 #endif
 }
 
-void
-AndroidBridge::GetScreenOrientation(dom::ScreenOrientationWrapper& aOrientation)
+uint32_t
+AndroidBridge::GetScreenOrientation()
 {
     ALOG_BRIDGE("AndroidBridge::GetScreenOrientation");
     JNIEnv* env = GetJNIEnv();
     if (!env)
-        return;
+        return dom::eScreenOrientation_None;
 
     AutoLocalJNIFrame jniFrame(env, 0);
 
     jshort orientation = env->CallStaticShortMethod(mGeckoAppShellClass, jGetScreenOrientation);
     if (jniFrame.CheckForException())
-        return;
-
-    aOrientation.orientation = static_cast<dom::ScreenOrientation>(orientation);
+        return dom::eScreenOrientation_None;
+
+    return static_cast<dom::ScreenOrientation>(orientation);
 }
 
 void
 AndroidBridge::EnableScreenOrientationNotifications()
 {
     ALOG_BRIDGE("AndroidBridge::EnableScreenOrientationNotifications");
     JNIEnv* env = GetJNIEnv();
     if (!env)
@@ -2297,25 +2297,25 @@ AndroidBridge::DisableScreenOrientationN
     if (!env)
         return;
 
     AutoLocalJNIFrame jniFrame(env, 0);
     env->CallStaticVoidMethod(mGeckoAppShellClass, jDisableScreenOrientationNotifications);
 }
 
 void
-AndroidBridge::LockScreenOrientation(const dom::ScreenOrientationWrapper& aOrientation)
+AndroidBridge::LockScreenOrientation(uint32_t aOrientation)
 {
     ALOG_BRIDGE("AndroidBridge::LockScreenOrientation");
     JNIEnv* env = GetJNIEnv();
     if (!env)
         return;
 
     AutoLocalJNIFrame jniFrame(env, 0);
-    env->CallStaticVoidMethod(mGeckoAppShellClass, jLockScreenOrientation, aOrientation.orientation);
+    env->CallStaticVoidMethod(mGeckoAppShellClass, jLockScreenOrientation, aOrientation);
 }
 
 void
 AndroidBridge::UnlockScreenOrientation()
 {
     ALOG_BRIDGE("AndroidBridge::UnlockScreenOrientation");
     JNIEnv* env = GetJNIEnv();
     if (!env)
--- a/widget/android/AndroidBridge.h
+++ b/widget/android/AndroidBridge.h
@@ -80,17 +80,16 @@ class Thread;
 namespace mozilla {
 
 namespace hal {
 class BatteryInformation;
 class NetworkInformation;
 } // namespace hal
 
 namespace dom {
-class ScreenOrientationWrapper;
 namespace sms {
 struct SmsFilterData;
 } // namespace sms
 } // namespace dom
 
 namespace layers {
 class CompositorParent;
 } // namespace layers
@@ -378,20 +377,20 @@ public:
 
     void AddPluginView(jobject view, const gfxRect& rect);
     void RemovePluginView(jobject view);
 
     // This method doesn't take a ScreenOrientation because it's an enum and
     // that would require including the header which requires include IPC
     // headers which requires including basictypes.h which requires a lot of
     // changes...
-    void GetScreenOrientation(dom::ScreenOrientationWrapper& aOrientation);
+    uint32_t GetScreenOrientation();
     void EnableScreenOrientationNotifications();
     void DisableScreenOrientationNotifications();
-    void LockScreenOrientation(const dom::ScreenOrientationWrapper& aOrientation);
+    void LockScreenOrientation(uint32_t aOrientation);
     void UnlockScreenOrientation();
 
     void PumpMessageLoop();
 
 protected:
     static AndroidBridge *sBridge;
 
     // the global JavaVM
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -557,17 +557,38 @@ nsAppShell::ProcessNextNativeEvent(bool 
             nsCOMPtr<nsIObserverService> obsServ =
                 mozilla::services::GetObserverService();
             obsServ->NotifyObservers(nsnull, "application-foreground", nsnull);
         }
         break;
     }
 
     case AndroidGeckoEvent::SCREENORIENTATION_CHANGED: {
-        hal::NotifyScreenOrientationChange(static_cast<dom::ScreenOrientation>(curEvent->ScreenOrientation()));
+        nsresult rv;
+        nsCOMPtr<nsIScreenManager> screenMgr =
+            do_GetService("@mozilla.org/gfx/screenmanager;1", &rv);
+        if (NS_FAILED(rv)) {
+            NS_ERROR("Can't find nsIScreenManager!");
+            break;
+        }
+
+        nsIntRect rect;
+        PRInt32 colorDepth, pixelDepth;
+        dom::ScreenOrientation orientation;
+        nsCOMPtr<nsIScreen> screen;
+
+        screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
+        screen->GetRect(&rect.x, &rect.y, &rect.width, &rect.height);
+        screen->GetColorDepth(&colorDepth);
+        screen->GetPixelDepth(&pixelDepth);
+        orientation =
+            static_cast<dom::ScreenOrientation>(curEvent->ScreenOrientation());
+
+        hal::NotifyScreenConfigurationChange(
+            hal::ScreenConfiguration(rect, orientation, colorDepth, pixelDepth));
         break;
     }
 
     default:
         nsWindow::OnGlobalAndroidEvent(curEvent);
     }
 
     EVLOG("nsAppShell: -- done event %p %d", (void*)curEvent.get(), curEvent->Type());