2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define PL_ARENA_CONST_ALIGN_MASK (sizeof(void*)-1)
|
|
|
|
#include "plarena.h"
|
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsViewManager.h"
|
|
|
|
#include "nsGfxCIID.h"
|
2013-01-03 05:23:11 -08:00
|
|
|
#include "nsView.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
#include "nsRegion.h"
|
|
|
|
#include "nsCOMArray.h"
|
2009-07-21 17:45:00 -07:00
|
|
|
#include "nsIPluginWidget.h"
|
2010-07-27 06:38:02 -07:00
|
|
|
#include "nsXULPopupManager.h"
|
2010-08-05 11:39:39 -07:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsPresContext.h"
|
2011-03-25 16:17:35 -07:00
|
|
|
#include "nsEventStateManager.h"
|
2011-11-17 23:54:27 -08:00
|
|
|
#include "mozilla/StartupTimeline.h"
|
2013-03-18 07:25:50 -07:00
|
|
|
#include "GeckoProfiler.h"
|
2012-08-13 03:10:10 -07:00
|
|
|
#include "nsRefreshDriver.h"
|
2012-08-13 03:11:33 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-08-13 23:56:21 -07:00
|
|
|
#include "nsContentUtils.h" // for nsAutoScriptBlocker
|
2013-05-13 16:47:02 -07:00
|
|
|
#include "nsLayoutUtils.h"
|
2013-06-18 00:59:29 -07:00
|
|
|
#include "mozilla/layers/Compositor.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
XXX TODO XXX
|
|
|
|
|
|
|
|
DeCOMify newly private methods
|
|
|
|
Optimize view storage
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
A note about platform assumptions:
|
|
|
|
|
|
|
|
We assume that a widget is z-ordered on top of its parent.
|
|
|
|
|
|
|
|
We do NOT assume anything about the relative z-ordering of sibling widgets. Even though
|
|
|
|
we ask for a specific z-order, we don't assume that widget z-ordering actually works.
|
|
|
|
*/
|
|
|
|
|
2013-06-18 00:59:29 -07:00
|
|
|
using namespace mozilla::layers;
|
|
|
|
|
2012-09-27 23:57:33 -07:00
|
|
|
#define NSCOORD_NONE INT32_MIN
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#undef DEBUG_MOUSE_LOCATION
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t nsViewManager::mVMCount = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Weakly held references to all of the view managers
|
2012-07-30 07:20:58 -07:00
|
|
|
nsVoidArray* nsViewManager::gViewManagers = nullptr;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t nsViewManager::gLastUserEventTime = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsViewManager::nsViewManager()
|
2011-05-11 08:49:16 -07:00
|
|
|
: mDelayedResize(NSCOORD_NONE, NSCOORD_NONE)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-03 04:27:19 -08:00
|
|
|
mRootViewManager = this;
|
2012-07-30 07:20:58 -07:00
|
|
|
if (gViewManagers == nullptr) {
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(mVMCount == 0, "View Manager count is incorrect");
|
|
|
|
// Create an array to hold a list of view managers
|
|
|
|
gViewManagers = new nsVoidArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
gViewManagers->AppendElement(this);
|
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
++mVMCount;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// NOTE: we use a zeroing operator new, so all data members are
|
|
|
|
// assumed to be cleared here.
|
2011-12-23 19:52:23 -08:00
|
|
|
mHasPendingWidgetGeometryChanges = false;
|
2011-10-17 07:59:28 -07:00
|
|
|
mRecursiveRefreshPending = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsViewManager::~nsViewManager()
|
|
|
|
{
|
|
|
|
if (mRootView) {
|
|
|
|
// Destroy any remaining views
|
|
|
|
mRootView->Destroy();
|
2012-07-30 07:20:58 -07:00
|
|
|
mRootView = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!IsRootVM()) {
|
|
|
|
// We have a strong ref to mRootViewManager
|
|
|
|
NS_RELEASE(mRootViewManager);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION((mVMCount > 0), "underflow of viewmanagers");
|
|
|
|
--mVMCount;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-09-28 23:19:26 -07:00
|
|
|
bool removed =
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
gViewManagers->RemoveElement(this);
|
|
|
|
NS_ASSERTION(removed, "Viewmanager instance not was not in the global list of viewmanagers");
|
|
|
|
|
|
|
|
if (0 == mVMCount) {
|
|
|
|
// There aren't any more view managers so
|
|
|
|
// release the global array of view managers
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ASSERTION(gViewManagers != nullptr, "About to delete null gViewManagers");
|
2007-03-22 10:30:00 -07:00
|
|
|
delete gViewManagers;
|
2012-07-30 07:20:58 -07:00
|
|
|
gViewManagers = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
mPresShell = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// We don't hold a reference to the presentation context because it
|
|
|
|
// holds a reference to us.
|
2013-01-04 19:13:05 -08:00
|
|
|
nsresult
|
|
|
|
nsViewManager::Init(nsDeviceContext* aContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_PRECONDITION(nullptr != aContext, "null ptr");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr == aContext) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr != mContext) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_ALREADY_INITIALIZED;
|
|
|
|
}
|
|
|
|
mContext = aContext;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
nsView*
|
2007-03-22 10:30:00 -07:00
|
|
|
nsViewManager::CreateView(const nsRect& aBounds,
|
2013-03-19 23:10:25 -07:00
|
|
|
nsView* aParent,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsViewVisibility aVisibilityFlag)
|
|
|
|
{
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView *v = new nsView(this, aVisibilityFlag);
|
2013-03-19 23:10:25 -07:00
|
|
|
v->SetParent(aParent);
|
2013-03-19 18:47:47 -07:00
|
|
|
v->SetPosition(aBounds.x, aBounds.y);
|
|
|
|
nsRect dim(0, 0, aBounds.width, aBounds.height);
|
|
|
|
v->SetDimensions(dim, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::SetRootView(nsView *aView)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-03 05:23:08 -08:00
|
|
|
NS_PRECONDITION(!aView || aView->GetViewManager() == this,
|
2007-03-22 10:30:00 -07:00
|
|
|
"Unexpected viewmanager on root view");
|
|
|
|
|
|
|
|
// Do NOT destroy the current root view. It's the caller's responsibility
|
|
|
|
// to destroy it
|
2013-01-03 05:23:08 -08:00
|
|
|
mRootView = aView;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (mRootView) {
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* parent = mRootView->GetParent();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (parent) {
|
|
|
|
// Calling InsertChild on |parent| will InvalidateHierarchy() on us, so
|
|
|
|
// no need to set mRootViewManager ourselves here.
|
2012-07-30 07:20:58 -07:00
|
|
|
parent->InsertChild(mRootView, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
|
|
|
InvalidateHierarchy();
|
|
|
|
}
|
|
|
|
|
2013-07-30 14:10:28 -07:00
|
|
|
mRootView->SetZIndex(false, 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
// Else don't touch mRootViewManager
|
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr != mRootView) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mDelayedResize == nsSize(NSCOORD_NONE, NSCOORD_NONE)) {
|
2011-05-11 08:49:16 -07:00
|
|
|
nsRect dim = mRootView->GetDimensions();
|
2007-03-22 10:30:00 -07:00
|
|
|
*aWidth = dim.width;
|
|
|
|
*aHeight = dim.height;
|
|
|
|
} else {
|
|
|
|
*aWidth = mDelayedResize.width;
|
|
|
|
*aHeight = mDelayedResize.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*aWidth = 0;
|
|
|
|
*aHeight = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-24 19:01:06 -07:00
|
|
|
void nsViewManager::DoSetWindowDimensions(nscoord aWidth, nscoord aHeight)
|
|
|
|
{
|
2011-05-11 08:49:16 -07:00
|
|
|
nsRect oldDim = mRootView->GetDimensions();
|
2010-06-24 19:01:06 -07:00
|
|
|
nsRect newDim(0, 0, aWidth, aHeight);
|
|
|
|
// We care about resizes even when one dimension is already zero.
|
2011-04-18 20:07:23 -07:00
|
|
|
if (!oldDim.IsEqualEdges(newDim)) {
|
2010-06-24 19:01:06 -07:00
|
|
|
// Don't resize the widget. It is already being set elsewhere.
|
2011-10-17 07:59:28 -07:00
|
|
|
mRootView->SetDimensions(newDim, true, false);
|
2011-11-21 09:53:20 -08:00
|
|
|
if (mPresShell)
|
|
|
|
mPresShell->ResizeReflow(aWidth, aHeight);
|
2010-06-24 19:01:06 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (mRootView) {
|
2011-11-21 09:53:20 -08:00
|
|
|
if (mRootView->IsEffectivelyVisible() && mPresShell && mPresShell->IsVisible()) {
|
2011-01-28 16:10:46 -08:00
|
|
|
if (mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) &&
|
|
|
|
mDelayedResize != nsSize(aWidth, aHeight)) {
|
|
|
|
// We have a delayed resize; that now obsolete size may already have
|
|
|
|
// been flushed to the PresContext so we need to update the PresContext
|
|
|
|
// with the new size because if the new size is exactly the same as the
|
|
|
|
// root view's current size then DoSetWindowDimensions will not
|
|
|
|
// request a resize reflow (which would correct it). See bug 617076.
|
|
|
|
mDelayedResize = nsSize(aWidth, aHeight);
|
2011-10-17 07:59:28 -07:00
|
|
|
FlushDelayedResize(false);
|
2011-01-28 16:10:46 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
mDelayedResize.SizeTo(NSCOORD_NONE, NSCOORD_NONE);
|
|
|
|
DoSetWindowDimensions(aWidth, aHeight);
|
|
|
|
} else {
|
|
|
|
mDelayedResize.SizeTo(aWidth, aHeight);
|
2011-12-14 20:42:15 -08:00
|
|
|
if (mPresShell && mPresShell->GetDocument()) {
|
|
|
|
mPresShell->GetDocument()->SetNeedStyleFlush();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::FlushDelayedResize(bool aDoReflow)
|
2008-09-09 06:43:10 -07:00
|
|
|
{
|
|
|
|
if (mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE)) {
|
2010-08-05 11:39:39 -07:00
|
|
|
if (aDoReflow) {
|
|
|
|
DoSetWindowDimensions(mDelayedResize.width, mDelayedResize.height);
|
|
|
|
mDelayedResize.SizeTo(NSCOORD_NONE, NSCOORD_NONE);
|
2011-11-21 09:53:20 -08:00
|
|
|
} else if (mPresShell) {
|
|
|
|
nsPresContext* presContext = mPresShell->GetPresContext();
|
2010-08-05 11:39:39 -07:00
|
|
|
if (presContext) {
|
|
|
|
presContext->SetVisibleArea(nsRect(nsPoint(0, 0), mDelayedResize));
|
|
|
|
}
|
|
|
|
}
|
2008-09-09 06:43:10 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-18 19:23:47 -07:00
|
|
|
// Convert aIn from being relative to and in appunits of aFromView, to being
|
|
|
|
// relative to and in appunits of aToView.
|
|
|
|
static nsRegion ConvertRegionBetweenViews(const nsRegion& aIn,
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* aFromView,
|
|
|
|
nsView* aToView)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-07-18 19:23:47 -07:00
|
|
|
nsRegion out = aIn;
|
|
|
|
out.MoveBy(aFromView->GetOffsetTo(aToView));
|
|
|
|
out = out.ConvertAppUnitsRoundOut(
|
2013-01-04 19:13:23 -08:00
|
|
|
aFromView->GetViewManager()->AppUnitsPerDevPixel(),
|
|
|
|
aToView->GetViewManager()->AppUnitsPerDevPixel());
|
2010-03-01 00:03:49 -08:00
|
|
|
return out;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-04 19:12:24 -08:00
|
|
|
nsView* nsViewManager::GetDisplayRootFor(nsView* aView)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView *displayRoot = aView;
|
2007-03-22 10:30:00 -07:00
|
|
|
for (;;) {
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView *displayParent = displayRoot->GetParent();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!displayParent)
|
|
|
|
return displayRoot;
|
|
|
|
|
|
|
|
if (displayRoot->GetFloating() && !displayParent->GetFloating())
|
|
|
|
return displayRoot;
|
2011-05-29 20:15:00 -07:00
|
|
|
|
|
|
|
// If we have a combobox dropdown popup within a panel popup, both the view
|
|
|
|
// for the dropdown popup and its parent will be floating, so we need to
|
|
|
|
// distinguish this situation. We do this by looking for a widget. Any view
|
|
|
|
// with a widget is a display root, except for plugins.
|
|
|
|
nsIWidget* widget = displayRoot->GetWidget();
|
|
|
|
if (widget) {
|
|
|
|
nsWindowType type;
|
|
|
|
widget->GetWindowType(type);
|
|
|
|
if (type == eWindowType_popup) {
|
|
|
|
NS_ASSERTION(displayRoot->GetFloating() && displayParent->GetFloating(),
|
|
|
|
"this should only happen with floating views that have floating parents");
|
|
|
|
return displayRoot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
displayRoot = displayParent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
aRegion is given in device coordinates!!
|
2010-03-01 00:03:49 -08:00
|
|
|
aContext may be null, in which case layers should be used for
|
|
|
|
rendering.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2013-01-28 11:34:08 -08:00
|
|
|
void nsViewManager::Refresh(nsView *aView, const nsIntRegion& aRegion)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-07-18 19:23:47 -07:00
|
|
|
NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// damageRegion is the damaged area, in twips, relative to the view origin
|
2010-07-18 19:23:47 -07:00
|
|
|
nsRegion damageRegion = aRegion.ToAppUnits(AppUnitsPerDevPixel());
|
2010-03-01 00:03:49 -08:00
|
|
|
// move region from widget coordinates into view coordinates
|
2010-07-18 19:23:47 -07:00
|
|
|
damageRegion.MoveBy(-aView->ViewToWidgetOffset());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (damageRegion.IsEmpty()) {
|
|
|
|
#ifdef DEBUG_roc
|
2011-05-11 08:49:16 -07:00
|
|
|
nsRect viewRect = aView->GetDimensions();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRect damageRect = damageRegion.GetBounds();
|
|
|
|
printf("XXX Damage rectangle (%d,%d,%d,%d) does not intersect the widget's view (%d,%d,%d,%d)!\n",
|
|
|
|
damageRect.x, damageRect.y, damageRect.width, damageRect.height,
|
|
|
|
viewRect.x, viewRect.y, viewRect.width, viewRect.height);
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
2012-09-11 14:21:46 -07:00
|
|
|
|
|
|
|
nsIWidget *widget = aView->GetWidget();
|
|
|
|
if (!widget) {
|
|
|
|
return;
|
|
|
|
}
|
2012-08-20 19:40:45 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(!IsPainting(), "recursive painting not permitted");
|
|
|
|
if (IsPainting()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
RootViewManager()->mRecursiveRefreshPending = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-14 16:08:57 -07:00
|
|
|
{
|
2009-11-15 14:48:18 -08:00
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
2011-10-17 07:59:28 -07:00
|
|
|
SetPainting(true);
|
2008-03-14 16:08:57 -07:00
|
|
|
|
2012-01-27 19:36:23 -08:00
|
|
|
NS_ASSERTION(GetDisplayRootFor(aView) == aView,
|
|
|
|
"Widgets that we paint must all be display roots");
|
|
|
|
|
|
|
|
if (mPresShell) {
|
2013-05-13 16:47:02 -07:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
|
|
|
|
printf("--COMPOSITE-- %p\n", mPresShell);
|
|
|
|
}
|
2012-08-13 03:10:10 -07:00
|
|
|
#endif
|
2013-06-18 00:59:29 -07:00
|
|
|
uint32_t paintFlags = nsIPresShell::PAINT_COMPOSITE;
|
|
|
|
LayerManager *manager = widget->GetLayerManager();
|
|
|
|
if (!manager->NeedsWidgetInvalidation()) {
|
|
|
|
manager->FlushRendering();
|
|
|
|
} else {
|
|
|
|
mPresShell->Paint(aView, damageRegion,
|
|
|
|
paintFlags);
|
|
|
|
}
|
2013-05-13 16:47:02 -07:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
|
|
|
|
printf("--ENDCOMPOSITE--\n");
|
|
|
|
}
|
2012-08-13 03:10:10 -07:00
|
|
|
#endif
|
2012-01-27 19:36:23 -08:00
|
|
|
mozilla::StartupTimeline::RecordOnce(mozilla::StartupTimeline::FIRST_PAINT);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
SetPainting(false);
|
2008-03-14 16:08:57 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (RootViewManager()->mRecursiveRefreshPending) {
|
2011-10-17 07:59:28 -07:00
|
|
|
RootViewManager()->mRecursiveRefreshPending = false;
|
2011-12-23 19:52:25 -08:00
|
|
|
InvalidateAllViews();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsViewManager::ProcessPendingUpdatesForView(nsView* aView,
|
2011-12-23 19:52:23 -08:00
|
|
|
bool aFlushDirtyRegion)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(IsRootVM(), "Updates will be missed");
|
|
|
|
|
|
|
|
// Protect against a null-view.
|
|
|
|
if (!aView) {
|
2012-07-03 17:14:47 -07:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aView->HasWidget()) {
|
2011-12-23 19:52:23 -08:00
|
|
|
aView->ResetWidgetBounds(false, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// process pending updates in child view.
|
2013-01-03 05:23:11 -08:00
|
|
|
for (nsView* childView = aView->GetFirstChild(); childView;
|
2007-03-22 10:30:00 -07:00
|
|
|
childView = childView->GetNextSibling()) {
|
2012-07-03 17:14:47 -07:00
|
|
|
ProcessPendingUpdatesForView(childView, aFlushDirtyRegion);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-12-23 19:52:23 -08:00
|
|
|
// Push out updates after we've processed the children; ensures that
|
|
|
|
// damage is applied based on the final widget geometry
|
2012-08-28 22:47:18 -07:00
|
|
|
if (aFlushDirtyRegion) {
|
2013-01-04 19:14:17 -08:00
|
|
|
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);
|
2012-08-13 03:10:11 -07:00
|
|
|
}
|
2013-01-04 19:14:17 -08:00
|
|
|
}
|
2012-08-13 03:10:11 -07:00
|
|
|
|
2013-01-04 19:14:17 -08:00
|
|
|
NS_ASSERTION(aView->HasWidget(), "Must have a widget!");
|
2012-08-13 03:10:11 -07:00
|
|
|
|
2013-05-13 16:47:02 -07:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
|
|
|
|
printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget);
|
|
|
|
}
|
2012-08-13 03:10:10 -07:00
|
|
|
#endif
|
2013-01-04 19:14:17 -08:00
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
|
|
|
NS_ASSERTION(aView->HasWidget(), "Must have a widget!");
|
2013-01-16 14:59:23 -08:00
|
|
|
SetPainting(true);
|
2013-01-04 19:14:17 -08:00
|
|
|
mPresShell->Paint(aView, nsRegion(),
|
2013-01-28 11:34:11 -08:00
|
|
|
nsIPresShell::PAINT_LAYERS);
|
2013-05-13 16:47:02 -07:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
|
|
|
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
|
|
|
|
printf("---- PAINT END ----\n");
|
|
|
|
}
|
2012-08-13 03:10:10 -07:00
|
|
|
#endif
|
2013-01-04 19:14:17 -08:00
|
|
|
aView->SetForcedRepaint(false);
|
|
|
|
SetPainting(false);
|
2013-07-11 07:43:35 -07:00
|
|
|
FlushDirtyRegionToWidget(aView);
|
|
|
|
} else {
|
|
|
|
FlushDirtyRegionToWidget(aView);
|
2012-08-13 03:10:10 -07:00
|
|
|
}
|
2011-12-23 19:52:23 -08:00
|
|
|
}
|
2011-12-23 19:52:22 -08:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsViewManager::FlushDirtyRegionToWidget(nsView* aView)
|
2011-12-23 19:52:22 -08:00
|
|
|
{
|
|
|
|
if (!aView->HasNonEmptyDirtyRegion())
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsRegion* dirtyRegion = aView->GetDirtyRegion();
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* nearestViewWithWidget = aView;
|
2011-12-23 19:52:22 -08:00
|
|
|
while (!nearestViewWithWidget->HasWidget() &&
|
|
|
|
nearestViewWithWidget->GetParent()) {
|
|
|
|
nearestViewWithWidget = nearestViewWithWidget->GetParent();
|
2011-12-23 19:52:23 -08:00
|
|
|
}
|
2011-12-23 19:52:22 -08:00
|
|
|
nsRegion r =
|
|
|
|
ConvertRegionBetweenViews(*dirtyRegion, aView, nearestViewWithWidget);
|
2013-01-04 19:13:23 -08:00
|
|
|
nsViewManager* widgetVM = nearestViewWithWidget->GetViewManager();
|
2011-12-23 19:52:25 -08:00
|
|
|
widgetVM->InvalidateWidgetArea(nearestViewWithWidget, r);
|
2011-12-23 19:52:22 -08:00
|
|
|
dirtyRegion->SetEmpty();
|
2011-12-23 19:52:22 -08:00
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::InvalidateView(nsView *aView)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Mark the entire view as damaged
|
2013-01-04 19:13:05 -08:00
|
|
|
InvalidateView(aView, aView->GetDimensions());
|
2011-12-23 19:52:23 -08:00
|
|
|
}
|
|
|
|
|
2011-12-23 19:52:22 -08:00
|
|
|
static void
|
2013-01-03 05:23:11 -08:00
|
|
|
AddDirtyRegion(nsView *aView, const nsRegion &aDamagedRegion)
|
2011-12-23 19:52:22 -08:00
|
|
|
{
|
|
|
|
nsRegion* dirtyRegion = aView->GetDirtyRegion();
|
|
|
|
if (!dirtyRegion)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dirtyRegion->Or(*dirtyRegion, aDamagedRegion);
|
|
|
|
dirtyRegion->SimplifyOutward(8);
|
|
|
|
}
|
|
|
|
|
2011-12-23 19:52:23 -08:00
|
|
|
void
|
|
|
|
nsViewManager::PostPendingUpdate()
|
|
|
|
{
|
|
|
|
nsViewManager* rootVM = RootViewManager();
|
2011-12-23 19:52:23 -08:00
|
|
|
rootVM->mHasPendingWidgetGeometryChanges = true;
|
2012-07-03 17:14:47 -07:00
|
|
|
if (rootVM->mPresShell) {
|
2012-07-03 17:20:24 -07:00
|
|
|
rootVM->mPresShell->ScheduleViewManagerFlush();
|
2011-12-23 19:52:23 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* @param aDamagedRegion this region, relative to aWidgetView, is invalidated in
|
|
|
|
* every widget child of aWidgetView, plus aWidgetView's own widget
|
|
|
|
*/
|
|
|
|
void
|
2013-01-03 05:23:11 -08:00
|
|
|
nsViewManager::InvalidateWidgetArea(nsView *aWidgetView,
|
2011-12-23 19:52:25 -08:00
|
|
|
const nsRegion &aDamagedRegion)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-07-18 19:23:47 -07:00
|
|
|
NS_ASSERTION(aWidgetView->GetViewManager() == this,
|
2011-12-23 19:52:25 -08:00
|
|
|
"InvalidateWidgetArea called on view we don't own");
|
2011-12-23 19:52:23 -08:00
|
|
|
nsIWidget* widget = aWidgetView->GetWidget();
|
2010-07-18 19:23:47 -07:00
|
|
|
|
2010-06-24 19:01:06 -07:00
|
|
|
#if 0
|
|
|
|
nsRect dbgBounds = aDamagedRegion.GetBounds();
|
2011-12-23 19:52:25 -08:00
|
|
|
printf("InvalidateWidgetArea view:%X (%d) widget:%X region: %d, %d, %d, %d\n",
|
2010-06-24 19:01:06 -07:00
|
|
|
aWidgetView, aWidgetView->IsAttachedToTopLevel(),
|
2011-12-23 19:52:23 -08:00
|
|
|
widget, dbgBounds.x, dbgBounds.y, dbgBounds.width, dbgBounds.height);
|
2010-06-24 19:01:06 -07:00
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// If the widget is hidden, it don't cover nothing
|
2012-07-19 01:57:50 -07:00
|
|
|
if (widget && !widget->IsVisible()) {
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-12-23 19:52:23 -08:00
|
|
|
if (!widget) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// The root view or a scrolling view might not have a widget
|
|
|
|
// (for example, during printing). We get here when we scroll
|
|
|
|
// during printing to show selected options in a listbox, for example.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update all child widgets with the damage. In the process,
|
|
|
|
// accumulate the union of all the child widget areas, or at least
|
|
|
|
// some subset of that.
|
|
|
|
nsRegion children;
|
2011-12-23 19:52:23 -08:00
|
|
|
if (widget->GetTransparencyMode() != eTransparencyTransparent) {
|
|
|
|
for (nsIWidget* childWidget = widget->GetFirstChild();
|
2009-02-24 08:53:32 -08:00
|
|
|
childWidget;
|
|
|
|
childWidget = childWidget->GetNextSibling()) {
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* view = nsView::GetViewFor(childWidget);
|
2009-02-24 08:53:32 -08:00
|
|
|
NS_ASSERTION(view != aWidgetView, "will recur infinitely");
|
2010-09-11 11:24:50 -07:00
|
|
|
nsWindowType type;
|
|
|
|
childWidget->GetWindowType(type);
|
2012-07-19 01:57:50 -07:00
|
|
|
if (view && childWidget->IsVisible() && type != eWindowType_popup) {
|
2010-09-17 11:05:51 -07:00
|
|
|
NS_ASSERTION(type == eWindowType_plugin,
|
|
|
|
"Only plugin or popup widgets can be children!");
|
|
|
|
|
|
|
|
// We do not need to invalidate in plugin widgets, but we should
|
|
|
|
// exclude them from the invalidation region IF we're not on
|
|
|
|
// Mac. On Mac we need to draw under plugin widgets, because
|
|
|
|
// plugin widgets are basically invisible
|
|
|
|
#ifndef XP_MACOSX
|
|
|
|
// GetBounds should compensate for chrome on a toplevel widget
|
|
|
|
nsIntRect bounds;
|
|
|
|
childWidget->GetBounds(bounds);
|
|
|
|
|
|
|
|
nsTArray<nsIntRect> clipRects;
|
|
|
|
childWidget->GetWindowClipRegion(&clipRects);
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < clipRects.Length(); ++i) {
|
2010-09-17 11:05:51 -07:00
|
|
|
nsRect rr = (clipRects[i] + bounds.TopLeft()).
|
|
|
|
ToAppUnits(AppUnitsPerDevPixel());
|
|
|
|
children.Or(children, rr - aWidgetView->ViewToWidgetOffset());
|
|
|
|
children.SimplifyInward(20);
|
2009-02-24 08:53:32 -08:00
|
|
|
}
|
2010-09-17 11:05:51 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRegion leftOver;
|
2012-05-03 09:33:51 -07:00
|
|
|
leftOver.Sub(aDamagedRegion, children);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (!leftOver.IsEmpty()) {
|
|
|
|
const nsRect* r;
|
|
|
|
for (nsRegionRectIterator iter(leftOver); (r = iter.Next());) {
|
2010-07-02 12:11:04 -07:00
|
|
|
nsIntRect bounds = ViewToWidget(aWidgetView, *r);
|
2011-12-23 19:52:23 -08:00
|
|
|
widget->Invalidate(bounds);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool
|
2010-08-18 18:16:58 -07:00
|
|
|
ShouldIgnoreInvalidation(nsViewManager* aVM)
|
|
|
|
{
|
|
|
|
while (aVM) {
|
2011-11-21 09:53:20 -08:00
|
|
|
nsIPresShell* shell = aVM->GetPresShell();
|
|
|
|
if (!shell || shell->ShouldIgnoreInvalidation()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2010-08-18 18:16:58 -07:00
|
|
|
}
|
2013-01-04 19:12:24 -08:00
|
|
|
nsView* view = aVM->GetRootView()->GetParent();
|
2013-01-04 19:13:23 -08:00
|
|
|
aVM = view ? view->GetViewManager() : nullptr;
|
2010-08-18 18:16:58 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-08-18 18:16:58 -07:00
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::InvalidateView(nsView *aView, const nsRect &aRect)
|
2010-08-18 18:16:58 -07:00
|
|
|
{
|
|
|
|
// If painting is suppressed in the presshell or an ancestor drop all
|
|
|
|
// invalidates, it will invalidate everything when it unsuppresses.
|
|
|
|
if (ShouldIgnoreInvalidation(this)) {
|
2013-01-04 19:13:05 -08:00
|
|
|
return;
|
2010-08-18 18:16:58 -07:00
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
InvalidateViewNoSuppression(aView, aRect);
|
2010-08-18 18:16:58 -07:00
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::InvalidateViewNoSuppression(nsView *aView,
|
|
|
|
const nsRect &aRect)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_PRECONDITION(nullptr != aView, "null view");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-03 05:23:08 -08:00
|
|
|
NS_ASSERTION(aView->GetViewManager() == this,
|
2011-12-23 19:52:25 -08:00
|
|
|
"InvalidateViewNoSuppression called on view we don't own");
|
2010-07-18 19:23:47 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRect damagedRect(aRect);
|
2009-09-08 22:40:02 -07:00
|
|
|
if (damagedRect.IsEmpty()) {
|
2013-01-04 19:13:05 -08:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* displayRoot = GetDisplayRootFor(aView);
|
2013-01-04 19:13:23 -08:00
|
|
|
nsViewManager* displayRootVM = displayRoot->GetViewManager();
|
2008-11-25 14:09:37 -08:00
|
|
|
// 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.
|
2013-01-03 05:23:08 -08:00
|
|
|
damagedRect.MoveBy(aView->GetOffsetTo(displayRoot));
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t rootAPD = displayRootVM->AppUnitsPerDevPixel();
|
|
|
|
int32_t APD = AppUnitsPerDevPixel();
|
2010-07-18 19:23:47 -07:00
|
|
|
damagedRect = damagedRect.ConvertAppUnitsRoundOut(APD, rootAPD);
|
2011-12-23 19:52:23 -08:00
|
|
|
|
|
|
|
// accumulate this rectangle in the view's dirty region, so we can
|
|
|
|
// process it later.
|
|
|
|
AddDirtyRegion(displayRoot, nsRegion(damagedRect));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::InvalidateAllViews()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (RootViewManager() != this) {
|
2011-12-23 19:52:25 -08:00
|
|
|
return RootViewManager()->InvalidateAllViews();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-12-23 19:52:25 -08:00
|
|
|
InvalidateViews(mRootView);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsViewManager::InvalidateViews(nsView *aView)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-12-23 19:52:25 -08:00
|
|
|
// Invalidate this view.
|
|
|
|
InvalidateView(aView);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-12-23 19:52:25 -08:00
|
|
|
// Invalidate all children as well.
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* childView = aView->GetFirstChild();
|
2012-07-30 07:20:58 -07:00
|
|
|
while (nullptr != childView) {
|
2013-01-04 19:13:23 -08:00
|
|
|
childView->GetViewManager()->InvalidateViews(childView);
|
2007-03-22 10:30:00 -07:00
|
|
|
childView = childView->GetNextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-28 11:34:08 -08:00
|
|
|
void nsViewManager::WillPaintWindow(nsIWidget* aWidget)
|
2010-07-27 06:38:02 -07:00
|
|
|
{
|
2013-01-04 19:14:17 -08:00
|
|
|
if (aWidget) {
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* view = nsView::GetViewFor(aWidget);
|
2013-06-20 06:01:20 -07:00
|
|
|
LayerManager *manager = aWidget->GetLayerManager();
|
|
|
|
if (view &&
|
|
|
|
(view->ForcedRepaint() || !manager->NeedsWidgetInvalidation())) {
|
2012-12-12 13:57:08 -08:00
|
|
|
ProcessPendingUpdates();
|
|
|
|
// Re-get the view pointer here since the ProcessPendingUpdates might have
|
|
|
|
// destroyed it during CallWillPaintOnObservers.
|
2013-01-03 05:23:11 -08:00
|
|
|
view = nsView::GetViewFor(aWidget);
|
2012-12-12 13:57:08 -08:00
|
|
|
if (view) {
|
|
|
|
view->SetForcedRepaint(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-10 03:25:57 -07:00
|
|
|
nsCOMPtr<nsIPresShell> shell = mPresShell;
|
|
|
|
if (shell) {
|
2013-01-28 11:34:11 -08:00
|
|
|
shell->WillPaintWindow();
|
2012-10-10 03:25:57 -07:00
|
|
|
}
|
2012-08-15 11:52:42 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-23 07:49:18 -07:00
|
|
|
bool nsViewManager::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion)
|
2013-01-28 11:34:06 -08:00
|
|
|
{
|
2012-08-15 11:52:42 -07:00
|
|
|
if (!aWidget || !mContext)
|
|
|
|
return false;
|
2010-07-27 06:38:02 -07:00
|
|
|
|
2012-08-15 11:52:42 -07:00
|
|
|
NS_ASSERTION(IsPaintingAllowed(),
|
|
|
|
"shouldn't be receiving paint events while painting is disallowed!");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-15 11:52:42 -07:00
|
|
|
// Get the view pointer here since NS_WILL_PAINT might have
|
|
|
|
// destroyed it during CallWillPaintOnObservers (bug 378273).
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* view = nsView::GetViewFor(aWidget);
|
2012-08-15 11:52:42 -07:00
|
|
|
if (view && !aRegion.IsEmpty()) {
|
2013-01-28 11:34:08 -08:00
|
|
|
Refresh(view, aRegion);
|
2012-08-15 11:52:42 -07:00
|
|
|
}
|
2012-08-13 03:11:33 -07:00
|
|
|
|
2012-08-15 11:52:42 -07:00
|
|
|
return true;
|
|
|
|
}
|
2011-12-23 19:52:24 -08:00
|
|
|
|
2012-08-15 11:52:42 -07:00
|
|
|
void nsViewManager::DidPaintWindow()
|
|
|
|
{
|
2012-10-10 03:25:57 -07:00
|
|
|
nsCOMPtr<nsIPresShell> shell = mPresShell;
|
|
|
|
if (shell) {
|
|
|
|
shell->DidPaintWindow();
|
|
|
|
}
|
2012-08-15 11:52:42 -07:00
|
|
|
}
|
2011-12-23 19:52:24 -08:00
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* aStatus)
|
2012-08-15 11:52:42 -07:00
|
|
|
{
|
2013-03-15 21:47:02 -07:00
|
|
|
PROFILER_LABEL("event", "nsViewManager::DispatchEvent");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-15 11:52:42 -07:00
|
|
|
if ((NS_IS_MOUSE_EVENT(aEvent) &&
|
|
|
|
// Ignore mouse events that we synthesize.
|
|
|
|
static_cast<nsMouseEvent*>(aEvent)->reason == nsMouseEvent::eReal &&
|
|
|
|
// Ignore mouse exit and enter (we'll get moves if the user
|
|
|
|
// is really moving the mouse) since we get them when we
|
|
|
|
// create and destroy widgets.
|
|
|
|
aEvent->message != NS_MOUSE_EXIT &&
|
|
|
|
aEvent->message != NS_MOUSE_ENTER) ||
|
|
|
|
NS_IS_KEY_EVENT(aEvent) ||
|
|
|
|
NS_IS_IME_EVENT(aEvent) ||
|
|
|
|
aEvent->message == NS_PLUGIN_INPUT_EVENT) {
|
|
|
|
gLastUserEventTime = PR_IntervalToMicroseconds(PR_IntervalNow());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the view whose coordinates system we're in.
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* view = aView;
|
2012-08-15 11:52:42 -07:00
|
|
|
bool dispatchUsingCoordinates = NS_IsEventUsingCoordinates(aEvent);
|
|
|
|
if (dispatchUsingCoordinates) {
|
|
|
|
// Will dispatch using coordinates. Pretty bogus but it's consistent
|
|
|
|
// with what presshell does.
|
|
|
|
view = GetDisplayRootFor(view);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the view has no frame, look for a view that does.
|
|
|
|
nsIFrame* frame = view->GetFrame();
|
|
|
|
if (!frame &&
|
|
|
|
(dispatchUsingCoordinates || NS_IS_KEY_EVENT(aEvent) ||
|
|
|
|
NS_IS_IME_RELATED_EVENT(aEvent) ||
|
|
|
|
NS_IS_NON_RETARGETED_PLUGIN_EVENT(aEvent) ||
|
|
|
|
aEvent->message == NS_PLUGIN_ACTIVATE ||
|
2012-10-16 12:41:21 -07:00
|
|
|
aEvent->message == NS_PLUGIN_FOCUS ||
|
|
|
|
aEvent->message == NS_PLUGIN_RESOLUTION_CHANGED)) {
|
2012-08-15 11:52:42 -07:00
|
|
|
while (view && !view->GetFrame()) {
|
|
|
|
view = view->GetParent();
|
2010-07-15 14:08:08 -07:00
|
|
|
}
|
|
|
|
|
2012-08-15 11:52:42 -07:00
|
|
|
if (view) {
|
|
|
|
frame = view->GetFrame();
|
|
|
|
}
|
|
|
|
}
|
2011-11-21 09:53:20 -08:00
|
|
|
|
2012-08-15 11:52:42 -07:00
|
|
|
if (nullptr != frame) {
|
|
|
|
// Hold a refcount to the presshell. The continued existence of the
|
|
|
|
// presshell will delay deletion of this view hierarchy should the event
|
|
|
|
// want to cause its destruction in, say, some JavaScript event handler.
|
|
|
|
nsCOMPtr<nsIPresShell> shell = view->GetViewManager()->GetPresShell();
|
|
|
|
if (shell) {
|
2013-01-04 19:13:05 -08:00
|
|
|
shell->HandleEvent(frame, aEvent, false, aStatus);
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-08-15 11:52:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
*aStatus = nsEventStatus_eIgnore;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Recursively reparent widgets if necessary
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsViewManager::ReparentChildWidgets(nsView* aView, nsIWidget *aNewWidget)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-09-18 04:28:50 -07:00
|
|
|
NS_PRECONDITION(aNewWidget, "");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aView->HasWidget()) {
|
|
|
|
// Check to see if the parent widget is the
|
|
|
|
// same as the new parent. If not then reparent
|
|
|
|
// the widget, otherwise there is nothing more
|
|
|
|
// to do for the view and its descendants
|
|
|
|
nsIWidget* widget = aView->GetWidget();
|
|
|
|
nsIWidget* parentWidget = widget->GetParent();
|
2010-09-18 04:28:50 -07:00
|
|
|
if (parentWidget) {
|
|
|
|
// Child widget
|
|
|
|
if (parentWidget != aNewWidget) {
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
2010-09-18 04:28:50 -07:00
|
|
|
nsresult rv =
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2010-09-18 04:28:50 -07:00
|
|
|
widget->SetParent(aNewWidget);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "SetParent failed!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Toplevel widget (popup, dialog, etc)
|
|
|
|
widget->ReparentNativeWidget(aNewWidget);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Need to check each of the views children to see
|
|
|
|
// if they have a widget and reparent it.
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
for (nsView *kid = aView->GetFirstChild(); kid; kid = kid->GetNextSibling()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
ReparentChildWidgets(kid, aNewWidget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reparent a view and its descendant views widgets if necessary
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
void nsViewManager::ReparentWidgets(nsView* aView, nsView *aParent)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aParent, "Must have a parent");
|
|
|
|
NS_PRECONDITION(aView, "Must have a view");
|
|
|
|
|
|
|
|
// Quickly determine whether the view has pre-existing children or a
|
|
|
|
// widget. In most cases the view will not have any pre-existing
|
|
|
|
// children when this is called. Only in the case
|
|
|
|
// where a view has been reparented by removing it from
|
|
|
|
// a reinserting it into a new location in the view hierarchy do we
|
|
|
|
// have to consider reparenting the existing widgets for the view and
|
|
|
|
// it's descendants.
|
2013-01-03 05:23:08 -08:00
|
|
|
if (aView->HasWidget() || aView->GetFirstChild()) {
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIWidget* parentWidget = aParent->GetNearestWidget(nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (parentWidget) {
|
|
|
|
ReparentChildWidgets(aView, parentWidget);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
NS_WARNING("Can not find a widget for the parent view");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling,
|
|
|
|
bool aAfter)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-03 05:23:08 -08:00
|
|
|
NS_PRECONDITION(nullptr != aParent, "null ptr");
|
|
|
|
NS_PRECONDITION(nullptr != aChild, "null ptr");
|
|
|
|
NS_ASSERTION(aSibling == nullptr || aSibling->GetParent() == aParent,
|
2007-03-22 10:30:00 -07:00
|
|
|
"tried to insert view with invalid sibling");
|
2013-01-03 05:23:08 -08:00
|
|
|
NS_ASSERTION(!IsViewInserted(aChild), "tried to insert an already-inserted view");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-03 05:23:08 -08:00
|
|
|
if ((nullptr != aParent) && (nullptr != aChild))
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// if aAfter is set, we will insert the child after 'prev' (i.e. after 'kid' in document
|
|
|
|
// order, otherwise after 'kid' (i.e. before 'kid' in document order).
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr == aSibling) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aAfter) {
|
|
|
|
// insert at end of document order, i.e., before first view
|
|
|
|
// this is the common case, by far
|
2013-01-03 05:23:08 -08:00
|
|
|
aParent->InsertChild(aChild, nullptr);
|
|
|
|
ReparentWidgets(aChild, aParent);
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
|
|
|
// insert at beginning of document order, i.e., after last view
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView *kid = aParent->GetFirstChild();
|
|
|
|
nsView *prev = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
while (kid) {
|
|
|
|
prev = kid;
|
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
|
|
|
// prev is last view or null if there are no children
|
2013-01-03 05:23:08 -08:00
|
|
|
aParent->InsertChild(aChild, prev);
|
|
|
|
ReparentWidgets(aChild, aParent);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
} else {
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView *kid = aParent->GetFirstChild();
|
|
|
|
nsView *prev = nullptr;
|
2013-01-03 05:23:08 -08:00
|
|
|
while (kid && aSibling != kid) {
|
2007-03-22 10:30:00 -07:00
|
|
|
//get the next sibling view
|
|
|
|
prev = kid;
|
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ASSERTION(kid != nullptr,
|
2007-03-22 10:30:00 -07:00
|
|
|
"couldn't find sibling in child list");
|
|
|
|
if (aAfter) {
|
|
|
|
// insert after 'kid' in document order, i.e. before in view order
|
2013-01-03 05:23:08 -08:00
|
|
|
aParent->InsertChild(aChild, prev);
|
|
|
|
ReparentWidgets(aChild, aParent);
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
|
|
|
// insert before 'kid' in document order, i.e. after in view order
|
2013-01-03 05:23:08 -08:00
|
|
|
aParent->InsertChild(aChild, kid);
|
|
|
|
ReparentWidgets(aChild, aParent);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if the parent view is marked as "floating", make the newly added view float as well.
|
2013-01-03 05:23:08 -08:00
|
|
|
if (aParent->GetFloating())
|
|
|
|
aChild->SetFloating(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// 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
|
2013-07-30 14:10:28 -07:00
|
|
|
SetViewZIndex(aChild, false, aZIndex);
|
2013-01-04 19:13:05 -08:00
|
|
|
InsertChild(aParent, aChild, nullptr, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::RemoveChild(nsView *aChild)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-04 19:13:05 -08:00
|
|
|
NS_ASSERTION(aChild, "aChild must not be null");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* parent = aChild->GetParent();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr != parent) {
|
2013-01-03 05:23:08 -08:00
|
|
|
NS_ASSERTION(aChild->GetViewManager() == this ||
|
2010-07-18 19:23:47 -07:00
|
|
|
parent->GetViewManager() == this, "wrong view manager");
|
2013-01-03 05:23:08 -08:00
|
|
|
parent->RemoveChild(aChild);
|
2010-07-18 19:23:47 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-03 05:23:08 -08:00
|
|
|
NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager");
|
|
|
|
aView->SetPosition(aX, aY);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExposedAreaOnly)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-03 05:23:08 -08:00
|
|
|
NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-03 05:23:08 -08:00
|
|
|
nsRect oldDimensions = aView->GetDimensions();
|
2011-04-18 20:07:23 -07:00
|
|
|
if (!oldDimensions.IsEqualEdges(aRect)) {
|
2013-06-18 00:59:00 -07:00
|
|
|
aView->SetDimensions(aRect, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Note that if layout resizes the view and the view has a custom clip
|
|
|
|
// region set, then we expect layout to update the clip region too. Thus
|
|
|
|
// in the case where mClipRect has been optimized away to just be a null
|
|
|
|
// pointer, and this resize is implicitly changing the clip rect, it's OK
|
|
|
|
// because layout will change it back again if necessary.
|
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::SetViewFloating(nsView *aView, bool aFloating)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-03 05:23:08 -08:00
|
|
|
NS_ASSERTION(!(nullptr == aView), "no view");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-03 05:23:08 -08:00
|
|
|
aView->SetFloating(aFloating);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-03 05:23:08 -08:00
|
|
|
NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-01-03 05:23:08 -08:00
|
|
|
if (aVisible != aView->GetVisibility()) {
|
|
|
|
aView->SetVisibility(aVisible);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
bool nsViewManager::IsViewInserted(nsView *aView)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (mRootView == aView) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2012-07-30 07:20:58 -07:00
|
|
|
} else if (aView->GetParent() == nullptr) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView* view = aView->GetParent()->GetFirstChild();
|
2012-07-30 07:20:58 -07:00
|
|
|
while (view != nullptr) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (view == aView) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2013-01-04 19:14:17 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
view = view->GetNextSibling();
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
2013-07-30 14:10:28 -07:00
|
|
|
nsViewManager::SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-01-03 05:23:08 -08:00
|
|
|
NS_ASSERTION((aView != nullptr), "no view");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// 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) {
|
2013-01-04 19:13:05 -08:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aAutoZIndex) {
|
|
|
|
aZIndex = 0;
|
|
|
|
}
|
|
|
|
|
2013-07-30 14:10:28 -07:00
|
|
|
aView->SetZIndex(aAutoZIndex, aZIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-04 19:12:24 -08:00
|
|
|
nsViewManager*
|
2011-12-23 19:52:23 -08:00
|
|
|
nsViewManager::IncrementDisableRefreshCount()
|
2011-12-23 22:21:58 -08:00
|
|
|
{
|
|
|
|
if (!IsRootVM()) {
|
2011-12-23 19:52:23 -08:00
|
|
|
return RootViewManager()->IncrementDisableRefreshCount();
|
2011-12-23 22:21:58 -08:00
|
|
|
}
|
2011-12-23 19:52:23 -08:00
|
|
|
|
|
|
|
++mRefreshDisableCount;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-01-26 15:59:50 -08:00
|
|
|
return this;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-12-23 19:52:23 -08:00
|
|
|
void
|
|
|
|
nsViewManager::DecrementDisableRefreshCount()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-01-26 15:59:50 -08:00
|
|
|
NS_ASSERTION(IsRootVM(), "Should only be called on root");
|
2011-12-23 19:52:23 -08:00
|
|
|
--mRefreshDisableCount;
|
|
|
|
NS_ASSERTION(mRefreshDisableCount >= 0, "Invalid refresh disable count!");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
|
|
|
nsViewManager::GetRootWidget(nsIWidget **aWidget)
|
2009-07-21 17:45:03 -07:00
|
|
|
{
|
|
|
|
if (!mRootView) {
|
2012-07-30 07:20:58 -07:00
|
|
|
*aWidget = nullptr;
|
2013-01-04 19:13:05 -08:00
|
|
|
return;
|
2009-07-21 17:45:03 -07:00
|
|
|
}
|
|
|
|
if (mRootView->HasWidget()) {
|
|
|
|
*aWidget = mRootView->GetWidget();
|
|
|
|
NS_ADDREF(*aWidget);
|
2013-01-04 19:13:05 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mRootView->GetParent()) {
|
2013-01-04 19:13:23 -08:00
|
|
|
mRootView->GetParent()->GetViewManager()->GetRootWidget(aWidget);
|
2013-01-04 19:13:05 -08:00
|
|
|
return;
|
2009-07-21 17:45:03 -07:00
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
*aWidget = nullptr;
|
2009-07-21 17:45:03 -07:00
|
|
|
}
|
|
|
|
|
2013-01-03 05:23:11 -08:00
|
|
|
nsIntRect nsViewManager::ViewToWidget(nsView *aView, const nsRect &aRect) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-07-02 12:11:04 -07:00
|
|
|
NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager");
|
|
|
|
|
|
|
|
// account for the view's origin not lining up with the widget's
|
2012-05-03 09:33:51 -07:00
|
|
|
nsRect rect = aRect + aView->ViewToWidgetOffset();
|
2007-06-27 23:02:05 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// finally, convert to device coordinates.
|
2010-06-05 13:29:49 -07:00
|
|
|
return rect.ToOutsidePixels(AppUnitsPerDevPixel());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
2011-09-28 23:19:26 -07:00
|
|
|
nsViewManager::IsPainting(bool& aIsPainting)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
aIsPainting = IsPainting();
|
|
|
|
}
|
|
|
|
|
2012-07-03 17:14:47 -07:00
|
|
|
void
|
2011-12-23 19:52:22 -08:00
|
|
|
nsViewManager::ProcessPendingUpdates()
|
|
|
|
{
|
2011-12-23 19:52:23 -08:00
|
|
|
if (!IsRootVM()) {
|
2012-07-03 17:14:47 -07:00
|
|
|
RootViewManager()->ProcessPendingUpdates();
|
|
|
|
return;
|
2011-12-23 19:52:23 -08:00
|
|
|
}
|
2010-08-05 11:39:39 -07:00
|
|
|
|
2013-01-04 19:14:17 -08:00
|
|
|
mPresShell->GetPresContext()->RefreshDriver()->RevokeViewManagerFlush();
|
|
|
|
|
|
|
|
// Flush things like reflows by calling WillPaint on observer presShells.
|
|
|
|
if (mPresShell) {
|
2013-01-28 11:34:08 -08:00
|
|
|
CallWillPaintOnObservers();
|
2012-07-03 17:24:55 -07:00
|
|
|
}
|
2013-01-04 19:14:17 -08:00
|
|
|
ProcessPendingUpdatesForView(mRootView, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-12-23 19:52:23 -08:00
|
|
|
void
|
|
|
|
nsViewManager::UpdateWidgetGeometry()
|
|
|
|
{
|
|
|
|
if (!IsRootVM()) {
|
|
|
|
RootViewManager()->UpdateWidgetGeometry();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mHasPendingWidgetGeometryChanges) {
|
2013-01-04 19:14:17 -08:00
|
|
|
mHasPendingWidgetGeometryChanges = false;
|
2012-08-13 03:10:11 -07:00
|
|
|
ProcessPendingUpdatesForView(mRootView, false);
|
2011-12-23 19:52:23 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-16 03:55:19 -07:00
|
|
|
void
|
2013-01-28 11:34:08 -08:00
|
|
|
nsViewManager::CallWillPaintOnObservers()
|
2009-10-16 03:55:19 -07:00
|
|
|
{
|
2010-07-15 14:08:08 -07:00
|
|
|
NS_PRECONDITION(IsRootVM(), "Must be root VM for this to be called!");
|
2009-10-16 03:55:19 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t index;
|
2009-10-16 03:55:19 -07:00
|
|
|
for (index = 0; index < mVMCount; index++) {
|
|
|
|
nsViewManager* vm = (nsViewManager*)gViewManagers->ElementAt(index);
|
|
|
|
if (vm->RootViewManager() == this) {
|
|
|
|
// One of our kids.
|
2010-09-11 11:24:50 -07:00
|
|
|
if (vm->mRootView && vm->mRootView->IsEffectivelyVisible()) {
|
2011-11-21 09:53:20 -08:00
|
|
|
nsCOMPtr<nsIPresShell> shell = vm->GetPresShell();
|
|
|
|
if (shell) {
|
2013-01-28 11:34:11 -08:00
|
|
|
shell->WillPaint();
|
2010-09-11 11:24:50 -07:00
|
|
|
}
|
2009-10-16 03:55:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-04 19:13:05 -08:00
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
nsViewManager::GetLastUserEventTime(uint32_t& aTime)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
aTime = gLastUserEventTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsViewManager::InvalidateHierarchy()
|
|
|
|
{
|
|
|
|
if (mRootView) {
|
|
|
|
if (!IsRootVM()) {
|
|
|
|
NS_RELEASE(mRootViewManager);
|
|
|
|
}
|
2013-01-03 05:23:11 -08:00
|
|
|
nsView *parent = mRootView->GetParent();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (parent) {
|
2013-01-04 19:13:23 -08:00
|
|
|
mRootViewManager = parent->GetViewManager()->RootViewManager();
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ADDREF(mRootViewManager);
|
|
|
|
NS_ASSERTION(mRootViewManager != this,
|
|
|
|
"Root view had a parent, but it has the same view manager");
|
|
|
|
} else {
|
|
|
|
mRootViewManager = this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|