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-03 17:23:11 +04:00
|
|
|
#ifndef nsView_h__
|
|
|
|
#define nsView_h__
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
#include "nsCoord.h"
|
Bug 109772. Cleanup views. Promote certain members of nsView and nsViewManager to stack variables. Provide non-COM versions of, and deprecate COM usage of, nsIView methods HasWidget, GetWidget, GetFloating, GetParent, GetFirstChild, GetNextSibling, GetOpacity, GetClientData, GetVisibility, GetViewManager, GetZIndex, GetPosition, and GetBounds. r+sr=dbaron
2003-06-24 05:00:46 +04:00
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsPoint.h"
|
2013-01-03 17:23:08 +04:00
|
|
|
#include "nsRegion.h"
|
|
|
|
#include "nsCRT.h"
|
2015-04-19 21:59:51 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2013-10-22 17:27:34 +04:00
|
|
|
#include "nsWidgetInitData.h" // for nsWindowType
|
2013-01-03 17:23:08 +04:00
|
|
|
#include "nsIWidgetListener.h"
|
2015-11-16 11:35:18 +03:00
|
|
|
#include "Units.h"
|
2019-03-11 17:58:04 +03:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-09-24 14:04:14 +04:00
|
|
|
#include "mozilla/EventForwards.h"
|
2001-07-16 06:40:48 +04:00
|
|
|
|
Bug 109772. Cleanup views. Promote certain members of nsView and nsViewManager to stack variables. Provide non-COM versions of, and deprecate COM usage of, nsIView methods HasWidget, GetWidget, GetFloating, GetParent, GetFirstChild, GetNextSibling, GetOpacity, GetClientData, GetVisibility, GetViewManager, GetZIndex, GetPosition, and GetBounds. r+sr=dbaron
2003-06-24 05:00:46 +04:00
|
|
|
class nsViewManager;
|
2009-04-02 01:59:02 +04:00
|
|
|
class nsIWidget;
|
2012-08-06 07:00:56 +04:00
|
|
|
class nsIFrame;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2019-04-13 04:05:21 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class PresShell;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2019-05-07 04:30:33 +03:00
|
|
|
/**
|
|
|
|
* nsView's serve two main purposes: 1) a bridge between nsIFrame's and
|
|
|
|
* nsIWidget's, 2) linking the frame tree of a(n) (in-process) subdocument with
|
|
|
|
* its parent document frame tree. Historically views were used for more things,
|
|
|
|
* but their role has been reduced, and could be reduced to nothing in the
|
|
|
|
* future (bug 337801 tracks removing views). Views are generally associated
|
|
|
|
* with a frame. A view that does not have a frame is called an anonymous view.
|
|
|
|
* Some frames also have associated widgets (think os level windows). If a frame
|
|
|
|
* has a widget it must also have a view, but not all frames with views will
|
|
|
|
* have widgets.
|
|
|
|
*
|
|
|
|
* Only five types of frames can have a view: root frames (ViewportFrame),
|
|
|
|
* subdocument frames (nsSubDocumentFrame), plugin frames (nsPluginFrame),
|
|
|
|
* menu popup frames (nsMenuPopupFrame), and list control frames
|
|
|
|
* (nsListControlFrame). Root frames and subdocument frames have views to link
|
|
|
|
* the two documents together (the frame trees do not link up otherwise).
|
|
|
|
* Plugin frames, menu popup frames, and list control frames have views because
|
|
|
|
* they (sometimes) need to create widgets (although plugins with widgets might
|
|
|
|
* be going away/gone?). Menu popup frames handles xul popups, which is anything
|
|
|
|
* where we need content to go over top the main window at an os level. List
|
|
|
|
* control frames handle select popups/dropdowns in non-e10s mode.
|
|
|
|
*
|
|
|
|
* The term "root view" refers to the root view of a document. Just like root
|
|
|
|
* frames, root views can have parent views. Only the root view of the root
|
|
|
|
* document in the process will not have a parent.
|
|
|
|
*
|
|
|
|
* All views are created by their frames except root views. Root views are
|
|
|
|
* special. Root views are created in nsDocumentViewer::MakeWindow before the
|
|
|
|
* root frame is created, so the root view will not have a frame very early in
|
|
|
|
* document creation.
|
|
|
|
*
|
|
|
|
* Subdocument frames and plugin frames have an anonymous (no frame associated
|
|
|
|
* with it) inner view that is a child of their "outer" view. On a plugin frame
|
|
|
|
* with a widget the inner view would be associated with the widget (as opposed
|
|
|
|
* to the outer view).
|
|
|
|
*
|
|
|
|
* On a subdocument frame the inner view serves as the parent of the
|
|
|
|
* root view of the subdocument. The outer and inner view of the subdocument
|
|
|
|
* frame belong to the subdocument frame and hence to the parent document. The
|
|
|
|
* root view of the subdocument belongs to the subdocument.
|
|
|
|
* nsLayoutUtils::GetCrossDocParentFrame and nsPresContext::GetParentPresContext
|
|
|
|
* depend on this view structure and are the main way that we traverse across
|
|
|
|
* the document boundary in layout.
|
|
|
|
*
|
|
|
|
* When the load of a new document is started in the subdocument, the creation
|
|
|
|
* of the new subdocument and destruction of the old subdocument are not
|
|
|
|
* linked. (This creation and destruction is handled in nsDocumentViewer.cpp.)
|
|
|
|
* This means that the old and new document will both exist at the same time
|
|
|
|
* during the loading of the new document. During this period the inner view of
|
|
|
|
* the subdocument parent will be the parent of two root views. This means that
|
|
|
|
* during this period there is a choice for which subdocument we draw,
|
|
|
|
* nsSubDocumentFrame::GetSubdocumentPresShellForPainting is what makes that
|
|
|
|
* choice. Note that this might not be a totally free choice, ie there might be
|
|
|
|
* hidden dependencies and bugs if the way we choose is changed.
|
|
|
|
*
|
|
|
|
* One thing that is special about the root view of a chrome window is that
|
|
|
|
* instead of creating a widget for the view, they can "attach" to the
|
|
|
|
* existing widget that was created by appshell code or something else. (see
|
|
|
|
* nsDocumentViewer::ShouldAttachToTopLevel)
|
|
|
|
*/
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Enumerated type to indicate the visibility of a layer.
|
|
|
|
// hide - the layer is not shown.
|
|
|
|
// show - the layer is shown irrespective of the visibility of
|
|
|
|
// the layer's parent.
|
1999-09-24 03:26:54 +04:00
|
|
|
enum nsViewVisibility {
|
1998-04-14 00:24:54 +04:00
|
|
|
nsViewVisibility_kHide = 0,
|
2001-12-01 17:31:45 +03:00
|
|
|
nsViewVisibility_kShow = 1
|
1999-09-24 03:26:54 +04:00
|
|
|
};
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-10-12 00:35:51 +04:00
|
|
|
// Public view flags
|
Bug 109772. Cleanup views. Promote certain members of nsView and nsViewManager to stack variables. Provide non-COM versions of, and deprecate COM usage of, nsIView methods HasWidget, GetWidget, GetFloating, GetParent, GetFirstChild, GetNextSibling, GetOpacity, GetClientData, GetVisibility, GetViewManager, GetZIndex, GetPosition, and GetBounds. r+sr=dbaron
2003-06-24 05:00:46 +04:00
|
|
|
|
2004-10-12 00:35:51 +04:00
|
|
|
// Indicates that the view is using auto z-indexing
|
|
|
|
#define NS_VIEW_FLAG_AUTO_ZINDEX 0x0004
|
Bug 109772. Cleanup views. Promote certain members of nsView and nsViewManager to stack variables. Provide non-COM versions of, and deprecate COM usage of, nsIView methods HasWidget, GetWidget, GetFloating, GetParent, GetFirstChild, GetNextSibling, GetOpacity, GetClientData, GetVisibility, GetViewManager, GetZIndex, GetPosition, and GetBounds. r+sr=dbaron
2003-06-24 05:00:46 +04:00
|
|
|
|
2004-10-12 00:35:51 +04:00
|
|
|
// Indicates that the view is a floating view.
|
|
|
|
#define NS_VIEW_FLAG_FLOATING 0x0008
|
Bug 109772. Cleanup views. Promote certain members of nsView and nsViewManager to stack variables. Provide non-COM versions of, and deprecate COM usage of, nsIView methods HasWidget, GetWidget, GetFloating, GetParent, GetFirstChild, GetNextSibling, GetOpacity, GetClientData, GetVisibility, GetViewManager, GetZIndex, GetPosition, and GetBounds. r+sr=dbaron
2003-06-24 05:00:46 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-08-08 08:23:33 +04:00
|
|
|
/**
|
|
|
|
* View interface
|
|
|
|
*
|
|
|
|
* Views are NOT reference counted. Use the Destroy() member function to
|
2001-12-01 17:31:45 +03:00
|
|
|
* destroy a view.
|
1998-08-08 08:23:33 +04:00
|
|
|
*
|
|
|
|
* The lifetime of the view hierarchy is bounded by the lifetime of the
|
|
|
|
* view manager that owns the views.
|
2001-12-01 17:31:45 +03:00
|
|
|
*
|
|
|
|
* Most of the methods here are read-only. To set the corresponding properties
|
2013-01-05 07:12:24 +04:00
|
|
|
* of a view, go through nsViewManager.
|
1998-08-08 08:23:33 +04:00
|
|
|
*/
|
2004-01-30 23:02:42 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsView final : public nsIWidgetListener {
|
1998-04-14 00:24:54 +04:00
|
|
|
public:
|
2013-01-03 17:23:10 +04:00
|
|
|
friend class nsViewManager;
|
2013-01-03 17:23:08 +04:00
|
|
|
|
2015-11-16 11:35:18 +03:00
|
|
|
typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
|
2015-12-03 08:45:41 +03:00
|
|
|
typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion;
|
2015-11-16 11:35:18 +03:00
|
|
|
|
2017-01-24 19:10:01 +03:00
|
|
|
void operator delete(void* ptr) { ::operator delete(ptr); }
|
2013-01-03 17:23:08 +04:00
|
|
|
|
2004-01-30 11:01:01 +03:00
|
|
|
/**
|
|
|
|
* Get the view manager which "owns" the view.
|
|
|
|
* This method might require some expensive traversal work in the future. If
|
|
|
|
* you can get the view manager from somewhere else, do that instead.
|
|
|
|
* @result the view manager
|
|
|
|
*/
|
2013-01-05 07:13:23 +04:00
|
|
|
nsViewManager* GetViewManager() const { return mViewManager; }
|
2013-01-03 17:23:10 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the view for the given widget, if there is one.
|
|
|
|
* @return the view the widget belongs to, or null if the widget doesn't
|
|
|
|
* belong to any view.
|
|
|
|
*/
|
2013-01-03 17:23:11 +04:00
|
|
|
static nsView* GetViewFor(nsIWidget* aWidget);
|
2004-01-30 11:01:01 +03:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
1998-08-08 08:23:33 +04:00
|
|
|
* Destroy the view.
|
|
|
|
*
|
|
|
|
* The view destroys its child views, and destroys and releases its
|
|
|
|
* widget (if it has one).
|
2004-05-17 20:29:13 +04:00
|
|
|
*
|
1998-08-08 08:23:33 +04:00
|
|
|
* Also informs the view manager that the view is destroyed by calling
|
2004-05-17 20:29:13 +04:00
|
|
|
* SetRootView(NULL) if the view is the root view and calling RemoveChild()
|
|
|
|
* otherwise.
|
1998-04-16 00:25:02 +04:00
|
|
|
*/
|
2004-01-30 06:20:41 +03:00
|
|
|
void Destroy();
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
|
|
|
* Called to get the position of a view.
|
2010-07-19 06:23:47 +04:00
|
|
|
* The specified coordinates are relative to the parent view's origin, but
|
|
|
|
* are in appunits of this.
|
2001-12-01 17:31:45 +03:00
|
|
|
* This is the (0, 0) origin of the coordinate space established by this view.
|
1998-04-16 00:25:02 +04:00
|
|
|
* @param x out parameter for x position
|
|
|
|
* @param y out parameter for y position
|
|
|
|
*/
|
Bug 109772. Cleanup views. Promote certain members of nsView and nsViewManager to stack variables. Provide non-COM versions of, and deprecate COM usage of, nsIView methods HasWidget, GetWidget, GetFloating, GetParent, GetFirstChild, GetNextSibling, GetOpacity, GetClientData, GetVisibility, GetViewManager, GetZIndex, GetPosition, and GetBounds. r+sr=dbaron
2003-06-24 05:00:46 +04:00
|
|
|
nsPoint GetPosition() const {
|
2013-01-03 17:23:09 +04:00
|
|
|
NS_ASSERTION(!IsRoot() || (mPosX == 0 && mPosY == 0),
|
Bug 109772. Cleanup views. Promote certain members of nsView and nsViewManager to stack variables. Provide non-COM versions of, and deprecate COM usage of, nsIView methods HasWidget, GetWidget, GetFloating, GetParent, GetFirstChild, GetNextSibling, GetOpacity, GetClientData, GetVisibility, GetViewManager, GetZIndex, GetPosition, and GetBounds. r+sr=dbaron
2003-06-24 05:00:46 +04:00
|
|
|
"root views should always have explicit position of (0,0)");
|
|
|
|
return nsPoint(mPosX, mPosY);
|
|
|
|
}
|
2009-10-08 07:01:15 +04:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
2001-12-01 17:31:45 +03:00
|
|
|
* Called to get the dimensions and position of the view's bounds.
|
2010-07-19 06:23:47 +04:00
|
|
|
* The view's bounds (x,y) are relative to the origin of the parent view, but
|
|
|
|
* are in appunits of this.
|
2001-12-01 17:31:45 +03:00
|
|
|
* The view's bounds (x,y) might not be the same as the view's position,
|
|
|
|
* if the view has content above or to the left of its origin.
|
1998-04-16 00:25:02 +04:00
|
|
|
* @param aBounds out parameter for bounds
|
|
|
|
*/
|
2004-01-30 06:20:41 +03:00
|
|
|
nsRect GetBounds() const { return mDimBounds; }
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2011-05-11 19:49:16 +04:00
|
|
|
/**
|
|
|
|
* The bounds of this view relative to this view. So this is the same as
|
|
|
|
* GetBounds except this is relative to this view instead of the parent view.
|
|
|
|
*/
|
|
|
|
nsRect GetDimensions() const {
|
|
|
|
nsRect r = mDimBounds;
|
|
|
|
r.MoveBy(-mPosX, -mPosY);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2004-11-03 19:16:57 +03:00
|
|
|
/**
|
|
|
|
* Get the offset between the coordinate systems of |this| and aOther.
|
|
|
|
* Adding the return value to a point in the coordinate system of |this|
|
|
|
|
* will transform the point to the coordinate system of aOther.
|
|
|
|
*
|
2010-07-19 06:23:47 +04:00
|
|
|
* The offset is expressed in appunits of |this|. So if you are getting the
|
|
|
|
* offset between views in different documents that might have different
|
|
|
|
* appunits per devpixel ratios you need to be careful how you use the
|
|
|
|
* result.
|
|
|
|
*
|
2004-11-03 19:16:57 +03:00
|
|
|
* If aOther is null, this will return the offset of |this| from the
|
|
|
|
* root of the viewmanager tree.
|
|
|
|
*
|
|
|
|
* This function is fastest when aOther is an ancestor of |this|.
|
|
|
|
*
|
|
|
|
* NOTE: this actually returns the offset from aOther to |this|, but
|
|
|
|
* that offset is added to transform _coordinates_ from |this| to aOther.
|
|
|
|
*/
|
2013-01-03 17:23:11 +04:00
|
|
|
nsPoint GetOffsetTo(const nsView* aOther) const;
|
2004-11-03 19:16:57 +03:00
|
|
|
|
2010-07-19 06:23:47 +04:00
|
|
|
/**
|
|
|
|
* Get the offset between the origin of |this| and the origin of aWidget.
|
|
|
|
* Adding the return value to a point in the coordinate system of |this|
|
|
|
|
* will transform the point to the coordinate system of aWidget.
|
|
|
|
*
|
|
|
|
* The offset is expressed in appunits of |this|.
|
|
|
|
*/
|
|
|
|
nsPoint GetOffsetToWidget(nsIWidget* aWidget) const;
|
|
|
|
|
2011-05-11 19:49:16 +04:00
|
|
|
/**
|
|
|
|
* Takes a point aPt that is in the coordinate system of |this|'s parent view
|
|
|
|
* and converts it to be in the coordinate system of |this| taking into
|
|
|
|
* account the offset and any app unit per dev pixel ratio differences.
|
|
|
|
*/
|
|
|
|
nsPoint ConvertFromParentCoords(nsPoint aPt) const;
|
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
|
|
|
* Called to query the visibility state of a view.
|
|
|
|
* @result current visibility state
|
|
|
|
*/
|
Bug 109772. Cleanup views. Promote certain members of nsView and nsViewManager to stack variables. Provide non-COM versions of, and deprecate COM usage of, nsIView methods HasWidget, GetWidget, GetFloating, GetParent, GetFirstChild, GetNextSibling, GetOpacity, GetClientData, GetVisibility, GetViewManager, GetZIndex, GetPosition, and GetBounds. r+sr=dbaron
2003-06-24 05:00:46 +04:00
|
|
|
nsViewVisibility GetVisibility() const { return mVis; }
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-09-24 03:26:54 +04:00
|
|
|
/**
|
2001-12-01 17:31:45 +03:00
|
|
|
* Get whether the view "floats" above all other views,
|
2000-01-25 04:53:34 +03:00
|
|
|
* 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.
|
2011-10-17 18:59:28 +04:00
|
|
|
* @result true if the view floats, false otherwise.
|
2000-01-25 04:53:34 +03:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool GetFloating() const { return (mVFlags & NS_VIEW_FLAG_FLOATING) != 0; }
|
2000-01-25 04:53:34 +03:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
|
|
|
* Called to query the parent of the view.
|
|
|
|
* @result view's parent
|
|
|
|
*/
|
2013-01-03 17:23:11 +04:00
|
|
|
nsView* GetParent() const { return mParent; }
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2002-12-14 19:18:57 +03:00
|
|
|
/**
|
|
|
|
* The view's first child is the child which is earliest in document order.
|
|
|
|
* @result first child
|
|
|
|
*/
|
2013-01-03 17:23:11 +04:00
|
|
|
nsView* GetFirstChild() const { return mFirstChild; }
|
2002-12-14 19:18:57 +03:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
|
|
|
* Called to query the next sibling of the view.
|
|
|
|
* @result view's next sibling
|
|
|
|
*/
|
2013-01-03 17:23:11 +04:00
|
|
|
nsView* GetNextSibling() const { return mNextSibling; }
|
1998-04-16 00:25:02 +04:00
|
|
|
|
|
|
|
/**
|
2011-11-21 21:53:20 +04:00
|
|
|
* Set the view's frame.
|
1998-04-16 00:25:02 +04:00
|
|
|
*/
|
2011-11-21 21:53:20 +04:00
|
|
|
void SetFrame(nsIFrame* aRootFrame) { mFrame = aRootFrame; }
|
1998-04-16 00:25:02 +04:00
|
|
|
|
|
|
|
/**
|
2011-11-21 21:53:20 +04:00
|
|
|
* Retrieve the view's frame.
|
1998-04-16 00:25:02 +04:00
|
|
|
*/
|
2011-11-21 21:53:20 +04:00
|
|
|
nsIFrame* GetFrame() const { return mFrame; }
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-16 00:25:02 +04:00
|
|
|
/**
|
1998-06-16 21:05:42 +04:00
|
|
|
* Get the nearest widget in this view or a parent of this view and
|
2004-01-30 06:20:41 +03:00
|
|
|
* the offset from the widget's origin to this view's origin
|
2011-03-01 19:15:23 +03:00
|
|
|
* @param aOffset - if non-null the offset from this view's origin to the
|
|
|
|
* widget's origin (usually positive) expressed in appunits of this will be
|
|
|
|
* returned in aOffset.
|
2004-01-30 06:20:41 +03:00
|
|
|
* @return the widget closest to this view; can be null because some view
|
|
|
|
* trees don't have widgets at all (e.g., printing), but if any view in the
|
|
|
|
* view tree has a widget, then it's safe to assume this will not return null
|
1998-04-16 00:25:02 +04:00
|
|
|
*/
|
2013-01-03 17:23:09 +04:00
|
|
|
nsIWidget* GetNearestWidget(nsPoint* aOffset) const;
|
1998-06-16 21:05:42 +04:00
|
|
|
|
1998-11-04 07:14:10 +03:00
|
|
|
/**
|
2010-08-20 23:29:02 +04:00
|
|
|
* Create a widget to associate with this view. This variant of
|
|
|
|
* CreateWidget*() will look around in the view hierarchy for an
|
|
|
|
* appropriate parent widget for the view.
|
|
|
|
*
|
1998-11-04 07:14:10 +03:00
|
|
|
* @param aWidgetInitData data used to initialize this view's widget before
|
|
|
|
* its create is called.
|
|
|
|
* @return error status
|
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
nsresult CreateWidget(nsWidgetInitData* aWidgetInitData = nullptr,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aEnableDragDrop = true,
|
|
|
|
bool aResetVisibility = true);
|
2010-08-20 23:29:02 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a widget for this view with an explicit parent widget.
|
|
|
|
* |aParentWidget| must be nonnull. The other params are the same
|
|
|
|
* as for |CreateWidget()|.
|
|
|
|
*/
|
2010-08-20 23:29:02 +04:00
|
|
|
nsresult CreateWidgetForParent(nsIWidget* aParentWidget,
|
2012-07-30 18:20:58 +04:00
|
|
|
nsWidgetInitData* aWidgetInitData = nullptr,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aEnableDragDrop = true,
|
|
|
|
bool aResetVisibility = true);
|
2010-08-20 23:29:02 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a popup widget for this view. Pass |aParentWidget| to
|
|
|
|
* explicitly set the popup's parent. If it's not passed, the view
|
|
|
|
* hierarchy will be searched for an appropriate parent widget. The
|
|
|
|
* other params are the same as for |CreateWidget()|, except that
|
|
|
|
* |aWidgetInitData| must be nonnull.
|
|
|
|
*/
|
2010-08-20 23:29:02 +04:00
|
|
|
nsresult CreateWidgetForPopup(nsWidgetInitData* aWidgetInitData,
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIWidget* aParentWidget = nullptr,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aEnableDragDrop = true,
|
|
|
|
bool aResetVisibility = true);
|
1998-11-04 07:14:10 +03:00
|
|
|
|
2011-03-21 21:28:10 +03:00
|
|
|
/**
|
|
|
|
* Destroys the associated widget for this view. If this method is
|
|
|
|
* not called explicitly, the widget when be destroyed when its
|
|
|
|
* view gets destroyed.
|
|
|
|
*/
|
|
|
|
void DestroyWidget();
|
|
|
|
|
2010-06-25 06:01:06 +04:00
|
|
|
/**
|
|
|
|
* Attach/detach a top level widget from this view. When attached, the view
|
|
|
|
* updates the widget's device context and allows the view to begin receiving
|
|
|
|
* gecko events. The underlying base window associated with the widget will
|
|
|
|
* continues to receive events it expects.
|
|
|
|
*
|
|
|
|
* An attached widget will not be destroyed when the view is destroyed,
|
|
|
|
* allowing the recycling of a single top level widget over multiple views.
|
|
|
|
*
|
|
|
|
* @param aWidget The widget to attach to / detach from.
|
|
|
|
*/
|
|
|
|
nsresult AttachToTopLevelWidget(nsIWidget* aWidget);
|
|
|
|
nsresult DetachFromTopLevelWidget();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a flag indicating whether the view owns it's widget
|
|
|
|
* or is attached to an existing top level widget.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsAttachedToTopLevel() const { return mWidgetIsTopLevel; }
|
2010-06-25 06:01:06 +04:00
|
|
|
|
1998-11-04 07:14:10 +03:00
|
|
|
/**
|
|
|
|
* In 4.0, the "cutout" nature of a view is queryable.
|
|
|
|
* If we believe that all cutout view have a native widget, this
|
|
|
|
* could be a replacement.
|
|
|
|
* @param aWidget out parameter for widget that this view contains,
|
2012-07-30 18:20:58 +04:00
|
|
|
* or nullptr if there is none.
|
1998-11-04 07:14:10 +03:00
|
|
|
*/
|
Bug 109772. Cleanup views. Promote certain members of nsView and nsViewManager to stack variables. Provide non-COM versions of, and deprecate COM usage of, nsIView methods HasWidget, GetWidget, GetFloating, GetParent, GetFirstChild, GetNextSibling, GetOpacity, GetClientData, GetVisibility, GetViewManager, GetZIndex, GetPosition, and GetBounds. r+sr=dbaron
2003-06-24 05:00:46 +04:00
|
|
|
nsIWidget* GetWidget() const { return mWindow; }
|
1998-11-04 07:14:10 +03:00
|
|
|
|
2015-07-22 04:09:02 +03:00
|
|
|
/**
|
|
|
|
* The widget which we have attached a listener to can also have a "previous"
|
|
|
|
* listener set on it. This is to keep track of the last nsView when
|
|
|
|
* navigating to a new one so that we can continue to paint that if the new
|
|
|
|
* one isn't ready yet.
|
|
|
|
*/
|
|
|
|
void SetPreviousWidget(nsIWidget* aWidget) { mPreviousWindow = aWidget; }
|
|
|
|
|
1999-11-14 05:51:25 +03:00
|
|
|
/**
|
2011-10-17 18:59:28 +04:00
|
|
|
* Returns true if the view has a widget associated with it.
|
1999-11-14 05:51:25 +03:00
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
bool HasWidget() const { return mWindow != nullptr; }
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2012-10-15 08:53:37 +04:00
|
|
|
void SetForcedRepaint(bool aForceRepaint) { mForcedRepaint = aForceRepaint; }
|
1999-11-14 05:51:25 +03:00
|
|
|
|
2015-05-04 22:29:19 +03:00
|
|
|
void SetNeedsWindowPropertiesSync();
|
|
|
|
|
2009-07-22 04:45:00 +04:00
|
|
|
/**
|
|
|
|
* Make aWidget direct its events to this view.
|
|
|
|
* The caller must call DetachWidgetEventHandler before this view
|
|
|
|
* is destroyed.
|
|
|
|
*/
|
2012-08-15 22:53:09 +04:00
|
|
|
void AttachWidgetEventHandler(nsIWidget* aWidget);
|
2009-07-22 04:45:00 +04:00
|
|
|
/**
|
|
|
|
* Stop aWidget directing its events to this view.
|
|
|
|
*/
|
|
|
|
void DetachWidgetEventHandler(nsIWidget* aWidget);
|
|
|
|
|
2004-01-21 01:15:38 +03:00
|
|
|
#ifdef DEBUG
|
2001-11-24 08:37:25 +03:00
|
|
|
/**
|
2001-12-01 17:31:45 +03:00
|
|
|
* Output debug info to FILE
|
|
|
|
* @param out output file handle
|
|
|
|
* @param aIndent indentation depth
|
2004-01-30 06:20:41 +03:00
|
|
|
* NOTE: virtual so that debugging tools not linked into gklayout can access
|
|
|
|
* it
|
2001-11-24 08:37:25 +03:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual void List(FILE* out, int32_t aIndent = 0) const;
|
2004-01-21 01:15:38 +03:00
|
|
|
#endif // DEBUG
|
2000-04-03 07:55:38 +04:00
|
|
|
|
Bug 109772. Cleanup views. Promote certain members of nsView and nsViewManager to stack variables. Provide non-COM versions of, and deprecate COM usage of, nsIView methods HasWidget, GetWidget, GetFloating, GetParent, GetFirstChild, GetNextSibling, GetOpacity, GetClientData, GetVisibility, GetViewManager, GetZIndex, GetPosition, and GetBounds. r+sr=dbaron
2003-06-24 05:00:46 +04:00
|
|
|
/**
|
|
|
|
* @result true iff this is the root view for its view manager
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsRoot() const;
|
Bug 109772. Cleanup views. Promote certain members of nsView and nsViewManager to stack variables. Provide non-COM versions of, and deprecate COM usage of, nsIView methods HasWidget, GetWidget, GetFloating, GetParent, GetFirstChild, GetNextSibling, GetOpacity, GetClientData, GetVisibility, GetViewManager, GetZIndex, GetPosition, and GetBounds. r+sr=dbaron
2003-06-24 05:00:46 +04:00
|
|
|
|
2015-11-16 11:35:18 +03:00
|
|
|
LayoutDeviceIntRect CalcWidgetBounds(nsWindowType aType);
|
2010-02-24 11:33:41 +03:00
|
|
|
|
2010-04-23 04:21:54 +04:00
|
|
|
// This is an app unit offset to add when converting view coordinates to
|
|
|
|
// widget coordinates. It is the offset in view coordinates from widget
|
2010-07-19 06:23:47 +04:00
|
|
|
// origin (unlike views, widgets can't extend above or to the left of their
|
|
|
|
// origin) to view origin expressed in appunits of this.
|
2010-06-26 01:51:17 +04:00
|
|
|
nsPoint ViewToWidgetOffset() const { return mViewToWidgetOffset; }
|
2010-04-23 04:21:54 +04:00
|
|
|
|
2013-01-03 17:23:08 +04:00
|
|
|
/**
|
|
|
|
* Called to indicate that the position of the view has been changed.
|
|
|
|
* The specified coordinates are in the parent view's coordinate space.
|
|
|
|
* @param x new x position
|
|
|
|
* @param y new y position
|
|
|
|
*/
|
2013-01-03 17:23:09 +04:00
|
|
|
void SetPosition(nscoord aX, nscoord aY);
|
2013-01-03 17:23:10 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to indicate that the z-index of a view has been changed.
|
|
|
|
* The z-index is relative to all siblings of the view.
|
|
|
|
* @param aAuto Indicate that the z-index of a view is "auto". An "auto"
|
|
|
|
* z-index means that the view does not define a new stacking
|
|
|
|
* context, which means that the z-indicies of the view's
|
|
|
|
* children are relative to the view's siblings.
|
|
|
|
* @param zindex new z depth
|
|
|
|
*/
|
2013-07-31 01:10:28 +04:00
|
|
|
void SetZIndex(bool aAuto, int32_t aZIndex);
|
2013-01-03 17:23:10 +04:00
|
|
|
bool GetZIndexIsAuto() const {
|
|
|
|
return (mVFlags & NS_VIEW_FLAG_AUTO_ZINDEX) != 0;
|
|
|
|
}
|
|
|
|
int32_t GetZIndex() const { return mZIndex; }
|
|
|
|
|
2013-01-03 17:23:11 +04:00
|
|
|
void SetParent(nsView* aParent) { mParent = aParent; }
|
|
|
|
void SetNextSibling(nsView* aSibling) {
|
2013-01-03 17:23:10 +04:00
|
|
|
NS_ASSERTION(aSibling != this, "Can't be our own sibling!");
|
|
|
|
mNextSibling = aSibling;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRegion* GetDirtyRegion() {
|
|
|
|
if (!mDirtyRegion) {
|
|
|
|
NS_ASSERTION(!mParent || GetFloating(),
|
|
|
|
"Only display roots should have dirty regions");
|
|
|
|
mDirtyRegion = new nsRegion();
|
|
|
|
NS_ASSERTION(mDirtyRegion, "Out of memory!");
|
|
|
|
}
|
|
|
|
return mDirtyRegion;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIWidgetListener
|
2019-04-13 04:05:21 +03:00
|
|
|
virtual mozilla::PresShell* GetPresShell() override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsView* GetView() override { return this; }
|
|
|
|
virtual bool WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y) override;
|
|
|
|
virtual bool WindowResized(nsIWidget* aWidget, int32_t aWidth,
|
|
|
|
int32_t aHeight) override;
|
2019-11-14 08:59:47 +03:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
virtual void DynamicToolbarMaxHeightChanged(
|
|
|
|
mozilla::ScreenIntCoord aHeight) override;
|
2019-11-22 00:15:46 +03:00
|
|
|
virtual void DynamicToolbarOffsetChanged(
|
|
|
|
mozilla::ScreenIntCoord aOffset) override;
|
2019-11-14 08:59:47 +03:00
|
|
|
#endif
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool RequestWindowClose(nsIWidget* aWidget) override;
|
2019-05-06 16:25:35 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void WillPaintWindow(nsIWidget* aWidget) override;
|
2019-05-06 16:25:35 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2015-12-03 08:45:41 +03:00
|
|
|
virtual bool PaintWindow(nsIWidget* aWidget,
|
|
|
|
LayoutDeviceIntRegion aRegion) override;
|
2019-05-06 16:01:48 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DidPaintWindow() override;
|
2018-04-20 22:13:06 +03:00
|
|
|
virtual void DidCompositeWindow(
|
|
|
|
mozilla::layers::TransactionId aTransactionId,
|
2016-04-13 23:59:15 +03:00
|
|
|
const mozilla::TimeStamp& aCompositeStart,
|
2015-08-25 08:51:58 +03:00
|
|
|
const mozilla::TimeStamp& aCompositeEnd) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void RequestRepaint() override;
|
2019-03-06 21:48:50 +03:00
|
|
|
virtual bool ShouldNotBeVisible() override;
|
2019-03-11 17:58:04 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2013-10-02 07:46:03 +04:00
|
|
|
virtual nsEventStatus HandleEvent(mozilla::WidgetGUIEvent* aEvent,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aUseAttachedEvents) override;
|
2020-03-04 11:16:31 +03:00
|
|
|
virtual void SafeAreaInsetsChanged(const mozilla::ScreenIntMargin&) override;
|
2013-01-03 17:23:10 +04:00
|
|
|
|
2013-01-03 17:23:11 +04:00
|
|
|
virtual ~nsView();
|
2013-01-03 17:23:10 +04:00
|
|
|
|
2013-01-03 17:23:11 +04:00
|
|
|
nsPoint GetOffsetTo(const nsView* aOther, const int32_t aAPD) const;
|
2013-01-03 17:23:10 +04:00
|
|
|
nsIWidget* GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const;
|
|
|
|
|
2015-07-22 04:09:02 +03:00
|
|
|
bool IsPrimaryFramePaintSuppressed();
|
|
|
|
|
2013-01-03 17:23:10 +04:00
|
|
|
private:
|
2014-08-08 03:48:38 +04:00
|
|
|
explicit nsView(nsViewManager* aViewManager = nullptr,
|
|
|
|
nsViewVisibility aVisibility = nsViewVisibility_kShow);
|
2013-01-03 17:23:10 +04:00
|
|
|
|
|
|
|
bool ForcedRepaint() { return mForcedRepaint; }
|
|
|
|
|
|
|
|
// Do the actual work of ResetWidgetBounds, unconditionally. Don't
|
|
|
|
// call this method if we have no widget.
|
|
|
|
void DoResetWidgetBounds(bool aMoveOnly, bool aInvalidateChangedSize);
|
|
|
|
void InitializeWindow(bool aEnableDragDrop, bool aResetVisibility);
|
|
|
|
|
|
|
|
bool IsEffectivelyVisible();
|
|
|
|
|
2013-01-03 17:23:08 +04:00
|
|
|
/**
|
|
|
|
* Called to indicate that the dimensions of the view have been changed.
|
|
|
|
* The x and y coordinates may be < 0, indicating that the view extends above
|
|
|
|
* or to the left of its origin position. The term 'dimensions' indicates it
|
|
|
|
* is relative to this view.
|
|
|
|
*/
|
2013-01-03 17:23:09 +04:00
|
|
|
void SetDimensions(const nsRect& aRect, bool aPaint = true,
|
|
|
|
bool aResizeWidget = true);
|
2013-01-03 17:23:08 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to indicate that the visibility of a view has been
|
|
|
|
* changed.
|
|
|
|
* @param visibility new visibility state
|
|
|
|
*/
|
2013-01-03 17:23:09 +04:00
|
|
|
void SetVisibility(nsViewVisibility visibility);
|
2013-01-03 17:23:08 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set/Get 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.
|
|
|
|
* @result true if the view floats, false otherwise.
|
|
|
|
*/
|
2013-01-03 17:23:09 +04:00
|
|
|
void SetFloating(bool aFloatingView);
|
2013-01-03 17:23:08 +04:00
|
|
|
|
|
|
|
// Helper function to get mouse grabbing off this view (by moving it to the
|
|
|
|
// parent, if we can)
|
|
|
|
void DropMouseGrabbing();
|
|
|
|
|
|
|
|
// Same as GetBounds but converts to parent appunits if they are different.
|
|
|
|
nsRect GetBoundsInParentUnits() const;
|
|
|
|
|
|
|
|
bool HasNonEmptyDirtyRegion() {
|
|
|
|
return mDirtyRegion && !mDirtyRegion->IsEmpty();
|
|
|
|
}
|
|
|
|
|
2013-01-03 17:23:11 +04:00
|
|
|
void InsertChild(nsView* aChild, nsView* aSibling);
|
|
|
|
void RemoveChild(nsView* aChild);
|
2013-01-03 17:23:08 +04:00
|
|
|
|
|
|
|
void ResetWidgetBounds(bool aRecurse, bool aForceSync);
|
|
|
|
void AssertNoWindow();
|
|
|
|
|
|
|
|
void NotifyEffectiveVisibilityChanged(bool aEffectivelyVisible);
|
|
|
|
|
2016-04-22 08:17:15 +03:00
|
|
|
// Update the cached RootViewManager for all view manager descendents.
|
|
|
|
void InvalidateHierarchy();
|
2013-01-03 17:23:08 +04:00
|
|
|
|
2013-01-05 07:12:24 +04:00
|
|
|
nsViewManager* mViewManager;
|
2013-01-03 17:23:11 +04:00
|
|
|
nsView* mParent;
|
2015-04-19 21:59:51 +03:00
|
|
|
nsCOMPtr<nsIWidget> mWindow;
|
2015-07-22 04:09:02 +03:00
|
|
|
nsCOMPtr<nsIWidget> mPreviousWindow;
|
2013-01-03 17:23:11 +04:00
|
|
|
nsView* mNextSibling;
|
|
|
|
nsView* mFirstChild;
|
2013-01-05 07:12:24 +04:00
|
|
|
nsIFrame* mFrame;
|
|
|
|
nsRegion* mDirtyRegion;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mZIndex;
|
Bug 109772. Cleanup views. Promote certain members of nsView and nsViewManager to stack variables. Provide non-COM versions of, and deprecate COM usage of, nsIView methods HasWidget, GetWidget, GetFloating, GetParent, GetFirstChild, GetNextSibling, GetOpacity, GetClientData, GetVisibility, GetViewManager, GetZIndex, GetPosition, and GetBounds. r+sr=dbaron
2003-06-24 05:00:46 +04:00
|
|
|
nsViewVisibility mVis;
|
2010-07-19 06:23:47 +04:00
|
|
|
// position relative our parent view origin but in our appunits
|
Bug 109772. Cleanup views. Promote certain members of nsView and nsViewManager to stack variables. Provide non-COM versions of, and deprecate COM usage of, nsIView methods HasWidget, GetWidget, GetFloating, GetParent, GetFirstChild, GetNextSibling, GetOpacity, GetClientData, GetVisibility, GetViewManager, GetZIndex, GetPosition, and GetBounds. r+sr=dbaron
2003-06-24 05:00:46 +04:00
|
|
|
nscoord mPosX, mPosY;
|
2010-07-19 06:23:47 +04:00
|
|
|
// relative to parent, but in our appunits
|
|
|
|
nsRect mDimBounds;
|
|
|
|
// in our appunits
|
2010-02-24 11:33:41 +03:00
|
|
|
nsPoint mViewToWidgetOffset;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mVFlags;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mWidgetIsTopLevel;
|
2012-09-12 01:17:26 +04:00
|
|
|
bool mForcedRepaint;
|
2015-05-04 22:29:19 +03:00
|
|
|
bool mNeedsWindowPropertiesSync;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|