Getting rid of event processor, it is no longer needed and will fix this problem

109566  r=kmcclusk sr=waterson
This commit is contained in:
rods%netscape.com 2002-01-16 03:02:35 +00:00
parent efa9881818
commit 6639d9eaad
9 changed files with 7 additions and 279 deletions

View File

@ -139,7 +139,6 @@ static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
// Print Preview
#include "nsIPrintPreviewContext.h"
#include "nsIEventProcessor.h"
#include "imgIContainer.h" // image animation mode constants
// Print Progress
@ -410,8 +409,7 @@ private:
class DocumentViewerImpl : public nsIDocumentViewer,
public nsIContentViewerEdit,
public nsIContentViewerFile,
public nsIMarkupDocumentViewer,
public nsIEventProcessor
public nsIMarkupDocumentViewer
{
friend class nsDocViewerSelectionListener;
friend class nsPagePrintTimer;
@ -447,9 +445,6 @@ public:
// nsIMarkupDocumentViewer
NS_DECL_NSIMARKUPDOCUMENTVIEWER
// nsIEventProcessor
NS_DECL_NSIEVENTPROCESSOR
typedef void (*CallChildFunc)(nsIMarkupDocumentViewer* aViewer,
void* aClosure);
nsresult CallChildren(CallChildFunc aFunc, void* aClosure);
@ -546,7 +541,6 @@ private:
void SetPrintPO(PrintObject* aPO, PRBool aPrint);
#ifdef NS_PRINT_PREVIEW
nsresult RemoveEventProcessorFromVMs(PrintObject* aPO);
nsresult ShowDocList(PrintObject* aPO, PRBool aShow);
void InstallNewPresentation();
void ReturnToGalleyPresentation();
@ -944,13 +938,12 @@ DocumentViewerImpl::DocumentViewerImpl(nsIPresContext* aPresContext)
PrepareToStartLoad();
}
NS_IMPL_ISUPPORTS6(DocumentViewerImpl,
NS_IMPL_ISUPPORTS5(DocumentViewerImpl,
nsIContentViewer,
nsIDocumentViewer,
nsIMarkupDocumentViewer,
nsIContentViewerFile,
nsIContentViewerEdit,
nsIEventProcessor)
nsIContentViewerEdit)
DocumentViewerImpl::~DocumentViewerImpl()
{
@ -1366,7 +1359,6 @@ DocumentViewerImpl::Destroy()
#ifdef NS_PRINT_PREVIEW
if (mPrtPreview) {
RemoveEventProcessorFromVMs(mPrtPreview->mPrintObject);
delete mPrtPreview;
mPrtPreview = nsnull;
}
@ -4568,26 +4560,6 @@ DocumentViewerImpl::IsThereARangeSelection(nsIDOMWindowInternal * aDOMWin)
}
#ifdef NS_PRINT_PREVIEW
//-------------------------------------------------------
// Recursively walks the PrintObject tree and removed the DocViewer
// as an event processor
nsresult
DocumentViewerImpl::RemoveEventProcessorFromVMs(PrintObject* aPO)
{
NS_ASSERTION(aPO, "Pointer is null!");
if (aPO->mViewManager != nsnull) {
aPO->mViewManager->SetEventProcessor(nsnull);
}
PRInt32 cnt = aPO->mKids.Count();
for (PRInt32 i=0;i<cnt;i++) {
if (NS_FAILED(RemoveEventProcessorFromVMs((PrintObject *)aPO->mKids[i]))) {
return NS_ERROR_FAILURE;
}
}
return NS_OK;
}
//-------------------------------------------------------
// Recursively walks the PrintObject tree and installs the DocViewer
// as an event processor and it shows the window
@ -4596,10 +4568,6 @@ DocumentViewerImpl::ShowDocList(PrintObject* aPO, PRBool aShow)
{
NS_ASSERTION(aPO, "Pointer is null!");
if (aPO->mViewManager != nsnull) {
aPO->mViewManager->SetEventProcessor(this);
}
PRBool donePrinting;
DoPrint(aPO, PR_FALSE, donePrinting);
@ -6497,51 +6465,6 @@ DocumentViewerImpl::FindFocusedDOMWindowInternal()
return domWin;
}
/*=============== nsIEventProcessor for PrintPreview ======================*/
// This is the method that gets plugged into the ViewManager
// so we can decide what events get discard.
NS_IMETHODIMP
DocumentViewerImpl::ProcessEvent(nsGUIEvent *aEvent, PRBool aIsInContentArea, nsEventStatus *aStatus) const
{
// short circut for mouse moves
if (aEvent->message == NS_MOUSE_MOVE) {
return NS_OK;
}
// check to see if it is a mouse event in the content area
// and discard it if it is
if (NS_IS_MOUSE_EVENT(aEvent)) {
if (aIsInContentArea) {
*aStatus = nsEventStatus_eConsumeNoDefault;
return NS_ERROR_FAILURE;
}
} else if (aEvent->message != NS_PAINT && // these are the events we let thru
aEvent->message != NS_DESTROY &&
aEvent->message != NS_SIZE &&
aEvent->message != NS_SCROLL_EVENT &&
aEvent->message != NS_SCROLLBAR_POS &&
aEvent->message != NS_SCROLLBAR_PAGE_NEXT &&
aEvent->message != NS_SCROLLBAR_PAGE_PREV &&
aEvent->message != NS_SCROLLBAR_LINE_NEXT &&
aEvent->message != NS_SCROLLBAR_LINE_PREV &&
aEvent->message != NS_MOUSE_SCROLL &&
aEvent->message != NS_SCROLLPORT_UNDERFLOW &&
aEvent->message != NS_SCROLLPORT_OVERFLOW &&
aEvent->message != NS_SCROLLPORT_OVERFLOWCHANGED &&
aEvent->message != NS_ACTIVATE &&
aEvent->message != NS_SETZLEVEL
) {
#ifdef DEBUG_rods
//printf("Discarding %d\n", aEvent->message);
#endif
*aStatus = nsEventStatus_eConsumeNoDefault;
return NS_ERROR_FAILURE;
}
return NS_OK;
}
/*=============== Timer Related Code ======================*/
nsresult
DocumentViewerImpl::StartPagePrintTimer(nsIPresContext * aPresContext,

View File

@ -139,7 +139,6 @@ static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
// Print Preview
#include "nsIPrintPreviewContext.h"
#include "nsIEventProcessor.h"
#include "imgIContainer.h" // image animation mode constants
// Print Progress
@ -410,8 +409,7 @@ private:
class DocumentViewerImpl : public nsIDocumentViewer,
public nsIContentViewerEdit,
public nsIContentViewerFile,
public nsIMarkupDocumentViewer,
public nsIEventProcessor
public nsIMarkupDocumentViewer
{
friend class nsDocViewerSelectionListener;
friend class nsPagePrintTimer;
@ -447,9 +445,6 @@ public:
// nsIMarkupDocumentViewer
NS_DECL_NSIMARKUPDOCUMENTVIEWER
// nsIEventProcessor
NS_DECL_NSIEVENTPROCESSOR
typedef void (*CallChildFunc)(nsIMarkupDocumentViewer* aViewer,
void* aClosure);
nsresult CallChildren(CallChildFunc aFunc, void* aClosure);
@ -546,7 +541,6 @@ private:
void SetPrintPO(PrintObject* aPO, PRBool aPrint);
#ifdef NS_PRINT_PREVIEW
nsresult RemoveEventProcessorFromVMs(PrintObject* aPO);
nsresult ShowDocList(PrintObject* aPO, PRBool aShow);
void InstallNewPresentation();
void ReturnToGalleyPresentation();
@ -944,13 +938,12 @@ DocumentViewerImpl::DocumentViewerImpl(nsIPresContext* aPresContext)
PrepareToStartLoad();
}
NS_IMPL_ISUPPORTS6(DocumentViewerImpl,
NS_IMPL_ISUPPORTS5(DocumentViewerImpl,
nsIContentViewer,
nsIDocumentViewer,
nsIMarkupDocumentViewer,
nsIContentViewerFile,
nsIContentViewerEdit,
nsIEventProcessor)
nsIContentViewerEdit)
DocumentViewerImpl::~DocumentViewerImpl()
{
@ -1366,7 +1359,6 @@ DocumentViewerImpl::Destroy()
#ifdef NS_PRINT_PREVIEW
if (mPrtPreview) {
RemoveEventProcessorFromVMs(mPrtPreview->mPrintObject);
delete mPrtPreview;
mPrtPreview = nsnull;
}
@ -4568,26 +4560,6 @@ DocumentViewerImpl::IsThereARangeSelection(nsIDOMWindowInternal * aDOMWin)
}
#ifdef NS_PRINT_PREVIEW
//-------------------------------------------------------
// Recursively walks the PrintObject tree and removed the DocViewer
// as an event processor
nsresult
DocumentViewerImpl::RemoveEventProcessorFromVMs(PrintObject* aPO)
{
NS_ASSERTION(aPO, "Pointer is null!");
if (aPO->mViewManager != nsnull) {
aPO->mViewManager->SetEventProcessor(nsnull);
}
PRInt32 cnt = aPO->mKids.Count();
for (PRInt32 i=0;i<cnt;i++) {
if (NS_FAILED(RemoveEventProcessorFromVMs((PrintObject *)aPO->mKids[i]))) {
return NS_ERROR_FAILURE;
}
}
return NS_OK;
}
//-------------------------------------------------------
// Recursively walks the PrintObject tree and installs the DocViewer
// as an event processor and it shows the window
@ -4596,10 +4568,6 @@ DocumentViewerImpl::ShowDocList(PrintObject* aPO, PRBool aShow)
{
NS_ASSERTION(aPO, "Pointer is null!");
if (aPO->mViewManager != nsnull) {
aPO->mViewManager->SetEventProcessor(this);
}
PRBool donePrinting;
DoPrint(aPO, PR_FALSE, donePrinting);
@ -6497,51 +6465,6 @@ DocumentViewerImpl::FindFocusedDOMWindowInternal()
return domWin;
}
/*=============== nsIEventProcessor for PrintPreview ======================*/
// This is the method that gets plugged into the ViewManager
// so we can decide what events get discard.
NS_IMETHODIMP
DocumentViewerImpl::ProcessEvent(nsGUIEvent *aEvent, PRBool aIsInContentArea, nsEventStatus *aStatus) const
{
// short circut for mouse moves
if (aEvent->message == NS_MOUSE_MOVE) {
return NS_OK;
}
// check to see if it is a mouse event in the content area
// and discard it if it is
if (NS_IS_MOUSE_EVENT(aEvent)) {
if (aIsInContentArea) {
*aStatus = nsEventStatus_eConsumeNoDefault;
return NS_ERROR_FAILURE;
}
} else if (aEvent->message != NS_PAINT && // these are the events we let thru
aEvent->message != NS_DESTROY &&
aEvent->message != NS_SIZE &&
aEvent->message != NS_SCROLL_EVENT &&
aEvent->message != NS_SCROLLBAR_POS &&
aEvent->message != NS_SCROLLBAR_PAGE_NEXT &&
aEvent->message != NS_SCROLLBAR_PAGE_PREV &&
aEvent->message != NS_SCROLLBAR_LINE_NEXT &&
aEvent->message != NS_SCROLLBAR_LINE_PREV &&
aEvent->message != NS_MOUSE_SCROLL &&
aEvent->message != NS_SCROLLPORT_UNDERFLOW &&
aEvent->message != NS_SCROLLPORT_OVERFLOW &&
aEvent->message != NS_SCROLLPORT_OVERFLOWCHANGED &&
aEvent->message != NS_ACTIVATE &&
aEvent->message != NS_SETZLEVEL
) {
#ifdef DEBUG_rods
//printf("Discarding %d\n", aEvent->message);
#endif
*aStatus = nsEventStatus_eConsumeNoDefault;
return NS_ERROR_FAILURE;
}
return NS_OK;
}
/*=============== Timer Related Code ======================*/
nsresult
DocumentViewerImpl::StartPagePrintTimer(nsIPresContext * aPresContext,

View File

@ -9,4 +9,3 @@ nsViewsCID.h
nsIViewObserver.h
nsIScrollPositionListener.h
nsICompositeListener.h
nsIEventProcessor.h

View File

@ -36,7 +36,6 @@ EXPORTS = \
nsIViewObserver.h \
nsIScrollPositionListener.h \
nsICompositeListener.h \
nsIEventProcessor.h \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -24,7 +24,7 @@ DEPTH=..\..
DEFINES=-D_IMPL_NS_UI
EXPORTS=nsIView.h nsIViewManager.h nsIScrollableView.h nsViewsCID.h nsIViewObserver.h \
nsIScrollPositionListener.h nsICompositeListener.h nsIEventProcessor.h
nsIScrollPositionListener.h nsICompositeListener.h
MODULE=view
include <$(DEPTH)\config\rules.mak>

View File

@ -1,79 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIEventProcessor_h___
#define nsIEventProcessor_h___
#include "nsISupports.h"
#include "nsEvent.h"
struct nsGUIEvent;
// IID for the nsIEventProcessor interface
// {DCC4C0F0-6D61-496f-96B1-F29226A62332}
#define NS_IEVENTPROCESSOR_IID \
{ 0xdcc4c0f0, 0x6d61, 0x496f, \
{ 0x96, 0xb1, 0xf2, 0x92, 0x26, 0xa6, 0x23, 0x32 } }
//----------------------------------------------------------------------
/**
* Event Processor interface
*
* Enables others to plug into the ViewManager so they can
* discard events of their choosing
*/
class nsIEventProcessor : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IEVENTPROCESSOR_IID)
/**
* Returns NS_OK if event should be processed, return NS_ERROR_FAILURE if
* the event should be discarded
* @param aEvent an event to be looked at
* @param aStatus status of event
*/
NS_IMETHOD ProcessEvent(nsGUIEvent *aEvent, PRBool aIsInContentArea, nsEventStatus *aStatus) const = 0;
};
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSIEVENTPROCESSOR \
NS_IMETHOD ProcessEvent(nsGUIEvent *aEvent, PRBool aIsInContentArea, nsEventStatus *aStatus) const;
#endif

View File

@ -48,7 +48,6 @@ class nsIWidget;
class nsICompositeListener;
struct nsRect;
class nsIDeviceContext;
class nsIEventProcessor;
class nsIViewObserver;
class nsIRegion;
@ -528,13 +527,6 @@ public:
*/
NS_IMETHOD IsRectVisible(nsIView *aView, const nsRect &aRect, PRBool aMustBeFullyVisible, PRBool *aIsVisible)=0;
/**
* Installs an event process that indicates whether the event should be disacrded or not
* (see nsIEventProcessor.h)
* @param aEventProcessor The event process to be installed and addref'ed,
* pass in nsnull to clear it
*/
NS_IMETHOD SetEventProcessor(nsIEventProcessor* aEventProcessor)=0;
};
//update view now?

View File

@ -1696,27 +1696,6 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
{
*aStatus = nsEventStatus_eIgnore;
if (mEventProcessor) {
// For mouse event we see if the event is in
// the content area (not the scrollbars),
// for other events we just pass true
PRBool isInRect = PR_TRUE;
if (NS_IS_MOUSE_EVENT(aEvent)) {
nsRect visRect;
GetVisibleRect(visRect);
float p2t;
mContext->GetDevUnitsToAppUnits(p2t);
nsPoint pnt(NSIntPixelsToTwips(aEvent->point.x, p2t),
NSIntPixelsToTwips(aEvent->point.y, p2t));
isInRect = visRect.Contains(pnt);
}
if (NS_FAILED(mEventProcessor->ProcessEvent(aEvent, isInRect, aStatus))) {
// means we should discard event
return NS_OK;
}
}
switch(aEvent->message)
{
case NS_SIZE:

View File

@ -52,7 +52,6 @@
#include "nsIBlender.h"
#include "nsIEventQueue.h"
#include "nsView.h"
#include "nsIEventProcessor.h"
class nsIRegion;
class nsIEvent;
@ -334,11 +333,6 @@ private:
nsresult ProcessWidgetChanges(nsView* aView);
/**
* Installs event processor
*/
NS_IMETHOD SetEventProcessor(nsIEventProcessor* aEventProcessor) { mEventProcessor = aEventProcessor; return NS_OK; }
// Utilities used to size the offscreen drawing surface
/**
@ -420,8 +414,6 @@ protected:
nsCOMPtr<nsIEventQueue> mEventQueue;
void PostInvalidateEvent();
nsCOMPtr<nsIEventProcessor> mEventProcessor;
#ifdef NS_VM_PERF_METRICS
MOZ_TIMER_DECLARE(mWatch) // Measures compositing+paint time for current document
#endif