2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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-09-23 19:19:23 +00:00
|
|
|
|
2013-12-09 02:52:54 +00:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-11 05:50:08 +00:00
|
|
|
|
2012-01-19 14:45:37 +00:00
|
|
|
#include "mozilla/layers/CompositorChild.h"
|
|
|
|
#include "mozilla/layers/CompositorParent.h"
|
2013-06-24 05:28:22 +00:00
|
|
|
#include "mozilla/layers/ImageBridgeChild.h"
|
1998-09-23 19:19:23 +00:00
|
|
|
#include "nsBaseWidget.h"
|
2011-04-17 01:22:44 +00:00
|
|
|
#include "nsDeviceContext.h"
|
1999-01-25 19:18:43 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1998-09-23 19:19:23 +00:00
|
|
|
#include "nsGfxCIID.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
2004-11-24 22:48:45 +00:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2003-05-08 18:31:01 +00:00
|
|
|
#include "nsIScreenManager.h"
|
2004-09-07 18:59:27 +00:00
|
|
|
#include "nsAppDirectoryServiceDefs.h"
|
2007-02-07 07:46:44 +00:00
|
|
|
#include "nsISimpleEnumerator.h"
|
2007-12-03 16:33:42 +00:00
|
|
|
#include "nsIContent.h"
|
2013-10-24 07:18:07 +00:00
|
|
|
#include "nsIDocument.h"
|
2014-04-02 00:21:23 +00:00
|
|
|
#include "nsIPresShell.h"
|
1999-09-09 02:32:54 +00:00
|
|
|
#include "nsIServiceManager.h"
|
2011-05-23 14:54:03 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
2010-03-01 08:03:49 +00:00
|
|
|
#include "BasicLayers.h"
|
2013-05-01 05:03:25 +00:00
|
|
|
#include "ClientLayerManager.h"
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
#include "mozilla/layers/Compositor.h"
|
2010-08-28 02:44:37 +00:00
|
|
|
#include "nsIXULRuntime.h"
|
2012-08-15 18:52:37 +00:00
|
|
|
#include "nsIXULWindow.h"
|
2012-08-15 18:52:41 +00:00
|
|
|
#include "nsIBaseWindow.h"
|
2012-10-26 13:15:22 +00:00
|
|
|
#include "nsXULPopupManager.h"
|
2012-08-15 18:52:42 +00:00
|
|
|
#include "nsIWidgetListener.h"
|
2011-01-18 20:11:19 +00:00
|
|
|
#include "nsIGfxInfo.h"
|
2011-01-21 04:01:25 +00:00
|
|
|
#include "npapi.h"
|
2012-01-19 14:45:37 +00:00
|
|
|
#include "base/thread.h"
|
2013-02-26 09:01:10 +00:00
|
|
|
#include "prdtoa.h"
|
2012-05-22 15:34:34 +00:00
|
|
|
#include "prenv.h"
|
2012-06-19 01:28:00 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-03-15 19:00:16 +00:00
|
|
|
#include "mozilla/unused.h"
|
2013-01-31 23:11:49 +00:00
|
|
|
#include "nsContentUtils.h"
|
2014-02-27 02:53:27 +00:00
|
|
|
#include "gfxPrefs.h"
|
2013-07-09 04:21:05 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-09-25 11:21:18 +00:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2013-11-26 22:15:17 +00:00
|
|
|
#include "GLConsts.h"
|
2014-03-15 19:00:16 +00:00
|
|
|
#include "mozilla/unused.h"
|
2009-09-24 10:58:04 +00:00
|
|
|
|
2012-08-15 18:52:37 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "nsAccessibilityService.h"
|
|
|
|
#endif
|
|
|
|
|
2009-09-24 10:58:04 +00:00
|
|
|
#ifdef DEBUG
|
2006-10-23 15:29:09 +00:00
|
|
|
#include "nsIObserver.h"
|
1999-12-03 07:23:22 +00:00
|
|
|
|
|
|
|
static void debug_RegisterPrefCallbacks();
|
|
|
|
|
1999-09-09 02:32:54 +00:00
|
|
|
#endif
|
|
|
|
|
1999-10-05 14:53:40 +00:00
|
|
|
#ifdef NOISY_WIDGET_LEAKS
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t gNumWidgets;
|
1999-10-05 14:53:40 +00:00
|
|
|
#endif
|
|
|
|
|
2013-12-19 16:42:19 +00:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
#include "nsCocoaFeatures.h"
|
|
|
|
#endif
|
|
|
|
|
2012-10-26 13:15:22 +00:00
|
|
|
nsIRollupListener* nsBaseWidget::gRollupListener = nullptr;
|
|
|
|
|
2010-03-01 08:03:49 +00:00
|
|
|
using namespace mozilla::layers;
|
2013-09-28 01:42:08 +00:00
|
|
|
using namespace mozilla::ipc;
|
2011-05-23 14:54:03 +00:00
|
|
|
using namespace mozilla;
|
2012-01-19 14:45:37 +00:00
|
|
|
using base::Thread;
|
2010-03-01 08:03:49 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIContent* nsBaseWidget::mLastRollup = nullptr;
|
2012-05-15 13:01:48 +00:00
|
|
|
// Global user preference for disabling native theme. Used
|
|
|
|
// in NativeWindowTheme.
|
|
|
|
bool gDisableNativeTheme = false;
|
2007-12-03 16:33:42 +00:00
|
|
|
|
2013-12-14 20:40:56 +00:00
|
|
|
// Async pump timer during injected long touch taps
|
|
|
|
#define TOUCH_INJECT_PUMP_TIMER_MSEC 50
|
|
|
|
#define TOUCH_INJECT_LONG_TAP_DEFAULT_MSEC 1500
|
|
|
|
int32_t nsIWidget::sPointerIdCounter = 0;
|
|
|
|
|
1999-09-04 08:13:41 +00:00
|
|
|
// nsBaseWidget
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(nsBaseWidget, nsIWidget)
|
1999-02-23 08:10:24 +00:00
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
|
2007-12-03 16:33:42 +00:00
|
|
|
nsAutoRollup::nsAutoRollup()
|
|
|
|
{
|
|
|
|
// remember if mLastRollup was null, and only clear it upon destruction
|
|
|
|
// if so. This prevents recursive usage of nsAutoRollup from clearing
|
|
|
|
// mLastRollup when it shouldn't.
|
|
|
|
wasClear = !nsBaseWidget::mLastRollup;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoRollup::~nsAutoRollup()
|
|
|
|
{
|
|
|
|
if (nsBaseWidget::mLastRollup && wasClear) {
|
|
|
|
NS_RELEASE(nsBaseWidget::mLastRollup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsBaseWidget constructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1999-10-05 14:53:40 +00:00
|
|
|
|
1999-08-24 01:00:01 +00:00
|
|
|
nsBaseWidget::nsBaseWidget()
|
2012-08-15 18:52:42 +00:00
|
|
|
: mWidgetListener(nullptr)
|
2012-08-15 18:53:14 +00:00
|
|
|
, mAttachedWidgetListener(nullptr)
|
2012-07-30 14:20:58 +00:00
|
|
|
, mContext(nullptr)
|
2002-11-06 09:35:13 +00:00
|
|
|
, mCursor(eCursor_standard)
|
2014-05-28 01:12:29 +00:00
|
|
|
, mUpdateCursor(true)
|
2002-11-06 09:35:13 +00:00
|
|
|
, mBorderStyle(eBorderStyle_none)
|
2012-11-15 18:55:15 +00:00
|
|
|
, mUseLayersAcceleration(false)
|
2012-02-27 21:33:19 +00:00
|
|
|
, mForceLayersAcceleration(false)
|
2011-10-17 14:59:28 +00:00
|
|
|
, mTemporarilyUseBasicLayerManager(false)
|
2012-08-15 18:53:09 +00:00
|
|
|
, mUseAttachedEvents(false)
|
2012-09-29 11:36:09 +00:00
|
|
|
, mContextInitialized(false)
|
2002-11-06 09:35:13 +00:00
|
|
|
, mBounds(0,0,0,0)
|
2012-07-30 14:20:58 +00:00
|
|
|
, mOriginalBounds(nullptr)
|
2009-07-22 00:44:55 +00:00
|
|
|
, mClipRectCount(0)
|
2002-11-06 09:35:13 +00:00
|
|
|
, mSizeMode(nsSizeMode_Normal)
|
2010-07-27 13:38:03 +00:00
|
|
|
, mPopupLevel(ePopupLevelTop)
|
2012-05-31 17:52:09 +00:00
|
|
|
, mPopupType(ePopupTypeAny)
|
1998-09-23 19:19:23 +00:00
|
|
|
{
|
1999-10-05 14:53:40 +00:00
|
|
|
#ifdef NOISY_WIDGET_LEAKS
|
|
|
|
gNumWidgets++;
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("WIDGETS+ = %d\n", gNumWidgets);
|
1999-10-05 14:53:40 +00:00
|
|
|
#endif
|
|
|
|
|
2002-01-24 01:18:36 +00:00
|
|
|
#ifdef DEBUG
|
2012-05-22 15:34:34 +00:00
|
|
|
debug_RegisterPrefCallbacks();
|
1999-12-03 07:23:22 +00:00
|
|
|
#endif
|
2013-06-17 02:50:32 +00:00
|
|
|
|
|
|
|
mShutdownObserver = new WidgetShutdownObserver(this);
|
|
|
|
nsContentUtils::RegisterShutdownObserver(mShutdownObserver);
|
1998-09-23 19:19:23 +00:00
|
|
|
}
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(WidgetShutdownObserver, nsIObserver)
|
2013-06-17 02:50:32 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
WidgetShutdownObserver::Observe(nsISupports *aSubject,
|
|
|
|
const char *aTopic,
|
2014-01-04 15:02:17 +00:00
|
|
|
const char16_t *aData)
|
2013-06-17 02:50:32 +00:00
|
|
|
{
|
2013-06-19 02:21:01 +00:00
|
|
|
if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0 &&
|
|
|
|
mWidget) {
|
2013-06-17 02:50:32 +00:00
|
|
|
mWidget->Shutdown();
|
|
|
|
nsContentUtils::UnregisterShutdownObserver(this);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBaseWidget::Shutdown()
|
|
|
|
{
|
|
|
|
DestroyCompositor();
|
|
|
|
mShutdownObserver = nullptr;
|
|
|
|
}
|
1998-09-23 19:19:23 +00:00
|
|
|
|
2012-05-23 14:17:44 +00:00
|
|
|
static void DeferredDestroyCompositor(CompositorParent* aCompositorParent,
|
2012-07-13 15:25:29 +00:00
|
|
|
CompositorChild* aCompositorChild)
|
2012-03-30 19:43:11 +00:00
|
|
|
{
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
// Bug 848949 needs to be fixed before
|
|
|
|
// we can close the channel properly
|
|
|
|
//aCompositorChild->Close();
|
2012-03-30 19:43:11 +00:00
|
|
|
aCompositorParent->Release();
|
|
|
|
aCompositorChild->Release();
|
|
|
|
}
|
|
|
|
|
2013-01-01 22:38:48 +00:00
|
|
|
void nsBaseWidget::DestroyCompositor()
|
2012-05-23 14:17:44 +00:00
|
|
|
{
|
|
|
|
if (mCompositorChild) {
|
|
|
|
mCompositorChild->SendWillStop();
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
mCompositorChild->Destroy();
|
2012-05-23 14:17:44 +00:00
|
|
|
|
|
|
|
// The call just made to SendWillStop can result in IPC from the
|
|
|
|
// CompositorParent to the CompositorChild (e.g. caused by the destruction
|
|
|
|
// of shared memory). We need to ensure this gets processed by the
|
|
|
|
// CompositorChild before it gets destroyed. It suffices to ensure that
|
|
|
|
// events already in the MessageLoop get processed before the
|
|
|
|
// CompositorChild is destroyed, so we add a task to the MessageLoop to
|
|
|
|
// handle compositor desctruction.
|
|
|
|
MessageLoop::current()->PostTask(FROM_HERE,
|
|
|
|
NewRunnableFunction(DeferredDestroyCompositor, mCompositorParent,
|
2012-07-13 15:25:29 +00:00
|
|
|
mCompositorChild));
|
2012-05-23 14:17:44 +00:00
|
|
|
// The DestroyCompositor task we just added to the MessageLoop will handle
|
|
|
|
// releasing mCompositorParent and mCompositorChild.
|
2014-03-15 19:00:16 +00:00
|
|
|
unused << mCompositorParent.forget();
|
|
|
|
unused << mCompositorChild.forget();
|
2012-05-23 14:17:44 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-30 19:43:11 +00:00
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsBaseWidget destructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsBaseWidget::~nsBaseWidget()
|
|
|
|
{
|
2010-07-15 21:08:10 +00:00
|
|
|
if (mLayerManager &&
|
2014-01-23 18:26:41 +00:00
|
|
|
mLayerManager->GetBackendType() == LayersBackend::LAYERS_BASIC) {
|
2010-07-15 21:08:10 +00:00
|
|
|
static_cast<BasicLayerManager*>(mLayerManager.get())->ClearRetainerWidget();
|
|
|
|
}
|
|
|
|
|
2010-12-07 02:05:25 +00:00
|
|
|
if (mLayerManager) {
|
|
|
|
mLayerManager->Destroy();
|
2012-07-30 14:20:58 +00:00
|
|
|
mLayerManager = nullptr;
|
2012-01-19 14:45:37 +00:00
|
|
|
}
|
|
|
|
|
2013-06-17 02:50:32 +00:00
|
|
|
if (mShutdownObserver) {
|
2013-06-19 02:21:01 +00:00
|
|
|
// If the shutdown observer is currently processing observers,
|
|
|
|
// then UnregisterShutdownObserver won't stop our Observer
|
|
|
|
// function from being called. Make sure we don't try
|
|
|
|
// to reference the dead widget.
|
|
|
|
mShutdownObserver->mWidget = nullptr;
|
2013-06-17 02:50:32 +00:00
|
|
|
nsContentUtils::UnregisterShutdownObserver(mShutdownObserver);
|
|
|
|
}
|
|
|
|
|
2012-05-23 14:17:44 +00:00
|
|
|
DestroyCompositor();
|
2010-12-07 02:05:25 +00:00
|
|
|
|
1999-10-05 14:53:40 +00:00
|
|
|
#ifdef NOISY_WIDGET_LEAKS
|
|
|
|
gNumWidgets--;
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("WIDGETS- = %d\n", gNumWidgets);
|
1999-10-05 14:53:40 +00:00
|
|
|
#endif
|
|
|
|
|
2004-01-05 23:28:41 +00:00
|
|
|
NS_IF_RELEASE(mContext);
|
2011-05-17 14:01:36 +00:00
|
|
|
delete mOriginalBounds;
|
1998-09-23 19:19:23 +00:00
|
|
|
}
|
|
|
|
|
1999-10-15 00:49:11 +00:00
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Basic create.
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsBaseWidget::BaseCreate(nsIWidget *aParent,
|
2009-01-15 03:27:09 +00:00
|
|
|
const nsIntRect &aRect,
|
2011-04-17 01:22:44 +00:00
|
|
|
nsDeviceContext *aContext,
|
1999-09-28 01:31:41 +00:00
|
|
|
nsWidgetInitData *aInitData)
|
1998-09-23 19:19:23 +00:00
|
|
|
{
|
2012-05-15 13:01:48 +00:00
|
|
|
static bool gDisableNativeThemeCached = false;
|
|
|
|
if (!gDisableNativeThemeCached) {
|
2012-07-17 23:59:45 +00:00
|
|
|
Preferences::AddBoolVarCache(&gDisableNativeTheme,
|
|
|
|
"mozilla.widget.disable-native-theme",
|
|
|
|
gDisableNativeTheme);
|
2012-05-15 13:01:48 +00:00
|
|
|
gDisableNativeThemeCached = true;
|
|
|
|
}
|
|
|
|
|
1999-09-28 01:31:41 +00:00
|
|
|
// keep a reference to the device context
|
|
|
|
if (aContext) {
|
|
|
|
mContext = aContext;
|
|
|
|
NS_ADDREF(mContext);
|
|
|
|
}
|
|
|
|
else {
|
2011-04-17 01:22:42 +00:00
|
|
|
mContext = new nsDeviceContext();
|
|
|
|
NS_ADDREF(mContext);
|
2012-07-30 14:20:58 +00:00
|
|
|
mContext->Init(nullptr);
|
1999-09-28 01:31:41 +00:00
|
|
|
}
|
1998-09-23 19:19:23 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
if (nullptr != aInitData) {
|
2009-09-24 09:32:20 +00:00
|
|
|
mWindowType = aInitData->mWindowType;
|
|
|
|
mBorderStyle = aInitData->mBorderStyle;
|
2010-07-27 13:38:03 +00:00
|
|
|
mPopupLevel = aInitData->mPopupLevel;
|
2012-05-31 17:52:09 +00:00
|
|
|
mPopupType = aInitData->mPopupHint;
|
2014-02-21 01:26:41 +00:00
|
|
|
mRequireOffMainThreadCompositing = aInitData->mRequireOffMainThreadCompositing;
|
1999-09-28 01:31:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aParent) {
|
|
|
|
aParent->AddChild(this);
|
|
|
|
}
|
1998-09-23 19:19:23 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP nsBaseWidget::CaptureMouse(bool aCapture)
|
1999-06-21 20:37:50 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Accessor functions to get/set the client data
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2012-08-15 18:52:42 +00:00
|
|
|
nsIWidgetListener* nsBaseWidget::GetWidgetListener()
|
1998-09-23 19:19:23 +00:00
|
|
|
{
|
2012-08-15 18:52:42 +00:00
|
|
|
return mWidgetListener;
|
1998-09-23 19:19:23 +00:00
|
|
|
}
|
|
|
|
|
2012-08-15 18:52:42 +00:00
|
|
|
void nsBaseWidget::SetWidgetListener(nsIWidgetListener* aWidgetListener)
|
1998-09-23 19:19:23 +00:00
|
|
|
{
|
2012-08-15 18:52:42 +00:00
|
|
|
mWidgetListener = aWidgetListener;
|
1998-09-23 19:19:23 +00:00
|
|
|
}
|
|
|
|
|
2010-08-20 19:29:02 +00:00
|
|
|
already_AddRefed<nsIWidget>
|
|
|
|
nsBaseWidget::CreateChild(const nsIntRect &aRect,
|
2011-04-17 01:22:44 +00:00
|
|
|
nsDeviceContext *aContext,
|
2010-08-20 19:29:02 +00:00
|
|
|
nsWidgetInitData *aInitData,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aForceUseIWidgetParent)
|
2010-08-20 19:29:02 +00:00
|
|
|
{
|
|
|
|
nsIWidget* parent = this;
|
2012-07-30 14:20:58 +00:00
|
|
|
nsNativeWidget nativeParent = nullptr;
|
2010-08-20 19:29:02 +00:00
|
|
|
|
|
|
|
if (!aForceUseIWidgetParent) {
|
|
|
|
// Use only either parent or nativeParent, not both, to match
|
|
|
|
// existing code. Eventually Create() should be divested of its
|
|
|
|
// nativeWidget parameter.
|
2012-07-30 14:20:58 +00:00
|
|
|
nativeParent = parent ? parent->GetNativeData(NS_NATIVE_WIDGET) : nullptr;
|
|
|
|
parent = nativeParent ? nullptr : parent;
|
2010-08-20 19:29:02 +00:00
|
|
|
NS_ABORT_IF_FALSE(!parent || !nativeParent, "messed up logic");
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWidget> widget;
|
|
|
|
if (aInitData && aInitData->mWindowType == eWindowType_popup) {
|
|
|
|
widget = AllocateChildPopupWidget();
|
|
|
|
} else {
|
|
|
|
static NS_DEFINE_IID(kCChildCID, NS_CHILD_CID);
|
|
|
|
widget = do_CreateInstance(kCChildCID);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widget &&
|
|
|
|
NS_SUCCEEDED(widget->Create(parent, nativeParent, aRect,
|
2011-10-25 15:05:32 +00:00
|
|
|
aContext, aInitData))) {
|
2010-08-20 19:29:02 +00:00
|
|
|
return widget.forget();
|
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-08-20 19:29:02 +00:00
|
|
|
}
|
|
|
|
|
2013-01-01 22:38:48 +00:00
|
|
|
// Attach a view to our widget which we'll send events to.
|
2010-06-25 02:01:06 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-15 18:53:09 +00:00
|
|
|
nsBaseWidget::AttachViewToTopLevel(bool aUseAttachedEvents,
|
2011-04-17 01:22:44 +00:00
|
|
|
nsDeviceContext *aContext)
|
2010-06-25 02:01:06 +00:00
|
|
|
{
|
2010-09-08 15:52:58 +00:00
|
|
|
NS_ASSERTION((mWindowType == eWindowType_toplevel ||
|
|
|
|
mWindowType == eWindowType_dialog ||
|
2011-02-09 20:13:18 +00:00
|
|
|
mWindowType == eWindowType_invisible ||
|
|
|
|
mWindowType == eWindowType_child),
|
|
|
|
"Can't attach to window of that type");
|
2010-06-25 02:01:06 +00:00
|
|
|
|
2012-08-15 18:53:09 +00:00
|
|
|
mUseAttachedEvents = aUseAttachedEvents;
|
2010-06-25 02:01:06 +00:00
|
|
|
|
|
|
|
if (aContext) {
|
|
|
|
if (mContext) {
|
|
|
|
NS_IF_RELEASE(mContext);
|
|
|
|
}
|
|
|
|
mContext = aContext;
|
|
|
|
NS_ADDREF(mContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-15 18:53:14 +00:00
|
|
|
nsIWidgetListener* nsBaseWidget::GetAttachedWidgetListener()
|
2010-06-25 02:01:06 +00:00
|
|
|
{
|
2012-08-15 18:53:14 +00:00
|
|
|
return mAttachedWidgetListener;
|
2010-06-25 02:01:06 +00:00
|
|
|
}
|
2013-01-01 22:38:48 +00:00
|
|
|
|
2012-08-15 18:53:14 +00:00
|
|
|
void nsBaseWidget::SetAttachedWidgetListener(nsIWidgetListener* aListener)
|
2010-06-25 02:01:06 +00:00
|
|
|
{
|
2012-08-15 18:53:14 +00:00
|
|
|
mAttachedWidgetListener = aListener;
|
2010-06-25 02:01:06 +00:00
|
|
|
}
|
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Close this nsBaseWidget
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsBaseWidget::Destroy()
|
1998-09-23 19:19:23 +00:00
|
|
|
{
|
2004-05-22 20:54:40 +00:00
|
|
|
// Just in case our parent is the only ref to us
|
|
|
|
nsCOMPtr<nsIWidget> kungFuDeathGrip(this);
|
1998-09-23 19:19:23 +00:00
|
|
|
// disconnect from the parent
|
|
|
|
nsIWidget *parent = GetParent();
|
|
|
|
if (parent) {
|
|
|
|
parent->RemoveChild(this);
|
|
|
|
}
|
1999-04-19 23:24:40 +00:00
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-09-23 19:19:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-12 03:59:15 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set this nsBaseWidget's parent
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP nsBaseWidget::SetParent(nsIWidget* aNewParent)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this nsBaseWidget parent
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsIWidget* nsBaseWidget::GetParent(void)
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
1998-09-23 19:19:23 +00:00
|
|
|
}
|
|
|
|
|
2008-09-16 08:21:06 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this nsBaseWidget top level widget
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2009-08-03 22:25:20 +00:00
|
|
|
nsIWidget* nsBaseWidget::GetTopLevelWidget()
|
2008-09-16 08:21:06 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIWidget *topLevelWidget = nullptr, *widget = this;
|
2008-09-16 08:21:06 +00:00
|
|
|
while (widget) {
|
|
|
|
topLevelWidget = widget;
|
|
|
|
widget = widget->GetParent();
|
|
|
|
}
|
|
|
|
return topLevelWidget;
|
|
|
|
}
|
|
|
|
|
2008-05-02 11:32:50 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this nsBaseWidget's top (non-sheet) parent (if it's a sheet)
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsIWidget* nsBaseWidget::GetSheetWindowParent(void)
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2008-05-02 11:32:50 +00:00
|
|
|
}
|
|
|
|
|
2010-08-13 09:57:48 +00:00
|
|
|
float nsBaseWidget::GetDPI()
|
|
|
|
{
|
|
|
|
return 96.0f;
|
|
|
|
}
|
|
|
|
|
2013-09-18 00:45:19 +00:00
|
|
|
CSSToLayoutDeviceScale nsIWidget::GetDefaultScale()
|
2013-04-09 08:39:47 +00:00
|
|
|
{
|
|
|
|
double devPixelsPerCSSPixel = DefaultScaleOverride();
|
|
|
|
|
|
|
|
if (devPixelsPerCSSPixel <= 0.0) {
|
|
|
|
devPixelsPerCSSPixel = GetDefaultScaleInternal();
|
|
|
|
}
|
|
|
|
|
2013-09-18 00:45:19 +00:00
|
|
|
return CSSToLayoutDeviceScale(devPixelsPerCSSPixel);
|
2013-04-09 08:39:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
double nsIWidget::DefaultScaleOverride()
|
2010-08-13 09:57:48 +00:00
|
|
|
{
|
2012-10-31 00:31:35 +00:00
|
|
|
// The number of device pixels per CSS pixel. A value <= 0 means choose
|
|
|
|
// automatically based on the DPI. A positive value is used as-is. This effectively
|
|
|
|
// controls the size of a CSS "px".
|
2013-02-26 09:01:10 +00:00
|
|
|
double devPixelsPerCSSPixel = -1.0;
|
2012-10-31 00:31:35 +00:00
|
|
|
|
|
|
|
nsAdoptingCString prefString = Preferences::GetCString("layout.css.devPixelsPerPx");
|
|
|
|
if (!prefString.IsEmpty()) {
|
2013-02-26 09:01:10 +00:00
|
|
|
devPixelsPerCSSPixel = PR_strtod(prefString, nullptr);
|
2012-10-31 00:31:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return devPixelsPerCSSPixel;
|
2010-08-13 09:57:48 +00:00
|
|
|
}
|
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Add a child to the list of children
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsBaseWidget::AddChild(nsIWidget* aChild)
|
|
|
|
{
|
2004-05-22 20:54:40 +00:00
|
|
|
NS_PRECONDITION(!aChild->GetNextSibling() && !aChild->GetPrevSibling(),
|
|
|
|
"aChild not properly removed from its old child list");
|
2013-01-01 22:38:48 +00:00
|
|
|
|
2004-05-22 20:54:40 +00:00
|
|
|
if (!mFirstChild) {
|
|
|
|
mFirstChild = mLastChild = aChild;
|
|
|
|
} else {
|
|
|
|
// append to the list
|
|
|
|
NS_ASSERTION(mLastChild, "Bogus state");
|
|
|
|
NS_ASSERTION(!mLastChild->GetNextSibling(), "Bogus state");
|
|
|
|
mLastChild->SetNextSibling(aChild);
|
|
|
|
aChild->SetPrevSibling(mLastChild);
|
|
|
|
mLastChild = aChild;
|
|
|
|
}
|
1998-09-23 19:19:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Remove a child from the list of children
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsBaseWidget::RemoveChild(nsIWidget* aChild)
|
|
|
|
{
|
2013-07-10 03:52:19 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// nsCocoaWindow doesn't implement GetParent, so in that case parent will be
|
|
|
|
// null and we'll just have to do without this assertion.
|
|
|
|
nsIWidget* parent = aChild->GetParent();
|
|
|
|
NS_ASSERTION(!parent || parent == this, "Not one of our kids!");
|
|
|
|
#else
|
2006-03-22 18:00:28 +00:00
|
|
|
NS_ASSERTION(aChild->GetParent() == this, "Not one of our kids!");
|
2013-07-10 03:52:19 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2013-01-01 22:38:48 +00:00
|
|
|
|
2004-05-22 20:54:40 +00:00
|
|
|
if (mLastChild == aChild) {
|
|
|
|
mLastChild = mLastChild->GetPrevSibling();
|
|
|
|
}
|
|
|
|
if (mFirstChild == aChild) {
|
|
|
|
mFirstChild = mFirstChild->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now remove from the list. Make sure that we pass ownership of the tail
|
|
|
|
// of the list correctly before we have aChild let go of it.
|
|
|
|
nsIWidget* prev = aChild->GetPrevSibling();
|
|
|
|
nsIWidget* next = aChild->GetNextSibling();
|
|
|
|
if (prev) {
|
|
|
|
prev->SetNextSibling(next);
|
|
|
|
}
|
|
|
|
if (next) {
|
|
|
|
next->SetPrevSibling(prev);
|
|
|
|
}
|
2013-01-01 22:38:48 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
aChild->SetNextSibling(nullptr);
|
|
|
|
aChild->SetPrevSibling(nullptr);
|
1998-09-23 19:19:23 +00:00
|
|
|
}
|
1999-09-23 23:26:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Sets widget's position within its parent's child list.
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2014-03-19 16:48:08 +00:00
|
|
|
void nsBaseWidget::SetZIndex(int32_t aZIndex)
|
1999-09-23 23:26:25 +00:00
|
|
|
{
|
2006-03-22 18:00:28 +00:00
|
|
|
// Hold a ref to ourselves just in case, since we're going to remove
|
|
|
|
// from our parent.
|
|
|
|
nsCOMPtr<nsIWidget> kungFuDeathGrip(this);
|
2013-01-01 22:38:48 +00:00
|
|
|
|
2004-01-05 23:28:41 +00:00
|
|
|
mZIndex = aZIndex;
|
|
|
|
|
|
|
|
// reorder this child in its parent's list.
|
2007-07-08 07:08:04 +00:00
|
|
|
nsBaseWidget* parent = static_cast<nsBaseWidget*>(GetParent());
|
2004-01-05 23:28:41 +00:00
|
|
|
if (parent) {
|
2004-05-22 20:54:40 +00:00
|
|
|
parent->RemoveChild(this);
|
|
|
|
// Scope sib outside the for loop so we can check it afterward
|
|
|
|
nsIWidget* sib = parent->GetFirstChild();
|
|
|
|
for ( ; sib; sib = sib->GetNextSibling()) {
|
2014-03-19 16:48:08 +00:00
|
|
|
int32_t childZIndex = GetZIndex();
|
|
|
|
if (aZIndex < childZIndex) {
|
|
|
|
// Insert ourselves before sib
|
|
|
|
nsIWidget* prev = sib->GetPrevSibling();
|
|
|
|
mNextSibling = sib;
|
|
|
|
mPrevSibling = prev;
|
|
|
|
sib->SetPrevSibling(this);
|
|
|
|
if (prev) {
|
|
|
|
prev->SetNextSibling(this);
|
|
|
|
} else {
|
|
|
|
NS_ASSERTION(sib == parent->mFirstChild, "Broken child list");
|
|
|
|
// We've taken ownership of sib, so it's safe to have parent let
|
|
|
|
// go of it
|
|
|
|
parent->mFirstChild = this;
|
2004-01-05 23:28:41 +00:00
|
|
|
}
|
2014-03-19 16:48:08 +00:00
|
|
|
PlaceBehind(eZPlacementBelow, sib, false);
|
|
|
|
break;
|
2004-01-05 23:28:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// were we added to the list?
|
2004-05-22 20:54:40 +00:00
|
|
|
if (!sib) {
|
|
|
|
parent->AddChild(this);
|
2004-01-05 23:28:41 +00:00
|
|
|
}
|
|
|
|
}
|
1999-09-23 23:26:25 +00:00
|
|
|
}
|
|
|
|
|
2000-04-01 22:10:22 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Places widget behind the given widget (platforms must override)
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2003-10-07 01:19:51 +00:00
|
|
|
NS_IMETHODIMP nsBaseWidget::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
2011-09-29 06:19:26 +00:00
|
|
|
nsIWidget *aWidget, bool aActivate)
|
2000-04-01 22:10:22 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-09 01:55:48 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Maximize, minimize or restore the window. The BaseWidget implementation
|
|
|
|
// merely stores the state.
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHODIMP nsBaseWidget::SetSizeMode(int32_t aMode)
|
2010-08-27 04:44:01 +00:00
|
|
|
{
|
2009-07-08 16:13:13 +00:00
|
|
|
if (aMode == nsSizeMode_Normal ||
|
|
|
|
aMode == nsSizeMode_Minimized ||
|
|
|
|
aMode == nsSizeMode_Maximized ||
|
|
|
|
aMode == nsSizeMode_Fullscreen) {
|
2000-03-09 01:55:48 +00:00
|
|
|
|
|
|
|
mSizeMode = (nsSizeMode) aMode;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
}
|
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this component cursor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsCursor nsBaseWidget::GetCursor()
|
|
|
|
{
|
1999-09-28 01:31:41 +00:00
|
|
|
return mCursor;
|
1998-09-23 19:19:23 +00:00
|
|
|
}
|
|
|
|
|
1998-09-28 22:32:48 +00:00
|
|
|
NS_METHOD nsBaseWidget::SetCursor(nsCursor aCursor)
|
1998-09-23 19:19:23 +00:00
|
|
|
{
|
2013-01-01 22:38:48 +00:00
|
|
|
mCursor = aCursor;
|
1998-09-28 22:32:48 +00:00
|
|
|
return NS_OK;
|
1998-09-23 19:19:23 +00:00
|
|
|
}
|
2004-12-30 21:56:11 +00:00
|
|
|
|
2005-07-01 04:29:42 +00:00
|
|
|
NS_IMETHODIMP nsBaseWidget::SetCursor(imgIContainer* aCursor,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aHotspotX, uint32_t aHotspotY)
|
2004-12-30 21:56:11 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2013-01-01 22:38:48 +00:00
|
|
|
|
2003-04-06 02:49:40 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Window transparency methods
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2008-08-13 00:44:14 +00:00
|
|
|
void nsBaseWidget::SetTransparencyMode(nsTransparencyMode aMode) {
|
2003-04-06 02:49:40 +00:00
|
|
|
}
|
|
|
|
|
2008-08-13 00:44:14 +00:00
|
|
|
nsTransparencyMode nsBaseWidget::GetTransparencyMode() {
|
|
|
|
return eTransparencyOpaque;
|
2003-04-06 02:49:40 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2009-07-22 00:44:55 +00:00
|
|
|
nsBaseWidget::StoreWindowClipRegion(const nsTArray<nsIntRect>& aRects)
|
|
|
|
{
|
2009-07-26 21:19:15 +00:00
|
|
|
if (mClipRects && mClipRectCount == aRects.Length() &&
|
|
|
|
memcmp(mClipRects, aRects.Elements(), sizeof(nsIntRect)*mClipRectCount) == 0)
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2009-07-26 21:19:15 +00:00
|
|
|
|
2009-07-22 00:44:55 +00:00
|
|
|
mClipRectCount = aRects.Length();
|
|
|
|
mClipRects = new nsIntRect[mClipRectCount];
|
|
|
|
if (mClipRects) {
|
|
|
|
memcpy(mClipRects, aRects.Elements(), sizeof(nsIntRect)*mClipRectCount);
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2009-07-22 00:44:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBaseWidget::GetWindowClipRegion(nsTArray<nsIntRect>* aRects)
|
|
|
|
{
|
|
|
|
if (mClipRects) {
|
|
|
|
aRects->AppendElements(mClipRects.get(), mClipRectCount);
|
|
|
|
} else {
|
|
|
|
aRects->AppendElement(nsIntRect(0, 0, mBounds.width, mBounds.height));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:59:19 +00:00
|
|
|
const nsIntRegion
|
|
|
|
nsBaseWidget::RegionFromArray(const nsTArray<nsIntRect>& aRects)
|
|
|
|
{
|
|
|
|
nsIntRegion region;
|
|
|
|
for (uint32_t i = 0; i < aRects.Length(); ++i) {
|
|
|
|
region.Or(region, aRects[i]);
|
|
|
|
}
|
|
|
|
return region;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBaseWidget::ArrayFromRegion(const nsIntRegion& aRegion, nsTArray<nsIntRect>& aRects)
|
|
|
|
{
|
|
|
|
const nsIntRect* r;
|
|
|
|
for (nsIntRegionRectIterator iter(aRegion); (r = iter.Next());) {
|
|
|
|
aRects.AppendElement(*r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBaseWidget::SetWindowClipRegion(const nsTArray<nsIntRect>& aRects,
|
|
|
|
bool aIntersectWithExisting)
|
|
|
|
{
|
|
|
|
if (!aIntersectWithExisting) {
|
|
|
|
nsBaseWidget::StoreWindowClipRegion(aRects);
|
|
|
|
} else {
|
|
|
|
// In this case still early return if nothing changed.
|
|
|
|
if (mClipRects && mClipRectCount == aRects.Length() &&
|
|
|
|
memcmp(mClipRects,
|
|
|
|
aRects.Elements(),
|
|
|
|
sizeof(nsIntRect)*mClipRectCount) == 0) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get current rects
|
|
|
|
nsTArray<nsIntRect> currentRects;
|
|
|
|
GetWindowClipRegion(¤tRects);
|
|
|
|
// create region from them
|
|
|
|
nsIntRegion currentRegion = RegionFromArray(currentRects);
|
|
|
|
// create region from new rects
|
|
|
|
nsIntRegion newRegion = RegionFromArray(aRects);
|
|
|
|
// intersect regions
|
|
|
|
nsIntRegion intersection;
|
|
|
|
intersection.And(currentRegion, newRegion);
|
|
|
|
// create int rect array from intersection
|
|
|
|
nsTArray<nsIntRect> rects;
|
|
|
|
ArrayFromRegion(intersection, rects);
|
|
|
|
// store
|
|
|
|
nsBaseWidget::StoreWindowClipRegion(rects);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-10-14 15:33:40 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set window shadow style
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHODIMP nsBaseWidget::SetWindowShadowStyle(int32_t aMode)
|
2008-10-14 15:33:40 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-02-20 03:33:52 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Hide window borders/decorations for this widget
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP nsBaseWidget::HideWindowChrome(bool aShouldHide)
|
2002-02-20 03:33:52 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2001-06-04 23:03:24 +00:00
|
|
|
|
2002-11-06 09:35:13 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Put the window into full-screen mode
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2014-07-09 19:29:28 +00:00
|
|
|
NS_IMETHODIMP nsBaseWidget::MakeFullScreen(bool aFullScreen, nsIScreen* aScreen)
|
2002-11-06 09:35:13 +00:00
|
|
|
{
|
2009-07-01 19:01:11 +00:00
|
|
|
HideWindowChrome(aFullScreen);
|
2002-11-06 09:35:13 +00:00
|
|
|
|
|
|
|
if (aFullScreen) {
|
|
|
|
if (!mOriginalBounds)
|
2009-01-15 03:27:09 +00:00
|
|
|
mOriginalBounds = new nsIntRect();
|
2002-11-06 09:35:13 +00:00
|
|
|
GetScreenBounds(*mOriginalBounds);
|
2013-11-29 04:11:49 +00:00
|
|
|
// convert dev pix to display pix for window manipulation
|
2013-09-18 00:45:19 +00:00
|
|
|
CSSToLayoutDeviceScale scale = GetDefaultScale();
|
|
|
|
mOriginalBounds->x = NSToIntRound(mOriginalBounds->x / scale.scale);
|
|
|
|
mOriginalBounds->y = NSToIntRound(mOriginalBounds->y / scale.scale);
|
|
|
|
mOriginalBounds->width = NSToIntRound(mOriginalBounds->width / scale.scale);
|
|
|
|
mOriginalBounds->height = NSToIntRound(mOriginalBounds->height / scale.scale);
|
2003-05-08 18:31:01 +00:00
|
|
|
|
|
|
|
// Move to top-left corner of screen and size to the screen dimensions
|
|
|
|
nsCOMPtr<nsIScreenManager> screenManager;
|
2013-01-01 22:38:48 +00:00
|
|
|
screenManager = do_GetService("@mozilla.org/gfx/screenmanager;1");
|
2003-05-08 18:31:01 +00:00
|
|
|
NS_ASSERTION(screenManager, "Unable to grab screenManager.");
|
|
|
|
if (screenManager) {
|
2014-07-09 19:29:28 +00:00
|
|
|
nsCOMPtr<nsIScreen> screen = aScreen;
|
|
|
|
if (!screen) {
|
|
|
|
// no screen was passed in, use the one that the window is on
|
|
|
|
screenManager->ScreenForRect(mOriginalBounds->x,
|
|
|
|
mOriginalBounds->y,
|
|
|
|
mOriginalBounds->width,
|
|
|
|
mOriginalBounds->height,
|
|
|
|
getter_AddRefs(screen));
|
|
|
|
}
|
|
|
|
|
2003-05-08 18:31:01 +00:00
|
|
|
if (screen) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t left, top, width, height;
|
2013-03-19 17:24:25 +00:00
|
|
|
if (NS_SUCCEEDED(screen->GetRectDisplayPix(&left, &top, &width, &height))) {
|
2011-10-17 14:59:28 +00:00
|
|
|
Resize(left, top, width, height, true);
|
2003-05-08 18:31:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-06 09:35:13 +00:00
|
|
|
} else if (mOriginalBounds) {
|
|
|
|
Resize(mOriginalBounds->x, mOriginalBounds->y, mOriginalBounds->width,
|
2011-10-17 14:59:28 +00:00
|
|
|
mOriginalBounds->height, true);
|
2002-11-06 09:35:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-03-01 08:03:49 +00:00
|
|
|
nsBaseWidget::AutoLayerManagerSetup::AutoLayerManagerSetup(
|
2010-07-15 21:08:04 +00:00
|
|
|
nsBaseWidget* aWidget, gfxContext* aTarget,
|
2012-07-31 00:42:26 +00:00
|
|
|
BufferMode aDoubleBuffering, ScreenRotation aRotation)
|
2010-03-01 08:03:49 +00:00
|
|
|
: mWidget(aWidget)
|
|
|
|
{
|
2012-12-27 05:55:41 +00:00
|
|
|
mLayerManager = static_cast<BasicLayerManager*>(mWidget->GetLayerManager());
|
|
|
|
if (mLayerManager) {
|
2014-01-23 18:26:41 +00:00
|
|
|
NS_ASSERTION(mLayerManager->GetBackendType() == LayersBackend::LAYERS_BASIC,
|
2010-03-31 03:02:58 +00:00
|
|
|
"AutoLayerManagerSetup instantiated for non-basic layer backend!");
|
2012-12-27 05:55:41 +00:00
|
|
|
mLayerManager->SetDefaultTarget(aTarget);
|
|
|
|
mLayerManager->SetDefaultTargetConfiguration(aDoubleBuffering, aRotation);
|
2010-03-01 08:03:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBaseWidget::AutoLayerManagerSetup::~AutoLayerManagerSetup()
|
|
|
|
{
|
2012-12-27 05:55:41 +00:00
|
|
|
if (mLayerManager) {
|
2014-01-23 18:26:41 +00:00
|
|
|
NS_ASSERTION(mLayerManager->GetBackendType() == LayersBackend::LAYERS_BASIC,
|
2010-03-31 03:02:58 +00:00
|
|
|
"AutoLayerManagerSetup instantiated for non-basic layer backend!");
|
2012-12-27 05:55:41 +00:00
|
|
|
mLayerManager->SetDefaultTarget(nullptr);
|
2014-01-23 18:26:41 +00:00
|
|
|
mLayerManager->SetDefaultTargetConfiguration(mozilla::layers::BufferMode::BUFFER_NONE, ROTATION_0);
|
2010-03-01 08:03:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-15 10:34:29 +00:00
|
|
|
nsBaseWidget::AutoUseBasicLayerManager::AutoUseBasicLayerManager(nsBaseWidget* aWidget)
|
|
|
|
: mWidget(aWidget)
|
|
|
|
{
|
2012-12-17 06:35:39 +00:00
|
|
|
mPreviousTemporarilyUseBasicLayerManager =
|
|
|
|
mWidget->mTemporarilyUseBasicLayerManager;
|
2011-10-17 14:59:28 +00:00
|
|
|
mWidget->mTemporarilyUseBasicLayerManager = true;
|
2010-10-15 10:34:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsBaseWidget::AutoUseBasicLayerManager::~AutoUseBasicLayerManager()
|
|
|
|
{
|
2012-12-17 06:35:39 +00:00
|
|
|
mWidget->mTemporarilyUseBasicLayerManager =
|
|
|
|
mPreviousTemporarilyUseBasicLayerManager;
|
2010-10-15 10:34:29 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2012-11-15 18:55:15 +00:00
|
|
|
nsBaseWidget::ComputeShouldAccelerate(bool aDefault)
|
2010-03-01 08:03:49 +00:00
|
|
|
{
|
2013-08-25 23:56:53 +00:00
|
|
|
#if defined(XP_WIN) || defined(ANDROID) || \
|
2014-02-21 02:08:53 +00:00
|
|
|
defined(MOZ_GL_PROVIDER) || defined(XP_MACOSX) || defined(MOZ_WIDGET_QT)
|
2011-09-29 06:19:26 +00:00
|
|
|
bool accelerateByDefault = true;
|
2011-01-11 22:01:37 +00:00
|
|
|
#else
|
2011-09-29 06:19:26 +00:00
|
|
|
bool accelerateByDefault = false;
|
2011-01-11 22:01:37 +00:00
|
|
|
#endif
|
2010-08-28 02:44:37 +00:00
|
|
|
|
2013-01-12 03:59:48 +00:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// 10.6.2 and lower have a bug involving textures and pixel buffer objects
|
|
|
|
// that caused bug 629016, so we don't allow OpenGL-accelerated layers on
|
|
|
|
// those versions of the OS.
|
|
|
|
// This will still let full-screen video be accelerated on OpenGL, because
|
|
|
|
// that XUL widget opts in to acceleration, but that's probably OK.
|
2014-09-17 21:48:07 +00:00
|
|
|
accelerateByDefault = nsCocoaFeatures::AccelerateByDefault();
|
2013-01-12 03:59:48 +00:00
|
|
|
#endif
|
|
|
|
|
2011-05-23 14:54:03 +00:00
|
|
|
// we should use AddBoolPrefVarCache
|
2014-02-27 02:53:27 +00:00
|
|
|
bool disableAcceleration = gfxPrefs::LayersAccelerationDisabled();
|
|
|
|
mForceLayersAcceleration = gfxPrefs::LayersAccelerationForceEnabled();
|
2010-09-08 22:19:11 +00:00
|
|
|
|
|
|
|
const char *acceleratedEnv = PR_GetEnv("MOZ_ACCELERATED");
|
2011-08-31 22:58:19 +00:00
|
|
|
accelerateByDefault = accelerateByDefault ||
|
2010-09-08 22:19:11 +00:00
|
|
|
(acceleratedEnv && (*acceleratedEnv != '0'));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXULRuntime> xr = do_GetService("@mozilla.org/xre/runtime;1");
|
2011-09-29 06:19:26 +00:00
|
|
|
bool safeMode = false;
|
2010-09-08 22:19:11 +00:00
|
|
|
if (xr)
|
|
|
|
xr->GetInSafeMode(&safeMode);
|
2010-05-12 18:56:31 +00:00
|
|
|
|
2011-08-19 15:39:00 +00:00
|
|
|
bool whitelisted = false;
|
2011-01-18 20:11:19 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
|
|
|
|
if (gfxInfo) {
|
2011-09-07 21:17:44 +00:00
|
|
|
// bug 655578: on X11 at least, we must always call GetData (even if we don't need that information)
|
|
|
|
// as that's what causes GfxInfo initialization which kills the zombie 'glxtest' process.
|
|
|
|
// initially we relied on the fact that GetFeatureStatus calls GetData for us, but bug 681026 showed
|
|
|
|
// that assumption to be unsafe.
|
|
|
|
gfxInfo->GetData();
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t status;
|
2011-01-18 20:11:19 +00:00
|
|
|
if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_OPENGL_LAYERS, &status))) {
|
2014-07-01 21:44:09 +00:00
|
|
|
if (status == nsIGfxInfo::FEATURE_STATUS_OK) {
|
2011-08-19 15:39:00 +00:00
|
|
|
whitelisted = true;
|
2011-01-18 20:11:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-19 15:39:00 +00:00
|
|
|
if (disableAcceleration || safeMode)
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2011-08-19 15:39:00 +00:00
|
|
|
|
2012-02-27 21:33:19 +00:00
|
|
|
if (mForceLayersAcceleration)
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2013-01-01 22:38:48 +00:00
|
|
|
|
2011-08-19 15:39:00 +00:00
|
|
|
if (!whitelisted) {
|
2014-01-27 20:40:50 +00:00
|
|
|
static int tell_me_once = 0;
|
|
|
|
if (!tell_me_once) {
|
|
|
|
NS_WARNING("OpenGL-accelerated layers are not supported on this system");
|
|
|
|
tell_me_once = 1;
|
|
|
|
}
|
2014-08-22 19:26:56 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-07-05 14:12:43 +00:00
|
|
|
NS_RUNTIMEABORT("OpenGL-accelerated layers are a hard requirement on this platform. "
|
2013-04-02 17:49:04 +00:00
|
|
|
"Cannot continue without support for them");
|
2012-07-05 14:12:43 +00:00
|
|
|
#endif
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2011-08-19 15:39:00 +00:00
|
|
|
}
|
|
|
|
|
2011-01-18 20:11:19 +00:00
|
|
|
if (accelerateByDefault)
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2010-09-08 22:19:11 +00:00
|
|
|
|
2011-01-11 22:01:37 +00:00
|
|
|
/* use the window acceleration flag */
|
2012-11-15 18:55:15 +00:00
|
|
|
return aDefault;
|
2010-09-08 22:19:11 +00:00
|
|
|
}
|
2010-09-03 18:08:23 +00:00
|
|
|
|
2013-04-17 21:39:13 +00:00
|
|
|
CompositorParent* nsBaseWidget::NewCompositorParent(int aSurfaceWidth,
|
|
|
|
int aSurfaceHeight)
|
|
|
|
{
|
2013-04-30 03:16:04 +00:00
|
|
|
return new CompositorParent(this, false, aSurfaceWidth, aSurfaceHeight);
|
2013-04-17 21:39:13 +00:00
|
|
|
}
|
|
|
|
|
2012-01-19 14:45:37 +00:00
|
|
|
void nsBaseWidget::CreateCompositor()
|
2013-03-20 22:45:07 +00:00
|
|
|
{
|
|
|
|
nsIntRect rect;
|
|
|
|
GetBounds(rect);
|
|
|
|
CreateCompositor(rect.width, rect.height);
|
|
|
|
}
|
|
|
|
|
2013-08-18 06:46:16 +00:00
|
|
|
void
|
|
|
|
nsBaseWidget::GetPreferredCompositorBackends(nsTArray<LayersBackend>& aHints)
|
2013-05-09 21:02:50 +00:00
|
|
|
{
|
2013-06-24 05:27:29 +00:00
|
|
|
if (mUseLayersAcceleration) {
|
2014-01-23 18:26:41 +00:00
|
|
|
aHints.AppendElement(LayersBackend::LAYERS_OPENGL);
|
2013-05-09 21:02:50 +00:00
|
|
|
}
|
|
|
|
|
2014-01-23 18:26:41 +00:00
|
|
|
aHints.AppendElement(LayersBackend::LAYERS_BASIC);
|
2013-08-18 06:46:16 +00:00
|
|
|
}
|
|
|
|
|
2013-03-20 22:45:07 +00:00
|
|
|
void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
|
2012-01-19 14:45:37 +00:00
|
|
|
{
|
2014-10-10 08:53:30 +00:00
|
|
|
// This makes sure that gfxPlatforms gets initialized if it hasn't by now.
|
|
|
|
gfxPlatform::GetPlatform();
|
|
|
|
|
2014-06-06 13:51:24 +00:00
|
|
|
MOZ_ASSERT(gfxPlatform::UsesOffMainThreadCompositing(),
|
|
|
|
"This function assumes OMTC");
|
|
|
|
|
2013-05-03 17:34:33 +00:00
|
|
|
// Recreating this is tricky, as we may still have an old and we need
|
|
|
|
// to make sure it's properly destroyed by calling DestroyCompositor!
|
|
|
|
|
2013-06-17 02:50:32 +00:00
|
|
|
// If we've already received a shutdown notification, don't try
|
|
|
|
// create a new compositor.
|
|
|
|
if (!mShutdownObserver) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-17 21:39:13 +00:00
|
|
|
mCompositorParent = NewCompositorParent(aWidth, aHeight);
|
2013-09-28 01:42:08 +00:00
|
|
|
MessageChannel *parentChannel = mCompositorParent->GetIPCChannel();
|
2014-07-15 15:37:45 +00:00
|
|
|
nsRefPtr<ClientLayerManager> lm = new ClientLayerManager(this);
|
2012-07-13 15:25:29 +00:00
|
|
|
MessageLoop *childMessageLoop = CompositorParent::CompositorLoop();
|
|
|
|
mCompositorChild = new CompositorChild(lm);
|
2013-09-28 01:42:08 +00:00
|
|
|
mCompositorChild->Open(parentChannel, childMessageLoop, ipc::ChildSide);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
|
|
|
|
TextureFactoryIdentifier textureFactoryIdentifier;
|
2014-03-04 08:45:51 +00:00
|
|
|
PLayerTransactionChild* shadowManager = nullptr;
|
2013-08-18 06:46:16 +00:00
|
|
|
nsTArray<LayersBackend> backendHints;
|
|
|
|
GetPreferredCompositorBackends(backendHints);
|
2013-05-03 17:34:33 +00:00
|
|
|
|
2014-09-03 12:59:36 +00:00
|
|
|
#if !defined(MOZ_X11) && !defined(XP_WIN)
|
|
|
|
if (!mRequireOffMainThreadCompositing &&
|
|
|
|
!Preferences::GetBool("layers.offmainthreadcomposition.force-basic", false)) {
|
|
|
|
for (size_t i = 0; i < backendHints.Length(); ++i) {
|
|
|
|
if (backendHints[i] == LayersBackend::LAYERS_BASIC) {
|
|
|
|
backendHints[i] = LayersBackend::LAYERS_NONE;
|
|
|
|
}
|
|
|
|
}
|
2014-09-03 11:52:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-08-08 23:32:26 +00:00
|
|
|
bool success = false;
|
2013-08-18 06:46:16 +00:00
|
|
|
if (!backendHints.IsEmpty()) {
|
2013-08-08 23:32:26 +00:00
|
|
|
shadowManager = mCompositorChild->SendPLayerTransactionConstructor(
|
2013-08-18 06:46:16 +00:00
|
|
|
backendHints, 0, &textureFactoryIdentifier, &success);
|
2013-08-08 23:32:26 +00:00
|
|
|
}
|
2012-01-19 14:45:37 +00:00
|
|
|
|
2013-08-04 07:46:17 +00:00
|
|
|
if (success) {
|
2012-07-13 15:25:29 +00:00
|
|
|
ShadowLayerForwarder* lf = lm->AsShadowForwarder();
|
|
|
|
if (!lf) {
|
2014-07-15 15:37:45 +00:00
|
|
|
lm = nullptr;
|
2012-07-30 14:20:58 +00:00
|
|
|
mCompositorChild = nullptr;
|
2012-07-13 15:25:29 +00:00
|
|
|
return;
|
2012-01-19 14:45:37 +00:00
|
|
|
}
|
2012-07-13 15:25:29 +00:00
|
|
|
lf->SetShadowManager(shadowManager);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
lf->IdentifyTextureHost(textureFactoryIdentifier);
|
2013-06-24 05:28:22 +00:00
|
|
|
ImageBridgeChild::IdentifyCompositorTextureHost(textureFactoryIdentifier);
|
2013-08-08 23:32:26 +00:00
|
|
|
WindowUsesOMTC();
|
2012-07-13 15:25:29 +00:00
|
|
|
|
2014-07-15 15:37:45 +00:00
|
|
|
mLayerManager = lm.forget();
|
2013-05-03 17:34:33 +00:00
|
|
|
return;
|
2012-01-19 14:45:37 +00:00
|
|
|
}
|
2013-05-03 17:34:33 +00:00
|
|
|
|
2013-08-04 23:20:02 +00:00
|
|
|
NS_WARNING("Failed to create an OMT compositor.");
|
2013-05-03 17:34:33 +00:00
|
|
|
DestroyCompositor();
|
|
|
|
// Compositor child had the only reference to LayerManager and will have
|
|
|
|
// deallocated it when being freed.
|
2012-01-19 14:45:37 +00:00
|
|
|
}
|
|
|
|
|
2013-03-04 18:32:20 +00:00
|
|
|
bool nsBaseWidget::ShouldUseOffMainThreadCompositing()
|
2012-05-22 15:34:34 +00:00
|
|
|
{
|
2014-06-06 13:51:24 +00:00
|
|
|
return gfxPlatform::UsesOffMainThreadCompositing();
|
2012-05-22 15:34:34 +00:00
|
|
|
}
|
|
|
|
|
2013-04-24 18:42:40 +00:00
|
|
|
LayerManager* nsBaseWidget::GetLayerManager(PLayerTransactionChild* aShadowManager,
|
2011-08-09 19:38:26 +00:00
|
|
|
LayersBackend aBackendHint,
|
|
|
|
LayerManagerPersistence aPersistence,
|
2010-12-07 02:05:52 +00:00
|
|
|
bool* aAllowRetaining)
|
2010-09-08 22:19:11 +00:00
|
|
|
{
|
|
|
|
if (!mLayerManager) {
|
2010-08-28 02:44:37 +00:00
|
|
|
|
2012-11-15 18:55:15 +00:00
|
|
|
mUseLayersAcceleration = ComputeShouldAccelerate(mUseLayersAcceleration);
|
2010-08-28 02:44:37 +00:00
|
|
|
|
2012-05-15 19:56:56 +00:00
|
|
|
// Try to use an async compositor first, if possible
|
2013-03-04 18:32:20 +00:00
|
|
|
if (ShouldUseOffMainThreadCompositing()) {
|
2012-05-15 19:56:56 +00:00
|
|
|
// e10s uses the parameter to pass in the shadow manager from the TabChild
|
|
|
|
// so we don't expect to see it there since this doesn't support e10s.
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION(aShadowManager == nullptr, "Async Compositor not supported with e10s");
|
2012-05-15 19:56:56 +00:00
|
|
|
CreateCompositor();
|
|
|
|
}
|
2012-05-16 03:19:37 +00:00
|
|
|
|
2010-03-31 03:02:58 +00:00
|
|
|
if (!mLayerManager) {
|
2013-01-19 01:07:32 +00:00
|
|
|
mLayerManager = CreateBasicLayerManager();
|
2010-03-31 03:02:58 +00:00
|
|
|
}
|
2010-03-01 08:03:49 +00:00
|
|
|
}
|
2010-10-15 10:34:29 +00:00
|
|
|
if (mTemporarilyUseBasicLayerManager && !mBasicLayerManager) {
|
|
|
|
mBasicLayerManager = CreateBasicLayerManager();
|
|
|
|
}
|
|
|
|
LayerManager* usedLayerManager = mTemporarilyUseBasicLayerManager ?
|
|
|
|
mBasicLayerManager : mLayerManager;
|
|
|
|
if (aAllowRetaining) {
|
|
|
|
*aAllowRetaining = (usedLayerManager == mLayerManager);
|
|
|
|
}
|
|
|
|
return usedLayerManager;
|
2010-03-01 08:03:49 +00:00
|
|
|
}
|
|
|
|
|
2013-09-01 22:20:45 +00:00
|
|
|
LayerManager* nsBaseWidget::CreateBasicLayerManager()
|
2010-09-14 23:40:23 +00:00
|
|
|
{
|
2013-05-01 05:03:25 +00:00
|
|
|
return new BasicLayerManager(this);
|
2010-09-14 23:40:23 +00:00
|
|
|
}
|
|
|
|
|
2012-10-04 07:05:24 +00:00
|
|
|
CompositorChild* nsBaseWidget::GetRemoteRenderer()
|
|
|
|
{
|
|
|
|
return mCompositorChild;
|
|
|
|
}
|
|
|
|
|
2013-07-09 04:21:05 +00:00
|
|
|
TemporaryRef<mozilla::gfx::DrawTarget> nsBaseWidget::StartRemoteDrawing()
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
1998-09-23 19:19:23 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Return the used device context
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2013-01-01 22:38:48 +00:00
|
|
|
nsDeviceContext* nsBaseWidget::GetDeviceContext()
|
1998-09-23 19:19:23 +00:00
|
|
|
{
|
2012-09-29 11:36:09 +00:00
|
|
|
if (!mContextInitialized) {
|
|
|
|
mContext->Init(this);
|
|
|
|
mContextInitialized = true;
|
|
|
|
}
|
2013-01-01 22:38:48 +00:00
|
|
|
return mContext;
|
1998-09-23 19:19:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Destroy the window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsBaseWidget::OnDestroy()
|
|
|
|
{
|
2011-10-25 15:05:32 +00:00
|
|
|
// release references to device context and app shell
|
1999-09-28 01:31:41 +00:00
|
|
|
NS_IF_RELEASE(mContext);
|
1998-12-01 17:58:27 +00:00
|
|
|
}
|
|
|
|
|
2006-07-19 12:56:40 +00:00
|
|
|
NS_METHOD nsBaseWidget::SetWindowClass(const nsAString& xulWinType)
|
2002-08-07 01:59:22 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
1998-12-01 17:58:27 +00:00
|
|
|
|
2012-12-12 09:57:38 +00:00
|
|
|
NS_METHOD nsBaseWidget::MoveClient(double aX, double aY)
|
2011-12-01 21:35:42 +00:00
|
|
|
{
|
|
|
|
nsIntPoint clientOffset(GetClientOffset());
|
2013-04-15 12:17:22 +00:00
|
|
|
|
|
|
|
// GetClientOffset returns device pixels; scale back to display pixels
|
|
|
|
// if that's what this widget uses for the Move/Resize APIs
|
2013-09-18 00:45:19 +00:00
|
|
|
CSSToLayoutDeviceScale scale = BoundsUseDisplayPixels()
|
|
|
|
? GetDefaultScale()
|
|
|
|
: CSSToLayoutDeviceScale(1.0);
|
|
|
|
aX -= clientOffset.x * 1.0 / scale.scale;
|
|
|
|
aY -= clientOffset.y * 1.0 / scale.scale;
|
2013-04-15 12:17:22 +00:00
|
|
|
|
2011-12-01 21:35:42 +00:00
|
|
|
return Move(aX, aY);
|
|
|
|
}
|
|
|
|
|
2012-12-12 09:57:38 +00:00
|
|
|
NS_METHOD nsBaseWidget::ResizeClient(double aWidth,
|
|
|
|
double aHeight,
|
2011-12-01 21:35:42 +00:00
|
|
|
bool aRepaint)
|
|
|
|
{
|
|
|
|
NS_ASSERTION((aWidth >=0) , "Negative width passed to ResizeClient");
|
|
|
|
NS_ASSERTION((aHeight >=0), "Negative height passed to ResizeClient");
|
|
|
|
|
|
|
|
nsIntRect clientBounds;
|
|
|
|
GetClientBounds(clientBounds);
|
2013-04-15 12:17:22 +00:00
|
|
|
|
|
|
|
// GetClientBounds and mBounds are device pixels; scale back to display pixels
|
|
|
|
// if that's what this widget uses for the Move/Resize APIs
|
2013-09-18 00:45:19 +00:00
|
|
|
CSSToLayoutDeviceScale scale = BoundsUseDisplayPixels()
|
|
|
|
? GetDefaultScale()
|
|
|
|
: CSSToLayoutDeviceScale(1.0);
|
|
|
|
double invScale = 1.0 / scale.scale;
|
|
|
|
aWidth = mBounds.width * invScale + (aWidth - clientBounds.width * invScale);
|
|
|
|
aHeight = mBounds.height * invScale + (aHeight - clientBounds.height * invScale);
|
2011-12-01 21:35:42 +00:00
|
|
|
|
|
|
|
return Resize(aWidth, aHeight, aRepaint);
|
|
|
|
}
|
|
|
|
|
2012-12-12 09:57:38 +00:00
|
|
|
NS_METHOD nsBaseWidget::ResizeClient(double aX,
|
|
|
|
double aY,
|
|
|
|
double aWidth,
|
|
|
|
double aHeight,
|
2011-12-01 21:35:42 +00:00
|
|
|
bool aRepaint)
|
|
|
|
{
|
|
|
|
NS_ASSERTION((aWidth >=0) , "Negative width passed to ResizeClient");
|
|
|
|
NS_ASSERTION((aHeight >=0), "Negative height passed to ResizeClient");
|
|
|
|
|
|
|
|
nsIntRect clientBounds;
|
|
|
|
GetClientBounds(clientBounds);
|
2013-04-15 12:17:22 +00:00
|
|
|
|
2013-09-18 00:45:19 +00:00
|
|
|
double scale = BoundsUseDisplayPixels() ? 1.0 / GetDefaultScale().scale : 1.0;
|
2013-04-15 12:17:22 +00:00
|
|
|
aWidth = mBounds.width * scale + (aWidth - clientBounds.width * scale);
|
|
|
|
aHeight = mBounds.height * scale + (aHeight - clientBounds.height * scale);
|
2011-12-01 21:35:42 +00:00
|
|
|
|
|
|
|
nsIntPoint clientOffset(GetClientOffset());
|
2013-04-15 12:17:22 +00:00
|
|
|
aX -= clientOffset.x * scale;
|
|
|
|
aY -= clientOffset.y * scale;
|
2011-12-01 21:35:42 +00:00
|
|
|
|
|
|
|
return Resize(aX, aY, aWidth, aHeight, aRepaint);
|
|
|
|
}
|
|
|
|
|
2010-06-25 02:01:07 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Bounds
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
1998-11-04 21:43:47 +00:00
|
|
|
/**
|
1998-12-03 21:46:27 +00:00
|
|
|
* If the implementation of nsWindow supports borders this method MUST be overridden
|
|
|
|
*
|
|
|
|
**/
|
2009-01-15 03:27:09 +00:00
|
|
|
NS_METHOD nsBaseWidget::GetClientBounds(nsIntRect &aRect)
|
1998-11-04 21:43:47 +00:00
|
|
|
{
|
|
|
|
return GetBounds(aRect);
|
|
|
|
}
|
|
|
|
|
1998-11-24 14:57:09 +00:00
|
|
|
/**
|
1998-12-03 21:46:27 +00:00
|
|
|
* If the implementation of nsWindow supports borders this method MUST be overridden
|
|
|
|
*
|
|
|
|
**/
|
2009-01-15 03:27:09 +00:00
|
|
|
NS_METHOD nsBaseWidget::GetBounds(nsIntRect &aRect)
|
1998-11-24 14:57:09 +00:00
|
|
|
{
|
|
|
|
aRect = mBounds;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-06 01:29:19 +00:00
|
|
|
/**
|
|
|
|
* If the implementation of nsWindow uses a local coordinate system within the window,
|
|
|
|
* this method must be overridden
|
|
|
|
*
|
|
|
|
**/
|
2009-01-15 03:27:09 +00:00
|
|
|
NS_METHOD nsBaseWidget::GetScreenBounds(nsIntRect &aRect)
|
2000-01-06 01:29:19 +00:00
|
|
|
{
|
|
|
|
return GetBounds(aRect);
|
|
|
|
}
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
|
2014-05-20 07:32:17 +00:00
|
|
|
NS_METHOD nsBaseWidget::GetRestoredBounds(nsIntRect &aRect)
|
|
|
|
{
|
|
|
|
if (SizeMode() != nsSizeMode_Normal) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return GetScreenBounds(aRect);
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:38:03 +00:00
|
|
|
nsIntPoint nsBaseWidget::GetClientOffset()
|
2010-06-25 02:01:06 +00:00
|
|
|
{
|
2010-07-27 13:38:03 +00:00
|
|
|
return nsIntPoint(0, 0);
|
2010-06-25 02:01:06 +00:00
|
|
|
}
|
|
|
|
|
2010-06-25 02:01:07 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseWidget::GetNonClientMargins(nsIntMargin &margins)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2013-01-01 22:38:48 +00:00
|
|
|
|
2010-06-25 02:01:07 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseWidget::SetNonClientMargins(nsIntMargin &margins)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
1998-11-04 21:43:47 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_METHOD nsBaseWidget::EnableDragDrop(bool aEnable)
|
1999-03-09 23:47:47 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-28 16:09:34 +00:00
|
|
|
uint32_t nsBaseWidget::GetMaxTouchPoints() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_METHOD nsBaseWidget::SetModal(bool aModal)
|
1999-06-13 20:56:08 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-07-09 12:11:12 +00:00
|
|
|
|
1999-12-10 07:20:51 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBaseWidget::GetAttention(int32_t aCycleCount) {
|
1999-12-10 07:20:51 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2009-04-21 23:53:52 +00:00
|
|
|
nsBaseWidget::HasPendingInputEvent()
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2009-04-21 23:53:52 +00:00
|
|
|
}
|
|
|
|
|
2001-04-14 00:57:30 +00:00
|
|
|
NS_IMETHODIMP
|
2002-03-23 22:26:36 +00:00
|
|
|
nsBaseWidget::SetIcon(const nsAString&)
|
2001-04-14 00:57:30 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-10-30 04:03:42 +00:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsBaseWidget::SetWindowTitlebarColor(nscolor aColor, bool aActive)
|
2007-10-30 04:03:42 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2008-08-08 16:11:54 +00:00
|
|
|
nsBaseWidget::ShowsResizeIndicator(nsIntRect* aResizerRect)
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2008-08-08 16:11:54 +00:00
|
|
|
}
|
|
|
|
|
2010-03-31 03:02:58 +00:00
|
|
|
NS_IMETHODIMP
|
2012-11-15 18:55:15 +00:00
|
|
|
nsBaseWidget::SetLayersAcceleration(bool aEnabled)
|
2010-03-31 03:02:58 +00:00
|
|
|
{
|
2012-11-15 18:55:15 +00:00
|
|
|
if (mUseLayersAcceleration == aEnabled) {
|
2010-03-31 03:02:58 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-11-15 18:55:15 +00:00
|
|
|
|
|
|
|
bool usedAcceleration = mUseLayersAcceleration;
|
|
|
|
|
|
|
|
mUseLayersAcceleration = ComputeShouldAccelerate(aEnabled);
|
|
|
|
// ComputeShouldAccelerate may have set mUseLayersAcceleration to a value
|
|
|
|
// different from aEnabled.
|
|
|
|
if (usedAcceleration == mUseLayersAcceleration) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-12-07 02:05:25 +00:00
|
|
|
if (mLayerManager) {
|
|
|
|
mLayerManager->Destroy();
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 09:20:52 +00:00
|
|
|
mLayerManager = nullptr;
|
2010-03-31 03:02:58 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-02 13:34:54 +00:00
|
|
|
NS_METHOD nsBaseWidget::RegisterTouchWindow()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsBaseWidget::UnregisterTouchWindow()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2009-09-24 10:58:04 +00:00
|
|
|
NS_IMETHODIMP
|
2013-03-15 09:03:16 +00:00
|
|
|
nsBaseWidget::OverrideSystemMouseScrollSpeed(double aOriginalDeltaX,
|
|
|
|
double aOriginalDeltaY,
|
|
|
|
double& aOverriddenDeltaX,
|
|
|
|
double& aOverriddenDeltaY)
|
|
|
|
{
|
|
|
|
aOverriddenDeltaX = aOriginalDeltaX;
|
|
|
|
aOverriddenDeltaY = aOriginalDeltaY;
|
|
|
|
|
|
|
|
static bool sInitialized = false;
|
|
|
|
static bool sIsOverrideEnabled = false;
|
|
|
|
static int32_t sIntFactorX = 0;
|
|
|
|
static int32_t sIntFactorY = 0;
|
|
|
|
|
|
|
|
if (!sInitialized) {
|
|
|
|
Preferences::AddBoolVarCache(&sIsOverrideEnabled,
|
|
|
|
"mousewheel.system_scroll_override_on_root_content.enabled", false);
|
|
|
|
Preferences::AddIntVarCache(&sIntFactorX,
|
|
|
|
"mousewheel.system_scroll_override_on_root_content.horizontal.factor", 0);
|
|
|
|
Preferences::AddIntVarCache(&sIntFactorY,
|
|
|
|
"mousewheel.system_scroll_override_on_root_content.vertical.factor", 0);
|
|
|
|
sIntFactorX = std::max(sIntFactorX, 0);
|
|
|
|
sIntFactorY = std::max(sIntFactorY, 0);
|
|
|
|
sInitialized = true;
|
|
|
|
}
|
2009-09-24 10:58:04 +00:00
|
|
|
|
2013-03-15 09:03:16 +00:00
|
|
|
if (!sIsOverrideEnabled) {
|
2009-09-24 10:58:04 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The pref value must be larger than 100, otherwise, we don't override the
|
|
|
|
// delta value.
|
2013-03-15 09:03:16 +00:00
|
|
|
if (sIntFactorX > 100) {
|
|
|
|
double factor = static_cast<double>(sIntFactorX) / 100;
|
|
|
|
aOverriddenDeltaX *= factor;
|
|
|
|
}
|
|
|
|
if (sIntFactorY > 100) {
|
|
|
|
double factor = static_cast<double>(sIntFactorY) / 100;
|
|
|
|
aOverriddenDeltaY *= factor;
|
2009-09-24 10:58:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-10-30 04:03:42 +00:00
|
|
|
|
2004-09-07 18:59:27 +00:00
|
|
|
/**
|
|
|
|
* Modifies aFile to point at an icon file with the given name and suffix. The
|
|
|
|
* suffix may correspond to a file extension with leading '.' if appropriate.
|
|
|
|
* Returns true if the icon file exists and can be read.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool
|
2012-06-06 02:08:30 +00:00
|
|
|
ResolveIconNameHelper(nsIFile *aFile,
|
2004-09-07 18:59:27 +00:00
|
|
|
const nsAString &aIconName,
|
|
|
|
const nsAString &aIconSuffix)
|
|
|
|
{
|
|
|
|
aFile->Append(NS_LITERAL_STRING("icons"));
|
|
|
|
aFile->Append(NS_LITERAL_STRING("default"));
|
|
|
|
aFile->Append(aIconName + aIconSuffix);
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool readable;
|
2004-09-07 18:59:27 +00:00
|
|
|
return NS_SUCCEEDED(aFile->IsReadable(&readable)) && readable;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resolve the given icon name into a local file object. This method is
|
|
|
|
* intended to be called by subclasses of nsBaseWidget. aIconSuffix is a
|
|
|
|
* platform specific icon file suffix (e.g., ".ico" under Win32).
|
|
|
|
*
|
|
|
|
* If no file is found matching the given parameters, then null is returned.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsBaseWidget::ResolveIconName(const nsAString &aIconName,
|
|
|
|
const nsAString &aIconSuffix,
|
2012-06-06 02:08:30 +00:00
|
|
|
nsIFile **aResult)
|
2013-01-01 22:38:48 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
*aResult = nullptr;
|
2004-09-07 18:59:27 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIProperties> dirSvc = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
|
|
|
|
if (!dirSvc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// first check auxilary chrome directories
|
|
|
|
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> dirs;
|
|
|
|
dirSvc->Get(NS_APP_CHROME_DIR_LIST, NS_GET_IID(nsISimpleEnumerator),
|
|
|
|
getter_AddRefs(dirs));
|
2004-09-08 22:06:17 +00:00
|
|
|
if (dirs) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool hasMore;
|
2004-09-08 22:06:17 +00:00
|
|
|
while (NS_SUCCEEDED(dirs->HasMoreElements(&hasMore)) && hasMore) {
|
|
|
|
nsCOMPtr<nsISupports> element;
|
|
|
|
dirs->GetNext(getter_AddRefs(element));
|
|
|
|
if (!element)
|
|
|
|
continue;
|
2012-06-06 02:08:30 +00:00
|
|
|
nsCOMPtr<nsIFile> file = do_QueryInterface(element);
|
2004-09-08 22:06:17 +00:00
|
|
|
if (!file)
|
|
|
|
continue;
|
|
|
|
if (ResolveIconNameHelper(file, aIconName, aIconSuffix)) {
|
|
|
|
NS_ADDREF(*aResult = file);
|
|
|
|
return;
|
|
|
|
}
|
2004-09-07 18:59:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// then check the main app chrome directory
|
|
|
|
|
2012-06-06 02:08:30 +00:00
|
|
|
nsCOMPtr<nsIFile> file;
|
|
|
|
dirSvc->Get(NS_APP_CHROME_DIR, NS_GET_IID(nsIFile),
|
2004-09-07 18:59:27 +00:00
|
|
|
getter_AddRefs(file));
|
2004-09-08 22:06:17 +00:00
|
|
|
if (file && ResolveIconNameHelper(file, aIconName, aIconSuffix))
|
2004-09-07 18:59:27 +00:00
|
|
|
NS_ADDREF(*aResult = file);
|
|
|
|
}
|
|
|
|
|
2013-01-01 22:38:48 +00:00
|
|
|
NS_IMETHODIMP
|
2013-10-02 03:46:03 +00:00
|
|
|
nsBaseWidget::BeginResizeDrag(WidgetGUIEvent* aEvent,
|
|
|
|
int32_t aHorizontal,
|
|
|
|
int32_t aVertical)
|
2007-12-11 10:08:35 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2010-07-17 08:11:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-10-02 06:38:27 +00:00
|
|
|
nsBaseWidget::BeginMoveDrag(WidgetMouseEvent* aEvent)
|
2010-07-17 08:11:54 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2007-12-11 10:08:35 +00:00
|
|
|
}
|
2010-11-23 06:48:03 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t
|
2012-01-26 02:05:34 +00:00
|
|
|
nsBaseWidget::GetGLFrameBufferFormat()
|
|
|
|
{
|
2013-11-26 22:15:17 +00:00
|
|
|
return LOCAL_GL_RGBA;
|
2012-01-26 02:05:34 +00:00
|
|
|
}
|
|
|
|
|
2012-07-31 00:43:29 +00:00
|
|
|
void nsBaseWidget::SetSizeConstraints(const SizeConstraints& aConstraints)
|
|
|
|
{
|
|
|
|
mSizeConstraints = aConstraints;
|
|
|
|
// We can't ensure that the size is honored at this point because we're
|
|
|
|
// probably in the middle of a reflow.
|
|
|
|
}
|
|
|
|
|
|
|
|
const widget::SizeConstraints& nsBaseWidget::GetSizeConstraints() const
|
|
|
|
{
|
|
|
|
return mSizeConstraints;
|
|
|
|
}
|
|
|
|
|
2012-10-26 13:15:22 +00:00
|
|
|
// static
|
|
|
|
nsIRollupListener*
|
|
|
|
nsBaseWidget::GetActiveRollupListener()
|
|
|
|
{
|
|
|
|
// If set, then this is likely an <html:select> dropdown.
|
|
|
|
if (gRollupListener)
|
|
|
|
return gRollupListener;
|
|
|
|
|
|
|
|
return nsXULPopupManager::GetInstance();
|
|
|
|
}
|
|
|
|
|
2012-08-15 18:52:41 +00:00
|
|
|
void
|
|
|
|
nsBaseWidget::NotifyWindowDestroyed()
|
|
|
|
{
|
2012-08-15 18:52:42 +00:00
|
|
|
if (!mWidgetListener)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXULWindow> window = mWidgetListener->GetXULWindow();
|
|
|
|
nsCOMPtr<nsIBaseWindow> xulWindow(do_QueryInterface(window));
|
|
|
|
if (xulWindow) {
|
|
|
|
xulWindow->Destroy();
|
2012-08-15 18:52:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-15 18:52:35 +00:00
|
|
|
void
|
|
|
|
nsBaseWidget::NotifySizeMoveDone()
|
|
|
|
{
|
2012-08-15 18:52:42 +00:00
|
|
|
if (!mWidgetListener || mWidgetListener->GetXULWindow())
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsIPresShell* presShell = mWidgetListener->GetPresShell();
|
2012-08-15 18:52:35 +00:00
|
|
|
if (presShell) {
|
|
|
|
presShell->WindowSizeMoveDone();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-28 07:45:08 +00:00
|
|
|
void
|
|
|
|
nsBaseWidget::NotifyWindowMoved(int32_t aX, int32_t aY)
|
|
|
|
{
|
|
|
|
if (mWidgetListener) {
|
|
|
|
mWidgetListener->WindowMoved(this, aX, aY);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetIMEUpdatePreference().WantPositionChanged()) {
|
|
|
|
NotifyIME(IMENotification(IMEMessage::NOTIFY_IME_OF_POSITION_CHANGE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-15 18:52:35 +00:00
|
|
|
void
|
|
|
|
nsBaseWidget::NotifySysColorChanged()
|
|
|
|
{
|
2012-08-15 18:52:42 +00:00
|
|
|
if (!mWidgetListener || mWidgetListener->GetXULWindow())
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsIPresShell* presShell = mWidgetListener->GetPresShell();
|
2012-08-15 18:52:35 +00:00
|
|
|
if (presShell) {
|
|
|
|
presShell->SysColorChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBaseWidget::NotifyThemeChanged()
|
|
|
|
{
|
2012-08-15 18:52:42 +00:00
|
|
|
if (!mWidgetListener || mWidgetListener->GetXULWindow())
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsIPresShell* presShell = mWidgetListener->GetPresShell();
|
2012-08-15 18:52:35 +00:00
|
|
|
if (presShell) {
|
|
|
|
presShell->ThemeChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-15 18:52:40 +00:00
|
|
|
void
|
|
|
|
nsBaseWidget::NotifyUIStateChanged(UIStateChangeType aShowAccelerators,
|
|
|
|
UIStateChangeType aShowFocusRings)
|
|
|
|
{
|
2012-08-17 15:36:34 +00:00
|
|
|
if (!mWidgetListener)
|
|
|
|
return;
|
|
|
|
|
2012-08-15 18:52:42 +00:00
|
|
|
nsIPresShell* presShell = mWidgetListener->GetPresShell();
|
2013-04-18 13:24:30 +00:00
|
|
|
if (!presShell)
|
|
|
|
return;
|
|
|
|
|
2012-08-15 18:52:40 +00:00
|
|
|
nsIDocument* doc = presShell->GetDocument();
|
|
|
|
if (doc) {
|
|
|
|
nsPIDOMWindow* win = doc->GetWindow();
|
|
|
|
if (win) {
|
|
|
|
win->SetKeyboardIndicators(aShowAccelerators, aShowFocusRings);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-15 18:52:37 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
|
2012-11-18 02:01:44 +00:00
|
|
|
a11y::Accessible*
|
2013-06-27 15:03:58 +00:00
|
|
|
nsBaseWidget::GetRootAccessible()
|
2012-08-15 18:52:37 +00:00
|
|
|
{
|
2012-08-17 15:36:34 +00:00
|
|
|
NS_ENSURE_TRUE(mWidgetListener, nullptr);
|
|
|
|
|
2012-08-15 18:52:42 +00:00
|
|
|
nsIPresShell* presShell = mWidgetListener->GetPresShell();
|
2012-08-15 18:52:37 +00:00
|
|
|
NS_ENSURE_TRUE(presShell, nullptr);
|
|
|
|
|
|
|
|
// If container is null then the presshell is not active. This often happens
|
|
|
|
// when a preshell is being held onto for fastback.
|
|
|
|
nsPresContext* presContext = presShell->GetPresContext();
|
2013-11-20 19:18:25 +00:00
|
|
|
NS_ENSURE_TRUE(presContext->GetContainerWeak(), nullptr);
|
2012-08-15 18:52:37 +00:00
|
|
|
|
|
|
|
// Accessible creation might be not safe so use IsSafeToRunScript to
|
|
|
|
// make sure it's not created at unsafe times.
|
2013-06-27 15:03:58 +00:00
|
|
|
nsCOMPtr<nsIAccessibilityService> accService =
|
|
|
|
services::GetAccessibilityService();
|
2012-08-15 18:52:37 +00:00
|
|
|
if (accService) {
|
|
|
|
return accService->GetRootDocumentAccessible(presShell, nsContentUtils::IsSafeToRunScript());
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-12-14 20:40:56 +00:00
|
|
|
#endif // ACCESSIBILITY
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsIWidget::SynthesizeNativeTouchTap(nsIntPoint aPointerScreenPoint, bool aLongTap)
|
|
|
|
{
|
|
|
|
if (sPointerIdCounter > TOUCH_INJECT_MAX_POINTS) {
|
|
|
|
sPointerIdCounter = 0;
|
|
|
|
}
|
|
|
|
int pointerId = sPointerIdCounter;
|
|
|
|
sPointerIdCounter++;
|
|
|
|
nsresult rv = SynthesizeNativeTouchPoint(pointerId, TOUCH_CONTACT,
|
|
|
|
aPointerScreenPoint, 1.0, 90);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aLongTap) {
|
|
|
|
nsresult rv = SynthesizeNativeTouchPoint(pointerId, TOUCH_REMOVE,
|
|
|
|
aPointerScreenPoint, 0, 0);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// initiate a long tap
|
|
|
|
int elapse = Preferences::GetInt("ui.click_hold_context_menus.delay",
|
|
|
|
TOUCH_INJECT_LONG_TAP_DEFAULT_MSEC);
|
|
|
|
if (!mLongTapTimer) {
|
|
|
|
mLongTapTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
SynthesizeNativeTouchPoint(pointerId, TOUCH_CANCEL,
|
|
|
|
aPointerScreenPoint, 0, 0);
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
// Windows requires recuring events, so we set this to a smaller window
|
|
|
|
// than the pref value.
|
|
|
|
int timeout = elapse;
|
|
|
|
if (timeout > TOUCH_INJECT_PUMP_TIMER_MSEC) {
|
|
|
|
timeout = TOUCH_INJECT_PUMP_TIMER_MSEC;
|
|
|
|
}
|
|
|
|
mLongTapTimer->InitWithFuncCallback(OnLongTapTimerCallback, this,
|
|
|
|
timeout,
|
|
|
|
nsITimer::TYPE_REPEATING_SLACK);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we already have a long tap pending, cancel it. We only allow one long
|
|
|
|
// tap to be active at a time.
|
|
|
|
if (mLongTapTouchPoint) {
|
|
|
|
SynthesizeNativeTouchPoint(mLongTapTouchPoint->mPointerId, TOUCH_CANCEL,
|
|
|
|
mLongTapTouchPoint->mPosition, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
mLongTapTouchPoint = new LongTapInfo(pointerId, aPointerScreenPoint,
|
|
|
|
TimeDuration::FromMilliseconds(elapse));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void
|
|
|
|
nsIWidget::OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure)
|
|
|
|
{
|
2014-03-15 19:00:15 +00:00
|
|
|
nsIWidget *self = static_cast<nsIWidget *>(aClosure);
|
2013-12-14 20:40:56 +00:00
|
|
|
|
|
|
|
if ((self->mLongTapTouchPoint->mStamp + self->mLongTapTouchPoint->mDuration) >
|
|
|
|
TimeStamp::Now()) {
|
|
|
|
#ifdef XP_WIN
|
|
|
|
// Windows needs us to keep pumping feedback to the digitizer, so update
|
|
|
|
// the pointer id with the same position.
|
|
|
|
self->SynthesizeNativeTouchPoint(self->mLongTapTouchPoint->mPointerId,
|
|
|
|
TOUCH_CONTACT,
|
|
|
|
self->mLongTapTouchPoint->mPosition,
|
|
|
|
1.0, 90);
|
2012-08-15 18:52:37 +00:00
|
|
|
#endif
|
2013-12-14 20:40:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// finished, remove the touch point
|
|
|
|
self->mLongTapTimer->Cancel();
|
|
|
|
self->mLongTapTimer = nullptr;
|
|
|
|
self->SynthesizeNativeTouchPoint(self->mLongTapTouchPoint->mPointerId,
|
|
|
|
TOUCH_REMOVE,
|
|
|
|
self->mLongTapTouchPoint->mPosition,
|
|
|
|
0, 0);
|
|
|
|
self->mLongTapTouchPoint = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsIWidget::ClearNativeTouchSequence()
|
|
|
|
{
|
|
|
|
if (!mLongTapTimer) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
mLongTapTimer->Cancel();
|
|
|
|
mLongTapTimer = nullptr;
|
|
|
|
SynthesizeNativeTouchPoint(mLongTapTouchPoint->mPointerId, TOUCH_CANCEL,
|
|
|
|
mLongTapTouchPoint->mPosition, 0, 0);
|
|
|
|
mLongTapTouchPoint = nullptr;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-08-15 18:52:37 +00:00
|
|
|
|
2002-01-24 01:18:36 +00:00
|
|
|
#ifdef DEBUG
|
1999-09-09 02:32:54 +00:00
|
|
|
//////////////////////////////////////////////////////////////
|
1999-07-09 12:11:12 +00:00
|
|
|
//
|
|
|
|
// Convert a GUI event message code to a string.
|
|
|
|
// Makes it a lot easier to debug events.
|
|
|
|
//
|
|
|
|
// See gtk/nsWidget.cpp and windows/nsWindow.cpp
|
|
|
|
// for a DebugPrintEvent() function that uses
|
|
|
|
// this.
|
|
|
|
//
|
1999-09-09 02:32:54 +00:00
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
/* static */ nsAutoString
|
2013-10-02 03:46:03 +00:00
|
|
|
nsBaseWidget::debug_GuiEventToString(WidgetGUIEvent* aGuiEvent)
|
1999-07-09 12:11:12 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION(nullptr != aGuiEvent,"cmon, null gui event.");
|
1999-09-09 02:32:54 +00:00
|
|
|
|
2001-12-16 11:58:03 +00:00
|
|
|
nsAutoString eventName(NS_LITERAL_STRING("UNKNOWN"));
|
1999-07-09 12:11:12 +00:00
|
|
|
|
|
|
|
#define _ASSIGN_eventName(_value,_name)\
|
2011-12-05 09:10:27 +00:00
|
|
|
case _value: eventName.AssignLiteral(_name) ; break
|
1999-07-09 12:11:12 +00:00
|
|
|
|
1999-09-09 02:32:54 +00:00
|
|
|
switch(aGuiEvent->message)
|
1999-07-09 12:11:12 +00:00
|
|
|
{
|
|
|
|
_ASSIGN_eventName(NS_BLUR_CONTENT,"NS_BLUR_CONTENT");
|
1999-09-09 02:32:54 +00:00
|
|
|
_ASSIGN_eventName(NS_DRAGDROP_GESTURE,"NS_DND_GESTURE");
|
|
|
|
_ASSIGN_eventName(NS_DRAGDROP_DROP,"NS_DND_DROP");
|
|
|
|
_ASSIGN_eventName(NS_DRAGDROP_ENTER,"NS_DND_ENTER");
|
|
|
|
_ASSIGN_eventName(NS_DRAGDROP_EXIT,"NS_DND_EXIT");
|
|
|
|
_ASSIGN_eventName(NS_DRAGDROP_OVER,"NS_DND_OVER");
|
2014-04-10 07:11:37 +00:00
|
|
|
_ASSIGN_eventName(NS_EDITOR_INPUT,"NS_EDITOR_INPUT");
|
1999-07-09 12:11:12 +00:00
|
|
|
_ASSIGN_eventName(NS_FOCUS_CONTENT,"NS_FOCUS_CONTENT");
|
1999-08-07 23:18:35 +00:00
|
|
|
_ASSIGN_eventName(NS_FORM_SELECTED,"NS_FORM_SELECTED");
|
1999-07-09 12:11:12 +00:00
|
|
|
_ASSIGN_eventName(NS_FORM_CHANGE,"NS_FORM_CHANGE");
|
|
|
|
_ASSIGN_eventName(NS_FORM_RESET,"NS_FORM_RESET");
|
|
|
|
_ASSIGN_eventName(NS_FORM_SUBMIT,"NS_FORM_SUBMIT");
|
|
|
|
_ASSIGN_eventName(NS_IMAGE_ABORT,"NS_IMAGE_ABORT");
|
2006-09-02 10:00:26 +00:00
|
|
|
_ASSIGN_eventName(NS_LOAD_ERROR,"NS_LOAD_ERROR");
|
1999-07-09 12:11:12 +00:00
|
|
|
_ASSIGN_eventName(NS_KEY_DOWN,"NS_KEY_DOWN");
|
|
|
|
_ASSIGN_eventName(NS_KEY_PRESS,"NS_KEY_PRESS");
|
|
|
|
_ASSIGN_eventName(NS_KEY_UP,"NS_KEY_UP");
|
|
|
|
_ASSIGN_eventName(NS_MOUSE_ENTER,"NS_MOUSE_ENTER");
|
|
|
|
_ASSIGN_eventName(NS_MOUSE_EXIT,"NS_MOUSE_EXIT");
|
2006-11-16 21:35:39 +00:00
|
|
|
_ASSIGN_eventName(NS_MOUSE_BUTTON_DOWN,"NS_MOUSE_BUTTON_DOWN");
|
|
|
|
_ASSIGN_eventName(NS_MOUSE_BUTTON_UP,"NS_MOUSE_BUTTON_UP");
|
|
|
|
_ASSIGN_eventName(NS_MOUSE_CLICK,"NS_MOUSE_CLICK");
|
|
|
|
_ASSIGN_eventName(NS_MOUSE_DOUBLECLICK,"NS_MOUSE_DBLCLICK");
|
1999-07-09 12:11:12 +00:00
|
|
|
_ASSIGN_eventName(NS_MOUSE_MOVE,"NS_MOUSE_MOVE");
|
2006-08-31 19:33:01 +00:00
|
|
|
_ASSIGN_eventName(NS_LOAD,"NS_LOAD");
|
2009-09-01 16:45:05 +00:00
|
|
|
_ASSIGN_eventName(NS_POPSTATE,"NS_POPSTATE");
|
2010-09-16 08:48:47 +00:00
|
|
|
_ASSIGN_eventName(NS_BEFORE_SCRIPT_EXECUTE,"NS_BEFORE_SCRIPT_EXECUTE");
|
|
|
|
_ASSIGN_eventName(NS_AFTER_SCRIPT_EXECUTE,"NS_AFTER_SCRIPT_EXECUTE");
|
1999-07-09 12:11:12 +00:00
|
|
|
_ASSIGN_eventName(NS_PAGE_UNLOAD,"NS_PAGE_UNLOAD");
|
2009-06-26 17:16:50 +00:00
|
|
|
_ASSIGN_eventName(NS_HASHCHANGE,"NS_HASHCHANGE");
|
2010-06-24 01:12:07 +00:00
|
|
|
_ASSIGN_eventName(NS_READYSTATECHANGE,"NS_READYSTATECHANGE");
|
1999-09-21 23:02:35 +00:00
|
|
|
_ASSIGN_eventName(NS_XUL_BROADCAST, "NS_XUL_BROADCAST");
|
|
|
|
_ASSIGN_eventName(NS_XUL_COMMAND_UPDATE, "NS_XUL_COMMAND_UPDATE");
|
1999-07-09 12:11:12 +00:00
|
|
|
|
|
|
|
#undef _ASSIGN_eventName
|
|
|
|
|
2013-01-01 22:38:48 +00:00
|
|
|
default:
|
1999-07-09 12:11:12 +00:00
|
|
|
{
|
|
|
|
char buf[32];
|
2013-01-01 22:38:48 +00:00
|
|
|
|
1999-09-09 02:32:54 +00:00
|
|
|
sprintf(buf,"UNKNOWN: %d",aGuiEvent->message);
|
2013-01-01 22:38:48 +00:00
|
|
|
|
2011-12-05 09:10:27 +00:00
|
|
|
CopyASCIItoUTF16(buf, eventName);
|
1999-07-09 12:11:12 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-01-01 22:38:48 +00:00
|
|
|
|
1999-07-09 12:11:12 +00:00
|
|
|
return nsAutoString(eventName);
|
|
|
|
}
|
1999-09-09 02:32:54 +00:00
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
//
|
1999-12-03 07:23:22 +00:00
|
|
|
// Code to deal with paint and event debug prefs.
|
1999-09-09 02:32:54 +00:00
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
1999-12-03 07:23:22 +00:00
|
|
|
struct PrefPair
|
|
|
|
{
|
2004-07-15 19:58:57 +00:00
|
|
|
const char * name;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool value;
|
1999-12-03 07:23:22 +00:00
|
|
|
};
|
1999-09-09 02:32:54 +00:00
|
|
|
|
1999-12-03 07:23:22 +00:00
|
|
|
static PrefPair debug_PrefValues[] =
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
{ "nglayout.debug.crossing_event_dumping", false },
|
|
|
|
{ "nglayout.debug.event_dumping", false },
|
|
|
|
{ "nglayout.debug.invalidate_dumping", false },
|
|
|
|
{ "nglayout.debug.motion_event_dumping", false },
|
|
|
|
{ "nglayout.debug.paint_dumping", false },
|
|
|
|
{ "nglayout.debug.paint_flashing", false }
|
1999-12-03 07:23:22 +00:00
|
|
|
};
|
|
|
|
|
1999-09-09 02:32:54 +00:00
|
|
|
//////////////////////////////////////////////////////////////
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2002-01-24 01:18:36 +00:00
|
|
|
nsBaseWidget::debug_GetCachedBoolPref(const char * aPrefName)
|
1999-09-09 02:32:54 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION(nullptr != aPrefName,"cmon, pref name is null.");
|
1999-09-09 02:32:54 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < ArrayLength(debug_PrefValues); i++)
|
1999-12-03 07:23:22 +00:00
|
|
|
{
|
2004-06-26 14:32:11 +00:00
|
|
|
if (strcmp(debug_PrefValues[i].name, aPrefName) == 0)
|
2004-01-05 23:28:41 +00:00
|
|
|
{
|
|
|
|
return debug_PrefValues[i].value;
|
|
|
|
}
|
1999-12-03 07:23:22 +00:00
|
|
|
}
|
1999-09-09 02:32:54 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
1999-12-03 07:23:22 +00:00
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
2011-09-29 06:19:26 +00:00
|
|
|
static void debug_SetCachedBoolPref(const char * aPrefName,bool aValue)
|
1999-12-03 07:23:22 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION(nullptr != aPrefName,"cmon, pref name is null.");
|
1999-09-09 02:32:54 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < ArrayLength(debug_PrefValues); i++)
|
1999-12-03 07:23:22 +00:00
|
|
|
{
|
2004-06-26 14:32:11 +00:00
|
|
|
if (strcmp(debug_PrefValues[i].name, aPrefName) == 0)
|
2004-01-05 23:28:41 +00:00
|
|
|
{
|
|
|
|
debug_PrefValues[i].value = aValue;
|
1999-09-09 02:32:54 +00:00
|
|
|
|
2004-01-05 23:28:41 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-12-03 07:23:22 +00:00
|
|
|
}
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_ASSERTION(false, "cmon, this code is not reached dude.");
|
1999-12-03 07:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////
|
2012-06-19 01:28:00 +00:00
|
|
|
class Debug_PrefObserver MOZ_FINAL : public nsIObserver {
|
2014-06-24 16:36:44 +00:00
|
|
|
~Debug_PrefObserver() {}
|
|
|
|
|
2006-10-23 15:29:09 +00:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
};
|
1999-12-03 07:23:22 +00:00
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(Debug_PrefObserver, nsIObserver)
|
1999-12-03 07:23:22 +00:00
|
|
|
|
2006-10-23 15:29:09 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
Debug_PrefObserver::Observe(nsISupports* subject, const char* topic,
|
2014-01-04 15:02:17 +00:00
|
|
|
const char16_t* data)
|
2006-10-23 15:29:09 +00:00
|
|
|
{
|
|
|
|
NS_ConvertUTF16toUTF8 prefName(data);
|
1999-12-03 07:23:22 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool value = Preferences::GetBool(prefName.get(), false);
|
2006-10-23 15:29:09 +00:00
|
|
|
debug_SetCachedBoolPref(prefName.get(), value);
|
|
|
|
return NS_OK;
|
1999-12-03 07:23:22 +00:00
|
|
|
}
|
2006-10-23 15:29:09 +00:00
|
|
|
|
1999-12-03 07:23:22 +00:00
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
/* static */ void
|
|
|
|
debug_RegisterPrefCallbacks()
|
|
|
|
{
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool once = true;
|
2004-01-05 23:28:41 +00:00
|
|
|
|
2011-05-23 14:54:03 +00:00
|
|
|
if (!once) {
|
|
|
|
return;
|
|
|
|
}
|
2004-01-05 23:28:41 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
once = false;
|
2004-01-05 23:28:41 +00:00
|
|
|
|
2011-05-23 14:54:03 +00:00
|
|
|
nsCOMPtr<nsIObserver> obs(new Debug_PrefObserver());
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < ArrayLength(debug_PrefValues); i++) {
|
2011-05-23 14:54:03 +00:00
|
|
|
// Initialize the pref values
|
|
|
|
debug_PrefValues[i].value =
|
2011-09-29 06:19:26 +00:00
|
|
|
Preferences::GetBool(debug_PrefValues[i].name, false);
|
2011-05-23 14:54:03 +00:00
|
|
|
|
|
|
|
if (obs) {
|
|
|
|
// Register callbacks for when these change
|
|
|
|
Preferences::AddStrongObserver(obs, debug_PrefValues[i].name);
|
2004-01-05 23:28:41 +00:00
|
|
|
}
|
|
|
|
}
|
1999-09-09 02:32:54 +00:00
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t
|
1999-09-09 02:32:54 +00:00
|
|
|
_GetPrintCount()
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
static int32_t sCount = 0;
|
2013-01-01 22:38:48 +00:00
|
|
|
|
1999-09-09 02:32:54 +00:00
|
|
|
return ++sCount;
|
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
2011-09-29 06:19:26 +00:00
|
|
|
/* static */ bool
|
1999-09-09 02:32:54 +00:00
|
|
|
nsBaseWidget::debug_WantPaintFlashing()
|
|
|
|
{
|
1999-12-03 07:23:22 +00:00
|
|
|
return debug_GetCachedBoolPref("nglayout.debug.paint_flashing");
|
1999-09-09 02:32:54 +00:00
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
/* static */ void
|
|
|
|
nsBaseWidget::debug_DumpEvent(FILE * aFileOut,
|
|
|
|
nsIWidget * aWidget,
|
2013-10-02 03:46:03 +00:00
|
|
|
WidgetGUIEvent* aGuiEvent,
|
2012-09-02 02:35:17 +00:00
|
|
|
const nsAutoCString & aWidgetName,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aWindowID)
|
1999-09-09 02:32:54 +00:00
|
|
|
{
|
|
|
|
if (aGuiEvent->message == NS_MOUSE_MOVE)
|
|
|
|
{
|
1999-12-03 07:23:22 +00:00
|
|
|
if (!debug_GetCachedBoolPref("nglayout.debug.motion_event_dumping"))
|
1999-09-09 02:32:54 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-01-01 22:38:48 +00:00
|
|
|
|
|
|
|
if (aGuiEvent->message == NS_MOUSE_ENTER ||
|
1999-09-09 02:32:54 +00:00
|
|
|
aGuiEvent->message == NS_MOUSE_EXIT)
|
|
|
|
{
|
1999-12-03 07:23:22 +00:00
|
|
|
if (!debug_GetCachedBoolPref("nglayout.debug.crossing_event_dumping"))
|
1999-09-09 02:32:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-12-03 07:23:22 +00:00
|
|
|
if (!debug_GetCachedBoolPref("nglayout.debug.event_dumping"))
|
1999-09-09 02:32:54 +00:00
|
|
|
return;
|
2000-04-17 08:21:30 +00:00
|
|
|
|
2011-12-05 09:10:27 +00:00
|
|
|
NS_LossyConvertUTF16toASCII tempString(debug_GuiEventToString(aGuiEvent).get());
|
2013-01-01 22:38:48 +00:00
|
|
|
|
1999-09-09 02:32:54 +00:00
|
|
|
fprintf(aFileOut,
|
2013-01-01 22:38:48 +00:00
|
|
|
"%4d %-26s widget=%-8p name=%-12s id=0x%-6x refpt=%d,%d\n",
|
1999-09-09 02:32:54 +00:00
|
|
|
_GetPrintCount(),
|
2001-10-26 04:24:06 +00:00
|
|
|
tempString.get(),
|
1999-09-09 02:32:54 +00:00
|
|
|
(void *) aWidget,
|
2001-10-26 04:24:06 +00:00
|
|
|
aWidgetName.get(),
|
2013-01-01 22:38:48 +00:00
|
|
|
aWindowID,
|
2014-08-28 16:45:48 +00:00
|
|
|
aGuiEvent->refPoint.x,
|
|
|
|
aGuiEvent->refPoint.y);
|
1999-09-09 02:32:54 +00:00
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
/* static */ void
|
|
|
|
nsBaseWidget::debug_DumpPaintEvent(FILE * aFileOut,
|
|
|
|
nsIWidget * aWidget,
|
2012-08-15 18:52:42 +00:00
|
|
|
const nsIntRegion & aRegion,
|
2012-09-02 02:35:17 +00:00
|
|
|
const nsAutoCString & aWidgetName,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aWindowID)
|
1999-09-09 02:32:54 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION(nullptr != aFileOut,"cmon, null output FILE");
|
|
|
|
NS_ASSERTION(nullptr != aWidget,"cmon, the widget is null");
|
1999-09-09 02:32:54 +00:00
|
|
|
|
1999-12-03 07:23:22 +00:00
|
|
|
if (!debug_GetCachedBoolPref("nglayout.debug.paint_dumping"))
|
1999-09-09 02:32:54 +00:00
|
|
|
return;
|
2013-01-01 22:38:48 +00:00
|
|
|
|
2012-08-15 18:52:42 +00:00
|
|
|
nsIntRect rect = aRegion.GetBounds();
|
1999-09-09 02:32:54 +00:00
|
|
|
fprintf(aFileOut,
|
2013-01-01 22:38:48 +00:00
|
|
|
"%4d PAINT widget=%p name=%-12s id=0x%-6x bounds-rect=%3d,%-3d %3d,%-3d",
|
1999-09-09 02:32:54 +00:00
|
|
|
_GetPrintCount(),
|
|
|
|
(void *) aWidget,
|
2001-10-26 04:24:06 +00:00
|
|
|
aWidgetName.get(),
|
2013-01-01 22:38:48 +00:00
|
|
|
aWindowID,
|
2010-08-20 19:29:01 +00:00
|
|
|
rect.x, rect.y, rect.width, rect.height
|
|
|
|
);
|
2013-01-01 22:38:48 +00:00
|
|
|
|
1999-09-09 02:32:54 +00:00
|
|
|
fprintf(aFileOut,"\n");
|
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
/* static */ void
|
|
|
|
nsBaseWidget::debug_DumpInvalidate(FILE * aFileOut,
|
|
|
|
nsIWidget * aWidget,
|
2009-01-15 03:27:09 +00:00
|
|
|
const nsIntRect * aRect,
|
2012-09-02 02:35:17 +00:00
|
|
|
const nsAutoCString & aWidgetName,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aWindowID)
|
1999-09-09 02:32:54 +00:00
|
|
|
{
|
1999-12-03 07:23:22 +00:00
|
|
|
if (!debug_GetCachedBoolPref("nglayout.debug.invalidate_dumping"))
|
1999-09-09 02:32:54 +00:00
|
|
|
return;
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION(nullptr != aFileOut,"cmon, null output FILE");
|
|
|
|
NS_ASSERTION(nullptr != aWidget,"cmon, the widget is null");
|
1999-09-09 02:32:54 +00:00
|
|
|
|
|
|
|
fprintf(aFileOut,
|
2013-01-01 22:38:48 +00:00
|
|
|
"%4d Invalidate widget=%p name=%-12s id=0x%-6x",
|
1999-09-09 02:32:54 +00:00
|
|
|
_GetPrintCount(),
|
|
|
|
(void *) aWidget,
|
2001-10-26 04:24:06 +00:00
|
|
|
aWidgetName.get(),
|
2013-01-01 22:38:48 +00:00
|
|
|
aWindowID);
|
1999-09-09 02:32:54 +00:00
|
|
|
|
2013-01-01 22:38:48 +00:00
|
|
|
if (aRect)
|
1999-09-09 02:32:54 +00:00
|
|
|
{
|
|
|
|
fprintf(aFileOut,
|
|
|
|
" rect=%3d,%-3d %3d,%-3d",
|
2013-01-01 22:38:48 +00:00
|
|
|
aRect->x,
|
1999-09-09 02:32:54 +00:00
|
|
|
aRect->y,
|
2013-01-01 22:38:48 +00:00
|
|
|
aRect->width,
|
1999-09-09 02:32:54 +00:00
|
|
|
aRect->height);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf(aFileOut,
|
|
|
|
" rect=%-15s",
|
|
|
|
"none");
|
|
|
|
}
|
2013-01-01 22:38:48 +00:00
|
|
|
|
1999-09-09 02:32:54 +00:00
|
|
|
fprintf(aFileOut,"\n");
|
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2002-01-24 01:18:36 +00:00
|
|
|
#endif // DEBUG
|
1999-09-09 02:32:54 +00:00
|
|
|
|