Bug 1194751 - Part 3. Remove unused nsIScreen::rotation attribute. r?jimm draft
authorKan-Ru Chen <kanru@kanru.info>
Thu, 09 Mar 2017 19:16:33 +0800
changeset 551526 d7fff28c9fb444589fa353f511707ac56ed82cf3
parent 551525 a154a493218991a78ab289e7e140a67380304eec
child 551527 96a8407046ed436da88719438eb52f964f24671e
push id51072
push userkchen@mozilla.com
push dateSun, 26 Mar 2017 23:21:39 +0000
reviewersjimm
bugs1194751
milestone55.0a1
Bug 1194751 - Part 3. Remove unused nsIScreen::rotation attribute. r?jimm It's only used by gonk. Remove it will make removing PScreenManager easier. MozReview-Commit-ID: GCHonrz30xK
hal/gonk/GonkHal.cpp
widget/PuppetWidget.cpp
widget/PuppetWidget.h
widget/gonk/OrientationObserver.cpp
widget/gonk/OrientationObserver.h
widget/gonk/ProcessOrientation.cpp
widget/gonk/moz.build
widget/gonk/nsAppShell.cpp
widget/gonk/nsScreenManagerGonk.cpp
widget/gonk/nsScreenManagerGonk.h
widget/nsBaseScreen.h
widget/nsIScreen.idl
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -66,17 +66,16 @@
 #include "nsIObserverService.h"
 #include "nsIRecoveryService.h"
 #include "nsIRunnable.h"
 #include "nsScreenManagerGonk.h"
 #include "nsThreadUtils.h"
 #include "nsThreadUtils.h"
 #include "nsIThread.h"
 #include "nsXULAppAPI.h"
-#include "OrientationObserver.h"
 #include "UeventPoller.h"
 #include "nsIWritablePropertyBag2.h"
 #include <algorithm>
 
 #define NsecPerMsec  1000000LL
 #define NsecPerSec   1000000000
 
 // The header linux/oom.h is not available in bionic libc. We
@@ -1007,23 +1006,22 @@ GetCurrentScreenConfiguration(hal::Scree
 {
   RefPtr<nsScreenGonk> screen = nsScreenManagerGonk::GetPrimaryScreen();
   *aScreenConfiguration = screen->GetConfiguration();
 }
 
 bool
 LockScreenOrientation(const dom::ScreenOrientationInternal& aOrientation)
 {
-  return OrientationObserver::GetInstance()->LockScreenOrientation(aOrientation);
+  return false;
 }
 
 void
 UnlockScreenOrientation()
 {
-  OrientationObserver::GetInstance()->UnlockScreenOrientation();
 }
 
 // This thread will wait for the alarm firing by a blocking IO.
 static pthread_t sAlarmFireWatcherThread;
 
 // If |sAlarmData| is non-null, it's owned by the alarm-watcher thread.
 struct AlarmData {
 public:
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -1392,30 +1392,16 @@ PuppetScreen::GetPixelDepth(int32_t *aPi
 
 NS_IMETHODIMP
 PuppetScreen::GetColorDepth(int32_t *aColorDepth)
 {
   *aColorDepth = ScreenConfig().colorDepth();
   return NS_OK;
 }
 
-NS_IMETHODIMP
-PuppetScreen::GetRotation(uint32_t* aRotation)
-{
-  NS_WARNING("Attempt to get screen rotation through nsIScreen::GetRotation().  Nothing should know or care this in sandboxed contexts.  If you want *orientation*, use hal.");
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
-NS_IMETHODIMP
-PuppetScreen::SetRotation(uint32_t aRotation)
-{
-  NS_WARNING("Attempt to set screen rotation through nsIScreen::GetRotation().  Nothing should know or care this in sandboxed contexts.  If you want *orientation*, use hal.");
-  return NS_ERROR_NOT_AVAILABLE;
-}
-
 NS_IMPL_ISUPPORTS(PuppetScreenManager, nsIScreenManager)
 
 PuppetScreenManager::PuppetScreenManager()
 {
     mOneScreen = new PuppetScreen(nullptr);
 }
 
 PuppetScreenManager::~PuppetScreenManager()
--- a/widget/PuppetWidget.h
+++ b/widget/PuppetWidget.h
@@ -443,18 +443,16 @@ public:
     explicit PuppetScreen(void* nativeScreen);
     ~PuppetScreen();
 
     NS_IMETHOD GetId(uint32_t* aId) override;
     NS_IMETHOD GetRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight) override;
     NS_IMETHOD GetAvailRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight) override;
     NS_IMETHOD GetPixelDepth(int32_t* aPixelDepth) override;
     NS_IMETHOD GetColorDepth(int32_t* aColorDepth) override;
-    NS_IMETHOD GetRotation(uint32_t* aRotation) override;
-    NS_IMETHOD SetRotation(uint32_t  aRotation) override;
 };
 
 class PuppetScreenManager final : public nsIScreenManager
 {
     ~PuppetScreenManager();
 
 public:
     PuppetScreenManager();
deleted file mode 100644
--- a/widget/gonk/OrientationObserver.cpp
+++ /dev/null
@@ -1,332 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et ft=cpp : */
-/* Copyright 2012 Mozilla Foundation and Mozilla contributors
- *
- * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "base/basictypes.h"
-#include "mozilla/ClearOnShutdown.h"
-#include "mozilla/StaticPtr.h"
-#include "mozilla/Hal.h"
-#include "nsIScreen.h"
-#include "nsIScreenManager.h"
-#include "OrientationObserver.h"
-#include "mozilla/HalSensor.h"
-#include "ProcessOrientation.h"
-#include "nsServiceManagerUtils.h"
-
-using namespace mozilla;
-using namespace dom;
-
-namespace {
-
-struct OrientationMapping {
-  uint32_t mScreenRotation;
-  ScreenOrientationInternal mDomOrientation;
-};
-
-static OrientationMapping sOrientationMappings[] = {
-  {nsIScreen::ROTATION_0_DEG,   eScreenOrientation_PortraitPrimary},
-  {nsIScreen::ROTATION_180_DEG, eScreenOrientation_PortraitSecondary},
-  {nsIScreen::ROTATION_90_DEG,  eScreenOrientation_LandscapePrimary},
-  {nsIScreen::ROTATION_270_DEG, eScreenOrientation_LandscapeSecondary},
-};
-
-const static uint32_t sDefaultLandscape = 2;
-const static uint32_t sDefaultPortrait = 0;
-
-static uint32_t sOrientationOffset = 0;
-
-static already_AddRefed<nsIScreen>
-GetPrimaryScreen()
-{
-  nsCOMPtr<nsIScreenManager> screenMgr =
-    do_GetService("@mozilla.org/gfx/screenmanager;1");
-  NS_ENSURE_TRUE(screenMgr, nullptr);
-
-  nsCOMPtr<nsIScreen> screen;
-  screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
-  return screen.forget();
-}
-
-static void
-DetectDefaultOrientation()
-{
-  nsCOMPtr<nsIScreen> screen = GetPrimaryScreen();
-  if (!screen) {
-    return;
-  }
-
-  int32_t left, top, width, height;
-  if (NS_FAILED(screen->GetRect(&left, &top, &width, &height))) {
-    return;
-  }
-
-  uint32_t rotation;
-  if (NS_FAILED(screen->GetRotation(&rotation))) {
-    return;
-  }
-
-  if (width < height) {
-    if (rotation == nsIScreen::ROTATION_0_DEG ||
-        rotation == nsIScreen::ROTATION_180_DEG) {
-      sOrientationOffset = sDefaultPortrait;
-    } else {
-      sOrientationOffset = sDefaultLandscape;
-    }
-  } else {
-    if (rotation == nsIScreen::ROTATION_0_DEG ||
-        rotation == nsIScreen::ROTATION_180_DEG) {
-      sOrientationOffset = sDefaultLandscape;
-    } else {
-      sOrientationOffset = sDefaultPortrait;
-    }
-  }
-}
-
-/**
- * Converts DOM orientation to nsIScreen rotation. Portrait and Landscape are
- * treated as PortraitPrimary and LandscapePrimary, respectively, during
- * conversion.
- *
- * @param aOrientation DOM orientation e.g.
- *        dom::eScreenOrientation_PortraitPrimary.
- * @param aResult output nsIScreen rotation e.g. nsIScreen::ROTATION_0_DEG.
- * @return NS_OK on success. NS_ILLEGAL_VALUE on failure.
- */
-static nsresult
-ConvertToScreenRotation(ScreenOrientationInternal aOrientation, uint32_t *aResult)
-{
-  for (uint32_t i = 0; i < ArrayLength(sOrientationMappings); i++) {
-    if (aOrientation & sOrientationMappings[i].mDomOrientation) {
-      // Shift the mappings in sOrientationMappings so devices with default
-      // landscape orientation map landscape-primary to 0 degree and so forth.
-      int adjusted = (i + sOrientationOffset) %
-                     ArrayLength(sOrientationMappings);
-      *aResult = sOrientationMappings[adjusted].mScreenRotation;
-      return NS_OK;
-    }
-  }
-
-  *aResult = nsIScreen::ROTATION_0_DEG;
-  return NS_ERROR_ILLEGAL_VALUE;
-}
-
-/**
- * Converts nsIScreen rotation to DOM orientation.
- *
- * @param aRotation nsIScreen rotation e.g. nsIScreen::ROTATION_0_DEG.
- * @param aResult output DOM orientation e.g.
- *        dom::eScreenOrientation_PortraitPrimary.
- * @return NS_OK on success. NS_ILLEGAL_VALUE on failure.
- */
-nsresult
-ConvertToDomOrientation(uint32_t aRotation, ScreenOrientationInternal *aResult)
-{
-  for (uint32_t i = 0; i < ArrayLength(sOrientationMappings); i++) {
-    if (aRotation == sOrientationMappings[i].mScreenRotation) {
-      // Shift the mappings in sOrientationMappings so devices with default
-      // landscape orientation map 0 degree to landscape-primary and so forth.
-      int adjusted = (i + sOrientationOffset) %
-                     ArrayLength(sOrientationMappings);
-      *aResult = sOrientationMappings[adjusted].mDomOrientation;
-      return NS_OK;
-    }
-  }
-
-  *aResult = eScreenOrientation_None;
-  return NS_ERROR_ILLEGAL_VALUE;
-}
-
-// Note that all operations with sOrientationSensorObserver
-// should be on the main thread.
-static StaticAutoPtr<OrientationObserver> sOrientationSensorObserver;
-
-} // namespace
-
-OrientationObserver*
-OrientationObserver::GetInstance()
-{
-  if (!sOrientationSensorObserver) {
-    sOrientationSensorObserver = new OrientationObserver();
-    ClearOnShutdown(&sOrientationSensorObserver);
-  }
-
-  return sOrientationSensorObserver;
-}
-
-OrientationObserver::OrientationObserver()
-  : mAutoOrientationEnabled(false)
-  , mAllowedOrientations(sDefaultOrientations)
-  , mOrientation(new mozilla::ProcessOrientation())
-{
-  DetectDefaultOrientation();
-
-  EnableAutoOrientation();
-}
-
-OrientationObserver::~OrientationObserver()
-{
-  if (mAutoOrientationEnabled) {
-    DisableAutoOrientation();
-  }
-}
-
-/* static */ void
-OrientationObserver::ShutDown()
-{
-  if (!sOrientationSensorObserver) {
-    return;
-  }
-
-  if (sOrientationSensorObserver->mAutoOrientationEnabled) {
-    sOrientationSensorObserver->DisableAutoOrientation();
-  }
-}
-
-void
-OrientationObserver::Notify(const hal::SensorData& aSensorData)
-{
-  // Sensor will call us on the main thread.
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(aSensorData.sensor() == hal::SensorType::SENSOR_ACCELERATION);
-
-  nsCOMPtr<nsIScreen> screen = GetPrimaryScreen();
-  if (!screen) {
-    return;
-  }
-
-  uint32_t currRotation;
-  if(NS_FAILED(screen->GetRotation(&currRotation))) {
-    return;
-  }
-
-  int rotation = mOrientation->OnSensorChanged(aSensorData, static_cast<int>(currRotation));
-  if (rotation < 0 || uint32_t(rotation) == currRotation) {
-    return;
-  }
-
-  ScreenOrientationInternal orientation;
-  if (NS_FAILED(ConvertToDomOrientation(rotation, &orientation))) {
-    return;
-  }
-
-  if ((mAllowedOrientations & orientation) == eScreenOrientation_None) {
-    // The orientation from sensor is not allowed.
-    return;
-  }
-
-  if (NS_FAILED(screen->SetRotation(static_cast<uint32_t>(rotation)))) {
-    // Don't notify dom on rotation failure.
-    return;
-  }
-}
-
-/**
- * Register the observer. Note that the observer shouldn't be registered.
- */
-void
-OrientationObserver::EnableAutoOrientation()
-{
-  MOZ_ASSERT(NS_IsMainThread() && !mAutoOrientationEnabled);
-
-  mOrientation->Reset();
-  hal::RegisterSensorObserver(hal::SENSOR_ACCELERATION, this);
-  mAutoOrientationEnabled = true;
-}
-
-/**
- * Unregister the observer. Note that the observer should already be registered.
- */
-void
-OrientationObserver::DisableAutoOrientation()
-{
-  MOZ_ASSERT(NS_IsMainThread() && mAutoOrientationEnabled);
-
-  hal::UnregisterSensorObserver(hal::SENSOR_ACCELERATION, this);
-  mAutoOrientationEnabled = false;
-}
-
-bool
-OrientationObserver::LockScreenOrientation(ScreenOrientationInternal aOrientation)
-{
-  MOZ_ASSERT(aOrientation | (eScreenOrientation_PortraitPrimary |
-                             eScreenOrientation_PortraitSecondary |
-                             eScreenOrientation_LandscapePrimary |
-                             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) {
-      EnableAutoOrientation();
-    }
-  } else if (mAutoOrientationEnabled) {
-    DisableAutoOrientation();
-  }
-
-  mAllowedOrientations = aOrientation;
-
-  nsCOMPtr<nsIScreen> screen = GetPrimaryScreen();
-  NS_ENSURE_TRUE(screen, false);
-
-  uint32_t currRotation;
-  nsresult rv = screen->GetRotation(&currRotation);
-  NS_ENSURE_SUCCESS(rv, false);
-
-  ScreenOrientationInternal currOrientation = eScreenOrientation_None;
-  rv = ConvertToDomOrientation(currRotation, &currOrientation);
-  NS_ENSURE_SUCCESS(rv, false);
-
-  // Don't rotate if the current orientation matches one of the
-  // requested orientations.
-  if (currOrientation & aOrientation) {
-    return true;
-  }
-
-  // Return false on invalid orientation value.
-  uint32_t rotation;
-  rv = ConvertToScreenRotation(aOrientation, &rotation);
-  NS_ENSURE_SUCCESS(rv, false);
-
-  rv = screen->SetRotation(rotation);
-  NS_ENSURE_SUCCESS(rv, false);
-
-  // This conversion will disambiguate aOrientation.
-  ScreenOrientationInternal orientation;
-  rv = ConvertToDomOrientation(rotation, &orientation);
-  NS_ENSURE_SUCCESS(rv, false);
-
-  return true;
-}
-
-void
-OrientationObserver::UnlockScreenOrientation()
-{
-  if (!mAutoOrientationEnabled) {
-    EnableAutoOrientation();
-  }
-
-  mAllowedOrientations = sDefaultOrientations;
-}
deleted file mode 100644
--- a/widget/gonk/OrientationObserver.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et ft=cpp : */
-/* Copyright 2012 Mozilla Foundation and Mozilla contributors
- *
- * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef OrientationObserver_h
-#define OrientationObserver_h
-
-#include "mozilla/Observer.h"
-#include "mozilla/dom/ScreenOrientation.h"
-#include "mozilla/UniquePtr.h"
-
-namespace mozilla {
-class ProcessOrientation;
-namespace hal {
-class SensorData;
-typedef mozilla::Observer<SensorData> ISensorObserver;
-} // namespace hal
-} // namespace mozilla
-
-using mozilla::hal::ISensorObserver;
-using mozilla::hal::SensorData;
-using mozilla::dom::ScreenOrientationInternal;
-
-class OrientationObserver : public ISensorObserver {
-public:
-  OrientationObserver();
-  ~OrientationObserver();
-
-  // Call DisableAutoOrientation on the existing OrientatiOnobserver singleton,
-  // if it exists.  If no OrientationObserver exists, do nothing.
-  static void ShutDown();
-
-  // Notification from sensor.
-  void Notify(const SensorData& aSensorData);
-
-  // Methods to enable/disable automatic orientation.
-  void EnableAutoOrientation();
-  void DisableAutoOrientation();
-
-  // Methods called by methods in hal_impl namespace.
-  bool LockScreenOrientation(ScreenOrientationInternal aOrientation);
-  void UnlockScreenOrientation();
-
-  static OrientationObserver* GetInstance();
-
-private:
-  bool mAutoOrientationEnabled;
-  uint32_t mAllowedOrientations;
-  mozilla::UniquePtr<mozilla::ProcessOrientation> mOrientation;
-
-  static const uint32_t sDefaultOrientations =
-      mozilla::dom::eScreenOrientation_PortraitPrimary |
-      mozilla::dom::eScreenOrientation_PortraitSecondary |
-      mozilla::dom::eScreenOrientation_LandscapePrimary |
-      mozilla::dom::eScreenOrientation_LandscapeSecondary;
-};
-
-#endif
--- a/widget/gonk/ProcessOrientation.cpp
+++ b/widget/gonk/ProcessOrientation.cpp
@@ -16,17 +16,16 @@
  * limitations under the License.
  */
 
 #include "base/basictypes.h"
 #include "mozilla/Hal.h"
 #include "mozilla/Unused.h"
 #include "nsIScreen.h"
 #include "nsIScreenManager.h"
-#include "OrientationObserver.h"
 #include "ProcessOrientation.h"
 #include "mozilla/HalSensor.h"
 #include "math.h"
 #include "limits.h"
 #include "android/log.h"
 
 #if 0
 #define LOGD(args...)  __android_log_print(ANDROID_LOG_DEBUG, "ProcessOrientation" , ## args)
--- a/widget/gonk/moz.build
+++ b/widget/gonk/moz.build
@@ -12,17 +12,16 @@
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
 EXPORTS += [
     'GeckoTouchDispatcher.h',
     'GonkPermission.h',
-    'OrientationObserver.h',
 ]
 
 DIRS += ['libdisplay', 'nativewindow']
 
 # libui files
 SOURCES += ['libui/' + src for src in [
     'EventHub.cpp',
     'Input.cpp',
@@ -61,17 +60,16 @@ SOURCES += [
     'HwcUtils.cpp',
     'nsAppShell.cpp',
     'nsClipboard.cpp',
     'nsIdleServiceGonk.cpp',
     'nsLookAndFeel.cpp',
     'nsScreenManagerGonk.cpp',
     'nsWidgetFactory.cpp',
     'nsWindow.cpp',
-    'OrientationObserver.cpp',
     'ProcessOrientation.cpp',
     'WidgetTraceEvent.cpp'
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
--- a/widget/gonk/nsAppShell.cpp
+++ b/widget/gonk/nsAppShell.cpp
@@ -50,17 +50,16 @@
 #include "mozilla/DebugOnly.h"
 #include "mozilla/dom/Touch.h"
 #include "nsGkAtoms.h"
 #include "nsIObserverService.h"
 #include "nsIScreen.h"
 #include "nsScreenManagerGonk.h"
 #include "nsThreadUtils.h"
 #include "nsWindow.h"
-#include "OrientationObserver.h"
 #include "GonkMemoryPressureMonitoring.h"
 
 #include "android/log.h"
 #include "libui/EventHub.h"
 #include "libui/InputReader.h"
 #include "libui/InputDispatcher.h"
 
 #include "mozilla/Preferences.h"
@@ -552,49 +551,27 @@ private:
     bool mKeyEventsFiltered;
     bool mPowerWakelock;
 };
 
 // GeckoInputReaderPolicy
 void
 GeckoInputReaderPolicy::setDisplayInfo()
 {
-    static_assert(static_cast<int>(nsIScreen::ROTATION_0_DEG) ==
-                  static_cast<int>(DISPLAY_ORIENTATION_0),
-                  "Orientation enums not matched!");
-    static_assert(static_cast<int>(nsIScreen::ROTATION_90_DEG) ==
-                  static_cast<int>(DISPLAY_ORIENTATION_90),
-                  "Orientation enums not matched!");
-    static_assert(static_cast<int>(nsIScreen::ROTATION_180_DEG) ==
-                  static_cast<int>(DISPLAY_ORIENTATION_180),
-                  "Orientation enums not matched!");
-    static_assert(static_cast<int>(nsIScreen::ROTATION_270_DEG) ==
-                  static_cast<int>(DISPLAY_ORIENTATION_270),
-                  "Orientation enums not matched!");
-
     RefPtr<nsScreenGonk> screen = nsScreenManagerGonk::GetPrimaryScreen();
 
-    uint32_t rotation = nsIScreen::ROTATION_0_DEG;
-    DebugOnly<nsresult> rv = screen->GetRotation(&rotation);
-    MOZ_ASSERT(NS_SUCCEEDED(rv));
     LayoutDeviceIntRect screenBounds = screen->GetNaturalBounds();
 
     DisplayViewport viewport;
     viewport.displayId = 0;
-    viewport.orientation = rotation;
+    viewport.orientation = DISPLAY_ORIENTATION_0;
     viewport.physicalRight = viewport.deviceWidth = screenBounds.width;
     viewport.physicalBottom = viewport.deviceHeight = screenBounds.height;
-    if (viewport.orientation == DISPLAY_ORIENTATION_90 ||
-        viewport.orientation == DISPLAY_ORIENTATION_270) {
-        viewport.logicalRight = screenBounds.height;
-        viewport.logicalBottom = screenBounds.width;
-    } else {
-        viewport.logicalRight = screenBounds.width;
-        viewport.logicalBottom = screenBounds.height;
-    }
+    viewport.logicalRight = screenBounds.width;
+    viewport.logicalBottom = screenBounds.height;
     mConfig.setDisplayInfo(false, viewport);
 }
 
 void GeckoInputReaderPolicy::getReaderConfiguration(InputReaderConfiguration* outConfig)
 {
     *outConfig = mConfig;
 }
 
@@ -961,17 +938,16 @@ nsAppShell::Observe(nsISupports* aSubjec
     }
 
     return nsBaseAppShell::Observe(aSubject, aTopic, aData);
 }
 
 NS_IMETHODIMP
 nsAppShell::Exit()
 {
-    OrientationObserver::ShutDown();
     nsCOMPtr<nsIObserverService> obsServ = GetObserverService();
     if (obsServ) {
         obsServ->RemoveObserver(this, "browser-ui-startup-complete");
         obsServ->RemoveObserver(this, "network-connection-state-changed");
     }
     return nsBaseAppShell::Exit();
 }
 
@@ -1065,19 +1041,16 @@ nsAppShell::NotifyNativeEvent()
 {
     write(signalfds[1], "w", 1);
 }
 
 /* static */ void
 nsAppShell::NotifyScreenInitialized()
 {
     gAppShell->InitInputDevices();
-
-    // Getting the instance of OrientationObserver to initialize it.
-    OrientationObserver::GetInstance();
 }
 
 /* static */ void
 nsAppShell::NotifyScreenRotation()
 {
     gAppShell->mReaderPolicy->setDisplayInfo();
     gAppShell->mReader->requestRefreshConfiguration(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
 
--- a/widget/gonk/nsScreenManagerGonk.cpp
+++ b/widget/gonk/nsScreenManagerGonk.cpp
@@ -233,23 +233,16 @@ nsScreenGonk::GetPixelDepth(int32_t *aPi
 
 NS_IMETHODIMP
 nsScreenGonk::GetColorDepth(int32_t *aColorDepth)
 {
     *aColorDepth = mColorDepth;
     return NS_OK;
 }
 
-NS_IMETHODIMP
-nsScreenGonk::GetRotation(uint32_t* aRotation)
-{
-    *aRotation = mScreenRotation;
-    return NS_OK;
-}
-
 float
 nsScreenGonk::GetDpi()
 {
     return mDpi;
 }
 
 int32_t
 nsScreenGonk::GetSurfaceFormat()
@@ -258,49 +251,16 @@ nsScreenGonk::GetSurfaceFormat()
 }
 
 ANativeWindow*
 nsScreenGonk::GetNativeWindow()
 {
     return mNativeWindow.get();
 }
 
-NS_IMETHODIMP
-nsScreenGonk::SetRotation(uint32_t aRotation)
-{
-    if (!(aRotation <= ROTATION_270_DEG)) {
-        return NS_ERROR_ILLEGAL_VALUE;
-    }
-
-    if (mScreenRotation == aRotation) {
-        return NS_OK;
-    }
-
-    mScreenRotation = aRotation;
-    uint32_t rotation = EffectiveScreenRotation();
-    if (rotation == nsIScreen::ROTATION_90_DEG ||
-        rotation == nsIScreen::ROTATION_270_DEG) {
-        mVirtualBounds = LayoutDeviceIntRect(0, 0,
-                                             mNaturalBounds.height,
-                                             mNaturalBounds.width);
-    } else {
-        mVirtualBounds = mNaturalBounds;
-    }
-
-    nsAppShell::NotifyScreenRotation();
-
-    for (unsigned int i = 0; i < mTopWindows.Length(); i++) {
-        mTopWindows[i]->Resize(mVirtualBounds.width,
-                               mVirtualBounds.height,
-                               true);
-    }
-
-    return NS_OK;
-}
-
 LayoutDeviceIntRect
 nsScreenGonk::GetNaturalBounds()
 {
     return mNaturalBounds;
 }
 
 uint32_t
 nsScreenGonk::EffectiveScreenRotation()
--- a/widget/gonk/nsScreenManagerGonk.h
+++ b/widget/gonk/nsScreenManagerGonk.h
@@ -70,18 +70,16 @@ public:
 
     ~nsScreenGonk();
 
     NS_IMETHOD GetId(uint32_t* aId);
     NS_IMETHOD GetRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight);
     NS_IMETHOD GetAvailRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight);
     NS_IMETHOD GetPixelDepth(int32_t* aPixelDepth);
     NS_IMETHOD GetColorDepth(int32_t* aColorDepth);
-    NS_IMETHOD GetRotation(uint32_t* aRotation);
-    NS_IMETHOD SetRotation(uint32_t  aRotation);
 
     uint32_t GetId();
     NotifyDisplayChangedEvent GetEventVisibility();
     LayoutDeviceIntRect GetRect();
     float GetDpi();
     int32_t GetSurfaceFormat();
     ANativeWindow* GetNativeWindow();
     LayoutDeviceIntRect GetNaturalBounds();
--- a/widget/nsBaseScreen.h
+++ b/widget/nsBaseScreen.h
@@ -23,22 +23,16 @@ public:
   // These simply forward to the device-pixel versions;
   // implementations where desktop pixels may not correspond
   // to per-screen device pixels must override.
   NS_IMETHOD GetRectDisplayPix(int32_t *outLeft,  int32_t *outTop,
                                int32_t *outWidth, int32_t *outHeight) override;
   NS_IMETHOD GetAvailRectDisplayPix(int32_t *outLeft,  int32_t *outTop,
                                     int32_t *outWidth, int32_t *outHeight) override;
 
-  NS_IMETHOD GetRotation(uint32_t* aRotation) override {
-    *aRotation = nsIScreen::ROTATION_0_DEG;
-    return NS_OK;
-  }
-  NS_IMETHOD SetRotation(uint32_t aRotation) override { return NS_ERROR_NOT_AVAILABLE; }
-
   NS_IMETHOD GetContentsScaleFactor(double* aContentsScaleFactor) override;
 
   NS_IMETHOD GetDefaultCSSScaleFactor(double* aScaleFactor) override;
 
 protected:
   virtual ~nsBaseScreen();
 };
 
--- a/widget/nsIScreen.idl
+++ b/widget/nsIScreen.idl
@@ -16,27 +16,16 @@ enum class DisplayType: int32_t {
   DISPLAY_VIRTUAL   // wireless displays, such as Chromecast, WiFi-Display, etc.
 };
 %}
 
 [scriptable, uuid(826e80c8-d70f-42e2-8aa9-82c05f2a370a)]
 interface nsIScreen : nsISupports
 {
   /**
-   * Allowable screen rotations, when the underlying widget toolkit
-   * supports rotating the screen.
-   *
-   * ROTATION_0_DEG is the default, unrotated configuration.
-   */
-  const unsigned long   ROTATION_0_DEG = 0;
-  const unsigned long  ROTATION_90_DEG = 1;
-  const unsigned long ROTATION_180_DEG = 2;
-  const unsigned long ROTATION_270_DEG = 3;
-
-  /**
    * A unique identifier for this device, useful for requerying
    * for it via nsIScreenManager.
    */
   readonly attribute unsigned long id;
 
   /**
    * These report screen dimensions in (screen-specific) device pixels
    */
@@ -46,21 +35,16 @@ interface nsIScreen : nsISupports
   /**
    * And these report in desktop pixels
    */
   void GetRectDisplayPix(out long left, out long top, out long width, out long height);
   void GetAvailRectDisplayPix(out long left, out long top, out long width, out long height);
 
   readonly attribute long pixelDepth;
   readonly attribute long colorDepth;
-  /**
-   * Get/set the screen rotation, on platforms that support changing
-   * screen rotation.
-   */
-  attribute unsigned long rotation;
 
   /**
    * The number of device pixels per desktop pixel for this screen (for
    * hidpi configurations where there may be multiple device pixels per
    * desktop px and/or per CSS px).
    *
    * This seems poorly named (something like devicePixelsPerDesktopPixel
    * would be more accurate/explicit), but given that it is exposed to