More support for onresize and onscroll, bug 960

This commit is contained in:
joki%netscape.com 2000-05-17 06:53:58 +00:00
parent 9f2ffd0225
commit c22fd60f54
18 changed files with 96 additions and 9 deletions

View File

@ -1667,7 +1667,8 @@ nsGenericElement::SetProperty(JSContext *aContext, JSObject *aObj, jsval aID, js
}
}
}
else if (atom.get() == nsLayoutAtoms::onpaint) {
else if (atom.get() == nsLayoutAtoms::onpaint || atom.get() == nsLayoutAtoms::onresize ||
atom.get() == nsLayoutAtoms::onscroll) {
if (NS_OK == GetListenerManager(&manager)) {
nsCOMPtr<nsIScriptContext> mScriptCX;
if (NS_FAILED(nsLayoutUtils::GetStaticScriptContext(aContext, (JSObject*)GetDOMSlots()->mScriptObject, getter_AddRefs(mScriptCX))) ||

View File

@ -49,7 +49,8 @@ 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", "resize"
"dragenter", "dragover", "dragexit", "dragdrop", "draggesture", "resize",
"scroll"
};
nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, const nsString& aEventType) {
@ -1073,6 +1074,8 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
return mEventNames[eDOMEvents_paint];
case NS_RESIZE_EVENT:
return mEventNames[eDOMEvents_resize];
case NS_SCROLL_EVENT:
return mEventNames[eDOMEvents_scroll];
case NS_TEXT_EVENT:
return mEventNames[eDOMEvents_text];
case NS_MENU_CREATE:

View File

@ -83,7 +83,8 @@ public:
eDOMEvents_dragexit,
eDOMEvents_dragdrop,
eDOMEvents_draggesture,
eDOMEvents_resize
eDOMEvents_resize,
eDOMEvents_scroll
};
nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, const nsString& aEventType);

View File

@ -421,6 +421,10 @@ nsresult nsEventListenerManager::GetIdentifiersForType(nsIAtom* aType, nsIID& aI
else if (aType == nsLayoutAtoms::onresize) {
aIID = kIDOMPaintListenerIID;
*aFlags = NS_EVENT_BITS_PAINT_RESIZE;
}
else if (aType == nsLayoutAtoms::onscroll) {
aIID = kIDOMPaintListenerIID;
*aFlags = NS_EVENT_BITS_PAINT_SCROLL;
} // extened this to handle IME related events
else if (aType == nsLayoutAtoms::oncreate) {
aIID = kIDOMMenuListenerIID;
@ -1327,6 +1331,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
case NS_PAINT:
case NS_RESIZE_EVENT:
case NS_SCROLL_EVENT:
if (nsnull != mPaintListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, empty, aEvent);
@ -1348,6 +1353,9 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
case NS_RESIZE_EVENT:
ret = paintListener->Resize(*aDOMEvent);
break;
case NS_SCROLL_EVENT:
ret = paintListener->Scroll(*aDOMEvent);
break;
default:
break;
}
@ -1369,6 +1377,12 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
correctSubType = PR_TRUE;
}
break;
case NS_SCROLL_EVENT:
subType = NS_EVENT_BITS_PAINT_SCROLL;
if (ls->mSubType & NS_EVENT_BITS_PAINT_SCROLL) {
correctSubType = PR_TRUE;
}
break;
default:
break;
}
@ -1821,6 +1835,15 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::SCROLL) {
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;
}

View File

@ -233,5 +233,6 @@ protected:
#define NS_EVENT_BITS_PAINT_NONE 0x00
#define NS_EVENT_BITS_PAINT_PAINT 0x01
#define NS_EVENT_BITS_PAINT_RESIZE 0x02
#define NS_EVENT_BITS_PAINT_SCROLL 0x04
#endif // nsEventListenerManager_h__

View File

@ -1246,7 +1246,9 @@ nsGenericHTMLElement::SetAttribute(PRInt32 aNameSpaceID,
(nsLayoutAtoms::onchange == aAttribute) ||
(nsLayoutAtoms::onselect == aAttribute))
AddScriptEventListener(aAttribute, aValue, kIDOMFormListenerIID);
else if (nsLayoutAtoms::onpaint == aAttribute)
else if (nsLayoutAtoms::onpaint == aAttribute ||
nsLayoutAtoms::onresize == aAttribute ||
nsLayoutAtoms::onscroll == aAttribute)
AddScriptEventListener(aAttribute, aValue, kIDOMPaintListenerIID);
else if (nsLayoutAtoms::oninput == aAttribute)
AddScriptEventListener(aAttribute, aValue, kIDOMFormListenerIID);

View File

@ -153,6 +153,7 @@ LAYOUT_ATOM(onmouseup, "onmouseup")
LAYOUT_ATOM(onpaint, "onpaint")
LAYOUT_ATOM(onreset, "onreset")
LAYOUT_ATOM(onresize, "onresize")
LAYOUT_ATOM(onscroll, "onscroll")
LAYOUT_ATOM(onselect, "onselect")
LAYOUT_ATOM(onsubmit, "onsubmit")
LAYOUT_ATOM(onunload, "onunload")

View File

@ -48,6 +48,13 @@ public:
* @returns whether the event was consumed or ignored. @see nsresult
*/
virtual nsresult Resize(nsIDOMEvent* aEvent) = 0;
/**
* Processes a scroll event
* @param aEvent @see nsIDOMEvent.h
* @returns whether the event was consumed or ignored. @see nsresult
*/
virtual nsresult Scroll(nsIDOMEvent* aEvent) = 0;
};
#endif /* nsIDOMPaintListener_h__ */

View File

@ -3805,6 +3805,21 @@ PRBool GlobalWindowImpl::CheckForEventListener(JSContext* aContext, nsString& aP
}
}
else if(aPropName.EqualsWithConversion("onscroll"))
{
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;
}

View File

@ -153,6 +153,7 @@ LAYOUT_ATOM(onmouseup, "onmouseup")
LAYOUT_ATOM(onpaint, "onpaint")
LAYOUT_ATOM(onreset, "onreset")
LAYOUT_ATOM(onresize, "onresize")
LAYOUT_ATOM(onscroll, "onscroll")
LAYOUT_ATOM(onselect, "onselect")
LAYOUT_ATOM(onsubmit, "onsubmit")
LAYOUT_ATOM(onunload, "onunload")

View File

@ -153,6 +153,7 @@ LAYOUT_ATOM(onmouseup, "onmouseup")
LAYOUT_ATOM(onpaint, "onpaint")
LAYOUT_ATOM(onreset, "onreset")
LAYOUT_ATOM(onresize, "onresize")
LAYOUT_ATOM(onscroll, "onscroll")
LAYOUT_ATOM(onselect, "onselect")
LAYOUT_ATOM(onsubmit, "onsubmit")
LAYOUT_ATOM(onunload, "onunload")

View File

@ -1667,7 +1667,8 @@ nsGenericElement::SetProperty(JSContext *aContext, JSObject *aObj, jsval aID, js
}
}
}
else if (atom.get() == nsLayoutAtoms::onpaint) {
else if (atom.get() == nsLayoutAtoms::onpaint || atom.get() == nsLayoutAtoms::onresize ||
atom.get() == nsLayoutAtoms::onscroll) {
if (NS_OK == GetListenerManager(&manager)) {
nsCOMPtr<nsIScriptContext> mScriptCX;
if (NS_FAILED(nsLayoutUtils::GetStaticScriptContext(aContext, (JSObject*)GetDOMSlots()->mScriptObject, getter_AddRefs(mScriptCX))) ||

View File

@ -49,7 +49,8 @@ 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", "resize"
"dragenter", "dragover", "dragexit", "dragdrop", "draggesture", "resize",
"scroll"
};
nsDOMEvent::nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, const nsString& aEventType) {
@ -1073,6 +1074,8 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
return mEventNames[eDOMEvents_paint];
case NS_RESIZE_EVENT:
return mEventNames[eDOMEvents_resize];
case NS_SCROLL_EVENT:
return mEventNames[eDOMEvents_scroll];
case NS_TEXT_EVENT:
return mEventNames[eDOMEvents_text];
case NS_MENU_CREATE:

View File

@ -83,7 +83,8 @@ public:
eDOMEvents_dragexit,
eDOMEvents_dragdrop,
eDOMEvents_draggesture,
eDOMEvents_resize
eDOMEvents_resize,
eDOMEvents_scroll
};
nsDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent, const nsString& aEventType);

View File

@ -421,6 +421,10 @@ nsresult nsEventListenerManager::GetIdentifiersForType(nsIAtom* aType, nsIID& aI
else if (aType == nsLayoutAtoms::onresize) {
aIID = kIDOMPaintListenerIID;
*aFlags = NS_EVENT_BITS_PAINT_RESIZE;
}
else if (aType == nsLayoutAtoms::onscroll) {
aIID = kIDOMPaintListenerIID;
*aFlags = NS_EVENT_BITS_PAINT_SCROLL;
} // extened this to handle IME related events
else if (aType == nsLayoutAtoms::oncreate) {
aIID = kIDOMMenuListenerIID;
@ -1327,6 +1331,7 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
case NS_PAINT:
case NS_RESIZE_EVENT:
case NS_SCROLL_EVENT:
if (nsnull != mPaintListeners) {
if (nsnull == *aDOMEvent) {
ret = NS_NewDOMUIEvent(aDOMEvent, aPresContext, empty, aEvent);
@ -1348,6 +1353,9 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
case NS_RESIZE_EVENT:
ret = paintListener->Resize(*aDOMEvent);
break;
case NS_SCROLL_EVENT:
ret = paintListener->Scroll(*aDOMEvent);
break;
default:
break;
}
@ -1369,6 +1377,12 @@ nsresult nsEventListenerManager::HandleEvent(nsIPresContext* aPresContext,
correctSubType = PR_TRUE;
}
break;
case NS_SCROLL_EVENT:
subType = NS_EVENT_BITS_PAINT_SCROLL;
if (ls->mSubType & NS_EVENT_BITS_PAINT_SCROLL) {
correctSubType = PR_TRUE;
}
break;
default:
break;
}
@ -1821,6 +1835,15 @@ nsresult nsEventListenerManager::FlipCaptureBit(PRInt32 aEventTypes, PRBool aIni
ls->mFlags |= NS_EVENT_FLAG_CAPTURE;
}
}
if (aEventTypes & nsIDOMEvent::SCROLL) {
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;
}

View File

@ -233,5 +233,6 @@ protected:
#define NS_EVENT_BITS_PAINT_NONE 0x00
#define NS_EVENT_BITS_PAINT_PAINT 0x01
#define NS_EVENT_BITS_PAINT_RESIZE 0x02
#define NS_EVENT_BITS_PAINT_SCROLL 0x04
#endif // nsEventListenerManager_h__

View File

@ -1246,7 +1246,9 @@ nsGenericHTMLElement::SetAttribute(PRInt32 aNameSpaceID,
(nsLayoutAtoms::onchange == aAttribute) ||
(nsLayoutAtoms::onselect == aAttribute))
AddScriptEventListener(aAttribute, aValue, kIDOMFormListenerIID);
else if (nsLayoutAtoms::onpaint == aAttribute)
else if (nsLayoutAtoms::onpaint == aAttribute ||
nsLayoutAtoms::onresize == aAttribute ||
nsLayoutAtoms::onscroll == aAttribute)
AddScriptEventListener(aAttribute, aValue, kIDOMPaintListenerIID);
else if (nsLayoutAtoms::oninput == aAttribute)
AddScriptEventListener(aAttribute, aValue, kIDOMFormListenerIID);

View File

@ -336,8 +336,8 @@ 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_SCROLL_EVENT (NS_WINDOW_START + 61)
#define NS_MOUSE_MESSAGE_START 300
#define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START)