Skip to content

Commit

Permalink
WIP: getting ready for using trunk for html5parser. This is used in e…
Browse files Browse the repository at this point in the history
…nv-js yet
  • Loading branch information
client9 committed Apr 9, 2010
1 parent 9dc1dff commit 5710074
Showing 1 changed file with 38 additions and 44 deletions.
Expand Up @@ -2,22 +2,22 @@
* Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2008-2009 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/

Expand Down Expand Up @@ -63,7 +63,7 @@ public ScriptHolder(JavaScriptObject script,

/**
* Returns the script.
*
*
* @return the script
*/
public JavaScriptObject getScript() {
Expand All @@ -72,7 +72,7 @@ public JavaScriptObject getScript() {

/**
* Returns the placeholder.
*
*
* @return the placeholder
*/
public JavaScriptObject getPlaceholder() {
Expand All @@ -98,7 +98,7 @@ private static native boolean installExplorerCreateElementNS(
obj.setAttribute("id", "mathplayer");
obj.setAttribute("classid", "clsid:32F66A20-7614-11D4-BD11-00104BD3F987");
document.getElementsByTagName("head")[0].appendChild(obj);
document.namespaces.add("m", "http://www.w3.org/1998/Math/MathML", "#mathplayer");
document.namespaces.add("m", "http://www.w3.org/1998/Math/MathML", "#mathplayer");
doc.mathplayerinitialized = true;
}
return doc.createElement("m:" + local);
Expand All @@ -108,7 +108,7 @@ private static native boolean installExplorerCreateElementNS(
obj.setAttribute("id", "renesis");
obj.setAttribute("classid", "clsid:AC159093-1683-4BA2-9DCF-0C350141D7F2");
document.getElementsByTagName("head")[0].appendChild(obj);
document.namespaces.add("s", "http://www.w3.org/2000/svg", "#renesis");
document.namespaces.add("s", "http://www.w3.org/2000/svg", "#renesis");
doc.renesisinitialized = true;
}
return doc.createElement("s:" + local);
Expand All @@ -121,12 +121,12 @@ private static native boolean installExplorerCreateElementNS(

private static native boolean hasAttributeNS(JavaScriptObject element,
String uri, String localName) /*-{
return element.hasAttributeNS(uri, localName);
return element.hasAttributeNS(uri, localName);
}-*/;

private static native void setAttributeNS(JavaScriptObject element,
String uri, String localName, String value) /*-{
element.setAttributeNS(uri, localName, value);
element.setAttributeNS(uri, localName, value);
}-*/;

@Override protected void addAttributesToElement(JavaScriptObject element,
Expand All @@ -147,12 +147,12 @@ private static native void setAttributeNS(JavaScriptObject element,

private static native void appendChild(JavaScriptObject parent,
JavaScriptObject child) /*-{
parent.appendChild(child);
parent.appendChild(child);
}-*/;

private static native JavaScriptObject createTextNode(JavaScriptObject doc,
String text) /*-{
return doc.createTextNode(text);
return doc.createTextNode(text);
}-*/;

@Override protected void appendCharacters(JavaScriptObject parent,
Expand All @@ -169,12 +169,12 @@ private static native JavaScriptObject createTextNode(JavaScriptObject doc,
}

private static native boolean hasChildNodes(JavaScriptObject element) /*-{
return element.hasChildNodes();
return element.hasChildNodes();
}-*/;

private static native JavaScriptObject getFirstChild(
JavaScriptObject element) /*-{
return element.firstChild;
return element.firstChild;
}-*/;

@Override protected void appendChildrenToNewParent(
Expand All @@ -191,7 +191,7 @@ private static native JavaScriptObject getFirstChild(

private static native JavaScriptObject createComment(JavaScriptObject doc,
String text) /*-{
return doc.createComment(text);
return doc.createComment(text);
}-*/;

@Override protected void appendComment(JavaScriptObject parent,
Expand All @@ -217,7 +217,7 @@ private static native JavaScriptObject createComment(JavaScriptObject doc,

private static native JavaScriptObject createElementNS(
JavaScriptObject doc, String ns, String local) /*-{
return doc.createElementNS(ns, local);
return doc.createElementNS(ns, local);
}-*/;

@Override protected JavaScriptObject createElement(String ns, String name,
Expand Down Expand Up @@ -269,7 +269,7 @@ private static native JavaScriptObject createElementNS(

private static native JavaScriptObject getParentNode(
JavaScriptObject element) /*-{
return element.parentNode;
return element.parentNode;
}-*/;

@Override protected void appendElement(JavaScriptObject child,
Expand Down Expand Up @@ -304,26 +304,20 @@ private static native int getNodeType(JavaScriptObject node) /*-{
}-*/;

private static native JavaScriptObject cloneNode(JavaScriptObject node) /*-{
return node.cloneNode(false);
}-*/;

@Override protected JavaScriptObject shallowClone(JavaScriptObject element)
throws SAXException {
try {
return cloneNode(element);
} catch (JavaScriptException e) {
fatal(e);
throw new RuntimeException("Unreachable");
}
}
return node.cloneNode(false);
}-*/;

protected native JavaScriptObject shallowClone(JavaScriptObject node) /*-{
return node.cloneNode(false);
}-*/;

private static native JavaScriptObject cloneNodeDeep(JavaScriptObject node) /*-{
return node.cloneNode(true);
}-*/;

/**
* Returns the document.
*
*
* @return the document
*/
JavaScriptObject getDocument() {
Expand All @@ -334,7 +328,7 @@ JavaScriptObject getDocument() {

private static native JavaScriptObject createDocumentFragment(
JavaScriptObject doc) /*-{
return doc.createDocumentFragment();
return doc.createDocumentFragment();
}-*/;

JavaScriptObject getDocumentFragment() {
Expand Down Expand Up @@ -393,16 +387,16 @@ protected void documentMode(DocumentMode mode, String publicIdentifier,
//the 'sax end element event'
elementPoppedNative(ns, name, node);
}

private static native void elementPoppedNative(String ns, String name,
JavaScriptObject node) /*-{
__elementPopped__(ns, name, node);
}-*/;
JavaScriptObject node) /*-{
__elementPopped__(ns, name, node);
}-*/;

private static native void replace(JavaScriptObject oldNode,
JavaScriptObject newNode) /*-{
oldNode.parentNode.replaceChild(newNode, oldNode);
__elementPopped__('', newNode.nodeName, newNode);
__elementPopped__('', newNode.nodeName, newNode);
}-*/;

void maybeRunScript() {
Expand Down

1 comment on commit 5710074

@client9
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment was wrong. this is NOT used in env-js yet.

Please sign in to comment.