mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
fixing js capitalization and finalize methods
This commit is contained in:
parent
c814fbb8a5
commit
cab1c3c057
@ -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}
|
||||
};
|
||||
|
||||
|
@ -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}
|
||||
};
|
||||
|
||||
|
@ -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}
|
||||
};
|
||||
|
||||
|
@ -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}
|
||||
};
|
||||
|
||||
|
@ -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}
|
||||
};
|
||||
|
||||
|
@ -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}
|
||||
};
|
||||
|
||||
|
@ -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}
|
||||
};
|
||||
|
||||
|
@ -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}
|
||||
};
|
||||
|
||||
|
Binary file not shown.
@ -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")
|
||||
|
||||
|
@ -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 + "</" + node.GetTagName() + ">"
|
||||
html += "\n" + indent + "</" + node.getTagName() + ">"
|
||||
}
|
||||
// if it's a piece of text just dump the text
|
||||
else if (type == Node.TEXT) {
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user