More wrappers for JavaScript APIs

This commit is contained in:
Alexey Andreev 2018-06-19 18:54:00 +03:00
parent 544eb4e827
commit f2adb9dbdd
16 changed files with 356 additions and 17 deletions

View File

@ -181,4 +181,7 @@ public abstract class Window implements JSObject, WindowEventTarget, StorageProv
@JSBody(params = "uri", script = "return decodeURIComponent(uri);")
public static native String decodeURIComponent(String uri);
@JSProperty
public abstract double getDevicePixelRatio();
}

View File

@ -19,11 +19,6 @@ import org.teavm.jso.JSIndexer;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
/**
*
* @author Alexey Andreev
* @param <T>
*/
public interface JSArrayReader<T extends JSObject> extends JSObject {
@JSProperty
int getLength();

View File

@ -43,7 +43,7 @@ public interface HTMLDocument extends Document, EventTarget {
HTMLBodyElement getBody();
@JSProperty
HTMLElement getHead();
HTMLHeadElement getHead();
@JSProperty
int getScrollLeft();
@ -60,4 +60,17 @@ public interface HTMLDocument extends Document, EventTarget {
@Override
NodeList<? extends HTMLElement> querySelectorAll(String selectors);
@JSProperty
HTMLElement getActiveElement();
@JSProperty
boolean isDesignMode();
@JSProperty
void setDesignMode(boolean value);
void execCommand(String commandName, boolean showDefaultUI, String valueArgument);
void execCommand(String commandName);
}

View File

@ -0,0 +1,90 @@
/*
* Copyright 2018 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.dom.html;
import org.teavm.jso.JSIndexer;
import org.teavm.jso.JSProperty;
public interface HTMLFormElement extends HTMLElement {
@JSProperty
String getAcceptCharset();
@JSProperty
void setAcceptCharset(String value);
@JSProperty
String getAction();
@JSProperty
void setAction(String value);
@JSProperty
String getAutocomplete();
@JSProperty
void setAutocomplete(String value);
@JSProperty
String getEnctype();
@JSProperty
void setEnctype(String enctype);
@JSProperty
String getEncoding();
@JSProperty
void setEncoding(String value);
@JSProperty
String getMethod();
@JSProperty
void setMethod(String value);
@JSProperty
String getName();
@JSProperty
void setName(String name);
@JSProperty
boolean isNoValidate();
@JSProperty
void setNoValidate(boolean value);
@JSProperty
String getTarget();
@JSProperty
void setTarget(String value);
@JSIndexer
HTMLElement get(String name);
@JSIndexer
HTMLElement get(int index);
@JSProperty
int getLength();
void submit();
void reset();
boolean checkValidity();
}

View File

@ -65,4 +65,6 @@ public interface HTMLInputElement extends HTMLElement {
@JSProperty
void setValue(String value);
void select();
}

View File

@ -0,0 +1,144 @@
/*
* Copyright 2018 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.dom.html;
import org.teavm.jso.JSProperty;
public interface HTMLTextAreaElement extends HTMLElement {
@JSProperty
String getAutocomplete();
@JSProperty
void setAutocomplete(String value);
@JSProperty
boolean isAutofocus();
@JSProperty
void setAutofocus(boolean value);
@JSProperty
int getCols();
@JSProperty
void setCols(int cols);
@JSProperty
String getDirName();
@JSProperty
void setDirName(String value);
@JSProperty
boolean isDisabled();
@JSProperty
void setDisabled(boolean value);
@JSProperty
HTMLFormElement getForm();
@JSProperty
int getMaxLength();
@JSProperty
void setMaxLength(int value);
@JSProperty
int getMinLength();
@JSProperty
void setMinLength(int value);
@JSProperty
String getName();
@JSProperty
void setName(String value);
@JSProperty
String getPlaceholder();
@JSProperty
void setPlaceholder(String value);
@JSProperty
boolean isReadOnly();
@JSProperty
void setReadOnly(boolean value);
@JSProperty
int getRows();
@JSProperty
void setRows(int rows);
@JSProperty
String getWrap();
@JSProperty
void setWrap(String value);
@JSProperty
String getType();
@JSProperty
String getDefaultValue();
@JSProperty
void setDefaultValue(String value);
@JSProperty
String getValue();
@JSProperty
void setValue(String value);
@JSProperty
int getTextLength();
void select();
@JSProperty
int getSelectionStart();
@JSProperty
void setSelectionStart(int value);
@JSProperty
int getSelectionEnd();
@JSProperty
void setSelectionEnd(int value);
@JSProperty
String getSelectionDirection();
@JSProperty
void setSelectionDirection(String value);
void setRangeText(String replacement);
void setRangeText(String replacement, int start, int end, String selectionMode);
void setRangeText(String replacement, int start, int end);
void setSelectionRange(int start, int end, String direction);
void setSelectionRange(int start, int end);
}

View File

@ -15,8 +15,10 @@
*/
package org.teavm.jso.typedarrays;
import org.teavm.jso.JSByRef;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
import org.teavm.jso.core.JSArrayReader;
public abstract class ArrayBufferView implements JSObject {
protected ArrayBufferView() {
@ -28,6 +30,37 @@ public abstract class ArrayBufferView implements JSObject {
@JSProperty
public abstract int getByteLength();
@JSProperty
public abstract int getByteOffset();
@JSProperty
public abstract ArrayBuffer getBuffer();
public abstract void set(ArrayBufferView other, int offset);
public abstract void set(ArrayBufferView other);
public abstract void set(JSArrayReader<?> other, int offset);
public abstract void set(JSArrayReader<?> other);
public abstract void set(@JSByRef byte[] other, int offset);
public abstract void set(@JSByRef byte[] other);
public abstract void set(@JSByRef short[] other, int offset);
public abstract void set(@JSByRef short[] other);
public abstract void set(@JSByRef int[] other, int offset);
public abstract void set(@JSByRef int[] other);
public abstract void set(@JSByRef float[] other, int offset);
public abstract void set(@JSByRef float[] other);
public abstract void set(@JSByRef double[] other, int offset);
public abstract void set(@JSByRef double[] other);
}

View File

@ -20,23 +20,23 @@ import org.teavm.jso.JSBody;
public abstract class DataView extends ArrayBufferView {
public abstract byte getInt8(int byteOffset);
public abstract short getUInt8(int byteOffset);
public abstract short getUint8(int byteOffset);
public abstract short getInt16(int byteOffset);
public abstract short getInt16(int byteOffset, boolean littleEndian);
public abstract int getUInt16(int byteOffset);
public abstract int getUint16(int byteOffset);
public abstract int getUInt16(int byteOffset, boolean littleEndian);
public abstract int getUint16(int byteOffset, boolean littleEndian);
public abstract int getInt32(int byteOffset);
public abstract int getInt32(int byteOffset, boolean littleEndian);
public abstract int getUInt32(int byteOffset);
public abstract int getUint32(int byteOffset);
public abstract int getUInt32(int byteOffset, boolean littleEndian);
public abstract int getUint32(int byteOffset, boolean littleEndian);
public abstract float getFloat32(int byteOffset);
@ -48,23 +48,23 @@ public abstract class DataView extends ArrayBufferView {
public abstract void setInt8(int byteOffset, int value);
public abstract void setUInt8(int byteOffset, int value);
public abstract void setUint8(int byteOffset, int value);
public abstract void setInt16(int byteOffset, int value);
public abstract void setInt16(int byteOffset, int value, boolean littleEndian);
public abstract void setUInt16(int byteOffset, int value);
public abstract void setUint16(int byteOffset, int value);
public abstract void setUInt16(int byteOffset, int value, boolean littleEndian);
public abstract void setUint16(int byteOffset, int value, boolean littleEndian);
public abstract void setInt32(int byteOffset, int value);
public abstract void setInt32(int byteOffset, int value, boolean littleEndian);
public abstract void setUInt32(int byteOffset, int value);
public abstract void setUint32(int byteOffset, int value);
public abstract void setUInt32(int byteOffset, int value, boolean littleEndian);
public abstract void setUint32(int byteOffset, int value, boolean littleEndian);
public abstract void setFloat32(int byteOffset, float value);
@ -77,6 +77,12 @@ public abstract class DataView extends ArrayBufferView {
@JSBody(params = "buffer", script = "return new DataView(buffer);")
public static native DataView create(ArrayBuffer buffer);
@JSBody(params = {"buffer", "offset", "length"}, script = "return new DataView(buffer, offset, length);")
@JSBody(params = "buffer", script = "return new DataView(buffer);")
public static native DataView create(ArrayBufferView buffer);
@JSBody(params = { "buffer", "offset", "length" }, script = "return new DataView(buffer, offset, length);")
public static native DataView create(ArrayBuffer buffer, int offset, int length);
@JSBody(params = { "buffer", "offset" }, script = "return new DataView(buffer, offset);")
public static native DataView create(ArrayBuffer buffer, int offset);
}

View File

@ -31,6 +31,12 @@ public abstract class Float32Array extends ArrayBufferView {
@JSBody(params = "buffer", script = "return new Float32Array(buffer);")
public static native Float32Array create(ArrayBuffer buffer);
@JSBody(params = "buffer", script = "return new Float32Array(buffer);")
public static native Float32Array create(ArrayBufferView buffer);
@JSBody(params = { "buffer", "offset", "length" }, script = "return new Float32Array(buffer, offset, length);")
public static native Float32Array create(ArrayBuffer buffer, int offset, int length);
@JSBody(params = { "buffer", "offset" }, script = "return new Float32Array(buffer, offset);")
public static native Float32Array create(ArrayBuffer buffer, int offset);
}

View File

@ -31,6 +31,12 @@ public abstract class Float64Array extends ArrayBufferView {
@JSBody(params = "buffer", script = "return new Float64Array(buffer);")
public static native Float64Array create(ArrayBuffer buffer);
@JSBody(params = "buffer", script = "return new Float64Array(buffer);")
public static native Float64Array create(ArrayBufferView buffer);
@JSBody(params = { "buffer", "offset", "length" }, script = "return new Float64Array(buffer, offset, length);")
public static native Float64Array create(ArrayBuffer buffer, int offset, int length);
@JSBody(params = { "buffer", "offset" }, script = "return new Float64Array(buffer, offset);")
public static native Float64Array create(ArrayBuffer buffer, int offset);
}

View File

@ -31,6 +31,12 @@ public abstract class Int16Array extends ArrayBufferView {
@JSBody(params = "buffer", script = "return new Int16Array(buffer);")
public static native Int16Array create(ArrayBuffer buffer);
@JSBody(params = "buffer", script = "return new Int16Array(buffer);")
public static native Int16Array create(ArrayBufferView buffer);
@JSBody(params = { "buffer", "offset", "length" }, script = "return new Int16Array(buffer, offset, length);")
public static native Int16Array create(ArrayBuffer buffer, int offset, int length);
@JSBody(params = { "buffer", "offset" }, script = "return new Int16Array(buffer, offset);")
public static native Int16Array create(ArrayBuffer buffer, int offset);
}

View File

@ -16,6 +16,7 @@
package org.teavm.jso.typedarrays;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSByRef;
import org.teavm.jso.JSIndexer;
public abstract class Int32Array extends ArrayBufferView {
@ -25,12 +26,22 @@ public abstract class Int32Array extends ArrayBufferView {
@JSIndexer
public abstract void set(int index, int value);
public abstract void set(@JSByRef int[] data, int offset);
public abstract void set(@JSByRef int[] data);
@JSBody(params = "length", script = "return new Int32Array(length);")
public static native Int32Array create(int length);
@JSBody(params = "buffer", script = "return new Int32Array(buffer);")
public static native Int32Array create(ArrayBuffer buffer);
@JSBody(params = "buffer", script = "return new Int32Array(buffer);")
public static native Int32Array create(ArrayBufferView buffer);
@JSBody(params = { "buffer", "offset", "length" }, script = "return new Int32Array(buffer, offset, length);")
public static native Int32Array create(ArrayBuffer buffer, int offset, int length);
@JSBody(params = { "buffer", "offset" }, script = "return new Int32Array(buffer, offset);")
public static native Int32Array create(ArrayBuffer buffer, int offset);
}

View File

@ -31,6 +31,12 @@ public abstract class Int8Array extends ArrayBufferView {
@JSBody(params = "buffer", script = "return new Int8Array(buffer);")
public static native Int8Array create(ArrayBuffer buffer);
@JSBody(params = "buffer", script = "return new Int8Array(buffer);")
public static native Int8Array create(ArrayBufferView buffer);
@JSBody(params = { "buffer", "offset", "length" }, script = "return new Int8Array(buffer, offset, length);")
public static native Int8Array create(ArrayBuffer buffer, int offset, int length);
@JSBody(params = { "buffer", "offset" }, script = "return new Int8Array(buffer, offset);")
public static native Int8Array create(ArrayBuffer buffer, int offset);
}

View File

@ -31,6 +31,12 @@ public abstract class Uint16Array extends ArrayBufferView {
@JSBody(params = "buffer", script = "return new Uint16Array(buffer);")
public static native Uint16Array create(ArrayBuffer buffer);
@JSBody(params = "buffer", script = "return new Uint16Array(buffer);")
public static native Uint16Array create(ArrayBufferView buffer);
@JSBody(params = { "buffer", "offset", "length" }, script = "return new Uint16Array(buffer, offset, length);")
public static native Uint16Array create(ArrayBuffer buffer, int offset, int length);
@JSBody(params = { "buffer", "offset" }, script = "return new Uint16Array(buffer, offset);")
public static native Uint16Array create(ArrayBuffer buffer, int offset);
}

View File

@ -31,6 +31,12 @@ public abstract class Uint8Array extends ArrayBufferView {
@JSBody(params = "buffer", script = "return new Uint8Array(buffer);")
public static native Uint8Array create(ArrayBuffer buffer);
@JSBody(params = "buffer", script = "return new Uint8Array(buffer);")
public static native Uint8Array create(ArrayBufferView buffer);
@JSBody(params = { "buffer", "offset", "length" }, script = "return new Uint8Array(buffer, offset, length);")
public static native Uint8Array create(ArrayBuffer buffer, int offset, int length);
@JSBody(params = { "buffer", "offset" }, script = "return new Uint8Array(buffer, offset);")
public static native Uint8Array create(ArrayBuffer buffer, int offset);
}

View File

@ -31,7 +31,13 @@ public abstract class Uint8ClampedArray extends ArrayBufferView {
@JSBody(params = "buffer", script = "return new Uint8ClampedArray(buffer);")
public static native Uint8ClampedArray create(ArrayBuffer buffer);
@JSBody(params = "buffer", script = "return new Uint8ClampedArray(buffer);")
public static native Uint8ClampedArray create(ArrayBufferView buffer);
@JSBody(params = { "buffer", "offset", "length" }, script = "return new "
+ "Uint8ClampedArray(buffer, offset, length);")
public static native Uint8ClampedArray create(ArrayBuffer buffer, int offset, int length);
@JSBody(params = { "buffer", "offset" }, script = "return new Uint8ClampedArray(buffer, offset);")
public static native Uint8ClampedArray create(ArrayBuffer buffer, int offset);
}