Bug 908058 - Add orientation keyword 'default' to express normal orientation. r=mounir, r=blassey
authorViral Wang <vwang@mozilla.com>
Mon, 30 Sep 2013 10:40:41 -0400
changeset 149313 11ab102e7e8719b9ce66427afedf6c8dfa02fef3
parent 149312 9c47f46943ff7bab98e6da5a8614b9c8b80be242
child 149314 8a34e37caf59254e1be9587143111512103ec178
push id25382
push userryanvm@gmail.com
push dateMon, 30 Sep 2013 20:47:44 +0000
treeherdermozilla-central@1b8d32bf6058 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir, blassey
bugs908058
milestone27.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
Bug 908058 - Add orientation keyword 'default' to express normal orientation. r=mounir, r=blassey
dom/base/ScreenOrientation.h
dom/base/nsScreen.cpp
hal/android/AndroidHal.cpp
mobile/android/base/GeckoScreenOrientationListener.java
widget/gonk/OrientationObserver.cpp
--- a/dom/base/ScreenOrientation.h
+++ b/dom/base/ScreenOrientation.h
@@ -12,13 +12,16 @@ namespace dom {
 // * mobile/android/base/GeckoScreenOrientationListener.java
 typedef uint32_t ScreenOrientation;
 
 static const ScreenOrientation eScreenOrientation_None               = 0;
 static const ScreenOrientation eScreenOrientation_PortraitPrimary    = 1u << 0;
 static const ScreenOrientation eScreenOrientation_PortraitSecondary  = 1u << 1;
 static const ScreenOrientation eScreenOrientation_LandscapePrimary   = 1u << 2;
 static const ScreenOrientation eScreenOrientation_LandscapeSecondary = 1u << 3;
+//eScreenOrientation_Default will use the natural orientation for the deivce,
+//it could be PortraitPrimary or LandscapePrimary depends on display resolution
+static const ScreenOrientation eScreenOrientation_Default            = 1u << 4;
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_ScreenOrientation_h
--- a/dom/base/nsScreen.cpp
+++ b/dom/base/nsScreen.cpp
@@ -326,16 +326,18 @@ nsScreen::MozLockOrientation(const Seque
       orientation |= eScreenOrientation_PortraitSecondary;
     } else if (item.EqualsLiteral("landscape")) {
       orientation |= eScreenOrientation_LandscapePrimary |
                      eScreenOrientation_LandscapeSecondary;
     } else if (item.EqualsLiteral("landscape-primary")) {
       orientation |= eScreenOrientation_LandscapePrimary;
     } else if (item.EqualsLiteral("landscape-secondary")) {
       orientation |= eScreenOrientation_LandscapeSecondary;
+    } else if (item.EqualsLiteral("default")) {
+      orientation |= eScreenOrientation_Default;
     } else {
       // If we don't recognize the token, we should just return 'false'
       // without throwing.
       return false;
     }
   }
 
   switch (GetLockOrientationPermission()) {
--- a/hal/android/AndroidHal.cpp
+++ b/hal/android/AndroidHal.cpp
@@ -189,16 +189,17 @@ LockScreenOrientation(const ScreenOrient
   switch (aOrientation) {
     // The Android backend only supports these orientations.
     case eScreenOrientation_PortraitPrimary:
     case eScreenOrientation_PortraitSecondary:
     case eScreenOrientation_PortraitPrimary | eScreenOrientation_PortraitSecondary:
     case eScreenOrientation_LandscapePrimary:
     case eScreenOrientation_LandscapeSecondary:
     case eScreenOrientation_LandscapePrimary | eScreenOrientation_LandscapeSecondary:
+    case eScreenOrientation_Default:
       bridge->LockScreenOrientation(aOrientation);
       return true;
     default:
       return false;
   }
 }
 
 void
--- a/mobile/android/base/GeckoScreenOrientationListener.java
+++ b/mobile/android/base/GeckoScreenOrientationListener.java
@@ -32,16 +32,17 @@ public class GeckoScreenOrientationListe
     static private GeckoScreenOrientationListener sInstance = null;
 
     // Make sure that any change in dom/base/ScreenOrientation.h happens here too.
     static public final short eScreenOrientation_None               = 0;
     static public final short eScreenOrientation_PortraitPrimary    = 1; // PR_BIT(0)
     static public final short eScreenOrientation_PortraitSecondary  = 2; // PR_BIT(1)
     static public final short eScreenOrientation_LandscapePrimary   = 4; // PR_BIT(2)
     static public final short eScreenOrientation_LandscapeSecondary = 8; // PR_BIT(3)
+    static public final short eScreenOrientation_Default            = 16;// PR_BIT(4)
 
     static private final short DEFAULT_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
 
     private short mOrientation;
     private OrientationEventListenerImpl mListener = null;
 
     // Whether the listener should be listening to changes.
     private boolean mShouldBeListening = false;
@@ -194,16 +195,19 @@ public class GeckoScreenOrientationListe
             orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
             break;
         case eScreenOrientation_LandscapeSecondary:
             orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
             break;
         case eScreenOrientation_LandscapePrimary | eScreenOrientation_LandscapeSecondary:
             orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
             break;
+        case eScreenOrientation_Default:
+            orientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
+            break;
         default:
             Log.e(LOGTAG, "Unexpected value received! (" + aOrientation + ")");
             return;
         }
 	if (GeckoAppShell.getContext() instanceof Activity)
 	  ((Activity)GeckoAppShell.getContext()).setRequestedOrientation(orientation);
         updateScreenOrientation();
     }
--- a/widget/gonk/OrientationObserver.cpp
+++ b/widget/gonk/OrientationObserver.cpp
@@ -259,17 +259,24 @@ OrientationObserver::DisableAutoOrientat
 }
 
 bool
 OrientationObserver::LockScreenOrientation(ScreenOrientation aOrientation)
 {
   MOZ_ASSERT(aOrientation | (eScreenOrientation_PortraitPrimary |
                              eScreenOrientation_PortraitSecondary |
                              eScreenOrientation_LandscapePrimary |
-                             eScreenOrientation_LandscapeSecondary));
+                             eScreenOrientation_LandscapeSecondary |
+                             eScreenOrientation_Default));
+
+  if (aOrientation == eScreenOrientation_Default) {
+    aOrientation = (sOrientationOffset == sDefaultPortrait) ?
+                    eScreenOrientation_PortraitPrimary :
+                    eScreenOrientation_LandscapePrimary;
+  }
 
   // If there are multiple orientations allowed, we should enable the
   // auto-rotation.
   if (aOrientation != eScreenOrientation_LandscapePrimary &&
       aOrientation != eScreenOrientation_LandscapeSecondary &&
       aOrientation != eScreenOrientation_PortraitPrimary &&
       aOrientation != eScreenOrientation_PortraitSecondary) {
     if (!mAutoOrientationEnabled) {