From 6ea82397a3c1e17e092902ef4e2a21dfcb6fd919 Mon Sep 17 00:00:00 2001
From: "vidur%netscape.com"
Date: Thu, 10 Sep 1998 17:11:46 +0000
Subject: [PATCH] Fixes to get Rotate.html working
git-svn-id: svn://10.0.0.236/trunk@9732 18797224-902f-48f8-a5cc-f745e15eee43
---
.../html/content/src/nsGenericHTMLElement.cpp | 4 ++-
.../html/content/src/nsGenericDOMDataNode.cpp | 18 ++++++----
.../html/content/src/nsGenericHTMLElement.cpp | 4 ++-
mozilla/layout/html/tests/Rotate.html | 36 +++++++++++++++++++
4 files changed, 54 insertions(+), 8 deletions(-)
diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
index bb76f1eb8b2..fe359611c75 100644
--- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
@@ -692,6 +692,7 @@ nsGenericHTMLElement::GetScriptObjectFactory(nsIDOMScriptObjectFactory **aResult
}
*aResult = gScriptObjectFactory;
+ NS_ADDREF(gScriptObjectFactory);
return result;
}
@@ -1046,7 +1047,7 @@ nsGenericHTMLElement::SetDocument(nsIDocument* aDocument)
// Once the element is added to the doc tree we need to check if
// event handler were registered on it. Unfortunately, this means
// doing a GetAttribute for every type of handler.
- if (nsnull != mAttributes) {
+ if ((nsnull != mDocument) && (nsnull != mAttributes)) {
nsHTMLValue val;
if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onclick, val))
AddScriptEventListener(nsHTMLAtoms::onclick, val, kIDOMMouseListenerIID);
@@ -1803,6 +1804,7 @@ nsGenericHTMLElement::GetScriptObject(nsIScriptContext* aContext,
mTag->ToString(tag);
res = factory->NewScriptElement(tag, aContext, mContent,
mParent, (void**)&mScriptObject);
+ NS_RELEASE(factory);
}
*aScriptObject = mScriptObject;
return res;
diff --git a/mozilla/layout/html/content/src/nsGenericDOMDataNode.cpp b/mozilla/layout/html/content/src/nsGenericDOMDataNode.cpp
index 1524ea8a0dd..2baac2eaca0 100644
--- a/mozilla/layout/html/content/src/nsGenericDOMDataNode.cpp
+++ b/mozilla/layout/html/content/src/nsGenericDOMDataNode.cpp
@@ -17,6 +17,7 @@
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "nsGenericDOMDataNode.h"
+#include "nsGenericHTMLElement.h"
#include "nsIEventListenerManager.h"
#include "nsIDocument.h"
#include "nsXIFConverter.h"
@@ -27,6 +28,7 @@
#include "nsIPrivateDOMEvent.h"
#include "nsISizeOfHandler.h"
#include "nsDOMEvent.h"
+#include "nsIDOMScriptObjectFactory.h"
// XXX share all id's in this dir
@@ -399,15 +401,19 @@ nsGenericDOMDataNode::GetScriptObject(nsIScriptContext* aContext,
void** aScriptObject)
{
nsresult res = NS_OK;
-#if XXX
if (nsnull == mScriptObject) {
- nsIDOMElement* ele = nsnull;
- mContent->QueryInterface(kIDOMElementIID, (void**) &ele);
- res = NS_NewScriptElement(aContext, ele, mParent, (void**)&mScriptObject);
- NS_RELEASE(ele);
+ nsIDOMScriptObjectFactory *factory;
+
+ res = nsGenericHTMLElement::GetScriptObjectFactory(&factory);
+ if (NS_OK != res) {
+ return res;
+ }
+
+ res = factory->NewScriptData(nsIDOMNode::TEXT, aContext, mContent,
+ mParent, (void**)&mScriptObject);
+ NS_RELEASE(factory);
}
*aScriptObject = mScriptObject;
-#endif
return res;
}
diff --git a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp
index bb76f1eb8b2..fe359611c75 100644
--- a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp
+++ b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp
@@ -692,6 +692,7 @@ nsGenericHTMLElement::GetScriptObjectFactory(nsIDOMScriptObjectFactory **aResult
}
*aResult = gScriptObjectFactory;
+ NS_ADDREF(gScriptObjectFactory);
return result;
}
@@ -1046,7 +1047,7 @@ nsGenericHTMLElement::SetDocument(nsIDocument* aDocument)
// Once the element is added to the doc tree we need to check if
// event handler were registered on it. Unfortunately, this means
// doing a GetAttribute for every type of handler.
- if (nsnull != mAttributes) {
+ if ((nsnull != mDocument) && (nsnull != mAttributes)) {
nsHTMLValue val;
if (NS_CONTENT_ATTR_HAS_VALUE == mAttributes->GetAttribute(nsHTMLAtoms::onclick, val))
AddScriptEventListener(nsHTMLAtoms::onclick, val, kIDOMMouseListenerIID);
@@ -1803,6 +1804,7 @@ nsGenericHTMLElement::GetScriptObject(nsIScriptContext* aContext,
mTag->ToString(tag);
res = factory->NewScriptElement(tag, aContext, mContent,
mParent, (void**)&mScriptObject);
+ NS_RELEASE(factory);
}
*aScriptObject = mScriptObject;
return res;
diff --git a/mozilla/layout/html/tests/Rotate.html b/mozilla/layout/html/tests/Rotate.html
index 164492127bf..3cbd9c26983 100644
--- a/mozilla/layout/html/tests/Rotate.html
+++ b/mozilla/layout/html/tests/Rotate.html
@@ -24,5 +24,41 @@ And now a lot more text. And now a lot more text. And now a lot more text.
And now a lot more text. And now a lot more text. And now a lot more text.
And now a lot more text. And now a lot more text. And now a lot more text.
+