diff --git a/teavm-classlib/src/test/java/org/teavm/classlib/java/util/HashtableTest.java b/teavm-classlib/src/test/java/org/teavm/classlib/java/util/HashtableTest.java index 95a5581bb..569df25cd 100644 --- a/teavm-classlib/src/test/java/org/teavm/classlib/java/util/HashtableTest.java +++ b/teavm-classlib/src/test/java/org/teavm/classlib/java/util/HashtableTest.java @@ -157,7 +157,9 @@ public class HashtableTest { String okey, ckey; while (org.hasMoreElements()) { - assertTrue("Key comparison failed", (okey = org.nextElement()).equals(ckey = cpy.nextElement())); + okey = org.nextElement(); + ckey = cpy.nextElement(); + assertTrue("Key comparison failed", okey.equals(ckey)); assertTrue("Value comparison failed", (htfull.get(okey)).equals(h.get(ckey))); } assertTrue("Copy has more keys than original", !cpy.hasMoreElements()); diff --git a/teavm-dom/src/main/java/org/teavm/dom/browser/Window.java b/teavm-dom/src/main/java/org/teavm/dom/browser/Window.java index 3ee4f5a48..7793a0dc5 100644 --- a/teavm-dom/src/main/java/org/teavm/dom/browser/Window.java +++ b/teavm-dom/src/main/java/org/teavm/dom/browser/Window.java @@ -15,7 +15,7 @@ */ package org.teavm.dom.browser; -import org.teavm.dom.core.Document; +import org.teavm.dom.html.HTMLDocument; import org.teavm.jso.JSGlobal; import org.teavm.jso.JSObject; import org.teavm.jso.JSProperty; @@ -26,7 +26,7 @@ import org.teavm.jso.JSProperty; */ public interface Window extends JSGlobal { @JSProperty - Document getDocument(); + HTMLDocument getDocument(); void alert(JSObject message); diff --git a/teavm-dom/src/main/java/org/teavm/dom/core/Element.java b/teavm-dom/src/main/java/org/teavm/dom/core/Element.java index f07a04ef6..d21f91f38 100644 --- a/teavm-dom/src/main/java/org/teavm/dom/core/Element.java +++ b/teavm-dom/src/main/java/org/teavm/dom/core/Element.java @@ -34,7 +34,7 @@ public interface Element extends Node { Attr removeAttributeNode(Attr oldAttr); - NodeList getElementsByTagName(String name); + NodeList getElementsByTagName(String name); String getAttributeNS(String namespaceURI, String localName); @@ -46,7 +46,7 @@ public interface Element extends Node { Attr setAttributeNodeNS(Attr newAttr); - NodeList getElementsByTagNameNS(String namespaceURI, String localName); + NodeList getElementsByTagNameNS(String namespaceURI, String localName); boolean hasAttribute(String name); diff --git a/teavm-dom/src/main/java/org/teavm/dom/core/NamedNodeMap.java b/teavm-dom/src/main/java/org/teavm/dom/core/NamedNodeMap.java index b893cfa82..394127fa9 100644 --- a/teavm-dom/src/main/java/org/teavm/dom/core/NamedNodeMap.java +++ b/teavm-dom/src/main/java/org/teavm/dom/core/NamedNodeMap.java @@ -15,7 +15,7 @@ */ package org.teavm.dom.core; -import org.teavm.jso.JSArray; +import org.teavm.jso.JSArrayReader; import org.teavm.jso.JSObject; import org.teavm.jso.JSProperty; @@ -23,7 +23,7 @@ import org.teavm.jso.JSProperty; * * @author Alexey Andreev */ -public interface NamedNodeMap extends JSObject, JSArray { +public interface NamedNodeMap extends JSObject, JSArrayReader { T getNamedItem(String name); T setNamedItem(T arg); diff --git a/teavm-dom/src/main/java/org/teavm/dom/core/NodeList.java b/teavm-dom/src/main/java/org/teavm/dom/core/NodeList.java index 3f0ca46e5..f3a9fff6b 100644 --- a/teavm-dom/src/main/java/org/teavm/dom/core/NodeList.java +++ b/teavm-dom/src/main/java/org/teavm/dom/core/NodeList.java @@ -15,14 +15,14 @@ */ package org.teavm.dom.core; -import org.teavm.jso.JSArray; +import org.teavm.jso.JSArrayReader; import org.teavm.jso.JSProperty; /** * * @author Alexey Andreev */ -public interface NodeList extends JSArray { +public interface NodeList extends JSArrayReader { T item(int index); @Override diff --git a/teavm-dom/src/main/java/org/teavm/dom/css/CSSStyleDeclaration.java b/teavm-dom/src/main/java/org/teavm/dom/css/CSSStyleDeclaration.java new file mode 100644 index 000000000..a96a1b257 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/css/CSSStyleDeclaration.java @@ -0,0 +1,52 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.dom.css; + +import org.teavm.jso.JSIndexer; +import org.teavm.jso.JSObject; +import org.teavm.jso.JSProperty; + +/** + * + * @author Alexey Andreev + */ +public interface CSSStyleDeclaration extends JSObject { + @JSProperty + String getCssText(); + + @JSProperty + void setCssText(String cssText); + + @JSProperty + int getLength(); + + @JSIndexer + String item(int index); + + String getPropertyValue(String property); + + String getPropertyPriority(String property); + + void setProperty(String property, String value); + + void setProperty(String property, String value, String priority); + + void setPropertyValue(String property, String value); + + void setPropertyPriority(String property, String priority); + + String removeProperty(String property); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/css/ElementCSSInlineStyle.java b/teavm-dom/src/main/java/org/teavm/dom/css/ElementCSSInlineStyle.java new file mode 100644 index 000000000..67ad3387a --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/css/ElementCSSInlineStyle.java @@ -0,0 +1,28 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.dom.css; + +import org.teavm.jso.JSObject; +import org.teavm.jso.JSProperty; + +/** + * + * @author Alexey Andreev + */ +public interface ElementCSSInlineStyle extends JSObject { + @JSProperty + CSSStyleDeclaration getStyle(); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLBaseElement.java b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLBaseElement.java new file mode 100644 index 000000000..d24e47c19 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLBaseElement.java @@ -0,0 +1,35 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.dom.html; + +import org.teavm.jso.JSProperty; + +/** + * + * @author Alexey Andreev + */ +public interface HTMLBaseElement extends HTMLElement { + @JSProperty + String getHref(); + + @JSProperty + void setHref(String href); + + @JSProperty + String getTarget(); + + void setTarget(String target); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLDocument.java b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLDocument.java new file mode 100644 index 000000000..3f1428f99 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLDocument.java @@ -0,0 +1,35 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.dom.html; + +import org.teavm.dom.core.Document; +import org.teavm.jso.JSProperty; + +/** + * + * @author Alexey Andreev + */ +public interface HTMLDocument extends Document { + @JSProperty + @Override + HTMLHtmlElement getDocumentElement(); + + @Override + HTMLElement createElement(String tagName); + + @Override + HTMLElement getElementById(String elementId); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLElement.java b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLElement.java new file mode 100644 index 000000000..99b313a5a --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLElement.java @@ -0,0 +1,83 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.dom.html; + +import org.teavm.dom.core.Element; +import org.teavm.dom.core.NodeList; +import org.teavm.dom.css.ElementCSSInlineStyle; +import org.teavm.dom.events.EventTarget; +import org.teavm.jso.JSProperty; + +/** + * + * @author Alexey Andreev + */ +public interface HTMLElement extends Element, ElementCSSInlineStyle, EventTarget { + @Override + @JSProperty + NodeList getElementsByTagName(String name); + + @JSProperty + String getTitle(); + + @JSProperty + void setTitle(String title); + + @JSProperty + String getLang(); + + @JSProperty + void setLang(String lang); + + @JSProperty + boolean isTranslate(); + + @JSProperty + void setTranslate(boolean translate); + + @JSProperty + String getDir(); + + @JSProperty + void setDir(String dir); + + @JSProperty + boolean isHidden(); + + @JSProperty + void setHidden(boolean hidden); + + void click(); + + @JSProperty + int getTabIndex(); + + @JSProperty + void setTabIndex(int tabIndex); + + void focus(); + + void blur(); + + @JSProperty + String getAccessKey(); + + @JSProperty + void setAccessKey(String accessKey); + + @JSProperty + String getAccessKeyLabel(); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLHeadElement.java b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLHeadElement.java new file mode 100644 index 000000000..eca363d46 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLHeadElement.java @@ -0,0 +1,23 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.dom.html; + +/** + * + * @author Alexey Andreev + */ +public interface HTMLHeadElement extends HTMLElement { +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLHtmlElement.java b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLHtmlElement.java new file mode 100644 index 000000000..2a2b9ce27 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLHtmlElement.java @@ -0,0 +1,23 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.dom.html; + +/** + * + * @author Alexey Andreev + */ +public interface HTMLHtmlElement extends HTMLElement { +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLLinkElement.java b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLLinkElement.java new file mode 100644 index 000000000..d66519872 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLLinkElement.java @@ -0,0 +1,60 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.dom.html; + +import org.teavm.jso.JSProperty; + +/** + * + * @author Alexey Andreev + */ +public interface HTMLLinkElement extends HTMLElement { + @JSProperty + String getHref(); + + @JSProperty + void setHref(String href); + + @JSProperty + String getCrossOrigin(); + + @JSProperty + void setCrossOrigin(String crossOrigin); + + @JSProperty + String getRel(); + + @JSProperty + void setRel(String rel); + + @JSProperty + String getMedia(); + + @JSProperty + void setMedia(String media); + + @JSProperty + String getHreflang(); + + @JSProperty + void setHreflang(String hreflang); + + @JSProperty + String getType(); + + @JSProperty + void setType(String property); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLMetaElement.java b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLMetaElement.java new file mode 100644 index 000000000..0e5db9032 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLMetaElement.java @@ -0,0 +1,42 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.dom.html; + +import org.teavm.jso.JSProperty; + +/** + * + * @author Alexey Andreev + */ +public interface HTMLMetaElement extends HTMLElement { + @JSProperty + String getName(); + + @JSProperty + void setName(String name); + + @JSProperty + String getHttpEquiv(); + + @JSProperty + void setHttpEquiv(String httpEquiv); + + @JSProperty + String getContent(); + + @JSProperty + void setContent(String content); +} diff --git a/teavm-dom/src/main/java/org/teavm/dom/html/HTMLTitleElement.java b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLTitleElement.java new file mode 100644 index 000000000..945a4a0f8 --- /dev/null +++ b/teavm-dom/src/main/java/org/teavm/dom/html/HTMLTitleElement.java @@ -0,0 +1,30 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.dom.html; + +import org.teavm.jso.JSProperty; + +/** + * + * @author Alexey Andreev + */ +public interface HTMLTitleElement extends HTMLElement { + @JSProperty + String getText(); + + @JSProperty + void setText(String text); +} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSArray.java b/teavm-jso/src/main/java/org/teavm/jso/JSArray.java index 882867210..44049df4d 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/JSArray.java +++ b/teavm-jso/src/main/java/org/teavm/jso/JSArray.java @@ -19,15 +19,59 @@ package org.teavm.jso; * * @author Alexey Andreev */ -public interface JSArray extends JSObject { - @JSProperty - int getLength(); - - @JSIndexer - T get(int index); - +public interface JSArray extends JSArrayReader { @JSIndexer void set(int index, T value); - - void push(T value); + + int push(T a); + + int push(T a, T b); + + int push(T a, T b, T c); + + int push(T a, T b, T c, T d); + + T shift(); + + String join(String separator); + + String join(); + + JSArray concat(JSArray a); + + JSArray concat(JSArray a, JSArray b); + + JSArray concat(JSArray a, JSArray b, JSArray c); + + JSArray concat(JSArray a, JSArray b, JSArray c, JSArray d); + + T pop(); + + int unshift(T a); + + int unshift(T a, T b); + + int unshift(T a, T b, T c); + + int unshift(T a, T b, T c, T d); + + JSArray slice(int start); + + JSArray slice(int start, int end); + + JSArray reverse(); + + JSArray sort(JSSortFunction function); + + JSArray sort(); + + JSArray splice(int start, int count); + + JSArray splice(int start, int count, T a); + + JSArray splice(int start, int count, T a, T b); + + JSArray splice(int start, int count, T a, T b, T c); + + JSArray splice(int start, int count, T a, T b, T c, T d); } diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSArrayReader.java b/teavm-jso/src/main/java/org/teavm/jso/JSArrayReader.java new file mode 100644 index 000000000..f5291774d --- /dev/null +++ b/teavm-jso/src/main/java/org/teavm/jso/JSArrayReader.java @@ -0,0 +1,28 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.jso; + +/** + * + * @author Alexey Andreev + */ +public interface JSArrayReader extends JSObject { + @JSProperty + int getLength(); + + @JSIndexer + T get(int index); +} diff --git a/teavm-jso/src/main/java/org/teavm/jso/JSSortFunction.java b/teavm-jso/src/main/java/org/teavm/jso/JSSortFunction.java new file mode 100644 index 000000000..fd6891aaf --- /dev/null +++ b/teavm-jso/src/main/java/org/teavm/jso/JSSortFunction.java @@ -0,0 +1,25 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.jso; + +/** + * + * @author Alexey Andreev + */ +@JSFunctor +public interface JSSortFunction { + int compare(T a, T b); +}