Whitespace cleanup and sanitizing code a bit.

This commit is contained in:
jst%mozilla.jstenback.com 2005-03-15 00:07:46 +00:00
Родитель afba5ade73
Коммит d6517ec0cb
4 изменённых файлов: 215 добавлений и 204 удалений

Просмотреть файл

@ -44,49 +44,53 @@
* class nsNativeDragSource
*/
nsNativeDragSource::nsNativeDragSource()
: m_cRef(0)
{
m_cRef = 0;
}
nsNativeDragSource::~nsNativeDragSource()
{
}
STDMETHODIMP nsNativeDragSource::QueryInterface(REFIID riid, void** ppv)
STDMETHODIMP
nsNativeDragSource::QueryInterface(REFIID riid, void** ppv)
{
*ppv=NULL;
*ppv=NULL;
if (IID_IUnknown==riid || IID_IDropSource==riid)
*ppv=this;
if (IID_IUnknown==riid || IID_IDropSource==riid)
*ppv=this;
if (NULL!=*ppv) {
((LPUNKNOWN)*ppv)->AddRef();
return NOERROR;
}
if (NULL!=*ppv) {
((LPUNKNOWN)*ppv)->AddRef();
return NOERROR;
}
return ResultFromScode(E_NOINTERFACE);
return ResultFromScode(E_NOINTERFACE);
}
STDMETHODIMP_(ULONG) nsNativeDragSource::AddRef(void)
STDMETHODIMP_(ULONG)
nsNativeDragSource::AddRef(void)
{
++m_cRef;
NS_LOG_ADDREF(this, m_cRef, "nsNativeDragSource", sizeof(*this));
++m_cRef;
NS_LOG_ADDREF(this, m_cRef, "nsNativeDragSource", sizeof(*this));
return m_cRef;
}
STDMETHODIMP_(ULONG)
nsNativeDragSource::Release(void)
{
--m_cRef;
NS_LOG_RELEASE(this, m_cRef, "nsNativeDragSource");
if (0 != m_cRef)
return m_cRef;
delete this;
return 0;
}
STDMETHODIMP_(ULONG) nsNativeDragSource::Release(void)
{
--m_cRef;
NS_LOG_RELEASE(this, m_cRef, "nsNativeDragSource");
if (0 != m_cRef)
return m_cRef;
delete this;
return 0;
}
STDMETHODIMP nsNativeDragSource::QueryContinueDrag(BOOL fEsc, DWORD grfKeyState)
STDMETHODIMP
nsNativeDragSource::QueryContinueDrag(BOOL fEsc, DWORD grfKeyState)
{
#ifdef DEBUG
//printf("QueryContinueDrag: ");
@ -104,14 +108,15 @@ STDMETHODIMP nsNativeDragSource::QueryContinueDrag(BOOL fEsc, DWORD grfKeyState)
#endif
return ResultFromScode(DRAGDROP_S_DROP);
}
#ifdef DEBUG
//printf("NOERROR\n");
#endif
return NOERROR;
}
STDMETHODIMP nsNativeDragSource::GiveFeedback(DWORD dwEffect)
STDMETHODIMP
nsNativeDragSource::GiveFeedback(DWORD dwEffect)
{
#ifdef DEBUG
//printf("GiveFeedback\n");

Просмотреть файл

@ -43,41 +43,41 @@
//class nsIDragSource;
/*
* nsNativeDragSource implements the IDropSource interface and gets most of its
* behavior from the associated adapter (m_dragDrop).
* nsNativeDragSource implements the IDropSource interface and gets
* most of its behavior from the associated adapter (m_dragDrop).
*/
class nsNativeDragSource : public IDropSource
{
public: // construction, destruction
public:
// construct an nsNativeDragSource referencing adapter
//nsNativeDragSource(nsIDragSource * adapter);
nsNativeDragSource();
~nsNativeDragSource();
// construct an nsNativeDragSource referencing adapter
// nsNativeDragSource(nsIDragSource * adapter);
nsNativeDragSource();
~nsNativeDragSource();
public: // IUnknown methods - see iunknown.h for documentation
// IUnknown methods - see iunknown.h for documentation
STDMETHODIMP QueryInterface(REFIID, void**);
STDMETHODIMP_(ULONG) AddRef ();
STDMETHODIMP_(ULONG) Release ();
STDMETHODIMP QueryInterface(REFIID, void**);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
public: // IDropSource methods - see idropsrc.h for documentation
// IDropSource methods - see idropsrc.h for documentation
// Return DRAGDROP_S_USEDEFAULTCURSORS if this object lets OLE provide
// default cursors, otherwise return NOERROR. This method gets called in
// response to changes that the target makes to dEffect (DragEnter,
// DragOver).
STDMETHODIMP GiveFeedback (DWORD dEffect);
// Return DRAGDROP_S_USEDEFAULTCURSORS if this object lets OLE provide
// default cursors, otherwise return NOERROR. This method gets called in
// response to changes that the target makes to dEffect (DragEnter,
// DragOver).
STDMETHODIMP GiveFeedback(DWORD dEffect);
// This method gets called if there is any change in the mouse or key
// state. Return DRAGDROP_S_CANCEL to stop the drag, DRAGDROP_S_DROP
// to execute the drop, otherwise NOERROR.
STDMETHODIMP QueryContinueDrag (BOOL fESC, DWORD grfKeyState);
// This method gets called if there is any change in the mouse or key
// state. Return DRAGDROP_S_CANCEL to stop the drag, DRAGDROP_S_DROP
// to execute the drop, otherwise NOERROR.
STDMETHODIMP QueryContinueDrag(BOOL fESC, DWORD grfKeyState);
protected:
ULONG m_cRef; // reference count
//nsIDragSource * mDragSource; // adapter
//CfDragDrop * mDragSource; // adapter
protected:
ULONG m_cRef; // reference count
//nsIDragSource * mDragSource; // adapter
//CfDragDrop * mDragSource; // adapter
};

Просмотреть файл

@ -74,9 +74,9 @@ static POINTL gDragLastPoint;
// construction
//-----------------------------------------------------
nsNativeDragTarget::nsNativeDragTarget(nsIWidget * aWnd)
: m_cRef(0), mWindow(aWnd), mCanMove(PR_TRUE)
: m_cRef(0), mWindow(aWnd), mCanMove(PR_TRUE)
{
mHWnd = (HWND)mWindow->GetNativeData(NS_NATIVE_WINDOW);
mHWnd = (HWND)mWindow->GetNativeData(NS_NATIVE_WINDOW);
/*
* Create/Get the DragService that we have implemented
@ -96,49 +96,54 @@ nsNativeDragTarget::~nsNativeDragTarget()
//-----------------------------------------------------
// IUnknown methods - see iunknown.h for documentation
//-----------------------------------------------------
STDMETHODIMP nsNativeDragTarget::QueryInterface(REFIID riid, void** ppv)
STDMETHODIMP
nsNativeDragTarget::QueryInterface(REFIID riid, void** ppv)
{
*ppv=NULL;
*ppv=NULL;
if (IID_IUnknown == riid || IID_IDropTarget == riid)
*ppv=this;
if (IID_IUnknown == riid || IID_IDropTarget == riid)
*ppv=this;
if (NULL!=*ppv) {
((LPUNKNOWN)*ppv)->AddRef();
return NOERROR;
}
if (NULL!=*ppv) {
((LPUNKNOWN)*ppv)->AddRef();
return NOERROR;
}
return ResultFromScode(E_NOINTERFACE);
return ResultFromScode(E_NOINTERFACE);
}
//-----------------------------------------------------
STDMETHODIMP_(ULONG) nsNativeDragTarget::AddRef(void)
STDMETHODIMP_(ULONG)
nsNativeDragTarget::AddRef(void)
{
++m_cRef;
NS_LOG_ADDREF(this, m_cRef, "nsNativeDragTarget", sizeof(*this));
return m_cRef;
++m_cRef;
NS_LOG_ADDREF(this, m_cRef, "nsNativeDragTarget", sizeof(*this));
return m_cRef;
}
//-----------------------------------------------------
STDMETHODIMP_(ULONG) nsNativeDragTarget::Release(void)
{
--m_cRef;
NS_LOG_RELEASE(this, m_cRef, "nsNativeDragTarget");
if (0 != m_cRef)
return m_cRef;
--m_cRef;
NS_LOG_RELEASE(this, m_cRef, "nsNativeDragTarget");
if (0 != m_cRef)
return m_cRef;
delete this;
return 0;
delete this;
return 0;
}
//-----------------------------------------------------
void nsNativeDragTarget::GetGeckoDragAction(LPDATAOBJECT pData, DWORD grfKeyState, LPDWORD pdwEffect, PRUint32 * aGeckoAction)
void
nsNativeDragTarget::GetGeckoDragAction(LPDATAOBJECT pData, DWORD grfKeyState,
LPDWORD pdwEffect,
PRUint32 * aGeckoAction)
{
// Check if we can link from this data object as well.
PRBool canLink = PR_FALSE;
if ( pData )
if (pData)
canLink = (S_OK == ::OleQueryLinkFromData(pData) ? PR_TRUE : PR_FALSE);
// Default is move if we can, in fact drop here,
@ -165,18 +170,17 @@ void nsNativeDragTarget::GetGeckoDragAction(LPDATAOBJECT pData, DWORD grfKeyStat
}
PRBool IsKeyDown ( char key ) ;
inline
PRBool IsKeyDown ( char key )
PRBool
IsKeyDown(char key)
{
return GetKeyState(key) < 0;
}
//-----------------------------------------------------
void nsNativeDragTarget::DispatchDragDropEvent(PRUint32 aEventType,
POINTL aPT)
void
nsNativeDragTarget::DispatchDragDropEvent(PRUint32 aEventType, POINTL aPT)
{
nsEventStatus status;
nsMouseEvent event(aEventType, mWindow);
@ -206,11 +210,12 @@ void nsNativeDragTarget::DispatchDragDropEvent(PRUint32 aEventType,
}
//-----------------------------------------------------
void nsNativeDragTarget::ProcessDrag(LPDATAOBJECT pData,
PRUint32 aEventType,
DWORD grfKeyState,
POINTL pt,
DWORD* pdwEffect)
void
nsNativeDragTarget::ProcessDrag(LPDATAOBJECT pData,
PRUint32 aEventType,
DWORD grfKeyState,
POINTL pt,
DWORD* pdwEffect)
{
// Before dispatching the event make sure we have the correct drop action set
PRUint32 geckoAction;
@ -218,14 +223,14 @@ void nsNativeDragTarget::ProcessDrag(LPDATAOBJECT pData,
// Set the current action into the Gecko specific type
nsCOMPtr<nsIDragSession> currSession;
mDragService->GetCurrentSession ( getter_AddRefs(currSession) );
mDragService->GetCurrentSession(getter_AddRefs(currSession));
currSession->SetDragAction(geckoAction);
// Dispatch the event into Gecko
DispatchDragDropEvent(aEventType, pt);
// Now get the cached Drag effect from the drag service
// the data memeber should have been set by who ever handled the
// the data memeber should have been set by who ever handled the
// nsGUIEvent or nsIDOMEvent
PRBool canDrop;
currSession->GetCanDrop(&canDrop);
@ -242,100 +247,101 @@ void nsNativeDragTarget::ProcessDrag(LPDATAOBJECT pData,
//-----------------------------------------------------
STDMETHODIMP nsNativeDragTarget::DragEnter(LPDATAOBJECT pIDataSource,
DWORD grfKeyState,
POINTL pt,
DWORD* pdwEffect)
STDMETHODIMP
nsNativeDragTarget::DragEnter(LPDATAOBJECT pIDataSource,
DWORD grfKeyState,
POINTL pt,
DWORD* pdwEffect)
{
if (DRAG_DEBUG) printf("DragEnter\n");
if (mDragService) {
// tell the drag service about this drag (it may have come from an
// outside app).
mDragService->StartDragSession();
// Remember if this operation allows a move.
mCanMove = (*pdwEffect) & DROPEFFECT_MOVE;
// Set the native data object into drag service
//
// This cast is ok because in the constructor we created a
// the actual implementation we wanted, so we know this is
// a nsDragService. It should be a private interface, though.
nsDragService * winDragService = NS_STATIC_CAST(nsDragService *, mDragService);
winDragService->SetIDataObject(pIDataSource);
// Now process the native drag state and then dispatch the event
ProcessDrag(pIDataSource, NS_DRAGDROP_ENTER, grfKeyState, pt, pdwEffect);
return S_OK;
}
else
if (!mDragService) {
return ResultFromScode(E_FAIL);
}
// tell the drag service about this drag (it may have come from an
// outside app).
mDragService->StartDragSession();
// Remember if this operation allows a move.
mCanMove = (*pdwEffect) & DROPEFFECT_MOVE;
// Set the native data object into drag service
//
// This cast is ok because in the constructor we created a
// the actual implementation we wanted, so we know this is
// a nsDragService. It should be a private interface, though.
nsDragService * winDragService =
NS_STATIC_CAST(nsDragService *, mDragService);
winDragService->SetIDataObject(pIDataSource);
// Now process the native drag state and then dispatch the event
ProcessDrag(pIDataSource, NS_DRAGDROP_ENTER, grfKeyState, pt, pdwEffect);
return S_OK;
}
//-----------------------------------------------------
STDMETHODIMP nsNativeDragTarget::DragOver(DWORD grfKeyState,
POINTL pt,
LPDWORD pdwEffect)
STDMETHODIMP
nsNativeDragTarget::DragOver(DWORD grfKeyState,
POINTL pt,
LPDWORD pdwEffect)
{
if (DRAG_DEBUG) printf("DragOver\n");
if (mDragService) {
// Now process the native drag state and then dispatch the event
ProcessDrag(nsnull, NS_DRAGDROP_OVER, grfKeyState, pt, pdwEffect);
return S_OK;
}
else
if (!mDragService) {
return ResultFromScode(E_FAIL);
}
// Now process the native drag state and then dispatch the event
ProcessDrag(nsnull, NS_DRAGDROP_OVER, grfKeyState, pt, pdwEffect);
return S_OK;
}
//-----------------------------------------------------
STDMETHODIMP nsNativeDragTarget::DragLeave() {
if (DRAG_DEBUG) printf("DragLeave\n");
if (mDragService) {
// dispatch the event into Gecko
DispatchDragDropEvent(NS_DRAGDROP_EXIT, gDragLastPoint);
// tell the drag service that we're done with it
mDragService->EndDragSession();
return S_OK;
}
else
return ResultFromScode(E_FAIL);
}
//-----------------------------------------------------
STDMETHODIMP nsNativeDragTarget::Drop(LPDATAOBJECT pData,
DWORD grfKeyState,
POINTL aPT,
LPDWORD pdwEffect)
STDMETHODIMP
nsNativeDragTarget::DragLeave()
{
if (mDragService) {
// Set the native data object into the drag service
//
// This cast is ok because in the constructor we created a
// the actual implementation we wanted, so we know this is
// a nsDragService (but it should still be a private interface)
nsDragService * winDragService = NS_STATIC_CAST(nsDragService *, mDragService);
winDragService->SetIDataObject(pData);
if (DRAG_DEBUG) printf("DragLeave\n");
// Now process the native drag state and then dispatch the event
ProcessDrag(pData, NS_DRAGDROP_DROP, grfKeyState, aPT, pdwEffect);
// tell the drag service we're done with the session
mDragService->EndDragSession();
return S_OK;
}
else
if (!mDragService) {
return ResultFromScode(E_FAIL);
}
// dispatch the event into Gecko
DispatchDragDropEvent(NS_DRAGDROP_EXIT, gDragLastPoint);
// tell the drag service that we're done with it
mDragService->EndDragSession();
return S_OK;
}
//-----------------------------------------------------
STDMETHODIMP
nsNativeDragTarget::Drop(LPDATAOBJECT pData,
DWORD grfKeyState,
POINTL aPT,
LPDWORD pdwEffect)
{
if (!mDragService) {
return ResultFromScode(E_FAIL);
}
// Set the native data object into the drag service
//
// This cast is ok because in the constructor we created a
// the actual implementation we wanted, so we know this is
// a nsDragService (but it should still be a private interface)
nsDragService * winDragService =
NS_STATIC_CAST(nsDragService *, mDragService);
winDragService->SetIDataObject(pData);
// Now process the native drag state and then dispatch the event
ProcessDrag(pData, NS_DRAGDROP_DROP, grfKeyState, aPT, pdwEffect);
// tell the drag service we're done with the session
mDragService->EndDragSession();
return S_OK;
}

Просмотреть файл

@ -54,58 +54,58 @@ struct IDataObject;
class nsNativeDragTarget : public IDropTarget
{
public: // construction, destruction
public:
nsNativeDragTarget(nsIWidget * aWnd);
~nsNativeDragTarget();
nsNativeDragTarget(nsIWidget * aWnd);
~nsNativeDragTarget();
// IUnknown members - see iunknown.h for documentation
STDMETHODIMP QueryInterface(REFIID, void**);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
public: // IUnknown members - see iunknown.h for documentation
STDMETHODIMP QueryInterface(REFIID, void**);
STDMETHODIMP_(ULONG) AddRef ();
STDMETHODIMP_(ULONG) Release ();
// IDataTarget members
public: // IDataTarget members
// Set pEffect based on whether this object can support a drop based on
// the data available from pSource, the key and mouse states specified
// in grfKeyState, and the coordinates specified by point. This is
// called by OLE when a drag enters this object's window (as registered
// by Initialize).
STDMETHODIMP DragEnter(LPDATAOBJECT pSource, DWORD grfKeyState,
POINTL point, DWORD* pEffect);
// Set pEffect based on whether this object can support a drop based on
// the data available from pSource, the key and mouse states specified
// in grfKeyState, and the coordinates specified by point. This is
// called by OLE when a drag enters this object's window (as registered
// by Initialize).
STDMETHODIMP DragEnter(LPDATAOBJECT pSource, DWORD grfKeyState,
POINTL point, DWORD* pEffect);
// Similar to DragEnter except it is called frequently while the drag
// is over this object's window.
STDMETHODIMP DragOver(DWORD grfKeyState, POINTL point, DWORD* pEffect);
// Similar to DragEnter except it is called frequently while the drag
// is over this object's window.
STDMETHODIMP DragOver(DWORD grfKeyState, POINTL point, DWORD* pEffect);
// Release the drag-drop source and put internal state back to the point
// before the call to DragEnter. This is called when the drag leaves
// without a drop occurring.
STDMETHODIMP DragLeave();
// Release the drag-drop source and put internal state back to the point
// before the call to DragEnter. This is called when the drag leaves
// without a drop occurring.
STDMETHODIMP DragLeave();
// If point is within our region of interest and pSource's data supports
// one of our formats, get the data and set pEffect according to
// grfKeyState (DROPEFFECT_MOVE if the control key was not pressed,
// DROPEFFECT_COPY if the control key was pressed). Otherwise return
// E_FAIL.
STDMETHODIMP Drop(LPDATAOBJECT pSource, DWORD grfKeyState,
POINTL point, DWORD* pEffect);
// If point is within our region of interest and pSource's data supports
// one of our formats, get the data and set pEffect according to
// grfKeyState (DROPEFFECT_MOVE if the control key was not pressed,
// DROPEFFECT_COPY if the control key was pressed). Otherwise return
// E_FAIL.
STDMETHODIMP Drop(LPDATAOBJECT pSource, DWORD grfKeyState,
POINTL point, DWORD* pEffect);
protected:
protected:
void GetGeckoDragAction(LPDATAOBJECT pData, DWORD grfKeyState,
LPDWORD pdwEffect, PRUint32 * aGeckoAction);
void ProcessDrag(LPDATAOBJECT pData, PRUint32 aEventType, DWORD grfKeyState,
POINTL pt, DWORD* pdwEffect);
void DispatchDragDropEvent(PRUint32 aType, POINTL pt);
void GetGeckoDragAction ( LPDATAOBJECT pData, DWORD grfKeyState, LPDWORD pdwEffect, PRUint32 * aGeckoAction );
void ProcessDrag ( LPDATAOBJECT pData, PRUint32 aEventType, DWORD grfKeyState,
POINTL pt, DWORD* pdwEffect );
void DispatchDragDropEvent(PRUint32 aType, POINTL pt);
// Native Stuff
ULONG m_cRef; // reference count
HWND mHWnd;
PRBool mCanMove;
// Native Stuff
ULONG m_cRef; // reference count
HWND mHWnd;
PRBool mCanMove;
// Gecko Stuff
nsIWidget * mWindow;
nsIDragService * mDragService;
// Gecko Stuff
nsIWidget * mWindow;
nsIDragService * mDragService;
};
#endif // _nsNativeDragTarget_h_