зеркало из https://github.com/mozilla/pjs.git
fix for resize event support, bug 960, and additional support for DOM 2 events.
This commit is contained in:
Родитель
c451085eea
Коммит
93950c7879
|
@ -2644,10 +2644,13 @@ nsresult nsDocument::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
nsresult mRet = NS_OK;
|
||||
nsIDOMEvent* mDOMEvent = nsnull;
|
||||
|
||||
nsIDOMEvent* domEvent = nsnull;
|
||||
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
aDOMEvent = &mDOMEvent;
|
||||
if (!aDOMEvent) {
|
||||
aDOMEvent = &domEvent;
|
||||
}
|
||||
aEvent->flags = aFlags;
|
||||
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
||||
}
|
||||
|
|
|
@ -753,7 +753,9 @@ nsGenericDOMDataNode::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
nsIDOMEvent* domEvent = nsnull;
|
||||
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
aDOMEvent = &domEvent;
|
||||
if (!aDOMEvent) {
|
||||
aDOMEvent = &domEvent;
|
||||
}
|
||||
aEvent->flags = aFlags;
|
||||
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
||||
|
||||
|
|
|
@ -1282,7 +1282,9 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
|
||||
nsIDOMEvent* domEvent = nsnull;
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
aDOMEvent = &domEvent;
|
||||
if (!aDOMEvent) {
|
||||
aDOMEvent = &domEvent;
|
||||
}
|
||||
aEvent->flags = aFlags;
|
||||
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget) = 0;
|
||||
NS_IMETHOD SetCurrentTarget(nsIDOMEventTarget* aTarget) = 0;
|
||||
NS_IMETHOD IsDispatchStopped(PRBool* aIsDispatchPrevented) = 0;
|
||||
NS_IMETHOD GetInternalNSEvent(nsEvent** aNSEvent) = 0;
|
||||
};
|
||||
|
||||
extern nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext* aPresContext, nsEvent *aEvent);
|
||||
|
|
|
@ -49,7 +49,7 @@ static char* mEventNames[] = {
|
|||
"focus", "blur", "load", "unload", "abort", "error",
|
||||
"submit", "reset", "change", "select", "input", "paint" ,"text",
|
||||
"create", "close", "destroy", "command", "broadcast", "commandupdate",
|
||||
"dragenter", "dragover", "dragexit", "dragdrop", "draggesture"
|
||||
"dragenter", "dragover", "dragexit", "dragdrop", "draggesture", "resize"
|
||||
};
|
||||
|
||||
nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, const nsString& aEventType) {
|
||||
|
@ -1005,6 +1005,13 @@ nsDOMEvent::IsDispatchStopped(PRBool* aIsDispatchStopped)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetInternalNSEvent(nsEvent** aNSEvent)
|
||||
{
|
||||
*aNSEvent = mEvent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
||||
{
|
||||
switch(aEventType) {
|
||||
|
@ -1064,6 +1071,8 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
|||
return mEventNames[eDOMEvents_input];
|
||||
case NS_PAINT:
|
||||
return mEventNames[eDOMEvents_paint];
|
||||
case NS_RESIZE_EVENT:
|
||||
return mEventNames[eDOMEvents_resize];
|
||||
case NS_TEXT_EVENT:
|
||||
return mEventNames[eDOMEvents_text];
|
||||
case NS_MENU_CREATE:
|
||||
|
|
|
@ -82,7 +82,8 @@ public:
|
|||
eDOMEvents_dragover,
|
||||
eDOMEvents_dragexit,
|
||||
eDOMEvents_dragdrop,
|
||||
eDOMEvents_draggesture
|
||||
eDOMEvents_draggesture,
|
||||
eDOMEvents_resize
|
||||
};
|
||||
|
||||
nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, const nsString& aEventType);
|
||||
|
@ -143,6 +144,7 @@ public:
|
|||
NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget);
|
||||
NS_IMETHOD SetCurrentTarget(nsIDOMEventTarget* aCurrentTarget);
|
||||
NS_IMETHOD IsDispatchStopped(PRBool* aIsDispatchStopped);
|
||||
NS_IMETHOD GetInternalNSEvent(nsEvent** aNSEvent);
|
||||
|
||||
// nsIPrivateTextEvent interface
|
||||
NS_IMETHOD GetText(nsString& aText);
|
||||
|
|
|
@ -417,6 +417,10 @@ nsresult nsEventListenerManager::GetIdentifiersForType(nsIAtom* aType, nsIID& aI
|
|||
else if (aType == nsLayoutAtoms::onpaint) {
|
||||
aIID = kIDOMPaintListenerIID;
|
||||
*aFlags = NS_EVENT_BITS_PAINT_PAINT;
|
||||
}
|
||||
else if (aType == nsLayoutAtoms::onresize) {
|
||||
aIID = kIDOMPaintListenerIID;
|
||||
*aFlags = NS_EVENT_BITS_PAINT_RESIZE;
|
||||
} // extened this to handle IME related events
|
||||
else if (aType == nsLayoutAtoms::oncreate) {
|
||||
aIID = kIDOMMenuListenerIID;
|
||||
|
@ -1322,6 +1326,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
break;
|
||||
|
||||
case NS_PAINT:
|
||||
case NS_RESIZE_EVENT:
|
||||
if (nsnull != mPaintListeners) {
|
||||
if (nsnull == *aDOMEvent) {
|
||||
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, empty, aEvent);
|
||||
|
@ -1336,14 +1341,36 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
if (ls->mFlags & aFlags) {
|
||||
if (NS_OK == ls->mListener->QueryInterface(kIDOMPaintListenerIID,
|
||||
(void**)&paintListener)) {
|
||||
ret = paintListener->Paint(*aDOMEvent);
|
||||
switch(aEvent->message) {
|
||||
case NS_PAINT:
|
||||
ret = paintListener->Paint(*aDOMEvent);
|
||||
break;
|
||||
case NS_RESIZE_EVENT:
|
||||
ret = paintListener->Resize(*aDOMEvent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
NS_RELEASE(paintListener);
|
||||
}
|
||||
else {
|
||||
PRBool correctSubType = PR_FALSE;
|
||||
PRUint32 subType = NS_EVENT_BITS_PAINT_PAINT;
|
||||
if (ls->mSubType & NS_EVENT_BITS_PAINT_PAINT) {
|
||||
correctSubType = PR_TRUE;
|
||||
PRUint32 subType = 0;
|
||||
switch(aEvent->message) {
|
||||
case NS_PAINT:
|
||||
subType = NS_EVENT_BITS_PAINT_PAINT;
|
||||
if (ls->mSubType & NS_EVENT_BITS_PAINT_PAINT) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
case NS_RESIZE_EVENT:
|
||||
subType = NS_EVENT_BITS_PAINT_RESIZE;
|
||||
if (ls->mSubType & NS_EVENT_BITS_PAINT_RESIZE) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (correctSubType || ls->mSubType == NS_EVENT_BITS_NONE) {
|
||||
ret = HandleEventSubType(ls, *aDOMEvent, aCurrentTarget, subType, aFlags);
|
||||
|
@ -1785,6 +1812,15 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
|
|||
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
|
||||
}
|
||||
}
|
||||
if (aEventTypes & nsIDOMEvent::RESIZE) {
|
||||
iid = kIDOMPaintListenerIID;
|
||||
ls = FindJSEventListener(iid);
|
||||
if (ls) {
|
||||
if (aInitCapture) ls->mSubTypeCapture |= NS_EVENT_BITS_PAINT_RESIZE;
|
||||
else ls->mSubTypeCapture &= ~NS_EVENT_BITS_PAINT_RESIZE;
|
||||
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -232,5 +232,6 @@ protected:
|
|||
//nsIDOMPaintListener
|
||||
#define NS_EVENT_BITS_PAINT_NONE 0x00
|
||||
#define NS_EVENT_BITS_PAINT_PAINT 0x01
|
||||
#define NS_EVENT_BITS_PAINT_RESIZE 0x02
|
||||
|
||||
#endif // nsEventListenerManager_h__
|
||||
|
|
|
@ -2602,7 +2602,33 @@ void nsEventStateManager::ForceViewUpdate(nsIView* aView)
|
|||
NS_IMETHODIMP
|
||||
nsEventStateManager::DispatchNewEvent(nsISupports* aTarget, nsIDOMEvent* aEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
nsresult ret = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privEvt(do_QueryInterface(aEvent));
|
||||
if (aEvent) {
|
||||
nsEvent* innerEvent;
|
||||
privEvt->GetInternalNSEvent(&innerEvent);
|
||||
if (innerEvent) {
|
||||
nsEventStatus status;
|
||||
nsCOMPtr<nsIScriptGlobalObject> target(do_QueryInterface(aTarget));
|
||||
if (target) {
|
||||
ret = target->HandleDOMEvent(mPresContext, innerEvent, &aEvent, NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDocument> target(do_QueryInterface(aTarget));
|
||||
if (target) {
|
||||
ret = target->HandleDOMEvent(mPresContext, innerEvent, &aEvent, NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIContent> target(do_QueryInterface(aTarget));
|
||||
if (target) {
|
||||
ret = target->HandleDOMEvent(mPresContext, innerEvent, &aEvent, NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
nsresult NS_NewEventStateManager(nsIEventStateManager** aInstancePtrResult)
|
||||
|
|
|
@ -152,6 +152,7 @@ LAYOUT_ATOM(onmouseout, "onmouseout")
|
|||
LAYOUT_ATOM(onmouseup, "onmouseup")
|
||||
LAYOUT_ATOM(onpaint, "onpaint")
|
||||
LAYOUT_ATOM(onreset, "onreset")
|
||||
LAYOUT_ATOM(onresize, "onresize")
|
||||
LAYOUT_ATOM(onselect, "onselect")
|
||||
LAYOUT_ATOM(onsubmit, "onsubmit")
|
||||
LAYOUT_ATOM(onunload, "onunload")
|
||||
|
|
|
@ -41,6 +41,13 @@ public:
|
|||
* @returns whether the event was consumed or ignored. @see nsresult
|
||||
*/
|
||||
virtual nsresult Paint(nsIDOMEvent* aEvent) = 0;
|
||||
|
||||
/**
|
||||
* Processes a resize event
|
||||
* @param aEvent @see nsIDOMEvent.h
|
||||
* @returns whether the event was consumed or ignored. @see nsresult
|
||||
*/
|
||||
virtual nsresult Resize(nsIDOMEvent* aEvent) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIDOMPaintListener_h__ */
|
||||
|
|
|
@ -379,7 +379,9 @@ NS_IMETHODIMP GlobalWindowImpl::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
|
||||
if(NS_EVENT_FLAG_INIT & aFlags)
|
||||
{
|
||||
aDOMEvent = &domEvent;
|
||||
if (!aDOMEvent) {
|
||||
aDOMEvent = &domEvent;
|
||||
}
|
||||
aEvent->flags = aFlags;
|
||||
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
||||
}
|
||||
|
@ -3773,6 +3775,21 @@ PRBool GlobalWindowImpl::CheckForEventListener(JSContext* aContext, nsString& aP
|
|||
}
|
||||
}
|
||||
|
||||
else if(aPropName.EqualsWithConversion("onresize"))
|
||||
{
|
||||
if(NS_OK == GetListenerManager(getter_AddRefs(manager)))
|
||||
{
|
||||
nsCOMPtr<nsIScriptContext> scriptCX;
|
||||
nsJSUtils::nsGetDynamicScriptContext(aContext, getter_AddRefs(scriptCX));
|
||||
if(!scriptCX ||
|
||||
NS_OK != manager->RegisterScriptEventListener(scriptCX, this, atom,
|
||||
NS_GET_IID(nsIDOMPaintListener)))
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,13 @@ GetEventProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
PRUint64 prop;
|
||||
rv = a->GetTimeStamp(&prop);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
//*vp = INT_TO_JSVAL(prop);
|
||||
#ifdef HAVE_LONG_LONG
|
||||
*vp = INT_TO_JSVAL(prop);
|
||||
#else
|
||||
int i;
|
||||
LL_L2UI(i, prop);
|
||||
*vp = INT_TO_JSVAL(i);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -713,6 +713,15 @@ static const char kStringGetCaseStr[] =
|
|||
static const char kIntGetCaseStr[] =
|
||||
" *vp = INT_TO_JSVAL(prop);\n";
|
||||
|
||||
static const char kLongLongGetCaseStr[] =
|
||||
"#ifdef HAVE_LONG_LONG\n"
|
||||
" *vp = INT_TO_JSVAL(prop);\n"
|
||||
"#else\n"
|
||||
" int i;\n"
|
||||
" LL_L2UI(i, prop);\n"
|
||||
" *vp = INT_TO_JSVAL(i);\n"
|
||||
"#endif\n";
|
||||
|
||||
static const char kFloatGetCaseStr[] =
|
||||
" *vp = DOUBLE_TO_JSVAL(JS_NewDouble(cx, prop));\n";
|
||||
|
||||
|
@ -744,16 +753,18 @@ JSStubGen::GeneratePropGetter(ofstream *file,
|
|||
case_str = kBoolGetCaseStr;
|
||||
break;
|
||||
case TYPE_LONG:
|
||||
case TYPE_LONG_LONG:
|
||||
case TYPE_SHORT:
|
||||
case TYPE_ULONG:
|
||||
case TYPE_ULONG_LONG:
|
||||
case TYPE_USHORT:
|
||||
case TYPE_CHAR:
|
||||
case TYPE_INT:
|
||||
case TYPE_UINT:
|
||||
case_str = kIntGetCaseStr;
|
||||
break;
|
||||
case TYPE_LONG_LONG:
|
||||
case TYPE_ULONG_LONG:
|
||||
case_str = kLongLongGetCaseStr;
|
||||
break;
|
||||
case TYPE_FLOAT:
|
||||
case_str = kFloatGetCaseStr;
|
||||
break;
|
||||
|
|
|
@ -152,6 +152,7 @@ LAYOUT_ATOM(onmouseout, "onmouseout")
|
|||
LAYOUT_ATOM(onmouseup, "onmouseup")
|
||||
LAYOUT_ATOM(onpaint, "onpaint")
|
||||
LAYOUT_ATOM(onreset, "onreset")
|
||||
LAYOUT_ATOM(onresize, "onresize")
|
||||
LAYOUT_ATOM(onselect, "onselect")
|
||||
LAYOUT_ATOM(onsubmit, "onsubmit")
|
||||
LAYOUT_ATOM(onunload, "onunload")
|
||||
|
|
|
@ -1781,6 +1781,17 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
|||
|
||||
mViewManager->CacheWidgetChanges(PR_FALSE);
|
||||
|
||||
//Send resize event from here.
|
||||
nsEvent event;
|
||||
nsEventStatus status;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_RESIZE_EVENT;
|
||||
event.time = 0;
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj;
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj));
|
||||
globalObj->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
||||
|
||||
return NS_OK; //XXX this needs to be real. MMP
|
||||
}
|
||||
|
||||
|
|
|
@ -152,6 +152,7 @@ LAYOUT_ATOM(onmouseout, "onmouseout")
|
|||
LAYOUT_ATOM(onmouseup, "onmouseup")
|
||||
LAYOUT_ATOM(onpaint, "onpaint")
|
||||
LAYOUT_ATOM(onreset, "onreset")
|
||||
LAYOUT_ATOM(onresize, "onresize")
|
||||
LAYOUT_ATOM(onselect, "onselect")
|
||||
LAYOUT_ATOM(onsubmit, "onsubmit")
|
||||
LAYOUT_ATOM(onunload, "onunload")
|
||||
|
|
|
@ -2644,10 +2644,13 @@ nsresult nsDocument::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
nsresult mRet = NS_OK;
|
||||
nsIDOMEvent* mDOMEvent = nsnull;
|
||||
|
||||
nsIDOMEvent* domEvent = nsnull;
|
||||
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
aDOMEvent = &mDOMEvent;
|
||||
if (!aDOMEvent) {
|
||||
aDOMEvent = &domEvent;
|
||||
}
|
||||
aEvent->flags = aFlags;
|
||||
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
||||
}
|
||||
|
|
|
@ -753,7 +753,9 @@ nsGenericDOMDataNode::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
nsIDOMEvent* domEvent = nsnull;
|
||||
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
aDOMEvent = &domEvent;
|
||||
if (!aDOMEvent) {
|
||||
aDOMEvent = &domEvent;
|
||||
}
|
||||
aEvent->flags = aFlags;
|
||||
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
||||
|
||||
|
|
|
@ -1282,7 +1282,9 @@ nsGenericElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
|
||||
nsIDOMEvent* domEvent = nsnull;
|
||||
if (NS_EVENT_FLAG_INIT & aFlags) {
|
||||
aDOMEvent = &domEvent;
|
||||
if (!aDOMEvent) {
|
||||
aDOMEvent = &domEvent;
|
||||
}
|
||||
aEvent->flags = aFlags;
|
||||
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget) = 0;
|
||||
NS_IMETHOD SetCurrentTarget(nsIDOMEventTarget* aTarget) = 0;
|
||||
NS_IMETHOD IsDispatchStopped(PRBool* aIsDispatchPrevented) = 0;
|
||||
NS_IMETHOD GetInternalNSEvent(nsEvent** aNSEvent) = 0;
|
||||
};
|
||||
|
||||
extern nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult, nsIPresContext* aPresContext, nsEvent *aEvent);
|
||||
|
|
|
@ -49,7 +49,7 @@ static char* mEventNames[] = {
|
|||
"focus", "blur", "load", "unload", "abort", "error",
|
||||
"submit", "reset", "change", "select", "input", "paint" ,"text",
|
||||
"create", "close", "destroy", "command", "broadcast", "commandupdate",
|
||||
"dragenter", "dragover", "dragexit", "dragdrop", "draggesture"
|
||||
"dragenter", "dragover", "dragexit", "dragdrop", "draggesture", "resize"
|
||||
};
|
||||
|
||||
nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, const nsString& aEventType) {
|
||||
|
@ -1005,6 +1005,13 @@ nsDOMEvent::IsDispatchStopped(PRBool* aIsDispatchStopped)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMEvent::GetInternalNSEvent(nsEvent** aNSEvent)
|
||||
{
|
||||
*aNSEvent = mEvent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
||||
{
|
||||
switch(aEventType) {
|
||||
|
@ -1064,6 +1071,8 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
|||
return mEventNames[eDOMEvents_input];
|
||||
case NS_PAINT:
|
||||
return mEventNames[eDOMEvents_paint];
|
||||
case NS_RESIZE_EVENT:
|
||||
return mEventNames[eDOMEvents_resize];
|
||||
case NS_TEXT_EVENT:
|
||||
return mEventNames[eDOMEvents_text];
|
||||
case NS_MENU_CREATE:
|
||||
|
|
|
@ -82,7 +82,8 @@ public:
|
|||
eDOMEvents_dragover,
|
||||
eDOMEvents_dragexit,
|
||||
eDOMEvents_dragdrop,
|
||||
eDOMEvents_draggesture
|
||||
eDOMEvents_draggesture,
|
||||
eDOMEvents_resize
|
||||
};
|
||||
|
||||
nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, const nsString& aEventType);
|
||||
|
@ -143,6 +144,7 @@ public:
|
|||
NS_IMETHOD SetTarget(nsIDOMEventTarget* aTarget);
|
||||
NS_IMETHOD SetCurrentTarget(nsIDOMEventTarget* aCurrentTarget);
|
||||
NS_IMETHOD IsDispatchStopped(PRBool* aIsDispatchStopped);
|
||||
NS_IMETHOD GetInternalNSEvent(nsEvent** aNSEvent);
|
||||
|
||||
// nsIPrivateTextEvent interface
|
||||
NS_IMETHOD GetText(nsString& aText);
|
||||
|
|
|
@ -417,6 +417,10 @@ nsresult nsEventListenerManager::GetIdentifiersForType(nsIAtom* aType, nsIID& aI
|
|||
else if (aType == nsLayoutAtoms::onpaint) {
|
||||
aIID = kIDOMPaintListenerIID;
|
||||
*aFlags = NS_EVENT_BITS_PAINT_PAINT;
|
||||
}
|
||||
else if (aType == nsLayoutAtoms::onresize) {
|
||||
aIID = kIDOMPaintListenerIID;
|
||||
*aFlags = NS_EVENT_BITS_PAINT_RESIZE;
|
||||
} // extened this to handle IME related events
|
||||
else if (aType == nsLayoutAtoms::oncreate) {
|
||||
aIID = kIDOMMenuListenerIID;
|
||||
|
@ -1322,6 +1326,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
break;
|
||||
|
||||
case NS_PAINT:
|
||||
case NS_RESIZE_EVENT:
|
||||
if (nsnull != mPaintListeners) {
|
||||
if (nsnull == *aDOMEvent) {
|
||||
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, empty, aEvent);
|
||||
|
@ -1336,14 +1341,36 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
|
|||
if (ls->mFlags & aFlags) {
|
||||
if (NS_OK == ls->mListener->QueryInterface(kIDOMPaintListenerIID,
|
||||
(void**)&paintListener)) {
|
||||
ret = paintListener->Paint(*aDOMEvent);
|
||||
switch(aEvent->message) {
|
||||
case NS_PAINT:
|
||||
ret = paintListener->Paint(*aDOMEvent);
|
||||
break;
|
||||
case NS_RESIZE_EVENT:
|
||||
ret = paintListener->Resize(*aDOMEvent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
NS_RELEASE(paintListener);
|
||||
}
|
||||
else {
|
||||
PRBool correctSubType = PR_FALSE;
|
||||
PRUint32 subType = NS_EVENT_BITS_PAINT_PAINT;
|
||||
if (ls->mSubType & NS_EVENT_BITS_PAINT_PAINT) {
|
||||
correctSubType = PR_TRUE;
|
||||
PRUint32 subType = 0;
|
||||
switch(aEvent->message) {
|
||||
case NS_PAINT:
|
||||
subType = NS_EVENT_BITS_PAINT_PAINT;
|
||||
if (ls->mSubType & NS_EVENT_BITS_PAINT_PAINT) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
case NS_RESIZE_EVENT:
|
||||
subType = NS_EVENT_BITS_PAINT_RESIZE;
|
||||
if (ls->mSubType & NS_EVENT_BITS_PAINT_RESIZE) {
|
||||
correctSubType = PR_TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (correctSubType || ls->mSubType == NS_EVENT_BITS_NONE) {
|
||||
ret = HandleEventSubType(ls, *aDOMEvent, aCurrentTarget, subType, aFlags);
|
||||
|
@ -1785,6 +1812,15 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
|
|||
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
|
||||
}
|
||||
}
|
||||
if (aEventTypes & nsIDOMEvent::RESIZE) {
|
||||
iid = kIDOMPaintListenerIID;
|
||||
ls = FindJSEventListener(iid);
|
||||
if (ls) {
|
||||
if (aInitCapture) ls->mSubTypeCapture |= NS_EVENT_BITS_PAINT_RESIZE;
|
||||
else ls->mSubTypeCapture &= ~NS_EVENT_BITS_PAINT_RESIZE;
|
||||
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -232,5 +232,6 @@ protected:
|
|||
//nsIDOMPaintListener
|
||||
#define NS_EVENT_BITS_PAINT_NONE 0x00
|
||||
#define NS_EVENT_BITS_PAINT_PAINT 0x01
|
||||
#define NS_EVENT_BITS_PAINT_RESIZE 0x02
|
||||
|
||||
#endif // nsEventListenerManager_h__
|
||||
|
|
|
@ -2602,7 +2602,33 @@ void nsEventStateManager::ForceViewUpdate(nsIView* aView)
|
|||
NS_IMETHODIMP
|
||||
nsEventStateManager::DispatchNewEvent(nsISupports* aTarget, nsIDOMEvent* aEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
nsresult ret = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privEvt(do_QueryInterface(aEvent));
|
||||
if (aEvent) {
|
||||
nsEvent* innerEvent;
|
||||
privEvt->GetInternalNSEvent(&innerEvent);
|
||||
if (innerEvent) {
|
||||
nsEventStatus status;
|
||||
nsCOMPtr<nsIScriptGlobalObject> target(do_QueryInterface(aTarget));
|
||||
if (target) {
|
||||
ret = target->HandleDOMEvent(mPresContext, innerEvent, &aEvent, NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDocument> target(do_QueryInterface(aTarget));
|
||||
if (target) {
|
||||
ret = target->HandleDOMEvent(mPresContext, innerEvent, &aEvent, NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIContent> target(do_QueryInterface(aTarget));
|
||||
if (target) {
|
||||
ret = target->HandleDOMEvent(mPresContext, innerEvent, &aEvent, NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
nsresult NS_NewEventStateManager(nsIEventStateManager** aInstancePtrResult)
|
||||
|
|
|
@ -1781,6 +1781,17 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
|||
|
||||
mViewManager->CacheWidgetChanges(PR_FALSE);
|
||||
|
||||
//Send resize event from here.
|
||||
nsEvent event;
|
||||
nsEventStatus status;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_RESIZE_EVENT;
|
||||
event.time = 0;
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj;
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj));
|
||||
globalObj->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
||||
|
||||
return NS_OK; //XXX this needs to be real. MMP
|
||||
}
|
||||
|
||||
|
|
|
@ -336,6 +336,9 @@ enum nsDragDropEventStatus {
|
|||
// Indicates a script error has occurred
|
||||
#define NS_SCRIPT_ERROR (NS_WINDOW_START + 50)
|
||||
|
||||
// Indicates a script error has occurred
|
||||
#define NS_RESIZE_EVENT (NS_WINDOW_START + 60)
|
||||
|
||||
#define NS_MOUSE_MESSAGE_START 300
|
||||
#define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START)
|
||||
#define NS_MOUSE_LEFT_BUTTON_UP (NS_MOUSE_MESSAGE_START + 1)
|
||||
|
|
Загрузка…
Ссылка в новой задаче