зеркало из https://github.com/mozilla/pjs.git
backing out 2002-09-08 changes of fix for bug 117730 due to very bad regression in absolute positioning (see bug 117730) and
because bz, who did the original check-in, is on vacation. rs=brade
This commit is contained in:
Родитель
0334a6db84
Коммит
c0b49363f2
|
@ -69,23 +69,23 @@ NS_IMPL_ISUPPORTS2(nsBaseWidget::Enumerator, nsIBidirectionalEnumerator, nsIEnum
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
nsBaseWidget::nsBaseWidget()
|
nsBaseWidget::nsBaseWidget()
|
||||||
: mClientData(nsnull)
|
: mClientData(nsnull)
|
||||||
, mEventCallback(nsnull)
|
, mEventCallback(nsnull)
|
||||||
, mContext(nsnull)
|
, mContext(nsnull)
|
||||||
, mToolkit(nsnull)
|
, mToolkit(nsnull)
|
||||||
, mMouseListener(nsnull)
|
, mMouseListener(nsnull)
|
||||||
, mEventListener(nsnull)
|
, mEventListener(nsnull)
|
||||||
, mMenuListener(nsnull)
|
, mMenuListener(nsnull)
|
||||||
, mCursor(eCursor_standard)
|
, mCursor(eCursor_standard)
|
||||||
, mBorderStyle(eBorderStyle_none)
|
, mBorderStyle(eBorderStyle_none)
|
||||||
, mIsShiftDown(PR_FALSE)
|
, mIsShiftDown(PR_FALSE)
|
||||||
, mIsControlDown(PR_FALSE)
|
, mIsControlDown(PR_FALSE)
|
||||||
, mIsAltDown(PR_FALSE)
|
, mIsAltDown(PR_FALSE)
|
||||||
, mIsDestroying(PR_FALSE)
|
, mIsDestroying(PR_FALSE)
|
||||||
, mOnDestroyCalled(PR_FALSE)
|
, mOnDestroyCalled(PR_FALSE)
|
||||||
, mBounds(0,0,0,0)
|
, mBounds(0,0,0,0)
|
||||||
, mZIndex(0)
|
, mZIndex(0)
|
||||||
, mSizeMode(nsSizeMode_Normal)
|
, mSizeMode(nsSizeMode_Normal)
|
||||||
{
|
{
|
||||||
#ifdef NOISY_WIDGET_LEAKS
|
#ifdef NOISY_WIDGET_LEAKS
|
||||||
gNumWidgets++;
|
gNumWidgets++;
|
||||||
|
@ -114,9 +114,9 @@ nsBaseWidget::~nsBaseWidget()
|
||||||
printf("WIDGETS- = %d\n", gNumWidgets);
|
printf("WIDGETS- = %d\n", gNumWidgets);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NS_IF_RELEASE(mMenuListener);
|
NS_IF_RELEASE(mMenuListener);
|
||||||
NS_IF_RELEASE(mToolkit);
|
NS_IF_RELEASE(mToolkit);
|
||||||
NS_IF_RELEASE(mContext);
|
NS_IF_RELEASE(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -310,42 +310,35 @@ void nsBaseWidget::RemoveChild(nsIWidget* aChild)
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
NS_IMETHODIMP nsBaseWidget::SetZIndex(PRInt32 aZIndex)
|
NS_IMETHODIMP nsBaseWidget::SetZIndex(PRInt32 aZIndex)
|
||||||
{
|
{
|
||||||
mZIndex = aZIndex;
|
mZIndex = aZIndex;
|
||||||
|
|
||||||
// reorder this child in its parent's list.
|
// reorder this child in its parent's list.
|
||||||
nsBaseWidget* parent = NS_STATIC_CAST(nsBaseWidget*, GetParent());
|
nsBaseWidget* parent = NS_STATIC_CAST(nsBaseWidget*, GetParent());
|
||||||
if (nsnull != parent) {
|
if (nsnull != parent) {
|
||||||
PRUint32 childCount;
|
parent->mChildren->RemoveElement(this);
|
||||||
|
PRUint32 childCount, index;
|
||||||
if (NS_SUCCEEDED(parent->mChildren->Count(&childCount))) {
|
if (NS_SUCCEEDED(parent->mChildren->Count(&childCount))) {
|
||||||
if (childCount-- > 1) {
|
for (index = 0; index < childCount; index++) {
|
||||||
parent->mChildren->RemoveElement(this);
|
nsCOMPtr<nsIWidget> childWidget;
|
||||||
|
if (NS_SUCCEEDED(parent->mChildren->QueryElementAt(index, NS_GET_IID(nsIWidget), (void**)getter_AddRefs(childWidget)))) {
|
||||||
PRUint32 index;
|
PRInt32 childZIndex;
|
||||||
for (index = 0; index < childCount; index++) {
|
if (NS_SUCCEEDED(childWidget->GetZIndex(&childZIndex))) {
|
||||||
nsCOMPtr<nsIWidget> childWidget;
|
if (aZIndex < childZIndex) {
|
||||||
if (NS_SUCCEEDED(parent->mChildren->QueryElementAt(index, NS_GET_IID(nsIWidget), (void**)getter_AddRefs(childWidget)))) {
|
parent->mChildren->InsertElementAt(this, index);
|
||||||
PRInt32 childZIndex;
|
PlaceBehind(childWidget, PR_FALSE);
|
||||||
if (NS_SUCCEEDED(childWidget->GetZIndex(&childZIndex))) {
|
break;
|
||||||
if (aZIndex < childZIndex) {
|
}
|
||||||
parent->mChildren->InsertElementAt(this, index);
|
}
|
||||||
PlaceBehind(childWidget, PR_FALSE);
|
}
|
||||||
break;
|
}
|
||||||
}
|
// were we added to the list?
|
||||||
}
|
if (index == childCount) {
|
||||||
}
|
parent->mChildren->AppendElement(this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// were we added to the list?
|
NS_RELEASE(parent);
|
||||||
if (index == childCount) {
|
}
|
||||||
parent->mChildren->AppendElement(this);
|
return NS_OK;
|
||||||
PlaceBehind(nsnull, PR_FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NS_RELEASE(parent);
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
@ -355,8 +348,8 @@ NS_IMETHODIMP nsBaseWidget::SetZIndex(PRInt32 aZIndex)
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
NS_IMETHODIMP nsBaseWidget::GetZIndex(PRInt32* aZIndex)
|
NS_IMETHODIMP nsBaseWidget::GetZIndex(PRInt32* aZIndex)
|
||||||
{
|
{
|
||||||
*aZIndex = mZIndex;
|
*aZIndex = mZIndex;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
@ -922,18 +915,18 @@ case _value: eventName.AssignWithConversion(_name) ; break
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
struct PrefPair
|
struct PrefPair
|
||||||
{
|
{
|
||||||
char * name;
|
char * name;
|
||||||
PRBool value;
|
PRBool value;
|
||||||
};
|
};
|
||||||
|
|
||||||
static PrefPair debug_PrefValues[] =
|
static PrefPair debug_PrefValues[] =
|
||||||
{
|
{
|
||||||
{ "nglayout.debug.crossing_event_dumping", PR_FALSE },
|
{ "nglayout.debug.crossing_event_dumping", PR_FALSE },
|
||||||
{ "nglayout.debug.event_dumping", PR_FALSE },
|
{ "nglayout.debug.event_dumping", PR_FALSE },
|
||||||
{ "nglayout.debug.invalidate_dumping", PR_FALSE },
|
{ "nglayout.debug.invalidate_dumping", PR_FALSE },
|
||||||
{ "nglayout.debug.motion_event_dumping", PR_FALSE },
|
{ "nglayout.debug.motion_event_dumping", PR_FALSE },
|
||||||
{ "nglayout.debug.paint_dumping", PR_FALSE },
|
{ "nglayout.debug.paint_dumping", PR_FALSE },
|
||||||
{ "nglayout.debug.paint_flashing", PR_FALSE }
|
{ "nglayout.debug.paint_flashing", PR_FALSE }
|
||||||
};
|
};
|
||||||
|
|
||||||
static PRUint32 debug_NumPrefValues =
|
static PRUint32 debug_NumPrefValues =
|
||||||
|
@ -950,7 +943,7 @@ static PRBool debug_GetBoolPref(nsIPref * aPrefs,const char * aPrefName)
|
||||||
|
|
||||||
if (aPrefs)
|
if (aPrefs)
|
||||||
{
|
{
|
||||||
aPrefs->GetBoolPref(aPrefName,&value);
|
aPrefs->GetBoolPref(aPrefName,&value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -963,10 +956,10 @@ nsBaseWidget::debug_GetCachedBoolPref(const char * aPrefName)
|
||||||
|
|
||||||
for (PRUint32 i = 0; i < debug_NumPrefValues; i++)
|
for (PRUint32 i = 0; i < debug_NumPrefValues; i++)
|
||||||
{
|
{
|
||||||
if (NS_ConvertASCIItoUCS2(debug_PrefValues[i].name).EqualsWithConversion(aPrefName))
|
if (NS_ConvertASCIItoUCS2(debug_PrefValues[i].name).EqualsWithConversion(aPrefName))
|
||||||
{
|
{
|
||||||
return debug_PrefValues[i].value;
|
return debug_PrefValues[i].value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
|
@ -978,12 +971,12 @@ static void debug_SetCachedBoolPref(const char * aPrefName,PRBool aValue)
|
||||||
|
|
||||||
for (PRUint32 i = 0; i < debug_NumPrefValues; i++)
|
for (PRUint32 i = 0; i < debug_NumPrefValues; i++)
|
||||||
{
|
{
|
||||||
if (NS_ConvertASCIItoUCS2(debug_PrefValues[i].name).EqualsWithConversion(aPrefName))
|
if (NS_ConvertASCIItoUCS2(debug_PrefValues[i].name).EqualsWithConversion(aPrefName))
|
||||||
{
|
{
|
||||||
debug_PrefValues[i].value = aValue;
|
debug_PrefValues[i].value = aValue;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ASSERTION(PR_FALSE, "cmon, this code is not reached dude.");
|
NS_ASSERTION(PR_FALSE, "cmon, this code is not reached dude.");
|
||||||
|
@ -996,64 +989,64 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||||
debug_PrefChangedCallback(const char * name,void * closure)
|
debug_PrefChangedCallback(const char * name,void * closure)
|
||||||
{
|
{
|
||||||
|
|
||||||
nsIPref * prefs = nsnull;
|
nsIPref * prefs = nsnull;
|
||||||
|
|
||||||
nsresult rv = nsServiceManager::GetService(kPrefCID,
|
nsresult rv = nsServiceManager::GetService(kPrefCID,
|
||||||
NS_GET_IID(nsIPref),
|
NS_GET_IID(nsIPref),
|
||||||
(nsISupports**) &prefs);
|
(nsISupports**) &prefs);
|
||||||
|
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get prefs service.");
|
NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get prefs service.");
|
||||||
NS_ASSERTION(nsnull != prefs,"Prefs services is null.");
|
NS_ASSERTION(nsnull != prefs,"Prefs services is null.");
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
{
|
{
|
||||||
PRBool value = PR_FALSE;
|
PRBool value = PR_FALSE;
|
||||||
|
|
||||||
prefs->GetBoolPref(name,&value);
|
prefs->GetBoolPref(name,&value);
|
||||||
|
|
||||||
debug_SetCachedBoolPref(name,value);
|
debug_SetCachedBoolPref(name,value);
|
||||||
|
|
||||||
NS_RELEASE(prefs);
|
NS_RELEASE(prefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
/* static */ void
|
/* static */ void
|
||||||
debug_RegisterPrefCallbacks()
|
debug_RegisterPrefCallbacks()
|
||||||
{
|
{
|
||||||
static PRBool once = PR_TRUE;
|
static PRBool once = PR_TRUE;
|
||||||
|
|
||||||
if (once)
|
if (once)
|
||||||
{
|
{
|
||||||
once = PR_FALSE;
|
once = PR_FALSE;
|
||||||
|
|
||||||
nsIPref * prefs = nsnull;
|
nsIPref * prefs = nsnull;
|
||||||
|
|
||||||
nsresult rv = nsServiceManager::GetService(kPrefCID,
|
nsresult rv = nsServiceManager::GetService(kPrefCID,
|
||||||
NS_GET_IID(nsIPref),
|
NS_GET_IID(nsIPref),
|
||||||
(nsISupports**) &prefs);
|
(nsISupports**) &prefs);
|
||||||
|
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get prefs service.");
|
NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get prefs service.");
|
||||||
NS_ASSERTION(nsnull != prefs,"Prefs services is null.");
|
NS_ASSERTION(nsnull != prefs,"Prefs services is null.");
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
{
|
{
|
||||||
for (PRUint32 i = 0; i < debug_NumPrefValues; i++)
|
for (PRUint32 i = 0; i < debug_NumPrefValues; i++)
|
||||||
{
|
{
|
||||||
// Initialize the pref values
|
// Initialize the pref values
|
||||||
debug_PrefValues[i].value =
|
debug_PrefValues[i].value =
|
||||||
debug_GetBoolPref(prefs,debug_PrefValues[i].name);
|
debug_GetBoolPref(prefs,debug_PrefValues[i].name);
|
||||||
|
|
||||||
// Register callbacks for when these change
|
// Register callbacks for when these change
|
||||||
prefs->RegisterCallback(debug_PrefValues[i].name,
|
prefs->RegisterCallback(debug_PrefValues[i].name,
|
||||||
debug_PrefChangedCallback,
|
debug_PrefChangedCallback,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_RELEASE(prefs);
|
NS_RELEASE(prefs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
static PRInt32
|
static PRInt32
|
||||||
|
@ -1276,7 +1269,7 @@ nsBaseWidget::Enumerator::CurrentItem(nsISupports **aItem)
|
||||||
mParent.mChildren->Count(&itemCount);
|
mParent.mChildren->Count(&itemCount);
|
||||||
if ( mCurrentPosition < itemCount ) {
|
if ( mCurrentPosition < itemCount ) {
|
||||||
nsISupports* widget = mParent.mChildren->ElementAt(mCurrentPosition);
|
nsISupports* widget = mParent.mChildren->ElementAt(mCurrentPosition);
|
||||||
// NS_IF_ADDREF(widget); already addref'd in nsSupportsArray::ElementAt()
|
// NS_IF_ADDREF(widget); already addref'd in nsSupportsArray::ElementAt()
|
||||||
*aItem = widget;
|
*aItem = widget;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Загрузка…
Ссылка в новой задаче