Merge remote-tracking branch 'origin/canvas'

Conflicts:
	teavm-dom/src/main/java/org/teavm/dom/browser/Window.java
This commit is contained in:
konsoletyper 2014-10-04 17:57:40 +04:00
commit 4f668d4d43
13 changed files with 651 additions and 0 deletions

View File

@ -17,6 +17,8 @@ package org.teavm.dom.browser;
import org.teavm.dom.ajax.XMLHttpRequest;
import org.teavm.dom.html.HTMLDocument;
import org.teavm.dom.typedarrays.ArrayBuffer;
import org.teavm.dom.typedarrays.Int8Array;
import org.teavm.jso.JSConstructor;
import org.teavm.jso.JSGlobal;
import org.teavm.jso.JSObject;
@ -44,4 +46,25 @@ public interface Window extends JSGlobal {
@JSConstructor("XMLHttpRequest")
XMLHttpRequest createXMLHttpRequest();
@JSConstructor("ArrayBuffer")
ArrayBuffer createArrayBuffer(int length);
@JSConstructor("Int8Array")
Int8Array createInt8Array(int length);
@JSConstructor("Int8Array")
Int8Array createInt8Array(ArrayBuffer buffer);
@JSConstructor("Int8Array")
Int8Array createInt8Array(ArrayBuffer buffer, int offset, int length);
@JSConstructor("Uint8ClampedArray")
Int8Array createUint8ClampedArray(int length);
@JSConstructor("Uint8ClampedArray")
Int8Array createUint8ClampedArray(ArrayBuffer buffer);
@JSConstructor("Uint8ClampedArray")
Int8Array createUintClamped8Array(ArrayBuffer buffer, int offset, int length);
}

View File

@ -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.dom.canvas;
import org.teavm.jso.JSObject;
/**
*
* @author Alexey Andreev
*/
public interface CanvasGradient extends JSObject {
}

View File

@ -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.dom.canvas;
import org.teavm.jso.JSObject;
/**
*
* @author Alexey Andreev
*/
public interface CanvasImageSource extends JSObject {
}

View File

@ -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.dom.canvas;
import org.teavm.jso.JSObject;
/**
*
* @author Alexey Andreev
*/
public interface CanvasPattern extends JSObject {
}

View File

@ -0,0 +1,268 @@
/*
* 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.canvas;
import org.teavm.dom.core.Element;
import org.teavm.dom.html.HTMLCanvasElement;
import org.teavm.jso.JSArray;
import org.teavm.jso.JSArrayReader;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
/**
*
* @author Alexey Andreev
*/
public interface CanvasRenderingContext2D extends JSObject {
// Path
void beginPath();
void closePath();
void arc(double x, double y, double radius, double startAngle, double endAngle, boolean anticlockwise);
void arc(double x, double y, double radius, double startAngle, double endAngle);
void arcTo(double x1, double y1, double x2, double y2, double radius);
void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
void clearRect(double x, double y, double width, double height);
void moveTo(double x, double y);
void lineTo(double x, double y);
boolean isPointInPath(double x, double y);
boolean isPointInStroke(double x, double y);
void quadraticCurveTo(double cpx, double cpy, double x, double y);
void rect(double x, double y, double width, double height);
void scrollPathIntoView();
// Clip
void clip();
// Creating images, gradients and patterns
ImageData createImageData(double width, double height);
CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1);
CanvasPattern createPattern(CanvasImageSource image, String repetition);
CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1);
// Drawing images
void drawImage(CanvasImageSource image, double dx, double dy);
void drawImage(CanvasImageSource image, double dx, double dy, double dw, double dh);
void drawImage(CanvasImageSource image, double sx, double sy, double sw, double sh, double dx, double dy,
double dw, double dh);
// Focus ring
boolean drawCustomFocusRing(Element element);
void drawSystemFocusRing(Element element);
// Line dash
JSArrayReader<JSObject> getLineDash();
void setLineDash(JSArray<JSObject> lineDash);
// Image data
void putImageData(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY,
double dirtyWidth, double dirtyHeight);
void putImageData(ImageData imagedata, double dx, double dy);
ImageData getImageData(double x, double y, double width, double height);
// Text
TextMetrics measureText(String text);
// Fill
void fill();
void fillRect(double x, double y, double width, double height);
void fillText(String text, double x, double y, double maxWidth);
void fillText(String text, double x, double y);
// Sroke
void stroke();
void strokeRect(double x, double y, double w, double h);
void strokeText(String text, float x, float y, float maxWidth);
void strokeText(String text, float x, float y);
// Transformation
void setTransform(double m11, double m12, double m21, double m22, double dx, double dy);
void transform(double m11, double m12, double m21, double m22, double dx, double dy);
void translate(double x, double y);
void rotate(double angle);
void scale(double x, double y);
// Save and restore
void save();
void restore();
// Fill properties
@JSProperty
JSObject getFillStyle();
@JSProperty
void setFillStyle(String fillStyle);
@JSProperty
void setFillStyle(CanvasGradient gradient);
@JSProperty
void setFillStyle(CanvasPattern pattern);
// Line properties
@JSProperty
String getLineCap();
@JSProperty
void setLineCap(String lineCap);
@JSProperty
float getLineDashOffset();
@JSProperty
void setLineDashOffset(float lineDashOffset);
@JSProperty
String getLineJoin();
@JSProperty
void setLineJoin(String lineJoin);
@JSProperty
double getLineWidth();
@JSProperty
void setLineWidth(double lineWidth);
@JSProperty
double getMiterLimit();
@JSProperty
void setMiterLimit(double miterLimit);
@JSProperty
JSObject getStrokeStyle();
@JSProperty
void setStrokeStyle(String fillStyle);
@JSProperty
void setStrokeStyle(CanvasGradient gradient);
@JSProperty
void setStrokeStyle(CanvasPattern pattern);
// Alpha composite options
@JSProperty
double getGlobalAlpha();
@JSProperty
void setGlobalAlpha(double globalAlpha);
@JSProperty
String getGlobalCompositeOperation();
@JSProperty
void setGlobalCompositeOperation(String operation);
// Shadow properties
@JSProperty
double getShadowBlur();
@JSProperty
void setShadowBlur(double shadowBlur);
@JSProperty
String getShadowColor();
@JSProperty
void setShadowColor(String shadowColor);
@JSProperty
double getShadowOffsetX();
@JSProperty
void setShadowOffsetX(double offsetX);
@JSProperty
double getShadowOffsetY();
@JSProperty
void setShadowOffsetY(double offsetY);
// Text properties
@JSProperty
String getFont();
@JSProperty
void setFont(String font);
@JSProperty
String getTextAlign();
@JSProperty
void setTextAlign(String textAlign);
@JSProperty
String getTextBaseline();
@JSProperty
void setTextBaseline(String textBaseline);
// Misc.
@JSProperty
HTMLCanvasElement getCanvas();
}

View File

@ -0,0 +1,38 @@
/*
* 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.canvas;
import org.teavm.dom.typedarrays.Uint8ClampedArray;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
/**
*
* @author Alexey Andreev
*/
public interface ImageData extends JSObject {
@JSProperty
int getWidth();
@JSProperty
int getHeight();
@JSProperty
Uint8ClampedArray getData();
@JSProperty
void setData(Uint8ClampedArray data);
}

View File

@ -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.canvas;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
/**
*
* @author Alexey Andreev
*/
public interface TextMetrics extends JSObject {
@JSProperty
int getWidth();
}

View File

@ -0,0 +1,40 @@
/*
* 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.canvas.CanvasImageSource;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
/**
*
* @author Alexey Andreev
*/
public interface HTMLCanvasElement extends HTMLElement, CanvasImageSource {
@JSProperty
int getWidth();
@JSProperty
void setWidth(int width);
@JSProperty
int getHeight();
@JSProperty
void setHeight(int height);
JSObject getContext(String contextId);
}

View File

@ -0,0 +1,55 @@
/*
* 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.canvas.CanvasImageSource;
import org.teavm.jso.JSProperty;
/**
*
* @author Alexey Andreev
*/
public interface HTMLImageElement extends HTMLElement, CanvasImageSource {
@JSProperty
String getAlt();
@JSProperty
void setAlt(String alt);
@JSProperty
int getWidth();
@JSProperty
void setWidth(int width);
@JSProperty
int getHeight();
@JSProperty
void setHeight(int height);
@JSProperty
int getNaturalWidth();
@JSProperty
int getNaturalHeight();
@JSProperty
String getSrc();
@JSProperty
void setSrc(String src);
}

View File

@ -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.typedarrays;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
/**
*
* @author Alexey Andreev
*/
public interface ArrayBuffer extends JSObject {
@JSProperty
int getByteLength();
ArrayBuffer slice(int begin, int end);
}

View File

@ -0,0 +1,34 @@
/*
* 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.typedarrays;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
/**
*
* @author Alexey Andreev
*/
public interface ArrayBufferView extends JSObject {
@JSProperty
int getLength();
@JSProperty
int getByteLength();
@JSProperty
ArrayBuffer getBuffer();
}

View File

@ -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.typedarrays;
import org.teavm.jso.JSIndexer;
/**
*
* @author Alexey Andreev
*/
public interface Int8Array extends ArrayBufferView {
@JSIndexer
byte get(int index);
@JSIndexer
void set(int index, byte value);
}

View File

@ -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.typedarrays;
import org.teavm.jso.JSIndexer;
/**
*
* @author Alexey Andreev
*/
public interface Uint8ClampedArray extends ArrayBufferView {
@JSIndexer
short get(int index);
@JSIndexer
void set(int index, int value);
}