Back out 5e76dfb1d426 (bug 826635) and 0df74b1a4543:20df426b6111 (bug 826632) for bustage
authorPhil Ringnalda <philringnalda@gmail.com>
Fri, 04 Jan 2013 21:30:14 -0800
changeset 126826 ea909ce6007b1c67b3bb9ef0d197ef8845399e9c
parent 126825 dcd2c2de5e65da154a6ebf6fe5da17ce45b3a7b3
child 126827 08570379483ee9e80a8807bab27ee831e37a7c7a
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs826635, 826632
milestone20.0a1
backs out5e76dfb1d426caa6e5fac3ac440184598066f969
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
Back out 5e76dfb1d426 (bug 826635) and 0df74b1a4543:20df426b6111 (bug 826632) for bustage CLOSED TREE
accessible/src/generic/DocAccessible.cpp
accessible/src/mac/RootAccessibleWrap.mm
accessible/src/msaa/AccessibleWrap.cpp
accessible/src/msaa/DocAccessibleWrap.cpp
content/base/public/nsIDocument.h
content/base/src/Element.cpp
content/base/src/FragmentOrElement.cpp
content/base/src/nsContentSink.cpp
content/base/src/nsContentSink.h
content/base/src/nsContentUtils.cpp
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
content/base/src/nsINode.cpp
content/events/src/nsEventListenerManager.cpp
content/events/src/nsIMEStateManager.cpp
content/html/content/src/nsGenericHTMLElement.cpp
content/html/document/src/MediaDocument.cpp
content/html/document/src/nsHTMLDocument.cpp
content/html/document/src/nsHTMLDocument.h
content/xml/document/src/nsXMLContentSink.h
content/xul/content/src/nsXULElement.cpp
content/xul/content/src/nsXULPopupListener.cpp
content/xul/document/src/nsXULContentSink.cpp
content/xul/document/src/nsXULDocument.cpp
docshell/base/nsDocShell.cpp
dom/base/nsDOMWindowUtils.cpp
dom/base/nsFocusManager.cpp
dom/base/nsGlobalWindow.cpp
dom/ipc/TabParent.cpp
dom/plugins/base/nsPluginInstanceOwner.cpp
embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
extensions/widgetutils/src/nsWidgetUtils.cpp
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsCSSRendering.cpp
layout/base/nsCSSRenderingBorders.cpp
layout/base/nsDisplayList.cpp
layout/base/nsDocumentViewer.cpp
layout/base/nsIDocumentViewerPrint.h
layout/base/nsIPresShell.h
layout/base/nsPresContext.cpp
layout/base/nsPresShell.cpp
layout/base/nsPresShell.h
layout/base/nsRefreshDriver.cpp
layout/build/nsLayoutModule.cpp
layout/forms/nsComboboxControlFrame.cpp
layout/forms/nsListControlFrame.cpp
layout/forms/nsTextControlFrame.cpp
layout/generic/nsContainerFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsFrameSetFrame.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsObjectFrame.cpp
layout/generic/nsSubDocumentFrame.cpp
layout/printing/nsPrintEngine.cpp
layout/printing/nsPrintObject.h
layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp
layout/tools/layout-debug/src/nsRegressionTester.cpp
layout/xul/base/src/nsBoxFrame.cpp
layout/xul/base/src/nsDeckFrame.cpp
layout/xul/base/src/nsLeafBoxFrame.cpp
layout/xul/base/src/nsListBoxBodyFrame.cpp
layout/xul/base/src/nsMenuPopupFrame.cpp
layout/xul/base/src/nsMenuPopupFrame.h
layout/xul/base/src/nsXULPopupManager.cpp
layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
view/public/Makefile.in
view/public/nsIViewManager.h
view/public/nsView.h
view/public/nsViewManager.h
view/public/nsViewsCID.h
view/src/nsView.cpp
view/src/nsViewManager.cpp
view/src/nsViewManager.h
widget/android/nsWindow.cpp
widget/cocoa/nsChildView.mm
widget/gtk2/nsDragService.cpp
widget/gtk2/nsNativeThemeGTK.cpp
widget/tests/TestWinTSF.cpp
widget/xpwidgets/nsBaseDragService.cpp
--- a/accessible/src/generic/DocAccessible.cpp
+++ b/accessible/src/generic/DocAccessible.cpp
@@ -30,17 +30,17 @@
 #include "nsIDOMXULPopupElement.h"
 #include "nsIEditingSession.h"
 #include "nsEventStateManager.h"
 #include "nsIFrame.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsINameSpaceManager.h"
 #include "nsIPresShell.h"
 #include "nsIServiceManager.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIScrollableFrame.h"
 #include "nsUnicharUtils.h"
 #include "nsIURI.h"
 #include "nsIWebNavigation.h"
 #include "nsFocusManager.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/dom/Element.h"
 
@@ -1248,17 +1248,17 @@ DocAccessible::HandleAccEvent(AccEvent* 
 // Public members
 
 void*
 DocAccessible::GetNativeWindow() const
 {
   if (!mPresShell)
     return nullptr;
 
-  nsViewManager* vm = mPresShell->GetViewManager();
+  nsIViewManager* vm = mPresShell->GetViewManager();
   if (!vm)
     return nullptr;
 
   nsCOMPtr<nsIWidget> widget;
   vm->GetRootWidget(getter_AddRefs(widget));
   if (widget)
     return widget->GetNativeData(NS_NATIVE_WINDOW);
 
--- a/accessible/src/mac/RootAccessibleWrap.mm
+++ b/accessible/src/mac/RootAccessibleWrap.mm
@@ -5,17 +5,17 @@
 
 #include "RootAccessibleWrap.h"
 
 #include "mozDocAccessible.h"
 
 #include "nsCOMPtr.h"
 #include "nsObjCExceptions.h"
 #include "nsIWidget.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 
 using namespace mozilla::a11y;
 
 RootAccessibleWrap::
   RootAccessibleWrap(nsIDocument* aDocument, nsIContent* aRootContent,
                      nsIPresShell* aPresShell) :
   RootAccessible(aDocument, aRootContent, aPresShell)
 {
--- a/accessible/src/msaa/AccessibleWrap.cpp
+++ b/accessible/src/msaa/AccessibleWrap.cpp
@@ -29,17 +29,17 @@
 #include "nsIMutableArray.h"
 #include "nsIFrame.h"
 #include "nsIScrollableFrame.h"
 #include "nsINameSpaceManager.h"
 #include "nsINodeInfo.h"
 #include "nsIServiceManager.h"
 #include "nsTextFormatter.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsEventMap.h"
 #include "nsArrayUtils.h"
 #include "mozilla/Preferences.h"
 
 #include "Accessible2_i.c"
 #include "AccessibleRole.h"
 #include "AccessibleStates.h"
 #include "oleacc.h"
@@ -1648,17 +1648,17 @@ AccessibleWrap::GetHWNDFor(Accessible* a
     // Popup lives in own windows, use its HWND until the popup window is
     // hidden to make old JAWS versions work with collapsed comboboxes (see
     // discussion in bug 379678).
     nsIFrame* frame = aAccessible->GetFrame();
     if (frame) {
       nsIWidget* widget = frame->GetNearestWidget();
       if (widget && widget->IsVisible()) {
         nsIPresShell* shell = document->PresShell();
-        nsViewManager* vm = shell->GetViewManager();
+        nsIViewManager* vm = shell->GetViewManager();
         if (vm) {
           nsCOMPtr<nsIWidget> rootWidget;
           vm->GetRootWidget(getter_AddRefs(rootWidget));
           // Make sure the accessible belongs to popup. If not then use
           // document HWND (which might be different from root widget in the
           // case of window emulation).
           if (rootWidget != widget)
             return static_cast<HWND>(widget->GetNativeData(NS_NATIVE_WINDOW));
--- a/accessible/src/msaa/DocAccessibleWrap.cpp
+++ b/accessible/src/msaa/DocAccessibleWrap.cpp
@@ -16,17 +16,17 @@
 #include "Statistics.h"
 
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeNode.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsISelectionController.h"
 #include "nsIServiceManager.h"
 #include "nsIURI.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIWebNavigation.h"
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 
 /* For documentation of the accessibility architecture, 
  * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
  */
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -60,17 +60,17 @@ class nsIObserver;
 class nsIPresShell;
 class nsIPrincipal;
 class nsIRequest;
 class nsIStreamListener;
 class nsIStyleRule;
 class nsIStyleSheet;
 class nsIURI;
 class nsIVariant;
-class nsViewManager;
+class nsIViewManager;
 class nsPresContext;
 class nsRange;
 class nsScriptLoader;
 class nsSMILAnimationController;
 class nsStyleSet;
 class nsTextNode;
 class nsWindowSizes;
 class nsSmallVoidArray;
@@ -473,17 +473,17 @@ public:
   /**
    * Create a new presentation shell that will use aContext for its
    * presentation context (presentation contexts <b>must not</b> be
    * shared among multiple presentation shells). The caller of this
    * method is responsible for calling BeginObservingDocument() on the
    * presshell if the presshell should observe document mutations.
    */
   virtual nsresult CreateShell(nsPresContext* aContext,
-                               nsViewManager* aViewManager,
+                               nsIViewManager* aViewManager,
                                nsStyleSet* aStyleSet,
                                nsIPresShell** aInstancePtrResult) = 0;
   virtual void DeleteShell() = 0;
 
   nsIPresShell* GetShell() const
   {
     return GetBFCacheEntry() ? nullptr : mPresShell;
   }
--- a/content/base/src/Element.cpp
+++ b/content/base/src/Element.cpp
@@ -89,17 +89,17 @@
 #include "nsGenericHTMLElement.h"
 #include "nsIEditor.h"
 #include "nsIEditorIMESupport.h"
 #include "nsIEditorDocShell.h"
 #include "nsEventDispatcher.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsIControllers.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIScrollableFrame.h"
 #include "nsXBLInsertionPoint.h"
 #include "mozilla/css/StyleRule.h" /* For nsCSSSelectorList */
 #include "nsCSSRuleProcessor.h"
 #include "nsRuleProcessorData.h"
 #include "nsAsyncDOMEvent.h"
 #include "nsTextNode.h"
 
--- a/content/base/src/FragmentOrElement.cpp
+++ b/content/base/src/FragmentOrElement.cpp
@@ -88,17 +88,17 @@
 #include "nsGenericHTMLElement.h"
 #include "nsIEditor.h"
 #include "nsIEditorIMESupport.h"
 #include "nsIEditorDocShell.h"
 #include "nsEventDispatcher.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsIControllers.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIScrollableFrame.h"
 #include "nsXBLInsertionPoint.h"
 #include "mozilla/css/StyleRule.h" /* For nsCSSSelectorList */
 #include "nsRuleProcessorData.h"
 #include "nsAsyncDOMEvent.h"
 #include "nsTextNode.h"
 #include "mozilla/dom/NodeListBinding.h"
 #include "mozilla/dom/UndoManager.h"
--- a/content/base/src/nsContentSink.cpp
+++ b/content/base/src/nsContentSink.cpp
@@ -20,17 +20,17 @@
 #include "nsIDocShellTreeItem.h"
 #include "nsCPrefetchService.h"
 #include "nsIURI.h"
 #include "nsNetUtil.h"
 #include "nsIHttpChannel.h"
 #include "nsIContent.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIAtom.h"
 #include "nsGkAtoms.h"
 #include "nsIDOMWindow.h"
 #include "nsNetCID.h"
 #include "nsIOfflineCacheUpdate.h"
 #include "nsIApplicationCache.h"
 #include "nsIApplicationCacheContainer.h"
 #include "nsIApplicationCacheChannel.h"
@@ -1366,17 +1366,17 @@ nsContentSink::DidProcessATokenImpl()
   }
 
   // Increase before comparing to gEventProbeRate
   ++mDeflectedCount;
 
   // Check if there's a pending event
   if (sPendingEventMode != 0 && !mHasPendingEvent &&
       (mDeflectedCount % sEventProbeRate) == 0) {
-    nsViewManager* vm = shell->GetViewManager();
+    nsIViewManager* vm = shell->GetViewManager();
     NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
     nsCOMPtr<nsIWidget> widget;
     vm->GetRootWidget(getter_AddRefs(widget));
     mHasPendingEvent = widget && widget->HasPendingInputEvent();
   }
 
   if (mHasPendingEvent && sPendingEventMode == 2) {
     return NS_ERROR_HTMLPARSER_INTERRUPTED;
@@ -1513,17 +1513,17 @@ nsContentSink::WillParseImpl(void)
   nsIPresShell *shell = mDocument->GetShell();
   if (!shell) {
     return NS_OK;
   }
 
   uint32_t currentTime = PR_IntervalToMicroseconds(PR_IntervalNow());
 
   if (sEnablePerfMode == 0) {
-    nsViewManager* vm = shell->GetViewManager();
+    nsIViewManager* vm = shell->GetViewManager();
     NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
     uint32_t lastEventTime;
     vm->GetLastUserEventTime(lastEventTime);
 
     bool newDynLower =
       mDocument->IsInBackgroundWindow() ||
       ((currentTime - mBeginLoadTime) > uint32_t(sInitialPerfTime) &&
        (currentTime - lastEventTime) < uint32_t(sInteractiveTime));
--- a/content/base/src/nsContentSink.h
+++ b/content/base/src/nsContentSink.h
@@ -29,17 +29,17 @@
 class nsIDocument;
 class nsIURI;
 class nsIChannel;
 class nsIDocShell;
 class nsIParser;
 class nsIAtom;
 class nsIChannel;
 class nsIContent;
-class nsViewManager;
+class nsIViewManager;
 class nsNodeInfoManager;
 class nsScriptLoader;
 class nsIApplicationCache;
 
 namespace mozilla {
 namespace css {
 class Loader;
 }
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -110,17 +110,17 @@
 #include "nsDOMDataTransfer.h"
 #include "nsHtml5Module.h"
 #include "nsPresContext.h"
 #include "nsLayoutStatics.h"
 #include "nsFocusManager.h"
 #include "nsTextEditorState.h"
 #include "nsIPluginHost.h"
 #include "nsICategoryManager.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsEventStateManager.h"
 #include "nsIDOMHTMLInputElement.h"
 #include "nsParserConstants.h"
 #include "nsIWebNavigation.h"
 #include "nsILoadContext.h"
 #include "nsTextFragment.h"
 #include "mozilla/Selection.h"
 
@@ -6430,21 +6430,21 @@ nsContentUtils::FindPresShellForDocument
   return nullptr;
 }
 
 nsIWidget*
 nsContentUtils::WidgetForDocument(nsIDocument* aDoc)
 {
   nsIPresShell* shell = FindPresShellForDocument(aDoc);
   if (shell) {
-    nsViewManager* VM = shell->GetViewManager();
+    nsIViewManager* VM = shell->GetViewManager();
     if (VM) {
       nsView* rootView = VM->GetRootView();
       if (rootView) {
-        nsView* displayRoot = nsViewManager::GetDisplayRootFor(rootView);
+        nsView* displayRoot = nsIViewManager::GetDisplayRootFor(rootView);
         if (displayRoot) {
           return displayRoot->GetNearestWidget(nullptr);
         }
       }
     }
   }
 
   return nullptr;
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -3114,30 +3114,30 @@ nsDocument::TryChannelCharset(nsIChannel
         aExecutor->ComplainAboutBogusProtocolCharset(this);
       }
     }
   }
   return false;
 }
 
 nsresult
-nsDocument::CreateShell(nsPresContext* aContext, nsViewManager* aViewManager,
+nsDocument::CreateShell(nsPresContext* aContext, nsIViewManager* aViewManager,
                         nsStyleSet* aStyleSet,
                         nsIPresShell** aInstancePtrResult)
 {
   // Don't add anything here.  Add it to |doCreateShell| instead.
   // This exists so that subclasses can pass other values for the 4th
   // parameter some of the time.
   return doCreateShell(aContext, aViewManager, aStyleSet,
                        eCompatibility_FullStandards, aInstancePtrResult);
 }
 
 nsresult
 nsDocument::doCreateShell(nsPresContext* aContext,
-                          nsViewManager* aViewManager, nsStyleSet* aStyleSet,
+                          nsIViewManager* aViewManager, nsStyleSet* aStyleSet,
                           nsCompatibility aCompatMode,
                           nsIPresShell** aInstancePtrResult)
 {
   *aInstancePtrResult = nullptr;
 
   NS_ASSERTION(!mPresShell, "We have a presshell already!");
 
   NS_ENSURE_FALSE(GetBFCacheEntry(), NS_ERROR_FAILURE);
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -563,17 +563,17 @@ public:
                              const nsAString& aData);
 
   /**
    * Create a new presentation shell that will use aContext for
    * its presentation context (presentation context's <b>must not</b> be
    * shared among multiple presentation shell's).
    */
   virtual nsresult CreateShell(nsPresContext* aContext,
-                               nsViewManager* aViewManager,
+                               nsIViewManager* aViewManager,
                                nsStyleSet* aStyleSet,
                                nsIPresShell** aInstancePtrResult);
   virtual void DeleteShell();
 
   virtual nsresult GetAllowPlugins(bool* aAllowPlugins);
 
   virtual already_AddRefed<mozilla::dom::UndoManager> GetUndoManager();
 
@@ -1071,17 +1071,17 @@ protected:
 public:
   // Get our title
   virtual void GetTitle(nsString& aTitle);
   // Set our title
   virtual void SetTitle(const nsAString& aTitle, mozilla::ErrorResult& rv);
 
 protected:
   nsresult doCreateShell(nsPresContext* aContext,
-                         nsViewManager* aViewManager, nsStyleSet* aStyleSet,
+                         nsIViewManager* aViewManager, nsStyleSet* aStyleSet,
                          nsCompatibility aCompatMode,
                          nsIPresShell** aInstancePtrResult);
 
   void RemoveStyleSheetsFromStyleSets(nsCOMArray<nsIStyleSheet>& aSheets, 
                                       nsStyleSet::sheetType aType);
   nsresult ResetStylesheetsToURI(nsIURI* aURI);
   void FillStyleSet(nsStyleSet* aStyleSet);
 
--- a/content/base/src/nsINode.cpp
+++ b/content/base/src/nsINode.cpp
@@ -69,17 +69,17 @@
 #include "nsIPresShell.h"
 #include "nsIScriptError.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIScrollableFrame.h"
 #include "nsIServiceManager.h"
 #include "nsIURL.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIWebNavigation.h"
 #include "nsIWidget.h"
 #include "nsLayoutStatics.h"
 #include "nsLayoutUtils.h"
 #include "nsMutationEvent.h"
 #include "nsNetUtil.h"
 #include "nsNodeInfoManager.h"
 #include "nsNodeUtils.h"
--- a/content/events/src/nsEventListenerManager.cpp
+++ b/content/events/src/nsEventListenerManager.cpp
@@ -22,17 +22,17 @@
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptRuntime.h"
 #include "nsLayoutUtils.h"
 #include "nsINameSpaceManager.h"
 #include "nsIContent.h"
 #include "mozilla/dom/Element.h"
 #include "nsIFrame.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsCOMPtr.h"
 #include "nsIServiceManager.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsError.h"
 #include "nsIJSContextStack.h"
 #include "nsIDocument.h"
 #include "nsIPresShell.h"
 #include "nsMutationEvent.h"
--- a/content/events/src/nsIMEStateManager.cpp
+++ b/content/events/src/nsIMEStateManager.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=2 sw=2 et tw=80: */
 /* 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/. */
 
 #include "nsIMEStateManager.h"
 #include "nsCOMPtr.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIPresShell.h"
 #include "nsISupports.h"
 #include "nsPIDOMWindow.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIEditorDocShell.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsPresContext.h"
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -33,17 +33,17 @@
 #include "nsPIDOMWindow.h"
 #include "nsIStyleRule.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
 #include "nsEscape.h"
 #include "nsIFrame.h"
 #include "nsIScrollableFrame.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIWidget.h"
 #include "nsRange.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsINameSpaceManager.h"
 #include "nsError.h"
--- a/content/html/document/src/MediaDocument.cpp
+++ b/content/html/document/src/MediaDocument.cpp
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MediaDocument.h"
 #include "nsGkAtoms.h"
 #include "nsRect.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsIScrollable.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsITextToSubURI.h"
 #include "nsIURL.h"
 #include "nsIContentViewer.h"
 #include "nsIMarkupDocumentViewer.h"
 #include "nsIDocShell.h"
 #include "nsCharsetSource.h" // kCharsetFrom* macro definition
 #include "nsNodeInfoManager.h"
 #include "nsContentUtils.h"
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -300,17 +300,17 @@ nsHTMLDocument::ResetToURI(nsIURI *aURI,
   // Make the content type default to "text/html", we are a HTML
   // document, after all. Once we start getting data, this may be
   // changed.
   SetContentTypeInternal(nsDependentCString("text/html"));
 }
 
 nsresult
 nsHTMLDocument::CreateShell(nsPresContext* aContext,
-                            nsViewManager* aViewManager,
+                            nsIViewManager* aViewManager,
                             nsStyleSet* aStyleSet,
                             nsIPresShell** aInstancePtrResult)
 {
   return doCreateShell(aContext, aViewManager, aStyleSet, mCompatMode,
                        aInstancePtrResult);
 }
 
 void
--- a/content/html/document/src/nsHTMLDocument.h
+++ b/content/html/document/src/nsHTMLDocument.h
@@ -50,17 +50,17 @@ public:
   NS_IMETHOD_(nsrefcnt) AddRef(void);
   NS_IMETHOD_(nsrefcnt) Release(void);
 
   virtual void Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup);
   virtual void ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup,
                           nsIPrincipal* aPrincipal);
 
   virtual nsresult CreateShell(nsPresContext* aContext,
-                               nsViewManager* aViewManager,
+                               nsIViewManager* aViewManager,
                                nsStyleSet* aStyleSet,
                                nsIPresShell** aInstancePtrResult);
 
   virtual nsresult StartDocumentLoad(const char* aCommand,
                                      nsIChannel* aChannel,
                                      nsILoadGroup* aLoadGroup,
                                      nsISupports* aContainer,
                                      nsIStreamListener **aDocListener,
--- a/content/xml/document/src/nsXMLContentSink.h
+++ b/content/xml/document/src/nsXMLContentSink.h
@@ -17,17 +17,17 @@
 #include "nsIDTD.h"
 #include "mozilla/dom/FromParser.h"
 
 class nsIDocument;
 class nsIURI;
 class nsIContent;
 class nsINodeInfo;
 class nsIParser;
-class nsViewManager;
+class nsIViewManager;
 
 typedef enum {
   eXMLContentSinkState_InProlog,
   eXMLContentSinkState_InDocumentElement,
   eXMLContentSinkState_InEpilog
 } XMLContentSinkState;
 
 struct StackNode {
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -49,17 +49,17 @@
 #include "nsIScriptContext.h"
 #include "nsIScriptRuntime.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptGlobalObjectOwner.h"
 #include "nsIServiceManager.h"
 #include "mozilla/css/StyleRule.h"
 #include "nsIStyleSheet.h"
 #include "nsIURL.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIWidget.h"
 #include "nsIXULDocument.h"
 #include "nsIXULTemplateBuilder.h"
 #include "nsLayoutCID.h"
 #include "nsContentCID.h"
 #include "nsRDFCID.h"
 #include "nsStyleConsts.h"
 #include "nsXPIDLString.h"
--- a/content/xul/content/src/nsXULPopupListener.cpp
+++ b/content/xul/content/src/nsXULPopupListener.cpp
@@ -35,17 +35,17 @@
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/FragmentOrElement.h"
 
 // for event firing in context menus
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsFocusManager.h"
 #include "nsPIDOMWindow.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsError.h"
 #include "nsMenuFrame.h"
 
 using namespace mozilla;
 
 // on win32 and os/2, context menus come up on mouse up. On other platforms,
 // they appear on mouse down. Certain bits of code care about this difference.
 #if defined(XP_WIN) || defined(XP_OS2)
--- a/content/xul/document/src/nsXULContentSink.cpp
+++ b/content/xul/document/src/nsXULContentSink.cpp
@@ -25,17 +25,17 @@
 #include "nsHTMLStyleSheet.h"
 #include "nsINameSpaceManager.h"
 #include "nsINodeInfo.h"
 #include "nsIScriptContext.h"
 #include "nsIScriptRuntime.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIServiceManager.h"
 #include "nsIURL.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIXULDocument.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsLayoutCID.h"
 #include "nsNetUtil.h"
 #include "nsRDFCID.h"
 #include "nsXPIDLString.h"
 #include "nsReadableUtils.h"
 #include "nsXULElement.h"
--- a/content/xul/document/src/nsXULDocument.cpp
+++ b/content/xul/document/src/nsXULDocument.cpp
@@ -25,17 +25,17 @@
 
 // Note the ALPHABETICAL ORDERING
 #include "nsXULDocument.h"
 
 #include "nsError.h"
 #include "nsIBoxObject.h"
 #include "nsIChromeRegistry.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIContentViewer.h"
 #include "nsGUIEvent.h"
 #include "nsIDOMXULElement.h"
 #include "nsIRDFNode.h"
 #include "nsIRDFRemoteDataSource.h"
 #include "nsIRDFService.h"
 #include "nsIStreamListener.h"
 #include "nsITimer.h"
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -61,17 +61,17 @@
 #include "nsISeekableStream.h"
 #include "nsAutoPtr.h"
 #include "nsIWritablePropertyBag2.h"
 #include "nsIAppShell.h"
 #include "nsWidgetsCID.h"
 #include "nsDOMJSUtils.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIScriptChannel.h"
 #include "nsIOfflineCacheUpdate.h"
 #include "nsITimedChannel.h"
 #include "nsIPrivacyTransitionObserver.h"
 #include "nsCPrefetchService.h"
 #include "nsJSON.h"
 #include "IHistory.h"
 #include "mozilla/Services.h"
@@ -3244,17 +3244,17 @@ PrintDocTree(nsIDocShellTreeItem * aPare
   nsCOMPtr<nsIPresShell> presShell = parentAsDocShell->GetPresShell();
   nsRefPtr<nsPresContext> presContext;
   parentAsDocShell->GetPresContext(getter_AddRefs(presContext));
   nsIDocument *doc = presShell->GetDocument();
 
   nsCOMPtr<nsIDOMWindow> domwin(doc->GetWindow());
 
   nsCOMPtr<nsIWidget> widget;
-  nsViewManager* vm = presShell->GetViewManager();
+  nsIViewManager* vm = presShell->GetViewManager();
   if (vm) {
     vm->GetWidget(getter_AddRefs(widget));
   }
   dom::Element* rootElement = doc->GetRootElement();
 
   printf("DS %p  Ty %s  Doc %p DW %p EM %p CN %p\n",  
     (void*)parentAsDocShell.get(), 
     type==nsIDocShellTreeItem::typeChrome?"Chr":"Con", 
@@ -5043,20 +5043,20 @@ nsDocShell::DoGetPositionAndSize(int32_t
 }
 
 NS_IMETHODIMP
 nsDocShell::Repaint(bool aForce)
 {
     nsCOMPtr<nsIPresShell> presShell =GetPresShell();
     NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
 
-    nsViewManager* viewManager = presShell->GetViewManager();
+    nsIViewManager* viewManager = presShell->GetViewManager();
     NS_ENSURE_TRUE(viewManager, NS_ERROR_FAILURE);
 
-    viewManager->InvalidateAllViews();
+    NS_ENSURE_SUCCESS(viewManager->InvalidateAllViews(), NS_ERROR_FAILURE);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::GetParentWidget(nsIWidget ** parentWidget)
 {
     NS_ENSURE_ARG_POINTER(parentWidget);
 
@@ -5110,17 +5110,17 @@ nsDocShell::GetVisibility(bool * aVisibi
     if (!mContentViewer)
         return NS_OK;
 
     nsCOMPtr<nsIPresShell> presShell = GetPresShell();
     if (!presShell)
         return NS_OK;
 
     // get the view manager
-    nsViewManager* vm = presShell->GetViewManager();
+    nsIViewManager* vm = presShell->GetViewManager();
     NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
 
     // get the root view
     nsView *view = vm->GetRootView(); // views are not ref counted
     NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
 
     // if our root view is hidden, we are not visible
     if (view->GetVisibility() == nsViewVisibility_kHide)
@@ -7383,17 +7383,17 @@ nsDocShell::RestoreFromHistory()
     // new content viewer's root view at the same position.  Also save the
     // bounds of the root view's widget.
 
     nsView *rootViewSibling = nullptr, *rootViewParent = nullptr;
     nsIntRect newBounds(0, 0, 0, 0);
 
     nsCOMPtr<nsIPresShell> oldPresShell = GetPresShell();
     if (oldPresShell) {
-        nsViewManager *vm = oldPresShell->GetViewManager();
+        nsIViewManager *vm = oldPresShell->GetViewManager();
         if (vm) {
             nsView *oldRootView = vm->GetRootView();
 
             if (oldRootView) {
                 rootViewSibling = oldRootView->GetNextSibling();
                 rootViewParent = oldRootView->GetParent();
 
                 mContentViewer->GetBounds(newBounds);
@@ -7604,33 +7604,33 @@ nsDocShell::RestoreFromHistory()
         childShell->SetAllowDNSPrefetch(allowDNSPrefetch);
 
         rv = childShell->BeginRestore(nullptr, false);
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
     nsCOMPtr<nsIPresShell> shell = GetPresShell();
 
-    nsViewManager *newVM = shell ? shell->GetViewManager() : nullptr;
+    nsIViewManager *newVM = shell ? shell->GetViewManager() : nullptr;
     nsView *newRootView = newVM ? newVM->GetRootView() : nullptr;
 
     // Insert the new root view at the correct location in the view tree.
     if (container) {
         nsSubDocumentFrame* subDocFrame = do_QueryFrame(container->GetPrimaryFrame());
         rootViewParent = subDocFrame ? subDocFrame->EnsureInnerView() : nullptr;
     }
     if (sibling &&
         sibling->GetShell() &&
         sibling->GetShell()->GetViewManager()) {
         rootViewSibling = sibling->GetShell()->GetViewManager()->GetRootView();
     } else {
         rootViewSibling = nullptr;
     }
     if (rootViewParent && newRootView && newRootView->GetParent() != rootViewParent) {
-        nsViewManager *parentVM = rootViewParent->GetViewManager();
+        nsIViewManager *parentVM = rootViewParent->GetViewManager();
         if (parentVM) {
             // InsertChild(parent, child, sib, true) inserts the child after
             // sib in content order, which is before sib in view order. BUT
             // when sib is null it inserts at the end of the the document
             // order, i.e., first in view order.  But when oldRootSibling is
             // null, the old root as at the end of the view list --- last in
             // content order --- and we want to call InsertChild(parent, child,
             // nullptr, false) in that case.
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -28,17 +28,17 @@
 
 #include "nsIFrame.h"
 #include "nsIWidget.h"
 #include "nsGUIEvent.h"
 #include "nsCharsetSource.h"
 #include "nsJSEnvironment.h"
 #include "nsJSUtils.h"
 
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 
 #include "nsIDOMHTMLCanvasElement.h"
 #include "gfxContext.h"
 #include "gfxImageSurface.h"
 #include "nsLayoutUtils.h"
 #include "nsComputedDOMStyle.h"
 #include "nsIPresShell.h"
 #include "nsStyleAnimation.h"
@@ -656,17 +656,17 @@ nsDOMWindowUtils::SendMouseEventCommon(c
   event.refPoint = ToWidgetPoint(aX, aY, offset, presContext);
   event.ignoreRootScrollFrame = aIgnoreRootScrollFrame;
 
   nsEventStatus status;
   if (aToWindow) {
     nsCOMPtr<nsIPresShell> presShell = presContext->PresShell();
     if (!presShell)
       return NS_ERROR_FAILURE;
-    nsViewManager* viewManager = presShell->GetViewManager();
+    nsIViewManager* viewManager = presShell->GetViewManager();
     if (!viewManager)
       return NS_ERROR_FAILURE;
     nsView* view = viewManager->GetRootView();
     if (!view)
       return NS_ERROR_FAILURE;
 
     status = nsEventStatus_eIgnore;
     return presShell->HandleEvent(view->GetFrame(), &event, false, &status);
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -34,17 +34,17 @@
 #include "nsFrameTraversal.h"
 #include "nsObjectFrame.h"
 #include "nsEventDispatcher.h"
 #include "nsEventStateManager.h"
 #include "nsIMEStateManager.h"
 #include "nsIWebNavigation.h"
 #include "nsCaret.h"
 #include "nsIBaseWindow.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsFrameSelection.h"
 #include "mozilla/Selection.h"
 #include "nsXULPopupManager.h"
 #include "nsIDOMNodeFilter.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIPrincipal.h"
 #include "mozAutoDocUpdate.h"
 #include "nsFrameLoader.h"
@@ -1050,17 +1050,17 @@ nsFocusManager::EnsureCurrentWidgetFocus
     return;
 
   // get the main child widget for the focused window and ensure that the
   // platform knows that this widget is focused.
   nsCOMPtr<nsIDocShell> docShell = mFocusedWindow->GetDocShell();
   if (docShell) {
     nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
     if (presShell) {
-      nsViewManager* vm = presShell->GetViewManager();
+      nsIViewManager* vm = presShell->GetViewManager();
       if (vm) {
         nsCOMPtr<nsIWidget> widget;
         vm->GetRootWidget(getter_AddRefs(widget));
         if (widget)
           widget->SetFocus(false);
       }
     }
   }
@@ -1547,17 +1547,17 @@ nsFocusManager::Blur(nsPIDOMWindow* aWin
     // But don't do this if we are blurring due to the window being lowered,
     // otherwise, the parent window can get raised again.
     if (mActiveWindow) {
       nsIFrame* contentFrame = content->GetPrimaryFrame();
       nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame);
       if (aAdjustWidgets && objectFrame && !sTestMode) {
         // note that the presshell's widget is being retrieved here, not the one
         // for the object frame.
-        nsViewManager* vm = presShell->GetViewManager();
+        nsIViewManager* vm = presShell->GetViewManager();
         if (vm) {
           nsCOMPtr<nsIWidget> widget;
           vm->GetRootWidget(getter_AddRefs(widget));
           if (widget)
             widget->SetFocus(false);
         }
       }
 
@@ -1721,17 +1721,17 @@ nsFocusManager::Focus(nsPIDOMWindow* aWi
   nsCOMPtr<nsIWidget> objectFrameWidget;
   if (aContent) {
     nsIFrame* contentFrame = aContent->GetPrimaryFrame();
     nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame);
     if (objectFrame)
       objectFrameWidget = objectFrame->GetWidget();
   }
   if (aAdjustWidgets && !objectFrameWidget && !sTestMode) {
-    nsViewManager* vm = presShell->GetViewManager();
+    nsIViewManager* vm = presShell->GetViewManager();
     if (vm) {
       nsCOMPtr<nsIWidget> widget;
       vm->GetRootWidget(getter_AddRefs(widget));
       if (widget)
         widget->SetFocus(false);
     }
   }
 
@@ -1807,17 +1807,17 @@ nsFocusManager::Focus(nsPIDOMWindow* aWi
   }
   else {
     // If the window focus event (fired above when aIsNewDocument) caused
     // the plugin not to be focusable, update the system focus by focusing
     // the root widget.
     if (aAdjustWidgets && objectFrameWidget &&
         mFocusedWindow == aWindow && mFocusedContent == nullptr &&
         !sTestMode) {
-      nsViewManager* vm = presShell->GetViewManager();
+      nsIViewManager* vm = presShell->GetViewManager();
       if (vm) {
         nsCOMPtr<nsIWidget> widget;
         vm->GetRootWidget(getter_AddRefs(widget));
         if (widget)
           widget->SetFocus(false);
       }
     }
 
@@ -1969,17 +1969,17 @@ nsFocusManager::RaiseWindow(nsPIDOMWindo
   nsCOMPtr<nsIDocShell> docShell = aWindow->GetDocShell();
   if (!docShell)
     return;
 
   nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
   if (!presShell)
     return;
 
-  nsViewManager* vm = presShell->GetViewManager();
+  nsIViewManager* vm = presShell->GetViewManager();
   if (vm) {
     nsCOMPtr<nsIWidget> widget;
     vm->GetRootWidget(getter_AddRefs(widget));
     if (widget)
       widget->SetFocus(true);
   }
 #else
   nsCOMPtr<nsIWebNavigation> webnav = do_GetInterface(aWindow);
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -113,17 +113,17 @@
 #include "nsIMarkupDocumentViewer.h"
 #include "nsIPresShell.h"
 #include "nsIProgrammingLanguage.h"
 #include "nsIServiceManager.h"
 #include "nsIScriptGlobalObjectOwner.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIScrollableFrame.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsISelectionController.h"
 #include "nsISelection.h"
 #include "nsIPrompt.h"
 #include "nsIPromptService.h"
 #include "nsIPromptFactory.h"
 #include "nsIWritablePropertyBag2.h"
 #include "nsIWebNavigation.h"
 #include "nsIWebBrowser.h"
@@ -11019,17 +11019,17 @@ nsGlobalChromeWindow::SetCursor(const ns
     mDocShell->GetPresContext(getter_AddRefs(presContext));
   }
 
   if (presContext) {
     // Need root widget.
     nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
     NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
 
-    nsViewManager* vm = presShell->GetViewManager();
+    nsIViewManager* vm = presShell->GetViewManager();
     NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
 
     nsView* rootView = vm->GetRootView();
     NS_ENSURE_TRUE(rootView, NS_ERROR_FAILURE);
 
     nsIWidget* widget = rootView->GetNearestWidget(nullptr);
     NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
 
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -36,17 +36,17 @@
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMHTMLFrameElement.h"
 #include "nsIDOMWindow.h"
 #include "nsIDialogCreator.h"
 #include "nsIPromptFactory.h"
 #include "nsIURI.h"
 #include "nsIMozBrowserFrame.h"
 #include "nsIScriptSecurityManager.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIWidget.h"
 #include "nsIWindowWatcher.h"
 #include "nsNetUtil.h"
 #include "nsPIDOMWindow.h"
 #include "nsPrintfCString.h"
 #include "nsSerializationHelper.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
@@ -878,17 +878,17 @@ TabParent::RecvGetDPI(float* aValue)
 
 bool
 TabParent::RecvGetWidgetNativeData(WindowsHandle* aValue)
 {
   nsCOMPtr<nsIContent> content = do_QueryInterface(mFrameElement);
   if (content) {
     nsIPresShell* shell = content->OwnerDoc()->GetShell();
     if (shell) {
-      nsViewManager* vm = shell->GetViewManager();
+      nsIViewManager* vm = shell->GetViewManager();
       nsCOMPtr<nsIWidget> widget;
       vm->GetRootWidget(getter_AddRefs(widget));
       if (widget) {
         *aValue = reinterpret_cast<WindowsHandle>(
           widget->GetNativeData(NS_NATIVE_SHAREABLE_WINDOW));
         return true;
       }
     }
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -40,17 +40,17 @@ using mozilla::DefaultXDisplay;
 #include "nsIStringStream.h"
 #include "nsNetUtil.h"
 #include "mozilla/Preferences.h"
 #include "nsILinkHandler.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIWebBrowserChrome.h"
 #include "nsLayoutUtils.h"
 #include "nsIPluginWidget.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIDOMHTMLObjectElement.h"
 #include "nsIAppShell.h"
 #include "nsIDOMHTMLAppletElement.h"
 #include "nsAttrName.h"
 #include "nsIFocusManager.h"
 #include "nsFocusManager.h"
 #include "nsIDOMDragEvent.h"
@@ -688,17 +688,17 @@ NS_IMETHODIMP nsPluginInstanceOwner::Get
 {
   if (!mObjectFrame) {
     NS_WARNING("plugin owner has no owner in getting doc's window handle");
     return NS_ERROR_FAILURE;
   }
   
 #if defined(XP_WIN) || defined(XP_OS2)
   void** pvalue = (void**)value;
-  nsViewManager* vm = mObjectFrame->PresContext()->GetPresShell()->GetViewManager();
+  nsIViewManager* vm = mObjectFrame->PresContext()->GetPresShell()->GetViewManager();
   if (!vm)
     return NS_ERROR_FAILURE;
 #if defined(XP_WIN)
   // This property is provided to allow a "windowless" plugin to determine the window it is drawing
   // in, so it can translate mouse coordinates it receives directly from the operating system
   // to coordinates relative to itself.
   
   // The original code (outside this #if) returns the document's window, which is OK if the window the "windowless" plugin
@@ -738,24 +738,24 @@ NS_IMETHODIMP nsPluginInstanceOwner::Get
         if (*pvalue)
           return NS_OK;
       }
     }
   }
 #endif
   // simply return the topmost document window
   nsCOMPtr<nsIWidget> widget;
-  vm->GetRootWidget(getter_AddRefs(widget));
+  nsresult rv = vm->GetRootWidget(getter_AddRefs(widget));            
   if (widget) {
     *pvalue = (void*)widget->GetNativeData(NS_NATIVE_WINDOW);
   } else {
     NS_ASSERTION(widget, "couldn't get doc's widget in getting doc's window handle");
   }
 
-  return NS_OK;
+  return rv;
 #elif (defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT)) && defined(MOZ_X11)
   // X11 window managers want the toplevel window for WM_TRANSIENT_FOR.
   nsIWidget* win = mObjectFrame->GetNearestWidget();
   if (!win)
     return NS_ERROR_FAILURE;
   *static_cast<Window*>(value) = (long unsigned int)win->GetNativeData(NS_NATIVE_SHAREABLE_WINDOW);
   return NS_OK;
 #else
--- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
+++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
@@ -56,17 +56,17 @@
 #include "nsPIWindowWatcher.h"
 #include "nsIPrompt.h"
 #include "nsRect.h"
 #include "nsIWebBrowserChromeFocus.h"
 #include "nsIContent.h"
 #include "imgIContainer.h"
 #include "nsContextMenuInfo.h"
 #include "nsPresContext.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsView.h"
 #include "nsEventListenerManager.h"
 #include "nsIDOMDragEvent.h"
 #include "nsIConstraintValidation.h"
 #include "mozilla/Attributes.h"
 
 using namespace mozilla;
 
@@ -1438,17 +1438,17 @@ ChromeTooltipListener::sTooltipCallback(
       do_GetInterface(static_cast<nsIWebBrowser*>(self->mWebBrowser));
     nsCOMPtr<nsIPresShell> shell;
     if (docShell) {
       shell = docShell->GetPresShell();
     }
 
     nsIWidget* widget = nullptr;
     if (shell) {
-      nsViewManager* vm = shell->GetViewManager();
+      nsIViewManager* vm = shell->GetViewManager();
       if (vm) {
         nsView* view = vm->GetRootView();
         if (view) {
           nsPoint offset;
           widget = view->GetNearestWidget(&offset);
         }
       }
     }
--- a/extensions/widgetutils/src/nsWidgetUtils.cpp
+++ b/extensions/widgetutils/src/nsWidgetUtils.cpp
@@ -31,17 +31,17 @@
 #include "nsPIDOMWindow.h"
 #include "nsIDOMWindow.h"
 #include "nsIDOMCompositionListener.h"
 #include "nsIDOMTextListener.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIDOMWheelEvent.h"
 #include "nsView.h"
 #include "nsGUIEvent.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIContentPolicy.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIContent.h"
 #include "nsITimer.h"
 
 using namespace mozilla;
 
 const int MIN_INT =((int) (1 << (sizeof(int) * 8 - 1)));
@@ -84,17 +84,17 @@ private:
   nsresult UpdateFromEvent(nsIDOMEvent *aDOMEvent);
   nsresult MouseDown(nsIDOMEvent* aDOMEvent);
   nsresult MouseUp(nsIDOMEvent* aDOMEvent);
   nsresult MouseMove(nsIDOMEvent* aDOMEvent);
 
   static void StopPanningCallback(nsITimer *timer, void *closure);
 
   nsCOMPtr<nsIWidget> mWidget;
-  nsRefPtr<nsViewManager> mViewManager;
+  nsCOMPtr<nsIViewManager> mViewManager;
   nsCOMPtr<nsITimer> mTimer;
 };
 
 nsWidgetUtils::nsWidgetUtils()
 {
   Init();
 }
 
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -31,17 +31,17 @@
 #include "nsTableColFrame.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMHTMLTableColElement.h"
 #include "nsIDOMHTMLTableCaptionElem.h"
 #include "nsHTMLParts.h"
 #include "nsIPresShell.h"
 #include "nsUnicharUtils.h"
 #include "nsStyleSet.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsEventStates.h"
 #include "nsStyleConsts.h"
 #include "nsTableOuterFrame.h"
 #include "nsIDOMXULElement.h"
 #include "nsContainerFrame.h"
 #include "nsINameSpaceManager.h"
 #include "nsIDOMHTMLSelectElement.h"
 #include "nsIDOMHTMLLegendElement.h"
@@ -12018,17 +12018,17 @@ nsCSSFrameConstructor::RebuildAllStyleDa
   mRebuildAllStyleData = false;
   NS_UpdateHint(aExtraHint, mRebuildAllExtraHint);
   mRebuildAllExtraHint = nsChangeHint(0);
 
   if (!mPresShell || !mPresShell->GetRootFrame())
     return;
 
   // Make sure that the viewmanager will outlive the presshell
-  nsRefPtr<nsViewManager> vm = mPresShell->GetViewManager();
+  nsCOMPtr<nsIViewManager> vm = mPresShell->GetViewManager();
 
   // Processing the style changes could cause a flush that propagates to
   // the parent frame and thus destroys the pres shell.
   nsCOMPtr<nsIPresShell> kungFuDeathGrip(mPresShell);
 
   // We may reconstruct frames below and hence process anything that is in the
   // tree. We don't want to get notified to process those items again after.
   mPresShell->GetDocument()->FlushPendingNotifications(Flush_ContentAndNotify);
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -14,17 +14,17 @@
 #include "mozilla/HashFunctions.h"
 #include "mozilla/Types.h"
 
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsIFrame.h"
 #include "nsPoint.h"
 #include "nsRect.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIPresShell.h"
 #include "nsFrameManager.h"
 #include "nsStyleContext.h"
 #include "nsGkAtoms.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsTransform2D.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
--- a/layout/base/nsCSSRenderingBorders.cpp
+++ b/layout/base/nsCSSRenderingBorders.cpp
@@ -2,17 +2,17 @@
 // vim:cindent:ts=2:et:sw=2:
 /* 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/. */
 
 #include "nsStyleConsts.h"
 #include "nsPoint.h"
 #include "nsRect.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsFrameManager.h"
 #include "nsStyleContext.h"
 #include "nsGkAtoms.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsTransform2D.h"
 #include "nsIContent.h"
 #include "nsIScrollableFrame.h"
 #include "imgIRequest.h"
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -41,17 +41,17 @@
 #include "nsBoxFrame.h"
 #include "nsViewportFrame.h"
 #include "nsSVGEffects.h"
 #include "nsSVGElement.h"
 #include "nsSVGClipPathFrame.h"
 #include "sampler.h"
 #include "nsAnimationManager.h"
 #include "nsTransitionManager.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "ImageLayers.h"
 #include "ImageContainer.h"
 #include "nsCanvasFrame.h"
 
 #include "mozilla/StandardInteger.h"
 
 using namespace mozilla;
 using namespace mozilla::css;
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -35,18 +35,19 @@
 #include "nsIDOMHTMLElement.h"
 #include "nsIDOMRange.h"
 #include "nsContentCID.h"
 #include "nsLayoutCID.h"
 #include "nsContentUtils.h"
 #include "nsLayoutStylesheetCache.h"
 #include "mozilla/Preferences.h"
 
+#include "nsViewsCID.h"
 #include "nsIDeviceContextSpec.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsView.h"
 
 #include "nsIPageSequenceFrame.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
 #include "nsIContentViewerEdit.h"
 #include "nsIContentViewerFile.h"
 #include "mozilla/css/Loader.h"
@@ -373,17 +374,17 @@ private:
   // are sharing/recycling a single base widget and not creating multiple
   // child widgets.
   bool ShouldAttachToTopLevel();
 
 protected:
   // These return the current shell/prescontext etc.
   nsIPresShell* GetPresShell();
   nsPresContext* GetPresContext();
-  nsViewManager* GetViewManager();
+  nsIViewManager* GetViewManager();
 
   void DetachFromTopLevelWidget();
 
   // IMPORTANT: The ownership implicit in the following member
   // variables has been explicitly checked and set using nsCOMPtr
   // for owning pointers and raw COM interface pointers for weak
   // (ie, non owning) references. If you add any members to this
   // class, please make the ownership explicit (pinkerton, scc).
@@ -391,17 +392,17 @@ protected:
   nsWeakPtr mContainer; // it owns me!
   nsWeakPtr mTopContainerWhilePrinting;
   nsRefPtr<nsDeviceContext> mDeviceContext;  // We create and own this baby
 
   // the following six items are explicitly in this order
   // so they will be destroyed in the reverse order (pinkerton, scc)
   nsCOMPtr<nsIDocument>    mDocument;
   nsCOMPtr<nsIWidget>      mWindow;      // may be null
-  nsRefPtr<nsViewManager> mViewManager;
+  nsCOMPtr<nsIViewManager> mViewManager;
   nsRefPtr<nsPresContext>  mPresContext;
   nsCOMPtr<nsIPresShell>   mPresShell;
 
   nsCOMPtr<nsISelectionListener> mSelectionListener;
   nsRefPtr<nsDocViewerFocusListener> mFocusListener;
 
   nsCOMPtr<nsIContentViewer> mPreviousViewer;
   nsCOMPtr<nsISHEntry> mSHEntry;
@@ -491,16 +492,18 @@ public:
 private:
   nsCOMPtr<nsIDocument> mDocument;
 };
 
 
 //------------------------------------------------------------------
 // nsDocumentViewer
 //------------------------------------------------------------------
+// Class IDs
+static NS_DEFINE_CID(kViewManagerCID,       NS_VIEW_MANAGER_CID);
 
 //------------------------------------------------------------------
 nsresult
 NS_NewContentViewer(nsIContentViewer** aResult)
 {
   *aResult = new nsDocumentViewer();
 
   NS_ADDREF(*aResult);
@@ -1391,17 +1394,17 @@ nsDocumentViewer::Open(nsISupports *aSta
   // page B, we detach. So page A's view has no widget. If we then go
   // back to it, and it is in the bfcache, we will use that view, which
   // doesn't have a widget. The attach call here will properly attach us.
   if (nsIWidget::UsePuppetWidgets() && mPresContext &&
       ShouldAttachToTopLevel()) {
     // If the old view is already attached to our parent, detach
     DetachFromTopLevelWidget();
 
-    nsViewManager *vm = GetViewManager();
+    nsIViewManager *vm = GetViewManager();
     NS_ABORT_IF_FALSE(vm, "no view manager");
     nsView* v = vm->GetRootView();
     NS_ABORT_IF_FALSE(v, "no root view");
     NS_ABORT_IF_FALSE(mParentWidget, "no mParentWidget to set");
     v->AttachToTopLevelWidget(mParentWidget);
 
     mAttachedToParent = true;
   }
@@ -1538,30 +1541,30 @@ nsDocumentViewer::Destroy()
     // Make sure the presentation isn't torn down by Hide().
     mSHEntry->SetSticky(mIsSticky);
     mIsSticky = true;
 
     bool savePresentation = mDocument ? mDocument->IsBFCachingAllowed() : true;
 
     // Remove our root view from the view hierarchy.
     if (mPresShell) {
-      nsViewManager *vm = mPresShell->GetViewManager();
+      nsIViewManager *vm = mPresShell->GetViewManager();
       if (vm) {
         nsView *rootView = vm->GetRootView();
 
         if (rootView) {
           // The invalidate that removing this view causes is dropped because
           // the Freeze call above sets painting to be suppressed for our
           // document. So we do it ourselves and make it happen.
           vm->InvalidateViewNoSuppression(rootView,
             rootView->GetBounds() - rootView->GetPosition());
 
           nsView *rootViewParent = rootView->GetParent();
           if (rootViewParent) {
-            nsViewManager *parentVM = rootViewParent->GetViewManager();
+            nsIViewManager *parentVM = rootViewParent->GetViewManager();
             if (parentVM) {
               parentVM->RemoveChild(rootView);
             }
           }
         }
       }
     }
 
@@ -1798,17 +1801,17 @@ nsDocumentViewer::GetPresShell()
 }
 
 nsPresContext*
 nsDocumentViewer::GetPresContext()
 {
   return mPresContext;
 }
 
-nsViewManager*
+nsIViewManager*
 nsDocumentViewer::GetViewManager()
 {
   return mViewManager;
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::GetPresShell(nsIPresShell** aResult)
 {
@@ -2264,21 +2267,24 @@ nsDocumentViewer::MakeWindow(const nsSiz
 
   bool shouldAttach = ShouldAttachToTopLevel();
 
   if (shouldAttach) {
     // If the old view is already attached to our parent, detach
     DetachFromTopLevelWidget();
   }
 
-  mViewManager = new nsViewManager();
+  nsresult rv;
+  mViewManager = do_CreateInstance(kViewManagerCID, &rv);
+  if (NS_FAILED(rv))
+    return rv;
 
   nsDeviceContext *dx = mPresContext->DeviceContext();
 
-  nsresult rv = mViewManager->Init(dx);
+  rv = mViewManager->Init(dx);
   if (NS_FAILED(rv))
     return rv;
 
   // The root view is always at 0,0.
   nsRect tbounds(nsPoint(0, 0), aSize);
   // Create a view
   nsView* view = mViewManager->CreateView(tbounds, aContainerView);
   if (!view)
@@ -4377,17 +4383,17 @@ nsDocumentViewer::IsInitializedForPrintP
 
 void
 nsDocumentViewer::InitializeForPrintPreview()
 {
   mInitializedForPrintPreview = true;
 }
 
 void
-nsDocumentViewer::SetPrintPreviewPresentation(nsViewManager* aViewManager,
+nsDocumentViewer::SetPrintPreviewPresentation(nsIViewManager* aViewManager,
                                                 nsPresContext* aPresContext,
                                                 nsIPresShell* aPresShell)
 {
   if (mPresShell) {
     DestroyPresShell();
   }
 
   mWindow = nullptr;
--- a/layout/base/nsIDocumentViewerPrint.h
+++ b/layout/base/nsIDocumentViewerPrint.h
@@ -7,17 +7,17 @@
 
 #include "nsISupports.h"
 
 class nsIDocument;
 class nsStyleSet;
 class nsIPresShell;
 class nsPresContext;
 class nsIWidget;
-class nsViewManager;
+class nsIViewManager;
 
 // {c6f255cf-cadd-4382-b57f-cd2a9874169b}
 #define NS_IDOCUMENT_VIEWER_PRINT_IID \
 { 0xc6f255cf, 0xcadd, 0x4382, \
   { 0xb5, 0x7f, 0xcd, 0x2a, 0x98, 0x74, 0x16, 0x9b } }
 
 /**
  * A DocumentViewerPrint is an INTERNAL Interface used for interaction
@@ -53,17 +53,17 @@ public:
   /**
    * Marks this viewer to be used for print preview.
    */
   virtual void InitializeForPrintPreview() = 0;
 
   /**
    * Replaces the current presentation with print preview presentation.
    */
-  virtual void SetPrintPreviewPresentation(nsViewManager* aViewManager,
+  virtual void SetPrintPreviewPresentation(nsIViewManager* aViewManager,
                                            nsPresContext* aPresContext,
                                            nsIPresShell* aPresShell) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentViewerPrint,
                               NS_IDOCUMENT_VIEWER_PRINT_IID)
 
 /* Use this macro when declaring classes that implement this interface. */
@@ -73,13 +73,13 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumen
   virtual void     SetIsPrintPreview(bool aIsPrintPreview); \
   virtual bool     GetIsPrintPreview(); \
   virtual nsresult CreateStyleSet(nsIDocument* aDocument, nsStyleSet** aStyleSet); \
   virtual void     IncrementDestroyRefCount(); \
   virtual void     ReturnToGalleyPresentation(); \
   virtual void     OnDonePrinting(); \
   virtual bool     IsInitializedForPrintPreview(); \
   virtual void     InitializeForPrintPreview(); \
-  virtual void     SetPrintPreviewPresentation(nsViewManager* aViewManager, \
+  virtual void     SetPrintPreviewPresentation(nsIViewManager* aViewManager, \
                                                nsPresContext* aPresContext, \
                                                nsIPresShell* aPresShell);
 
 #endif /* nsIDocumentViewerPrint_h___ */
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -39,17 +39,17 @@
 #include "nsEventStates.h"
 #include "nsPresArena.h"
 
 class nsIContent;
 class nsIDocument;
 class nsIFrame;
 class nsPresContext;
 class nsStyleSet;
-class nsViewManager;
+class nsIViewManager;
 class nsView;
 class nsRenderingContext;
 class nsIPageSequenceFrame;
 class nsAString;
 class nsCaret;
 class nsFrameSelection;
 class nsFrameManager;
 class nsILayoutHistoryState;
@@ -171,17 +171,17 @@ protected:
   enum eRenderFlag {
     STATE_IGNORING_VIEWPORT_SCROLLING = 0x1
   };
   typedef uint8_t RenderFlags; // for storing the above flags
 
 public:
   virtual NS_HIDDEN_(nsresult) Init(nsIDocument* aDocument,
                                    nsPresContext* aPresContext,
-                                   nsViewManager* aViewManager,
+                                   nsIViewManager* aViewManager,
                                    nsStyleSet* aStyleSet,
                                    nsCompatibility aCompatMode) = 0;
 
   /**
    * All callers are responsible for calling |Destroy| after calling
    * |EndObservingDocument|.  It needs to be separate only because form
    * controls incorrectly store their data in the frames rather than the
    * content model and printing calls |EndObservingDocument| multiple
@@ -267,17 +267,17 @@ public:
     if (PRESARENA_MUST_FREE_DURING_DESTROY || !mIsDestroying)
       mFrameArena.FreeBySize(aSize, aPtr);
   }
 
   nsIDocument* GetDocument() const { return mDocument; }
 
   nsPresContext* GetPresContext() const { return mPresContext; }
 
-  nsViewManager* GetViewManager() const { return mViewManager; }
+  nsIViewManager* GetViewManager() const { return mViewManager; }
 
 #ifdef ACCESSIBILITY
   /**
    * Return the document accessible for this pres shell if there is one.
    */
   mozilla::a11y::DocAccessible* GetDocAccessible() const
   {
     return mDocAccessible;
@@ -1376,17 +1376,17 @@ protected:
   // please make the ownership explicit (pinkerton, scc).
 
   // These are the same Document and PresContext owned by the DocViewer.
   // we must share ownership.
   nsIDocument*              mDocument;      // [STRONG]
   nsPresContext*            mPresContext;   // [STRONG]
   nsStyleSet*               mStyleSet;      // [OWNS]
   nsCSSFrameConstructor*    mFrameConstructor; // [OWNS]
-  nsViewManager*           mViewManager;   // [WEAK] docViewer owns it so I don't have to
+  nsIViewManager*           mViewManager;   // [WEAK] docViewer owns it so I don't have to
   nsPresArena               mFrameArena;
   nsFrameSelection*         mSelection;
   // Pointer into mFrameConstructor - this is purely so that FrameManager() and
   // GetRootFrame() can be inlined:
   nsFrameManagerBase*       mFrameManager;
   nsWeakPtr                 mForwardingContainer;
   nsRefreshDriver*          mHiddenInvalidationObserverRefreshDriver;
 #ifdef ACCESSIBILITY
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -38,17 +38,17 @@
 #include "nsIWeakReferenceUtils.h"
 #include "nsCSSRendering.h"
 #include "prprf.h"
 #include "nsAutoPtr.h"
 #include "nsEventStateManager.h"
 #include "nsThreadUtils.h"
 #include "nsFrameManager.h"
 #include "nsLayoutUtils.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsCSSRuleProcessor.h"
 #include "nsStyleChangeList.h"
 #include "nsRuleNode.h"
 #include "nsEventDispatcher.h"
 #include "gfxUserFontSet.h"
 #include "gfxPlatform.h"
 #include "nsCSSRules.h"
@@ -821,17 +821,17 @@ nsPresContext::PreferenceChanged(const c
   nsDependentCString prefName(aPrefName);
   if (prefName.EqualsLiteral("layout.css.dpi") ||
       prefName.EqualsLiteral("layout.css.devPixelsPerPx")) {
     int32_t oldAppUnitsPerDevPixel = AppUnitsPerDevPixel();
     if (mDeviceContext->CheckDPIChange() && mShell) {
       // Re-fetch the view manager's window dimensions in case there's a deferred
       // resize which hasn't affected our mVisibleArea yet
       nscoord oldWidthAppUnits, oldHeightAppUnits;
-      nsViewManager* vm = mShell->GetViewManager();
+      nsIViewManager* vm = mShell->GetViewManager();
       vm->GetWindowDimensions(&oldWidthAppUnits, &oldHeightAppUnits);
       float oldWidthDevPixels = oldWidthAppUnits/oldAppUnitsPerDevPixel;
       float oldHeightDevPixels = oldHeightAppUnits/oldAppUnitsPerDevPixel;
 
       nscoord width = NSToCoordRound(oldWidthDevPixels*AppUnitsPerDevPixel());
       nscoord height = NSToCoordRound(oldHeightDevPixels*AppUnitsPerDevPixel());
       vm->SetWindowDimensions(width, height);
 
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -67,16 +67,17 @@
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsIPageSequenceFrame.h"
 #include "nsCaret.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMXMLDocument.h"
+#include "nsViewsCID.h"
 #include "nsFrameManager.h"
 #include "nsEventStateManager.h"
 #include "nsIMEStateManager.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsILayoutHistoryState.h"
 #include "nsILineIterator.h" // for ScrollContentIntoView
 #include "nsWeakPtr.h"
@@ -782,17 +783,17 @@ PresShell::~PresShell()
 
 /**
  * Initialize the presentation shell. Create view manager and style
  * manager.
  */
 nsresult
 PresShell::Init(nsIDocument* aDocument,
                 nsPresContext* aPresContext,
-                nsViewManager* aViewManager,
+                nsIViewManager* aViewManager,
                 nsStyleSet* aStyleSet,
                 nsCompatibility aCompatMode)
 {
   NS_PRECONDITION(nullptr != aDocument, "null ptr");
   NS_PRECONDITION(nullptr != aPresContext, "null ptr");
   NS_PRECONDITION(nullptr != aViewManager, "null ptr");
   nsresult result;
 
@@ -1851,17 +1852,17 @@ PresShell::ResizeReflowIgnoreOverride(ns
   nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
 
   if (!rootFrame && aHeight == NS_UNCONSTRAINEDSIZE) {
     // We can't do the work needed for SizeToContent without a root
     // frame, and we want to return before setting the visible area.
     return NS_ERROR_NOT_AVAILABLE;
   }
 
-  nsRefPtr<nsViewManager> viewManagerDeathGrip = mViewManager;
+  nsCOMPtr<nsIViewManager> viewManagerDeathGrip = mViewManager;
   // Take this ref after viewManager so it'll make sure to go away first
   nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
 
   if (!mIsDestroying && !mResizeEvent.IsPending() &&
       !mAsyncResizeTimerIsActive) {
     FireBeforeResizeEvent();
   }
 
@@ -1891,17 +1892,17 @@ PresShell::ResizeReflowIgnoreOverride(ns
       // the way don't have region accumulation issues?
 
       {
         nsAutoCauseReflowNotifier crNotifier(this);
         WillDoReflow();
 
         // Kick off a top-down reflow
         AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow);
-        nsViewManager::AutoDisableRefresh refreshBlocker(mViewManager);
+        nsIViewManager::AutoDisableRefresh refreshBlocker(mViewManager);
 
         mDirtyRoots.RemoveElement(rootFrame);
         DoReflow(rootFrame, true);
       }
 
       DidDoReflow(true);
     }
   }
@@ -3729,17 +3730,17 @@ bool
 PresShell::IsSafeToFlush() const
 {
   // Not safe if we are reflowing or in the middle of frame construction
   bool isSafeToFlush = !mIsReflowing &&
                          !mChangeNestCount;
 
   if (isSafeToFlush) {
     // Not safe if we are painting
-    nsViewManager* viewManager = GetViewManager();
+    nsIViewManager* viewManager = GetViewManager();
     if (viewManager) {
       bool isPainting = false;
       viewManager->IsPainting(isPainting);
       if (isPainting) {
         isSafeToFlush = false;
       }
     }
   }
@@ -3802,17 +3803,17 @@ PresShell::FlushPendingNotifications(moz
   bool hasHadScriptObject;
   if (mDocument->GetScriptHandlingObject(hasHadScriptObject) ||
       hasHadScriptObject) {
     isSafeToFlush = isSafeToFlush && nsContentUtils::IsSafeToRunScript();
   }
 
   NS_ASSERTION(!isSafeToFlush || mViewManager, "Must have view manager");
   // Make sure the view manager stays alive.
-  nsRefPtr<nsViewManager> viewManagerDeathGrip = mViewManager;
+  nsCOMPtr<nsIViewManager> viewManagerDeathGrip = mViewManager;
   if (isSafeToFlush && mViewManager) {
     // Processing pending notifications can kill us, and some callers only
     // hold weak refs when calling FlushPendingNotifications().  :(
     nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
 
     if (mResizeEvent.IsPending()) {
       FireResizeEvent();
       if (mIsDestroying) {
@@ -5180,17 +5181,17 @@ PresShell::ProcessSynthMouseMoveEvent(bo
   int32_t viewAPD;
 
   // refPoint will be mMouseLocation relative to the widget of |view|, the
   // widget we will put in the event we dispatch, in viewAPD appunits
   nsPoint refpoint(0, 0);
 
   // We always dispatch the event to the pres shell that contains the view that
   // the mouse is over. pointVM is the VM of that pres shell.
-  nsViewManager *pointVM = nullptr;
+  nsIViewManager *pointVM = nullptr;
 
   // This could be a bit slow (traverses entire view hierarchy)
   // but it's OK to do it once per synthetic mouse event
   view = FindFloatingViewContaining(rootView, mMouseLocation);
   if (!view) {
     view = rootView;
     nsView *pointView = FindViewContaining(rootView, mMouseLocation);
     // pointView can be null in situations related to mouse capture
@@ -7646,17 +7647,17 @@ PresShell::ProcessReflowCommands(bool aI
         ? PR_IntervalNow() + PR_MicrosecondsToInterval(gMaxRCProcessingTime)
         : (PRIntervalTime)0;
 
     // Scope for the reflow entry point
     {
       nsAutoScriptBlocker scriptBlocker;
       WillDoReflow();
       AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow);
-      nsViewManager::AutoDisableRefresh refreshBlocker(mViewManager);
+      nsIViewManager::AutoDisableRefresh refreshBlocker(mViewManager);
 
       do {
         // Send an incremental reflow notification to the target frame.
         int32_t idx = mDirtyRoots.Length() - 1;
         nsIFrame *target = mDirtyRoots[idx];
         mDirtyRoots.RemoveElementAt(idx);
 
         if (!NS_SUBTREE_DIRTY(target)) {
@@ -7920,16 +7921,18 @@ nsIPresShell::RemoveRefreshObserverExter
 //------------------------------------------------------
 
 // Start of DEBUG only code
 
 #ifdef DEBUG
 #include "nsIURL.h"
 #include "nsILinkHandler.h"
 
+static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID);
+
 static void
 LogVerifyMessage(nsIFrame* k1, nsIFrame* k2, const char* aMsg)
 {
   nsAutoString n1, n2;
   if (k1) {
     k1->GetFrameName(n1);
   } else {
     n1.Assign(NS_LITERAL_STRING("(null)"));
@@ -8262,17 +8265,17 @@ PresShell::VerifyIncrementalReflow()
   NS_ENSURE_SUCCESS(rv, false);
 
   // Get our scrolling preference
   nsView* rootView = mViewManager->GetRootView();
   NS_ENSURE_TRUE(rootView->HasWidget(), false);
   nsIWidget* parentWidget = rootView->GetWidget();
 
   // Create a new view manager.
-  nsRefPtr<nsViewManager> vm = new nsViewManager();
+  nsCOMPtr<nsIViewManager> vm = do_CreateInstance(kViewManagerCID);
   NS_ENSURE_TRUE(vm, false);
   rv = vm->Init(dc);
   NS_ENSURE_SUCCESS(rv, false);
 
   // Create a child window of the parent that is our "root view/window"
   // Create a view
   nsRect tbounds = mPresContext->GetVisibleArea();
   nsView* view = vm->CreateView(tbounds, nullptr);
--- a/layout/base/nsPresShell.h
+++ b/layout/base/nsPresShell.h
@@ -65,17 +65,17 @@ public:
   NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
 
   // nsISupports
   NS_DECL_ISUPPORTS
 
   // nsIPresShell
   virtual NS_HIDDEN_(nsresult) Init(nsIDocument* aDocument,
                                    nsPresContext* aPresContext,
-                                   nsViewManager* aViewManager,
+                                   nsIViewManager* aViewManager,
                                    nsStyleSet* aStyleSet,
                                    nsCompatibility aCompatMode);
   virtual NS_HIDDEN_(void) Destroy();
 
   virtual NS_HIDDEN_(nsresult) SetPreferenceStyleRules(bool aForceReflow);
 
   NS_IMETHOD GetSelection(SelectionType aType, nsISelection** aSelection);
   virtual nsISelection* GetCurrentSelection(SelectionType aType);
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -34,17 +34,17 @@
 #include "nsAutoPtr.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsIDocument.h"
 #include "nsGUIEvent.h"
 #include "nsEventDispatcher.h"
 #include "jsapi.h"
 #include "nsContentUtils.h"
 #include "mozilla/Preferences.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "sampler.h"
 #include "nsNPAPIPluginInstance.h"
 
 using mozilla::TimeStamp;
 using mozilla::TimeDuration;
 
 using namespace mozilla;
 
@@ -946,17 +946,17 @@ nsRefreshDriver::Tick(int64_t aNowEpoch,
     // Waiting for bug 785597 to work on android.
     nsRefPtr<layers::LayerManager> mgr = mPresContext->GetPresShell()->GetLayerManager();
     if (mgr) {
       mgr->SetPaintStartTime(mMostRecentRefresh);
     }
 #endif
 
     mViewManagerFlushIsPending = false;
-    nsRefPtr<nsViewManager> vm = mPresContext->GetPresShell()->GetViewManager();
+    nsCOMPtr<nsIViewManager> vm = mPresContext->GetPresShell()->GetViewManager();
     vm->ProcessPendingUpdates();
 #ifdef DEBUG_INVALIDATIONS
     printf("Ending ProcessPendingUpdates\n");
 #endif
   }
 }
 
 PLDHashOperator
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -61,16 +61,18 @@
 #include "txNodeSetAdaptor.h"
 
 #include "nsDOMParser.h"
 #include "nsDOMSerializer.h"
 #include "nsXMLHttpRequest.h"
 #include "nsChannelPolicy.h"
 
 // view stuff
+#include "nsViewsCID.h"
+#include "nsViewManager.h"
 #include "nsContentCreatorFunctions.h"
 
 // DOM includes
 #include "nsDOMException.h"
 #include "nsDOMFileReader.h"
 
 #include "ArchiveReader.h"
 
@@ -587,16 +589,18 @@ static nsresult                         
         rv = NS_ERROR_OUT_OF_MEMORY;                                          \
         return rv;                                                            \
     }                                                                         \
     rv = inst->QueryInterface(aIID, aResult);                                 \
                                                                               \
     return rv;                                                                \
 }                                                                             \
 
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewManager)
+
 static nsresult
 CreateHTMLImgElement(nsISupports* aOuter, REFNSIID aIID, void** aResult)
 {
   *aResult = nullptr;
   if (aOuter)
     return NS_ERROR_NO_AGGREGATION;
   // Note! NS_NewHTMLImageElement is special cased to handle a null nodeinfo
   nsCOMPtr<nsINodeInfo> ni;
@@ -746,16 +750,17 @@ NS_DEFINE_NAMED_CID(NS_XULTREEBUILDER_CI
 NS_DEFINE_NAMED_CID(NS_XULDOCUMENT_CID);
 #endif
 NS_DEFINE_NAMED_CID(NS_CONTENT_DOCUMENT_LOADER_FACTORY_CID);
 NS_DEFINE_NAMED_CID(NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
 NS_DEFINE_NAMED_CID(NS_JSPROTOCOLHANDLER_CID);
 NS_DEFINE_NAMED_CID(NS_JSURI_CID);
 NS_DEFINE_NAMED_CID(NS_WINDOWCOMMANDTABLE_CID);
 NS_DEFINE_NAMED_CID(NS_WINDOWCONTROLLER_CID);
+NS_DEFINE_NAMED_CID(NS_VIEW_MANAGER_CID);
 NS_DEFINE_NAMED_CID(NS_PLUGINDOCLOADERFACTORY_CID);
 NS_DEFINE_NAMED_CID(NS_PLUGINDOCUMENT_CID);
 #ifdef MOZ_MEDIA
 NS_DEFINE_NAMED_CID(NS_VIDEODOCUMENT_CID);
 #endif
 NS_DEFINE_NAMED_CID(NS_STYLESHEETSERVICE_CID);
 NS_DEFINE_NAMED_CID(TRANSFORMIIX_XSLT_PROCESSOR_CID);
 NS_DEFINE_NAMED_CID(TRANSFORMIIX_XPATH_EVALUATOR_CID);
@@ -1029,16 +1034,17 @@ static const mozilla::Module::CIDEntry k
   { &kNS_XULDOCUMENT_CID, false, NULL, CreateXULDocument },
 #endif
   { &kNS_CONTENT_DOCUMENT_LOADER_FACTORY_CID, false, NULL, CreateContentDLF },
   { &kNS_DOM_SCRIPT_OBJECT_FACTORY_CID, false, NULL, nsDOMScriptObjectFactoryConstructor },
   { &kNS_JSPROTOCOLHANDLER_CID, false, NULL, nsJSProtocolHandler::Create },
   { &kNS_JSURI_CID, false, NULL, nsJSURIConstructor },
   { &kNS_WINDOWCOMMANDTABLE_CID, false, NULL, CreateWindowCommandTableConstructor },
   { &kNS_WINDOWCONTROLLER_CID, false, NULL, CreateWindowControllerWithSingletonCommandTable },
+  { &kNS_VIEW_MANAGER_CID, false, NULL, nsViewManagerConstructor },
   { &kNS_PLUGINDOCLOADERFACTORY_CID, false, NULL, CreateContentDLF },
   { &kNS_PLUGINDOCUMENT_CID, false, NULL, CreatePluginDocument },
 #ifdef MOZ_MEDIA
   { &kNS_VIDEODOCUMENT_CID, false, NULL, CreateVideoDocument },
 #endif
   { &kNS_STYLESHEETSERVICE_CID, false, NULL, nsStyleSheetServiceConstructor },
   { &kTRANSFORMIIX_XSLT_PROCESSOR_CID, false, NULL, txMozillaXSLTProcessorConstructor },
   { &kTRANSFORMIIX_XPATH_EVALUATOR_CID, false, NULL, nsXPathEvaluatorConstructor },
@@ -1178,16 +1184,17 @@ static const mozilla::Module::ContractID
   { "@mozilla.org/xul/xul-sort-service;1", &kNS_XULSORTSERVICE_CID },
   { "@mozilla.org/xul/xul-template-builder;1", &kNS_XULTEMPLATEBUILDER_CID },
   { "@mozilla.org/xul/xul-tree-builder;1", &kNS_XULTREEBUILDER_CID },
   { "@mozilla.org/xul/xul-document;1", &kNS_XULDOCUMENT_CID },
 #endif
   { CONTENT_DLF_CONTRACTID, &kNS_CONTENT_DOCUMENT_LOADER_FACTORY_CID },
   { NS_JSPROTOCOLHANDLER_CONTRACTID, &kNS_JSPROTOCOLHANDLER_CID },
   { NS_WINDOWCONTROLLER_CONTRACTID, &kNS_WINDOWCONTROLLER_CID },
+  { "@mozilla.org/view-manager;1", &kNS_VIEW_MANAGER_CID },
   { PLUGIN_DLF_CONTRACTID, &kNS_PLUGINDOCLOADERFACTORY_CID },
   { NS_STYLESHEETSERVICE_CONTRACTID, &kNS_STYLESHEETSERVICE_CID },
   { TRANSFORMIIX_XSLT_PROCESSOR_CONTRACTID, &kTRANSFORMIIX_XSLT_PROCESSOR_CID },
   { NS_XPATH_EVALUATOR_CONTRACTID, &kTRANSFORMIIX_XPATH_EVALUATOR_CID },
   { TRANSFORMIIX_NODESET_CONTRACTID, &kTRANSFORMIIX_NODESET_CID },
   { NS_XMLSERIALIZER_CONTRACTID, &kNS_XMLSERIALIZER_CID },
   { NS_FILEREADER_CONTRACTID, &kNS_FILEREADER_CID },
   { NS_ARCHIVEREADER_CONTRACTID, &kNS_ARCHIVEREADER_CID },
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -19,17 +19,17 @@
 #include "nsIListControlFrame.h"
 #include "nsIDOMHTMLCollection.h"
 #include "nsIDOMHTMLSelectElement.h"
 #include "nsIDOMHTMLOptionElement.h"
 #include "nsPIDOMWindow.h"
 #include "nsIPresShell.h"
 #include "nsContentList.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsEventDispatcher.h"
 #include "nsEventListenerManager.h"
 #include "nsIDOMNode.h"
 #include "nsISelectControlFrame.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIComponentManager.h"
 #include "nsContentUtils.h"
@@ -351,17 +351,17 @@ nsComboboxControlFrame::SetFocus(bool aO
   // Bug 32920
   InvalidateFrame();
 }
 
 void
 nsComboboxControlFrame::ShowPopup(bool aShowPopup)
 {
   nsView* view = mDropdownFrame->GetView();
-  nsViewManager* viewManager = view->GetViewManager();
+  nsIViewManager* viewManager = view->GetViewManager();
 
   if (aShowPopup) {
     nsRect rect = mDropdownFrame->GetRect();
     rect.x = rect.y = 0;
     viewManager->ResizeView(view, rect);
     viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
   } else {
     viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
@@ -505,17 +505,17 @@ nsComboboxControlFrame::ReflowDropdown(n
     aReflowState.mComputedBorderPadding.LeftRight() -
     kidReflowState.mComputedBorderPadding.LeftRight();
   kidReflowState.SetComputedWidth(NS_MAX(kidReflowState.ComputedWidth(),
                                          forcedWidth));
 
   // ensure we start off hidden
   if (GetStateBits() & NS_FRAME_FIRST_REFLOW) {
     nsView* view = mDropdownFrame->GetView();
-    nsViewManager* viewManager = view->GetViewManager();
+    nsIViewManager* viewManager = view->GetViewManager();
     viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
     nsRect emptyRect(0, 0, 0, 0);
     viewManager->ResizeView(view, emptyRect);
   }
 
   // Allow the child to move/size/change-visibility its view if it's currently
   // dropped down
   int32_t flags = NS_FRAME_NO_MOVE_FRAME | NS_FRAME_NO_VISIBILITY | NS_FRAME_NO_SIZE_VIEW;
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -12,17 +12,17 @@
 #include "nsGkAtoms.h"
 #include "nsIFormControl.h"
 #include "nsIDocument.h"
 #include "nsIDOMHTMLCollection.h"
 #include "nsIDOMHTMLOptionsCollection.h"
 #include "nsIDOMHTMLSelectElement.h"
 #include "nsIDOMHTMLOptionElement.h"
 #include "nsComboboxControlFrame.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIDOMHTMLOptGroupElement.h"
 #include "nsWidgetsCID.h"
 #include "nsIPresShell.h"
 #include "nsHTMLParts.h"
 #include "nsIDOMEventTarget.h"
 #include "nsEventDispatcher.h"
 #include "nsEventStateManager.h"
 #include "nsEventListenerManager.h"
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -34,17 +34,17 @@
 #include "nsIContent.h"
 #include "nsIAtom.h"
 #include "nsPresContext.h"
 #include "nsRenderingContext.h"
 #include "nsGkAtoms.h"
 #include "nsLayoutUtils.h"
 #include "nsIComponentManager.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIDOMHTMLInputElement.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIPresShell.h"
 
 #include "nsBoxLayoutState.h"
 //for keylistener for "return" check
 #include "nsIDOMEventTarget.h"
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -17,17 +17,17 @@
 #include "nsGUIEvent.h"
 #include "nsStyleConsts.h"
 #include "nsView.h"
 #include "nsFrameManager.h"
 #include "nsIPresShell.h"
 #include "nsCOMPtr.h"
 #include "nsGkAtoms.h"
 #include "nsCSSAnonBoxes.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIWidget.h"
 #include "nsGfxCIID.h"
 #include "nsIServiceManager.h"
 #include "nsCSSRendering.h"
 #include "nsTransform2D.h"
 #include "nsRegion.h"
 #include "nsError.h"
 #include "nsDisplayList.h"
@@ -368,17 +368,17 @@ nsContainerFrame::PeekOffsetCharacter(bo
   return false;
 }
 
 /////////////////////////////////////////////////////////////////////////////
 // Helper member functions
 
 static nsresult
 ReparentFrameViewTo(nsIFrame*       aFrame,
-                    nsViewManager* aViewManager,
+                    nsIViewManager* aViewManager,
                     nsView*        aNewParentView,
                     nsView*        aOldParentView)
 {
 
   // XXX What to do about placeholder views for "position: fixed" elements?
   // They should be reparented too.
 
   // Does aFrame have a view?
@@ -427,17 +427,17 @@ nsContainerFrame::CreateViewForFrame(nsI
   if (!aForce && !aFrame->NeedsView()) {
     // don't need a view
     return NS_OK;
   }
 
   nsView* parentView = aFrame->GetParent()->GetClosestView();
   NS_ASSERTION(parentView, "no parent with view");
 
-  nsViewManager* viewManager = parentView->GetViewManager();
+  nsIViewManager* viewManager = parentView->GetViewManager();
   NS_ASSERTION(viewManager, "null view manager");
 
   // Create a view
   nsView* view = viewManager->CreateView(aFrame->GetRect(), parentView);
   if (!view)
     return NS_ERROR_OUT_OF_MEMORY;
 
   SyncFrameViewProperties(aFrame->PresContext(), aFrame, nullptr, view);
@@ -475,17 +475,17 @@ nsContainerFrame::CreateViewForFrame(nsI
 void
 nsContainerFrame::PositionFrameView(nsIFrame* aKidFrame)
 {
   nsIFrame* parentFrame = aKidFrame->GetParent();
   if (!aKidFrame->HasView() || !parentFrame)
     return;
 
   nsView* view = aKidFrame->GetView();
-  nsViewManager* vm = view->GetViewManager();
+  nsIViewManager* vm = view->GetViewManager();
   nsPoint pt;
   nsView* ancestorView = parentFrame->GetClosestView(&pt);
 
   if (ancestorView != view->GetParent()) {
     NS_ASSERTION(ancestorView == view->GetParent()->GetParent(),
                  "Allowed only one anonymous view between frames");
     // parentFrame is responsible for positioning aKidFrame's view
     // explicitly
@@ -602,17 +602,17 @@ nsContainerFrame::ReparentFrameViewList(
   // found a common ancestor.
   nsView* oldParentView = aOldParentFrame->GetClosestView();
   nsView* newParentView = aNewParentFrame->GetClosestView();
   
   // See if the old parent frame and the new parent frame are in the
   // same view sub-hierarchy. If they are then we don't have to do
   // anything
   if (oldParentView != newParentView) {
-    nsViewManager* viewManager = oldParentView->GetViewManager();
+    nsIViewManager* viewManager = oldParentView->GetViewManager();
 
     // They're not so we need to reparent any child views
     for (nsFrameList::Enumerator e(aChildFrameList); !e.AtEnd(); e.Next()) {
       ReparentFrameViewTo(e.get(), viewManager, newParentView, oldParentView);
     }
   }
 
   return NS_OK;
@@ -651,17 +651,17 @@ nsContainerFrame::SyncWindowProperties(n
 #ifdef MOZ_XUL
   if (!aView || !nsCSSRendering::IsCanvasFrame(aFrame) || !aView->HasWidget())
     return;
 
   nsIWidget* windowWidget = GetPresContextContainerWidget(aPresContext);
   if (!windowWidget || !IsTopLevelWidget(windowWidget))
     return;
 
-  nsViewManager* vm = aView->GetViewManager();
+  nsIViewManager* vm = aView->GetViewManager();
   nsView* rootView = vm->GetRootView();
 
   if (aView != rootView)
     return;
 
   Element* rootElement = aPresContext->Document()->GetRootElement();
   if (!rootElement || !rootElement->IsXUL()) {
     // Scrollframes use native widgets which don't work well with
@@ -743,17 +743,17 @@ nsContainerFrame::SyncFrameViewAfterRefl
   }
 
   // Make sure the view is sized and positioned correctly
   if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) {
     PositionFrameView(aFrame);
   }
 
   if (0 == (aFlags & NS_FRAME_NO_SIZE_VIEW)) {
-    nsViewManager* vm = aView->GetViewManager();
+    nsIViewManager* vm = aView->GetViewManager();
 
     vm->ResizeView(aView, aVisualOverflowArea, true);
   }
 }
 
 void
 nsContainerFrame::SyncFrameViewProperties(nsPresContext*  aPresContext,
                                           nsIFrame*        aFrame,
@@ -763,17 +763,17 @@ nsContainerFrame::SyncFrameViewPropertie
 {
   NS_ASSERTION(!aStyleContext || aFrame->GetStyleContext() == aStyleContext,
                "Wrong style context for frame?");
 
   if (!aView) {
     return;
   }
 
-  nsViewManager* vm = aView->GetViewManager();
+  nsIViewManager* vm = aView->GetViewManager();
 
   if (nullptr == aStyleContext) {
     aStyleContext = aFrame->GetStyleContext();
   }
 
   // Make sure visibility is correct. This only affects nsSubdocumentFrame.
   if (0 == (aFlags & NS_FRAME_NO_VISIBILITY) &&
       !aFrame->SupportsVisibilityHidden()) {
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -17,17 +17,17 @@
 #include "nsIContent.h"
 #include "nsContentUtils.h"
 #include "nsIAtom.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsStyleContext.h"
 #include "nsTableOuterFrame.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIScrollableFrame.h"
 #include "nsPresContext.h"
 #include "nsCRT.h"
 #include "nsGUIEvent.h"
 #include "nsIDOMEvent.h"
 #include "nsAsyncDOMEvent.h"
 #include "nsStyleConsts.h"
 #include "nsIPresShell.h"
@@ -5284,17 +5284,17 @@ nsFrame::UpdateOverflow()
   if (FinishAndStoreOverflow(overflowAreas, GetSize())) {
     nsView* view = GetView();
     if (view) {
       uint32_t flags = 0;
       GetLayoutFlags(flags);
 
       if ((flags & NS_FRAME_NO_SIZE_VIEW) == 0) {
         // Make sure the frame's view is properly sized.
-        nsViewManager* vm = view->GetViewManager();
+        nsIViewManager* vm = view->GetViewManager();
         vm->ResizeView(view, overflowAreas.VisualOverflow(), true);
       }
     }
 
     return true;
   }
 
   return false;
--- a/layout/generic/nsFrameSetFrame.cpp
+++ b/layout/generic/nsFrameSetFrame.cpp
@@ -17,17 +17,17 @@
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsIComponentManager.h"
 #include "nsIStreamListener.h"
 #include "nsIURL.h"
 #include "nsIDocument.h"
 #include "nsINodeInfo.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsWidgetsCID.h"
 #include "nsGkAtoms.h"
 #include "nsStyleCoord.h"
 #include "nsStyleConsts.h"
 #include "nsStyleContext.h"
 #include "nsHTMLParts.h"
 #include "nsGUIEvent.h"
 #include "nsRenderingContext.h"
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -6,17 +6,17 @@
 /* rendering object to wrap rendering objects that should be scrollable */
 
 #include "nsCOMPtr.h"
 #include "nsHTMLParts.h"
 #include "nsPresContext.h"
 #include "nsIServiceManager.h"
 #include "nsView.h"
 #include "nsIScrollable.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsContainerFrame.h"
 #include "nsGfxScrollFrame.h"
 #include "nsGkAtoms.h"
 #include "nsINameSpaceManager.h"
 #include "nsContentList.h"
 #include "nsIDocument.h"
 #include "nsFontMetrics.h"
 #include "nsIDocumentObserver.h"
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -9,17 +9,17 @@
 #include "mozilla/plugins/PluginMessageUtils.h"
 
 #include "nscore.h"
 #include "nsCOMPtr.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsWidgetsCID.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIDOMEventListener.h"
 #include "nsIDOMDragEvent.h"
 #include "nsPluginHost.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsGkAtoms.h"
 #include "nsIAppShell.h"
 #include "nsIDocument.h"
@@ -324,17 +324,17 @@ nsObjectFrame::DestroyFrom(nsIFrame* aDe
   nsObjectFrameSuper::DestroyFrom(aDestructRoot);
 }
 
 /* virtual */ void
 nsObjectFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
 {
   if (HasView()) {
     nsView* view = GetView();
-    nsViewManager* vm = view->GetViewManager();
+    nsIViewManager* vm = view->GetViewManager();
     if (vm) {
       nsViewVisibility visibility = 
         IsHidden() ? nsViewVisibility_kHide : nsViewVisibility_kShow;
       vm->SetViewVisibility(view, visibility);
     }
   }
 
   nsObjectFrameSuper::DidSetStyleContext(aOldStyleContext);
@@ -360,17 +360,17 @@ nsObjectFrame::PrepForDrawing(nsIWidget 
   mWidget = aWidget;
 
   nsView* view = GetView();
   NS_ASSERTION(view, "Object frames must have views");  
   if (!view) {
     return NS_ERROR_FAILURE;
   }
 
-  nsViewManager* viewMan = view->GetViewManager();
+  nsIViewManager* viewMan = view->GetViewManager();
   // mark the view as hidden since we don't know the (x,y) until Paint
   // XXX is the above comment correct?
   viewMan->SetViewVisibility(view, nsViewVisibility_kHide);
 
   //this is ugly. it was ripped off from didreflow(). MMP
   // Position and size view relative to its parent, not relative to our
   // parent frame (our parent frame may not have a view).
   
@@ -588,17 +588,17 @@ nsObjectFrame::Reflow(nsPresContext*    
     aStatus = NS_FRAME_COMPLETE;
     return NS_OK;
   }
 
   nsRect r(0, 0, aMetrics.width, aMetrics.height);
   r.Deflate(aReflowState.mComputedBorderPadding);
 
   if (mInnerView) {
-    nsViewManager* vm = mInnerView->GetViewManager();
+    nsIViewManager* vm = mInnerView->GetViewManager();
     vm->MoveViewTo(mInnerView, r.x, r.y);
     vm->ResizeView(mInnerView, nsRect(nsPoint(0, 0), r.Size()), true);
   }
 
   FixupWindow(r.Size());
   if (!mReflowCallbackPosted) {
     mReflowCallbackPosted = true;
     aPresContext->PresShell()->PostReflowCallback(this);
@@ -879,17 +879,17 @@ nsObjectFrame::DidReflow(nsPresContext* 
 
   // The view is created hidden; once we have reflowed it and it has been
   // positioned then we show it.
   if (aStatus != nsDidReflowStatus::FINISHED) 
     return rv;
 
   if (HasView()) {
     nsView* view = GetView();
-    nsViewManager* vm = view->GetViewManager();
+    nsIViewManager* vm = view->GetViewManager();
     if (vm)
       vm->SetViewVisibility(view, IsHidden() ? nsViewVisibility_kHide : nsViewVisibility_kShow);
   }
 
   return rv;
 }
 
 /* static */ void
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -25,17 +25,17 @@
 #include "nsIPresShell.h"
 #include "nsIComponentManager.h"
 #include "nsFrameManager.h"
 #include "nsIStreamListener.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
 #include "nsIDocument.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsGkAtoms.h"
 #include "nsStyleCoord.h"
 #include "nsStyleContext.h"
 #include "nsStyleConsts.h"
 #include "nsFrameSetFrame.h"
 #include "nsIDOMHTMLFrameElement.h"
 #include "nsIDOMHTMLIFrameElement.h"
 #include "nsIDOMXULElement.h"
@@ -669,17 +669,17 @@ nsSubDocumentFrame::Reflow(nsPresContext
 
   nsSize innerSize(aDesiredSize.width, aDesiredSize.height);
   if (IsInline()) {
     innerSize.width  -= aReflowState.mComputedBorderPadding.LeftRight();
     innerSize.height -= aReflowState.mComputedBorderPadding.TopBottom();
   }
 
   if (mInnerView) {
-    nsViewManager* vm = mInnerView->GetViewManager();
+    nsIViewManager* vm = mInnerView->GetViewManager();
     vm->MoveViewTo(mInnerView, offset.x, offset.y);
     vm->ResizeView(mInnerView, nsRect(nsPoint(0, 0), innerSize), true);
   }
 
   aDesiredSize.SetOverflowAreasToDesiredBounds();
   if (!ShouldClipSubdocument()) {
     nsIFrame* subdocRootFrame = GetSubdocumentRootFrame();
     if (subdocRootFrame) {
@@ -953,17 +953,17 @@ BeginSwapDocShellsForViews(nsView* aSibl
 }
 
 static void
 InsertViewsInReverseOrder(nsView* aSibling, nsView* aParent)
 {
   NS_PRECONDITION(aParent, "");
   NS_PRECONDITION(!aParent->GetFirstChild(), "inserting into non-empty list");
 
-  nsViewManager* vm = aParent->GetViewManager();
+  nsIViewManager* vm = aParent->GetViewManager();
   while (aSibling) {
     nsView* next = aSibling->GetNextSibling();
     aSibling->SetNextSibling(nullptr);
     // true means 'after' in document order which is 'before' in view order,
     // so this call prepends the child, thus reversing the siblings as we go.
     vm->InsertChild(aParent, aSibling, nullptr, true);
     aSibling = next;
   }
@@ -1087,17 +1087,17 @@ nsSubDocumentFrame::EnsureInnerView()
     return mInnerView;
   }
 
   // create, init, set the parent of the view
   nsView* outerView = GetView();
   NS_ASSERTION(outerView, "Must have an outer view already");
   nsRect viewBounds(0, 0, 0, 0); // size will be fixed during reflow
 
-  nsViewManager* viewMan = outerView->GetViewManager();
+  nsIViewManager* viewMan = outerView->GetViewManager();
   nsView* innerView = viewMan->CreateView(viewBounds, outerView);
   if (!innerView) {
     NS_ERROR("Could not create inner view");
     return nullptr;
   }
   mInnerView = innerView;
   viewMan->InsertChild(outerView, innerView, nullptr, true);
 
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -82,19 +82,20 @@ static const char kPrintingPromptService
 #include "nsIDOMRange.h"
 #include "nsContentCID.h"
 #include "nsLayoutCID.h"
 #include "nsContentUtils.h"
 #include "nsIPresShell.h"
 #include "nsLayoutUtils.h"
 #include "mozilla/Preferences.h"
 
+#include "nsViewsCID.h"
 #include "nsWidgetsCID.h"
 #include "nsIDeviceContextSpec.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsView.h"
 #include "nsRenderingContext.h"
 
 #include "nsIPageSequenceFrame.h"
 #include "nsIURL.h"
 #include "nsIContentViewerEdit.h"
 #include "nsIContentViewerFile.h"
 #include "nsIMarkupDocumentViewer.h"
@@ -210,16 +211,19 @@ public:
   }
 
   void Disconnect() { mPrintEngine = nullptr; }
 protected:
   nsRefPtr<nsPrintEngine> mPrintEngine;
   bool                    mSuppressed;
 };
 
+// Class IDs
+static NS_DEFINE_CID(kViewManagerCID,       NS_VIEW_MANAGER_CID);
+
 NS_IMPL_ISUPPORTS3(nsPrintEngine, nsIWebProgressListener,
                    nsISupportsWeakReference, nsIObserver)
 
 //---------------------------------------------------
 //-- nsPrintEngine Class Impl
 //---------------------------------------------------
 nsPrintEngine::nsPrintEngine() :
   mIsCreatingPrintPreview(false),
@@ -2188,17 +2192,18 @@ nsPrintEngine::ReflowPrintObject(nsPrint
   aPO->mPresContext->SetBackgroundColorDraw(printBGColors);
   mPrt->mPrintSettings->GetPrintBGImages(&printBGColors);
   aPO->mPresContext->SetBackgroundImageDraw(printBGColors);
 
   // init it with the DC
   nsresult rv = aPO->mPresContext->Init(mPrt->mPrintDC);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  aPO->mViewManager = new nsViewManager();
+  aPO->mViewManager = do_CreateInstance(kViewManagerCID, &rv);
+  NS_ENSURE_SUCCESS(rv,rv);
 
   rv = aPO->mViewManager->Init(mPrt->mPrintDC);
   NS_ENSURE_SUCCESS(rv,rv);
 
   nsStyleSet* styleSet;
   rv = mDocViewerPrint->CreateStyleSet(aPO->mDocument, &styleSet);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -3783,17 +3788,17 @@ DumpViews(nsIDocShell* aDocShell, FILE* 
 {
   NS_ASSERTION(aDocShell, "Pointer is null!");
   NS_ASSERTION(out, "Pointer is null!");
 
   if (nullptr != aDocShell) {
     fprintf(out, "docshell=%p \n", aDocShell);
     nsIPresShell* shell = nsPrintEngine::GetPresShellFor(aDocShell);
     if (shell) {
-      nsViewManager* vm = shell->GetViewManager();
+      nsIViewManager* vm = shell->GetViewManager();
       if (vm) {
         nsView* root = vm->GetRootView();
         if (root) {
           root->List(out);
         }
       }
     }
     else {
--- a/layout/printing/nsPrintObject.h
+++ b/layout/printing/nsPrintObject.h
@@ -7,17 +7,17 @@
 
 #include "mozilla/Attributes.h"
 
 // Interfaces
 #include "nsCOMPtr.h"
 #include "nsIContent.h"
 #include "nsIPresShell.h"
 #include "nsStyleSet.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
 #include "nsIDocShellTreeOwner.h"
 
 class nsPresContext;
 
 // nsPrintObject Document Type
 enum PrintObjectType  {eDoc = 0, eFrame = 1, eIFrame = 2, eFrameSet = 3};
@@ -41,17 +41,17 @@ public:
 
   // Data Members
   nsCOMPtr<nsIDocShell>    mDocShell;
   nsCOMPtr<nsIDocShellTreeOwner> mTreeOwner;
   nsCOMPtr<nsIDocument>    mDocument;
 
   nsRefPtr<nsPresContext>  mPresContext;
   nsCOMPtr<nsIPresShell>   mPresShell;
-  nsRefPtr<nsViewManager> mViewManager;
+  nsCOMPtr<nsIViewManager> mViewManager;
 
   nsCOMPtr<nsIContent>     mContent;
   PrintObjectType  mFrameType;
   
   nsTArray<nsPrintObject*> mKids;
   nsPrintObject*   mParent;
   bool             mHasBeenPrinted;
   bool             mDontPrint;
--- a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp
+++ b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp
@@ -16,17 +16,17 @@
 #include "nsIAtom.h"
 #include "nsQuickSort.h"
 
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 
 #include "nsIPresShell.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIFrame.h"
 
 #include "nsILayoutDebugger.h"
 #include "nsLayoutCID.h"
 static NS_DEFINE_CID(kLayoutDebuggerCID, NS_LAYOUT_DEBUGGER_CID);
 
 #include "nsISelectionController.h"
 #include "mozilla/dom/Element.h"
@@ -50,17 +50,17 @@ pres_shell(nsIDocShell *aDocShell)
     nsCOMPtr<nsIContentViewer> cv = doc_viewer(aDocShell);
     if (!cv)
         return nullptr;
     nsCOMPtr<nsIPresShell> result;
     cv->GetPresShell(getter_AddRefs(result));
     return result.forget();
 }
 
-static nsViewManager*
+static nsIViewManager*
 view_manager(nsIDocShell *aDocShell)
 {
     nsCOMPtr<nsIPresShell> shell(pres_shell(aDocShell));
     if (!shell)
         return nullptr;
     return shell->GetViewManager();
 }
 
@@ -428,17 +428,17 @@ nsLayoutDebuggingTools::DumpFrames()
 }
 
 static
 void
 DumpViewsRecur(nsIDocShell* aDocShell, FILE* out)
 {
 #ifdef DEBUG
     fprintf(out, "docshell=%p \n", static_cast<void*>(aDocShell));
-    nsRefPtr<nsViewManager> vm(view_manager(aDocShell));
+    nsCOMPtr<nsIViewManager> vm(view_manager(aDocShell));
     if (vm) {
         nsView* root = vm->GetRootView();
         if (root) {
             root->List(out);
         }
     }
     else {
         fputs("null view manager\n", out);
@@ -519,17 +519,17 @@ nsLayoutDebuggingTools::DumpReflowStats(
 #endif
     }
 #endif
     return NS_OK;
 }
 
 void nsLayoutDebuggingTools::ForceRefresh()
 {
-    nsRefPtr<nsViewManager> vm(view_manager(mDocShell));
+    nsCOMPtr<nsIViewManager> vm(view_manager(mDocShell));
     if (!vm)
         return;
     nsView* root = vm->GetRootView();
     if (root) {
         vm->InvalidateView(root);
     }
 }
 
--- a/layout/tools/layout-debug/src/nsRegressionTester.cpp
+++ b/layout/tools/layout-debug/src/nsRegressionTester.cpp
@@ -20,17 +20,17 @@
 #include "nsIContentViewer.h"
 #include "nsIContentViewerFile.h"
 #include "nsIFrame.h"
 #include "nsStyleStruct.h"
 #include "nsIFrameUtil.h"
 #include "nsLayoutCID.h"
 #include "nsNetUtil.h"
 #include "nsIFile.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsView.h"
 
 
 
 static NS_DEFINE_CID(kFrameUtilCID, NS_FRAME_UTIL_CID);
 
 
 nsRegressionTester::nsRegressionTester()
--- a/layout/xul/base/src/nsBoxFrame.cpp
+++ b/layout/xul/base/src/nsBoxFrame.cpp
@@ -36,17 +36,17 @@
 #include "nsDOMTouchEvent.h"
 #include "nsStyleContext.h"
 #include "nsPresContext.h"
 #include "nsCOMPtr.h"
 #include "nsINameSpaceManager.h"
 #include "nsGkAtoms.h"
 #include "nsIContent.h"
 #include "nsHTMLParts.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsView.h"
 #include "nsIPresShell.h"
 #include "nsCSSRendering.h"
 #include "nsIServiceManager.h"
 #include "nsBoxLayout.h"
 #include "nsSprocketLayout.h"
 #include "nsIScrollableFrame.h"
 #include "nsWidgetsCID.h"
--- a/layout/xul/base/src/nsDeckFrame.cpp
+++ b/layout/xul/base/src/nsDeckFrame.cpp
@@ -15,17 +15,17 @@
 #include "nsPresContext.h"
 #include "nsIContent.h"
 #include "nsCOMPtr.h"
 #include "nsINameSpaceManager.h"
 #include "nsGkAtoms.h"
 #include "nsHTMLParts.h"
 #include "nsIPresShell.h"
 #include "nsCSSRendering.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsBoxLayoutState.h"
 #include "nsStackLayout.h"
 #include "nsDisplayList.h"
 #include "nsContainerFrame.h"
 
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
 #endif
--- a/layout/xul/base/src/nsLeafBoxFrame.cpp
+++ b/layout/xul/base/src/nsLeafBoxFrame.cpp
@@ -15,17 +15,17 @@
 #include "nsCOMPtr.h"
 #include "nsGkAtoms.h"
 #include "nsPresContext.h"
 #include "nsStyleContext.h"
 #include "nsIContent.h"
 #include "nsINameSpaceManager.h"
 #include "nsBoxLayoutState.h"
 #include "nsWidgetsCID.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsContainerFrame.h"
 #include "nsDisplayList.h"
 
 //
 // NS_NewLeafBoxFrame
 //
 // Creates a new Toolbar frame and returns it
 //
--- a/layout/xul/base/src/nsListBoxBodyFrame.cpp
+++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp
@@ -17,17 +17,17 @@
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMNodeList.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsIScrollableFrame.h"
 #include "nsScrollbarFrame.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsStyleContext.h"
 #include "nsFontMetrics.h"
 #include "nsITimer.h"
 #include "nsAutoPtr.h"
 #include "nsStyleSet.h"
 #include "nsPIBoxObject.h"
 #include "nsINodeInfo.h"
 #include "nsLayoutUtils.h"
--- a/layout/xul/base/src/nsMenuPopupFrame.cpp
+++ b/layout/xul/base/src/nsMenuPopupFrame.cpp
@@ -7,17 +7,17 @@
 #include "nsMenuPopupFrame.h"
 #include "nsGkAtoms.h"
 #include "nsIContent.h"
 #include "nsIAtom.h"
 #include "nsPresContext.h"
 #include "nsStyleContext.h"
 #include "nsCSSRendering.h"
 #include "nsINameSpaceManager.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsWidgetsCID.h"
 #include "nsMenuFrame.h"
 #include "nsMenuBarFrame.h"
 #include "nsPopupSetFrame.h"
 #include "nsEventDispatcher.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMScreen.h"
 #include "nsIPresShell.h"
@@ -120,17 +120,17 @@ nsMenuPopupFrame::Init(nsIContent*      
 
   rv = CreatePopupView();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // XXX Hack. The popup's view should float above all other views,
   // so we use the nsView::SetFloating() to tell the view manager
   // about that constraint.
   nsView* ourView = GetView();
-  nsViewManager* viewManager = ourView->GetViewManager();
+  nsIViewManager* viewManager = ourView->GetViewManager();
   viewManager->SetViewFloating(ourView, true);
 
   mPopupType = ePopupTypePanel;
   nsIDocument* doc = aContent->OwnerDoc();
   int32_t namespaceID;
   nsCOMPtr<nsIAtom> tag = doc->BindingManager()->ResolveTag(aContent, &namespaceID);
   if (namespaceID == kNameSpaceID_XUL) {
     if (tag == nsGkAtoms::menupopup || tag == nsGkAtoms::popup)
@@ -454,17 +454,17 @@ nsMenuPopupFrame::LayoutPopup(nsBoxLayou
     // If the size of the popup changed, apply any size constraints.
     nsIWidget* widget = view->GetWidget();
     if (widget) {
       SetSizeConstraints(pc, widget, minSize, maxSize);
     }
   }
 
   if (isOpen) {
-    nsViewManager* viewManager = view->GetViewManager();
+    nsIViewManager* viewManager = view->GetViewManager();
     nsRect rect = GetRect();
     rect.x = rect.y = 0;
     viewManager->ResizeView(view, rect);
 
     viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
     mPopupState = ePopupOpenAndVisible;
     nsContainerFrame::SyncFrameViewProperties(pc, this, nullptr, view, 0);
   }
@@ -789,17 +789,17 @@ nsMenuPopupFrame::HidePopup(bool aDesele
 
   LockMenuUntilClosed(false);
 
   mIsOpenChanged = false;
   mCurrentMenu = nullptr; // make sure no current menu is set
   mHFlip = mVFlip = false;
 
   nsView* view = GetView();
-  nsViewManager* viewManager = view->GetViewManager();
+  nsIViewManager* viewManager = view->GetViewManager();
   viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
 
   FireDOMEvent(NS_LITERAL_STRING("DOMMenuInactive"), mContent);
 
   // XXX, bug 137033, In Windows, if mouse is outside the window when the menupopup closes, no
   // mouse_enter/mouse_exit event will be fired to clear current hover state, we should clear it manually.
   // This code may not the best solution, but we can leave it here until we find the better approach.
   NS_ASSERTION(mContent->IsElement(), "How do we have a non-element?");
@@ -1914,17 +1914,17 @@ nsMenuPopupFrame::SetConsumeRollupEvent(
  */
 nsresult
 nsMenuPopupFrame::CreatePopupView()
 {
   if (HasView()) {
     return NS_OK;
   }
 
-  nsViewManager* viewManager = PresContext()->GetPresShell()->GetViewManager();
+  nsIViewManager* viewManager = PresContext()->GetPresShell()->GetViewManager();
   NS_ASSERTION(nullptr != viewManager, "null view manager");
 
   // Create a view
   nsView* parentView = viewManager->GetRootView();
   nsViewVisibility visibility = nsViewVisibility_kHide;
   int32_t zIndex = INT32_MAX;
   bool    autoZIndex = false;
 
--- a/layout/xul/base/src/nsMenuPopupFrame.h
+++ b/layout/xul/base/src/nsMenuPopupFrame.h
@@ -85,17 +85,17 @@ enum FlipStyle {
 //  nsMenuPopupFrame.h, nsListControlFrame.cpp, listbox.xml, tree.xml
 //  need to find a good place to put them together.
 //  if someone changes one, please also change the other.
 
 #define CONTEXT_MENU_OFFSET_PIXELS 2
 
 nsIFrame* NS_NewMenuPopupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
 
-class nsViewManager;
+class nsIViewManager;
 class nsView;
 class nsMenuPopupFrame;
 
 class nsMenuPopupFrame : public nsBoxFrame, public nsMenuParent
 {
 public:
   NS_DECL_QUERYFRAME_TARGET(nsMenuPopupFrame)
   NS_DECL_QUERYFRAME
--- a/layout/xul/base/src/nsXULPopupManager.cpp
+++ b/layout/xul/base/src/nsXULPopupManager.cpp
@@ -15,17 +15,17 @@
 #include "nsIDOMEvent.h"
 #include "nsIDOMXULElement.h"
 #include "nsIXULDocument.h"
 #include "nsIXULTemplateBuilder.h"
 #include "nsEventDispatcher.h"
 #include "nsEventStateManager.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsLayoutUtils.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIComponentManager.h"
 #include "nsITimer.h"
 #include "nsFocusManager.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShell.h"
 #include "nsPIDOMWindow.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIBaseWindow.h"
@@ -2257,17 +2257,17 @@ nsXULPopupHidingEvent::Run()
 
 NS_IMETHODIMP
 nsXULMenuCommandEvent::Run()
 {
   nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
   if (!pm)
     return NS_OK;
 
-  // The order of the nsViewManager and nsIPresShell COM pointers is
+  // The order of the nsIViewManager and nsIPresShell COM pointers is
   // important below.  We want the pres shell to get released before the
   // associated view manager on exit from this function.
   // See bug 54233.
   // XXXndeakin is this still needed?
 
   nsCOMPtr<nsIContent> popup;
   nsMenuFrame* menuFrame = do_QueryFrame(mMenu->GetPrimaryFrame());
   nsWeakFrame weakFrame(menuFrame);
@@ -2290,17 +2290,17 @@ nsXULMenuCommandEvent::Run()
         popup = popupFrame->GetContent();
         break;
       }
       frame = frame->GetParent();
     }
 
     nsPresContext* presContext = menuFrame->PresContext();
     nsCOMPtr<nsIPresShell> shell = presContext->PresShell();
-    nsRefPtr<nsViewManager> kungFuDeathGrip = shell->GetViewManager();
+    nsCOMPtr<nsIViewManager> kungFuDeathGrip = shell->GetViewManager();
 
     // Deselect ourselves.
     if (mCloseMenuMode != CloseMenuMode_None)
       menuFrame->SelectMenu(false);
 
     nsAutoHandlingUserInputStatePusher userInpStatePusher(mUserInput, nullptr,
                                                           shell->GetDocument());
     nsContentUtils::DispatchXULCommand(mMenu, mIsTrusted, nullptr, shell,
--- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
@@ -34,17 +34,17 @@
 #include "nsIDOMXULElement.h"
 #include "nsIDocument.h"
 #include "mozilla/css/StyleRule.h"
 #include "nsCSSRendering.h"
 #include "nsIXULTemplateBuilder.h"
 #include "nsXPIDLString.h"
 #include "nsContainerFrame.h"
 #include "nsView.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsWidgetsCID.h"
 #include "nsBoxFrame.h"
 #include "nsBoxObject.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
 #include "nsBoxLayoutState.h"
 #include "nsTreeContentView.h"
 #include "nsTreeUtils.h"
--- a/view/public/Makefile.in
+++ b/view/public/Makefile.in
@@ -9,14 +9,15 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= view
 
 EXPORTS		= \
 		nsView.h \
-		nsViewManager.h \
+		nsIViewManager.h \
+		nsViewsCID.h \
 		nsIScrollPositionListener.h \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
new file mode 100644
--- /dev/null
+++ b/view/public/nsIViewManager.h
@@ -0,0 +1,311 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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 nsIViewManager_h___
+#define nsIViewManager_h___
+
+#include "nscore.h"
+#include "nsView.h"
+#include "nsEvent.h"
+
+class nsIWidget;
+struct nsRect;
+class nsRegion;
+class nsDeviceContext;
+class nsIPresShell;
+
+#define NS_IVIEWMANAGER_IID \
+{ 0x540610a6, 0x4fdd, 0x4ae3, \
+  { 0x9b, 0xdb, 0xa6, 0x4d, 0x8b, 0xca, 0x02, 0x0f } }
+
+class nsIViewManager : public nsISupports
+{
+public:
+
+  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IVIEWMANAGER_IID)
+  /**
+   * Initialize the ViewManager
+   * Note: this instance does not hold a reference to the presshell
+   * because it holds a reference to this instance.
+   * @result The result of the initialization, NS_OK if no errors
+   */
+  NS_IMETHOD  Init(nsDeviceContext* aContext) = 0;
+
+  /**
+   * Create an ordinary view
+   * @param aBounds initial bounds for view
+   *        XXX We should eliminate this parameter; you can set the bounds after CreateView
+   * @param aParent intended parent for view. this is not actually set in the
+   *        nsView through this method. it is only used by the initialization
+   *        code to walk up the view tree, if necessary, to find resources.
+   *        XXX We should eliminate this parameter!
+   * @param aVisibilityFlag initial visibility state of view
+   *        XXX We should eliminate this parameter; you can set it after CreateView
+   * @result The new view
+   */
+  NS_IMETHOD_(nsView*) CreateView(const nsRect& aBounds,
+                                   const nsView* aParent,
+                                   nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow) = 0;
+
+  /**
+   * Get the root of the view tree.
+   * @result the root view
+   */
+  NS_IMETHOD_(nsView*) GetRootView() = 0;
+
+  /**
+   * Set the root of the view tree. Does not destroy the current root view.
+   * aView may have a parent view managed by a different view manager.
+   * aView may have a widget (anything but printing) or may not (printing).
+   * @param aView view to set as root
+   */
+  NS_IMETHOD  SetRootView(nsView *aView) = 0;
+
+  /**
+   * Get the dimensions of the root window. The dimensions are in
+   * twips
+   * @param aWidth out parameter for width of window in twips
+   * @param aHeight out parameter for height of window in twips
+   */
+  NS_IMETHOD  GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) = 0;
+
+  /**
+   * Set the dimensions of the root window.
+   * Called if the root window is resized. The dimensions are in
+   * twips
+   * @param aWidth of window in twips
+   * @param aHeight of window in twips
+   */
+  NS_IMETHOD  SetWindowDimensions(nscoord aWidth, nscoord aHeight) = 0;
+
+  /**
+   * Do any resizes that are pending.
+   */
+  NS_IMETHOD  FlushDelayedResize(bool aDoReflow) = 0;
+
+  /**
+   * Called to inform the view manager that the entire area of a view
+   * is dirty and needs to be redrawn.
+   * @param aView view to paint. should be root view
+   */
+  NS_IMETHOD  InvalidateView(nsView *aView) = 0;
+
+  /**
+   * Called to inform the view manager that some portion of a view is dirty and
+   * needs to be redrawn. The rect passed in should be in the view's coordinate
+   * space. Does not check for paint suppression.
+   * @param aView view to paint. should be root view
+   * @param rect rect to mark as damaged
+   */
+  NS_IMETHOD  InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect) = 0;
+
+  /**
+   * Called to inform the view manager that it should invalidate all views.
+   */
+  NS_IMETHOD  InvalidateAllViews() = 0;
+
+  /**
+   * Called to dispatch an event to the appropriate view. Often called
+   * as a result of receiving a mouse or keyboard event from the widget
+   * event system.
+   * @param aEvent event to dispatch
+   * @param aViewTarget dispatch the event to this view
+   * @param aStatus event handling status
+   */
+  NS_IMETHOD  DispatchEvent(nsGUIEvent *aEvent,
+      nsView* aViewTarget, nsEventStatus* aStatus) = 0;
+
+  /**
+   * Given a parent view, insert another view as its child.
+   * aSibling and aAbove control the "document order" for the insertion.
+   * If aSibling is null, the view is inserted at the end of the document order
+   * if aAfter is true, otherwise it is inserted at the beginning.
+   * If aSibling is non-null, then if aAfter is true, the view is inserted
+   * after the sibling in document order (appearing above the sibling unless
+   * overriden by z-order).
+   * If it is false, the view is inserted before the sibling.
+   * The view manager generates the appopriate dirty regions.
+   * @param aParent parent view
+   * @param aChild child view
+   * @param aSibling sibling view
+   * @param aAfter after or before in the document order
+   */
+  NS_IMETHOD  InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling,
+                          bool aAfter) = 0;
+
+  /**
+   * Remove a specific child view from its parent. This will NOT remove its placeholder
+   * if there is one.
+   * The view manager generates the appropriate dirty regions.
+   * @param aParent parent view
+   * @param aChild child view
+   */
+  NS_IMETHOD  RemoveChild(nsView *aChild) = 0;
+
+  /**
+   * Move a view to the specified position, provided in parent coordinates.
+   * The new position is the (0, 0) origin for the view's coordinate system.
+   * The view's bounds may extend above or to the left of this point.
+   * The view manager generates the appropriate dirty regions.
+   * @param aView view to move
+   * @param aX x value for new view position
+   * @param aY y value for new view position
+   */
+  NS_IMETHOD  MoveViewTo(nsView *aView, nscoord aX, nscoord aY) = 0;
+
+  /**
+   * Resize a view. In addition to setting the width and height, you can
+   * set the x and y of its bounds relative to its position. Negative x and y
+   * will let the view extend above and to the left of the (0,0) point in its
+   * coordinate system.
+   * The view manager generates the appropriate dirty regions.
+   * @param aView view to move
+   * @param the new bounds relative to the current position
+   * @param RepaintExposedAreaOnly
+   *     if true Repaint only the expanded or contracted region,
+   *     if false Repaint the union of the old and new rectangles.
+   */
+  NS_IMETHOD  ResizeView(nsView *aView, const nsRect &aRect,
+                         bool aRepaintExposedAreaOnly = false) = 0;
+
+  /**
+   * Set the visibility of a view. Hidden views have the effect of hiding
+   * their descendants as well. This does not affect painting, so layout
+   * is responsible for ensuring that content in hidden views is not
+   * painted nor handling events. It does affect the visibility of widgets;
+   * if a view is hidden, descendant views with widgets have their widgets
+   * hidden.
+   * The view manager generates the appropriate dirty regions.
+   * @param aView view to change visibility state of
+   * @param visible new visibility state
+   */
+  NS_IMETHOD  SetViewVisibility(nsView *aView, nsViewVisibility aVisible) = 0;
+
+  /**
+   * Set the z-index of a view. Positive z-indices mean that a view
+   * is above its parent in z-order. Negative z-indices mean that a
+   * view is below its parent.
+   * The view manager generates the appropriate dirty regions.
+   * @param aAutoZIndex indicate that the z-index of a view is "auto". An "auto" z-index
+   * means that the view does not define a new stacking context,
+   * which means that the z-indicies of the view's children are
+   * relative to the view's siblings.
+   * @param aView view to change z depth of
+   * @param aZindex explicit z depth
+   * @param aTopMost used when this view is z-index:auto to compare against 
+   *        other z-index:auto views.
+   *        true if the view should be topmost when compared with 
+   *        other z-index:auto views.
+   */
+  NS_IMETHOD  SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZindex, bool aTopMost = false) = 0;
+
+  /**
+   * Set whether the view "floats" above all other views,
+   * which tells the compositor not to consider higher views in
+   * the view hierarchy that would geometrically intersect with
+   * this view. This is a hack, but it fixes some problems with
+   * views that need to be drawn in front of all other views.
+   */
+  NS_IMETHOD  SetViewFloating(nsView *aView, bool aFloatingView) = 0;
+
+  /**
+   * Set the presshell associated with this manager
+   * @param aPresShell - new presshell
+   */
+  virtual void SetPresShell(nsIPresShell *aPresShell) = 0;
+
+  /**
+   * Get the pres shell associated with this manager
+   */
+  virtual nsIPresShell* GetPresShell() = 0;
+
+  /**
+   * Get the device context associated with this manager
+   * @result device context
+   */
+  NS_IMETHOD  GetDeviceContext(nsDeviceContext *&aContext) = 0;
+
+  /**
+   * A stack class for disallowing changes that would enter painting. For
+   * example, popup widgets shouldn't be resized during reflow, since doing so
+   * might cause synchronous painting inside reflow which is forbidden.
+   * While refresh is disabled, widget geometry changes are deferred and will
+   * be handled later, either from the refresh driver or from an NS_WILL_PAINT
+   * event.
+   * We don't want to defer widget geometry changes all the time. Resizing a
+   * popup from script doesn't need to be deferred, for example, especially
+   * since popup widget geometry is observable from script and expected to
+   * update synchronously.
+   */
+  class NS_STACK_CLASS AutoDisableRefresh {
+  public:
+    AutoDisableRefresh(nsIViewManager* aVM) {
+      if (aVM) {
+        mRootVM = aVM->IncrementDisableRefreshCount();
+      }
+    }
+    ~AutoDisableRefresh() {
+      if (mRootVM) {
+        mRootVM->DecrementDisableRefreshCount();
+      }
+    }
+  private:
+    AutoDisableRefresh(const AutoDisableRefresh& aOther);
+    const AutoDisableRefresh& operator=(const AutoDisableRefresh& aOther);
+
+    nsCOMPtr<nsIViewManager> mRootVM;
+  };
+
+private:
+  friend class AutoDisableRefresh;
+
+  virtual nsIViewManager* IncrementDisableRefreshCount() = 0;
+  virtual void DecrementDisableRefreshCount() = 0;
+
+public:
+  /**
+   * Retrieve the widget at the root of the nearest enclosing
+   * view manager whose root view has a widget.
+   */
+  NS_IMETHOD GetRootWidget(nsIWidget **aWidget) = 0;
+
+  /**
+   * Indicate whether the viewmanager is currently painting
+   *
+   * @param aPainting true if the viewmanager is painting
+   *                  false otherwise
+   */
+  NS_IMETHOD IsPainting(bool& aIsPainting)=0;
+
+  /**
+   * Retrieve the time of the last user event. User events
+   * include mouse and keyboard events. The viewmanager
+   * saves the time of the last user event.
+   *
+   * @param aTime Last user event time in microseconds
+   */
+  NS_IMETHOD GetLastUserEventTime(uint32_t& aTime)=0;
+
+  /**
+   * Find the nearest display root view for the view aView. This is the view for
+   * the nearest enclosing popup or the root view for the root document.
+   */
+  static nsView* GetDisplayRootFor(nsView* aView);
+
+  /**
+   * Flush the accumulated dirty region to the widget and update widget
+   * geometry.
+   */
+  virtual void ProcessPendingUpdates()=0;
+
+  /**
+   * Just update widget geometry without flushing the dirty region
+   */
+  virtual void UpdateWidgetGeometry() = 0;
+};
+
+NS_DEFINE_STATIC_IID_ACCESSOR(nsIViewManager, NS_IVIEWMANAGER_IID)
+
+#endif  // nsIViewManager_h___
--- a/view/public/nsView.h
+++ b/view/public/nsView.h
@@ -1,24 +1,31 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 nsView_h__
 #define nsView_h__
 
+#include "nsISupports.h"
 #include "nsCoord.h"
 #include "nsRect.h"
 #include "nsPoint.h"
+#include "nsNativeWidget.h"
+#include "nsIWidget.h"
+#include "nsWidgetInitData.h"
 #include "nsRegion.h"
 #include "nsCRT.h"
+#include "nsIFactory.h"
 #include "nsEvent.h"
 #include "nsIWidgetListener.h"
+#include <stdio.h>
 
+class nsIViewManager;
 class nsViewManager;
 class nsIWidget;
 class nsIFrame;
 
 // Enumerated type to indicate the visibility of a layer.
 // hide - the layer is not shown.
 // show - the layer is shown irrespective of the visibility of 
 //        the layer's parent.
@@ -47,33 +54,35 @@ enum nsViewVisibility {
  *
  * Views are NOT reference counted. Use the Destroy() member function to
  * destroy a view.
  *
  * The lifetime of the view hierarchy is bounded by the lifetime of the
  * view manager that owns the views.
  *
  * Most of the methods here are read-only. To set the corresponding properties
- * of a view, go through nsViewManager.
+ * of a view, go through nsIViewManager.
  */
 
 class nsView MOZ_FINAL : public nsIWidgetListener
 {
 public:
   friend class nsViewManager;
 
   NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
 
   /**
    * Get the view manager which "owns" the view.
    * This method might require some expensive traversal work in the future. If you can get the
    * view manager from somewhere else, do that instead.
    * @result the view manager
    */
-  nsViewManager* GetViewManager() const { return mViewManager; }
+  nsIViewManager* GetViewManager() const
+  { return reinterpret_cast<nsIViewManager*>(mViewManager); }
+  nsViewManager* GetViewManagerInternal() const { return mViewManager; }
 
   /**
    * Find the view for the given widget, if there is one.
    * @return the view the widget belongs to, or null if the widget doesn't
    * belong to any view.
    */
   static nsView* GetViewFor(nsIWidget* aWidget);
 
@@ -446,23 +455,23 @@ private:
   void NotifyEffectiveVisibilityChanged(bool aEffectivelyVisible);
 
   // Update the cached RootViewManager for all view manager descendents,
   // If the hierarchy is being removed, aViewManagerParent points to the view
   // manager for the hierarchy's old parent, and will have its mouse grab
   // released if it points to any view in this view hierarchy.
   void InvalidateHierarchy(nsViewManager *aViewManagerParent);
 
-  nsViewManager    *mViewManager;
+  nsViewManager     *mViewManager;
   nsView           *mParent;
-  nsIWidget        *mWindow;
+  nsIWidget         *mWindow;
   nsView           *mNextSibling;
   nsView           *mFirstChild;
-  nsIFrame         *mFrame;
-  nsRegion         *mDirtyRegion;
+  nsIFrame          *mFrame;
+  nsRegion          *mDirtyRegion;
   int32_t           mZIndex;
   nsViewVisibility  mVis;
   // position relative our parent view origin but in our appunits
   nscoord           mPosX, mPosY;
   // relative to parent, but in our appunits
   nsRect            mDimBounds;
   // in our appunits
   nsPoint           mViewToWidgetOffset;
deleted file mode 100644
--- a/view/public/nsViewManager.h
+++ /dev/null
@@ -1,443 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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 nsViewManager_h___
-#define nsViewManager_h___
-
-#include "nscore.h"
-#include "nsView.h"
-#include "nsEvent.h"
-#include "nsCOMPtr.h"
-#include "nsCRT.h"
-#include "nsVoidArray.h"
-#include "nsDeviceContext.h"
-
-class nsIWidget;
-struct nsRect;
-class nsRegion;
-class nsDeviceContext;
-class nsIPresShell;
-
-class nsViewManager MOZ_FINAL
-{
-public:
-  friend class nsView;
-
-  NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
-
-  NS_INLINE_DECL_REFCOUNTING(nsViewManager)
-
-  nsViewManager();
-  ~nsViewManager();
-
-  /**
-   * Initialize the ViewManager
-   * Note: this instance does not hold a reference to the presshell
-   * because it holds a reference to this instance.
-   * @result The result of the initialization, NS_OK if no errors
-   */
-  nsresult Init(nsDeviceContext* aContext);
-
-  /**
-   * Create an ordinary view
-   * @param aBounds initial bounds for view
-   *        XXX We should eliminate this parameter; you can set the bounds after CreateView
-   * @param aParent intended parent for view. this is not actually set in the
-   *        nsView through this method. it is only used by the initialization
-   *        code to walk up the view tree, if necessary, to find resources.
-   *        XXX We should eliminate this parameter!
-   * @param aVisibilityFlag initial visibility state of view
-   *        XXX We should eliminate this parameter; you can set it after CreateView
-   * @result The new view
-   */
-  nsView* CreateView(const nsRect& aBounds,
-                     const nsView* aParent,
-                     nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
-
-  /**
-   * Get the root of the view tree.
-   * @result the root view
-   */
-  nsView* GetRootView() { return mRootView; }
-
-  /**
-   * Set the root of the view tree. Does not destroy the current root view.
-   * aView may have a parent view managed by a different view manager.
-   * aView may have a widget (anything but printing) or may not (printing).
-   * @param aView view to set as root
-   */
-  void SetRootView(nsView *aView);
-
-  /**
-   * Get the dimensions of the root window. The dimensions are in
-   * twips
-   * @param aWidth out parameter for width of window in twips
-   * @param aHeight out parameter for height of window in twips
-   */
-  void GetWindowDimensions(nscoord *aWidth, nscoord *aHeight);
-
-  /**
-   * Set the dimensions of the root window.
-   * Called if the root window is resized. The dimensions are in
-   * twips
-   * @param aWidth of window in twips
-   * @param aHeight of window in twips
-   */
-  void SetWindowDimensions(nscoord aWidth, nscoord aHeight);
-
-  /**
-   * Do any resizes that are pending.
-   */
-  void FlushDelayedResize(bool aDoReflow);
-
-  /**
-   * Called to inform the view manager that the entire area of a view
-   * is dirty and needs to be redrawn.
-   * @param aView view to paint. should be root view
-   */
-  void InvalidateView(nsView *aView);
-
-  /**
-   * Called to inform the view manager that some portion of a view is dirty and
-   * needs to be redrawn. The rect passed in should be in the view's coordinate
-   * space. Does not check for paint suppression.
-   * @param aView view to paint. should be root view
-   * @param rect rect to mark as damaged
-   */
-  void InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect);
-
-  /**
-   * Called to inform the view manager that it should invalidate all views.
-   */
-  void InvalidateAllViews();
-
-  /**
-   * Called to dispatch an event to the appropriate view. Often called
-   * as a result of receiving a mouse or keyboard event from the widget
-   * event system.
-   * @param aEvent event to dispatch
-   * @param aViewTarget dispatch the event to this view
-   * @param aStatus event handling status
-   */
-  void DispatchEvent(nsGUIEvent *aEvent,
-      nsView* aViewTarget, nsEventStatus* aStatus);
-
-  /**
-   * Given a parent view, insert another view as its child.
-   * aSibling and aAbove control the "document order" for the insertion.
-   * If aSibling is null, the view is inserted at the end of the document order
-   * if aAfter is true, otherwise it is inserted at the beginning.
-   * If aSibling is non-null, then if aAfter is true, the view is inserted
-   * after the sibling in document order (appearing above the sibling unless
-   * overriden by z-order).
-   * If it is false, the view is inserted before the sibling.
-   * The view manager generates the appopriate dirty regions.
-   * @param aParent parent view
-   * @param aChild child view
-   * @param aSibling sibling view
-   * @param aAfter after or before in the document order
-   */
-  void InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling,
-                   bool aAfter);
-
-  void InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex);
-
-  /**
-   * Remove a specific child view from its parent. This will NOT remove its placeholder
-   * if there is one.
-   * The view manager generates the appropriate dirty regions.
-   * @param aParent parent view
-   * @param aChild child view
-   */
-  void RemoveChild(nsView *aChild);
-
-  /**
-   * Move a view to the specified position, provided in parent coordinates.
-   * The new position is the (0, 0) origin for the view's coordinate system.
-   * The view's bounds may extend above or to the left of this point.
-   * The view manager generates the appropriate dirty regions.
-   * @param aView view to move
-   * @param aX x value for new view position
-   * @param aY y value for new view position
-   */
-  void MoveViewTo(nsView *aView, nscoord aX, nscoord aY);
-
-  /**
-   * Resize a view. In addition to setting the width and height, you can
-   * set the x and y of its bounds relative to its position. Negative x and y
-   * will let the view extend above and to the left of the (0,0) point in its
-   * coordinate system.
-   * The view manager generates the appropriate dirty regions.
-   * @param aView view to move
-   * @param the new bounds relative to the current position
-   * @param RepaintExposedAreaOnly
-   *     if true Repaint only the expanded or contracted region,
-   *     if false Repaint the union of the old and new rectangles.
-   */
-  void ResizeView(nsView *aView, const nsRect &aRect,
-                  bool aRepaintExposedAreaOnly = false);
-
-  /**
-   * Set the visibility of a view. Hidden views have the effect of hiding
-   * their descendants as well. This does not affect painting, so layout
-   * is responsible for ensuring that content in hidden views is not
-   * painted nor handling events. It does affect the visibility of widgets;
-   * if a view is hidden, descendant views with widgets have their widgets
-   * hidden.
-   * The view manager generates the appropriate dirty regions.
-   * @param aView view to change visibility state of
-   * @param visible new visibility state
-   */
-  void SetViewVisibility(nsView *aView, nsViewVisibility aVisible);
-
-  /**
-   * Set the z-index of a view. Positive z-indices mean that a view
-   * is above its parent in z-order. Negative z-indices mean that a
-   * view is below its parent.
-   * The view manager generates the appropriate dirty regions.
-   * @param aAutoZIndex indicate that the z-index of a view is "auto". An "auto" z-index
-   * means that the view does not define a new stacking context,
-   * which means that the z-indicies of the view's children are
-   * relative to the view's siblings.
-   * @param aView view to change z depth of
-   * @param aZindex explicit z depth
-   * @param aTopMost used when this view is z-index:auto to compare against 
-   *        other z-index:auto views.
-   *        true if the view should be topmost when compared with 
-   *        other z-index:auto views.
-   */
-  void SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZindex, bool aTopMost = false);
-
-  /**
-   * Set whether the view "floats" above all other views,
-   * which tells the compositor not to consider higher views in
-   * the view hierarchy that would geometrically intersect with
-   * this view. This is a hack, but it fixes some problems with
-   * views that need to be drawn in front of all other views.
-   */
-  void SetViewFloating(nsView *aView, bool aFloatingView);
-
-  /**
-   * Set the presshell associated with this manager
-   * @param aPresShell - new presshell
-   */
-  void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; }
-
-  /**
-   * Get the pres shell associated with this manager
-   */
-  nsIPresShell* GetPresShell() { return mPresShell; }
-
-  /**
-   * Get the device context associated with this manager
-   * @result device context
-   */
-  void GetDeviceContext(nsDeviceContext *&aContext);
-
-  /**
-   * A stack class for disallowing changes that would enter painting. For
-   * example, popup widgets shouldn't be resized during reflow, since doing so
-   * might cause synchronous painting inside reflow which is forbidden.
-   * While refresh is disabled, widget geometry changes are deferred and will
-   * be handled later, either from the refresh driver or from an NS_WILL_PAINT
-   * event.
-   * We don't want to defer widget geometry changes all the time. Resizing a
-   * popup from script doesn't need to be deferred, for example, especially
-   * since popup widget geometry is observable from script and expected to
-   * update synchronously.
-   */
-  class NS_STACK_CLASS AutoDisableRefresh {
-  public:
-    AutoDisableRefresh(nsViewManager* aVM) {
-      if (aVM) {
-        mRootVM = aVM->IncrementDisableRefreshCount();
-      }
-    }
-    ~AutoDisableRefresh() {
-      if (mRootVM) {
-        mRootVM->DecrementDisableRefreshCount();
-      }
-    }
-  private:
-    AutoDisableRefresh(const AutoDisableRefresh& aOther);
-    const AutoDisableRefresh& operator=(const AutoDisableRefresh& aOther);
-
-    nsRefPtr<nsViewManager> mRootVM;
-  };
-
-private:
-  friend class AutoDisableRefresh;
-
-  nsViewManager* IncrementDisableRefreshCount();
-  void DecrementDisableRefreshCount();
-
-public:
-  /**
-   * Retrieve the widget at the root of the nearest enclosing
-   * view manager whose root view has a widget.
-   */
-  void GetRootWidget(nsIWidget **aWidget);
-
-  /**
-   * Indicate whether the viewmanager is currently painting
-   *
-   * @param aPainting true if the viewmanager is painting
-   *                  false otherwise
-   */
-  void IsPainting(bool& aIsPainting);
-
-  /**
-   * Retrieve the time of the last user event. User events
-   * include mouse and keyboard events. The viewmanager
-   * saves the time of the last user event.
-   *
-   * @param aTime Last user event time in microseconds
-   */
-  void GetLastUserEventTime(uint32_t& aTime);
-
-  /**
-   * Find the nearest display root view for the view aView. This is the view for
-   * the nearest enclosing popup or the root view for the root document.
-   */
-  static nsView* GetDisplayRootFor(nsView* aView);
-
-  /**
-   * Flush the accumulated dirty region to the widget and update widget
-   * geometry.
-   */
-  void ProcessPendingUpdates();
-
-  /**
-   * Just update widget geometry without flushing the dirty region
-   */
-  void UpdateWidgetGeometry();
-
-  uint32_t AppUnitsPerDevPixel() const
-  {
-    return mContext->AppUnitsPerDevPixel();
-  }
-
-private:
-  static uint32_t gLastUserEventTime;
-
-  /* Update the cached RootViewManager pointer on this view manager. */
-  void InvalidateHierarchy();
-  void FlushPendingInvalidates();
-
-  void ProcessPendingUpdatesForView(nsView *aView,
-                                    bool aFlushDirtyRegion = true);
-  void FlushDirtyRegionToWidget(nsView* aView);
-  /**
-   * Call WillPaint() on all view observers under this vm root.
-   */
-  void CallWillPaintOnObservers(bool aWillSendDidPaint);
-  void ReparentChildWidgets(nsView* aView, nsIWidget *aNewWidget);
-  void ReparentWidgets(nsView* aView, nsView *aParent);
-  void InvalidateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedRegion);
-
-  void InvalidateViews(nsView *aView);
-
-  // aView is the view for aWidget and aRegion is relative to aWidget.
-  void Refresh(nsView *aView, const nsIntRegion& aRegion, bool aWillSendDidPaint);
-
-  void InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut);
-  void InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut,
-                                          nscoord aY1, nscoord aY2, bool aInCutOut);
-
-  // Utilities
-
-  bool IsViewInserted(nsView *aView);
-
-  /**
-   * Intersects aRect with aView's bounds and then transforms it from aView's
-   * coordinate system to the coordinate system of the widget attached to
-   * aView.
-   */
-  nsIntRect ViewToWidget(nsView *aView, const nsRect &aRect) const;
-
-  void DoSetWindowDimensions(nscoord aWidth, nscoord aHeight);
-
-  bool IsPainting() const {
-    return RootViewManager()->mPainting;
-  }
-
-  void SetPainting(bool aPainting) {
-    RootViewManager()->mPainting = aPainting;
-  }
-
-  void InvalidateView(nsView *aView, const nsRect &aRect);
-
-  nsViewManager* RootViewManager() const { return mRootViewManager; }
-  bool IsRootVM() const { return this == RootViewManager(); }
-
-  // Whether synchronous painting is allowed at the moment. For example,
-  // widget geometry changes can cause synchronous painting, so they need to
-  // be deferred while refresh is disabled.
-  bool IsPaintingAllowed() { return RootViewManager()->mRefreshDisableCount == 0; }
-
-  void WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint);
-  bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion,
-                   uint32_t aFlags);
-  void DidPaintWindow();
-
-  // Call this when you need to let the viewmanager know that it now has
-  // pending updates.
-  void PostPendingUpdate();
-
-  nsRefPtr<nsDeviceContext> mContext;
-  nsIPresShell   *mPresShell;
-
-  // The size for a resize that we delayed until the root view becomes
-  // visible again.
-  nsSize            mDelayedResize;
-
-  nsView           *mRootView;
-  // mRootViewManager is a strong ref unless it equals |this|.  It's
-  // never null (if we have no ancestors, it will be |this|).
-  nsViewManager   *mRootViewManager;
-
-  // The following members should not be accessed directly except by
-  // the root view manager.  Some have accessor functions to enforce
-  // this, as noted.
-
-  int32_t           mRefreshDisableCount;
-  // Use IsPainting() and SetPainting() to access mPainting.
-  bool              mPainting;
-  bool              mRecursiveRefreshPending;
-  bool              mHasPendingWidgetGeometryChanges;
-  bool              mInScroll;
-
-  //from here to public should be static and locked... MMP
-  static int32_t           mVMCount;        //number of viewmanagers
-
-  //list of view managers
-  static nsVoidArray       *gViewManagers;
-};
-
-/**
-   Invalidation model:
-
-   1) Callers call into the view manager and ask it to invalidate a view.
-
-   2) The view manager finds the "right" widget for the view, henceforth called
-      the root widget.
-
-   3) The view manager traverses descendants of the root widget and for each
-      one that needs invalidation stores the rect to invalidate on the widget's
-      view (batching).
-
-   4) The dirty region is flushed to the right widget when
-      ProcessPendingUpdates is called from the RefreshDriver.
-
-   It's important to note that widgets associated to views outside this view
-   manager can end up being invalidated during step 3.  Therefore, the end of a
-   view update batch really needs to traverse the entire view tree, to ensure
-   that those invalidates happen.
-
-   To cope with this, invalidation processing and should only happen on the
-   root viewmanager.
-*/
-
-#endif  // nsViewManager_h___
new file mode 100644
--- /dev/null
+++ b/view/public/nsViewsCID.h
@@ -0,0 +1,17 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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 nsViewsCID_h__
+#define nsViewsCID_h__
+
+#include "nsISupports.h"
+#include "nsIFactory.h"
+#include "nsIComponentManager.h"
+
+#define NS_VIEW_MANAGER_CID \
+{ 0xc95f1831, 0xc376, 0x11d1, \
+    {0xb7, 0x21, 0x0, 0x60, 0x8, 0x91, 0xd8, 0xc9}}
+
+#endif // nsViewsCID_h__
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -58,17 +58,17 @@ nsView::~nsView()
       RemoveChild(child);
     }
   }
 
   if (mViewManager)
   {
     DropMouseGrabbing();
   
-    nsView *rootView = mViewManager->GetRootView();
+    nsView *rootView = mViewManager->GetRootViewImpl();
     
     if (rootView)
     {
       // Root views can have parents!
       if (mParent)
       {
         mViewManager->RemoveChild(this);
       }
@@ -220,17 +220,17 @@ nsIntRect nsView::CalcWidgetBounds(nsWin
 
   return newBounds;
 }
 
 void nsView::DoResetWidgetBounds(bool aMoveOnly,
                                  bool aInvalidateChangedSize) {
   // The geometry of a root view's widget is controlled externally,
   // NOT by sizing or positioning the view
-  if (mViewManager->GetRootView() == this) {
+  if (mViewManager->GetRootViewImpl() == this) {
     return;
   }
   
   nsIntRect curBounds;
   mWindow->GetClientBounds(curBounds);
 
   nsWindowType type;
   mWindow->GetWindowType(type);
@@ -342,17 +342,17 @@ void nsView::SetFloating(bool aFloatingV
 	if (aFloatingView)
 		mVFlags |= NS_VIEW_FLAG_FLOATING;
 	else
 		mVFlags &= ~NS_VIEW_FLAG_FLOATING;
 }
 
 void nsView::InvalidateHierarchy(nsViewManager *aViewManagerParent)
 {
-  if (mViewManager->GetRootView() == this)
+  if (mViewManager->GetRootViewImpl() == this)
     mViewManager->InvalidateHierarchy();
 
   for (nsView *child = mFirstChild; child; child = child->GetNextSibling())
     child->InvalidateHierarchy(aViewManagerParent);
 }
 
 void nsView::InsertChild(nsView *aChild, nsView *aSibling)
 {
@@ -374,18 +374,18 @@ void nsView::InsertChild(nsView *aChild,
       aChild->SetNextSibling(mFirstChild);
       mFirstChild = aChild;
     }
     aChild->SetParent(this);
 
     // If we just inserted a root view, then update the RootViewManager
     // on all view managers in the new subtree.
 
-    nsViewManager *vm = aChild->GetViewManager();
-    if (vm->GetRootView() == aChild)
+    nsViewManager *vm = aChild->GetViewManagerInternal();
+    if (vm->GetRootViewImpl() == aChild)
     {
       aChild->InvalidateHierarchy(nullptr); // don't care about releasing grabs
     }
   }
 }
 
 void nsView::RemoveChild(nsView *child)
 {
@@ -410,20 +410,20 @@ void nsView::RemoveChild(nsView *child)
       prevKid = kid;
 	    kid = kid->GetNextSibling();
     }
     NS_ASSERTION(found, "tried to remove non child");
 
     // If we just removed a root view, then update the RootViewManager
     // on all view managers in the removed subtree.
 
-    nsViewManager *vm = child->GetViewManager();
-    if (vm->GetRootView() == child)
+    nsViewManager *vm = child->GetViewManagerInternal();
+    if (vm->GetRootViewImpl() == child)
     {
-      child->InvalidateHierarchy(GetViewManager());
+      child->InvalidateHierarchy(GetViewManagerInternal());
     }
   }
 }
 
 // Native widgets ultimately just can't deal with the awesome power of
 // CSS2 z-index. However, we set the z-index on the widget anyway
 // because in many simple common cases the widgets do end up in the
 // right order. We set each widget's z-index to the z-index of the
@@ -731,34 +731,34 @@ void nsView::List(FILE* out, int32_t aIn
   }
   for (i = aIndent; --i >= 0; ) fputs("  ", out);
   fputs(">\n", out);
 }
 #endif // DEBUG
 
 nsPoint nsView::GetOffsetTo(const nsView* aOther) const
 {
-  return GetOffsetTo(aOther, GetViewManager()->AppUnitsPerDevPixel());
+  return GetOffsetTo(aOther, GetViewManagerInternal()->AppUnitsPerDevPixel());
 }
 
 nsPoint nsView::GetOffsetTo(const nsView* aOther, const int32_t aAPD) const
 {
   NS_ABORT_IF_FALSE(GetParent() || !aOther || aOther->GetParent() ||
                     this == aOther, "caller of (outer) GetOffsetTo must not "
                     "pass unrelated views");
   // We accumulate the final result in offset
   nsPoint offset(0, 0);
   // The offset currently accumulated at the current APD
   nsPoint docOffset(0, 0);
   const nsView* v = this;
-  nsViewManager* currVM = v->GetViewManager();
+  nsViewManager* currVM = v->GetViewManagerInternal();
   int32_t currAPD = currVM->AppUnitsPerDevPixel();
   const nsView* root = nullptr;
   for ( ; v != aOther && v; root = v, v = v->GetParent()) {
-    nsViewManager* newVM = v->GetViewManager();
+    nsViewManager* newVM = v->GetViewManagerInternal();
     if (newVM != currVM) {
       int32_t newAPD = newVM->AppUnitsPerDevPixel();
       if (newAPD != currAPD) {
         offset += docOffset.ConvertAppUnits(currAPD, aAPD);
         docOffset.x = docOffset.y = 0;
         currAPD = newAPD;
       }
       currVM = newVM;
@@ -794,41 +794,41 @@ nsPoint nsView::GetOffsetToWidget(nsIWid
   // so that we don't have to convert the APD of the relatively small
   // ViewToWidgetOffset by itself with a potentially large relative rounding
   // error.
   pt = -widgetView->GetOffsetTo(this);
   // Add in the offset to the widget.
   pt += widgetView->ViewToWidgetOffset();
 
   // Convert to our appunits.
-  int32_t widgetAPD = widgetView->GetViewManager()->AppUnitsPerDevPixel();
-  int32_t ourAPD = GetViewManager()->AppUnitsPerDevPixel();
+  int32_t widgetAPD = widgetView->GetViewManagerInternal()->AppUnitsPerDevPixel();
+  int32_t ourAPD = GetViewManagerInternal()->AppUnitsPerDevPixel();
   pt = pt.ConvertAppUnits(widgetAPD, ourAPD);
   return pt;
 }
 
 nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset) const
 {
-  return GetNearestWidget(aOffset, GetViewManager()->AppUnitsPerDevPixel());
+  return GetNearestWidget(aOffset, GetViewManagerInternal()->AppUnitsPerDevPixel());
 }
 
 nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const
 {
   // aOffset is based on the view's position, which ignores any chrome on
   // attached parent widgets.
 
   // We accumulate the final result in pt
   nsPoint pt(0, 0);
   // The offset currently accumulated at the current APD
   nsPoint docPt(0,0);
   const nsView* v = this;
-  nsViewManager* currVM = v->GetViewManager();
+  nsViewManager* currVM = v->GetViewManagerInternal();
   int32_t currAPD = currVM->AppUnitsPerDevPixel();
   for ( ; v && !v->HasWidget(); v = v->GetParent()) {
-    nsViewManager* newVM = v->GetViewManager();
+    nsViewManager* newVM = v->GetViewManagerInternal();
     if (newVM != currVM) {
       int32_t newAPD = newVM->AppUnitsPerDevPixel();
       if (newAPD != currAPD) {
         pt += docPt.ConvertAppUnits(currAPD, aAPD);
         docPt.x = docPt.y = 0;
         currAPD = newAPD;
       }
       currVM = newVM;
@@ -851,39 +851,39 @@ nsIWidget* nsView::GetNearestWidget(nsPo
     *aOffset = pt;
   }
   return v->GetWidget();
 }
 
 bool nsView::IsRoot() const
 {
   NS_ASSERTION(mViewManager != nullptr," View manager is null in nsView::IsRoot()");
-  return mViewManager->GetRootView() == this;
+  return mViewManager->GetRootViewImpl() == this;
 }
 
 nsRect
 nsView::GetBoundsInParentUnits() const
 {
   nsView* parent = GetParent();
-  nsViewManager* VM = GetViewManager();
-  if (this != VM->GetRootView() || !parent) {
+  nsViewManager* VM = GetViewManagerInternal();
+  if (this != VM->GetRootViewImpl() || !parent) {
     return mDimBounds;
   }
   int32_t ourAPD = VM->AppUnitsPerDevPixel();
-  int32_t parentAPD = parent->GetViewManager()->AppUnitsPerDevPixel();
+  int32_t parentAPD = parent->GetViewManagerInternal()->AppUnitsPerDevPixel();
   return mDimBounds.ConvertAppUnitsRoundOut(ourAPD, parentAPD);
 }
 
 nsPoint
 nsView::ConvertFromParentCoords(nsPoint aPt) const
 {
   const nsView* parent = GetParent();
   if (parent) {
-    aPt = aPt.ConvertAppUnits(parent->GetViewManager()->AppUnitsPerDevPixel(),
-                              GetViewManager()->AppUnitsPerDevPixel());
+    aPt = aPt.ConvertAppUnits(parent->GetViewManagerInternal()->AppUnitsPerDevPixel(),
+                              GetViewManagerInternal()->AppUnitsPerDevPixel());
   }
   aPt -= GetPosition();
   return aPt;
 }
 
 static bool
 IsPopupWidget(nsIWidget* aWidget)
 {
@@ -948,41 +948,41 @@ nsView::RequestWindowClose(nsIWidget* aW
   }
 
   return false;
 }
 
 void
 nsView::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint)
 {
-  nsRefPtr<nsViewManager> vm = mViewManager;
+  nsCOMPtr<nsViewManager> vm = mViewManager;
   vm->WillPaintWindow(aWidget, aWillSendDidPaint);
 }
 
 bool
 nsView::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, uint32_t aFlags)
 {
   NS_ASSERTION(this == nsView::GetViewFor(aWidget), "wrong view for widget?");
 
   mInAlternatePaint = aFlags & PAINT_IS_ALTERNATE;
-  nsRefPtr<nsViewManager> vm = mViewManager;
+  nsCOMPtr<nsViewManager> vm = mViewManager;
   bool result = vm->PaintWindow(aWidget, aRegion, aFlags);
   // PaintWindow can destroy this via WillPaintWindow notification, so we have
   // to re-get the view from the widget.
   nsView* view = nsView::GetViewFor(aWidget);
   if (view) {
     view->mInAlternatePaint = false;
   }
   return result;
 }
 
 void
 nsView::DidPaintWindow()
 {
-  nsRefPtr<nsViewManager> vm = mViewManager;
+  nsCOMPtr<nsViewManager> vm = mViewManager;
   vm->DidPaintWindow();
 }
 
 void
 nsView::RequestRepaint()
 {
   nsIPresShell* presShell = mViewManager->GetPresShell();
   if (presShell) {
@@ -1001,14 +1001,14 @@ nsView::HandleEvent(nsGUIEvent* aEvent, 
     nsIWidgetListener* listener = aEvent->widget->GetAttachedWidgetListener();
     view = listener ? listener->GetView() : nullptr;
   }
   else {
     view = GetViewFor(aEvent->widget);
   }
 
   if (view) {
-    nsRefPtr<nsViewManager> vm = view->GetViewManager();
+    nsCOMPtr<nsIViewManager> vm = view->GetViewManager();
     vm->DispatchEvent(aEvent, view, &result);
   }
 
   return result;
 }
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -41,16 +41,32 @@
    We do NOT assume anything about the relative z-ordering of sibling widgets. Even though
    we ask for a specific z-order, we don't assume that widget z-ordering actually works.
 */
 
 #define NSCOORD_NONE      INT32_MIN
 
 #undef DEBUG_MOUSE_LOCATION
 
+static bool
+IsRefreshDriverPaintingEnabled()
+{
+  static bool sRefreshDriverPaintingEnabled;
+  static bool sRefreshDriverPaintingPrefCached = false;
+
+  if (!sRefreshDriverPaintingPrefCached) {
+    sRefreshDriverPaintingPrefCached = true;
+    mozilla::Preferences::AddBoolVarCache(&sRefreshDriverPaintingEnabled,
+                                          "viewmanager.refresh-driver-painting.enabled",
+                                          true);
+  }
+
+  return sRefreshDriverPaintingEnabled;
+}
+
 int32_t nsViewManager::mVMCount = 0;
 
 // Weakly held references to all of the view managers
 nsVoidArray* nsViewManager::gViewManagers = nullptr;
 uint32_t nsViewManager::gLastUserEventTime = 0;
 
 nsViewManager::nsViewManager()
   : mDelayedResize(NSCOORD_NONE, NSCOORD_NONE)
@@ -101,51 +117,57 @@ nsViewManager::~nsViewManager()
     NS_ASSERTION(gViewManagers != nullptr, "About to delete null gViewManagers");
     delete gViewManagers;
     gViewManagers = nullptr;
   }
 
   mPresShell = nullptr;
 }
 
+NS_IMPL_ISUPPORTS1(nsViewManager, nsIViewManager)
+
 // We don't hold a reference to the presentation context because it
 // holds a reference to us.
-nsresult
-nsViewManager::Init(nsDeviceContext* aContext)
+NS_IMETHODIMP nsViewManager::Init(nsDeviceContext* aContext)
 {
   NS_PRECONDITION(nullptr != aContext, "null ptr");
 
   if (nullptr == aContext) {
     return NS_ERROR_NULL_POINTER;
   }
   if (nullptr != mContext) {
     return NS_ERROR_ALREADY_INITIALIZED;
   }
   mContext = aContext;
 
   return NS_OK;
 }
 
-nsView*
+NS_IMETHODIMP_(nsView *)
 nsViewManager::CreateView(const nsRect& aBounds,
                           const nsView* aParent,
                           nsViewVisibility aVisibilityFlag)
 {
   nsView *v = new nsView(this, aVisibilityFlag);
   if (v) {
     v->SetParent(const_cast<nsView*>(aParent));
     v->SetPosition(aBounds.x, aBounds.y);
     nsRect dim(0, 0, aBounds.width, aBounds.height);
     v->SetDimensions(dim, false);
   }
   return v;
 }
 
-void
-nsViewManager::SetRootView(nsView *aView)
+NS_IMETHODIMP_(nsView*)
+nsViewManager::GetRootView()
+{
+  return mRootView;
+}
+
+NS_IMETHODIMP nsViewManager::SetRootView(nsView *aView)
 {
   NS_PRECONDITION(!aView || aView->GetViewManager() == this,
                   "Unexpected viewmanager on root view");
   
   // Do NOT destroy the current root view. It's the caller's responsibility
   // to destroy it
   mRootView = aView;
 
@@ -157,53 +179,54 @@ nsViewManager::SetRootView(nsView *aView
       parent->InsertChild(mRootView, nullptr);
     } else {
       InvalidateHierarchy();
     }
 
     mRootView->SetZIndex(false, 0, false);
   }
   // Else don't touch mRootViewManager
+
+  return NS_OK;
 }
 
-void
-nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight)
+NS_IMETHODIMP nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight)
 {
   if (nullptr != mRootView) {
     if (mDelayedResize == nsSize(NSCOORD_NONE, NSCOORD_NONE)) {
       nsRect dim = mRootView->GetDimensions();
       *aWidth = dim.width;
       *aHeight = dim.height;
     } else {
       *aWidth = mDelayedResize.width;
       *aHeight = mDelayedResize.height;
     }
   }
   else
     {
       *aWidth = 0;
       *aHeight = 0;
     }
+  return NS_OK;
 }
 
 void nsViewManager::DoSetWindowDimensions(nscoord aWidth, nscoord aHeight)
 {
   nsRect oldDim = mRootView->GetDimensions();
   nsRect newDim(0, 0, aWidth, aHeight);
   // We care about resizes even when one dimension is already zero.
   if (!oldDim.IsEqualEdges(newDim)) {
     // Don't resize the widget. It is already being set elsewhere.
     mRootView->SetDimensions(newDim, true, false);
     if (mPresShell)
       mPresShell->ResizeReflow(aWidth, aHeight);
   }
 }
 
-void
-nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight)
+NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight)
 {
   if (mRootView) {
     if (mRootView->IsEffectivelyVisible() && mPresShell && mPresShell->IsVisible()) {
       if (mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
           mDelayedResize != nsSize(aWidth, aHeight)) {
         // We have a delayed resize; that now obsolete size may already have
         // been flushed to the PresContext so we need to update the PresContext
         // with the new size because if the new size is exactly the same as the
@@ -216,49 +239,51 @@ nsViewManager::SetWindowDimensions(nscoo
       DoSetWindowDimensions(aWidth, aHeight);
     } else {
       mDelayedResize.SizeTo(aWidth, aHeight);
       if (mPresShell && mPresShell->GetDocument()) {
         mPresShell->GetDocument()->SetNeedStyleFlush();
       }
     }
   }
+
+  return NS_OK;
 }
 
-void
-nsViewManager::FlushDelayedResize(bool aDoReflow)
+NS_IMETHODIMP nsViewManager::FlushDelayedResize(bool aDoReflow)
 {
   if (mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE)) {
     if (aDoReflow) {
       DoSetWindowDimensions(mDelayedResize.width, mDelayedResize.height);
       mDelayedResize.SizeTo(NSCOORD_NONE, NSCOORD_NONE);
     } else if (mPresShell) {
       nsPresContext* presContext = mPresShell->GetPresContext();
       if (presContext) {
         presContext->SetVisibleArea(nsRect(nsPoint(0, 0), mDelayedResize));
       }
     }
   }
+  return NS_OK;
 }
 
 // Convert aIn from being relative to and in appunits of aFromView, to being
 // relative to and in appunits of aToView.
 static nsRegion ConvertRegionBetweenViews(const nsRegion& aIn,
                                           nsView* aFromView,
                                           nsView* aToView)
 {
   nsRegion out = aIn;
   out.MoveBy(aFromView->GetOffsetTo(aToView));
   out = out.ConvertAppUnitsRoundOut(
-    aFromView->GetViewManager()->AppUnitsPerDevPixel(),
-    aToView->GetViewManager()->AppUnitsPerDevPixel());
+    aFromView->GetViewManagerInternal()->AppUnitsPerDevPixel(),
+    aToView->GetViewManagerInternal()->AppUnitsPerDevPixel());
   return out;
 }
 
-nsView* nsViewManager::GetDisplayRootFor(nsView* aView)
+nsView* nsIViewManager::GetDisplayRootFor(nsView* aView)
 {
   nsView *displayRoot = aView;
   for (;;) {
     nsView *displayParent = displayRoot->GetParent();
     if (!displayParent)
       return displayRoot;
 
     if (displayRoot->GetFloating() && !displayParent->GetFloating())
@@ -327,16 +352,17 @@ void nsViewManager::Refresh(nsView *aVie
     NS_ASSERTION(GetDisplayRootFor(aView) == aView,
                  "Widgets that we paint must all be display roots");
 
     if (mPresShell) {
 #ifdef DEBUG_INVALIDATIONS
       printf("--COMPOSITE-- %p\n", mPresShell);
 #endif
       mPresShell->Paint(aView, damageRegion,
+                        (IsRefreshDriverPaintingEnabled() ? 0 : nsIPresShell::PAINT_LAYERS) |
                         nsIPresShell::PAINT_COMPOSITE |
                         (aWillSendDidPaint ? nsIPresShell::PAINT_WILL_SEND_DID_PAINT : 0));
 #ifdef DEBUG_INVALIDATIONS
       printf("--ENDCOMPOSITE--\n");
 #endif
       mozilla::StartupTimeline::RecordOnce(mozilla::StartupTimeline::FIRST_PAINT);
     }
 
@@ -367,48 +393,50 @@ void nsViewManager::ProcessPendingUpdate
   for (nsView* childView = aView->GetFirstChild(); childView;
        childView = childView->GetNextSibling()) {
     ProcessPendingUpdatesForView(childView, aFlushDirtyRegion);
   }
 
   // Push out updates after we've processed the children; ensures that
   // damage is applied based on the final widget geometry
   if (aFlushDirtyRegion) {
-    nsIWidget *widget = aView->GetWidget();
-    if (widget && widget->NeedsPaint()) {
-      // If an ancestor widget was hidden and then shown, we could
-      // have a delayed resize to handle.
-      for (nsViewManager *vm = this; vm;
-           vm = vm->mRootView->GetParent()
-                  ? vm->mRootView->GetParent()->GetViewManager()
-                  : nullptr) {
-        if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
-            vm->mRootView->IsEffectivelyVisible() &&
-            mPresShell && mPresShell->IsVisible()) {
-          vm->FlushDelayedResize(true);
-          vm->InvalidateView(vm->mRootView);
+    if (IsRefreshDriverPaintingEnabled()) {
+      nsIWidget *widget = aView->GetWidget();
+      if (widget && widget->NeedsPaint()) {
+        // If an ancestor widget was hidden and then shown, we could
+        // have a delayed resize to handle.
+        for (nsViewManager *vm = this; vm;
+             vm = vm->mRootView->GetParent()
+                    ? vm->mRootView->GetParent()->GetViewManagerInternal()
+                    : nullptr) {
+          if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
+              vm->mRootView->IsEffectivelyVisible() &&
+              mPresShell && mPresShell->IsVisible()) {
+            vm->FlushDelayedResize(true);
+            vm->InvalidateView(vm->mRootView);
+          }
         }
-      }
 
-      NS_ASSERTION(aView->HasWidget(), "Must have a widget!");
+        NS_ASSERTION(aView->HasWidget(), "Must have a widget!");
 
-      SetPainting(true);
+        SetPainting(true);
 #ifdef DEBUG_INVALIDATIONS
-      printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget);
+        printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget);
 #endif
-      nsAutoScriptBlocker scriptBlocker;
-      NS_ASSERTION(aView->HasWidget(), "Must have a widget!");
-      mPresShell->Paint(aView, nsRegion(),
-                        nsIPresShell::PAINT_LAYERS |
-                        nsIPresShell::PAINT_WILL_SEND_DID_PAINT);
+        nsAutoScriptBlocker scriptBlocker;
+        NS_ASSERTION(aView->HasWidget(), "Must have a widget!");
+        mPresShell->Paint(aView, nsRegion(),
+                          nsIPresShell::PAINT_LAYERS |
+                          nsIPresShell::PAINT_WILL_SEND_DID_PAINT);
 #ifdef DEBUG_INVALIDATIONS
-      printf("---- PAINT END ----\n");
+        printf("---- PAINT END ----\n");
 #endif
-      aView->SetForcedRepaint(false);
-      SetPainting(false);
+        aView->SetForcedRepaint(false);
+        SetPainting(false);
+      }
     }
     FlushDirtyRegionToWidget(aView);
   }
 }
 
 void nsViewManager::FlushDirtyRegionToWidget(nsView* aView)
 {
   if (!aView->HasNonEmptyDirtyRegion())
@@ -417,26 +445,25 @@ void nsViewManager::FlushDirtyRegionToWi
   nsRegion* dirtyRegion = aView->GetDirtyRegion();
   nsView* nearestViewWithWidget = aView;
   while (!nearestViewWithWidget->HasWidget() &&
          nearestViewWithWidget->GetParent()) {
     nearestViewWithWidget = nearestViewWithWidget->GetParent();
   }
   nsRegion r =
     ConvertRegionBetweenViews(*dirtyRegion, aView, nearestViewWithWidget);
-  nsViewManager* widgetVM = nearestViewWithWidget->GetViewManager();
+  nsViewManager* widgetVM = nearestViewWithWidget->GetViewManagerInternal();
   widgetVM->InvalidateWidgetArea(nearestViewWithWidget, r);
   dirtyRegion->SetEmpty();
 }
 
-void
-nsViewManager::InvalidateView(nsView *aView)
+NS_IMETHODIMP nsViewManager::InvalidateView(nsView *aView)
 {
   // Mark the entire view as damaged
-  InvalidateView(aView, aView->GetDimensions());
+  return InvalidateView(aView, aView->GetDimensions());
 }
 
 static void
 AddDirtyRegion(nsView *aView, const nsRegion &aDamagedRegion)
 {
   nsRegion* dirtyRegion = aView->GetDirtyRegion();
   if (!dirtyRegion)
     return;
@@ -539,89 +566,112 @@ nsViewManager::InvalidateWidgetArea(nsVi
 static bool
 ShouldIgnoreInvalidation(nsViewManager* aVM)
 {
   while (aVM) {
     nsIPresShell* shell = aVM->GetPresShell();
     if (!shell || shell->ShouldIgnoreInvalidation()) {
       return true;
     }
-    nsView* view = aVM->GetRootView()->GetParent();
-    aVM = view ? view->GetViewManager() : nullptr;
+    nsView* view = aVM->GetRootViewImpl()->GetParent();
+    aVM = view ? view->GetViewManagerInternal() : nullptr;
   }
   return false;
 }
 
-void
-nsViewManager::InvalidateView(nsView *aView, const nsRect &aRect)
+nsresult nsViewManager::InvalidateView(nsView *aView, const nsRect &aRect)
 {
   // If painting is suppressed in the presshell or an ancestor drop all
   // invalidates, it will invalidate everything when it unsuppresses.
   if (ShouldIgnoreInvalidation(this)) {
-    return;
+    return NS_OK;
   }
 
-  InvalidateViewNoSuppression(aView, aRect);
+  return InvalidateViewNoSuppression(aView, aRect);
 }
 
-void
-nsViewManager::InvalidateViewNoSuppression(nsView *aView,
-                                           const nsRect &aRect)
+NS_IMETHODIMP nsViewManager::InvalidateViewNoSuppression(nsView *aView,
+                                                         const nsRect &aRect)
 {
   NS_PRECONDITION(nullptr != aView, "null view");
 
   NS_ASSERTION(aView->GetViewManager() == this,
                "InvalidateViewNoSuppression called on view we don't own");
 
   nsRect damagedRect(aRect);
   if (damagedRect.IsEmpty()) {
-    return;
+    return NS_OK;
   }
 
   nsView* displayRoot = GetDisplayRootFor(aView);
-  nsViewManager* displayRootVM = displayRoot->GetViewManager();
+  nsViewManager* displayRootVM = displayRoot->GetViewManagerInternal();
   // Propagate the update to the displayRoot, since iframes, for example,
   // can overlap each other and be translucent.  So we have to possibly
   // invalidate our rect in each of the widgets we have lying about.
   damagedRect.MoveBy(aView->GetOffsetTo(displayRoot));
   int32_t rootAPD = displayRootVM->AppUnitsPerDevPixel();
   int32_t APD = AppUnitsPerDevPixel();
   damagedRect = damagedRect.ConvertAppUnitsRoundOut(APD, rootAPD);
 
   // accumulate this rectangle in the view's dirty region, so we can
   // process it later.
   AddDirtyRegion(displayRoot, nsRegion(damagedRect));
+
+  return NS_OK;
 }
 
-void
-nsViewManager::InvalidateAllViews()
+NS_IMETHODIMP nsViewManager::InvalidateAllViews()
 {
   if (RootViewManager() != this) {
     return RootViewManager()->InvalidateAllViews();
   }
   
   InvalidateViews(mRootView);
+  return NS_OK;
 }
 
 void nsViewManager::InvalidateViews(nsView *aView)
 {
   // Invalidate this view.
   InvalidateView(aView);
 
   // Invalidate all children as well.
   nsView* childView = aView->GetFirstChild();
   while (nullptr != childView)  {
-    childView->GetViewManager()->InvalidateViews(childView);
+    childView->GetViewManagerInternal()->InvalidateViews(childView);
     childView = childView->GetNextSibling();
   }
 }
 
 void nsViewManager::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint)
 {
-  if (aWidget) {
+  if (!IsRefreshDriverPaintingEnabled() && aWidget && mContext) {
+    // If an ancestor widget was hidden and then shown, we could
+    // have a delayed resize to handle.
+    for (nsViewManager *vm = this; vm;
+         vm = vm->mRootView->GetParent()
+                ? vm->mRootView->GetParent()->GetViewManagerInternal()
+                : nullptr) {
+      if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
+          vm->mRootView->IsEffectivelyVisible() &&
+          mPresShell && mPresShell->IsVisible()) {
+        vm->FlushDelayedResize(true);
+        vm->InvalidateView(vm->mRootView);
+      }
+    }
+
+    // Flush things like reflows by calling WillPaint on observer presShells.
+    nsRefPtr<nsViewManager> rootVM = RootViewManager();
+    rootVM->CallWillPaintOnObservers(aWillSendDidPaint);
+
+    // Flush view widget geometry updates and invalidations.
+    rootVM->ProcessPendingUpdates();
+  }
+
+  if (aWidget && IsRefreshDriverPaintingEnabled()) {
     nsView* view = nsView::GetViewFor(aWidget);
     if (view && view->ForcedRepaint()) {
       ProcessPendingUpdates();
       // Re-get the view pointer here since the ProcessPendingUpdates might have
       // destroyed it during CallWillPaintOnObservers.
       view = nsView::GetViewFor(aWidget);
       if (view) {
         view->SetForcedRepaint(false);
@@ -639,16 +689,20 @@ bool nsViewManager::PaintWindow(nsIWidge
                                 uint32_t aFlags)
  {
   if (!aWidget || !mContext)
     return false;
 
   NS_ASSERTION(IsPaintingAllowed(),
                "shouldn't be receiving paint events while painting is disallowed!");
 
+  if (!(aFlags & nsIWidgetListener::SENT_WILL_PAINT) && !IsRefreshDriverPaintingEnabled()) {
+    WillPaintWindow(aWidget, (aFlags & nsIWidgetListener::WILL_SEND_DID_PAINT));
+  }
+
   // Get the view pointer here since NS_WILL_PAINT might have
   // destroyed it during CallWillPaintOnObservers (bug 378273).
   nsView* view = nsView::GetViewFor(aWidget);
   if (view && !aRegion.IsEmpty()) {
     Refresh(view, aRegion, (aFlags & nsIWidgetListener::WILL_SEND_DID_PAINT));
   }
 
   return true;
@@ -657,18 +711,17 @@ bool nsViewManager::PaintWindow(nsIWidge
 void nsViewManager::DidPaintWindow()
 {
   nsCOMPtr<nsIPresShell> shell = mPresShell;
   if (shell) {
     shell->DidPaintWindow();
   }
 }
 
-void
-nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* aStatus)
+nsresult nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* aStatus)
 {
   SAMPLE_LABEL("event", "nsViewManager::DispatchEvent");
 
   if ((NS_IS_MOUSE_EVENT(aEvent) &&
        // Ignore mouse events that we synthesize.
        static_cast<nsMouseEvent*>(aEvent)->reason == nsMouseEvent::eReal &&
        // Ignore mouse exit and enter (we'll get moves if the user
        // is really moving the mouse) since we get them when we
@@ -709,21 +762,23 @@ nsViewManager::DispatchEvent(nsGUIEvent 
   }
 
   if (nullptr != frame) {
     // Hold a refcount to the presshell. The continued existence of the
     // presshell will delay deletion of this view hierarchy should the event
     // want to cause its destruction in, say, some JavaScript event handler.
     nsCOMPtr<nsIPresShell> shell = view->GetViewManager()->GetPresShell();
     if (shell) {
-      shell->HandleEvent(frame, aEvent, false, aStatus);
+      return shell->HandleEvent(frame, aEvent, false, aStatus);
     }
   }
 
   *aStatus = nsEventStatus_eIgnore;
+
+  return NS_OK;
 }
 
 // Recursively reparent widgets if necessary 
 
 void nsViewManager::ReparentChildWidgets(nsView* aView, nsIWidget *aNewWidget)
 {
   NS_PRECONDITION(aNewWidget, "");
 
@@ -777,19 +832,18 @@ void nsViewManager::ReparentWidgets(nsVi
     if (parentWidget) {
       ReparentChildWidgets(aView, parentWidget);
       return;
     }
     NS_WARNING("Can not find a widget for the parent view");
   }
 }
 
-void
-nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling,
-                           bool aAfter)
+NS_IMETHODIMP nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling,
+                                         bool aAfter)
 {
   NS_PRECONDITION(nullptr != aParent, "null ptr");
   NS_PRECONDITION(nullptr != aChild, "null ptr");
   NS_ASSERTION(aSibling == nullptr || aSibling->GetParent() == aParent,
                "tried to insert view with invalid sibling");
   NS_ASSERTION(!IsViewInserted(aChild), "tried to insert an already-inserted view");
 
   if ((nullptr != aParent) && (nullptr != aChild))
@@ -838,64 +892,65 @@ nsViewManager::InsertChild(nsView *aPare
 
       // if the parent view is marked as "floating", make the newly added view float as well.
       if (aParent->GetFloating())
         aChild->SetFloating(true);
 
       //and mark this area as dirty if the view is visible...
 
       if (nsViewVisibility_kHide != aChild->GetVisibility())
-        aChild->GetViewManager()->InvalidateView(aChild);
+        aChild->GetViewManagerInternal()->InvalidateView(aChild);
     }
+  return NS_OK;
 }
 
-void
-nsViewManager::InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex)
+NS_IMETHODIMP nsViewManager::InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex)
 {
   // no-one really calls this with anything other than aZIndex == 0 on a fresh view
   // XXX this method should simply be eliminated and its callers redirected to the real method
   SetViewZIndex(aChild, false, aZIndex, false);
-  InsertChild(aParent, aChild, nullptr, true);
+  return InsertChild(aParent, aChild, nullptr, true);
 }
 
-void
-nsViewManager::RemoveChild(nsView *aChild)
+NS_IMETHODIMP nsViewManager::RemoveChild(nsView *aChild)
 {
-  NS_ASSERTION(aChild, "aChild must not be null");
+  NS_ENSURE_ARG_POINTER(aChild);
 
   nsView* parent = aChild->GetParent();
 
   if (nullptr != parent) {
     NS_ASSERTION(aChild->GetViewManager() == this ||
                  parent->GetViewManager() == this, "wrong view manager");
-    aChild->GetViewManager()->InvalidateView(aChild);
+    aChild->GetViewManagerInternal()->InvalidateView(aChild);
     parent->RemoveChild(aChild);
   }
+
+  return NS_OK;
 }
 
-void
-nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY)
+NS_IMETHODIMP nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY)
 {
   NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager");
   nsPoint oldPt = aView->GetPosition();
   nsRect oldBounds = aView->GetBoundsInParentUnits();
   aView->SetPosition(aX, aY);
 
   // only do damage control if the view is visible
 
   if ((aX != oldPt.x) || (aY != oldPt.y)) {
     if (aView->GetVisibility() != nsViewVisibility_kHide) {
       nsView* parentView = aView->GetParent();
       if (parentView) {
-        nsViewManager* parentVM = parentView->GetViewManager();
+        nsViewManager* parentVM = parentView->GetViewManagerInternal();
         parentVM->InvalidateView(parentView, oldBounds);
         parentVM->InvalidateView(parentView, aView->GetBoundsInParentUnits());
       }
     }
   }
+  return NS_OK;
 }
 
 void nsViewManager::InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut,
   nscoord aY1, nscoord aY2, bool aInCutOut) {
   nscoord height = aY2 - aY1;
   if (aRect.x < aCutOut.x) {
     nsRect r(aRect.x, aY1, aCutOut.x - aRect.x, height);
     InvalidateView(aView, r);
@@ -919,35 +974,34 @@ void nsViewManager::InvalidateRectDiffer
   if (aCutOut.y < aCutOut.YMost()) {
     InvalidateHorizontalBandDifference(aView, aRect, aCutOut, aCutOut.y, aCutOut.YMost(), true);
   }
   if (aCutOut.YMost() < aRect.YMost()) {
     InvalidateHorizontalBandDifference(aView, aRect, aCutOut, aCutOut.YMost(), aRect.YMost(), false);
   }
 }
 
-void
-nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExposedAreaOnly)
+NS_IMETHODIMP nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExposedAreaOnly)
 {
   NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager");
 
   nsRect oldDimensions = aView->GetDimensions();
   if (!oldDimensions.IsEqualEdges(aRect)) {
     // resize the view.
     // Prevent Invalidation of hidden views 
     if (aView->GetVisibility() == nsViewVisibility_kHide) {
       aView->SetDimensions(aRect, false);
     } else {
       nsView* parentView = aView->GetParent();
       if (!parentView) {
         parentView = aView;
       }
       nsRect oldBounds = aView->GetBoundsInParentUnits();
       aView->SetDimensions(aRect, true);
-      nsViewManager* parentVM = parentView->GetViewManager();
+      nsViewManager* parentVM = parentView->GetViewManagerInternal();
       if (!aRepaintExposedAreaOnly) {
         // Invalidate the union of the old and new size
         InvalidateView(aView, aRect);
         parentVM->InvalidateView(parentView, oldBounds);
       } else {
         InvalidateRectDifference(aView, aRect, oldDimensions);
         nsRect newBounds = aView->GetBoundsInParentUnits();
         parentVM->InvalidateRectDifference(parentView, oldBounds, newBounds);
@@ -955,104 +1009,110 @@ nsViewManager::ResizeView(nsView *aView,
     }
   }
 
   // Note that if layout resizes the view and the view has a custom clip
   // region set, then we expect layout to update the clip region too. Thus
   // in the case where mClipRect has been optimized away to just be a null
   // pointer, and this resize is implicitly changing the clip rect, it's OK
   // because layout will change it back again if necessary.
+
+  return NS_OK;
 }
 
-void
-nsViewManager::SetViewFloating(nsView *aView, bool aFloating)
+NS_IMETHODIMP nsViewManager::SetViewFloating(nsView *aView, bool aFloating)
 {
   NS_ASSERTION(!(nullptr == aView), "no view");
 
   aView->SetFloating(aFloating);
+
+  return NS_OK;
 }
 
-void
-nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible)
+NS_IMETHODIMP nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible)
 {
   NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager");
 
   if (aVisible != aView->GetVisibility()) {
     aView->SetVisibility(aVisible);
 
     if (IsViewInserted(aView)) {
       if (!aView->HasWidget()) {
         if (nsViewVisibility_kHide == aVisible) {
           nsView* parentView = aView->GetParent();
           if (parentView) {
-            parentView->GetViewManager()->
+            parentView->GetViewManagerInternal()->
               InvalidateView(parentView, aView->GetBoundsInParentUnits());
           }
         }
         else {
           InvalidateView(aView);
         }
       }
     }
   }
+  return NS_OK;
 }
 
 bool nsViewManager::IsViewInserted(nsView *aView)
 {
   if (mRootView == aView) {
     return true;
   } else if (aView->GetParent() == nullptr) {
     return false;
   } else {
     nsView* view = aView->GetParent()->GetFirstChild();
     while (view != nullptr) {
       if (view == aView) {
         return true;
-      }
+      }        
       view = view->GetNextSibling();
     }
     return false;
   }
 }
 
-void
-nsViewManager::SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZIndex, bool aTopMost)
+NS_IMETHODIMP nsViewManager::SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZIndex, bool aTopMost)
 {
+  nsresult  rv = NS_OK;
+
   NS_ASSERTION((aView != nullptr), "no view");
 
   // don't allow the root view's z-index to be changed. It should always be zero.
   // This could be removed and replaced with a style rule, or just removed altogether, with interesting consequences
   if (aView == mRootView) {
-    return;
+    return rv;
   }
 
   bool oldTopMost = aView->IsTopMost();
   bool oldIsAuto = aView->GetZIndexIsAuto();
 
   if (aAutoZIndex) {
     aZIndex = 0;
   }
 
   int32_t oldidx = aView->GetZIndex();
   aView->SetZIndex(aAutoZIndex, aZIndex, aTopMost);
 
   if (oldidx != aZIndex || oldTopMost != aTopMost ||
       oldIsAuto != aAutoZIndex) {
     InvalidateView(aView);
   }
+
+  return rv;
 }
 
-void
-nsViewManager::GetDeviceContext(nsDeviceContext *&aContext)
+NS_IMETHODIMP nsViewManager::GetDeviceContext(nsDeviceContext *&aContext)
 {
   aContext = mContext;
   NS_IF_ADDREF(aContext);
+  return NS_OK;
 }
 
-nsViewManager*
+nsIViewManager*
 nsViewManager::IncrementDisableRefreshCount()
 {
   if (!IsRootVM()) {
     return RootViewManager()->IncrementDisableRefreshCount();
   }
 
   ++mRefreshDisableCount;
 
@@ -1062,80 +1122,88 @@ nsViewManager::IncrementDisableRefreshCo
 void
 nsViewManager::DecrementDisableRefreshCount()
 {
   NS_ASSERTION(IsRootVM(), "Should only be called on root");
   --mRefreshDisableCount;
   NS_ASSERTION(mRefreshDisableCount >= 0, "Invalid refresh disable count!");
 }
 
-void
-nsViewManager::GetRootWidget(nsIWidget **aWidget)
+NS_IMETHODIMP nsViewManager::GetRootWidget(nsIWidget **aWidget)
 {
   if (!mRootView) {
     *aWidget = nullptr;
-    return;
+    return NS_OK;
   }
   if (mRootView->HasWidget()) {
     *aWidget = mRootView->GetWidget();
     NS_ADDREF(*aWidget);
-    return;
+    return NS_OK;
   }
-  if (mRootView->GetParent()) {
-    mRootView->GetParent()->GetViewManager()->GetRootWidget(aWidget);
-    return;
-  }
+  if (mRootView->GetParent())
+    return mRootView->GetParent()->GetViewManagerInternal()->GetRootWidget(aWidget);
   *aWidget = nullptr;
+  return NS_OK;
 }
 
 nsIntRect nsViewManager::ViewToWidget(nsView *aView, const nsRect &aRect) const
 {
   NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager");
 
   // account for the view's origin not lining up with the widget's
   nsRect rect = aRect + aView->ViewToWidgetOffset();
 
   // finally, convert to device coordinates.
   return rect.ToOutsidePixels(AppUnitsPerDevPixel());
 }
 
-void
+NS_IMETHODIMP
 nsViewManager::IsPainting(bool& aIsPainting)
 {
   aIsPainting = IsPainting();
+  return NS_OK;
 }
 
 void
 nsViewManager::ProcessPendingUpdates()
 {
   if (!IsRootVM()) {
     RootViewManager()->ProcessPendingUpdates();
     return;
   }
 
-  mPresShell->GetPresContext()->RefreshDriver()->RevokeViewManagerFlush();
-
-  // Flush things like reflows by calling WillPaint on observer presShells.
-  if (mPresShell) {
-    CallWillPaintOnObservers(true);
+  if (IsRefreshDriverPaintingEnabled()) {
+    mPresShell->GetPresContext()->RefreshDriver()->RevokeViewManagerFlush();
+      
+    // Flush things like reflows by calling WillPaint on observer presShells.
+    if (mPresShell) {
+      CallWillPaintOnObservers(true);
+    }
+    ProcessPendingUpdatesForView(mRootView, true);
+  } else {
+    ProcessPendingUpdatesForView(mRootView, true);
   }
-  ProcessPendingUpdatesForView(mRootView, true);
 }
 
 void
 nsViewManager::UpdateWidgetGeometry()
 {
   if (!IsRootVM()) {
     RootViewManager()->UpdateWidgetGeometry();
     return;
   }
 
   if (mHasPendingWidgetGeometryChanges) {
-    mHasPendingWidgetGeometryChanges = false;
+    if (IsRefreshDriverPaintingEnabled()) {
+      mHasPendingWidgetGeometryChanges = false;
+    }
     ProcessPendingUpdatesForView(mRootView, false);
+    if (!IsRefreshDriverPaintingEnabled()) {
+      mHasPendingWidgetGeometryChanges = false;
+    }
   }
 }
 
 void
 nsViewManager::CallWillPaintOnObservers(bool aWillSendDidPaint)
 {
   NS_PRECONDITION(IsRootVM(), "Must be root VM for this to be called!");
 
@@ -1149,32 +1217,33 @@ nsViewManager::CallWillPaintOnObservers(
         if (shell) {
           shell->WillPaint(aWillSendDidPaint);
         }
       }
     }
   }
 }
 
-void
+NS_IMETHODIMP
 nsViewManager::GetLastUserEventTime(uint32_t& aTime)
 {
   aTime = gLastUserEventTime;
+  return NS_OK;
 }
 
 void
 nsViewManager::InvalidateHierarchy()
 {
   if (mRootView) {
     if (!IsRootVM()) {
       NS_RELEASE(mRootViewManager);
     }
     nsView *parent = mRootView->GetParent();
     if (parent) {
-      mRootViewManager = parent->GetViewManager()->RootViewManager();
+      mRootViewManager = parent->GetViewManagerInternal()->RootViewManager();
       NS_ADDREF(mRootViewManager);
       NS_ASSERTION(mRootViewManager != this,
                    "Root view had a parent, but it has the same view manager");
     } else {
       mRootViewManager = this;
     }
   }
 }
new file mode 100644
--- /dev/null
+++ b/view/src/nsViewManager.h
@@ -0,0 +1,214 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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 nsViewManager_h___
+#define nsViewManager_h___
+#include "nsCOMPtr.h"
+#include "nsIViewManager.h"
+#include "nsCRT.h"
+#include "nsITimer.h"
+#include "prtime.h"
+#include "prinrval.h"
+#include "nsVoidArray.h"
+#include "nsThreadUtils.h"
+#include "nsIPresShell.h"
+#include "nsDeviceContext.h"
+
+
+/**
+   Invalidation model:
+
+   1) Callers call into the view manager and ask it to invalidate a view.
+   
+   2) The view manager finds the "right" widget for the view, henceforth called
+      the root widget.
+
+   3) The view manager traverses descendants of the root widget and for each
+      one that needs invalidation stores the rect to invalidate on the widget's
+      view (batching).
+
+   4) The dirty region is flushed to the right widget when
+      ProcessPendingUpdates is called from the RefreshDriver.
+
+   It's important to note that widgets associated to views outside this view
+   manager can end up being invalidated during step 3.  Therefore, the end of a
+   view update batch really needs to traverse the entire view tree, to ensure
+   that those invalidates happen.
+
+   To cope with this, invalidation processing and should only happen on the
+   root viewmanager.
+*/
+
+class nsViewManager : public nsIViewManager {
+public:
+  nsViewManager();
+
+  NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
+
+  NS_DECL_ISUPPORTS
+
+  NS_IMETHOD  Init(nsDeviceContext* aContext);
+
+  NS_IMETHOD_(nsView*) CreateView(const nsRect& aBounds,
+                                   const nsView* aParent,
+                                   nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
+
+  NS_IMETHOD_(nsView*) GetRootView();
+  NS_IMETHOD  SetRootView(nsView *aView);
+
+  NS_IMETHOD  GetWindowDimensions(nscoord *width, nscoord *height);
+  NS_IMETHOD  SetWindowDimensions(nscoord width, nscoord height);
+  NS_IMETHOD  FlushDelayedResize(bool aDoReflow);
+
+  NS_IMETHOD  InvalidateView(nsView *aView);
+  NS_IMETHOD  InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect);
+  NS_IMETHOD  InvalidateAllViews();
+
+  NS_IMETHOD  DispatchEvent(nsGUIEvent *aEvent,
+      nsView* aTargetView, nsEventStatus* aStatus);
+
+  NS_IMETHOD  InsertChild(nsView *parent, nsView *child, nsView *sibling,
+                          bool above);
+
+  NS_IMETHOD  InsertChild(nsView *parent, nsView *child,
+                          int32_t zindex);
+
+  NS_IMETHOD  RemoveChild(nsView *parent);
+
+  NS_IMETHOD  MoveViewTo(nsView *aView, nscoord aX, nscoord aY);
+
+  NS_IMETHOD  ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExposedAreaOnly = false);
+
+  NS_IMETHOD  SetViewFloating(nsView *aView, bool aFloating);
+
+  NS_IMETHOD  SetViewVisibility(nsView *aView, nsViewVisibility aVisible);
+
+  NS_IMETHOD  SetViewZIndex(nsView *aView, bool aAuto, int32_t aZIndex, bool aTopMost=false);
+
+  virtual void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; }
+  virtual nsIPresShell* GetPresShell() { return mPresShell; }
+
+  NS_IMETHOD  GetDeviceContext(nsDeviceContext *&aContext);
+
+  virtual nsIViewManager* IncrementDisableRefreshCount();
+  virtual void DecrementDisableRefreshCount();
+
+  NS_IMETHOD GetRootWidget(nsIWidget **aWidget);
+ 
+  NS_IMETHOD IsPainting(bool& aIsPainting);
+  NS_IMETHOD GetLastUserEventTime(uint32_t& aTime);
+  static uint32_t gLastUserEventTime;
+
+  /* Update the cached RootViewManager pointer on this view manager. */
+  void InvalidateHierarchy();
+
+  virtual void ProcessPendingUpdates();
+  virtual void UpdateWidgetGeometry();
+
+protected:
+  virtual ~nsViewManager();
+
+private:
+
+  void FlushPendingInvalidates();
+  void ProcessPendingUpdatesForView(nsView *aView,
+                                    bool aFlushDirtyRegion = true);
+  void FlushDirtyRegionToWidget(nsView* aView);
+  /**
+   * Call WillPaint() on all view observers under this vm root.
+   */
+  void CallWillPaintOnObservers(bool aWillSendDidPaint);
+  void ReparentChildWidgets(nsView* aView, nsIWidget *aNewWidget);
+  void ReparentWidgets(nsView* aView, nsView *aParent);
+  void InvalidateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedRegion);
+
+  void InvalidateViews(nsView *aView);
+
+  // aView is the view for aWidget and aRegion is relative to aWidget.
+  void Refresh(nsView *aView, const nsIntRegion& aRegion, bool aWillSendDidPaint);
+
+  void InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut);
+  void InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut,
+                                          nscoord aY1, nscoord aY2, bool aInCutOut);
+
+  // Utilities
+
+  bool IsViewInserted(nsView *aView);
+
+  /**
+   * Intersects aRect with aView's bounds and then transforms it from aView's
+   * coordinate system to the coordinate system of the widget attached to
+   * aView.
+   */
+  nsIntRect ViewToWidget(nsView *aView, const nsRect &aRect) const;
+
+  void DoSetWindowDimensions(nscoord aWidth, nscoord aHeight);
+
+  bool IsPainting() const {
+    return RootViewManager()->mPainting;
+  }
+
+  void SetPainting(bool aPainting) {
+    RootViewManager()->mPainting = aPainting;
+  }
+
+  nsresult InvalidateView(nsView *aView, const nsRect &aRect);
+
+public: // NOT in nsIViewManager, so private to the view module
+  nsView* GetRootViewImpl() const { return mRootView; }
+  nsViewManager* RootViewManager() const { return mRootViewManager; }
+  bool IsRootVM() const { return this == RootViewManager(); }
+
+  // Whether synchronous painting is allowed at the moment. For example,
+  // widget geometry changes can cause synchronous painting, so they need to
+  // be deferred while refresh is disabled.
+  bool IsPaintingAllowed() { return RootViewManager()->mRefreshDisableCount == 0; }
+
+  void WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint);
+  bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion,
+                   uint32_t aFlags);
+  void DidPaintWindow();
+
+  // Call this when you need to let the viewmanager know that it now has
+  // pending updates.
+  void PostPendingUpdate();
+
+  uint32_t AppUnitsPerDevPixel() const
+  {
+    return mContext->AppUnitsPerDevPixel();
+  }
+
+private:
+  nsRefPtr<nsDeviceContext> mContext;
+  nsIPresShell   *mPresShell;
+
+  // The size for a resize that we delayed until the root view becomes
+  // visible again.
+  nsSize            mDelayedResize;
+
+  nsView           *mRootView;
+  // mRootViewManager is a strong ref unless it equals |this|.  It's
+  // never null (if we have no ancestors, it will be |this|).
+  nsViewManager     *mRootViewManager;
+
+  // The following members should not be accessed directly except by
+  // the root view manager.  Some have accessor functions to enforce
+  // this, as noted.
+  
+  int32_t           mRefreshDisableCount;
+  // Use IsPainting() and SetPainting() to access mPainting.
+  bool              mPainting;
+  bool              mRecursiveRefreshPending;
+  bool              mHasPendingWidgetGeometryChanges;
+  bool              mInScroll;
+
+  //from here to public should be static and locked... MMP
+  static int32_t           mVMCount;        //number of viewmanagers
+
+  //list of view managers
+  static nsVoidArray       *gViewManagers;
+};
+
+#endif /* nsViewManager_h___ */
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -18,17 +18,17 @@ using mozilla::dom::ContentChild;
 using mozilla::unused;
 
 #include "nsAppShell.h"
 #include "nsIdleService.h"
 #include "nsWindow.h"
 #include "nsIObserverService.h"
 #include "nsFocusManager.h"
 #include "nsIWidgetListener.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 
 #include "nsRenderingContext.h"
 #include "nsIDOMSimpleGestureEvent.h"
 #include "nsDOMTouchEvent.h"
 
 #include "nsGkAtoms.h"
 #include "nsWidgetsCID.h"
 #include "nsGfxCIID.h"
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -18,17 +18,17 @@
 
 #include "nsObjCExceptions.h"
 #include "nsCOMPtr.h"
 #include "nsToolkit.h"
 #include "nsCRT.h"
 
 #include "nsFontMetrics.h"
 #include "nsIRollupListener.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIFile.h"
 #include "nsILocalFileMac.h"
 #include "nsGfxCIID.h"
 #include "nsIDOMSimpleGestureEvent.h"
 #include "nsNPAPIPluginInstance.h"
 #include "nsThemeConstants.h"
 #include "nsIWidgetListener.h"
--- a/widget/gtk2/nsDragService.cpp
+++ b/widget/gtk2/nsDragService.cpp
@@ -26,17 +26,17 @@
 
 #include "gfxASurface.h"
 #include "gfxXlibSurface.h"
 #include "gfxContext.h"
 #include "nsImageToPixbuf.h"
 #include "nsPresContext.h"
 #include "nsIDocument.h"
 #include "nsISelection.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIFrame.h"
 
 // This sets how opaque the drag image is
 #define DRAG_IMAGE_ALPHA_LEVEL 0.5
 
 // These values are copied from GtkDragResult (rather than using GtkDragResult
 // directly) so that this code can be compiled against versions of GTK+ that
 // do not have GtkDragResult.
@@ -264,17 +264,17 @@ GetGtkWindow(nsIDOMDocument *aDocument)
     nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDocument);
     if (!doc)
         return NULL;
 
     nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
     if (!presShell)
         return NULL;
 
-    nsRefPtr<nsViewManager> vm = presShell->GetViewManager();
+    nsCOMPtr<nsIViewManager> vm = presShell->GetViewManager();
     if (!vm)
         return NULL;
 
     nsCOMPtr<nsIWidget> widget;
     vm->GetRootWidget(getter_AddRefs(widget));
     if (!widget)
         return NULL;
 
--- a/widget/gtk2/nsNativeThemeGTK.cpp
+++ b/widget/gtk2/nsNativeThemeGTK.cpp
@@ -7,17 +7,17 @@
 #include "nsThemeConstants.h"
 #include "gtkdrawing.h"
 
 #include "nsIObserverService.h"
 #include "nsIServiceManager.h"
 #include "nsIFrame.h"
 #include "nsIPresShell.h"
 #include "nsIContent.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsINameSpaceManager.h"
 #include "nsGfxCIID.h"
 #include "nsTransform2D.h"
 #include "nsMenuFrame.h"
 #include "prlink.h"
 #include "nsIDOMHTMLInputElement.h"
 #include "nsRenderingContext.h"
 #include "nsGkAtoms.h"
@@ -70,17 +70,17 @@ nsNativeThemeGTK::Observe(nsISupports *a
 
 void
 nsNativeThemeGTK::RefreshWidgetWindow(nsIFrame* aFrame)
 {
   nsIPresShell *shell = GetPresShell(aFrame);
   if (!shell)
     return;
 
-  nsViewManager* vm = shell->GetViewManager();
+  nsIViewManager* vm = shell->GetViewManager();
   if (!vm)
     return;
  
   vm->InvalidateAllViews();
 }
 
 static bool IsFrameContentNodeInNamespace(nsIFrame *aFrame, uint32_t aNamespace)
 {
--- a/widget/tests/TestWinTSF.cpp
+++ b/widget/tests/TestWinTSF.cpp
@@ -60,17 +60,17 @@ template<class T> class nsReadingIterato
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMHTMLBodyElement.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIDOMHTMLInputElement.h"
 #include "nsIDOMHTMLTextAreaElement.h"
 #include "nsIDOMElement.h"
 #include "nsISelectionController.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsTArray.h"
 #include "nsGUIEvent.h"
 
 #ifndef MOZILLA_INTERNAL_API
 #undef nsString_h___
 #undef nsAString_h___
 #undef nsReadableUtils_h___
 #endif
@@ -3139,17 +3139,17 @@ TestApp::GetWidget(nsIWidget** aWidget)
   }
 
   nsCOMPtr<nsIPresShell> presShell;
   rv = docShell->GetPresShell(getter_AddRefs(presShell));
   if (NS_FAILED(rv) || !presShell) {
     return false;
   }
 
-  nsRefPtr<nsViewManager> viewManager = presShell->GetViewManager();
+  nsCOMPtr<nsIViewManager> viewManager = presShell->GetViewManager();
   if (!viewManager) {
     return false;
   }
 
   rv = viewManager->GetRootWidget(aWidget);
   return (NS_SUCCEEDED(rv) && aWidget);
 }
 
--- a/widget/xpwidgets/nsBaseDragService.cpp
+++ b/widget/xpwidgets/nsBaseDragService.cpp
@@ -13,17 +13,17 @@
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsCOMPtr.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIFrame.h"
 #include "nsIDocument.h"
 #include "nsIContent.h"
 #include "nsIPresShell.h"
-#include "nsViewManager.h"
+#include "nsIViewManager.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMDragEvent.h"
 #include "nsISelection.h"
 #include "nsISelectionPrivate.h"
 #include "nsPresContext.h"
 #include "nsIDOMDataTransfer.h"
 #include "nsICanvasElementExternal.h"
 #include "nsIImageLoadingContent.h"