Bug 496102 - Remove nsNotifyPaintEvent, r+sr=roc

This commit is contained in:
Olli Pettay 2009-06-23 12:09:05 +03:00
Родитель 8a5663062e
Коммит c76d6cdde2
7 изменённых файлов: 53 добавлений и 71 удалений

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

@ -53,6 +53,7 @@ class nsIDOMEventTarget;
class nsIDOMEvent;
class nsEvent;
class nsCommandEvent;
class nsRegion;
class nsIPrivateDOMEvent : public nsISupports
{
@ -110,7 +111,11 @@ NS_NewDOMMessageEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresCont
nsresult
NS_NewDOMProgressEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsEvent* aEvent);
nsresult
NS_NewDOMNotifyPaintEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsNotifyPaintEvent* aEvent);
NS_NewDOMNotifyPaintEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext,
nsEvent* aEvent,
PRUint32 aEventType = 0,
const nsRegion* aSameOriginRegion = nsnull,
const nsRegion* aCrossDocRegion = nsnull);
nsresult
NS_NewDOMSimpleGestureEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsSimpleGestureEvent* aEvent);
#endif // nsIPrivateDOMEvent_h__

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

@ -532,6 +532,8 @@ nsDOMEvent::SetEventType(const nsAString& aEventTypeArg)
else if (atom == nsGkAtoms::oncompositionend)
mEvent->message = NS_COMPOSITION_END;
} else if (mEvent->eventStructType == NS_EVENT) {
if (atom == nsGkAtoms::onMozAfterPaint)
mEvent->message = NS_AFTERPAINT;
if (atom == nsGkAtoms::onfocus)
mEvent->message = NS_FOCUS_CONTENT;
else if (atom == nsGkAtoms::onblur)
@ -665,10 +667,6 @@ nsDOMEvent::SetEventType(const nsAString& aEventTypeArg)
mEvent->message = NS_MEDIA_ERROR;
}
#endif // MOZ_MEDIA
else if (mEvent->eventStructType == NS_NOTIFYPAINT_EVENT) {
if (atom == nsGkAtoms::onMozAfterPaint)
mEvent->message = NS_AFTERPAINT;
}
else if (mEvent->eventStructType == NS_SIMPLE_GESTURE_EVENT) {
if (atom == nsGkAtoms::onMozSwipeGesture)
mEvent->message = NS_SIMPLE_GESTURE_SWIPE;
@ -990,14 +988,6 @@ NS_METHOD nsDOMEvent::DuplicatePrivateData()
static_cast<nsXULCommandEvent*>(mEvent)->sourceEvent;
break;
}
case NS_NOTIFYPAINT_EVENT:
{
nsNotifyPaintEvent* event = static_cast<nsNotifyPaintEvent*>(mEvent);
newEvent =
new nsNotifyPaintEvent(PR_FALSE, msg,
event->sameDocRegion, event->crossDocRegion);
break;
}
case NS_SIMPLE_GESTURE_EVENT:
{
nsSimpleGestureEvent* oldSimpleGestureEvent = static_cast<nsSimpleGestureEvent*>(mEvent);

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

@ -41,27 +41,20 @@
#include "nsClientRect.h"
nsDOMNotifyPaintEvent::nsDOMNotifyPaintEvent(nsPresContext* aPresContext,
nsNotifyPaintEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent ? aEvent :
new nsNotifyPaintEvent(PR_FALSE, 0, nsRegion(), nsRegion()))
{
if (aEvent) {
mEventIsInternal = PR_FALSE;
}
else
{
mEventIsInternal = PR_TRUE;
mEvent->time = PR_Now();
}
}
nsDOMNotifyPaintEvent::~nsDOMNotifyPaintEvent()
nsEvent* aEvent,
PRUint32 aEventType,
const nsRegion* aSameDocRegion,
const nsRegion* aCrossDocRegion)
: nsDOMEvent(aPresContext, aEvent)
{
if (mEventIsInternal) {
if (mEvent->eventStructType == NS_NOTIFYPAINT_EVENT) {
delete static_cast<nsNotifyPaintEvent*>(mEvent);
mEvent = nsnull;
}
if (mEvent) {
mEvent->message = aEventType;
}
if (aSameDocRegion) {
mSameDocRegion = *aSameDocRegion;
}
if (aCrossDocRegion) {
mCrossDocRegion = *aCrossDocRegion;
}
}
@ -76,13 +69,11 @@ NS_IMPL_RELEASE_INHERITED(nsDOMNotifyPaintEvent, nsDOMEvent)
nsRegion
nsDOMNotifyPaintEvent::GetRegion()
{
nsNotifyPaintEvent* event = static_cast<nsNotifyPaintEvent*>(mEvent);
nsRegion r;
if (nsContentUtils::IsCallerTrustedForRead()) {
r.Or(event->sameDocRegion, event->crossDocRegion);
r.Or(mSameDocRegion, mCrossDocRegion);
} else {
r = event->sameDocRegion;
r = mSameDocRegion;
}
return r;
}
@ -127,10 +118,14 @@ nsDOMNotifyPaintEvent::GetClientRects(nsIDOMClientRectList** aResult)
nsresult NS_NewDOMNotifyPaintEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsNotifyPaintEvent *aEvent)
nsEvent *aEvent,
PRUint32 aEventType,
const nsRegion* aSameOriginRegion,
const nsRegion* aCrossDocRegion)
{
nsDOMNotifyPaintEvent* it =
new nsDOMNotifyPaintEvent(aPresContext, aEvent);
new nsDOMNotifyPaintEvent(aPresContext, aEvent, aEventType,
aSameOriginRegion, aCrossDocRegion);
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}

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

@ -46,9 +46,11 @@ class nsDOMNotifyPaintEvent : public nsIDOMNotifyPaintEvent,
public nsDOMEvent
{
public:
nsDOMNotifyPaintEvent(nsPresContext* aPresContext,
nsNotifyPaintEvent* aEvent);
virtual ~nsDOMNotifyPaintEvent();
nsDOMNotifyPaintEvent(nsPresContext* aPresContext,
nsEvent* aEvent,
PRUint32 aEventType,
const nsRegion* aSameOriginRegion,
const nsRegion* aCrossDocRegion);
NS_DECL_ISUPPORTS_INHERITED
@ -59,6 +61,9 @@ public:
private:
nsRegion GetRegion();
nsRegion mSameDocRegion;
nsRegion mCrossDocRegion;
};
#endif // nsDOMNotifyPaintEvent_h_

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

@ -668,10 +668,6 @@ nsEventDispatcher::CreateEvent(nsPresContext* aPresContext,
case NS_COMMAND_EVENT:
return NS_NewDOMCommandEvent(aDOMEvent, aPresContext,
static_cast<nsCommandEvent*>(aEvent));
case NS_NOTIFYPAINT_EVENT:
return NS_NewDOMNotifyPaintEvent(aDOMEvent, aPresContext,
static_cast<nsNotifyPaintEvent*>
(aEvent));
case NS_SIMPLE_GESTURE_EVENT:
return NS_NewDOMSimpleGestureEvent(aDOMEvent, aPresContext,
static_cast<nsSimpleGestureEvent*>(aEvent));

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

@ -91,6 +91,8 @@
#include "nsStyleStructInlines.h"
#include "nsIAppShell.h"
#include "prenv.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIDOMEventTarget.h"
#ifdef MOZ_SMIL
#include "nsSMILAnimationController.h"
@ -1932,26 +1934,31 @@ nsPresContext::UserFontSetUpdated()
void
nsPresContext::FireDOMPaintEvent()
{
nsCOMPtr<nsPIDOMWindow> ourWindow = mDocument->GetWindow();
nsPIDOMWindow* ourWindow = mDocument->GetWindow();
if (!ourWindow)
return;
nsISupports* eventTarget = ourWindow;
nsCOMPtr<nsIDOMEventTarget> dispatchTarget = do_QueryInterface(ourWindow);
nsCOMPtr<nsIDOMEventTarget> eventTarget = dispatchTarget;
if (mSameDocDirtyRegion.IsEmpty() && !IsChrome()) {
// Don't tell the window about this event, it should not know that
// something happened in a subdocument. Tell only the chrome event handler.
// (Events sent to the window get propagated to the chrome event handler
// automatically.)
eventTarget = ourWindow->GetChromeEventHandler();
if (!eventTarget) {
dispatchTarget = do_QueryInterface(ourWindow->GetChromeEventHandler());
if (!dispatchTarget) {
return;
}
}
// Events sent to the window get propagated to the chrome event handler
// automatically.
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMNotifyPaintEvent(getter_AddRefs(event), this, nsnull,
NS_AFTERPAINT,
&mSameDocDirtyRegion, &mCrossDocDirtyRegion);
nsCOMPtr<nsIPrivateDOMEvent> pEvent = do_QueryInterface(event);
if (!pEvent) return;
nsNotifyPaintEvent event(PR_TRUE, NS_AFTERPAINT, mSameDocDirtyRegion,
mCrossDocDirtyRegion);
// Empty our regions now in case dispatching the event causes more damage
// (hopefully it won't, or we're likely to get an infinite loop! At least
// it won't be blocking app execution though).
@ -1960,8 +1967,9 @@ nsPresContext::FireDOMPaintEvent()
// Even if we're not telling the window about the event (so eventTarget is
// the chrome event handler, not the window), the window is still
// logically the event target.
event.target = do_QueryInterface(ourWindow);
nsEventDispatcher::Dispatch(eventTarget, this, &event);
pEvent->SetTarget(eventTarget);
pEvent->SetTrusted(PR_TRUE);
nsEventDispatcher::DispatchDOMEvent(dispatchTarget, nsnull, event, this, nsnull);
}
static PRBool MayHavePaintEventListener(nsPIDOMWindow* aInnerWindow)

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

@ -1220,23 +1220,6 @@ public:
PRInt32 detail;
};
/**
* NotifyPaint event
*/
class nsNotifyPaintEvent : public nsEvent
{
public:
nsNotifyPaintEvent(PRBool isTrusted, PRUint32 msg,
const nsRegion& aSameDocRegion, const nsRegion& aCrossDocRegion)
: nsEvent(isTrusted, msg, NS_NOTIFYPAINT_EVENT),
sameDocRegion(aSameDocRegion), crossDocRegion(aCrossDocRegion)
{
}
nsRegion sameDocRegion;
nsRegion crossDocRegion;
};
/**
* PageTransition event
*/