Skip to content

Commit

Permalink
Bug 908058 - Add orientation keyword 'default' to express normal orie…
Browse files Browse the repository at this point in the history
…ntation. r=mounir, r=blassey
  • Loading branch information
viralwang committed Sep 30, 2013
1 parent 481ac47 commit 2345a99
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions dom/base/ScreenOrientation.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ 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
Expand Down
2 changes: 2 additions & 0 deletions dom/base/nsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ nsScreen::MozLockOrientation(const Sequence<nsString>& aOrientations,
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.
Expand Down
1 change: 1 addition & 0 deletions hal/android/AndroidHal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ LockScreenOrientation(const ScreenOrientation& aOrientation)
case eScreenOrientation_LandscapePrimary:
case eScreenOrientation_LandscapeSecondary:
case eScreenOrientation_LandscapePrimary | eScreenOrientation_LandscapeSecondary:
case eScreenOrientation_Default:
bridge->LockScreenOrientation(aOrientation);
return true;
default:
Expand Down
4 changes: 4 additions & 0 deletions mobile/android/base/GeckoScreenOrientationListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void onOrientationChanged(int aOrientation) {
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;

Expand Down Expand Up @@ -199,6 +200,9 @@ public void lockScreenOrientation(int aOrientation) {
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;
Expand Down
9 changes: 8 additions & 1 deletion widget/gonk/OrientationObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,14 @@ 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.
Expand Down

0 comments on commit 2345a99

Please sign in to comment.