2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2013-01-05 07:12:24 +04:00
|
|
|
#ifndef nsViewManager_h___
|
|
|
|
#define nsViewManager_h___
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
#include "nscore.h"
|
2013-01-03 17:23:11 +04:00
|
|
|
#include "nsView.h"
|
2001-12-01 17:31:45 +03:00
|
|
|
#include "nsEvent.h"
|
2013-01-05 07:12:24 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsVoidArray.h"
|
|
|
|
#include "nsDeviceContext.h"
|
1998-05-19 01:46:20 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
class nsIWidget;
|
|
|
|
struct nsRect;
|
2002-08-30 07:32:05 +04:00
|
|
|
class nsRegion;
|
2011-04-17 05:22:44 +04:00
|
|
|
class nsDeviceContext;
|
2012-08-06 07:00:56 +04:00
|
|
|
class nsIPresShell;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2013-01-05 07:13:05 +04:00
|
|
|
class nsViewManager MOZ_FINAL
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
public:
|
2013-01-05 07:12:24 +04:00
|
|
|
friend class nsView;
|
2013-01-05 07:12:24 +04:00
|
|
|
|
2013-01-05 07:12:24 +04:00
|
|
|
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
|
|
|
|
2013-01-05 07:12:57 +04:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsViewManager)
|
2013-01-05 07:12:24 +04:00
|
|
|
|
|
|
|
nsViewManager();
|
2013-01-05 07:13:05 +04:00
|
|
|
~nsViewManager();
|
2013-01-05 07:12:24 +04:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
|
|
|
* Initialize the ViewManager
|
2011-11-21 21:53:20 +04:00
|
|
|
* Note: this instance does not hold a reference to the presshell
|
1998-08-28 07:05:23 +04:00
|
|
|
* because it holds a reference to this instance.
|
2004-05-17 20:29:13 +04:00
|
|
|
* @result The result of the initialization, NS_OK if no errors
|
1998-04-16 00:25:02 +04:00
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
nsresult Init(nsDeviceContext* aContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-11-04 18:06:50 +03:00
|
|
|
/**
|
|
|
|
* Create an ordinary view
|
|
|
|
* @param aBounds initial bounds for view
|
|
|
|
* XXX We should eliminate this parameter; you can set the bounds after CreateView
|
|
|
|
* @param aParent intended parent for view. this is not actually set in the
|
2013-01-03 17:23:11 +04:00
|
|
|
* nsView through this method. it is only used by the initialization
|
2004-11-04 18:06:50 +03:00
|
|
|
* code to walk up the view tree, if necessary, to find resources.
|
|
|
|
* XXX We should eliminate this parameter!
|
|
|
|
* @param aVisibilityFlag initial visibility state of view
|
|
|
|
* XXX We should eliminate this parameter; you can set it after CreateView
|
|
|
|
* @result The new view
|
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
nsView* CreateView(const nsRect& aBounds,
|
|
|
|
const nsView* aParent,
|
|
|
|
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
|
2004-11-04 18:06:50 +03:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
|
|
|
* Get the root of the view tree.
|
|
|
|
* @result the root view
|
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
nsView* GetRootView() { return mRootView; }
|
2004-05-17 20:29:13 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the root of the view tree. Does not destroy the current root view.
|
|
|
|
* aView may have a parent view managed by a different view manager.
|
|
|
|
* aView may have a widget (anything but printing) or may not (printing).
|
|
|
|
* @param aView view to set as root
|
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void SetRootView(nsView *aView);
|
2004-05-17 20:29:13 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the dimensions of the root window. The dimensions are in
|
|
|
|
* twips
|
|
|
|
* @param aWidth out parameter for width of window in twips
|
|
|
|
* @param aHeight out parameter for height of window in twips
|
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void GetWindowDimensions(nscoord *aWidth, nscoord *aHeight);
|
1998-04-16 00:25:02 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the dimensions of the root window.
|
|
|
|
* Called if the root window is resized. The dimensions are in
|
|
|
|
* twips
|
2001-12-01 17:31:45 +03:00
|
|
|
* @param aWidth of window in twips
|
|
|
|
* @param aHeight of window in twips
|
1998-05-08 21:50:43 +04:00
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void SetWindowDimensions(nscoord aWidth, nscoord aHeight);
|
1998-05-08 21:50:43 +04:00
|
|
|
|
2008-09-09 17:43:10 +04:00
|
|
|
/**
|
|
|
|
* Do any resizes that are pending.
|
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void FlushDelayedResize(bool aDoReflow);
|
2008-09-09 17:43:10 +04:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
1999-11-14 05:51:25 +03:00
|
|
|
* Called to inform the view manager that the entire area of a view
|
|
|
|
* is dirty and needs to be redrawn.
|
1998-04-16 00:25:02 +04:00
|
|
|
* @param aView view to paint. should be root view
|
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void InvalidateView(nsView *aView);
|
1998-04-16 00:25:02 +04:00
|
|
|
|
|
|
|
/**
|
2010-08-19 05:16:58 +04:00
|
|
|
* Called to inform the view manager that some portion of a view is dirty and
|
|
|
|
* needs to be redrawn. The rect passed in should be in the view's coordinate
|
|
|
|
* space. Does not check for paint suppression.
|
1998-04-16 00:25:02 +04:00
|
|
|
* @param aView view to paint. should be root view
|
|
|
|
* @param rect rect to mark as damaged
|
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-09-19 04:51:41 +04:00
|
|
|
/**
|
2011-12-24 07:52:25 +04:00
|
|
|
* Called to inform the view manager that it should invalidate all views.
|
1999-09-19 04:51:41 +04:00
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void InvalidateAllViews();
|
1999-09-19 04:51:41 +04:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
|
|
|
* Called to dispatch an event to the appropriate view. Often called
|
|
|
|
* as a result of receiving a mouse or keyboard event from the widget
|
|
|
|
* event system.
|
2009-07-22 04:44:59 +04:00
|
|
|
* @param aEvent event to dispatch
|
|
|
|
* @param aViewTarget dispatch the event to this view
|
|
|
|
* @param aStatus event handling status
|
1998-04-16 00:25:02 +04:00
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void DispatchEvent(nsGUIEvent *aEvent,
|
2013-01-05 07:12:24 +04:00
|
|
|
nsView* aViewTarget, nsEventStatus* aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
2001-12-01 17:31:45 +03:00
|
|
|
* Given a parent view, insert another view as its child.
|
|
|
|
* aSibling and aAbove control the "document order" for the insertion.
|
|
|
|
* If aSibling is null, the view is inserted at the end of the document order
|
2011-10-17 18:59:28 +04:00
|
|
|
* if aAfter is true, otherwise it is inserted at the beginning.
|
|
|
|
* If aSibling is non-null, then if aAfter is true, the view is inserted
|
2001-12-01 17:31:45 +03:00
|
|
|
* after the sibling in document order (appearing above the sibling unless
|
|
|
|
* overriden by z-order).
|
2011-10-17 18:59:28 +04:00
|
|
|
* If it is false, the view is inserted before the sibling.
|
1998-04-16 00:25:02 +04:00
|
|
|
* The view manager generates the appopriate dirty regions.
|
2001-12-01 17:31:45 +03:00
|
|
|
* @param aParent parent view
|
|
|
|
* @param aChild child view
|
|
|
|
* @param aSibling sibling view
|
|
|
|
* @param aAfter after or before in the document order
|
1998-04-16 00:25:02 +04:00
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling,
|
|
|
|
bool aAfter);
|
2013-01-05 07:12:24 +04:00
|
|
|
|
2013-01-05 07:13:05 +04:00
|
|
|
void InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
2001-12-01 17:31:45 +03:00
|
|
|
* Remove a specific child view from its parent. This will NOT remove its placeholder
|
|
|
|
* if there is one.
|
|
|
|
* The view manager generates the appropriate dirty regions.
|
|
|
|
* @param aParent parent view
|
|
|
|
* @param aChild child view
|
1998-04-16 00:25:02 +04:00
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void RemoveChild(nsView *aChild);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
2001-12-01 17:31:45 +03:00
|
|
|
* Move a view to the specified position, provided in parent coordinates.
|
|
|
|
* The new position is the (0, 0) origin for the view's coordinate system.
|
|
|
|
* The view's bounds may extend above or to the left of this point.
|
|
|
|
* The view manager generates the appropriate dirty regions.
|
1998-04-16 00:25:02 +04:00
|
|
|
* @param aView view to move
|
2001-12-01 17:31:45 +03:00
|
|
|
* @param aX x value for new view position
|
|
|
|
* @param aY y value for new view position
|
1998-04-16 00:25:02 +04:00
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void MoveViewTo(nsView *aView, nscoord aX, nscoord aY);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
2001-12-01 17:31:45 +03:00
|
|
|
* Resize a view. In addition to setting the width and height, you can
|
|
|
|
* set the x and y of its bounds relative to its position. Negative x and y
|
|
|
|
* will let the view extend above and to the left of the (0,0) point in its
|
|
|
|
* coordinate system.
|
|
|
|
* The view manager generates the appropriate dirty regions.
|
1998-04-16 00:25:02 +04:00
|
|
|
* @param aView view to move
|
2001-12-01 17:31:45 +03:00
|
|
|
* @param the new bounds relative to the current position
|
|
|
|
* @param RepaintExposedAreaOnly
|
2011-10-17 18:59:28 +04:00
|
|
|
* if true Repaint only the expanded or contracted region,
|
|
|
|
* if false Repaint the union of the old and new rectangles.
|
2001-12-01 17:31:45 +03:00
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void ResizeView(nsView *aView, const nsRect &aRect,
|
|
|
|
bool aRepaintExposedAreaOnly = false);
|
2001-12-01 17:31:45 +03:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
2009-07-30 06:54:42 +04:00
|
|
|
* Set the visibility of a view. Hidden views have the effect of hiding
|
|
|
|
* their descendants as well. This does not affect painting, so layout
|
|
|
|
* is responsible for ensuring that content in hidden views is not
|
|
|
|
* painted nor handling events. It does affect the visibility of widgets;
|
|
|
|
* if a view is hidden, descendant views with widgets have their widgets
|
|
|
|
* hidden.
|
2001-12-01 17:31:45 +03:00
|
|
|
* The view manager generates the appropriate dirty regions.
|
1998-04-16 00:25:02 +04:00
|
|
|
* @param aView view to change visibility state of
|
|
|
|
* @param visible new visibility state
|
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void SetViewVisibility(nsView *aView, nsViewVisibility aVisible);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
|
|
|
* Set the z-index of a view. Positive z-indices mean that a view
|
|
|
|
* is above its parent in z-order. Negative z-indices mean that a
|
|
|
|
* view is below its parent.
|
2001-12-01 17:31:45 +03:00
|
|
|
* The view manager generates the appropriate dirty regions.
|
|
|
|
* @param aAutoZIndex indicate that the z-index of a view is "auto". An "auto" z-index
|
2001-11-24 08:37:25 +03:00
|
|
|
* means that the view does not define a new stacking context,
|
|
|
|
* which means that the z-indicies of the view's children are
|
|
|
|
* relative to the view's siblings.
|
|
|
|
* @param aView view to change z depth of
|
2002-07-02 16:50:14 +04:00
|
|
|
* @param aZindex explicit z depth
|
|
|
|
* @param aTopMost used when this view is z-index:auto to compare against
|
|
|
|
* other z-index:auto views.
|
2011-10-17 18:59:28 +04:00
|
|
|
* true if the view should be topmost when compared with
|
2002-07-02 16:50:14 +04:00
|
|
|
* other z-index:auto views.
|
1998-04-16 00:25:02 +04:00
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZindex, bool aTopMost = false);
|
1998-04-16 00:25:02 +04:00
|
|
|
|
|
|
|
/**
|
2001-12-01 17:31:45 +03:00
|
|
|
* Set whether the view "floats" above all other views,
|
|
|
|
* which tells the compositor not to consider higher views in
|
|
|
|
* the view hierarchy that would geometrically intersect with
|
|
|
|
* this view. This is a hack, but it fixes some problems with
|
|
|
|
* views that need to be drawn in front of all other views.
|
1998-04-16 00:25:02 +04:00
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void SetViewFloating(nsView *aView, bool aFloatingView);
|
2001-11-22 08:26:32 +03:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
2011-11-21 21:53:20 +04:00
|
|
|
* Set the presshell associated with this manager
|
|
|
|
* @param aPresShell - new presshell
|
1998-04-16 00:25:02 +04:00
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; }
|
1998-08-28 07:05:23 +04:00
|
|
|
|
|
|
|
/**
|
2011-11-21 21:53:20 +04:00
|
|
|
* Get the pres shell associated with this manager
|
1998-08-28 07:05:23 +04:00
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
nsIPresShell* GetPresShell() { return mPresShell; }
|
1998-08-28 07:05:23 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the device context associated with this manager
|
|
|
|
* @result device context
|
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void GetDeviceContext(nsDeviceContext *&aContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-05-27 01:13:06 +04:00
|
|
|
/**
|
2011-12-24 07:52:23 +04:00
|
|
|
* A stack class for disallowing changes that would enter painting. For
|
|
|
|
* example, popup widgets shouldn't be resized during reflow, since doing so
|
|
|
|
* might cause synchronous painting inside reflow which is forbidden.
|
|
|
|
* While refresh is disabled, widget geometry changes are deferred and will
|
|
|
|
* be handled later, either from the refresh driver or from an NS_WILL_PAINT
|
|
|
|
* event.
|
|
|
|
* We don't want to defer widget geometry changes all the time. Resizing a
|
|
|
|
* popup from script doesn't need to be deferred, for example, especially
|
|
|
|
* since popup widget geometry is observable from script and expected to
|
|
|
|
* update synchronously.
|
1999-05-27 01:13:06 +04:00
|
|
|
*/
|
2011-12-24 07:52:23 +04:00
|
|
|
class NS_STACK_CLASS AutoDisableRefresh {
|
|
|
|
public:
|
2013-01-05 07:12:24 +04:00
|
|
|
AutoDisableRefresh(nsViewManager* aVM) {
|
2008-01-27 02:59:50 +03:00
|
|
|
if (aVM) {
|
2011-12-24 07:52:23 +04:00
|
|
|
mRootVM = aVM->IncrementDisableRefreshCount();
|
2008-01-27 02:59:50 +03:00
|
|
|
}
|
|
|
|
}
|
2011-12-24 07:52:23 +04:00
|
|
|
~AutoDisableRefresh() {
|
|
|
|
if (mRootVM) {
|
|
|
|
mRootVM->DecrementDisableRefreshCount();
|
2008-01-27 02:59:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
private:
|
2011-12-24 07:52:23 +04:00
|
|
|
AutoDisableRefresh(const AutoDisableRefresh& aOther);
|
|
|
|
const AutoDisableRefresh& operator=(const AutoDisableRefresh& aOther);
|
2008-01-27 02:59:50 +03:00
|
|
|
|
2013-01-05 07:12:42 +04:00
|
|
|
nsRefPtr<nsViewManager> mRootVM;
|
2008-01-27 02:59:50 +03:00
|
|
|
};
|
2011-12-24 07:52:23 +04:00
|
|
|
|
2008-01-27 02:59:50 +03:00
|
|
|
private:
|
2011-12-24 07:52:23 +04:00
|
|
|
friend class AutoDisableRefresh;
|
2008-01-27 02:59:50 +03:00
|
|
|
|
2013-01-05 07:13:05 +04:00
|
|
|
nsViewManager* IncrementDisableRefreshCount();
|
|
|
|
void DecrementDisableRefreshCount();
|
1999-05-27 01:13:06 +04:00
|
|
|
|
2008-01-27 02:59:50 +03:00
|
|
|
public:
|
2009-07-22 04:45:03 +04:00
|
|
|
/**
|
|
|
|
* Retrieve the widget at the root of the nearest enclosing
|
|
|
|
* view manager whose root view has a widget.
|
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void GetRootWidget(nsIWidget **aWidget);
|
2009-07-22 04:45:03 +04:00
|
|
|
|
2000-10-17 09:03:45 +04:00
|
|
|
/**
|
2001-01-20 07:59:39 +03:00
|
|
|
* Indicate whether the viewmanager is currently painting
|
2000-10-17 09:03:45 +04:00
|
|
|
*
|
2011-10-17 18:59:28 +04:00
|
|
|
* @param aPainting true if the viewmanager is painting
|
|
|
|
* false otherwise
|
2000-10-17 09:03:45 +04:00
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void IsPainting(bool& aIsPainting);
|
2000-10-17 09:03:45 +04:00
|
|
|
|
2001-06-29 08:01:26 +04:00
|
|
|
/**
|
|
|
|
* Retrieve the time of the last user event. User events
|
|
|
|
* include mouse and keyboard events. The viewmanager
|
|
|
|
* saves the time of the last user event.
|
|
|
|
*
|
|
|
|
* @param aTime Last user event time in microseconds
|
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void GetLastUserEventTime(uint32_t& aTime);
|
2011-05-30 07:15:00 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the nearest display root view for the view aView. This is the view for
|
|
|
|
* the nearest enclosing popup or the root view for the root document.
|
|
|
|
*/
|
2013-01-03 17:23:11 +04:00
|
|
|
static nsView* GetDisplayRootFor(nsView* aView);
|
2011-12-24 07:52:22 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flush the accumulated dirty region to the widget and update widget
|
|
|
|
* geometry.
|
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void ProcessPendingUpdates();
|
2011-12-24 07:52:23 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Just update widget geometry without flushing the dirty region
|
|
|
|
*/
|
2013-01-05 07:13:05 +04:00
|
|
|
void UpdateWidgetGeometry();
|
2013-01-05 07:12:24 +04:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2013-01-28 23:34:08 +04:00
|
|
|
void CallWillPaintOnObservers();
|
2013-01-05 07:12:24 +04:00
|
|
|
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.
|
2013-01-28 23:34:08 +04:00
|
|
|
void Refresh(nsView *aView, const nsIntRegion& aRegion);
|
2013-01-05 07:12:24 +04:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-01-05 07:13:05 +04:00
|
|
|
void InvalidateView(nsView *aView, const nsRect &aRect);
|
2013-01-05 07:12:24 +04:00
|
|
|
|
|
|
|
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; }
|
|
|
|
|
2013-01-28 23:34:08 +04:00
|
|
|
void WillPaintWindow(nsIWidget* aWidget);
|
2013-01-05 07:12:24 +04:00
|
|
|
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;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
2013-01-05 07:12:24 +04:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
2005-11-11 17:36:26 +03:00
|
|
|
|
2013-01-05 07:12:24 +04:00
|
|
|
#endif // nsViewManager_h___
|