From d44dff50964522e8d91c9b9d64b05009a6b117ee Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Fri, 4 Jan 2013 21:30:14 -0800 Subject: [PATCH] Back out 5e76dfb1d426 (bug 826635) and 0df74b1a4543:20df426b6111 (bug 826632) for bustage CLOSED TREE --- accessible/src/generic/DocAccessible.cpp | 4 +- accessible/src/mac/RootAccessibleWrap.mm | 2 +- accessible/src/msaa/AccessibleWrap.cpp | 4 +- accessible/src/msaa/DocAccessibleWrap.cpp | 2 +- content/base/public/nsIDocument.h | 4 +- content/base/src/Element.cpp | 2 +- content/base/src/FragmentOrElement.cpp | 2 +- content/base/src/nsContentSink.cpp | 6 +- content/base/src/nsContentSink.h | 2 +- content/base/src/nsContentUtils.cpp | 6 +- content/base/src/nsDocument.cpp | 4 +- content/base/src/nsDocument.h | 4 +- content/base/src/nsINode.cpp | 2 +- content/events/src/nsEventListenerManager.cpp | 2 +- content/events/src/nsIMEStateManager.cpp | 2 +- .../html/content/src/nsGenericHTMLElement.cpp | 2 +- content/html/document/src/MediaDocument.cpp | 2 +- content/html/document/src/nsHTMLDocument.cpp | 2 +- content/html/document/src/nsHTMLDocument.h | 2 +- content/xml/document/src/nsXMLContentSink.h | 2 +- content/xul/content/src/nsXULElement.cpp | 2 +- .../xul/content/src/nsXULPopupListener.cpp | 2 +- content/xul/document/src/nsXULContentSink.cpp | 2 +- content/xul/document/src/nsXULDocument.cpp | 2 +- docshell/base/nsDocShell.cpp | 16 +- dom/base/nsDOMWindowUtils.cpp | 4 +- dom/base/nsFocusManager.cpp | 12 +- dom/base/nsGlobalWindow.cpp | 4 +- dom/ipc/TabParent.cpp | 4 +- dom/plugins/base/nsPluginInstanceOwner.cpp | 8 +- .../webBrowser/nsDocShellTreeOwner.cpp | 4 +- extensions/widgetutils/src/nsWidgetUtils.cpp | 4 +- layout/base/nsCSSFrameConstructor.cpp | 4 +- layout/base/nsCSSRendering.cpp | 2 +- layout/base/nsCSSRenderingBorders.cpp | 2 +- layout/base/nsDisplayList.cpp | 2 +- layout/base/nsDocumentViewer.cpp | 26 +- layout/base/nsIDocumentViewerPrint.h | 6 +- layout/base/nsIPresShell.h | 8 +- layout/base/nsPresContext.cpp | 4 +- layout/base/nsPresShell.cpp | 19 +- layout/base/nsPresShell.h | 2 +- layout/base/nsRefreshDriver.cpp | 4 +- layout/build/nsLayoutModule.cpp | 7 + layout/forms/nsComboboxControlFrame.cpp | 6 +- layout/forms/nsListControlFrame.cpp | 2 +- layout/forms/nsTextControlFrame.cpp | 2 +- layout/generic/nsContainerFrame.cpp | 16 +- layout/generic/nsFrame.cpp | 4 +- layout/generic/nsFrameSetFrame.cpp | 2 +- layout/generic/nsGfxScrollFrame.cpp | 2 +- layout/generic/nsObjectFrame.cpp | 10 +- layout/generic/nsSubDocumentFrame.cpp | 8 +- layout/printing/nsPrintEngine.cpp | 11 +- layout/printing/nsPrintObject.h | 4 +- .../src/nsLayoutDebuggingTools.cpp | 8 +- .../layout-debug/src/nsRegressionTester.cpp | 2 +- layout/xul/base/src/nsBoxFrame.cpp | 2 +- layout/xul/base/src/nsDeckFrame.cpp | 2 +- layout/xul/base/src/nsLeafBoxFrame.cpp | 2 +- layout/xul/base/src/nsListBoxBodyFrame.cpp | 2 +- layout/xul/base/src/nsMenuPopupFrame.cpp | 10 +- layout/xul/base/src/nsMenuPopupFrame.h | 2 +- layout/xul/base/src/nsXULPopupManager.cpp | 6 +- .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 2 +- view/public/Makefile.in | 3 +- .../{nsViewManager.h => nsIViewManager.h} | 222 +++---------- view/public/nsView.h | 21 +- view/public/nsViewsCID.h | 17 + view/src/nsView.cpp | 52 +-- view/src/nsViewManager.cpp | 295 +++++++++++------- view/src/nsViewManager.h | 214 +++++++++++++ widget/android/nsWindow.cpp | 2 +- widget/cocoa/nsChildView.mm | 2 +- widget/gtk2/nsDragService.cpp | 4 +- widget/gtk2/nsNativeThemeGTK.cpp | 4 +- widget/tests/TestWinTSF.cpp | 4 +- widget/xpwidgets/nsBaseDragService.cpp | 2 +- 78 files changed, 677 insertions(+), 478 deletions(-) rename view/public/{nsViewManager.h => nsIViewManager.h} (57%) create mode 100644 view/public/nsViewsCID.h create mode 100644 view/src/nsViewManager.h diff --git a/accessible/src/generic/DocAccessible.cpp b/accessible/src/generic/DocAccessible.cpp index b579a96d2c02..4163a9ed83fa 100644 --- a/accessible/src/generic/DocAccessible.cpp +++ b/accessible/src/generic/DocAccessible.cpp @@ -35,7 +35,7 @@ #include "nsINameSpaceManager.h" #include "nsIPresShell.h" #include "nsIServiceManager.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIScrollableFrame.h" #include "nsUnicharUtils.h" #include "nsIURI.h" @@ -1253,7 +1253,7 @@ DocAccessible::GetNativeWindow() const if (!mPresShell) return nullptr; - nsViewManager* vm = mPresShell->GetViewManager(); + nsIViewManager* vm = mPresShell->GetViewManager(); if (!vm) return nullptr; diff --git a/accessible/src/mac/RootAccessibleWrap.mm b/accessible/src/mac/RootAccessibleWrap.mm index 729087d03468..6e332c935850 100644 --- a/accessible/src/mac/RootAccessibleWrap.mm +++ b/accessible/src/mac/RootAccessibleWrap.mm @@ -10,7 +10,7 @@ #include "nsCOMPtr.h" #include "nsObjCExceptions.h" #include "nsIWidget.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" using namespace mozilla::a11y; diff --git a/accessible/src/msaa/AccessibleWrap.cpp b/accessible/src/msaa/AccessibleWrap.cpp index ec20bad885d4..4f0704b5ff62 100644 --- a/accessible/src/msaa/AccessibleWrap.cpp +++ b/accessible/src/msaa/AccessibleWrap.cpp @@ -34,7 +34,7 @@ #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" @@ -1653,7 +1653,7 @@ AccessibleWrap::GetHWNDFor(Accessible* aAccessible) nsIWidget* widget = frame->GetNearestWidget(); if (widget && widget->IsVisible()) { nsIPresShell* shell = document->PresShell(); - nsViewManager* vm = shell->GetViewManager(); + nsIViewManager* vm = shell->GetViewManager(); if (vm) { nsCOMPtr rootWidget; vm->GetRootWidget(getter_AddRefs(rootWidget)); diff --git a/accessible/src/msaa/DocAccessibleWrap.cpp b/accessible/src/msaa/DocAccessibleWrap.cpp index 876958f24dff..8fd23d488887 100644 --- a/accessible/src/msaa/DocAccessibleWrap.cpp +++ b/accessible/src/msaa/DocAccessibleWrap.cpp @@ -21,7 +21,7 @@ #include "nsISelectionController.h" #include "nsIServiceManager.h" #include "nsIURI.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIWebNavigation.h" using namespace mozilla; diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index a8c45d36846e..12544516354b 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -65,7 +65,7 @@ class nsIStyleRule; class nsIStyleSheet; class nsIURI; class nsIVariant; -class nsViewManager; +class nsIViewManager; class nsPresContext; class nsRange; class nsScriptLoader; @@ -478,7 +478,7 @@ public: * 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; diff --git a/content/base/src/Element.cpp b/content/base/src/Element.cpp index 0f6a7a1e4f9e..bc5538b3a1fb 100644 --- a/content/base/src/Element.cpp +++ b/content/base/src/Element.cpp @@ -94,7 +94,7 @@ #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 */ diff --git a/content/base/src/FragmentOrElement.cpp b/content/base/src/FragmentOrElement.cpp index fb51d78dde75..e43cd5301611 100644 --- a/content/base/src/FragmentOrElement.cpp +++ b/content/base/src/FragmentOrElement.cpp @@ -93,7 +93,7 @@ #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 */ diff --git a/content/base/src/nsContentSink.cpp b/content/base/src/nsContentSink.cpp index 81bec6f4af40..a2bdec6a9cac 100644 --- a/content/base/src/nsContentSink.cpp +++ b/content/base/src/nsContentSink.cpp @@ -25,7 +25,7 @@ #include "nsIContent.h" #include "nsIPresShell.h" #include "nsPresContext.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIAtom.h" #include "nsGkAtoms.h" #include "nsIDOMWindow.h" @@ -1371,7 +1371,7 @@ nsContentSink::DidProcessATokenImpl() // 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 widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1518,7 +1518,7 @@ nsContentSink::WillParseImpl(void) 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); diff --git a/content/base/src/nsContentSink.h b/content/base/src/nsContentSink.h index 9537c801ab7c..4cb8bbce8480 100644 --- a/content/base/src/nsContentSink.h +++ b/content/base/src/nsContentSink.h @@ -34,7 +34,7 @@ class nsIParser; class nsIAtom; class nsIChannel; class nsIContent; -class nsViewManager; +class nsIViewManager; class nsNodeInfoManager; class nsScriptLoader; class nsIApplicationCache; diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index dd70005135a9..d2b910cea9e1 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -115,7 +115,7 @@ #include "nsTextEditorState.h" #include "nsIPluginHost.h" #include "nsICategoryManager.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsEventStateManager.h" #include "nsIDOMHTMLInputElement.h" #include "nsParserConstants.h" @@ -6435,11 +6435,11 @@ 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); } diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 3cf1e8bd782f..fb018d1a03da 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -3119,7 +3119,7 @@ nsDocument::TryChannelCharset(nsIChannel *aChannel, } nsresult -nsDocument::CreateShell(nsPresContext* aContext, nsViewManager* aViewManager, +nsDocument::CreateShell(nsPresContext* aContext, nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult) { @@ -3132,7 +3132,7 @@ nsDocument::CreateShell(nsPresContext* aContext, nsViewManager* aViewManager, nsresult nsDocument::doCreateShell(nsPresContext* aContext, - nsViewManager* aViewManager, nsStyleSet* aStyleSet, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode, nsIPresShell** aInstancePtrResult) { diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 9da0d22572f2..adbd2a66bd11 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -568,7 +568,7 @@ public: * shared among multiple presentation shell's). */ virtual nsresult CreateShell(nsPresContext* aContext, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult); virtual void DeleteShell(); @@ -1076,7 +1076,7 @@ public: protected: nsresult doCreateShell(nsPresContext* aContext, - nsViewManager* aViewManager, nsStyleSet* aStyleSet, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode, nsIPresShell** aInstancePtrResult); diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index 6ae96a8cfaed..90eb565a7e4d 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -74,7 +74,7 @@ #include "nsIServiceManager.h" #include "nsIURL.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIWebNavigation.h" #include "nsIWidget.h" #include "nsLayoutStatics.h" diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index e235fe40626d..23c0174a27f8 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -27,7 +27,7 @@ #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" diff --git a/content/events/src/nsIMEStateManager.cpp b/content/events/src/nsIMEStateManager.cpp index 216d1dea558e..75aa6b148fd0 100644 --- a/content/events/src/nsIMEStateManager.cpp +++ b/content/events/src/nsIMEStateManager.cpp @@ -6,7 +6,7 @@ #include "nsIMEStateManager.h" #include "nsCOMPtr.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIPresShell.h" #include "nsISupports.h" #include "nsPIDOMWindow.h" diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index d52947b19d9d..559d8aea071a 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -38,7 +38,7 @@ #include "nsIFrame.h" #include "nsIScrollableFrame.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIWidget.h" #include "nsRange.h" #include "nsIPresShell.h" diff --git a/content/html/document/src/MediaDocument.cpp b/content/html/document/src/MediaDocument.cpp index 7576db42357b..0f86c50208f7 100644 --- a/content/html/document/src/MediaDocument.cpp +++ b/content/html/document/src/MediaDocument.cpp @@ -9,7 +9,7 @@ #include "nsPresContext.h" #include "nsIPresShell.h" #include "nsIScrollable.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsITextToSubURI.h" #include "nsIURL.h" #include "nsIContentViewer.h" diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 7f2b5bdaa3ca..a15ddf6b8c01 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -305,7 +305,7 @@ nsHTMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup, nsresult nsHTMLDocument::CreateShell(nsPresContext* aContext, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult) { diff --git a/content/html/document/src/nsHTMLDocument.h b/content/html/document/src/nsHTMLDocument.h index a7124471a44e..2ceecf8c5c95 100644 --- a/content/html/document/src/nsHTMLDocument.h +++ b/content/html/document/src/nsHTMLDocument.h @@ -55,7 +55,7 @@ public: nsIPrincipal* aPrincipal); virtual nsresult CreateShell(nsPresContext* aContext, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult); diff --git a/content/xml/document/src/nsXMLContentSink.h b/content/xml/document/src/nsXMLContentSink.h index 140fb66be030..a7c31295dbcb 100644 --- a/content/xml/document/src/nsXMLContentSink.h +++ b/content/xml/document/src/nsXMLContentSink.h @@ -22,7 +22,7 @@ class nsIURI; class nsIContent; class nsINodeInfo; class nsIParser; -class nsViewManager; +class nsIViewManager; typedef enum { eXMLContentSinkState_InProlog, diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index c87be6820afd..0afe23e0538f 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -54,7 +54,7 @@ #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" diff --git a/content/xul/content/src/nsXULPopupListener.cpp b/content/xul/content/src/nsXULPopupListener.cpp index 4382be6ddae7..26577548f2cd 100644 --- a/content/xul/content/src/nsXULPopupListener.cpp +++ b/content/xul/content/src/nsXULPopupListener.cpp @@ -40,7 +40,7 @@ #include "nsIPresShell.h" #include "nsFocusManager.h" #include "nsPIDOMWindow.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsError.h" #include "nsMenuFrame.h" diff --git a/content/xul/document/src/nsXULContentSink.cpp b/content/xul/document/src/nsXULContentSink.cpp index 54eb53f8a48f..3068587e3970 100644 --- a/content/xul/document/src/nsXULContentSink.cpp +++ b/content/xul/document/src/nsXULContentSink.cpp @@ -30,7 +30,7 @@ #include "nsIScriptGlobalObject.h" #include "nsIServiceManager.h" #include "nsIURL.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIXULDocument.h" #include "nsIScriptSecurityManager.h" #include "nsLayoutCID.h" diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 583b8adebabe..ddebfd771566 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -30,7 +30,7 @@ #include "nsIBoxObject.h" #include "nsIChromeRegistry.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIContentViewer.h" #include "nsGUIEvent.h" #include "nsIDOMXULElement.h" diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index f4f10dabb371..c5a5b46bbad0 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -66,7 +66,7 @@ #include "nsDOMJSUtils.h" #include "nsIInterfaceRequestorUtils.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIScriptChannel.h" #include "nsIOfflineCacheUpdate.h" #include "nsITimedChannel.h" @@ -3249,7 +3249,7 @@ PrintDocTree(nsIDocShellTreeItem * aParentNode, int aLevel) nsCOMPtr domwin(doc->GetWindow()); nsCOMPtr widget; - nsViewManager* vm = presShell->GetViewManager(); + nsIViewManager* vm = presShell->GetViewManager(); if (vm) { vm->GetWidget(getter_AddRefs(widget)); } @@ -5048,10 +5048,10 @@ nsDocShell::Repaint(bool aForce) nsCOMPtr 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; } @@ -5115,7 +5115,7 @@ nsDocShell::GetVisibility(bool * aVisibility) 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 @@ -7388,7 +7388,7 @@ nsDocShell::RestoreFromHistory() nsCOMPtr oldPresShell = GetPresShell(); if (oldPresShell) { - nsViewManager *vm = oldPresShell->GetViewManager(); + nsIViewManager *vm = oldPresShell->GetViewManager(); if (vm) { nsView *oldRootView = vm->GetRootView(); @@ -7609,7 +7609,7 @@ nsDocShell::RestoreFromHistory() nsCOMPtr 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. @@ -7625,7 +7625,7 @@ nsDocShell::RestoreFromHistory() 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 diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 17501cdc436d..77a94372207b 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -33,7 +33,7 @@ #include "nsJSEnvironment.h" #include "nsJSUtils.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIDOMHTMLCanvasElement.h" #include "gfxContext.h" @@ -661,7 +661,7 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType, nsCOMPtr 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(); diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 54bca81fa689..f382d73e67fa 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -39,7 +39,7 @@ #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" @@ -1055,7 +1055,7 @@ nsFocusManager::EnsureCurrentWidgetFocused() if (docShell) { nsCOMPtr presShell = docShell->GetPresShell(); if (presShell) { - nsViewManager* vm = presShell->GetViewManager(); + nsIViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1552,7 +1552,7 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear, 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 widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1726,7 +1726,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow, objectFrameWidget = objectFrame->GetWidget(); } if (aAdjustWidgets && !objectFrameWidget && !sTestMode) { - nsViewManager* vm = presShell->GetViewManager(); + nsIViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1812,7 +1812,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow, if (aAdjustWidgets && objectFrameWidget && mFocusedWindow == aWindow && mFocusedContent == nullptr && !sTestMode) { - nsViewManager* vm = presShell->GetViewManager(); + nsIViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1974,7 +1974,7 @@ nsFocusManager::RaiseWindow(nsPIDOMWindow* aWindow) if (!presShell) return; - nsViewManager* vm = presShell->GetViewManager(); + nsIViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 011c79740d45..48f071dad082 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -118,7 +118,7 @@ #include "nsIScriptSecurityManager.h" #include "nsIScrollableFrame.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsISelectionController.h" #include "nsISelection.h" #include "nsIPrompt.h" @@ -11024,7 +11024,7 @@ nsGlobalChromeWindow::SetCursor(const nsAString& aCursor) nsCOMPtr 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(); diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index a64e07c96362..70a607aa7081 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -41,7 +41,7 @@ #include "nsIURI.h" #include "nsIMozBrowserFrame.h" #include "nsIScriptSecurityManager.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIWidget.h" #include "nsIWindowWatcher.h" #include "nsNetUtil.h" @@ -883,7 +883,7 @@ TabParent::RecvGetWidgetNativeData(WindowsHandle* aValue) if (content) { nsIPresShell* shell = content->OwnerDoc()->GetShell(); if (shell) { - nsViewManager* vm = shell->GetViewManager(); + nsIViewManager* vm = shell->GetViewManager(); nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); if (widget) { diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 0b46a8ce1105..ac7ad95dbe2a 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -45,7 +45,7 @@ using mozilla::DefaultXDisplay; #include "nsIWebBrowserChrome.h" #include "nsLayoutUtils.h" #include "nsIPluginWidget.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIDocShellTreeOwner.h" #include "nsIDOMHTMLObjectElement.h" #include "nsIAppShell.h" @@ -693,7 +693,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value) #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) @@ -743,14 +743,14 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value) #endif // simply return the topmost document window nsCOMPtr 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(); diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index b11429c539a6..68985c3cb8d3 100644 --- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -61,7 +61,7 @@ #include "imgIContainer.h" #include "nsContextMenuInfo.h" #include "nsPresContext.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsView.h" #include "nsEventListenerManager.h" #include "nsIDOMDragEvent.h" @@ -1443,7 +1443,7 @@ ChromeTooltipListener::sTooltipCallback(nsITimer *aTimer, nsIWidget* widget = nullptr; if (shell) { - nsViewManager* vm = shell->GetViewManager(); + nsIViewManager* vm = shell->GetViewManager(); if (vm) { nsView* view = vm->GetRootView(); if (view) { diff --git a/extensions/widgetutils/src/nsWidgetUtils.cpp b/extensions/widgetutils/src/nsWidgetUtils.cpp index ec6ccbf78717..9810e14b0a81 100644 --- a/extensions/widgetutils/src/nsWidgetUtils.cpp +++ b/extensions/widgetutils/src/nsWidgetUtils.cpp @@ -36,7 +36,7 @@ #include "nsIDOMWheelEvent.h" #include "nsView.h" #include "nsGUIEvent.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIContentPolicy.h" #include "nsIDocShellTreeItem.h" #include "nsIContent.h" @@ -89,7 +89,7 @@ private: static void StopPanningCallback(nsITimer *timer, void *closure); nsCOMPtr mWidget; - nsRefPtr mViewManager; + nsCOMPtr mViewManager; nsCOMPtr mTimer; }; diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 271102f07fcd..f5d4dd66c202 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -36,7 +36,7 @@ #include "nsIPresShell.h" #include "nsUnicharUtils.h" #include "nsStyleSet.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsEventStates.h" #include "nsStyleConsts.h" #include "nsTableOuterFrame.h" @@ -12023,7 +12023,7 @@ nsCSSFrameConstructor::RebuildAllStyleData(nsChangeHint aExtraHint) return; // Make sure that the viewmanager will outlive the presshell - nsRefPtr vm = mPresShell->GetViewManager(); + nsCOMPtr vm = mPresShell->GetViewManager(); // Processing the style changes could cause a flush that propagates to // the parent frame and thus destroys the pres shell. diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index f8162d78d477..98d67dd741d4 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -19,7 +19,7 @@ #include "nsIFrame.h" #include "nsPoint.h" #include "nsRect.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIPresShell.h" #include "nsFrameManager.h" #include "nsStyleContext.h" diff --git a/layout/base/nsCSSRenderingBorders.cpp b/layout/base/nsCSSRenderingBorders.cpp index 07fe86babf11..a28b2a7dc2b1 100644 --- a/layout/base/nsCSSRenderingBorders.cpp +++ b/layout/base/nsCSSRenderingBorders.cpp @@ -7,7 +7,7 @@ #include "nsStyleConsts.h" #include "nsPoint.h" #include "nsRect.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsFrameManager.h" #include "nsStyleContext.h" #include "nsGkAtoms.h" diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 8111f8c6a57a..d17034b2bd08 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -46,7 +46,7 @@ #include "sampler.h" #include "nsAnimationManager.h" #include "nsTransitionManager.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "ImageLayers.h" #include "ImageContainer.h" #include "nsCanvasFrame.h" diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index a8f3cfc43811..870cfc3fd1ee 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -40,8 +40,9 @@ #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" @@ -378,7 +379,7 @@ protected: // These return the current shell/prescontext etc. nsIPresShell* GetPresShell(); nsPresContext* GetPresContext(); - nsViewManager* GetViewManager(); + nsIViewManager* GetViewManager(); void DetachFromTopLevelWidget(); @@ -396,7 +397,7 @@ protected: // so they will be destroyed in the reverse order (pinkerton, scc) nsCOMPtr mDocument; nsCOMPtr mWindow; // may be null - nsRefPtr mViewManager; + nsCOMPtr mViewManager; nsRefPtr mPresContext; nsCOMPtr mPresShell; @@ -496,6 +497,8 @@ private: //------------------------------------------------------------------ // nsDocumentViewer //------------------------------------------------------------------ +// Class IDs +static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); //------------------------------------------------------------------ nsresult @@ -1396,7 +1399,7 @@ nsDocumentViewer::Open(nsISupports *aState, nsISHEntry *aSHEntry) // 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"); @@ -1543,7 +1546,7 @@ nsDocumentViewer::Destroy() // Remove our root view from the view hierarchy. if (mPresShell) { - nsViewManager *vm = mPresShell->GetViewManager(); + nsIViewManager *vm = mPresShell->GetViewManager(); if (vm) { nsView *rootView = vm->GetRootView(); @@ -1556,7 +1559,7 @@ nsDocumentViewer::Destroy() nsView *rootViewParent = rootView->GetParent(); if (rootViewParent) { - nsViewManager *parentVM = rootViewParent->GetViewManager(); + nsIViewManager *parentVM = rootViewParent->GetViewManager(); if (parentVM) { parentVM->RemoveChild(rootView); } @@ -1803,7 +1806,7 @@ nsDocumentViewer::GetPresContext() return mPresContext; } -nsViewManager* +nsIViewManager* nsDocumentViewer::GetViewManager() { return mViewManager; @@ -2269,11 +2272,14 @@ nsDocumentViewer::MakeWindow(const nsSize& aSize, nsView* aContainerView) 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; @@ -4382,7 +4388,7 @@ nsDocumentViewer::InitializeForPrintPreview() } void -nsDocumentViewer::SetPrintPreviewPresentation(nsViewManager* aViewManager, +nsDocumentViewer::SetPrintPreviewPresentation(nsIViewManager* aViewManager, nsPresContext* aPresContext, nsIPresShell* aPresShell) { diff --git a/layout/base/nsIDocumentViewerPrint.h b/layout/base/nsIDocumentViewerPrint.h index e99d39198339..083afc1219a1 100644 --- a/layout/base/nsIDocumentViewerPrint.h +++ b/layout/base/nsIDocumentViewerPrint.h @@ -12,7 +12,7 @@ class nsStyleSet; class nsIPresShell; class nsPresContext; class nsIWidget; -class nsViewManager; +class nsIViewManager; // {c6f255cf-cadd-4382-b57f-cd2a9874169b} #define NS_IDOCUMENT_VIEWER_PRINT_IID \ @@ -58,7 +58,7 @@ public: /** * Replaces the current presentation with print preview presentation. */ - virtual void SetPrintPreviewPresentation(nsViewManager* aViewManager, + virtual void SetPrintPreviewPresentation(nsIViewManager* aViewManager, nsPresContext* aPresContext, nsIPresShell* aPresShell) = 0; }; @@ -78,7 +78,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentViewerPrint, virtual void OnDonePrinting(); \ virtual bool IsInitializedForPrintPreview(); \ virtual void InitializeForPrintPreview(); \ - virtual void SetPrintPreviewPresentation(nsViewManager* aViewManager, \ + virtual void SetPrintPreviewPresentation(nsIViewManager* aViewManager, \ nsPresContext* aPresContext, \ nsIPresShell* aPresShell); diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index afc91f51df71..39aa465b9b91 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -44,7 +44,7 @@ class nsIDocument; class nsIFrame; class nsPresContext; class nsStyleSet; -class nsViewManager; +class nsIViewManager; class nsView; class nsRenderingContext; class nsIPageSequenceFrame; @@ -176,7 +176,7 @@ protected: public: virtual NS_HIDDEN_(nsresult) Init(nsIDocument* aDocument, nsPresContext* aPresContext, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode) = 0; @@ -272,7 +272,7 @@ public: nsPresContext* GetPresContext() const { return mPresContext; } - nsViewManager* GetViewManager() const { return mViewManager; } + nsIViewManager* GetViewManager() const { return mViewManager; } #ifdef ACCESSIBILITY /** @@ -1381,7 +1381,7 @@ protected: 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 diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 10350a5bf5f2..00c6e59fa601 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -43,7 +43,7 @@ #include "nsThreadUtils.h" #include "nsFrameManager.h" #include "nsLayoutUtils.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsCSSFrameConstructor.h" #include "nsCSSRuleProcessor.h" #include "nsStyleChangeList.h" @@ -826,7 +826,7 @@ nsPresContext::PreferenceChanged(const char* aPrefName) // 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; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 427aecd9deb3..0e19a038b38e 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -72,6 +72,7 @@ #include "nsCaret.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMXMLDocument.h" +#include "nsViewsCID.h" #include "nsFrameManager.h" #include "nsEventStateManager.h" #include "nsIMEStateManager.h" @@ -787,7 +788,7 @@ PresShell::~PresShell() nsresult PresShell::Init(nsIDocument* aDocument, nsPresContext* aPresContext, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode) { @@ -1856,7 +1857,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) return NS_ERROR_NOT_AVAILABLE; } - nsRefPtr viewManagerDeathGrip = mViewManager; + nsCOMPtr viewManagerDeathGrip = mViewManager; // Take this ref after viewManager so it'll make sure to go away first nsCOMPtr kungFuDeathGrip(this); @@ -1896,7 +1897,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) // 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); @@ -3734,7 +3735,7 @@ PresShell::IsSafeToFlush() const if (isSafeToFlush) { // Not safe if we are painting - nsViewManager* viewManager = GetViewManager(); + nsIViewManager* viewManager = GetViewManager(); if (viewManager) { bool isPainting = false; viewManager->IsPainting(isPainting); @@ -3807,7 +3808,7 @@ PresShell::FlushPendingNotifications(mozilla::ChangesToFlush aFlush) NS_ASSERTION(!isSafeToFlush || mViewManager, "Must have view manager"); // Make sure the view manager stays alive. - nsRefPtr viewManagerDeathGrip = mViewManager; + nsCOMPtr viewManagerDeathGrip = mViewManager; if (isSafeToFlush && mViewManager) { // Processing pending notifications can kill us, and some callers only // hold weak refs when calling FlushPendingNotifications(). :( @@ -5185,7 +5186,7 @@ PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll) // 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 @@ -7651,7 +7652,7 @@ PresShell::ProcessReflowCommands(bool aInterruptible) 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. @@ -7925,6 +7926,8 @@ nsIPresShell::RemoveRefreshObserverExternal(nsARefreshObserver* aObserver, #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) { @@ -8267,7 +8270,7 @@ PresShell::VerifyIncrementalReflow() nsIWidget* parentWidget = rootView->GetWidget(); // Create a new view manager. - nsRefPtr vm = new nsViewManager(); + nsCOMPtr vm = do_CreateInstance(kViewManagerCID); NS_ENSURE_TRUE(vm, false); rv = vm->Init(dc); NS_ENSURE_SUCCESS(rv, false); diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h index bde4b2f3e9a8..89ae708e5a2f 100644 --- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -70,7 +70,7 @@ public: // nsIPresShell virtual NS_HIDDEN_(nsresult) Init(nsIDocument* aDocument, nsPresContext* aPresContext, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode); virtual NS_HIDDEN_(void) Destroy(); diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 66cd63ae4f33..2b3993a3a752 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -39,7 +39,7 @@ #include "jsapi.h" #include "nsContentUtils.h" #include "mozilla/Preferences.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "sampler.h" #include "nsNPAPIPluginInstance.h" @@ -951,7 +951,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime) #endif mViewManagerFlushIsPending = false; - nsRefPtr vm = mPresContext->GetPresShell()->GetViewManager(); + nsCOMPtr vm = mPresContext->GetPresShell()->GetViewManager(); vm->ProcessPendingUpdates(); #ifdef DEBUG_INVALIDATIONS printf("Ending ProcessPendingUpdates\n"); diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index 0589851d6361..ad41b6b499d4 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -66,6 +66,8 @@ #include "nsChannelPolicy.h" // view stuff +#include "nsViewsCID.h" +#include "nsViewManager.h" #include "nsContentCreatorFunctions.h" // DOM includes @@ -592,6 +594,8 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \ return rv; \ } \ +NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewManager) + static nsresult CreateHTMLImgElement(nsISupports* aOuter, REFNSIID aIID, void** aResult) { @@ -751,6 +755,7 @@ 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 @@ -1034,6 +1039,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = { { &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 @@ -1183,6 +1189,7 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = { { 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 }, diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index bae444b06e8c..7231f4d72633 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -24,7 +24,7 @@ #include "nsIPresShell.h" #include "nsContentList.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsEventDispatcher.h" #include "nsEventListenerManager.h" #include "nsIDOMNode.h" @@ -356,7 +356,7 @@ void nsComboboxControlFrame::ShowPopup(bool aShowPopup) { nsView* view = mDropdownFrame->GetView(); - nsViewManager* viewManager = view->GetViewManager(); + nsIViewManager* viewManager = view->GetViewManager(); if (aShowPopup) { nsRect rect = mDropdownFrame->GetRect(); @@ -510,7 +510,7 @@ nsComboboxControlFrame::ReflowDropdown(nsPresContext* aPresContext, // 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); diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 120ac259c914..7574138c8c1b 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -17,7 +17,7 @@ #include "nsIDOMHTMLSelectElement.h" #include "nsIDOMHTMLOptionElement.h" #include "nsComboboxControlFrame.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIDOMHTMLOptGroupElement.h" #include "nsWidgetsCID.h" #include "nsIPresShell.h" diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 94ccfc181392..8a9497a06f8f 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -39,7 +39,7 @@ #include "nsLayoutUtils.h" #include "nsIComponentManager.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIDOMHTMLInputElement.h" #include "nsIDOMElement.h" #include "nsIDOMHTMLElement.h" diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 623de06d899e..b6e27140d8ef 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -22,7 +22,7 @@ #include "nsCOMPtr.h" #include "nsGkAtoms.h" #include "nsCSSAnonBoxes.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIWidget.h" #include "nsGfxCIID.h" #include "nsIServiceManager.h" @@ -373,7 +373,7 @@ nsContainerFrame::PeekOffsetCharacter(bool aForward, int32_t* aOffset, static nsresult ReparentFrameViewTo(nsIFrame* aFrame, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsView* aNewParentView, nsView* aOldParentView) { @@ -432,7 +432,7 @@ nsContainerFrame::CreateViewForFrame(nsIFrame* aFrame, 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 @@ -480,7 +480,7 @@ nsContainerFrame::PositionFrameView(nsIFrame* aKidFrame) return; nsView* view = aKidFrame->GetView(); - nsViewManager* vm = view->GetViewManager(); + nsIViewManager* vm = view->GetViewManager(); nsPoint pt; nsView* ancestorView = parentFrame->GetClosestView(&pt); @@ -607,7 +607,7 @@ nsContainerFrame::ReparentFrameViewList(nsPresContext* aPresContext, // 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()) { @@ -656,7 +656,7 @@ nsContainerFrame::SyncWindowProperties(nsPresContext* aPresContext, if (!windowWidget || !IsTopLevelWidget(windowWidget)) return; - nsViewManager* vm = aView->GetViewManager(); + nsIViewManager* vm = aView->GetViewManager(); nsView* rootView = vm->GetRootView(); if (aView != rootView) @@ -748,7 +748,7 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsPresContext* aPresContext, } if (0 == (aFlags & NS_FRAME_NO_SIZE_VIEW)) { - nsViewManager* vm = aView->GetViewManager(); + nsIViewManager* vm = aView->GetViewManager(); vm->ResizeView(aView, aVisualOverflowArea, true); } @@ -768,7 +768,7 @@ nsContainerFrame::SyncFrameViewProperties(nsPresContext* aPresContext, return; } - nsViewManager* vm = aView->GetViewManager(); + nsIViewManager* vm = aView->GetViewManager(); if (nullptr == aStyleContext) { aStyleContext = aFrame->GetStyleContext(); diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index be9082de186b..fbd308f54891 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -22,7 +22,7 @@ #include "nsStyleContext.h" #include "nsTableOuterFrame.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIScrollableFrame.h" #include "nsPresContext.h" #include "nsCRT.h" @@ -5289,7 +5289,7 @@ nsFrame::UpdateOverflow() 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); } } diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index 7ea3d8e737ba..843ef0ca5b55 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -22,7 +22,7 @@ #include "nsIDocument.h" #include "nsINodeInfo.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsWidgetsCID.h" #include "nsGkAtoms.h" #include "nsStyleCoord.h" diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index e0510aa491b9..541abd69edc9 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -11,7 +11,7 @@ #include "nsIServiceManager.h" #include "nsView.h" #include "nsIScrollable.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsContainerFrame.h" #include "nsGfxScrollFrame.h" #include "nsGkAtoms.h" diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 7f1b46428bc8..c7b9fed522e9 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -14,7 +14,7 @@ #include "nsIPresShell.h" #include "nsWidgetsCID.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIDOMEventListener.h" #include "nsIDOMDragEvent.h" #include "nsPluginHost.h" @@ -329,7 +329,7 @@ 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; @@ -365,7 +365,7 @@ nsObjectFrame::PrepForDrawing(nsIWidget *aWidget) 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); @@ -593,7 +593,7 @@ nsObjectFrame::Reflow(nsPresContext* aPresContext, 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); } @@ -884,7 +884,7 @@ nsObjectFrame::DidReflow(nsPresContext* aPresContext, if (HasView()) { nsView* view = GetView(); - nsViewManager* vm = view->GetViewManager(); + nsIViewManager* vm = view->GetViewManager(); if (vm) vm->SetViewVisibility(view, IsHidden() ? nsViewVisibility_kHide : nsViewVisibility_kShow); } diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index 9ead05a2f475..4a5bf79aa73e 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -30,7 +30,7 @@ #include "nsNetUtil.h" #include "nsIDocument.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsGkAtoms.h" #include "nsStyleCoord.h" #include "nsStyleContext.h" @@ -674,7 +674,7 @@ nsSubDocumentFrame::Reflow(nsPresContext* aPresContext, } 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); } @@ -958,7 +958,7 @@ 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); @@ -1092,7 +1092,7 @@ nsSubDocumentFrame::EnsureInnerView() 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"); diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 2224765fddce..41042894f8e6 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -87,9 +87,10 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro #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" @@ -215,6 +216,9 @@ protected: bool mSuppressed; }; +// Class IDs +static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); + NS_IMPL_ISUPPORTS3(nsPrintEngine, nsIWebProgressListener, nsISupportsWeakReference, nsIObserver) @@ -2193,7 +2197,8 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO) 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); @@ -3788,7 +3793,7 @@ DumpViews(nsIDocShell* aDocShell, FILE* out) 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) { diff --git a/layout/printing/nsPrintObject.h b/layout/printing/nsPrintObject.h index 2ea10001b046..672d05d56c90 100644 --- a/layout/printing/nsPrintObject.h +++ b/layout/printing/nsPrintObject.h @@ -12,7 +12,7 @@ #include "nsIContent.h" #include "nsIPresShell.h" #include "nsStyleSet.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIDocShell.h" #include "nsIDocument.h" #include "nsIDocShellTreeOwner.h" @@ -46,7 +46,7 @@ public: nsRefPtr mPresContext; nsCOMPtr mPresShell; - nsRefPtr mViewManager; + nsCOMPtr mViewManager; nsCOMPtr mContent; PrintObjectType mFrameType; diff --git a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp index 072b2f216d7d..2e86a23f7c77 100644 --- a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp +++ b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp @@ -21,7 +21,7 @@ #include "nsIDOMDocument.h" #include "nsIPresShell.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIFrame.h" #include "nsILayoutDebugger.h" @@ -55,7 +55,7 @@ pres_shell(nsIDocShell *aDocShell) return result.forget(); } -static nsViewManager* +static nsIViewManager* view_manager(nsIDocShell *aDocShell) { nsCOMPtr shell(pres_shell(aDocShell)); @@ -433,7 +433,7 @@ DumpViewsRecur(nsIDocShell* aDocShell, FILE* out) { #ifdef DEBUG fprintf(out, "docshell=%p \n", static_cast(aDocShell)); - nsRefPtr vm(view_manager(aDocShell)); + nsCOMPtr vm(view_manager(aDocShell)); if (vm) { nsView* root = vm->GetRootView(); if (root) { @@ -524,7 +524,7 @@ nsLayoutDebuggingTools::DumpReflowStats() void nsLayoutDebuggingTools::ForceRefresh() { - nsRefPtr vm(view_manager(mDocShell)); + nsCOMPtr vm(view_manager(mDocShell)); if (!vm) return; nsView* root = vm->GetRootView(); diff --git a/layout/tools/layout-debug/src/nsRegressionTester.cpp b/layout/tools/layout-debug/src/nsRegressionTester.cpp index af942203e6da..a23195f613db 100644 --- a/layout/tools/layout-debug/src/nsRegressionTester.cpp +++ b/layout/tools/layout-debug/src/nsRegressionTester.cpp @@ -25,7 +25,7 @@ #include "nsLayoutCID.h" #include "nsNetUtil.h" #include "nsIFile.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsView.h" diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index 011b9ea9d354..e7c44eb816ed 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -41,7 +41,7 @@ #include "nsGkAtoms.h" #include "nsIContent.h" #include "nsHTMLParts.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsView.h" #include "nsIPresShell.h" #include "nsCSSRendering.h" diff --git a/layout/xul/base/src/nsDeckFrame.cpp b/layout/xul/base/src/nsDeckFrame.cpp index 34932e816285..50f4611bf7f6 100644 --- a/layout/xul/base/src/nsDeckFrame.cpp +++ b/layout/xul/base/src/nsDeckFrame.cpp @@ -20,7 +20,7 @@ #include "nsHTMLParts.h" #include "nsIPresShell.h" #include "nsCSSRendering.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsBoxLayoutState.h" #include "nsStackLayout.h" #include "nsDisplayList.h" diff --git a/layout/xul/base/src/nsLeafBoxFrame.cpp b/layout/xul/base/src/nsLeafBoxFrame.cpp index 1ce3541532b1..163ed3ce0a30 100644 --- a/layout/xul/base/src/nsLeafBoxFrame.cpp +++ b/layout/xul/base/src/nsLeafBoxFrame.cpp @@ -20,7 +20,7 @@ #include "nsINameSpaceManager.h" #include "nsBoxLayoutState.h" #include "nsWidgetsCID.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsContainerFrame.h" #include "nsDisplayList.h" diff --git a/layout/xul/base/src/nsListBoxBodyFrame.cpp b/layout/xul/base/src/nsListBoxBodyFrame.cpp index 72eaf2c9f3ad..b5496a07cc1b 100644 --- a/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -22,7 +22,7 @@ #include "nsIScrollableFrame.h" #include "nsScrollbarFrame.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsStyleContext.h" #include "nsFontMetrics.h" #include "nsITimer.h" diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index c463591f28d0..eb20199c67c8 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -12,7 +12,7 @@ #include "nsStyleContext.h" #include "nsCSSRendering.h" #include "nsINameSpaceManager.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsWidgetsCID.h" #include "nsMenuFrame.h" #include "nsMenuBarFrame.h" @@ -125,7 +125,7 @@ nsMenuPopupFrame::Init(nsIContent* aContent, // 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; @@ -459,7 +459,7 @@ nsMenuPopupFrame::LayoutPopup(nsBoxLayoutState& aState, nsIFrame* aParentMenu, b } if (isOpen) { - nsViewManager* viewManager = view->GetViewManager(); + nsIViewManager* viewManager = view->GetViewManager(); nsRect rect = GetRect(); rect.x = rect.y = 0; viewManager->ResizeView(view, rect); @@ -794,7 +794,7 @@ nsMenuPopupFrame::HidePopup(bool aDeselectMenu, nsPopupState aNewState) 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); @@ -1919,7 +1919,7 @@ nsMenuPopupFrame::CreatePopupView() return NS_OK; } - nsViewManager* viewManager = PresContext()->GetPresShell()->GetViewManager(); + nsIViewManager* viewManager = PresContext()->GetPresShell()->GetViewManager(); NS_ASSERTION(nullptr != viewManager, "null view manager"); // Create a view diff --git a/layout/xul/base/src/nsMenuPopupFrame.h b/layout/xul/base/src/nsMenuPopupFrame.h index 10b977609aa9..bcf09d20e979 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.h +++ b/layout/xul/base/src/nsMenuPopupFrame.h @@ -90,7 +90,7 @@ enum FlipStyle { nsIFrame* NS_NewMenuPopupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); -class nsViewManager; +class nsIViewManager; class nsView; class nsMenuPopupFrame; diff --git a/layout/xul/base/src/nsXULPopupManager.cpp b/layout/xul/base/src/nsXULPopupManager.cpp index 340fe7ec364a..cf6befa60196 100644 --- a/layout/xul/base/src/nsXULPopupManager.cpp +++ b/layout/xul/base/src/nsXULPopupManager.cpp @@ -20,7 +20,7 @@ #include "nsEventStateManager.h" #include "nsCSSFrameConstructor.h" #include "nsLayoutUtils.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIComponentManager.h" #include "nsITimer.h" #include "nsFocusManager.h" @@ -2262,7 +2262,7 @@ nsXULMenuCommandEvent::Run() 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. @@ -2295,7 +2295,7 @@ nsXULMenuCommandEvent::Run() nsPresContext* presContext = menuFrame->PresContext(); nsCOMPtr shell = presContext->PresShell(); - nsRefPtr kungFuDeathGrip = shell->GetViewManager(); + nsCOMPtr kungFuDeathGrip = shell->GetViewManager(); // Deselect ourselves. if (mCloseMenuMode != CloseMenuMode_None) diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index e0f6f69aa3f8..f889eba2383d 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -39,7 +39,7 @@ #include "nsXPIDLString.h" #include "nsContainerFrame.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsWidgetsCID.h" #include "nsBoxFrame.h" #include "nsBoxObject.h" diff --git a/view/public/Makefile.in b/view/public/Makefile.in index 49effdfb71a2..f4c2731040a9 100644 --- a/view/public/Makefile.in +++ b/view/public/Makefile.in @@ -14,7 +14,8 @@ MODULE = view EXPORTS = \ nsView.h \ - nsViewManager.h \ + nsIViewManager.h \ + nsViewsCID.h \ nsIScrollPositionListener.h \ $(NULL) diff --git a/view/public/nsViewManager.h b/view/public/nsIViewManager.h similarity index 57% rename from view/public/nsViewManager.h rename to view/public/nsIViewManager.h index f5ba8823e065..b8ca74541cbd 100644 --- a/view/public/nsViewManager.h +++ b/view/public/nsIViewManager.h @@ -3,16 +3,12 @@ * 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___ +#ifndef nsIViewManager_h___ +#define nsIViewManager_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; @@ -20,25 +16,22 @@ class nsRegion; class nsDeviceContext; class nsIPresShell; -class nsViewManager MOZ_FINAL +#define NS_IVIEWMANAGER_IID \ +{ 0x540610a6, 0x4fdd, 0x4ae3, \ + { 0x9b, 0xdb, 0xa6, 0x4d, 0x8b, 0xca, 0x02, 0x0f } } + +class nsIViewManager : public nsISupports { public: - friend class nsView; - - NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW - - NS_INLINE_DECL_REFCOUNTING(nsViewManager) - - nsViewManager(); - ~nsViewManager(); + 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 */ - nsresult Init(nsDeviceContext* aContext); + NS_IMETHOD Init(nsDeviceContext* aContext) = 0; /** * Create an ordinary view @@ -52,15 +45,15 @@ public: * 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); + 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 */ - nsView* GetRootView() { return mRootView; } + NS_IMETHOD_(nsView*) GetRootView() = 0; /** * Set the root of the view tree. Does not destroy the current root view. @@ -68,7 +61,7 @@ public: * aView may have a widget (anything but printing) or may not (printing). * @param aView view to set as root */ - void SetRootView(nsView *aView); + NS_IMETHOD SetRootView(nsView *aView) = 0; /** * Get the dimensions of the root window. The dimensions are in @@ -76,7 +69,7 @@ public: * @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); + NS_IMETHOD GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) = 0; /** * Set the dimensions of the root window. @@ -85,19 +78,19 @@ public: * @param aWidth of window in twips * @param aHeight of window in twips */ - void SetWindowDimensions(nscoord aWidth, nscoord aHeight); + NS_IMETHOD SetWindowDimensions(nscoord aWidth, nscoord aHeight) = 0; /** * Do any resizes that are pending. */ - void FlushDelayedResize(bool aDoReflow); + 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 */ - void InvalidateView(nsView *aView); + NS_IMETHOD InvalidateView(nsView *aView) = 0; /** * Called to inform the view manager that some portion of a view is dirty and @@ -106,12 +99,12 @@ public: * @param aView view to paint. should be root view * @param rect rect to mark as damaged */ - void InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect); + NS_IMETHOD InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect) = 0; /** * Called to inform the view manager that it should invalidate all views. */ - void InvalidateAllViews(); + NS_IMETHOD InvalidateAllViews() = 0; /** * Called to dispatch an event to the appropriate view. Often called @@ -121,8 +114,8 @@ public: * @param aViewTarget dispatch the event to this view * @param aStatus event handling status */ - void DispatchEvent(nsGUIEvent *aEvent, - nsView* aViewTarget, nsEventStatus* aStatus); + NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, + nsView* aViewTarget, nsEventStatus* aStatus) = 0; /** * Given a parent view, insert another view as its child. @@ -139,10 +132,8 @@ public: * @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); + 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 @@ -151,7 +142,7 @@ public: * @param aParent parent view * @param aChild child view */ - void RemoveChild(nsView *aChild); + NS_IMETHOD RemoveChild(nsView *aChild) = 0; /** * Move a view to the specified position, provided in parent coordinates. @@ -162,7 +153,7 @@ public: * @param aX x value for new view position * @param aY y value for new view position */ - void MoveViewTo(nsView *aView, nscoord aX, nscoord aY); + NS_IMETHOD MoveViewTo(nsView *aView, nscoord aX, nscoord aY) = 0; /** * Resize a view. In addition to setting the width and height, you can @@ -176,8 +167,8 @@ public: * 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); + 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 @@ -190,7 +181,7 @@ public: * @param aView view to change visibility state of * @param visible new visibility state */ - void SetViewVisibility(nsView *aView, nsViewVisibility aVisible); + NS_IMETHOD SetViewVisibility(nsView *aView, nsViewVisibility aVisible) = 0; /** * Set the z-index of a view. Positive z-indices mean that a view @@ -208,7 +199,7 @@ public: * 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); + NS_IMETHOD SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZindex, bool aTopMost = false) = 0; /** * Set whether the view "floats" above all other views, @@ -217,24 +208,24 @@ public: * 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); + NS_IMETHOD SetViewFloating(nsView *aView, bool aFloatingView) = 0; /** * Set the presshell associated with this manager * @param aPresShell - new presshell */ - void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; } + virtual void SetPresShell(nsIPresShell *aPresShell) = 0; /** * Get the pres shell associated with this manager */ - nsIPresShell* GetPresShell() { return mPresShell; } + virtual nsIPresShell* GetPresShell() = 0; /** * Get the device context associated with this manager * @result device context */ - void GetDeviceContext(nsDeviceContext *&aContext); + NS_IMETHOD GetDeviceContext(nsDeviceContext *&aContext) = 0; /** * A stack class for disallowing changes that would enter painting. For @@ -250,7 +241,7 @@ public: */ class NS_STACK_CLASS AutoDisableRefresh { public: - AutoDisableRefresh(nsViewManager* aVM) { + AutoDisableRefresh(nsIViewManager* aVM) { if (aVM) { mRootVM = aVM->IncrementDisableRefreshCount(); } @@ -264,21 +255,21 @@ public: AutoDisableRefresh(const AutoDisableRefresh& aOther); const AutoDisableRefresh& operator=(const AutoDisableRefresh& aOther); - nsRefPtr mRootVM; + nsCOMPtr mRootVM; }; private: friend class AutoDisableRefresh; - nsViewManager* IncrementDisableRefreshCount(); - void DecrementDisableRefreshCount(); + 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. */ - void GetRootWidget(nsIWidget **aWidget); + NS_IMETHOD GetRootWidget(nsIWidget **aWidget) = 0; /** * Indicate whether the viewmanager is currently painting @@ -286,7 +277,7 @@ public: * @param aPainting true if the viewmanager is painting * false otherwise */ - void IsPainting(bool& aIsPainting); + NS_IMETHOD IsPainting(bool& aIsPainting)=0; /** * Retrieve the time of the last user event. User events @@ -295,7 +286,7 @@ public: * * @param aTime Last user event time in microseconds */ - void GetLastUserEventTime(uint32_t& aTime); + NS_IMETHOD GetLastUserEventTime(uint32_t& aTime)=0; /** * Find the nearest display root view for the view aView. This is the view for @@ -307,137 +298,14 @@ public: * Flush the accumulated dirty region to the widget and update widget * geometry. */ - void ProcessPendingUpdates(); + virtual void ProcessPendingUpdates()=0; /** * 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 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; + virtual void UpdateWidgetGeometry() = 0; }; -/** - Invalidation model: +NS_DEFINE_STATIC_IID_ACCESSOR(nsIViewManager, NS_IVIEWMANAGER_IID) - 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___ +#endif // nsIViewManager_h___ diff --git a/view/public/nsView.h b/view/public/nsView.h index 9e2d9f02c728..a9bade64954b 100644 --- a/view/public/nsView.h +++ b/view/public/nsView.h @@ -6,14 +6,21 @@ #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 +class nsIViewManager; class nsViewManager; class nsIWidget; class nsIFrame; @@ -52,7 +59,7 @@ enum nsViewVisibility { * 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 @@ -68,7 +75,9 @@ public: * view manager from somewhere else, do that instead. * @result the view manager */ - nsViewManager* GetViewManager() const { return mViewManager; } + nsIViewManager* GetViewManager() const + { return reinterpret_cast(mViewManager); } + nsViewManager* GetViewManagerInternal() const { return mViewManager; } /** * Find the view for the given widget, if there is one. @@ -451,13 +460,13 @@ private: // 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 diff --git a/view/public/nsViewsCID.h b/view/public/nsViewsCID.h new file mode 100644 index 000000000000..5c06871a4235 --- /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__ diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index a2dc372a6fdb..31deaad1aecf 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -63,7 +63,7 @@ nsView::~nsView() { DropMouseGrabbing(); - nsView *rootView = mViewManager->GetRootView(); + nsView *rootView = mViewManager->GetRootViewImpl(); if (rootView) { @@ -225,7 +225,7 @@ 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; } @@ -347,7 +347,7 @@ void nsView::SetFloating(bool aFloatingView) void nsView::InvalidateHierarchy(nsViewManager *aViewManagerParent) { - if (mViewManager->GetRootView() == this) + if (mViewManager->GetRootViewImpl() == this) mViewManager->InvalidateHierarchy(); for (nsView *child = mFirstChild; child; child = child->GetNextSibling()) @@ -379,8 +379,8 @@ void nsView::InsertChild(nsView *aChild, nsView *aSibling) // 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 } @@ -415,10 +415,10 @@ void nsView::RemoveChild(nsView *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()); } } } @@ -736,7 +736,7 @@ void nsView::List(FILE* out, int32_t aIndent) const 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 @@ -749,11 +749,11 @@ nsPoint nsView::GetOffsetTo(const nsView* aOther, const int32_t aAPD) const // 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) { @@ -799,15 +799,15 @@ nsPoint nsView::GetOffsetToWidget(nsIWidget* aWidget) const 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 @@ -820,10 +820,10 @@ nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const // 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) { @@ -856,19 +856,19 @@ nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const 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); } @@ -877,8 +877,8 @@ 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; @@ -953,7 +953,7 @@ nsView::RequestWindowClose(nsIWidget* aWidget) void nsView::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint) { - nsRefPtr vm = mViewManager; + nsCOMPtr vm = mViewManager; vm->WillPaintWindow(aWidget, aWillSendDidPaint); } @@ -963,7 +963,7 @@ 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 vm = mViewManager; + nsCOMPtr 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. @@ -977,7 +977,7 @@ nsView::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, uint32_t aFlags) void nsView::DidPaintWindow() { - nsRefPtr vm = mViewManager; + nsCOMPtr vm = mViewManager; vm->DidPaintWindow(); } @@ -1006,7 +1006,7 @@ nsView::HandleEvent(nsGUIEvent* aEvent, bool aUseAttachedEvents) } if (view) { - nsRefPtr vm = view->GetViewManager(); + nsCOMPtr vm = view->GetViewManager(); vm->DispatchEvent(aEvent, view, &result); } diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index b51d1fd34953..442b7056e849 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -46,6 +46,22 @@ #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 @@ -106,10 +122,11 @@ nsViewManager::~nsViewManager() 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"); @@ -124,7 +141,7 @@ nsViewManager::Init(nsDeviceContext* aContext) return NS_OK; } -nsView* +NS_IMETHODIMP_(nsView *) nsViewManager::CreateView(const nsRect& aBounds, const nsView* aParent, nsViewVisibility aVisibilityFlag) @@ -139,8 +156,13 @@ nsViewManager::CreateView(const nsRect& aBounds, 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"); @@ -162,10 +184,11 @@ nsViewManager::SetRootView(nsView *aView) 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)) { @@ -182,6 +205,7 @@ nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) *aWidth = 0; *aHeight = 0; } + return NS_OK; } void nsViewManager::DoSetWindowDimensions(nscoord aWidth, nscoord aHeight) @@ -197,8 +221,7 @@ void nsViewManager::DoSetWindowDimensions(nscoord aWidth, nscoord aHeight) } } -void -nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight) +NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight) { if (mRootView) { if (mRootView->IsEffectivelyVisible() && mPresShell && mPresShell->IsVisible()) { @@ -221,10 +244,11 @@ nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight) } } } + + return NS_OK; } -void -nsViewManager::FlushDelayedResize(bool aDoReflow) +NS_IMETHODIMP nsViewManager::FlushDelayedResize(bool aDoReflow) { if (mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE)) { if (aDoReflow) { @@ -237,6 +261,7 @@ nsViewManager::FlushDelayedResize(bool aDoReflow) } } } + return NS_OK; } // Convert aIn from being relative to and in appunits of aFromView, to being @@ -248,12 +273,12 @@ static nsRegion ConvertRegionBetweenViews(const nsRegion& aIn, 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 (;;) { @@ -332,6 +357,7 @@ void nsViewManager::Refresh(nsView *aView, const nsIntRegion& aRegion, 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 @@ -372,38 +398,40 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView, // 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!"); + + SetPainting(true); +#ifdef DEBUG_INVALIDATIONS + 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); +#ifdef DEBUG_INVALIDATIONS + printf("---- PAINT END ----\n"); +#endif + aView->SetForcedRepaint(false); + SetPainting(false); } - - NS_ASSERTION(aView->HasWidget(), "Must have a widget!"); - - SetPainting(true); -#ifdef DEBUG_INVALIDATIONS - 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); -#ifdef DEBUG_INVALIDATIONS - printf("---- PAINT END ----\n"); -#endif - aView->SetForcedRepaint(false); - SetPainting(false); } FlushDirtyRegionToWidget(aView); } @@ -422,16 +450,15 @@ void nsViewManager::FlushDirtyRegionToWidget(nsView* aView) } 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 @@ -544,27 +571,25 @@ ShouldIgnoreInvalidation(nsViewManager* aVM) 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"); @@ -573,11 +598,11 @@ nsViewManager::InvalidateViewNoSuppression(nsView *aView, 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. @@ -589,16 +614,18 @@ nsViewManager::InvalidateViewNoSuppression(nsView *aView, // 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) @@ -609,14 +636,37 @@ void nsViewManager::InvalidateViews(nsView *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 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(); @@ -644,6 +694,10 @@ bool nsViewManager::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, 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); @@ -662,8 +716,7 @@ void nsViewManager::DidPaintWindow() } } -void -nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* aStatus) +nsresult nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* aStatus) { SAMPLE_LABEL("event", "nsViewManager::DispatchEvent"); @@ -714,11 +767,13 @@ nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* a // want to cause its destruction in, say, some JavaScript event handler. nsCOMPtr 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 @@ -782,9 +837,8 @@ void nsViewManager::ReparentWidgets(nsView* aView, nsView *aParent) } } -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"); @@ -843,36 +897,36 @@ nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, //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(); @@ -885,12 +939,13 @@ nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY) 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, @@ -924,8 +979,7 @@ void nsViewManager::InvalidateRectDifference(nsView *aView, const nsRect& aRect, } } -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"); @@ -942,7 +996,7 @@ nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExpos } 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); @@ -960,18 +1014,20 @@ nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExpos // 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"); @@ -983,7 +1039,7 @@ nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible) if (nsViewVisibility_kHide == aVisible) { nsView* parentView = aView->GetParent(); if (parentView) { - parentView->GetViewManager()-> + parentView->GetViewManagerInternal()-> InvalidateView(parentView, aView->GetBoundsInParentUnits()); } } @@ -993,6 +1049,7 @@ nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible) } } } + return NS_OK; } bool nsViewManager::IsViewInserted(nsView *aView) @@ -1006,22 +1063,23 @@ bool nsViewManager::IsViewInserted(nsView *aView) 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(); @@ -1038,16 +1096,18 @@ nsViewManager::SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZIndex, b 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()) { @@ -1067,23 +1127,21 @@ nsViewManager::DecrementDisableRefreshCount() 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; - } - if (mRootView->GetParent()) { - mRootView->GetParent()->GetViewManager()->GetRootWidget(aWidget); - return; + return NS_OK; } + if (mRootView->GetParent()) + return mRootView->GetParent()->GetViewManagerInternal()->GetRootWidget(aWidget); *aWidget = nullptr; + return NS_OK; } nsIntRect nsViewManager::ViewToWidget(nsView *aView, const nsRect &aRect) const @@ -1097,10 +1155,11 @@ nsIntRect nsViewManager::ViewToWidget(nsView *aView, const nsRect &aRect) const return rect.ToOutsidePixels(AppUnitsPerDevPixel()); } -void +NS_IMETHODIMP nsViewManager::IsPainting(bool& aIsPainting) { aIsPainting = IsPainting(); + return NS_OK; } void @@ -1111,13 +1170,17 @@ nsViewManager::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 @@ -1129,8 +1192,13 @@ nsViewManager::UpdateWidgetGeometry() } if (mHasPendingWidgetGeometryChanges) { - mHasPendingWidgetGeometryChanges = false; + if (IsRefreshDriverPaintingEnabled()) { + mHasPendingWidgetGeometryChanges = false; + } ProcessPendingUpdatesForView(mRootView, false); + if (!IsRefreshDriverPaintingEnabled()) { + mHasPendingWidgetGeometryChanges = false; + } } } @@ -1154,10 +1222,11 @@ nsViewManager::CallWillPaintOnObservers(bool aWillSendDidPaint) } } -void +NS_IMETHODIMP nsViewManager::GetLastUserEventTime(uint32_t& aTime) { aTime = gLastUserEventTime; + return NS_OK; } void @@ -1169,7 +1238,7 @@ nsViewManager::InvalidateHierarchy() } 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"); diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h new file mode 100644 index 000000000000..7315a3bd6683 --- /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 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___ */ diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 7d42ad969b03..6c86c30ccdab 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -23,7 +23,7 @@ using mozilla::unused; #include "nsIObserverService.h" #include "nsFocusManager.h" #include "nsIWidgetListener.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsRenderingContext.h" #include "nsIDOMSimpleGestureEvent.h" diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 71ea4e226fa8..0f84ca234fec 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -23,7 +23,7 @@ #include "nsFontMetrics.h" #include "nsIRollupListener.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIInterfaceRequestor.h" #include "nsIFile.h" #include "nsILocalFileMac.h" diff --git a/widget/gtk2/nsDragService.cpp b/widget/gtk2/nsDragService.cpp index 73900e74ffed..2f98d290ca39 100644 --- a/widget/gtk2/nsDragService.cpp +++ b/widget/gtk2/nsDragService.cpp @@ -31,7 +31,7 @@ #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 @@ -269,7 +269,7 @@ GetGtkWindow(nsIDOMDocument *aDocument) if (!presShell) return NULL; - nsRefPtr vm = presShell->GetViewManager(); + nsCOMPtr vm = presShell->GetViewManager(); if (!vm) return NULL; diff --git a/widget/gtk2/nsNativeThemeGTK.cpp b/widget/gtk2/nsNativeThemeGTK.cpp index 35b786aec4c5..59132735dada 100644 --- a/widget/gtk2/nsNativeThemeGTK.cpp +++ b/widget/gtk2/nsNativeThemeGTK.cpp @@ -12,7 +12,7 @@ #include "nsIFrame.h" #include "nsIPresShell.h" #include "nsIContent.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsINameSpaceManager.h" #include "nsGfxCIID.h" #include "nsTransform2D.h" @@ -75,7 +75,7 @@ nsNativeThemeGTK::RefreshWidgetWindow(nsIFrame* aFrame) if (!shell) return; - nsViewManager* vm = shell->GetViewManager(); + nsIViewManager* vm = shell->GetViewManager(); if (!vm) return; diff --git a/widget/tests/TestWinTSF.cpp b/widget/tests/TestWinTSF.cpp index e9f4cc049911..150c72c075a6 100644 --- a/widget/tests/TestWinTSF.cpp +++ b/widget/tests/TestWinTSF.cpp @@ -65,7 +65,7 @@ template class nsReadingIterator; #include "nsIDOMHTMLTextAreaElement.h" #include "nsIDOMElement.h" #include "nsISelectionController.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsTArray.h" #include "nsGUIEvent.h" @@ -3144,7 +3144,7 @@ TestApp::GetWidget(nsIWidget** aWidget) return false; } - nsRefPtr viewManager = presShell->GetViewManager(); + nsCOMPtr viewManager = presShell->GetViewManager(); if (!viewManager) { return false; } diff --git a/widget/xpwidgets/nsBaseDragService.cpp b/widget/xpwidgets/nsBaseDragService.cpp index 60c677fb00e3..df2bb433365b 100644 --- a/widget/xpwidgets/nsBaseDragService.cpp +++ b/widget/xpwidgets/nsBaseDragService.cpp @@ -18,7 +18,7 @@ #include "nsIDocument.h" #include "nsIContent.h" #include "nsIPresShell.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIDOMNode.h" #include "nsIDOMDragEvent.h" #include "nsISelection.h"