Use nsINode in nsEventListenerManager::CompileEventHandlerInternal. Bug

329192, r+sr=sicking.
This commit is contained in:
bzbarsky%mit.edu 2006-05-05 22:45:56 +00:00
Родитель 19eac0bfdf
Коммит dc6c7fda01
1 изменённых файлов: 14 добавлений и 20 удалений

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

@ -699,10 +699,9 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
// Go from our target to the nearest enclosing DOM window.
nsCOMPtr<nsPIDOMWindow> window;
nsCOMPtr<nsIDocument> document;
nsCOMPtr<nsIContent> content(do_QueryInterface(mTarget));
if (content)
document = content->GetOwnerDoc();
else document = do_QueryInterface(mTarget);
nsCOMPtr<nsINode> node(do_QueryInterface(mTarget));
if (node)
document = node->GetOwnerDoc();
if (document)
window = document->GetInnerWindow();
else window = do_QueryInterface(mTarget);
@ -1205,7 +1204,7 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
nsIScriptContext *context = nsnull;
JSContext* cx = nsnull;
nsCOMPtr<nsIContent> content(do_QueryInterface(aObject));
nsCOMPtr<nsINode> node(do_QueryInterface(aObject));
nsCOMPtr<nsIDocument> doc;
@ -1213,9 +1212,9 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
JSObject *scope = nsnull;
if (content) {
if (node) {
// Try to get context from doc
doc = content->GetOwnerDoc();
doc = node->GetOwnerDoc();
nsIScriptGlobalObject *global;
if (doc && (global = doc->GetScriptGlobalObject())) {
@ -1233,15 +1232,9 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
win->GetDocument(getter_AddRefs(domdoc));
doc = do_QueryInterface(domdoc);
global = do_QueryInterface(win);
} else {
doc = do_QueryInterface(aObject);
if (doc) {
global = doc->GetScriptGlobalObject();
} else {
global = do_QueryInterface(aObject);
}
}
if (global) {
context = global->GetContext();
scope = global->GetGlobalJSObject();
@ -1331,8 +1324,10 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
}
else {
PRInt32 nameSpace = kNameSpaceID_Unknown;
if (content)
if (node && node->IsNodeOfType(nsINode::eCONTENT)) {
nsIContent* content = NS_STATIC_CAST(nsIContent*, node.get());
nameSpace = content->GetNameSpaceID();
}
else if (doc) {
nsCOMPtr<nsIContent> root = doc->GetRootContent();
if (root)
@ -1553,11 +1548,10 @@ nsEventListenerManager::CompileEventHandlerInternal(nsIScriptContext *aContext,
PRUint32 lineNo = 0;
nsCAutoString url (NS_LITERAL_CSTRING("javascript:alert('TODO: FIXME')"));
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aCurrentTarget);
if (!doc) {
nsCOMPtr<nsIContent> content = do_QueryInterface(aCurrentTarget);
if (content)
doc = content->GetOwnerDoc();
nsIDocument* doc = nsnull;
nsCOMPtr<nsINode> node = do_QueryInterface(aCurrentTarget);
if (node) {
doc = node->GetOwnerDoc();
}
if (doc) {
nsIURI *uri = doc->GetDocumentURI();