Bug 252631 - allow multiple onloads in svg content. r=sicking, sr=jst

This commit is contained in:
tor%cs.brown.edu 2005-01-26 14:28:21 +00:00
Родитель 9d36c66c37
Коммит f0305d4312
3 изменённых файлов: 15 добавлений и 25 удалений

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

@ -214,29 +214,7 @@ nsSVGElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName, nsIAtom* aPrefix,
if (aNamespaceID == kNameSpaceID_None && IsEventName(aName)) {
nsCOMPtr<nsIEventListenerManager> manager;
if (aName == nsSVGAtoms::onload) {
// If we have a document, and it has a script global, add the
// event listener on the global.
// Until we figure out how to handle multiple onloads, only
// onload on the root element (least surprise, hopefully).
// This test isn't ideal, as it's really checking for an
// empty document, which could happen with javascript DOM
// creation as well as for the root element of a document
// we're parsing. But in famous last words, this code will
// be changing soon to allow multiple onloads per document.
nsIDocument *document = GetCurrentDoc();
if (document && !document->GetRootContent()) {
nsCOMPtr<nsIDOMEventReceiver> receiver =
do_QueryInterface(document->GetScriptGlobalObject());
if (receiver) {
receiver->GetListenerManager(getter_AddRefs(manager));
}
}
}
else {
GetListenerManager(getter_AddRefs(manager));
}
GetListenerManager(getter_AddRefs(manager));
if (manager) {
manager->AddScriptEventListener(NS_STATIC_CAST(nsIContent*, this), aName,
aValue, PR_TRUE);
@ -864,6 +842,7 @@ nsSVGElement::IsGraphicElementEventName(nsIAtom* aName)
}
return (aName == nsSVGAtoms::onclick ||
aName == nsSVGAtoms::onload ||
aName == nsSVGAtoms::onmousedown ||
aName == nsSVGAtoms::onmouseup ||
aName == nsSVGAtoms::onmouseover ||

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

@ -1294,8 +1294,7 @@ nsSVGSVGElement::DidModifySVGObservable (nsISVGValue* observable,
PRBool
nsSVGSVGElement::IsEventName(nsIAtom* aName)
{
return IsGraphicElementEventName(aName) ||
aName == nsSVGAtoms::onload;
return IsGraphicElementEventName(aName);
}
//----------------------------------------------------------------------

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

@ -99,6 +99,7 @@
#ifdef MOZ_SVG
#include "nsSVGAtoms.h"
#include "nsGUIEvent.h"
#endif
#define kXSLType "text/xsl"
@ -1052,6 +1053,17 @@ nsXMLContentSink::HandleEndElement(const PRUnichar *aName)
result = NS_ERROR_HTMLPARSER_BLOCK;
}
#ifdef MOZ_SVG
if (content->GetNameSpaceID() == kNameSpaceID_SVG &&
content->HasAttr(kNameSpaceID_None, nsSVGAtoms::onload)) {
nsEventStatus status = nsEventStatus_eIgnore;
nsEvent event(NS_PAGE_LOAD);
nsIPresShell *presShell = mDocument->GetShellAt(0);
if (presShell)
presShell->HandleDOMEventWithTarget(content, &event, &status);
}
#endif
return result;
}