Back out 5e76dfb1d426 (bug 826635) and 0df74b1a4543:20df426b6111 (bug 826632) for bustage

CLOSED TREE
This commit is contained in:
Phil Ringnalda 2013-01-04 21:30:14 -08:00
parent f34bb3f29c
commit d44dff5096
78 changed files with 677 additions and 478 deletions

View File

@ -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;

View File

@ -10,7 +10,7 @@
#include "nsCOMPtr.h"
#include "nsObjCExceptions.h"
#include "nsIWidget.h"
#include "nsViewManager.h"
#include "nsIViewManager.h"
using namespace mozilla::a11y;

View File

@ -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<nsIWidget> rootWidget;
vm->GetRootWidget(getter_AddRefs(rootWidget));

View File

@ -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;

View File

@ -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;

View File

@ -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 */

View File

@ -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 */

View File

@ -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<nsIWidget> 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);

View File

@ -34,7 +34,7 @@ class nsIParser;
class nsIAtom;
class nsIChannel;
class nsIContent;
class nsViewManager;
class nsIViewManager;
class nsNodeInfoManager;
class nsScriptLoader;
class nsIApplicationCache;

View File

@ -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);
}

View File

@ -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)
{

View File

@ -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);

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -305,7 +305,7 @@ nsHTMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
nsresult
nsHTMLDocument::CreateShell(nsPresContext* aContext,
nsViewManager* aViewManager,
nsIViewManager* aViewManager,
nsStyleSet* aStyleSet,
nsIPresShell** aInstancePtrResult)
{

View File

@ -55,7 +55,7 @@ public:
nsIPrincipal* aPrincipal);
virtual nsresult CreateShell(nsPresContext* aContext,
nsViewManager* aViewManager,
nsIViewManager* aViewManager,
nsStyleSet* aStyleSet,
nsIPresShell** aInstancePtrResult);

View File

@ -22,7 +22,7 @@ class nsIURI;
class nsIContent;
class nsINodeInfo;
class nsIParser;
class nsViewManager;
class nsIViewManager;
typedef enum {
eXMLContentSinkState_InProlog,

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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<nsIDOMWindow> domwin(doc->GetWindow());
nsCOMPtr<nsIWidget> 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<nsIPresShell> presShell =GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsViewManager* viewManager = presShell->GetViewManager();
nsIViewManager* viewManager = presShell->GetViewManager();
NS_ENSURE_TRUE(viewManager, NS_ERROR_FAILURE);
viewManager->InvalidateAllViews();
NS_ENSURE_SUCCESS(viewManager->InvalidateAllViews(), NS_ERROR_FAILURE);
return NS_OK;
}
@ -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<nsIPresShell> 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<nsIPresShell> shell = GetPresShell();
nsViewManager *newVM = shell ? shell->GetViewManager() : nullptr;
nsIViewManager *newVM = shell ? shell->GetViewManager() : nullptr;
nsView *newRootView = newVM ? newVM->GetRootView() : nullptr;
// Insert the new root view at the correct location in the view tree.
@ -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

View File

@ -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<nsIPresShell> presShell = presContext->PresShell();
if (!presShell)
return NS_ERROR_FAILURE;
nsViewManager* viewManager = presShell->GetViewManager();
nsIViewManager* viewManager = presShell->GetViewManager();
if (!viewManager)
return NS_ERROR_FAILURE;
nsView* view = viewManager->GetRootView();

View File

@ -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<nsIPresShell> presShell = docShell->GetPresShell();
if (presShell) {
nsViewManager* vm = presShell->GetViewManager();
nsIViewManager* vm = presShell->GetViewManager();
if (vm) {
nsCOMPtr<nsIWidget> 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<nsIWidget> 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<nsIWidget> 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<nsIWidget> 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<nsIWidget> widget;
vm->GetRootWidget(getter_AddRefs(widget));

View File

@ -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<nsIPresShell> presShell = mDocShell->GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsViewManager* vm = presShell->GetViewManager();
nsIViewManager* vm = presShell->GetViewManager();
NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
nsView* rootView = vm->GetRootView();

View File

@ -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<nsIWidget> widget;
vm->GetRootWidget(getter_AddRefs(widget));
if (widget) {

View File

@ -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<nsIWidget> widget;
vm->GetRootWidget(getter_AddRefs(widget));
nsresult rv = vm->GetRootWidget(getter_AddRefs(widget));
if (widget) {
*pvalue = (void*)widget->GetNativeData(NS_NATIVE_WINDOW);
} else {
NS_ASSERTION(widget, "couldn't get doc's widget in getting doc's window handle");
}
return NS_OK;
return rv;
#elif (defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT)) && defined(MOZ_X11)
// X11 window managers want the toplevel window for WM_TRANSIENT_FOR.
nsIWidget* win = mObjectFrame->GetNearestWidget();

View File

@ -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) {

View File

@ -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<nsIWidget> mWidget;
nsRefPtr<nsViewManager> mViewManager;
nsCOMPtr<nsIViewManager> mViewManager;
nsCOMPtr<nsITimer> mTimer;
};

View File

@ -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<nsViewManager> vm = mPresShell->GetViewManager();
nsCOMPtr<nsIViewManager> vm = mPresShell->GetViewManager();
// Processing the style changes could cause a flush that propagates to
// the parent frame and thus destroys the pres shell.

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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<nsIDocument> mDocument;
nsCOMPtr<nsIWidget> mWindow; // may be null
nsRefPtr<nsViewManager> mViewManager;
nsCOMPtr<nsIViewManager> mViewManager;
nsRefPtr<nsPresContext> mPresContext;
nsCOMPtr<nsIPresShell> 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)
{

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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<nsViewManager> viewManagerDeathGrip = mViewManager;
nsCOMPtr<nsIViewManager> viewManagerDeathGrip = mViewManager;
// Take this ref after viewManager so it'll make sure to go away first
nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
@ -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<nsViewManager> viewManagerDeathGrip = mViewManager;
nsCOMPtr<nsIViewManager> viewManagerDeathGrip = mViewManager;
if (isSafeToFlush && mViewManager) {
// Processing pending notifications can kill us, and some callers only
// hold weak refs when calling FlushPendingNotifications(). :(
@ -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<nsViewManager> vm = new nsViewManager();
nsCOMPtr<nsIViewManager> vm = do_CreateInstance(kViewManagerCID);
NS_ENSURE_TRUE(vm, false);
rv = vm->Init(dc);
NS_ENSURE_SUCCESS(rv, false);

View File

@ -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();

View File

@ -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<nsViewManager> vm = mPresContext->GetPresShell()->GetViewManager();
nsCOMPtr<nsIViewManager> vm = mPresContext->GetPresShell()->GetViewManager();
vm->ProcessPendingUpdates();
#ifdef DEBUG_INVALIDATIONS
printf("Ending ProcessPendingUpdates\n");

View File

@ -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 },

View File

@ -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);

View File

@ -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"

View File

@ -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"

View File

@ -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();

View File

@ -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);
}
}

View File

@ -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"

View File

@ -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"

View File

@ -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);
}

View File

@ -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");

View File

@ -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) {

View File

@ -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<nsPresContext> mPresContext;
nsCOMPtr<nsIPresShell> mPresShell;
nsRefPtr<nsViewManager> mViewManager;
nsCOMPtr<nsIViewManager> mViewManager;
nsCOMPtr<nsIContent> mContent;
PrintObjectType mFrameType;

View File

@ -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<nsIPresShell> shell(pres_shell(aDocShell));
@ -433,7 +433,7 @@ DumpViewsRecur(nsIDocShell* aDocShell, FILE* out)
{
#ifdef DEBUG
fprintf(out, "docshell=%p \n", static_cast<void*>(aDocShell));
nsRefPtr<nsViewManager> vm(view_manager(aDocShell));
nsCOMPtr<nsIViewManager> vm(view_manager(aDocShell));
if (vm) {
nsView* root = vm->GetRootView();
if (root) {
@ -524,7 +524,7 @@ nsLayoutDebuggingTools::DumpReflowStats()
void nsLayoutDebuggingTools::ForceRefresh()
{
nsRefPtr<nsViewManager> vm(view_manager(mDocShell));
nsCOMPtr<nsIViewManager> vm(view_manager(mDocShell));
if (!vm)
return;
nsView* root = vm->GetRootView();

View File

@ -25,7 +25,7 @@
#include "nsLayoutCID.h"
#include "nsNetUtil.h"
#include "nsIFile.h"
#include "nsViewManager.h"
#include "nsIViewManager.h"
#include "nsView.h"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -90,7 +90,7 @@ enum FlipStyle {
nsIFrame* NS_NewMenuPopupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
class nsViewManager;
class nsIViewManager;
class nsView;
class nsMenuPopupFrame;

View File

@ -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<nsIPresShell> shell = presContext->PresShell();
nsRefPtr<nsViewManager> kungFuDeathGrip = shell->GetViewManager();
nsCOMPtr<nsIViewManager> kungFuDeathGrip = shell->GetViewManager();
// Deselect ourselves.
if (mCloseMenuMode != CloseMenuMode_None)

View File

@ -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"

View File

@ -14,7 +14,8 @@ MODULE = view
EXPORTS = \
nsView.h \
nsViewManager.h \
nsIViewManager.h \
nsViewsCID.h \
nsIScrollPositionListener.h \
$(NULL)

View File

@ -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<nsViewManager> mRootVM;
nsCOMPtr<nsIViewManager> 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<nsDeviceContext> mContext;
nsIPresShell *mPresShell;
// The size for a resize that we delayed until the root view becomes
// visible again.
nsSize mDelayedResize;
nsView *mRootView;
// mRootViewManager is a strong ref unless it equals |this|. It's
// never null (if we have no ancestors, it will be |this|).
nsViewManager *mRootViewManager;
// The following members should not be accessed directly except by
// the root view manager. Some have accessor functions to enforce
// this, as noted.
int32_t mRefreshDisableCount;
// Use IsPainting() and SetPainting() to access mPainting.
bool mPainting;
bool mRecursiveRefreshPending;
bool mHasPendingWidgetGeometryChanges;
bool mInScroll;
//from here to public should be static and locked... MMP
static int32_t mVMCount; //number of viewmanagers
//list of view managers
static nsVoidArray *gViewManagers;
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___

View File

@ -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 <stdio.h>
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<nsIViewManager*>(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

17
view/public/nsViewsCID.h Normal file
View File

@ -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__

View File

@ -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<nsViewManager> vm = mViewManager;
nsCOMPtr<nsViewManager> 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<nsViewManager> vm = mViewManager;
nsCOMPtr<nsViewManager> vm = mViewManager;
bool result = vm->PaintWindow(aWidget, aRegion, aFlags);
// PaintWindow can destroy this via WillPaintWindow notification, so we have
// to re-get the view from the widget.
@ -977,7 +977,7 @@ nsView::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, uint32_t aFlags)
void
nsView::DidPaintWindow()
{
nsRefPtr<nsViewManager> vm = mViewManager;
nsCOMPtr<nsViewManager> vm = mViewManager;
vm->DidPaintWindow();
}
@ -1006,7 +1006,7 @@ nsView::HandleEvent(nsGUIEvent* aEvent, bool aUseAttachedEvents)
}
if (view) {
nsRefPtr<nsViewManager> vm = view->GetViewManager();
nsCOMPtr<nsIViewManager> vm = view->GetViewManager();
vm->DispatchEvent(aEvent, view, &result);
}

View File

@ -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<nsViewManager> rootVM = RootViewManager();
rootVM->CallWillPaintOnObservers(aWillSendDidPaint);
// Flush view widget geometry updates and invalidations.
rootVM->ProcessPendingUpdates();
}
if (aWidget && IsRefreshDriverPaintingEnabled()) {
nsView* view = nsView::GetViewFor(aWidget);
if (view && view->ForcedRepaint()) {
ProcessPendingUpdates();
@ -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<nsIPresShell> shell = view->GetViewManager()->GetPresShell();
if (shell) {
shell->HandleEvent(frame, aEvent, false, aStatus);
return shell->HandleEvent(frame, aEvent, false, aStatus);
}
}
*aStatus = nsEventStatus_eIgnore;
return NS_OK;
}
// Recursively reparent widgets if necessary
@ -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");

214
view/src/nsViewManager.h Normal file
View File

@ -0,0 +1,214 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsViewManager_h___
#define nsViewManager_h___
#include "nsCOMPtr.h"
#include "nsIViewManager.h"
#include "nsCRT.h"
#include "nsITimer.h"
#include "prtime.h"
#include "prinrval.h"
#include "nsVoidArray.h"
#include "nsThreadUtils.h"
#include "nsIPresShell.h"
#include "nsDeviceContext.h"
/**
Invalidation model:
1) Callers call into the view manager and ask it to invalidate a view.
2) The view manager finds the "right" widget for the view, henceforth called
the root widget.
3) The view manager traverses descendants of the root widget and for each
one that needs invalidation stores the rect to invalidate on the widget's
view (batching).
4) The dirty region is flushed to the right widget when
ProcessPendingUpdates is called from the RefreshDriver.
It's important to note that widgets associated to views outside this view
manager can end up being invalidated during step 3. Therefore, the end of a
view update batch really needs to traverse the entire view tree, to ensure
that those invalidates happen.
To cope with this, invalidation processing and should only happen on the
root viewmanager.
*/
class nsViewManager : public nsIViewManager {
public:
nsViewManager();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsDeviceContext* aContext);
NS_IMETHOD_(nsView*) CreateView(const nsRect& aBounds,
const nsView* aParent,
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
NS_IMETHOD_(nsView*) GetRootView();
NS_IMETHOD SetRootView(nsView *aView);
NS_IMETHOD GetWindowDimensions(nscoord *width, nscoord *height);
NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height);
NS_IMETHOD FlushDelayedResize(bool aDoReflow);
NS_IMETHOD InvalidateView(nsView *aView);
NS_IMETHOD InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect);
NS_IMETHOD InvalidateAllViews();
NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent,
nsView* aTargetView, nsEventStatus* aStatus);
NS_IMETHOD InsertChild(nsView *parent, nsView *child, nsView *sibling,
bool above);
NS_IMETHOD InsertChild(nsView *parent, nsView *child,
int32_t zindex);
NS_IMETHOD RemoveChild(nsView *parent);
NS_IMETHOD MoveViewTo(nsView *aView, nscoord aX, nscoord aY);
NS_IMETHOD ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExposedAreaOnly = false);
NS_IMETHOD SetViewFloating(nsView *aView, bool aFloating);
NS_IMETHOD SetViewVisibility(nsView *aView, nsViewVisibility aVisible);
NS_IMETHOD SetViewZIndex(nsView *aView, bool aAuto, int32_t aZIndex, bool aTopMost=false);
virtual void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; }
virtual nsIPresShell* GetPresShell() { return mPresShell; }
NS_IMETHOD GetDeviceContext(nsDeviceContext *&aContext);
virtual nsIViewManager* IncrementDisableRefreshCount();
virtual void DecrementDisableRefreshCount();
NS_IMETHOD GetRootWidget(nsIWidget **aWidget);
NS_IMETHOD IsPainting(bool& aIsPainting);
NS_IMETHOD GetLastUserEventTime(uint32_t& aTime);
static uint32_t gLastUserEventTime;
/* Update the cached RootViewManager pointer on this view manager. */
void InvalidateHierarchy();
virtual void ProcessPendingUpdates();
virtual void UpdateWidgetGeometry();
protected:
virtual ~nsViewManager();
private:
void FlushPendingInvalidates();
void ProcessPendingUpdatesForView(nsView *aView,
bool aFlushDirtyRegion = true);
void FlushDirtyRegionToWidget(nsView* aView);
/**
* Call WillPaint() on all view observers under this vm root.
*/
void CallWillPaintOnObservers(bool aWillSendDidPaint);
void ReparentChildWidgets(nsView* aView, nsIWidget *aNewWidget);
void ReparentWidgets(nsView* aView, nsView *aParent);
void InvalidateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedRegion);
void InvalidateViews(nsView *aView);
// aView is the view for aWidget and aRegion is relative to aWidget.
void Refresh(nsView *aView, const nsIntRegion& aRegion, bool aWillSendDidPaint);
void InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut);
void InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut,
nscoord aY1, nscoord aY2, bool aInCutOut);
// Utilities
bool IsViewInserted(nsView *aView);
/**
* Intersects aRect with aView's bounds and then transforms it from aView's
* coordinate system to the coordinate system of the widget attached to
* aView.
*/
nsIntRect ViewToWidget(nsView *aView, const nsRect &aRect) const;
void DoSetWindowDimensions(nscoord aWidth, nscoord aHeight);
bool IsPainting() const {
return RootViewManager()->mPainting;
}
void SetPainting(bool aPainting) {
RootViewManager()->mPainting = aPainting;
}
nsresult InvalidateView(nsView *aView, const nsRect &aRect);
public: // NOT in nsIViewManager, so private to the view module
nsView* GetRootViewImpl() const { return mRootView; }
nsViewManager* RootViewManager() const { return mRootViewManager; }
bool IsRootVM() const { return this == RootViewManager(); }
// Whether synchronous painting is allowed at the moment. For example,
// widget geometry changes can cause synchronous painting, so they need to
// be deferred while refresh is disabled.
bool IsPaintingAllowed() { return RootViewManager()->mRefreshDisableCount == 0; }
void WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint);
bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion,
uint32_t aFlags);
void DidPaintWindow();
// Call this when you need to let the viewmanager know that it now has
// pending updates.
void PostPendingUpdate();
uint32_t AppUnitsPerDevPixel() const
{
return mContext->AppUnitsPerDevPixel();
}
private:
nsRefPtr<nsDeviceContext> mContext;
nsIPresShell *mPresShell;
// The size for a resize that we delayed until the root view becomes
// visible again.
nsSize mDelayedResize;
nsView *mRootView;
// mRootViewManager is a strong ref unless it equals |this|. It's
// never null (if we have no ancestors, it will be |this|).
nsViewManager *mRootViewManager;
// The following members should not be accessed directly except by
// the root view manager. Some have accessor functions to enforce
// this, as noted.
int32_t mRefreshDisableCount;
// Use IsPainting() and SetPainting() to access mPainting.
bool mPainting;
bool mRecursiveRefreshPending;
bool mHasPendingWidgetGeometryChanges;
bool mInScroll;
//from here to public should be static and locked... MMP
static int32_t mVMCount; //number of viewmanagers
//list of view managers
static nsVoidArray *gViewManagers;
};
#endif /* nsViewManager_h___ */

View File

@ -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"

View File

@ -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"

View File

@ -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<nsViewManager> vm = presShell->GetViewManager();
nsCOMPtr<nsIViewManager> vm = presShell->GetViewManager();
if (!vm)
return NULL;

View File

@ -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;

View File

@ -65,7 +65,7 @@ template<class T> 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<nsViewManager> viewManager = presShell->GetViewManager();
nsCOMPtr<nsIViewManager> viewManager = presShell->GetViewManager();
if (!viewManager) {
return false;
}

View File

@ -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"