2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1998-09-23 23:19:23 +04:00
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
#include "mozilla/Util.h"
|
|
|
|
|
2012-01-19 18:45:37 +04:00
|
|
|
#include "mozilla/layers/CompositorChild.h"
|
|
|
|
#include "mozilla/layers/CompositorParent.h"
|
1998-09-23 23:19:23 +04:00
|
|
|
#include "nsBaseWidget.h"
|
2011-04-17 05:22:44 +04:00
|
|
|
#include "nsDeviceContext.h"
|
1999-01-25 22:18:43 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1998-09-23 23:19:23 +04:00
|
|
|
#include "nsGfxCIID.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
2004-11-25 01:48:45 +03:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2003-05-08 22:31:01 +04:00
|
|
|
#include "nsIScreenManager.h"
|
2004-09-07 22:59:27 +04:00
|
|
|
#include "nsAppDirectoryServiceDefs.h"
|
2007-02-07 10:46:44 +03:00
|
|
|
#include "nsISimpleEnumerator.h"
|
2007-12-03 19:33:42 +03:00
|
|
|
#include "nsIContent.h"
|
1999-09-09 06:32:54 +04:00
|
|
|
#include "nsIServiceManager.h"
|
2011-05-23 18:54:03 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2010-03-01 11:03:49 +03:00
|
|
|
#include "BasicLayers.h"
|
2010-03-31 07:02:58 +04:00
|
|
|
#include "LayerManagerOGL.h"
|
2010-08-28 06:44:37 +04:00
|
|
|
#include "nsIXULRuntime.h"
|
2011-01-18 23:11:19 +03:00
|
|
|
#include "nsIGfxInfo.h"
|
2011-01-21 07:01:25 +03:00
|
|
|
#include "npapi.h"
|
2012-01-19 18:45:37 +04:00
|
|
|
#include "base/thread.h"
|
2009-09-24 14:58:04 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2006-10-23 19:29:09 +04:00
|
|
|
#include "nsIObserver.h"
|
1999-12-03 10:23:22 +03:00
|
|
|
|
|
|
|
static void debug_RegisterPrefCallbacks();
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool debug_InSecureKeyboardInputMode = false;
|
1999-09-09 06:32:54 +04:00
|
|
|
#endif
|
|
|
|
|
1999-10-05 18:53:40 +04:00
|
|
|
#ifdef NOISY_WIDGET_LEAKS
|
|
|
|
static PRInt32 gNumWidgets;
|
|
|
|
#endif
|
|
|
|
|
2010-03-01 11:03:49 +03:00
|
|
|
using namespace mozilla::layers;
|
2011-05-23 18:54:03 +04:00
|
|
|
using namespace mozilla;
|
2012-01-19 18:45:37 +04:00
|
|
|
using base::Thread;
|
|
|
|
using mozilla::ipc::AsyncChannel;
|
2010-03-01 11:03:49 +03:00
|
|
|
|
2007-12-03 19:33:42 +03:00
|
|
|
nsIContent* nsBaseWidget::mLastRollup = nsnull;
|
2012-05-15 17:01:48 +04:00
|
|
|
// Global user preference for disabling native theme. Used
|
|
|
|
// in NativeWindowTheme.
|
|
|
|
bool gDisableNativeTheme = false;
|
2007-12-03 19:33:42 +03:00
|
|
|
|
1999-09-04 12:13:41 +04:00
|
|
|
// nsBaseWidget
|
|
|
|
NS_IMPL_ISUPPORTS1(nsBaseWidget, nsIWidget)
|
1999-02-23 11:10:24 +03:00
|
|
|
|
1998-09-23 23:19:23 +04:00
|
|
|
|
2007-12-03 19:33:42 +03: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 23:19:23 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsBaseWidget constructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1999-10-05 18:53:40 +04:00
|
|
|
|
1999-08-24 05:00:01 +04:00
|
|
|
nsBaseWidget::nsBaseWidget()
|
2002-11-06 12:35:13 +03:00
|
|
|
: mClientData(nsnull)
|
2010-06-25 06:01:06 +04:00
|
|
|
, mViewWrapperPtr(nsnull)
|
2002-11-06 12:35:13 +03:00
|
|
|
, mEventCallback(nsnull)
|
2010-06-25 06:01:06 +04:00
|
|
|
, mViewCallback(nsnull)
|
2002-11-06 12:35:13 +03:00
|
|
|
, mContext(nsnull)
|
2012-01-19 18:45:37 +04:00
|
|
|
, mCompositorThread(nsnull)
|
2002-11-06 12:35:13 +03:00
|
|
|
, mCursor(eCursor_standard)
|
2003-03-10 04:23:32 +03:00
|
|
|
, mWindowType(eWindowType_child)
|
2002-11-06 12:35:13 +03:00
|
|
|
, mBorderStyle(eBorderStyle_none)
|
2011-10-17 18:59:28 +04:00
|
|
|
, mOnDestroyCalled(false)
|
|
|
|
, mUseAcceleratedRendering(false)
|
2012-02-28 01:33:19 +04:00
|
|
|
, mForceLayersAcceleration(false)
|
2011-10-17 18:59:28 +04:00
|
|
|
, mTemporarilyUseBasicLayerManager(false)
|
2002-11-06 12:35:13 +03:00
|
|
|
, mBounds(0,0,0,0)
|
|
|
|
, mOriginalBounds(nsnull)
|
2009-07-22 04:44:55 +04:00
|
|
|
, mClipRectCount(0)
|
2002-11-06 12:35:13 +03:00
|
|
|
, mZIndex(0)
|
|
|
|
, mSizeMode(nsSizeMode_Normal)
|
2010-07-27 17:38:03 +04:00
|
|
|
, mPopupLevel(ePopupLevelTop)
|
1998-09-23 23:19:23 +04:00
|
|
|
{
|
1999-10-05 18:53:40 +04:00
|
|
|
#ifdef NOISY_WIDGET_LEAKS
|
|
|
|
gNumWidgets++;
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("WIDGETS+ = %d\n", gNumWidgets);
|
1999-10-05 18:53:40 +04:00
|
|
|
#endif
|
|
|
|
|
2002-01-24 04:18:36 +03:00
|
|
|
#ifdef DEBUG
|
1999-12-03 10:23:22 +03:00
|
|
|
debug_RegisterPrefCallbacks();
|
|
|
|
#endif
|
1998-09-23 23:19:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-30 23:43:11 +04:00
|
|
|
static void DestroyCompositor(CompositorParent* aCompositorParent,
|
|
|
|
CompositorChild* aCompositorChild,
|
|
|
|
Thread* aCompositorThread)
|
|
|
|
{
|
|
|
|
aCompositorChild->Destroy();
|
|
|
|
delete aCompositorThread;
|
|
|
|
aCompositorParent->Release();
|
|
|
|
aCompositorChild->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-23 23:19:23 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// nsBaseWidget destructor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsBaseWidget::~nsBaseWidget()
|
|
|
|
{
|
2010-07-16 01:08:10 +04:00
|
|
|
if (mLayerManager &&
|
|
|
|
mLayerManager->GetBackendType() == LayerManager::LAYERS_BASIC) {
|
|
|
|
static_cast<BasicLayerManager*>(mLayerManager.get())->ClearRetainerWidget();
|
|
|
|
}
|
|
|
|
|
2010-12-07 05:05:25 +03:00
|
|
|
if (mLayerManager) {
|
|
|
|
mLayerManager->Destroy();
|
2012-01-19 18:45:37 +04:00
|
|
|
mLayerManager = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mCompositorChild) {
|
2012-03-30 23:43:11 +04:00
|
|
|
mCompositorChild->SendWillStop();
|
|
|
|
|
|
|
|
// 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(DestroyCompositor, mCompositorParent,
|
|
|
|
mCompositorChild, mCompositorThread));
|
|
|
|
// The DestroyCompositor task we just added to the MessageLoop will handle
|
|
|
|
// releasing mCompositorParent and mCompositorChild.
|
|
|
|
mCompositorParent.forget();
|
|
|
|
mCompositorChild.forget();
|
2010-12-07 05:05:25 +03:00
|
|
|
}
|
|
|
|
|
1999-10-05 18:53:40 +04:00
|
|
|
#ifdef NOISY_WIDGET_LEAKS
|
|
|
|
gNumWidgets--;
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("WIDGETS- = %d\n", gNumWidgets);
|
1999-10-05 18:53:40 +04:00
|
|
|
#endif
|
|
|
|
|
2004-01-06 02:28:41 +03:00
|
|
|
NS_IF_RELEASE(mContext);
|
2011-05-17 18:01:36 +04:00
|
|
|
delete mOriginalBounds;
|
1998-09-23 23:19:23 +04:00
|
|
|
}
|
|
|
|
|
1999-10-15 04:49:11 +04:00
|
|
|
|
1998-09-23 23:19:23 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Basic create.
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsBaseWidget::BaseCreate(nsIWidget *aParent,
|
2009-01-15 06:27:09 +03:00
|
|
|
const nsIntRect &aRect,
|
1999-09-28 05:31:41 +04:00
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
2011-04-17 05:22:44 +04:00
|
|
|
nsDeviceContext *aContext,
|
1999-09-28 05:31:41 +04:00
|
|
|
nsWidgetInitData *aInitData)
|
1998-09-23 23:19:23 +04:00
|
|
|
{
|
2012-05-15 17:01:48 +04:00
|
|
|
static bool gDisableNativeThemeCached = false;
|
|
|
|
if (!gDisableNativeThemeCached) {
|
|
|
|
mozilla::Preferences::AddBoolVarCache(&gDisableNativeTheme,
|
|
|
|
"mozilla.widget.disable-native-theme",
|
|
|
|
gDisableNativeTheme);
|
|
|
|
gDisableNativeThemeCached = true;
|
|
|
|
}
|
|
|
|
|
1999-09-28 05:31:41 +04:00
|
|
|
// save the event callback function
|
|
|
|
mEventCallback = aHandleEventFunction;
|
|
|
|
|
|
|
|
// keep a reference to the device context
|
|
|
|
if (aContext) {
|
|
|
|
mContext = aContext;
|
|
|
|
NS_ADDREF(mContext);
|
|
|
|
}
|
|
|
|
else {
|
2011-04-17 05:22:42 +04:00
|
|
|
mContext = new nsDeviceContext();
|
|
|
|
NS_ADDREF(mContext);
|
|
|
|
mContext->Init(nsnull);
|
1999-09-28 05:31:41 +04:00
|
|
|
}
|
1998-09-23 23:19:23 +04:00
|
|
|
|
1999-09-28 05:31:41 +04:00
|
|
|
if (nsnull != aInitData) {
|
2009-09-24 13:32:20 +04:00
|
|
|
mWindowType = aInitData->mWindowType;
|
|
|
|
mBorderStyle = aInitData->mBorderStyle;
|
2010-07-27 17:38:03 +04:00
|
|
|
mPopupLevel = aInitData->mPopupLevel;
|
1999-09-28 05:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aParent) {
|
|
|
|
aParent->AddChild(this);
|
|
|
|
}
|
1998-09-23 23:19:23 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP nsBaseWidget::CaptureMouse(bool aCapture)
|
1999-06-22 00:37:50 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-23 23:19:23 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Accessor functions to get/set the client data
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBaseWidget::GetClientData(void*& aClientData)
|
|
|
|
{
|
|
|
|
aClientData = mClientData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBaseWidget::SetClientData(void* aClientData)
|
|
|
|
{
|
|
|
|
mClientData = aClientData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-20 23:29:02 +04:00
|
|
|
already_AddRefed<nsIWidget>
|
|
|
|
nsBaseWidget::CreateChild(const nsIntRect &aRect,
|
|
|
|
EVENT_CALLBACK aHandleEventFunction,
|
2011-04-17 05:22:44 +04:00
|
|
|
nsDeviceContext *aContext,
|
2010-08-20 23:29:02 +04:00
|
|
|
nsWidgetInitData *aInitData,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aForceUseIWidgetParent)
|
2010-08-20 23:29:02 +04:00
|
|
|
{
|
|
|
|
nsIWidget* parent = this;
|
|
|
|
nsNativeWidget nativeParent = nsnull;
|
|
|
|
|
|
|
|
if (!aForceUseIWidgetParent) {
|
|
|
|
// Use only either parent or nativeParent, not both, to match
|
|
|
|
// existing code. Eventually Create() should be divested of its
|
|
|
|
// nativeWidget parameter.
|
|
|
|
nativeParent = parent ? parent->GetNativeData(NS_NATIVE_WIDGET) : nsnull;
|
|
|
|
parent = nativeParent ? nsnull : parent;
|
|
|
|
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,
|
|
|
|
aHandleEventFunction,
|
2011-10-25 19:05:32 +04:00
|
|
|
aContext, aInitData))) {
|
2010-08-20 23:29:02 +04:00
|
|
|
return widget.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2012-02-01 01:55:54 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseWidget::SetEventCallback(EVENT_CALLBACK aEventFunction,
|
|
|
|
nsDeviceContext *aContext)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aEventFunction, "Must have valid event callback!");
|
|
|
|
|
|
|
|
mEventCallback = aEventFunction;
|
|
|
|
|
|
|
|
if (aContext) {
|
|
|
|
NS_IF_RELEASE(mContext);
|
|
|
|
mContext = aContext;
|
|
|
|
NS_ADDREF(mContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-06-25 06:01:06 +04:00
|
|
|
// Attach a view to our widget which we'll send events to.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseWidget::AttachViewToTopLevel(EVENT_CALLBACK aViewEventFunction,
|
2011-04-17 05:22:44 +04:00
|
|
|
nsDeviceContext *aContext)
|
2010-06-25 06:01:06 +04:00
|
|
|
{
|
2010-09-08 19:52:58 +04:00
|
|
|
NS_ASSERTION((mWindowType == eWindowType_toplevel ||
|
|
|
|
mWindowType == eWindowType_dialog ||
|
2011-02-09 23:13:18 +03:00
|
|
|
mWindowType == eWindowType_invisible ||
|
|
|
|
mWindowType == eWindowType_child),
|
|
|
|
"Can't attach to window of that type");
|
2010-06-25 06:01:06 +04:00
|
|
|
|
|
|
|
mViewCallback = aViewEventFunction;
|
|
|
|
|
|
|
|
if (aContext) {
|
|
|
|
if (mContext) {
|
|
|
|
NS_IF_RELEASE(mContext);
|
|
|
|
}
|
|
|
|
mContext = aContext;
|
|
|
|
NS_ADDREF(mContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewWrapper* nsBaseWidget::GetAttachedViewPtr()
|
|
|
|
{
|
|
|
|
return mViewWrapperPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBaseWidget::SetAttachedViewPtr(ViewWrapper* aViewWrapper)
|
|
|
|
{
|
|
|
|
mViewWrapperPtr = aViewWrapper;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-23 23:19:23 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Close this nsBaseWidget
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-29 02:32:48 +04:00
|
|
|
NS_METHOD nsBaseWidget::Destroy()
|
1998-09-23 23:19:23 +04:00
|
|
|
{
|
2004-05-23 00:54:40 +04:00
|
|
|
// Just in case our parent is the only ref to us
|
|
|
|
nsCOMPtr<nsIWidget> kungFuDeathGrip(this);
|
1998-09-23 23:19:23 +04:00
|
|
|
// disconnect from the parent
|
|
|
|
nsIWidget *parent = GetParent();
|
|
|
|
if (parent) {
|
|
|
|
parent->RemoveChild(this);
|
|
|
|
}
|
1999-04-20 03:24:40 +04:00
|
|
|
|
1998-09-29 02:32:48 +04:00
|
|
|
return NS_OK;
|
1998-09-23 23:19:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-12 07:59:15 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set this nsBaseWidget's parent
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP nsBaseWidget::SetParent(nsIWidget* aNewParent)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-23 23:19:23 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this nsBaseWidget parent
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsIWidget* nsBaseWidget::GetParent(void)
|
|
|
|
{
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2008-09-16 12:21:06 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this nsBaseWidget top level widget
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2009-08-04 02:25:20 +04:00
|
|
|
nsIWidget* nsBaseWidget::GetTopLevelWidget()
|
2008-09-16 12:21:06 +04:00
|
|
|
{
|
2008-12-15 16:43:48 +03:00
|
|
|
nsIWidget *topLevelWidget = nsnull, *widget = this;
|
2008-09-16 12:21:06 +04:00
|
|
|
while (widget) {
|
|
|
|
topLevelWidget = widget;
|
|
|
|
widget = widget->GetParent();
|
|
|
|
}
|
|
|
|
return topLevelWidget;
|
|
|
|
}
|
|
|
|
|
2008-05-02 15:32:50 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this nsBaseWidget's top (non-sheet) parent (if it's a sheet)
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsIWidget* nsBaseWidget::GetSheetWindowParent(void)
|
|
|
|
{
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2010-08-13 13:57:48 +04:00
|
|
|
float nsBaseWidget::GetDPI()
|
|
|
|
{
|
|
|
|
return 96.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
double nsBaseWidget::GetDefaultScale()
|
|
|
|
{
|
|
|
|
return 1.0;
|
|
|
|
}
|
|
|
|
|
1998-09-23 23:19:23 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Add a child to the list of children
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsBaseWidget::AddChild(nsIWidget* aChild)
|
|
|
|
{
|
2004-05-23 00:54:40 +04:00
|
|
|
NS_PRECONDITION(!aChild->GetNextSibling() && !aChild->GetPrevSibling(),
|
|
|
|
"aChild not properly removed from its old child list");
|
|
|
|
|
|
|
|
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 23:19:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Remove a child from the list of children
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsBaseWidget::RemoveChild(nsIWidget* aChild)
|
|
|
|
{
|
2006-03-22 21:00:28 +03:00
|
|
|
NS_ASSERTION(aChild->GetParent() == this, "Not one of our kids!");
|
2004-05-23 00:54:40 +04: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);
|
|
|
|
}
|
|
|
|
|
|
|
|
aChild->SetNextSibling(nsnull);
|
|
|
|
aChild->SetPrevSibling(nsnull);
|
1998-09-23 23:19:23 +04:00
|
|
|
}
|
1999-09-24 03:26:25 +04:00
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Sets widget's position within its parent's child list.
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP nsBaseWidget::SetZIndex(PRInt32 aZIndex)
|
|
|
|
{
|
2006-03-22 21:00:28 +03:00
|
|
|
// Hold a ref to ourselves just in case, since we're going to remove
|
|
|
|
// from our parent.
|
|
|
|
nsCOMPtr<nsIWidget> kungFuDeathGrip(this);
|
|
|
|
|
2004-01-06 02:28:41 +03:00
|
|
|
mZIndex = aZIndex;
|
|
|
|
|
|
|
|
// reorder this child in its parent's list.
|
2007-07-08 11:08:04 +04:00
|
|
|
nsBaseWidget* parent = static_cast<nsBaseWidget*>(GetParent());
|
2004-01-06 02:28:41 +03:00
|
|
|
if (parent) {
|
2004-05-23 00:54:40 +04: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()) {
|
2004-01-06 02:28:41 +03:00
|
|
|
PRInt32 childZIndex;
|
2004-05-23 00:54:40 +04:00
|
|
|
if (NS_SUCCEEDED(sib->GetZIndex(&childZIndex))) {
|
2004-01-06 02:28:41 +03:00
|
|
|
if (aZIndex < childZIndex) {
|
2004-05-23 00:54:40 +04:00
|
|
|
// 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;
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
PlaceBehind(eZPlacementBelow, sib, false);
|
2004-01-06 02:28:41 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// were we added to the list?
|
2004-05-23 00:54:40 +04:00
|
|
|
if (!sib) {
|
|
|
|
parent->AddChild(this);
|
2004-01-06 02:28:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1999-09-24 03:26:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Gets widget's position within its parent's child list.
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP nsBaseWidget::GetZIndex(PRInt32* aZIndex)
|
|
|
|
{
|
2004-01-06 02:28:41 +03:00
|
|
|
*aZIndex = mZIndex;
|
|
|
|
return NS_OK;
|
1999-09-24 03:26:25 +04:00
|
|
|
}
|
|
|
|
|
2000-04-02 02:10:22 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Places widget behind the given widget (platforms must override)
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2003-10-07 05:19:51 +04:00
|
|
|
NS_IMETHODIMP nsBaseWidget::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
2011-09-29 10:19:26 +04:00
|
|
|
nsIWidget *aWidget, bool aActivate)
|
2000-04-02 02:10:22 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-09 04:55:48 +03:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Maximize, minimize or restore the window. The BaseWidget implementation
|
|
|
|
// merely stores the state.
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2010-08-27 08:44:01 +04:00
|
|
|
NS_IMETHODIMP nsBaseWidget::SetSizeMode(PRInt32 aMode)
|
|
|
|
{
|
2009-07-08 20:13:13 +04:00
|
|
|
if (aMode == nsSizeMode_Normal ||
|
|
|
|
aMode == nsSizeMode_Minimized ||
|
|
|
|
aMode == nsSizeMode_Maximized ||
|
|
|
|
aMode == nsSizeMode_Fullscreen) {
|
2000-03-09 04:55:48 +03:00
|
|
|
|
|
|
|
mSizeMode = (nsSizeMode) aMode;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get the size mode (minimized, maximized, that sort of thing...)
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2010-08-27 08:44:01 +04:00
|
|
|
NS_IMETHODIMP nsBaseWidget::GetSizeMode(PRInt32* aMode)
|
|
|
|
{
|
2000-03-09 04:55:48 +03:00
|
|
|
*aMode = mSizeMode;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-23 23:19:23 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get the foreground color
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nscolor nsBaseWidget::GetForegroundColor(void)
|
|
|
|
{
|
1999-09-28 05:31:41 +04:00
|
|
|
return mForeground;
|
1998-09-23 23:19:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set the foreground color
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-29 02:32:48 +04:00
|
|
|
NS_METHOD nsBaseWidget::SetForegroundColor(const nscolor &aColor)
|
1998-09-23 23:19:23 +04:00
|
|
|
{
|
1999-09-28 05:31:41 +04:00
|
|
|
mForeground = aColor;
|
|
|
|
return NS_OK;
|
1998-09-23 23:19:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get the background color
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nscolor nsBaseWidget::GetBackgroundColor(void)
|
|
|
|
{
|
1999-09-28 05:31:41 +04:00
|
|
|
return mBackground;
|
1998-09-23 23:19:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set the background color
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
1998-09-29 02:32:48 +04:00
|
|
|
NS_METHOD nsBaseWidget::SetBackgroundColor(const nscolor &aColor)
|
1998-09-23 23:19:23 +04:00
|
|
|
{
|
1999-09-28 05:31:41 +04:00
|
|
|
mBackground = aColor;
|
|
|
|
return NS_OK;
|
1998-09-23 23:19:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get this component cursor
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
nsCursor nsBaseWidget::GetCursor()
|
|
|
|
{
|
1999-09-28 05:31:41 +04:00
|
|
|
return mCursor;
|
1998-09-23 23:19:23 +04:00
|
|
|
}
|
|
|
|
|
1998-09-29 02:32:48 +04:00
|
|
|
NS_METHOD nsBaseWidget::SetCursor(nsCursor aCursor)
|
1998-09-23 23:19:23 +04:00
|
|
|
{
|
|
|
|
mCursor = aCursor;
|
1998-09-29 02:32:48 +04:00
|
|
|
return NS_OK;
|
1998-09-23 23:19:23 +04:00
|
|
|
}
|
2004-12-31 00:56:11 +03:00
|
|
|
|
2005-07-01 08:29:42 +04:00
|
|
|
NS_IMETHODIMP nsBaseWidget::SetCursor(imgIContainer* aCursor,
|
|
|
|
PRUint32 aHotspotX, PRUint32 aHotspotY)
|
2004-12-31 00:56:11 +03:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
1998-09-23 23:19:23 +04:00
|
|
|
|
2001-06-05 03:03:24 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get the window type for this widget
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP nsBaseWidget::GetWindowType(nsWindowType& aWindowType)
|
|
|
|
{
|
|
|
|
aWindowType = mWindowType;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-04-06 06:49:40 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Window transparency methods
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2008-08-13 04:44:14 +04:00
|
|
|
void nsBaseWidget::SetTransparencyMode(nsTransparencyMode aMode) {
|
2003-04-06 06:49:40 +04:00
|
|
|
}
|
|
|
|
|
2008-08-13 04:44:14 +04:00
|
|
|
nsTransparencyMode nsBaseWidget::GetTransparencyMode() {
|
|
|
|
return eTransparencyOpaque;
|
2003-04-06 06:49:40 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-07-22 04:44:55 +04:00
|
|
|
nsBaseWidget::StoreWindowClipRegion(const nsTArray<nsIntRect>& aRects)
|
|
|
|
{
|
2009-07-27 01:19:15 +04:00
|
|
|
if (mClipRects && mClipRectCount == aRects.Length() &&
|
|
|
|
memcmp(mClipRects, aRects.Elements(), sizeof(nsIntRect)*mClipRectCount) == 0)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-07-27 01:19:15 +04:00
|
|
|
|
2009-07-22 04:44:55 +04:00
|
|
|
mClipRectCount = aRects.Length();
|
|
|
|
mClipRects = new nsIntRect[mClipRectCount];
|
|
|
|
if (mClipRects) {
|
|
|
|
memcpy(mClipRects, aRects.Elements(), sizeof(nsIntRect)*mClipRectCount);
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-07-22 04:44:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBaseWidget::GetWindowClipRegion(nsTArray<nsIntRect>* aRects)
|
|
|
|
{
|
|
|
|
if (mClipRects) {
|
|
|
|
aRects->AppendElements(mClipRects.get(), mClipRectCount);
|
|
|
|
} else {
|
|
|
|
aRects->AppendElement(nsIntRect(0, 0, mBounds.width, mBounds.height));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-14 19:33:40 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Set window shadow style
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBaseWidget::SetWindowShadowStyle(PRInt32 aMode)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2002-02-20 06:33:52 +03:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Hide window borders/decorations for this widget
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP nsBaseWidget::HideWindowChrome(bool aShouldHide)
|
2002-02-20 06:33:52 +03:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2001-06-05 03:03:24 +04:00
|
|
|
|
2002-11-06 12:35:13 +03:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Put the window into full-screen mode
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP nsBaseWidget::MakeFullScreen(bool aFullScreen)
|
2002-11-06 12:35:13 +03:00
|
|
|
{
|
2009-07-01 23:01:11 +04:00
|
|
|
HideWindowChrome(aFullScreen);
|
2002-11-06 12:35:13 +03:00
|
|
|
|
|
|
|
if (aFullScreen) {
|
|
|
|
if (!mOriginalBounds)
|
2009-01-15 06:27:09 +03:00
|
|
|
mOriginalBounds = new nsIntRect();
|
2002-11-06 12:35:13 +03:00
|
|
|
GetScreenBounds(*mOriginalBounds);
|
2003-05-08 22:31:01 +04:00
|
|
|
|
|
|
|
// Move to top-left corner of screen and size to the screen dimensions
|
|
|
|
nsCOMPtr<nsIScreenManager> screenManager;
|
|
|
|
screenManager = do_GetService("@mozilla.org/gfx/screenmanager;1");
|
|
|
|
NS_ASSERTION(screenManager, "Unable to grab screenManager.");
|
|
|
|
if (screenManager) {
|
|
|
|
nsCOMPtr<nsIScreen> screen;
|
|
|
|
screenManager->ScreenForRect(mOriginalBounds->x, mOriginalBounds->y,
|
|
|
|
mOriginalBounds->width, mOriginalBounds->height,
|
|
|
|
getter_AddRefs(screen));
|
|
|
|
if (screen) {
|
|
|
|
PRInt32 left, top, width, height;
|
|
|
|
if (NS_SUCCEEDED(screen->GetRect(&left, &top, &width, &height))) {
|
2011-10-17 18:59:28 +04:00
|
|
|
Resize(left, top, width, height, true);
|
2003-05-08 22:31:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-06 12:35:13 +03:00
|
|
|
} else if (mOriginalBounds) {
|
|
|
|
Resize(mOriginalBounds->x, mOriginalBounds->y, mOriginalBounds->width,
|
2011-10-17 18:59:28 +04:00
|
|
|
mOriginalBounds->height, true);
|
2002-11-06 12:35:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-03-01 11:03:49 +03:00
|
|
|
nsBaseWidget::AutoLayerManagerSetup::AutoLayerManagerSetup(
|
2010-07-16 01:08:04 +04:00
|
|
|
nsBaseWidget* aWidget, gfxContext* aTarget,
|
|
|
|
BasicLayerManager::BufferMode aDoubleBuffering)
|
2010-03-01 11:03:49 +03:00
|
|
|
: mWidget(aWidget)
|
|
|
|
{
|
|
|
|
BasicLayerManager* manager =
|
2011-03-25 18:03:35 +03:00
|
|
|
static_cast<BasicLayerManager*>(mWidget->GetLayerManager());
|
2010-03-01 11:03:49 +03:00
|
|
|
if (manager) {
|
2010-03-31 07:02:58 +04:00
|
|
|
NS_ASSERTION(manager->GetBackendType() == LayerManager::LAYERS_BASIC,
|
|
|
|
"AutoLayerManagerSetup instantiated for non-basic layer backend!");
|
2010-07-16 01:08:04 +04:00
|
|
|
manager->SetDefaultTarget(aTarget, aDoubleBuffering);
|
2010-03-01 11:03:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBaseWidget::AutoLayerManagerSetup::~AutoLayerManagerSetup()
|
|
|
|
{
|
|
|
|
BasicLayerManager* manager =
|
2011-03-25 18:03:35 +03:00
|
|
|
static_cast<BasicLayerManager*>(mWidget->GetLayerManager());
|
2010-03-01 11:03:49 +03:00
|
|
|
if (manager) {
|
2010-03-31 07:02:58 +04:00
|
|
|
NS_ASSERTION(manager->GetBackendType() == LayerManager::LAYERS_BASIC,
|
|
|
|
"AutoLayerManagerSetup instantiated for non-basic layer backend!");
|
2010-07-16 01:08:04 +04:00
|
|
|
manager->SetDefaultTarget(nsnull, BasicLayerManager::BUFFER_NONE);
|
2010-03-01 11:03:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-15 14:34:29 +04:00
|
|
|
nsBaseWidget::AutoUseBasicLayerManager::AutoUseBasicLayerManager(nsBaseWidget* aWidget)
|
|
|
|
: mWidget(aWidget)
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
mWidget->mTemporarilyUseBasicLayerManager = true;
|
2010-10-15 14:34:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsBaseWidget::AutoUseBasicLayerManager::~AutoUseBasicLayerManager()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
mWidget->mTemporarilyUseBasicLayerManager = false;
|
2010-10-15 14:34:29 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-09-09 02:19:11 +04:00
|
|
|
nsBaseWidget::GetShouldAccelerate()
|
2010-03-01 11:03:49 +03:00
|
|
|
{
|
2012-03-23 22:43:52 +04:00
|
|
|
#if defined(XP_WIN) || defined(ANDROID) || (MOZ_PLATFORM_MAEMO > 5) || defined(MOZ_GL_PROVIDER)
|
2011-09-29 10:19:26 +04:00
|
|
|
bool accelerateByDefault = true;
|
2011-01-21 00:21:47 +03:00
|
|
|
#elif defined(XP_MACOSX)
|
|
|
|
/* quickdraw plugins don't work with OpenGL so we need to avoid OpenGL when we want to support
|
|
|
|
* them. e.g. 10.5 */
|
|
|
|
# if defined(NP_NO_QUICKDRAW)
|
2011-09-29 10:19:26 +04:00
|
|
|
bool accelerateByDefault = true;
|
2011-02-04 00:12:33 +03:00
|
|
|
|
|
|
|
// 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.
|
|
|
|
SInt32 major, minor, bugfix;
|
|
|
|
OSErr err1 = ::Gestalt(gestaltSystemVersionMajor, &major);
|
|
|
|
OSErr err2 = ::Gestalt(gestaltSystemVersionMinor, &minor);
|
|
|
|
OSErr err3 = ::Gestalt(gestaltSystemVersionBugFix, &bugfix);
|
|
|
|
if (err1 == noErr && err2 == noErr && err3 == noErr) {
|
|
|
|
if (major == 10 && minor == 6) {
|
|
|
|
if (bugfix <= 2) {
|
2011-10-17 18:59:28 +04:00
|
|
|
accelerateByDefault = false;
|
2011-02-04 00:12:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-21 00:21:47 +03:00
|
|
|
# else
|
2011-09-29 10:19:26 +04:00
|
|
|
bool accelerateByDefault = false;
|
2011-01-21 00:21:47 +03:00
|
|
|
# endif
|
|
|
|
|
2011-01-12 01:01:37 +03:00
|
|
|
#else
|
2011-09-29 10:19:26 +04:00
|
|
|
bool accelerateByDefault = false;
|
2011-01-12 01:01:37 +03:00
|
|
|
#endif
|
2010-08-28 06:44:37 +04:00
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
// we should use AddBoolPrefVarCache
|
2012-05-06 00:29:13 +04:00
|
|
|
bool disableAcceleration = (mWindowType == eWindowType_popup) ||
|
2011-09-29 10:19:26 +04:00
|
|
|
Preferences::GetBool("layers.acceleration.disabled", false);
|
2012-02-28 01:33:19 +04:00
|
|
|
mForceLayersAcceleration =
|
2011-09-29 10:19:26 +04:00
|
|
|
Preferences::GetBool("layers.acceleration.force-enabled", false);
|
2010-09-09 02:19:11 +04:00
|
|
|
|
|
|
|
const char *acceleratedEnv = PR_GetEnv("MOZ_ACCELERATED");
|
2011-09-01 02:58:19 +04:00
|
|
|
accelerateByDefault = accelerateByDefault ||
|
2010-09-09 02:19:11 +04:00
|
|
|
(acceleratedEnv && (*acceleratedEnv != '0'));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXULRuntime> xr = do_GetService("@mozilla.org/xre/runtime;1");
|
2011-09-29 10:19:26 +04:00
|
|
|
bool safeMode = false;
|
2010-09-09 02:19:11 +04:00
|
|
|
if (xr)
|
|
|
|
xr->GetInSafeMode(&safeMode);
|
2010-05-12 22:56:31 +04:00
|
|
|
|
2011-08-19 19:39:00 +04:00
|
|
|
bool whitelisted = false;
|
2011-01-18 23:11:19 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
|
|
|
|
if (gfxInfo) {
|
2011-09-08 01:17:44 +04: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();
|
|
|
|
|
2011-01-18 23:11:19 +03:00
|
|
|
PRInt32 status;
|
|
|
|
if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_OPENGL_LAYERS, &status))) {
|
2011-08-19 19:39:00 +04:00
|
|
|
if (status == nsIGfxInfo::FEATURE_NO_INFO) {
|
|
|
|
whitelisted = true;
|
2011-01-18 23:11:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-19 19:39:00 +04:00
|
|
|
if (disableAcceleration || safeMode)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-08-19 19:39:00 +04:00
|
|
|
|
2012-02-28 01:33:19 +04:00
|
|
|
if (mForceLayersAcceleration)
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2011-08-19 19:39:00 +04:00
|
|
|
|
|
|
|
if (!whitelisted) {
|
|
|
|
NS_WARNING("OpenGL-accelerated layers are not supported on this system.");
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-08-19 19:39:00 +04:00
|
|
|
}
|
|
|
|
|
2011-01-18 23:11:19 +03:00
|
|
|
if (accelerateByDefault)
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2010-09-09 02:19:11 +04:00
|
|
|
|
2011-01-12 01:01:37 +03:00
|
|
|
/* use the window acceleration flag */
|
2010-09-09 02:19:11 +04:00
|
|
|
return mUseAcceleratedRendering;
|
|
|
|
}
|
2010-09-03 22:08:23 +04:00
|
|
|
|
2012-01-19 18:45:37 +04:00
|
|
|
void nsBaseWidget::CreateCompositor()
|
|
|
|
{
|
|
|
|
mCompositorThread = new Thread("CompositorThread");
|
|
|
|
if (mCompositorThread->Start()) {
|
2012-05-08 23:40:41 +04:00
|
|
|
bool renderToEGLSurface = false;
|
|
|
|
#ifdef MOZ_JAVA_COMPOSITOR
|
|
|
|
renderToEGLSurface = true;
|
|
|
|
#endif
|
|
|
|
nsIntRect rect;
|
|
|
|
GetBounds(rect);
|
|
|
|
mCompositorParent =
|
|
|
|
new CompositorParent(this, mCompositorThread->message_loop(), mCompositorThread->thread_id(),
|
|
|
|
renderToEGLSurface, rect.width, rect.height);
|
2012-01-19 18:45:37 +04:00
|
|
|
LayerManager* lm = CreateBasicLayerManager();
|
|
|
|
MessageLoop *childMessageLoop = mCompositorThread->message_loop();
|
|
|
|
mCompositorChild = new CompositorChild(lm);
|
|
|
|
AsyncChannel *parentChannel = mCompositorParent->GetIPCChannel();
|
|
|
|
AsyncChannel::Side childSide = mozilla::ipc::AsyncChannel::Child;
|
|
|
|
mCompositorChild->Open(parentChannel, childMessageLoop, childSide);
|
2012-05-16 07:19:37 +04:00
|
|
|
PLayersChild* shadowManager =
|
|
|
|
mCompositorChild->SendPLayersConstructor(LayerManager::LAYERS_OPENGL);
|
2012-01-19 18:45:37 +04:00
|
|
|
|
|
|
|
if (shadowManager) {
|
|
|
|
ShadowLayerForwarder* lf = lm->AsShadowForwarder();
|
|
|
|
if (!lf) {
|
|
|
|
delete lm;
|
|
|
|
mCompositorChild = nsnull;
|
2012-02-01 19:57:24 +04:00
|
|
|
return;
|
2012-01-19 18:45:37 +04:00
|
|
|
}
|
|
|
|
lf->SetShadowManager(shadowManager);
|
2012-05-16 07:19:37 +04:00
|
|
|
lf->SetParentBackendType(LayerManager::LAYERS_OPENGL);
|
2012-01-19 18:45:37 +04:00
|
|
|
|
|
|
|
mLayerManager = lm;
|
|
|
|
} else {
|
|
|
|
NS_WARNING("fail to construct LayersChild");
|
|
|
|
delete lm;
|
|
|
|
mCompositorChild = nsnull;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-09 23:38:26 +04:00
|
|
|
LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
|
|
|
|
LayersBackend aBackendHint,
|
|
|
|
LayerManagerPersistence aPersistence,
|
2010-12-07 05:05:52 +03:00
|
|
|
bool* aAllowRetaining)
|
2010-09-09 02:19:11 +04:00
|
|
|
{
|
|
|
|
if (!mLayerManager) {
|
2010-08-28 06:44:37 +04:00
|
|
|
|
2010-09-09 02:19:11 +04:00
|
|
|
mUseAcceleratedRendering = GetShouldAccelerate();
|
2010-08-28 06:44:37 +04:00
|
|
|
|
2012-05-15 23:56:56 +04:00
|
|
|
if (mUseAcceleratedRendering) {
|
2012-01-19 18:45:37 +04:00
|
|
|
|
2012-05-16 07:19:37 +04:00
|
|
|
// Try to use an async compositor first, if possible
|
|
|
|
bool useCompositor =
|
|
|
|
Preferences::GetBool("layers.offmainthreadcomposition.enabled", false);
|
|
|
|
if (useCompositor) {
|
|
|
|
// 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.
|
|
|
|
NS_ASSERTION(aShadowManager == nsnull, "Async Compositor not supported with e10s");
|
|
|
|
CreateCompositor();
|
|
|
|
}
|
|
|
|
|
2012-01-19 18:45:37 +04:00
|
|
|
if (!mLayerManager) {
|
|
|
|
nsRefPtr<LayerManagerOGL> layerManager = new LayerManagerOGL(this);
|
|
|
|
/**
|
|
|
|
* XXX - On several OSes initialization is expected to fail for now.
|
|
|
|
* If we'd get a non-basic layer manager they'd crash. This is ok though
|
|
|
|
* since on those platforms it will fail. Anyone implementing new
|
|
|
|
* platforms on LayerManagerOGL should ensure their widget is able to
|
|
|
|
* deal with it though!
|
|
|
|
*/
|
2012-02-28 01:33:19 +04:00
|
|
|
|
|
|
|
if (layerManager->Initialize(mForceLayersAcceleration)) {
|
2012-01-19 18:45:37 +04:00
|
|
|
mLayerManager = layerManager;
|
|
|
|
}
|
2010-03-31 07:02:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!mLayerManager) {
|
2010-10-15 14:34:29 +04:00
|
|
|
mBasicLayerManager = mLayerManager = CreateBasicLayerManager();
|
2010-03-31 07:02:58 +04:00
|
|
|
}
|
2010-03-01 11:03:49 +03:00
|
|
|
}
|
2010-10-15 14:34:29 +04:00
|
|
|
if (mTemporarilyUseBasicLayerManager && !mBasicLayerManager) {
|
|
|
|
mBasicLayerManager = CreateBasicLayerManager();
|
|
|
|
}
|
|
|
|
LayerManager* usedLayerManager = mTemporarilyUseBasicLayerManager ?
|
|
|
|
mBasicLayerManager : mLayerManager;
|
|
|
|
if (aAllowRetaining) {
|
|
|
|
*aAllowRetaining = (usedLayerManager == mLayerManager);
|
|
|
|
}
|
|
|
|
return usedLayerManager;
|
2010-03-01 11:03:49 +03:00
|
|
|
}
|
|
|
|
|
2010-09-15 03:40:23 +04:00
|
|
|
BasicLayerManager* nsBaseWidget::CreateBasicLayerManager()
|
|
|
|
{
|
|
|
|
return new BasicShadowLayerManager(this);
|
|
|
|
}
|
|
|
|
|
1998-09-23 23:19:23 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Return the used device context
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
2011-04-17 05:22:44 +04:00
|
|
|
nsDeviceContext* nsBaseWidget::GetDeviceContext()
|
1998-09-23 23:19:23 +04:00
|
|
|
{
|
|
|
|
return mContext;
|
|
|
|
}
|
|
|
|
|
2005-11-29 23:12:29 +03:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Get the thebes surface
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
gfxASurface *nsBaseWidget::GetThebesSurface()
|
|
|
|
{
|
|
|
|
// in theory we should get our parent's surface,
|
|
|
|
// clone it, and set a device offset before returning
|
|
|
|
return nsnull;
|
|
|
|
}
|
2007-09-02 19:55:28 +04:00
|
|
|
|
2005-11-29 23:12:29 +03:00
|
|
|
|
1998-09-23 23:19:23 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Destroy the window
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
void nsBaseWidget::OnDestroy()
|
|
|
|
{
|
2011-10-25 19:05:32 +04:00
|
|
|
// release references to device context and app shell
|
1999-09-28 05:31:41 +04:00
|
|
|
NS_IF_RELEASE(mContext);
|
1998-12-01 20:58:27 +03:00
|
|
|
}
|
|
|
|
|
2006-07-19 16:56:40 +04:00
|
|
|
NS_METHOD nsBaseWidget::SetWindowClass(const nsAString& xulWinType)
|
2002-08-07 05:59:22 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
1998-12-01 20:58:27 +03:00
|
|
|
|
2011-12-02 01:35:42 +04:00
|
|
|
NS_METHOD nsBaseWidget::MoveClient(PRInt32 aX, PRInt32 aY)
|
|
|
|
{
|
|
|
|
nsIntPoint clientOffset(GetClientOffset());
|
|
|
|
aX -= clientOffset.x;
|
|
|
|
aY -= clientOffset.y;
|
|
|
|
return Move(aX, aY);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsBaseWidget::ResizeClient(PRInt32 aWidth,
|
|
|
|
PRInt32 aHeight,
|
|
|
|
bool aRepaint)
|
|
|
|
{
|
|
|
|
NS_ASSERTION((aWidth >=0) , "Negative width passed to ResizeClient");
|
|
|
|
NS_ASSERTION((aHeight >=0), "Negative height passed to ResizeClient");
|
|
|
|
|
|
|
|
nsIntRect clientBounds;
|
|
|
|
GetClientBounds(clientBounds);
|
|
|
|
aWidth = mBounds.width + (aWidth - clientBounds.width);
|
|
|
|
aHeight = mBounds.height + (aHeight - clientBounds.height);
|
|
|
|
|
|
|
|
return Resize(aWidth, aHeight, aRepaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsBaseWidget::ResizeClient(PRInt32 aX,
|
|
|
|
PRInt32 aY,
|
|
|
|
PRInt32 aWidth,
|
|
|
|
PRInt32 aHeight,
|
|
|
|
bool aRepaint)
|
|
|
|
{
|
|
|
|
NS_ASSERTION((aWidth >=0) , "Negative width passed to ResizeClient");
|
|
|
|
NS_ASSERTION((aHeight >=0), "Negative height passed to ResizeClient");
|
|
|
|
|
|
|
|
nsIntRect clientBounds;
|
|
|
|
GetClientBounds(clientBounds);
|
|
|
|
aWidth = mBounds.width + (aWidth - clientBounds.width);
|
|
|
|
aHeight = mBounds.height + (aHeight - clientBounds.height);
|
|
|
|
|
|
|
|
nsIntPoint clientOffset(GetClientOffset());
|
|
|
|
aX -= clientOffset.x;
|
|
|
|
aY -= clientOffset.y;
|
|
|
|
|
|
|
|
return Resize(aX, aY, aWidth, aHeight, aRepaint);
|
|
|
|
}
|
|
|
|
|
2010-06-25 06:01:07 +04:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Bounds
|
|
|
|
//
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
1998-11-05 00:43:47 +03:00
|
|
|
/**
|
1998-12-04 00:46:27 +03:00
|
|
|
* If the implementation of nsWindow supports borders this method MUST be overridden
|
|
|
|
*
|
|
|
|
**/
|
2009-01-15 06:27:09 +03:00
|
|
|
NS_METHOD nsBaseWidget::GetClientBounds(nsIntRect &aRect)
|
1998-11-05 00:43:47 +03:00
|
|
|
{
|
|
|
|
return GetBounds(aRect);
|
|
|
|
}
|
|
|
|
|
1998-11-24 17:57:09 +03:00
|
|
|
/**
|
1998-12-04 00:46:27 +03:00
|
|
|
* If the implementation of nsWindow supports borders this method MUST be overridden
|
|
|
|
*
|
|
|
|
**/
|
2009-01-15 06:27:09 +03:00
|
|
|
NS_METHOD nsBaseWidget::GetBounds(nsIntRect &aRect)
|
1998-11-24 17:57:09 +03:00
|
|
|
{
|
|
|
|
aRect = mBounds;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-06 04:29:19 +03:00
|
|
|
/**
|
|
|
|
* If the implementation of nsWindow uses a local coordinate system within the window,
|
|
|
|
* this method must be overridden
|
|
|
|
*
|
|
|
|
**/
|
2009-01-15 06:27:09 +03:00
|
|
|
NS_METHOD nsBaseWidget::GetScreenBounds(nsIntRect &aRect)
|
2000-01-06 04:29:19 +03: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-15 02:00:24 +04:00
|
|
|
|
2010-07-27 17:38:03 +04:00
|
|
|
nsIntPoint nsBaseWidget::GetClientOffset()
|
2010-06-25 06:01:06 +04:00
|
|
|
{
|
2010-07-27 17:38:03 +04:00
|
|
|
return nsIntPoint(0, 0);
|
2010-06-25 06:01:06 +04:00
|
|
|
}
|
|
|
|
|
2009-01-15 06:27:09 +03:00
|
|
|
NS_METHOD nsBaseWidget::SetBounds(const nsIntRect &aRect)
|
1998-11-24 17:57:09 +03:00
|
|
|
{
|
|
|
|
mBounds = aRect;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-06-25 06:01:07 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseWidget::GetNonClientMargins(nsIntMargin &margins)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseWidget::SetNonClientMargins(nsIntMargin &margins)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
1998-11-05 00:43:47 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_METHOD nsBaseWidget::EnableDragDrop(bool aEnable)
|
1999-03-10 02:47:47 +03:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_METHOD nsBaseWidget::SetModal(bool aModal)
|
1999-06-14 00:56:08 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-07-09 16:11:12 +04:00
|
|
|
|
1999-12-10 10:20:51 +03:00
|
|
|
NS_IMETHODIMP
|
2004-02-11 06:46:30 +03:00
|
|
|
nsBaseWidget::GetAttention(PRInt32 aCycleCount) {
|
1999-12-10 10:20:51 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-04-22 03:53:52 +04:00
|
|
|
nsBaseWidget::HasPendingInputEvent()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-04-22 03:53:52 +04:00
|
|
|
}
|
|
|
|
|
2001-04-14 04:57:30 +04:00
|
|
|
NS_IMETHODIMP
|
2002-03-24 01:26:36 +03:00
|
|
|
nsBaseWidget::SetIcon(const nsAString&)
|
2001-04-14 04:57:30 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-09-27 20:01:32 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseWidget::BeginSecureKeyboardInput()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
NS_ASSERTION(!debug_InSecureKeyboardInputMode, "Attempting to nest call to BeginSecureKeyboardInput!");
|
2011-10-17 18:59:28 +04:00
|
|
|
debug_InSecureKeyboardInputMode = true;
|
2007-09-27 20:01:32 +04:00
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseWidget::EndSecureKeyboardInput()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
NS_ASSERTION(debug_InSecureKeyboardInputMode, "Calling EndSecureKeyboardInput when it hasn't been enabled!");
|
2011-10-17 18:59:28 +04:00
|
|
|
debug_InSecureKeyboardInputMode = false;
|
2007-09-27 20:01:32 +04:00
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-10-30 07:03:42 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBaseWidget::SetWindowTitlebarColor(nscolor aColor, bool aActive)
|
2007-10-30 07:03:42 +03:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2008-08-08 20:11:54 +04:00
|
|
|
nsBaseWidget::ShowsResizeIndicator(nsIntRect* aResizerRect)
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2008-08-08 20:11:54 +04:00
|
|
|
}
|
|
|
|
|
2010-03-31 07:02:58 +04:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBaseWidget::SetAcceleratedRendering(bool aEnabled)
|
2010-03-31 07:02:58 +04:00
|
|
|
{
|
|
|
|
if (mUseAcceleratedRendering == aEnabled) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
mUseAcceleratedRendering = aEnabled;
|
2010-12-07 05:05:25 +03:00
|
|
|
if (mLayerManager) {
|
|
|
|
mLayerManager->Destroy();
|
|
|
|
}
|
2010-03-31 07:02:58 +04:00
|
|
|
mLayerManager = NULL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-03-31 07:02:58 +04:00
|
|
|
nsBaseWidget::GetAcceleratedRendering()
|
|
|
|
{
|
|
|
|
return mUseAcceleratedRendering;
|
|
|
|
}
|
|
|
|
|
2010-08-02 17:34:54 +04:00
|
|
|
NS_METHOD nsBaseWidget::RegisterTouchWindow()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsBaseWidget::UnregisterTouchWindow()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2009-09-24 14:58:04 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseWidget::OverrideSystemMouseScrollSpeed(PRInt32 aOriginalDelta,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsHorizontal,
|
2009-09-24 14:58:04 +04:00
|
|
|
PRInt32 &aOverriddenDelta)
|
|
|
|
{
|
|
|
|
aOverriddenDelta = aOriginalDelta;
|
|
|
|
|
|
|
|
const char* kPrefNameOverrideEnabled =
|
|
|
|
"mousewheel.system_scroll_override_on_root_content.enabled";
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isOverrideEnabled =
|
|
|
|
Preferences::GetBool(kPrefNameOverrideEnabled, false);
|
2011-05-23 18:54:03 +04:00
|
|
|
if (!isOverrideEnabled) {
|
2009-09-24 14:58:04 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCAutoString factorPrefName(
|
|
|
|
"mousewheel.system_scroll_override_on_root_content.");
|
|
|
|
if (aIsHorizontal) {
|
|
|
|
factorPrefName.AppendLiteral("horizontal.");
|
|
|
|
} else {
|
|
|
|
factorPrefName.AppendLiteral("vertical.");
|
|
|
|
}
|
|
|
|
factorPrefName.AppendLiteral("factor");
|
2011-05-23 18:54:03 +04:00
|
|
|
PRInt32 iFactor = Preferences::GetInt(factorPrefName.get(), 0);
|
2009-09-24 14:58:04 +04:00
|
|
|
// The pref value must be larger than 100, otherwise, we don't override the
|
|
|
|
// delta value.
|
2011-05-23 18:54:03 +04:00
|
|
|
if (iFactor <= 100) {
|
2009-09-24 14:58:04 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
double factor = (double)iFactor / 100;
|
|
|
|
aOverriddenDelta = PRInt32(NS_round((double)aOriginalDelta * factor));
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-10-30 07:03:42 +03:00
|
|
|
|
2004-09-07 22:59:27 +04: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 10:19:26 +04:00
|
|
|
static bool
|
2004-09-07 22:59:27 +04:00
|
|
|
ResolveIconNameHelper(nsILocalFile *aFile,
|
|
|
|
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 10:19:26 +04:00
|
|
|
bool readable;
|
2004-09-07 22:59:27 +04: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,
|
|
|
|
nsILocalFile **aResult)
|
|
|
|
{
|
|
|
|
*aResult = nsnull;
|
|
|
|
|
|
|
|
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-09 02:06:17 +04:00
|
|
|
if (dirs) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool hasMore;
|
2004-09-09 02:06:17 +04:00
|
|
|
while (NS_SUCCEEDED(dirs->HasMoreElements(&hasMore)) && hasMore) {
|
|
|
|
nsCOMPtr<nsISupports> element;
|
|
|
|
dirs->GetNext(getter_AddRefs(element));
|
|
|
|
if (!element)
|
|
|
|
continue;
|
|
|
|
nsCOMPtr<nsILocalFile> file = do_QueryInterface(element);
|
|
|
|
if (!file)
|
|
|
|
continue;
|
|
|
|
if (ResolveIconNameHelper(file, aIconName, aIconSuffix)) {
|
|
|
|
NS_ADDREF(*aResult = file);
|
|
|
|
return;
|
|
|
|
}
|
2004-09-07 22:59:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// then check the main app chrome directory
|
|
|
|
|
|
|
|
nsCOMPtr<nsILocalFile> file;
|
|
|
|
dirSvc->Get(NS_APP_CHROME_DIR, NS_GET_IID(nsILocalFile),
|
|
|
|
getter_AddRefs(file));
|
2004-09-09 02:06:17 +04:00
|
|
|
if (file && ResolveIconNameHelper(file, aIconName, aIconSuffix))
|
2004-09-07 22:59:27 +04:00
|
|
|
NS_ADDREF(*aResult = file);
|
|
|
|
}
|
|
|
|
|
2007-12-11 13:08:35 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseWidget::BeginResizeDrag(nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2010-07-17 12:11:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseWidget::BeginMoveDrag(nsMouseEvent* aEvent)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2007-12-11 13:08:35 +03:00
|
|
|
}
|
2010-11-23 09:48:03 +03:00
|
|
|
|
2012-01-26 06:05:34 +04:00
|
|
|
PRUint32
|
|
|
|
nsBaseWidget::GetGLFrameBufferFormat()
|
|
|
|
{
|
|
|
|
if (mLayerManager &&
|
|
|
|
mLayerManager->GetBackendType() == LayerManager::LAYERS_OPENGL) {
|
|
|
|
// Assume that the default framebuffer has RGBA format. Specific
|
|
|
|
// backends that know differently will override this method.
|
|
|
|
return LOCAL_GL_RGBA;
|
|
|
|
}
|
|
|
|
return LOCAL_GL_NONE;
|
|
|
|
}
|
|
|
|
|
2002-01-24 04:18:36 +03:00
|
|
|
#ifdef DEBUG
|
1999-09-09 06:32:54 +04:00
|
|
|
//////////////////////////////////////////////////////////////
|
1999-07-09 16:11:12 +04: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 06:32:54 +04:00
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
/* static */ nsAutoString
|
|
|
|
nsBaseWidget::debug_GuiEventToString(nsGUIEvent * aGuiEvent)
|
1999-07-09 16:11:12 +04:00
|
|
|
{
|
1999-09-09 06:32:54 +04:00
|
|
|
NS_ASSERTION(nsnull != aGuiEvent,"cmon, null gui event.");
|
|
|
|
|
2001-12-16 14:58:03 +03:00
|
|
|
nsAutoString eventName(NS_LITERAL_STRING("UNKNOWN"));
|
1999-07-09 16:11:12 +04:00
|
|
|
|
|
|
|
#define _ASSIGN_eventName(_value,_name)\
|
2011-12-05 13:10:27 +04:00
|
|
|
case _value: eventName.AssignLiteral(_name) ; break
|
1999-07-09 16:11:12 +04:00
|
|
|
|
1999-09-09 06:32:54 +04:00
|
|
|
switch(aGuiEvent->message)
|
1999-07-09 16:11:12 +04:00
|
|
|
{
|
|
|
|
_ASSIGN_eventName(NS_BLUR_CONTENT,"NS_BLUR_CONTENT");
|
|
|
|
_ASSIGN_eventName(NS_CREATE,"NS_CREATE");
|
|
|
|
_ASSIGN_eventName(NS_DESTROY,"NS_DESTROY");
|
1999-09-09 06:32:54 +04: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");
|
1999-07-09 16:11:12 +04:00
|
|
|
_ASSIGN_eventName(NS_FOCUS_CONTENT,"NS_FOCUS_CONTENT");
|
1999-08-08 03:18:35 +04:00
|
|
|
_ASSIGN_eventName(NS_FORM_SELECTED,"NS_FORM_SELECTED");
|
1999-07-09 16:11:12 +04:00
|
|
|
_ASSIGN_eventName(NS_FORM_CHANGE,"NS_FORM_CHANGE");
|
1999-09-22 03:02:35 +04:00
|
|
|
_ASSIGN_eventName(NS_FORM_INPUT,"NS_FORM_INPUT");
|
1999-07-09 16:11:12 +04:00
|
|
|
_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 14:00:26 +04:00
|
|
|
_ASSIGN_eventName(NS_LOAD_ERROR,"NS_LOAD_ERROR");
|
1999-07-09 16:11:12 +04: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-17 00:35:39 +03: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 16:11:12 +04:00
|
|
|
_ASSIGN_eventName(NS_MOUSE_MOVE,"NS_MOUSE_MOVE");
|
|
|
|
_ASSIGN_eventName(NS_MOVE,"NS_MOVE");
|
2006-08-31 23:33:01 +04:00
|
|
|
_ASSIGN_eventName(NS_LOAD,"NS_LOAD");
|
2009-09-01 20:45:05 +04:00
|
|
|
_ASSIGN_eventName(NS_POPSTATE,"NS_POPSTATE");
|
2010-09-16 12:48:47 +04:00
|
|
|
_ASSIGN_eventName(NS_BEFORE_SCRIPT_EXECUTE,"NS_BEFORE_SCRIPT_EXECUTE");
|
|
|
|
_ASSIGN_eventName(NS_AFTER_SCRIPT_EXECUTE,"NS_AFTER_SCRIPT_EXECUTE");
|
1999-07-09 16:11:12 +04:00
|
|
|
_ASSIGN_eventName(NS_PAGE_UNLOAD,"NS_PAGE_UNLOAD");
|
2009-06-26 21:16:50 +04:00
|
|
|
_ASSIGN_eventName(NS_HASHCHANGE,"NS_HASHCHANGE");
|
2010-06-24 05:12:07 +04:00
|
|
|
_ASSIGN_eventName(NS_READYSTATECHANGE,"NS_READYSTATECHANGE");
|
1999-07-09 16:11:12 +04:00
|
|
|
_ASSIGN_eventName(NS_PAINT,"NS_PAINT");
|
1999-09-22 03:02:35 +04:00
|
|
|
_ASSIGN_eventName(NS_XUL_BROADCAST, "NS_XUL_BROADCAST");
|
|
|
|
_ASSIGN_eventName(NS_XUL_COMMAND_UPDATE, "NS_XUL_COMMAND_UPDATE");
|
1999-09-09 06:32:54 +04:00
|
|
|
_ASSIGN_eventName(NS_SCROLLBAR_LINE_NEXT,"NS_SB_LINE_NEXT");
|
|
|
|
_ASSIGN_eventName(NS_SCROLLBAR_LINE_PREV,"NS_SB_LINE_PREV");
|
|
|
|
_ASSIGN_eventName(NS_SCROLLBAR_PAGE_NEXT,"NS_SB_PAGE_NEXT");
|
|
|
|
_ASSIGN_eventName(NS_SCROLLBAR_PAGE_PREV,"NS_SB_PAGE_PREV");
|
|
|
|
_ASSIGN_eventName(NS_SCROLLBAR_POS,"NS_SB_POS");
|
1999-07-09 16:11:12 +04:00
|
|
|
_ASSIGN_eventName(NS_SIZE,"NS_SIZE");
|
|
|
|
|
|
|
|
#undef _ASSIGN_eventName
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
|
1999-09-09 06:32:54 +04:00
|
|
|
sprintf(buf,"UNKNOWN: %d",aGuiEvent->message);
|
1999-07-09 16:11:12 +04:00
|
|
|
|
2011-12-05 13:10:27 +04:00
|
|
|
CopyASCIItoUTF16(buf, eventName);
|
1999-07-09 16:11:12 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1999-09-09 06:32:54 +04:00
|
|
|
|
1999-07-09 16:11:12 +04:00
|
|
|
return nsAutoString(eventName);
|
|
|
|
}
|
1999-09-09 06:32:54 +04:00
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
//
|
1999-12-03 10:23:22 +03:00
|
|
|
// Code to deal with paint and event debug prefs.
|
1999-09-09 06:32:54 +04:00
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
1999-12-03 10:23:22 +03:00
|
|
|
struct PrefPair
|
|
|
|
{
|
2004-07-15 23:58:57 +04:00
|
|
|
const char * name;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool value;
|
1999-12-03 10:23:22 +03:00
|
|
|
};
|
1999-09-09 06:32:54 +04:00
|
|
|
|
1999-12-03 10:23:22 +03:00
|
|
|
static PrefPair debug_PrefValues[] =
|
|
|
|
{
|
2011-10-17 18:59:28 +04: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 10:23:22 +03:00
|
|
|
};
|
|
|
|
|
1999-09-09 06:32:54 +04:00
|
|
|
//////////////////////////////////////////////////////////////
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2002-01-24 04:18:36 +03:00
|
|
|
nsBaseWidget::debug_GetCachedBoolPref(const char * aPrefName)
|
1999-09-09 06:32:54 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull != aPrefName,"cmon, pref name is null.");
|
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
for (PRUint32 i = 0; i < ArrayLength(debug_PrefValues); i++)
|
1999-12-03 10:23:22 +03:00
|
|
|
{
|
2004-06-26 18:32:11 +04:00
|
|
|
if (strcmp(debug_PrefValues[i].name, aPrefName) == 0)
|
2004-01-06 02:28:41 +03:00
|
|
|
{
|
|
|
|
return debug_PrefValues[i].value;
|
|
|
|
}
|
1999-12-03 10:23:22 +03:00
|
|
|
}
|
1999-09-09 06:32:54 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1999-12-03 10:23:22 +03:00
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
2011-09-29 10:19:26 +04:00
|
|
|
static void debug_SetCachedBoolPref(const char * aPrefName,bool aValue)
|
1999-12-03 10:23:22 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull != aPrefName,"cmon, pref name is null.");
|
1999-09-09 06:32:54 +04:00
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
for (PRUint32 i = 0; i < ArrayLength(debug_PrefValues); i++)
|
1999-12-03 10:23:22 +03:00
|
|
|
{
|
2004-06-26 18:32:11 +04:00
|
|
|
if (strcmp(debug_PrefValues[i].name, aPrefName) == 0)
|
2004-01-06 02:28:41 +03:00
|
|
|
{
|
|
|
|
debug_PrefValues[i].value = aValue;
|
1999-09-09 06:32:54 +04:00
|
|
|
|
2004-01-06 02:28:41 +03:00
|
|
|
return;
|
|
|
|
}
|
1999-12-03 10:23:22 +03:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_ASSERTION(false, "cmon, this code is not reached dude.");
|
1999-12-03 10:23:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////
|
2006-10-23 19:29:09 +04:00
|
|
|
class Debug_PrefObserver : public nsIObserver {
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
};
|
1999-12-03 10:23:22 +03:00
|
|
|
|
2006-10-23 19:29:09 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(Debug_PrefObserver, nsIObserver)
|
1999-12-03 10:23:22 +03:00
|
|
|
|
2006-10-23 19:29:09 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
Debug_PrefObserver::Observe(nsISupports* subject, const char* topic,
|
|
|
|
const PRUnichar* data)
|
|
|
|
{
|
|
|
|
NS_ConvertUTF16toUTF8 prefName(data);
|
1999-12-03 10:23:22 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool value = Preferences::GetBool(prefName.get(), false);
|
2006-10-23 19:29:09 +04:00
|
|
|
debug_SetCachedBoolPref(prefName.get(), value);
|
|
|
|
return NS_OK;
|
1999-12-03 10:23:22 +03:00
|
|
|
}
|
2006-10-23 19:29:09 +04:00
|
|
|
|
1999-12-03 10:23:22 +03:00
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
/* static */ void
|
|
|
|
debug_RegisterPrefCallbacks()
|
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool once = true;
|
2004-01-06 02:28:41 +03:00
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
if (!once) {
|
|
|
|
return;
|
|
|
|
}
|
2004-01-06 02:28:41 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
once = false;
|
2004-01-06 02:28:41 +03:00
|
|
|
|
2011-05-23 18:54:03 +04:00
|
|
|
nsCOMPtr<nsIObserver> obs(new Debug_PrefObserver());
|
2011-10-11 09:50:08 +04:00
|
|
|
for (PRUint32 i = 0; i < ArrayLength(debug_PrefValues); i++) {
|
2011-05-23 18:54:03 +04:00
|
|
|
// Initialize the pref values
|
|
|
|
debug_PrefValues[i].value =
|
2011-09-29 10:19:26 +04:00
|
|
|
Preferences::GetBool(debug_PrefValues[i].name, false);
|
2011-05-23 18:54:03 +04:00
|
|
|
|
|
|
|
if (obs) {
|
|
|
|
// Register callbacks for when these change
|
|
|
|
Preferences::AddStrongObserver(obs, debug_PrefValues[i].name);
|
2004-01-06 02:28:41 +03:00
|
|
|
}
|
|
|
|
}
|
1999-09-09 06:32:54 +04:00
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
static PRInt32
|
|
|
|
_GetPrintCount()
|
|
|
|
{
|
|
|
|
static PRInt32 sCount = 0;
|
|
|
|
|
|
|
|
return ++sCount;
|
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
2011-09-29 10:19:26 +04:00
|
|
|
/* static */ bool
|
1999-09-09 06:32:54 +04:00
|
|
|
nsBaseWidget::debug_WantPaintFlashing()
|
|
|
|
{
|
1999-12-03 10:23:22 +03:00
|
|
|
return debug_GetCachedBoolPref("nglayout.debug.paint_flashing");
|
1999-09-09 06:32:54 +04:00
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
/* static */ void
|
|
|
|
nsBaseWidget::debug_DumpEvent(FILE * aFileOut,
|
|
|
|
nsIWidget * aWidget,
|
|
|
|
nsGUIEvent * aGuiEvent,
|
|
|
|
const nsCAutoString & aWidgetName,
|
|
|
|
PRInt32 aWindowID)
|
|
|
|
{
|
|
|
|
// NS_PAINT is handled by debug_DumpPaintEvent()
|
|
|
|
if (aGuiEvent->message == NS_PAINT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (aGuiEvent->message == NS_MOUSE_MOVE)
|
|
|
|
{
|
1999-12-03 10:23:22 +03:00
|
|
|
if (!debug_GetCachedBoolPref("nglayout.debug.motion_event_dumping"))
|
1999-09-09 06:32:54 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aGuiEvent->message == NS_MOUSE_ENTER ||
|
|
|
|
aGuiEvent->message == NS_MOUSE_EXIT)
|
|
|
|
{
|
1999-12-03 10:23:22 +03:00
|
|
|
if (!debug_GetCachedBoolPref("nglayout.debug.crossing_event_dumping"))
|
1999-09-09 06:32:54 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-12-03 10:23:22 +03:00
|
|
|
if (!debug_GetCachedBoolPref("nglayout.debug.event_dumping"))
|
1999-09-09 06:32:54 +04:00
|
|
|
return;
|
2000-04-17 12:21:30 +04:00
|
|
|
|
2011-12-05 13:10:27 +04:00
|
|
|
NS_LossyConvertUTF16toASCII tempString(debug_GuiEventToString(aGuiEvent).get());
|
1999-09-09 06:32:54 +04:00
|
|
|
|
|
|
|
fprintf(aFileOut,
|
2005-08-23 07:57:07 +04:00
|
|
|
"%4d %-26s widget=%-8p name=%-12s id=%-8p refpt=%d,%d\n",
|
1999-09-09 06:32:54 +04:00
|
|
|
_GetPrintCount(),
|
2001-10-26 08:24:06 +04:00
|
|
|
tempString.get(),
|
1999-09-09 06:32:54 +04:00
|
|
|
(void *) aWidget,
|
2001-10-26 08:24:06 +04:00
|
|
|
aWidgetName.get(),
|
1999-09-09 06:32:54 +04:00
|
|
|
(void *) (aWindowID ? aWindowID : 0x0),
|
2005-08-23 07:57:07 +04:00
|
|
|
aGuiEvent->refPoint.x,
|
|
|
|
aGuiEvent->refPoint.y);
|
1999-09-09 06:32:54 +04:00
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
/* static */ void
|
|
|
|
nsBaseWidget::debug_DumpPaintEvent(FILE * aFileOut,
|
|
|
|
nsIWidget * aWidget,
|
|
|
|
nsPaintEvent * aPaintEvent,
|
|
|
|
const nsCAutoString & aWidgetName,
|
|
|
|
PRInt32 aWindowID)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull != aFileOut,"cmon, null output FILE");
|
|
|
|
NS_ASSERTION(nsnull != aWidget,"cmon, the widget is null");
|
|
|
|
NS_ASSERTION(nsnull != aPaintEvent,"cmon, the paint event is null");
|
|
|
|
|
1999-12-03 10:23:22 +03:00
|
|
|
if (!debug_GetCachedBoolPref("nglayout.debug.paint_dumping"))
|
1999-09-09 06:32:54 +04:00
|
|
|
return;
|
|
|
|
|
2010-08-20 23:29:01 +04:00
|
|
|
nsIntRect rect = aPaintEvent->region.GetBounds();
|
1999-09-09 06:32:54 +04:00
|
|
|
fprintf(aFileOut,
|
2010-08-20 23:29:01 +04:00
|
|
|
"%4d PAINT widget=%p name=%-12s id=%-8p bounds-rect=%3d,%-3d %3d,%-3d",
|
1999-09-09 06:32:54 +04:00
|
|
|
_GetPrintCount(),
|
|
|
|
(void *) aWidget,
|
2001-10-26 08:24:06 +04:00
|
|
|
aWidgetName.get(),
|
2010-08-20 23:29:01 +04:00
|
|
|
(void *) aWindowID,
|
|
|
|
rect.x, rect.y, rect.width, rect.height
|
|
|
|
);
|
1999-09-09 06:32:54 +04:00
|
|
|
|
|
|
|
fprintf(aFileOut,"\n");
|
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
/* static */ void
|
|
|
|
nsBaseWidget::debug_DumpInvalidate(FILE * aFileOut,
|
|
|
|
nsIWidget * aWidget,
|
2009-01-15 06:27:09 +03:00
|
|
|
const nsIntRect * aRect,
|
1999-09-09 06:32:54 +04:00
|
|
|
const nsCAutoString & aWidgetName,
|
|
|
|
PRInt32 aWindowID)
|
|
|
|
{
|
1999-12-03 10:23:22 +03:00
|
|
|
if (!debug_GetCachedBoolPref("nglayout.debug.invalidate_dumping"))
|
1999-09-09 06:32:54 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
NS_ASSERTION(nsnull != aFileOut,"cmon, null output FILE");
|
|
|
|
NS_ASSERTION(nsnull != aWidget,"cmon, the widget is null");
|
|
|
|
|
|
|
|
fprintf(aFileOut,
|
|
|
|
"%4d Invalidate widget=%p name=%-12s id=%-8p",
|
|
|
|
_GetPrintCount(),
|
|
|
|
(void *) aWidget,
|
2001-10-26 08:24:06 +04:00
|
|
|
aWidgetName.get(),
|
1999-09-09 06:32:54 +04:00
|
|
|
(void *) aWindowID);
|
|
|
|
|
|
|
|
if (aRect)
|
|
|
|
{
|
|
|
|
fprintf(aFileOut,
|
|
|
|
" rect=%3d,%-3d %3d,%-3d",
|
|
|
|
aRect->x,
|
|
|
|
aRect->y,
|
|
|
|
aRect->width,
|
|
|
|
aRect->height);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf(aFileOut,
|
|
|
|
" rect=%-15s",
|
|
|
|
"none");
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(aFileOut,"\n");
|
|
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2002-01-24 04:18:36 +03:00
|
|
|
#endif // DEBUG
|
1999-09-09 06:32:54 +04:00
|
|
|
|