From 63354f30cf3da8474581ac54d6b26a9009b58ff9 Mon Sep 17 00:00:00 2001 From: dario Date: Fri, 17 Apr 1998 01:32:07 +0000 Subject: [PATCH] fixing js capitalization and finalize methods git-svn-id: svn://10.0.0.236/trunk@344 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/dom/src/nsJSAttribute.cpp | 21 ++++++++------- mozilla/dom/src/nsJSAttributeList.cpp | 27 ++++++++++--------- mozilla/dom/src/nsJSDocument.cpp | 35 ++++++++++++------------ mozilla/dom/src/nsJSElement.cpp | 37 +++++++++++++------------- mozilla/dom/src/nsJSNode.cpp | 37 +++++++++++++------------- mozilla/dom/src/nsJSNodeIterator.cpp | 33 ++++++++++++----------- mozilla/dom/src/nsJSText.cpp | 27 ++++++++++--------- mozilla/dom/src/nsJSWindow.cpp | 15 ++++++----- mozilla/dom/tests/js/DumpHTML.js | Bin 2024 -> 2025 bytes mozilla/dom/tests/js/DumpTree.js | 20 +++++++------- mozilla/dom/tests/js/HTMLString.js | 24 ++++++++--------- mozilla/dom/tests/js/simple.js | 34 +++++++++++------------ 12 files changed, 159 insertions(+), 151 deletions(-) diff --git a/mozilla/dom/src/nsJSAttribute.cpp b/mozilla/dom/src/nsJSAttribute.cpp index 913d1596370..91c66d00920 100644 --- a/mozilla/dom/src/nsJSAttribute.cpp +++ b/mozilla/dom/src/nsJSAttribute.cpp @@ -124,16 +124,17 @@ PR_STATIC_CALLBACK(void) FinalizeAttribute(JSContext *cx, JSObject *obj) { nsIDOMAttribute *attribute = (nsIDOMAttribute*)JS_GetPrivate(cx, obj); - NS_ASSERTION(nsnull != attribute, "null pointer"); + + if (nsnull != attribute) { + // get the js object + nsIScriptObjectOwner *owner = nsnull; + if (NS_OK == attribute->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + owner->ResetScriptObject(); + NS_RELEASE(owner); + } - // get the js object - nsIScriptObjectOwner *owner = nsnull; - if (NS_OK == attribute->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { - owner->ResetScriptObject(); - NS_RELEASE(owner); + attribute->Release(); } - - attribute->Release(); } /***********************************************************************/ @@ -197,8 +198,8 @@ static JSPropertySpec attributeProperties[] = // Attribute class methods // static JSFunctionSpec attributeMethods[] = { - {"GetName", GetName, 0}, - {"ToString", ToString, 0}, + {"getName", GetName, 0}, + {"toString", ToString, 0}, {0} }; diff --git a/mozilla/dom/src/nsJSAttributeList.cpp b/mozilla/dom/src/nsJSAttributeList.cpp index 7d13b94e095..b6700756fb6 100644 --- a/mozilla/dom/src/nsJSAttributeList.cpp +++ b/mozilla/dom/src/nsJSAttributeList.cpp @@ -80,16 +80,17 @@ PR_STATIC_CALLBACK(void) FinalizeAttributeList(JSContext *cx, JSObject *obj) { nsIDOMAttributeList *attributeList = (nsIDOMAttributeList*)JS_GetPrivate(cx, obj); - NS_ASSERTION(nsnull != attributeList, "null pointer"); - // get the js object - nsIScriptObjectOwner *owner = nsnull; - if (NS_OK == attributeList->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { - owner->ResetScriptObject(); - NS_RELEASE(owner); + if (nsnull != attributeList) { + // get the js object + nsIScriptObjectOwner *owner = nsnull; + if (NS_OK == attributeList->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + owner->ResetScriptObject(); + NS_RELEASE(owner); + } + + attributeList->Release(); } - - attributeList->Release(); } /***********************************************************************/ @@ -275,11 +276,11 @@ JSClass attributeList = { // AttributeList class methods // static JSFunctionSpec attributeListMethods[] = { - {"GetAttribute", GetAttribute, 1}, - {"SetAttribute", SetAttribute, 1}, - {"Remove", Remove, 1}, - {"Item", Item, 1}, - {"GetLength", GetLength, 0}, + {"getAttribute", GetAttribute, 1}, + {"setAttribute", SetAttribute, 1}, + {"remove", Remove, 1}, + {"item", Item, 1}, + {"getLength", GetLength, 0}, {0} }; diff --git a/mozilla/dom/src/nsJSDocument.cpp b/mozilla/dom/src/nsJSDocument.cpp index 62c36682dad..5be61500087 100644 --- a/mozilla/dom/src/nsJSDocument.cpp +++ b/mozilla/dom/src/nsJSDocument.cpp @@ -138,16 +138,17 @@ PR_STATIC_CALLBACK(void) FinalizeDocument(JSContext *cx, JSObject *obj) { nsIDOMDocument *document = (nsIDOMDocument*)JS_GetPrivate(cx, obj); - NS_ASSERTION(nsnull != document, "null pointer"); + + if (nsnull != document) { + // get the js object + nsIScriptObjectOwner *owner = nsnull; + if (NS_OK == document->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + owner->ResetScriptObject(); + NS_RELEASE(owner); + } - // get the js object - nsIScriptObjectOwner *owner = nsnull; - if (NS_OK == document->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { - owner->ResetScriptObject(); - NS_RELEASE(owner); + document->Release(); } - - document->Release(); } /***********************************************************************/ @@ -249,15 +250,15 @@ static JSPropertySpec documentProperties[] = // Document class methods // static JSFunctionSpec documentMethods[] = { - {"CreateDocumentContext", CreateDocumentContext, 0}, - {"CreateElement", CreateElement, 2}, - {"CreateTextNode", CreateTextNode, 1}, - {"CreateComment", CreateComment, 1}, - {"CreatePI", CreatePI, 2}, - {"CreateAttribute", CreateAttribute, 2}, - {"CreateAttributeList", CreateAttributeList, 0}, - {"CreateTreeIterator", CreateTreeIterator, 1}, - {"GetElementsByTagName", GetElementsByTagName, 0}, + {"createDocumentContext", CreateDocumentContext, 0}, + {"createElement", CreateElement, 2}, + {"createTextNode", CreateTextNode, 1}, + {"createComment", CreateComment, 1}, + {"createPI", CreatePI, 2}, + {"createAttribute", CreateAttribute, 2}, + {"createAttributeList", CreateAttributeList, 0}, + {"createTreeIterator", CreateTreeIterator, 1}, + {"getElementsByTagName", GetElementsByTagName, 0}, {0} }; diff --git a/mozilla/dom/src/nsJSElement.cpp b/mozilla/dom/src/nsJSElement.cpp index 8ac3f89575f..63aa3f45578 100644 --- a/mozilla/dom/src/nsJSElement.cpp +++ b/mozilla/dom/src/nsJSElement.cpp @@ -82,16 +82,17 @@ PR_STATIC_CALLBACK(void) FinalizeElement(JSContext *cx, JSObject *obj) { nsIDOMElement *element = (nsIDOMElement*)JS_GetPrivate(cx, obj); - NS_ASSERTION(nsnull != element, "null pointer"); + + if (nsnull != element) { + // get the js object + nsIScriptObjectOwner *owner = nsnull; + if (NS_OK == element->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + owner->ResetScriptObject(); + NS_RELEASE(owner); + } - // get the js object - nsIScriptObjectOwner *owner = nsnull; - if (NS_OK == element->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { - owner->ResetScriptObject(); - NS_RELEASE(owner); + element->Release(); } - - element->Release(); } /***********************************************************************/ @@ -373,16 +374,16 @@ JSClass element = { // Element class methods // static JSFunctionSpec elementMethods[] = { - {"GetTagName", GetTagName, 0}, - {"GetAttributes", GetAttributes, 0}, - {"GetAttribute", GetAttribute, 1}, - {"SetAttribute", SetAttribute, 2}, - {"RemoveAttribute", RemoveAttribute, 1}, - {"GetAttributeNode", GetAttributeNode, 1}, - {"SetAttributeNode", SetAttributeNode, 1}, - {"RemoveAttributeNode", RemoveAttributeNode, 1}, - {"GetElementsByTagName", GetElementsByTagName, 1}, - {"Normalize", Normalize, 0}, + {"getTagName", GetTagName, 0}, + {"getAttributes", GetAttributes, 0}, + {"getAttribute", GetAttribute, 1}, + {"setAttribute", SetAttribute, 2}, + {"removeAttribute", RemoveAttribute, 1}, + {"getAttributeNode", GetAttributeNode, 1}, + {"setAttributeNode", SetAttributeNode, 1}, + {"removeAttributeNode", RemoveAttributeNode, 1}, + {"getElementsByTagName", GetElementsByTagName, 1}, + {"normalize", Normalize, 0}, {0} }; diff --git a/mozilla/dom/src/nsJSNode.cpp b/mozilla/dom/src/nsJSNode.cpp index d5fa68ecdf3..97e0f6d9c2b 100644 --- a/mozilla/dom/src/nsJSNode.cpp +++ b/mozilla/dom/src/nsJSNode.cpp @@ -80,16 +80,17 @@ PR_STATIC_CALLBACK(void) FinalizeNode(JSContext *cx, JSObject *obj) { nsIDOMNode *node = (nsIDOMNode*)JS_GetPrivate(cx, obj); - NS_ASSERTION(nsnull != node, "null pointer"); + + if (nsnull != node) { + // get the js object + nsIScriptObjectOwner *owner = nsnull; + if (NS_OK == node->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + owner->ResetScriptObject(); + NS_RELEASE(owner); + } - // get the js object - nsIScriptObjectOwner *owner = nsnull; - if (NS_OK == node->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { - owner->ResetScriptObject(); - NS_RELEASE(owner); + node->Release(); } - - node->Release(); } /***********************************************************************/ @@ -418,16 +419,16 @@ JSClass node = { // Node class methods // static JSFunctionSpec nodeMethods[] = { - {"GetNodeType", GetNodeType, 0}, - {"GetParentNode", GetParentNode, 0}, - {"GetChildNodes", GetChildNodes, 0}, - {"HasChildNodes", HasChildNodes, 0}, - {"GetFirstChild", GetFirstChild, 0}, - {"GetPreviousSibling", GetPreviousSibling, 0}, - {"GetNextSibling", GetNextSibling, 0}, - {"InsertBefore", InsertBefore, 2}, - {"ReplaceChild", ReplaceChild, 2}, - {"RemoveChild", RemoveChild, 1}, + {"getNodeType", GetNodeType, 0}, + {"getParentNode", GetParentNode, 0}, + {"getChildNodes", GetChildNodes, 0}, + {"hasChildNodes", HasChildNodes, 0}, + {"getFirstChild", GetFirstChild, 0}, + {"getPreviousSibling", GetPreviousSibling, 0}, + {"getNextSibling", GetNextSibling, 0}, + {"insertBefore", InsertBefore, 2}, + {"replaceChild", ReplaceChild, 2}, + {"removeChild", RemoveChild, 1}, {0} }; diff --git a/mozilla/dom/src/nsJSNodeIterator.cpp b/mozilla/dom/src/nsJSNodeIterator.cpp index 4c57db843d4..54e4b020150 100644 --- a/mozilla/dom/src/nsJSNodeIterator.cpp +++ b/mozilla/dom/src/nsJSNodeIterator.cpp @@ -80,16 +80,17 @@ PR_STATIC_CALLBACK(void) FinalizeNodeIterator(JSContext *cx, JSObject *obj) { nsIDOMNodeIterator *nodeIterator = (nsIDOMNodeIterator*)JS_GetPrivate(cx, obj); - NS_ASSERTION(nsnull != nodeIterator, "null pointer"); + + if (nsnull != nodeIterator) { + // get the js object + nsIScriptObjectOwner *owner = nsnull; + if (NS_OK == nodeIterator->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + owner->ResetScriptObject(); + NS_RELEASE(owner); + } - // get the js object - nsIScriptObjectOwner *owner = nsnull; - if (NS_OK == nodeIterator->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { - owner->ResetScriptObject(); - NS_RELEASE(owner); + nodeIterator->Release(); } - - nodeIterator->Release(); } /***********************************************************************/ @@ -315,14 +316,14 @@ JSClass nodeIterator = { // NodeIterator class methods // static JSFunctionSpec nodeIteratorMethods[] = { - {"SetFilter", SetFilter, 2}, - {"GetLength", GetLength, 0}, - {"GetCurrentNode", GetCurrentNode, 0}, - {"GetNextNode", GetNextNode, 0}, - {"GetPreviousNode", GetPreviousNode, 0}, - {"ToFirst", ToFirst, 0}, - {"ToLast", ToLast, 0}, - {"MoveTo", MoveTo, 1}, + {"setFilter", SetFilter, 2}, + {"getLength", GetLength, 0}, + {"getCurrentNode", GetCurrentNode, 0}, + {"getNextNode", GetNextNode, 0}, + {"getPreviousNode", GetPreviousNode, 0}, + {"toFirst", ToFirst, 0}, + {"toLast", ToLast, 0}, + {"moveTo", MoveTo, 1}, {0} }; diff --git a/mozilla/dom/src/nsJSText.cpp b/mozilla/dom/src/nsJSText.cpp index e2f6f0ed025..e3ad7f4c3d0 100644 --- a/mozilla/dom/src/nsJSText.cpp +++ b/mozilla/dom/src/nsJSText.cpp @@ -108,16 +108,17 @@ PR_STATIC_CALLBACK(void) FinalizeText(JSContext *cx, JSObject *obj) { nsIDOMText *text = (nsIDOMText*)JS_GetPrivate(cx, obj); - NS_ASSERTION(nsnull != text, "null pointer"); - // get the js object - nsIScriptObjectOwner *owner = nsnull; - if (NS_OK == text->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { - owner->ResetScriptObject(); - NS_RELEASE(owner); - } + if (nsnull != text) { + // get the js object + nsIScriptObjectOwner *owner = nsnull; + if (NS_OK == text->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + owner->ResetScriptObject(); + NS_RELEASE(owner); + } - text->Release(); + text->Release(); + } } /***********************************************************************/ @@ -215,11 +216,11 @@ static JSPropertySpec textProperties[] = // Text class methods // static JSFunctionSpec textMethods[] = { - {"Append", Append, 1}, - {"Insert", Insert, 2}, - {"Delete", Delete, 2}, - {"Replace", Replace, 3}, - {"Splice", Splice, 3}, + {"append", Append, 1}, + {"insert", Insert, 2}, + {"delete", Delete, 2}, + {"replace", Replace, 3}, + {"splice", Splice, 3}, {0} }; diff --git a/mozilla/dom/src/nsJSWindow.cpp b/mozilla/dom/src/nsJSWindow.cpp index e429f4b47f3..28c7cb4449c 100644 --- a/mozilla/dom/src/nsJSWindow.cpp +++ b/mozilla/dom/src/nsJSWindow.cpp @@ -120,13 +120,14 @@ PR_STATIC_CALLBACK(void) FinalizeWindow(JSContext *cx, JSObject *obj) { nsIWebWidget *window = (nsIWebWidget*)JS_GetPrivate(cx, obj); - NS_ASSERTION(nsnull != window, "null pointer"); - // get the js object - nsIScriptObjectOwner *owner = nsnull; - if (NS_OK == window->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { - owner->ResetScriptObject(); - NS_RELEASE(owner); + if (nsnull != window) { + // get the js object + nsIScriptObjectOwner *owner = nsnull; + if (NS_OK == window->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + owner->ResetScriptObject(); + NS_RELEASE(owner); + } } } @@ -181,7 +182,7 @@ static JSPropertySpec windowProperties[] = // Window class methods // static JSFunctionSpec windowMethods[] = { - {"Dump", Dump, 1}, + {"dump", Dump, 1}, {0} }; diff --git a/mozilla/dom/tests/js/DumpHTML.js b/mozilla/dom/tests/js/DumpHTML.js index 7f8276e33da206123bfa58fbb4dbc5444fbcea22..a2aedf9fcbf5b01d61d2041e6a4b0e51e7f877eb 100644 GIT binary patch delta 142 zcmaFC|B`=05Hn-?~mbSeyhPY860g6H7|;N+wINW;3QtZeev{%$R(VH3+CdhRqPHO$SI;vvq<=$;t28 ZSSKs9Hv-izWjE)A7!#AHq{*eg002l$DpLRe delta 141 zcmaFK|AK!*5Hq9uZeev{^q72-H3+CdhRqPHO$SI;vvq<=$;t28 YSSKs9Hv-izWjE)67!#AHq{*cK0FeMFQUCw| diff --git a/mozilla/dom/tests/js/DumpTree.js b/mozilla/dom/tests/js/DumpTree.js index cd2d5bb3426..ef43f2dac58 100644 --- a/mozilla/dom/tests/js/DumpTree.js +++ b/mozilla/dom/tests/js/DumpTree.js @@ -22,37 +22,37 @@ // function traverse(node, indent) { - Dump("\n") + dump("\n") indent += " " - var type = node.GetNodeType() + var type = node.getNodeType() // if it's an element dump the tag and recurse the children if (type == Node.ELEMENT) { - Dump(indent + node.GetTagName()) + dump(indent + node.getTagName()) // go through the children - if (node.HasChildNodes()) { - var children = node.GetChildNodes() - var length = children.GetLength() - var child = children.GetNextNode() + if (node.hasChildNodes()) { + var children = node.getChildNodes() + var length = children.getLength() + var child = children.getNextNode() var count = 0; while(count < length) { traverse(child, indent) - child = children.GetNextNode() + child = children.getNextNode() count++ } } } // it's just text, no tag, dump "Text" else if (type == Node.TEXT) { - Dump(indent + "Text") + dump(indent + "Text") } } var node = document.documentElement traverse(node, "") -Dump("\n") +dump("\n") \ No newline at end of file diff --git a/mozilla/dom/tests/js/HTMLString.js b/mozilla/dom/tests/js/HTMLString.js index 949e1de4266..0b4475f5848 100644 --- a/mozilla/dom/tests/js/HTMLString.js +++ b/mozilla/dom/tests/js/HTMLString.js @@ -25,22 +25,22 @@ function htmlString(node, indent) var html = "" indent += " " - var type = node.GetNodeType() + var type = node.getNodeType() if (type == Node.ELEMENT) { // open tag - html += "\n" + indent + "<" + node.GetTagName() + html += "\n" + indent + "<" + node.getTagName() // dump the attributes if any - attributes = node.GetAttributes() + attributes = node.getAttributes() if (null != attributes) { html += " " - var countAttrs = attributes.GetLength() + var countAttrs = attributes.getLength() var index = 0 while(index < countAttrs) { - att = attributes.Item(index) + att = attributes.item(index) if (null != att) { - html += att.ToString() + html += att.toString() } index++ } @@ -50,21 +50,21 @@ function htmlString(node, indent) html += ">" // recursively dump the children - if (node.HasChildNodes()) { + if (node.hasChildNodes()) { // get the children - var children = node.GetChildNodes() - var length = children.GetLength() - var child = children.GetNextNode() + var children = node.getChildNodes() + var length = children.getLength() + var child = children.getNextNode() var count = 0; while(count < length) { html += htmlString(child, indent) - child = children.GetNextNode() + child = children.getNextNode() count++ } } // close tag - html += "\n" + indent + "" + html += "\n" + indent + "" } // if it's a piece of text just dump the text else if (type == Node.TEXT) { diff --git a/mozilla/dom/tests/js/simple.js b/mozilla/dom/tests/js/simple.js index 0dfe2f2097c..e3994e79379 100644 --- a/mozilla/dom/tests/js/simple.js +++ b/mozilla/dom/tests/js/simple.js @@ -18,39 +18,39 @@ var node = document.documentElement -node.GetNodeType() +node.getNodeType() -node.GetTagName() +node.getTagName() -var attrList = node.GetAttributes() +var attrList = node.getAttributes() -attrList.GetLength() +attrList.getLength() -var attr = attrList.Item(0) +var attr = attrList.item(0) -attr.GetName() +attr.getName() attr.value -attr.ToString() +attr.toString() -node.HasChildNodes() +node.hasChildNodes() -var children = node.GetChildNodes() +var children = node.getChildNodes() -children.GetLength() +children.getLength() -node = children.GetNextNode() -node.GetNodeType() +node = children.getNextNode() +node.getNodeType() -node.GetTagName() +node.getTagName() -children.ToFirst() +children.toFirst() -node = node.GetFirstChild() +node = node.getFirstChild() -node = node.GetNextSiblings() +node = node.getNextSiblings() -node = node.GetParentNode() +node = node.getParentNode() \ No newline at end of file