jso apis: turn DOM interfaces into abstract classes

This would make it possible to test HTMLElement for particular type with instanceof
This commit is contained in:
Alexey Andreev 2024-04-12 13:00:05 +02:00
parent 6a09f181c7
commit 272f55b383
27 changed files with 424 additions and 442 deletions

View File

@ -17,6 +17,8 @@ package org.teavm.jso.crypto;
import org.teavm.jso.JSBody; import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject; import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
import org.teavm.jso.JSTopLevel;
import org.teavm.jso.typedarrays.Int16Array; import org.teavm.jso.typedarrays.Int16Array;
import org.teavm.jso.typedarrays.Int32Array; import org.teavm.jso.typedarrays.Int32Array;
import org.teavm.jso.typedarrays.Int8Array; import org.teavm.jso.typedarrays.Int8Array;
@ -28,7 +30,8 @@ public abstract class Crypto implements JSObject {
@JSBody(script = "return crypto != null;") @JSBody(script = "return crypto != null;")
public static native boolean isSupported(); public static native boolean isSupported();
@JSBody(script = "return crypto;") @JSProperty("crypto")
@JSTopLevel
public static native Crypto current(); public static native Crypto current();
public abstract String randomUUID(); public abstract String randomUUID();

View File

@ -18,55 +18,55 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
import org.teavm.jso.dom.types.DOMTokenList; import org.teavm.jso.dom.types.DOMTokenList;
public interface HTMLAnchorElement extends HTMLElement { public abstract class HTMLAnchorElement extends HTMLElement {
@JSProperty @JSProperty
String getHref(); public abstract String getHref();
@JSProperty @JSProperty
void setHref(String value); public abstract void setHref(String value);
@JSProperty @JSProperty
String getTarget(); public abstract String getTarget();
@JSProperty @JSProperty
void setTarget(String value); public abstract void setTarget(String value);
@JSProperty @JSProperty
String getRel(); public abstract String getRel();
@JSProperty @JSProperty
void setRel(String value); public abstract void setRel(String value);
@JSProperty @JSProperty
DOMTokenList getTokenList(); public abstract DOMTokenList getTokenList();
@JSProperty @JSProperty
String getMedia(); public abstract String getMedia();
@JSProperty @JSProperty
void setMedia(String value); public abstract void setMedia(String value);
@JSProperty @JSProperty
String getHreflang(); public abstract String getHreflang();
@JSProperty @JSProperty
void setHreflang(String value); public abstract void setHreflang(String value);
@JSProperty @JSProperty
String getType(); public abstract String getType();
@JSProperty @JSProperty
void setType(String value); public abstract void setType(String value);
@JSProperty @JSProperty
String getText(); public abstract String getText();
@JSProperty @JSProperty
void setText(String value); public abstract void setText(String value);
@JSProperty @JSProperty
String getDownload(); public abstract String getDownload();
@JSProperty @JSProperty
void setDownload(String download); public abstract void setDownload(String download);
} }

View File

@ -15,10 +15,5 @@
*/ */
package org.teavm.jso.dom.html; package org.teavm.jso.dom.html;
/** public abstract class HTMLAudioElement extends HTMLMediaElement {
*
* @author Junji Takakura
*/
public interface HTMLAudioElement extends HTMLMediaElement {
} }

View File

@ -17,15 +17,15 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
public interface HTMLBaseElement extends HTMLElement { public abstract class HTMLBaseElement extends HTMLElement {
@JSProperty @JSProperty
String getHref(); public abstract String getHref();
@JSProperty @JSProperty
void setHref(String href); public abstract void setHref(String href);
@JSProperty @JSProperty
String getTarget(); public abstract String getTarget();
void setTarget(String target); public abstract void setTarget(String target);
} }

View File

@ -19,26 +19,26 @@ import org.teavm.jso.JSProperty;
import org.teavm.jso.dom.events.Event; import org.teavm.jso.dom.events.Event;
import org.teavm.jso.dom.events.EventListener; import org.teavm.jso.dom.events.EventListener;
public interface HTMLBodyElement extends HTMLElement { public abstract class HTMLBodyElement extends HTMLElement {
@JSProperty("onbeforeunload") @JSProperty("onbeforeunload")
void setOnBeforeUnload(EventListener<Event> listener); public abstract void setOnBeforeUnload(EventListener<Event> listener);
@JSProperty("onerror") @JSProperty("onerror")
void setOnError(EventListener<Event> listener); public abstract void setOnError(EventListener<Event> listener);
@JSProperty("onload") @JSProperty("onload")
void setOnLoad(EventListener<Event> listener); public abstract void setOnLoad(EventListener<Event> listener);
@JSProperty("onmessage") @JSProperty("onmessage")
void setOnMessage(EventListener<Event> listener); public abstract void setOnMessage(EventListener<Event> listener);
@JSProperty("onoffline") @JSProperty("onoffline")
void setOnOffline(EventListener<Event> listener); public abstract void setOnOffline(EventListener<Event> listener);
@JSProperty("ononline") @JSProperty("ononline")
void setOnOnline(EventListener<Event> listener); public abstract void setOnOnline(EventListener<Event> listener);
@JSProperty("ononunload") @JSProperty("ononunload")
void setOnUnload(EventListener<Event> listener); public abstract void setOnUnload(EventListener<Event> listener);
} }

View File

@ -17,43 +17,43 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
public interface HTMLButtonElement extends HTMLElement { public abstract class HTMLButtonElement extends HTMLElement {
String TYPE_BUTTON = "button"; public static final String TYPE_BUTTON = "button";
String TYPE_RESET = "reset"; public static final String TYPE_RESET = "reset";
String TYPE_SUBMIT = "submit"; public static final String TYPE_SUBMIT = "submit";
@JSProperty @JSProperty
boolean isAutofocus(); public abstract boolean isAutofocus();
@JSProperty @JSProperty
void setAutofocus(boolean autofocus); public abstract void setAutofocus(boolean autofocus);
@JSProperty @JSProperty
boolean isDisabled(); public abstract boolean isDisabled();
@JSProperty @JSProperty
void setDisabled(boolean disabled); public abstract void setDisabled(boolean disabled);
@JSProperty @JSProperty
HTMLElement getForm(); public abstract HTMLElement getForm();
@JSProperty @JSProperty
String getName(); public abstract String getName();
@JSProperty @JSProperty
void setName(String name); public abstract void setName(String name);
@JSProperty @JSProperty
String getValue(); public abstract String getValue();
@JSProperty @JSProperty
void setValue(String value); public abstract void setValue(String value);
@JSProperty @JSProperty
String getType(); public abstract String getType();
@JSProperty @JSProperty
void setType(String type); public abstract void setType(String type);
} }

View File

@ -19,26 +19,26 @@ import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
import org.teavm.jso.canvas.CanvasImageSource; import org.teavm.jso.canvas.CanvasImageSource;
public interface HTMLCanvasElement extends HTMLElement, CanvasImageSource { public abstract class HTMLCanvasElement extends HTMLElement implements CanvasImageSource {
@JSProperty @JSProperty
int getWidth(); public abstract int getWidth();
@JSProperty @JSProperty
void setWidth(int width); public abstract void setWidth(int width);
@JSProperty @JSProperty
int getHeight(); public abstract int getHeight();
@JSProperty @JSProperty
void setHeight(int height); public abstract void setHeight(int height);
JSObject getContext(String contextId); public abstract JSObject getContext(String contextId);
JSObject getContext(String contextId, JSObject attributes); public abstract JSObject getContext(String contextId, JSObject attributes);
String toDataURL(String type, double quality); public abstract String toDataURL(String type, double quality);
String toDataURL(String type); public abstract String toDataURL(String type);
String toDataURL(); public abstract String toDataURL();
} }

View File

@ -22,74 +22,74 @@ import org.teavm.jso.dom.events.EventTarget;
import org.teavm.jso.dom.xml.Document; import org.teavm.jso.dom.xml.Document;
import org.teavm.jso.dom.xml.NodeList; import org.teavm.jso.dom.xml.NodeList;
public interface HTMLDocument extends Document, EventTarget { public abstract class HTMLDocument implements Document, EventTarget {
@JSProperty @JSProperty
@Override @Override
HTMLHtmlElement getDocumentElement(); public abstract HTMLHtmlElement getDocumentElement();
@Override @Override
HTMLElement createElement(String tagName); public abstract HTMLElement createElement(String tagName);
default HTMLElement createElement(String tagName, Consumer<HTMLElement> consumer) { public final HTMLElement createElement(String tagName, Consumer<HTMLElement> consumer) {
HTMLElement result = createElement(tagName); HTMLElement result = createElement(tagName);
consumer.accept(result); consumer.accept(result);
return result; return result;
} }
@Override @Override
HTMLElement getElementById(String elementId); public abstract HTMLElement getElementById(String elementId);
@JSProperty @JSProperty
HTMLBodyElement getBody(); public abstract HTMLBodyElement getBody();
@JSProperty @JSProperty
HTMLHeadElement getHead(); public abstract HTMLHeadElement getHead();
@JSProperty @JSProperty
int getScrollLeft(); public abstract int getScrollLeft();
@JSProperty @JSProperty
int getScrollTop(); public abstract int getScrollTop();
static HTMLDocument current() { public static HTMLDocument current() {
return Window.current().getDocument(); return Window.current().getDocument();
} }
@Override @Override
HTMLElement querySelector(String selectors); public abstract HTMLElement querySelector(String selectors);
@Override @Override
NodeList<? extends HTMLElement> querySelectorAll(String selectors); public abstract NodeList<? extends HTMLElement> querySelectorAll(String selectors);
@JSProperty @JSProperty
HTMLElement getActiveElement(); public abstract HTMLElement getActiveElement();
HTMLElement elementFromPoint(int x, int y); public abstract HTMLElement elementFromPoint(int x, int y);
@JSProperty @JSProperty
boolean isDesignMode(); public abstract boolean isDesignMode();
@JSProperty @JSProperty
void setDesignMode(boolean value); public abstract void setDesignMode(boolean value);
void execCommand(String commandName, boolean showDefaultUI, String valueArgument); public abstract void execCommand(String commandName, boolean showDefaultUI, String valueArgument);
void execCommand(String commandName); public abstract void execCommand(String commandName);
@JSProperty @JSProperty
String getCookie(); public abstract String getCookie();
@JSProperty @JSProperty
void setCookie(String cookie); public abstract void setCookie(String cookie);
@JSProperty @JSProperty
String getTitle(); public abstract String getTitle();
@JSProperty @JSProperty
void setTitle(String title); public abstract void setTitle(String title);
@JSProperty @JSProperty
HTMLElement getPointerLockElement(); public abstract HTMLElement getPointerLockElement();
void exitPointerLock(); public abstract void exitPointerLock();
} }

View File

@ -29,158 +29,158 @@ import org.teavm.jso.dom.xml.Element;
import org.teavm.jso.dom.xml.Node; import org.teavm.jso.dom.xml.Node;
import org.teavm.jso.dom.xml.NodeList; import org.teavm.jso.dom.xml.NodeList;
public interface HTMLElement extends Element, ElementCSSInlineStyle, EventTarget, FocusEventTarget, MouseEventTarget, public abstract class HTMLElement implements Element, ElementCSSInlineStyle, EventTarget, FocusEventTarget,
WheelEventTarget, KeyboardEventTarget, LoadEventTarget { MouseEventTarget, WheelEventTarget, KeyboardEventTarget, LoadEventTarget {
@Override @Override
NodeList<? extends HTMLElement> getElementsByTagName(String name); public abstract NodeList<? extends HTMLElement> getElementsByTagName(String name);
@JSProperty @JSProperty
String getTitle(); public abstract String getTitle();
@JSProperty @JSProperty
void setTitle(String title); public abstract void setTitle(String title);
@JSProperty @JSProperty
String getLang(); public abstract String getLang();
@JSProperty @JSProperty
void setLang(String lang); public abstract void setLang(String lang);
@JSProperty @JSProperty
boolean isTranslate(); public abstract boolean isTranslate();
@JSProperty @JSProperty
void setTranslate(boolean translate); public abstract void setTranslate(boolean translate);
@JSProperty @JSProperty
String getDir(); public abstract String getDir();
@JSProperty @JSProperty
void setDir(String dir); public abstract void setDir(String dir);
@JSProperty @JSProperty
boolean isHidden(); public abstract boolean isHidden();
@JSProperty @JSProperty
void setHidden(boolean hidden); public abstract void setHidden(boolean hidden);
void click(); public abstract void click();
@JSProperty @JSProperty
int getTabIndex(); public abstract int getTabIndex();
@JSProperty @JSProperty
void setTabIndex(int tabIndex); public abstract void setTabIndex(int tabIndex);
void focus(); public abstract void focus();
void blur(); public abstract void blur();
@JSProperty @JSProperty
String getAccessKey(); public abstract String getAccessKey();
@JSProperty @JSProperty
void setAccessKey(String accessKey); public abstract void setAccessKey(String accessKey);
@JSProperty @JSProperty
String getAccessKeyLabel(); public abstract String getAccessKeyLabel();
@JSProperty @JSProperty
int getClientWidth(); public abstract int getClientWidth();
@JSProperty @JSProperty
int getClientHeight(); public abstract int getClientHeight();
@JSProperty @JSProperty
int getAbsoluteLeft(); public abstract int getAbsoluteLeft();
@JSProperty @JSProperty
int getAbsoluteTop(); public abstract int getAbsoluteTop();
@JSProperty @JSProperty
int getScrollLeft(); public abstract int getScrollLeft();
@JSProperty @JSProperty
void setScrollLeft(int scrollLeft); public abstract void setScrollLeft(int scrollLeft);
@JSProperty @JSProperty
int getScrollTop(); public abstract int getScrollTop();
@JSProperty @JSProperty
void setScrollTop(int scrollTop); public abstract void setScrollTop(int scrollTop);
@JSProperty @JSProperty
int getScrollWidth(); public abstract int getScrollWidth();
@JSProperty @JSProperty
int getScrollHeight(); public abstract int getScrollHeight();
@JSProperty @JSProperty
int getOffsetWidth(); public abstract int getOffsetWidth();
@JSProperty @JSProperty
int getOffsetHeight(); public abstract int getOffsetHeight();
@JSProperty @JSProperty
int getOffsetTop(); public abstract int getOffsetTop();
@JSProperty @JSProperty
int getOffsetLeft(); public abstract int getOffsetLeft();
@JSProperty @JSProperty
@Override @Override
HTMLDocument getOwnerDocument(); public abstract HTMLDocument getOwnerDocument();
@JSProperty @JSProperty
HTMLCollection getChildren(); public abstract HTMLCollection getChildren();
@JSProperty @JSProperty
String getInnerHTML(); public abstract String getInnerHTML();
@JSProperty @JSProperty
void setInnerHTML(String content); public abstract void setInnerHTML(String content);
@JSProperty @JSProperty
String getInnerText(); public abstract String getInnerText();
@JSProperty @JSProperty
void setInnerText(String content); public abstract void setInnerText(String content);
TextRectangle getBoundingClientRect(); public abstract TextRectangle getBoundingClientRect();
@JSProperty @JSProperty
String getClassName(); public abstract String getClassName();
@JSProperty @JSProperty
void setClassName(String className); public abstract void setClassName(String className);
@JSProperty @JSProperty
DOMTokenList getClassList(); public abstract DOMTokenList getClassList();
default HTMLElement withAttr(String name, String value) { public final HTMLElement withAttr(String name, String value) {
setAttribute(name, value); setAttribute(name, value);
return this; return this;
} }
default HTMLElement withChild(String tagName) { public final HTMLElement withChild(String tagName) {
HTMLElement result = getOwnerDocument().createElement(tagName); HTMLElement result = getOwnerDocument().createElement(tagName);
appendChild(result); appendChild(result);
return this; return this;
} }
default HTMLElement withChild(Node node) { public final HTMLElement withChild(Node node) {
appendChild(node); appendChild(node);
return this; return this;
} }
default HTMLElement withChild(String tagName, Consumer<HTMLElement> consumer) { public final HTMLElement withChild(String tagName, Consumer<HTMLElement> consumer) {
HTMLElement result = getOwnerDocument().createElement(tagName); HTMLElement result = getOwnerDocument().createElement(tagName);
appendChild(result); appendChild(result);
consumer.accept(result); consumer.accept(result);
return this; return this;
} }
default HTMLElement clear() { public final HTMLElement clear() {
Node node = getLastChild(); Node node = getLastChild();
while (node != null) { while (node != null) {
Node prev = node.getPreviousSibling(); Node prev = node.getPreviousSibling();
@ -192,16 +192,16 @@ public interface HTMLElement extends Element, ElementCSSInlineStyle, EventTarget
return this; return this;
} }
default HTMLElement withText(String content) { public final HTMLElement withText(String content) {
clear().appendChild(getOwnerDocument().createTextNode(content)); clear().appendChild(getOwnerDocument().createTextNode(content));
return this; return this;
} }
@Override @Override
HTMLElement querySelector(String selectors); public abstract HTMLElement querySelector(String selectors);
@Override @Override
NodeList<? extends HTMLElement> querySelectorAll(String selectors); public abstract NodeList<? extends HTMLElement> querySelectorAll(String selectors);
void requestPointerLock(); public abstract void requestPointerLock();
} }

View File

@ -18,73 +18,73 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSIndexer; import org.teavm.jso.JSIndexer;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
public interface HTMLFormElement extends HTMLElement { public abstract class HTMLFormElement extends HTMLElement {
@JSProperty @JSProperty
String getAcceptCharset(); public abstract String getAcceptCharset();
@JSProperty @JSProperty
void setAcceptCharset(String value); public abstract void setAcceptCharset(String value);
@JSProperty @JSProperty
String getAction(); public abstract String getAction();
@JSProperty @JSProperty
void setAction(String value); public abstract void setAction(String value);
@JSProperty @JSProperty
String getAutocomplete(); public abstract String getAutocomplete();
@JSProperty @JSProperty
void setAutocomplete(String value); public abstract void setAutocomplete(String value);
@JSProperty @JSProperty
String getEnctype(); public abstract String getEnctype();
@JSProperty @JSProperty
void setEnctype(String enctype); public abstract void setEnctype(String enctype);
@JSProperty @JSProperty
String getEncoding(); public abstract String getEncoding();
@JSProperty @JSProperty
void setEncoding(String value); public abstract void setEncoding(String value);
@JSProperty @JSProperty
String getMethod(); public abstract String getMethod();
@JSProperty @JSProperty
void setMethod(String value); public abstract void setMethod(String value);
@JSProperty @JSProperty
String getName(); public abstract String getName();
@JSProperty @JSProperty
void setName(String name); public abstract void setName(String name);
@JSProperty @JSProperty
boolean isNoValidate(); public abstract boolean isNoValidate();
@JSProperty @JSProperty
void setNoValidate(boolean value); public abstract void setNoValidate(boolean value);
@JSProperty @JSProperty
String getTarget(); public abstract String getTarget();
@JSProperty @JSProperty
void setTarget(String value); public abstract void setTarget(String value);
@JSIndexer @JSIndexer
HTMLElement get(String name); public abstract HTMLElement get(String name);
@JSIndexer @JSIndexer
HTMLElement get(int index); public abstract HTMLElement get(int index);
@JSProperty @JSProperty
int getLength(); public abstract int getLength();
void submit(); public abstract void submit();
void reset(); public abstract void reset();
boolean checkValidity(); public abstract boolean checkValidity();
} }

View File

@ -15,5 +15,5 @@
*/ */
package org.teavm.jso.dom.html; package org.teavm.jso.dom.html;
public interface HTMLHeadElement extends HTMLElement { public abstract class HTMLHeadElement extends HTMLElement {
} }

View File

@ -15,5 +15,5 @@
*/ */
package org.teavm.jso.dom.html; package org.teavm.jso.dom.html;
public interface HTMLHtmlElement extends HTMLElement { public abstract class HTMLHtmlElement extends HTMLElement {
} }

View File

@ -18,40 +18,40 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
import org.teavm.jso.browser.Window; import org.teavm.jso.browser.Window;
public interface HTMLIFrameElement extends HTMLElement { public abstract class HTMLIFrameElement extends HTMLElement {
@JSProperty @JSProperty
HTMLDocument getContentDocument(); public abstract HTMLDocument getContentDocument();
@JSProperty @JSProperty
Window getContentWindow(); public abstract Window getContentWindow();
@JSProperty @JSProperty
String getWidth(); public abstract String getWidth();
@JSProperty @JSProperty
void setWidth(String width); public abstract void setWidth(String width);
@JSProperty @JSProperty
String getHeight(); public abstract String getHeight();
@JSProperty @JSProperty
void setHeight(String height); public abstract void setHeight(String height);
@JSProperty @JSProperty
String getName(); public abstract String getName();
@JSProperty @JSProperty
void setName(String name); public abstract void setName(String name);
@JSProperty("src") @JSProperty("src")
String getSourceAddress(); public abstract String getSourceAddress();
@JSProperty("src") @JSProperty("src")
void setSourceAddress(String src); public abstract void setSourceAddress(String src);
@JSProperty("srcdoc") @JSProperty("srcdoc")
String getSourceDocument(); public abstract String getSourceDocument();
@JSProperty("srcdoc") @JSProperty("srcdoc")
void setSourceDocument(String srcdoc); public abstract void setSourceDocument(String srcdoc);
} }

View File

@ -18,40 +18,40 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
import org.teavm.jso.canvas.CanvasImageSource; import org.teavm.jso.canvas.CanvasImageSource;
public interface HTMLImageElement extends HTMLElement, CanvasImageSource { public abstract class HTMLImageElement extends HTMLElement implements CanvasImageSource {
@JSProperty @JSProperty
String getAlt(); public abstract String getAlt();
@JSProperty @JSProperty
void setAlt(String alt); public abstract void setAlt(String alt);
@JSProperty @JSProperty
int getWidth(); public abstract int getWidth();
@JSProperty @JSProperty
void setWidth(int width); public abstract void setWidth(int width);
@JSProperty @JSProperty
int getHeight(); public abstract int getHeight();
@JSProperty @JSProperty
void setHeight(int height); public abstract void setHeight(int height);
@JSProperty @JSProperty
int getNaturalWidth(); public abstract int getNaturalWidth();
@JSProperty @JSProperty
int getNaturalHeight(); public abstract int getNaturalHeight();
@JSProperty @JSProperty
String getSrc(); public abstract String getSrc();
@JSProperty @JSProperty
void setSrc(String src); public abstract void setSrc(String src);
@JSProperty @JSProperty
String getCrossOrigin(); public abstract String getCrossOrigin();
@JSProperty @JSProperty
void setCrossOrigin(String crossOrigin); public abstract void setCrossOrigin(String crossOrigin);
} }

View File

@ -17,66 +17,66 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
public interface HTMLInputElement extends HTMLElement { public abstract class HTMLInputElement extends HTMLElement {
@JSProperty @JSProperty
boolean isChecked(); public abstract boolean isChecked();
@JSProperty @JSProperty
void setChecked(boolean checked); public abstract void setChecked(boolean checked);
@JSProperty @JSProperty
boolean isDisabled(); public abstract boolean isDisabled();
@JSProperty @JSProperty
void setDisabled(boolean disabled); public abstract void setDisabled(boolean disabled);
@JSProperty @JSProperty
int getMaxLength(); public abstract int getMaxLength();
@JSProperty @JSProperty
void setMaxLength(int maxLength); public abstract void setMaxLength(int maxLength);
@JSProperty @JSProperty
String getName(); public abstract String getName();
@JSProperty @JSProperty
void setName(String name); public abstract void setName(String name);
@JSProperty @JSProperty
boolean isReadOnly(); public abstract boolean isReadOnly();
@JSProperty @JSProperty
void setReadOnly(boolean readOnly); public abstract void setReadOnly(boolean readOnly);
@JSProperty @JSProperty
int getSize(); public abstract int getSize();
@JSProperty @JSProperty
void setSize(int size); public abstract void setSize(int size);
@JSProperty @JSProperty
String getType(); public abstract String getType();
@JSProperty @JSProperty
void setType(String type); public abstract void setType(String type);
@JSProperty @JSProperty
String getValue(); public abstract String getValue();
@JSProperty @JSProperty
void setValue(String value); public abstract void setValue(String value);
void setCustomValidity(String validationFailure); public abstract void setCustomValidity(String validationFailure);
boolean checkValidity(); public abstract boolean checkValidity();
boolean reportValidity(); public abstract boolean reportValidity();
void select(); public abstract void select();
@JSProperty @JSProperty
String getPlaceholder(); public abstract String getPlaceholder();
@JSProperty @JSProperty
void setPlaceholder(String value); public abstract void setPlaceholder(String value);
} }

View File

@ -17,40 +17,40 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
public interface HTMLLinkElement extends HTMLElement { public abstract class HTMLLinkElement extends HTMLElement {
@JSProperty @JSProperty
String getHref(); public abstract String getHref();
@JSProperty @JSProperty
void setHref(String href); public abstract void setHref(String href);
@JSProperty @JSProperty
String getCrossOrigin(); public abstract String getCrossOrigin();
@JSProperty @JSProperty
void setCrossOrigin(String crossOrigin); public abstract void setCrossOrigin(String crossOrigin);
@JSProperty @JSProperty
String getRel(); public abstract String getRel();
@JSProperty @JSProperty
void setRel(String rel); public abstract void setRel(String rel);
@JSProperty @JSProperty
String getMedia(); public abstract String getMedia();
@JSProperty @JSProperty
void setMedia(String media); public abstract void setMedia(String media);
@JSProperty @JSProperty
String getHreflang(); public abstract String getHreflang();
@JSProperty @JSProperty
void setHreflang(String hreflang); public abstract void setHreflang(String hreflang);
@JSProperty @JSProperty
String getType(); public abstract String getType();
@JSProperty @JSProperty
void setType(String property); public abstract void setType(String property);
} }

View File

@ -16,6 +16,7 @@
package org.teavm.jso.dom.html; package org.teavm.jso.dom.html;
import java.util.Date; import java.util.Date;
import org.teavm.jso.JSClass;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
import org.teavm.jso.media.AudioTrackList; import org.teavm.jso.media.AudioTrackList;
import org.teavm.jso.media.MediaController; import org.teavm.jso.media.MediaController;
@ -25,171 +26,168 @@ import org.teavm.jso.media.TextTrackList;
import org.teavm.jso.media.TimeRanges; import org.teavm.jso.media.TimeRanges;
import org.teavm.jso.media.VideoTrackList; import org.teavm.jso.media.VideoTrackList;
/** @JSClass
* public abstract class HTMLMediaElement extends HTMLElement {
* @author Junji Takakura public static final int HAVE_NOTHING = 0;
*/ public static final int HAVE_METADATA = 1;
public interface HTMLMediaElement extends HTMLElement { public static final int HAVE_CURRENT_DATA = 2;
int HAVE_NOTHING = 0; public static final int HAVE_FUTURE_DATA = 3;
int HAVE_METADATA = 1; public static final int HAVE_ENOUGH_DATA = 4;
int HAVE_CURRENT_DATA = 2;
int HAVE_FUTURE_DATA = 3;
int HAVE_ENOUGH_DATA = 4;
int NETWORK_EMPTY = 0; public static final int NETWORK_EMPTY = 0;
int NETWORK_IDLE = 1; public static final int NETWORK_IDLE = 1;
int NETWORK_LOADING = 2; public static final int NETWORK_LOADING = 2;
int NETWORK_NO_SOURCE = 3; public static final int NETWORK_NO_SOURCE = 3;
@JSProperty @JSProperty
MediaError getError(); public abstract MediaError getError();
@JSProperty @JSProperty
String getSrc(); public abstract String getSrc();
@JSProperty @JSProperty
void setSrc(String src); public abstract void setSrc(String src);
@JSProperty @JSProperty
String getCurrentSrc(); public abstract String getCurrentSrc();
@JSProperty @JSProperty
String getCrossOrigin(); public abstract String getCrossOrigin();
@JSProperty @JSProperty
void setCrossOrigin(String crossOrigin); public abstract void setCrossOrigin(String crossOrigin);
@JSProperty @JSProperty
int getNetworkState(); public abstract int getNetworkState();
@JSProperty @JSProperty
String getPreload(); public abstract String getPreload();
@JSProperty @JSProperty
void setPreload(String preload); public abstract void setPreload(String preload);
@JSProperty @JSProperty
TimeRanges getBuffered(); public abstract TimeRanges getBuffered();
@JSProperty @JSProperty
int getReadyState(); public abstract int getReadyState();
@JSProperty @JSProperty
boolean isSeeking(); public abstract boolean isSeeking();
@JSProperty @JSProperty
double getCurrentTime(); public abstract double getCurrentTime();
@JSProperty @JSProperty
void setCurrentTime(double currentTime); public abstract void setCurrentTime(double currentTime);
default void addCurrentTime(double delta) { public final void addCurrentTime(double delta) {
setCurrentTime(getCurrentTime() + delta); setCurrentTime(getCurrentTime() + delta);
} }
@JSProperty @JSProperty
double getDuration(); public abstract double getDuration();
@JSProperty @JSProperty
Date getStartDate(); public abstract Date getStartDate();
@JSProperty @JSProperty
boolean isPaused(); public abstract boolean isPaused();
@JSProperty @JSProperty
double getDefaultPlaybackRate(); public abstract double getDefaultPlaybackRate();
@JSProperty @JSProperty
void setDefaultPlaybackRate(double defaultPlaybackRate); public abstract void setDefaultPlaybackRate(double defaultPlaybackRate);
@JSProperty @JSProperty
double getPlaybackRate(); public abstract double getPlaybackRate();
@JSProperty @JSProperty
void setPlaybackRate(double playbackRate); public abstract void setPlaybackRate(double playbackRate);
default void addPlaybackRate(double delta) { public final void addPlaybackRate(double delta) {
setPlaybackRate(getPlaybackRate() + delta); setPlaybackRate(getPlaybackRate() + delta);
} }
@JSProperty @JSProperty
TimeRanges getPlayed(); public abstract TimeRanges getPlayed();
@JSProperty @JSProperty
TimeRanges getSeekable(); public abstract TimeRanges getSeekable();
@JSProperty @JSProperty
boolean isEnded(); public abstract boolean isEnded();
@JSProperty @JSProperty
boolean isAutoplay(); public abstract boolean isAutoplay();
@JSProperty @JSProperty
void setAutoplay(boolean autoplay); public abstract void setAutoplay(boolean autoplay);
@JSProperty @JSProperty
boolean isLoop(); public abstract boolean isLoop();
@JSProperty @JSProperty
void setLoop(boolean loop); public abstract void setLoop(boolean loop);
@JSProperty @JSProperty
String getMediaGroup(); public abstract String getMediaGroup();
@JSProperty @JSProperty
void setMediaGroup(String mediaGroup); public abstract void setMediaGroup(String mediaGroup);
@JSProperty @JSProperty
MediaController getController(); public abstract MediaController getController();
@JSProperty @JSProperty
void setController(MediaController controller); public abstract void setController(MediaController controller);
@JSProperty @JSProperty
boolean isControls(); public abstract boolean isControls();
@JSProperty @JSProperty
void setControls(boolean controls); public abstract void setControls(boolean controls);
@JSProperty @JSProperty
float getVolume(); public abstract float getVolume();
@JSProperty @JSProperty
void setVolume(float volume); public abstract void setVolume(float volume);
default void addVolume(float delta) { public final void addVolume(float delta) {
setVolume(getVolume() + delta); setVolume(getVolume() + delta);
} }
@JSProperty @JSProperty
boolean isMuted(); public abstract boolean isMuted();
@JSProperty @JSProperty
void setMuted(boolean muted); public abstract void setMuted(boolean muted);
@JSProperty @JSProperty
boolean isDefaultMuted(); public abstract boolean isDefaultMuted();
@JSProperty @JSProperty
void setDefaultMuted(boolean defaultMuted); public abstract void setDefaultMuted(boolean defaultMuted);
AudioTrackList getAudioTracks(); public abstract AudioTrackList getAudioTracks();
VideoTrackList getVideoTracks(); public abstract VideoTrackList getVideoTracks();
TextTrackList getTextTracks(); public abstract TextTrackList getTextTracks();
TextTrack addTextTrack(String kind); public abstract TextTrack addTextTrack(String kind);
TextTrack addTextTrack(String kind, String label); public abstract TextTrack addTextTrack(String kind, String label);
TextTrack addTextTrack(String kind, String label, String language); public abstract TextTrack addTextTrack(String kind, String label, String language);
void play(); public abstract void play();
void pause(); public abstract void pause();
void load(); public abstract void load();
String canPlayType(String type); public abstract String canPlayType(String type);
} }

View File

@ -17,22 +17,22 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
public interface HTMLMetaElement extends HTMLElement { public abstract class HTMLMetaElement extends HTMLElement {
@JSProperty @JSProperty
String getName(); public abstract String getName();
@JSProperty @JSProperty
void setName(String name); public abstract void setName(String name);
@JSProperty @JSProperty
String getHttpEquiv(); public abstract String getHttpEquiv();
@JSProperty @JSProperty
void setHttpEquiv(String httpEquiv); public abstract void setHttpEquiv(String httpEquiv);
@JSProperty @JSProperty
String getContent(); public abstract String getContent();
@JSProperty @JSProperty
void setContent(String content); public abstract void setContent(String content);
} }

View File

@ -17,43 +17,43 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
public interface HTMLOptionElement extends HTMLElement { public abstract class HTMLOptionElement extends HTMLElement {
@JSProperty @JSProperty
boolean isDisabled(); public abstract boolean isDisabled();
@JSProperty @JSProperty
void setDisabled(boolean disabled); public abstract void setDisabled(boolean disabled);
@JSProperty @JSProperty
String getLabel(); public abstract String getLabel();
@JSProperty @JSProperty
void setLabel(String label); public abstract void setLabel(String label);
@JSProperty @JSProperty
boolean isDefaultSelected(); public abstract boolean isDefaultSelected();
@JSProperty @JSProperty
void setDefaultSelected(boolean defaultSelected); public abstract void setDefaultSelected(boolean defaultSelected);
@JSProperty @JSProperty
boolean isSelected(); public abstract boolean isSelected();
@JSProperty @JSProperty
void setSelected(boolean selected); public abstract void setSelected(boolean selected);
@JSProperty @JSProperty
String getValue(); public abstract String getValue();
@JSProperty @JSProperty
void setValue(String value); public abstract void setValue(String value);
@JSProperty @JSProperty
String getText(); public abstract String getText();
@JSProperty @JSProperty
void setText(String text); public abstract void setText(String text);
@JSProperty @JSProperty
int getIndex(); public abstract int getIndex();
} }

View File

@ -17,40 +17,40 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
public interface HTMLScriptElement extends HTMLElement { public abstract class HTMLScriptElement extends HTMLElement {
@JSProperty @JSProperty
String getSrc(); public abstract String getSrc();
@JSProperty @JSProperty
void setSrc(String value); public abstract void setSrc(String value);
@JSProperty @JSProperty
boolean isAsync(); public abstract boolean isAsync();
@JSProperty @JSProperty
void setAsync(boolean value); public abstract void setAsync(boolean value);
@JSProperty @JSProperty
boolean isDefer(); public abstract boolean isDefer();
@JSProperty @JSProperty
void setDefer(boolean value); public abstract void setDefer(boolean value);
@JSProperty @JSProperty
String getType(); public abstract String getType();
@JSProperty @JSProperty
void setType(String value); public abstract void setType(String value);
@JSProperty @JSProperty
String getCharset(); public abstract String getCharset();
@JSProperty @JSProperty
void setCharset(String value); public abstract void setCharset(String value);
@JSProperty @JSProperty
String getText(); public abstract String getText();
@JSProperty @JSProperty
void setText(String value); public abstract void setText(String value);
} }

View File

@ -17,47 +17,47 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
public interface HTMLSelectElement extends HTMLElement { public abstract class HTMLSelectElement extends HTMLElement {
@JSProperty @JSProperty
boolean isDisabled(); public abstract boolean isDisabled();
@JSProperty @JSProperty
void setDisabled(boolean disabled); public abstract void setDisabled(boolean disabled);
@JSProperty @JSProperty
boolean isMultiple(); public abstract boolean isMultiple();
@JSProperty @JSProperty
void setMultiple(boolean multiple); public abstract void setMultiple(boolean multiple);
@JSProperty @JSProperty
HTMLOptionsCollection getOptions(); public abstract HTMLOptionsCollection getOptions();
@JSProperty @JSProperty
String getName(); public abstract String getName();
@JSProperty @JSProperty
void setName(String name); public abstract void setName(String name);
@JSProperty @JSProperty
int getSize(); public abstract int getSize();
@JSProperty @JSProperty
void setSize(int size); public abstract void setSize(int size);
@JSProperty @JSProperty
int getSelectedIndex(); public abstract int getSelectedIndex();
@JSProperty @JSProperty
void setSelectedIndex(int selectedIndex); public abstract void setSelectedIndex(int selectedIndex);
@JSProperty @JSProperty
String getValue(); public abstract String getValue();
@JSProperty @JSProperty
void setValue(String value); public abstract void setValue(String value);
void setCustomValidity(String validationFailure); public abstract void setCustomValidity(String validationFailure);
boolean reportValidity(); public abstract boolean reportValidity();
} }

View File

@ -17,28 +17,24 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
/** public abstract class HTMLSourceElement extends HTMLElement {
*
* @author Junji Takakura
*/
public interface HTMLSourceElement extends HTMLElement {
@JSProperty @JSProperty
String getType(); public abstract String getType();
@JSProperty @JSProperty
void setType(String type); public abstract void setType(String type);
@JSProperty @JSProperty
String getSrc(); public abstract String getSrc();
@JSProperty @JSProperty
void setSrc(String src); public abstract void setSrc(String src);
@JSProperty @JSProperty
String getMedia(); public abstract String getMedia();
@JSProperty @JSProperty
void setMedia(String media); public abstract void setMedia(String media);
} }

View File

@ -17,133 +17,133 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
public interface HTMLTextAreaElement extends HTMLElement { public abstract class HTMLTextAreaElement extends HTMLElement {
@JSProperty @JSProperty
String getAutocomplete(); public abstract String getAutocomplete();
@JSProperty @JSProperty
void setAutocomplete(String value); public abstract void setAutocomplete(String value);
@JSProperty @JSProperty
boolean isAutofocus(); public abstract boolean isAutofocus();
@JSProperty @JSProperty
void setAutofocus(boolean value); public abstract void setAutofocus(boolean value);
@JSProperty @JSProperty
int getCols(); public abstract int getCols();
@JSProperty @JSProperty
void setCols(int cols); public abstract void setCols(int cols);
@JSProperty @JSProperty
String getDirName(); public abstract String getDirName();
@JSProperty @JSProperty
void setDirName(String value); public abstract void setDirName(String value);
@JSProperty @JSProperty
boolean isDisabled(); public abstract boolean isDisabled();
@JSProperty @JSProperty
void setDisabled(boolean value); public abstract void setDisabled(boolean value);
@JSProperty @JSProperty
HTMLFormElement getForm(); public abstract HTMLFormElement getForm();
@JSProperty @JSProperty
int getMaxLength(); public abstract int getMaxLength();
@JSProperty @JSProperty
void setMaxLength(int value); public abstract void setMaxLength(int value);
@JSProperty @JSProperty
int getMinLength(); public abstract int getMinLength();
@JSProperty @JSProperty
void setMinLength(int value); public abstract void setMinLength(int value);
@JSProperty @JSProperty
String getName(); public abstract String getName();
@JSProperty @JSProperty
void setName(String value); public abstract void setName(String value);
@JSProperty @JSProperty
String getPlaceholder(); public abstract String getPlaceholder();
@JSProperty @JSProperty
void setPlaceholder(String value); public abstract void setPlaceholder(String value);
@JSProperty @JSProperty
boolean isReadOnly(); public abstract boolean isReadOnly();
@JSProperty @JSProperty
void setReadOnly(boolean value); public abstract void setReadOnly(boolean value);
@JSProperty @JSProperty
int getRows(); public abstract int getRows();
@JSProperty @JSProperty
void setRows(int rows); public abstract void setRows(int rows);
@JSProperty @JSProperty
String getWrap(); public abstract String getWrap();
@JSProperty @JSProperty
void setWrap(String value); public abstract void setWrap(String value);
@JSProperty @JSProperty
String getType(); public abstract String getType();
@JSProperty @JSProperty
String getDefaultValue(); public abstract String getDefaultValue();
@JSProperty @JSProperty
void setDefaultValue(String value); public abstract void setDefaultValue(String value);
@JSProperty @JSProperty
String getValue(); public abstract String getValue();
@JSProperty @JSProperty
void setValue(String value); public abstract void setValue(String value);
@JSProperty @JSProperty
int getTextLength(); public abstract int getTextLength();
void setCustomValidity(String validationFailure); public abstract void setCustomValidity(String validationFailure);
boolean checkValidity(); public abstract boolean checkValidity();
boolean reportValidity(); public abstract boolean reportValidity();
void select(); public abstract void select();
@JSProperty @JSProperty
int getSelectionStart(); public abstract int getSelectionStart();
@JSProperty @JSProperty
void setSelectionStart(int value); public abstract void setSelectionStart(int value);
@JSProperty @JSProperty
int getSelectionEnd(); public abstract int getSelectionEnd();
@JSProperty @JSProperty
void setSelectionEnd(int value); public abstract void setSelectionEnd(int value);
@JSProperty @JSProperty
String getSelectionDirection(); public abstract String getSelectionDirection();
@JSProperty @JSProperty
void setSelectionDirection(String value); public abstract void setSelectionDirection(String value);
void setRangeText(String replacement); public abstract void setRangeText(String replacement);
void setRangeText(String replacement, int start, int end, String selectionMode); public abstract void setRangeText(String replacement, int start, int end, String selectionMode);
void setRangeText(String replacement, int start, int end); public abstract void setRangeText(String replacement, int start, int end);
void setSelectionRange(int start, int end, String direction); public abstract void setSelectionRange(int start, int end, String direction);
void setSelectionRange(int start, int end); public abstract void setSelectionRange(int start, int end);
} }

View File

@ -17,10 +17,10 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
public interface HTMLTitleElement extends HTMLElement { public abstract class HTMLTitleElement extends HTMLElement {
@JSProperty @JSProperty
String getText(); public abstract String getText();
@JSProperty @JSProperty
void setText(String text); public abstract void setText(String text);
} }

View File

@ -17,33 +17,29 @@ package org.teavm.jso.dom.html;
import org.teavm.jso.JSProperty; import org.teavm.jso.JSProperty;
/** public abstract class HTMLVideoElement extends HTMLMediaElement {
*
* @author Junji Takakura
*/
public interface HTMLVideoElement extends HTMLMediaElement {
@JSProperty @JSProperty
int getWidth(); public abstract int getWidth();
@JSProperty @JSProperty
int getHeight(); public abstract int getHeight();
@JSProperty @JSProperty
void setWidth(int width); public abstract void setWidth(int width);
@JSProperty @JSProperty
void setHeight(int height); public abstract void setHeight(int height);
@JSProperty @JSProperty
int getVideoWidth(); public abstract int getVideoWidth();
@JSProperty @JSProperty
int getVideoHeight(); public abstract int getVideoHeight();
@JSProperty @JSProperty
String getPoster(); public abstract String getPoster();
@JSProperty @JSProperty
void setPoster(String poster); public abstract void setPoster(String poster);
} }

View File

@ -16,6 +16,7 @@
package org.teavm.jso.dom.xml; package org.teavm.jso.dom.xml;
import org.teavm.jso.JSBody; import org.teavm.jso.JSBody;
import org.teavm.jso.JSClass;
import org.teavm.jso.JSObject; import org.teavm.jso.JSObject;
import org.teavm.jso.dom.html.HTMLDocument; import org.teavm.jso.dom.html.HTMLDocument;
@ -23,9 +24,13 @@ import org.teavm.jso.dom.html.HTMLDocument;
* The DOMParser interface provides the ability to parse XML or HTML source code from * The DOMParser interface provides the ability to parse XML or HTML source code from
* a string into a DOM {@link Document}. * a string into a DOM {@link Document}.
*/ */
public abstract class DOMParser implements JSObject { @JSClass
public class DOMParser implements JSObject {
public DOMParser() {
}
@JSBody(script = "return new DOMParser();") @JSBody(script = "return new DOMParser();")
@Deprecated
public static native DOMParser create(); public static native DOMParser create();
/** /**
@ -51,6 +56,6 @@ public abstract class DOMParser implements JSObject {
* application/xml, application/xhtml+xml, image/svg+xml * application/xml, application/xhtml+xml, image/svg+xml
* @return Newly created {@link Document} or {@link HTMLDocument} * @return Newly created {@link Document} or {@link HTMLDocument}
*/ */
public abstract Document parseFromString(String s, String mimeType); public native Document parseFromString(String s, String mimeType);
} }

View File

@ -16,32 +16,21 @@
package org.teavm.jso.dom.xml; package org.teavm.jso.dom.xml;
import org.teavm.jso.JSBody; import org.teavm.jso.JSBody;
import org.teavm.jso.JSClass;
import org.teavm.jso.JSObject; import org.teavm.jso.JSObject;
/** /**
* The XMLSerializer interface provides the ability to construct an XML string * The XMLSerializer interface provides the ability to construct an XML string
* representing a DOM tree. * representing a DOM tree.
*/ */
public abstract class XMLSerializer implements JSObject { @JSClass
public class XMLSerializer implements JSObject {
public XMLSerializer() {
}
@JSBody(script = "return new XMLSerializer();") @JSBody(script = "return new XMLSerializer();")
@Deprecated
public static native XMLSerializer create(); public static native XMLSerializer create();
/** public native String serializeToString(Node rootNode);
* Constructs a string representing the specified DOM tree in XML form.
*
* @param rootNode The Node to use as the root of the DOM tree or subtree for
* which to construct an XML representation. The root node itself must be
* either a {@link Node} or {@link Attr} object.
* @return A DOMString containing the XML representation of the specified DOM
* tree.
* @throws TypeError The specified rootNode is not a compatible node type. The
* root node must be either Node or Attr.
* @throws InvalidStateError The tree could not be successfully serialized,
* probably due to issues with the content's compatibility with XML
* serialization.
* @throws SyntaxError A serialization of HTML was requested but could not
* succeed due to the content not being well-formed.
*/
public abstract String serializeToString(Node rootNode);
} }