Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2022-01-19 10:29:12 +08:00
commit b0eda70edf
12 changed files with 79 additions and 59 deletions

View file

@ -24,6 +24,7 @@
#include "nsIURL.h"
#include "nsNetUtil.h"
#include "mozilla/Services.h"
#include "nsProxyRelease.h"
#include "nsIOutputStream.h"
#include "nsXPCOMStrings.h"
#include "nscore.h"
@ -442,6 +443,12 @@ STDMETHODIMP_(ULONG) nsDataObj::AddRef()
{
++m_cRef;
NS_LOG_ADDREF(this, m_cRef, "nsDataObj", sizeof(*this));
// When the first reference is taken, hold our own internal reference.
if (m_cRef == 1) {
mKeepAlive = this;
}
return m_cRef;
}
@ -528,6 +535,12 @@ STDMETHODIMP_(ULONG) nsDataObj::Release()
--m_cRef;
NS_LOG_RELEASE(this, m_cRef, "nsDataObj");
// If we hold the last reference, submit release of it to the main thread.
if (m_cRef == 1 && mKeepAlive) {
NS_ReleaseOnMainThread(mKeepAlive.forget(), true);
}
if (0 != m_cRef)
return m_cRef;
@ -542,6 +555,10 @@ STDMETHODIMP_(ULONG) nsDataObj::Release()
helper->Attach();
}
// In case the destructor ever AddRef/Releases, ensure we don't delete twice
// or take mKeepAlive as another reference.
m_cRef = 1;
delete this;
return 0;
@ -567,6 +584,9 @@ STDMETHODIMP nsDataObj::GetData(LPFORMATETC aFormat, LPSTGMEDIUM pSTM)
if (!mTransferable)
return DV_E_FORMATETC;
// Hold an extra reference in case we end up spinning the event loop.
RefPtr<nsDataObj> keepAliveDuringGetData(this);
uint32_t dfInx = 0;
static CLIPFORMAT fileDescriptorFlavorA = ::RegisterClipboardFormat( CFSTR_FILEDESCRIPTORA );

View file

@ -228,6 +228,7 @@ protected:
// nsDataObj owns and ref counts CEnumFormatEtc,
nsCOMPtr<nsIFile> mCachedTempFile;
RefPtr<nsDataObj> mKeepAlive;
BOOL mIsAsyncMode;
BOOL mIsInOperation;

View file

@ -1587,7 +1587,20 @@ NS_IMETHODIMP nsWindow::Show(bool bState)
// the popup.
flags |= SWP_NOACTIVATE;
HWND owner = ::GetWindow(mWnd, GW_OWNER);
::SetWindowPos(mWnd, owner ? 0 : HWND_TOPMOST, 0, 0, 0, 0, flags);
if (owner) {
// ePopupLevelTop popups should be above all else. All other
// types should be placed in front of their owner, without
// changing the owner's z-level relative to other windows.
if (PopupLevel() != ePopupLevelTop) {
::SetWindowPos(mWnd, owner, 0, 0, 0, 0, flags);
::SetWindowPos(owner, mWnd, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
} else {
::SetWindowPos(mWnd, HWND_TOP, 0, 0, 0, 0, flags);
}
} else {
::SetWindowPos(mWnd, HWND_TOPMOST, 0, 0, 0, 0, flags);
}
} else {
if (mWindowType == eWindowType_dialog && !CanTakeFocus())
flags |= SWP_NOACTIVATE;
@ -3449,8 +3462,6 @@ nsWindow::MakeFullScreen(bool aFullScreen, nsIScreen* aTargetScreen)
taskbarInfo->PrepareFullScreenHWND(mWnd, TRUE);
}
} else {
if (mSizeMode != nsSizeMode_Fullscreen)
return NS_OK;
SetSizeMode(mOldSizeMode);
}