From 07a3233569fae062ad0c9bba20d4327cdade6381 Mon Sep 17 00:00:00 2001 From: Sergey Mashkov Date: Mon, 25 May 2015 12:19:23 +0300 Subject: [PATCH] JS stubs: add CSSOM view specification and GEOMETRY spec --- js/js.libraries/src/core/htmlDom.kt | 8 - .../src/generated/org.w3c.dom.css.kt | 6 +- .../src/generated/org.w3c.dom.events.kt | 30 + js/js.libraries/src/generated/org.w3c.dom.kt | 371 ++++++++++- libraries/idl/org.w3c.dom.idl | 574 ++++++++++++++++++ .../tools/idl2k/src/main/kotlin/config.kt | 2 + .../tools/idl2k/src/main/kotlin/download.kt | 13 +- .../tools/idl2k/src/main/kotlin/render.kt | 6 +- 8 files changed, 996 insertions(+), 14 deletions(-) diff --git a/js/js.libraries/src/core/htmlDom.kt b/js/js.libraries/src/core/htmlDom.kt index 28bdd15d0e9..8a91ec63e4a 100644 --- a/js/js.libraries/src/core/htmlDom.kt +++ b/js/js.libraries/src/core/htmlDom.kt @@ -200,19 +200,11 @@ public native trait HTMLElement : Element { public native var lang: String public native var dir: String public native var style: CSSStyleDeclaration - public native var clientWidth: Double - public native var clientHeight: Double - public native var clientTop: Double - public native var clientLeft: Double public native var offsetWidth: Double public native var offsetHeight: Double public native var offsetTop: Double public native var offsetLeft: Double public native var offsetParent: HTMLElement? - public native var scrollWidth: Double - public native var scrollHeight: Double - public native var scrollTop: Double - public native var scrollLeft: Double public native var stylesheet: Stylesheet public native var onblur: () -> Unit public native var onclick: () -> Unit diff --git a/js/js.libraries/src/generated/org.w3c.dom.css.kt b/js/js.libraries/src/generated/org.w3c.dom.css.kt index 70e56890d5c..622b7574e54 100644 --- a/js/js.libraries/src/generated/org.w3c.dom.css.kt +++ b/js/js.libraries/src/generated/org.w3c.dom.css.kt @@ -869,7 +869,7 @@ native public interface CSSStyleDeclaration { fun removeProperty(property: String): String = noImpl } -native public interface PseudoElement { +native public interface PseudoElement : GeometryNode { var cascadedStyle: CSSStyleDeclaration get() = noImpl set(value) = noImpl @@ -882,6 +882,10 @@ native public interface PseudoElement { var usedStyle: CSSStyleDeclaration get() = noImpl set(value) = noImpl + fun getBoxQuads(options: BoxQuadOptions = noImpl): Array = noImpl + fun convertQuadFromNode(quad: DOMQuad, from: GeometryNode, options: ConvertCoordinateOptions = noImpl): DOMQuad = noImpl + fun convertRectFromNode(rect: DOMRectReadOnly, from: GeometryNode, options: ConvertCoordinateOptions = noImpl): DOMQuad = noImpl + fun convertPointFromNode(point: DOMPointInit, from: GeometryNode, options: ConvertCoordinateOptions = noImpl): DOMPoint = noImpl } native public interface CSS { diff --git a/js/js.libraries/src/generated/org.w3c.dom.events.kt b/js/js.libraries/src/generated/org.w3c.dom.events.kt index 50dd88db376..af234aad1fa 100644 --- a/js/js.libraries/src/generated/org.w3c.dom.events.kt +++ b/js/js.libraries/src/generated/org.w3c.dom.events.kt @@ -56,6 +56,36 @@ native public open class MouseEvent(typeArg: String, mouseEventInitDict: MouseEv var region: String? get() = noImpl set(value) = noImpl +// var screenX: Double +// get() = noImpl +// set(value) = noImpl +// var screenY: Double +// get() = noImpl +// set(value) = noImpl + var pageX: Double + get() = noImpl + set(value) = noImpl + var pageY: Double + get() = noImpl + set(value) = noImpl +// var clientX: Double +// get() = noImpl +// set(value) = noImpl +// var clientY: Double +// get() = noImpl +// set(value) = noImpl +// var x: Double +// get() = noImpl +// set(value) = noImpl +// var y: Double +// get() = noImpl +// set(value) = noImpl + var offsetX: Double + get() = noImpl + set(value) = noImpl + var offsetY: Double + get() = noImpl + set(value) = noImpl fun getModifierState(keyArg: String): Boolean = noImpl fun initMouseEvent(typeArg: String, bubblesArg: Boolean, cancelableArg: Boolean, viewArg: Window?, detailArg: Int, screenXArg: Int, screenYArg: Int, clientXArg: Int, clientYArg: Int, ctrlKeyArg: Boolean, altKeyArg: Boolean, shiftKeyArg: Boolean, metaKeyArg: Boolean, buttonArg: Short, relatedTargetArg: EventTarget?): Unit = noImpl } diff --git a/js/js.libraries/src/generated/org.w3c.dom.kt b/js/js.libraries/src/generated/org.w3c.dom.kt index 77c40526005..bed921e09c6 100644 --- a/js/js.libraries/src/generated/org.w3c.dom.kt +++ b/js/js.libraries/src/generated/org.w3c.dom.kt @@ -67,7 +67,7 @@ native public interface DOMElementMap { nativeSetter fun set(name: String, value: Element): Unit = noImpl } -native public open class Document : Node { +native public open class Document : Node, GeometryNode { var fullscreenEnabled: Boolean get() = noImpl set(value) = noImpl @@ -459,6 +459,9 @@ native public open class Document : Node { fun createTreeWalker(root: Node, whatToShow: Int = noImpl, filter: NodeFilter? = null): TreeWalker = noImpl fun createTreeWalker(root: Node, whatToShow: Int = noImpl, filter: ((Node) -> Short)? = null): TreeWalker = noImpl fun getSelection(): Selection = noImpl + fun elementFromPoint(x: Double, y: Double): Element? = noImpl + fun elementsFromPoint(x: Double, y: Double): Array = noImpl + fun caretPositionFromPoint(x: Double, y: Double): CaretPosition? = noImpl fun getElementById(elementId: String): Element? = noImpl fun prepend(vararg nodes: dynamic): Unit = noImpl fun append(vararg nodes: dynamic): Unit = noImpl @@ -466,6 +469,10 @@ native public open class Document : Node { fun queryAll(relativeSelectors: String): dynamic = noImpl fun querySelector(selectors: String): Element? = noImpl fun querySelectorAll(selectors: String): NodeList = noImpl + fun getBoxQuads(options: BoxQuadOptions = noImpl): Array = noImpl + fun convertQuadFromNode(quad: DOMQuad, from: GeometryNode, options: ConvertCoordinateOptions = noImpl): DOMQuad = noImpl + fun convertRectFromNode(rect: DOMRectReadOnly, from: GeometryNode, options: ConvertCoordinateOptions = noImpl): DOMQuad = noImpl + fun convertPointFromNode(point: DOMPointInit, from: GeometryNode, options: ConvertCoordinateOptions = noImpl): DOMPoint = noImpl } native public open class XMLDocument : Document() { @@ -551,6 +558,21 @@ native public interface HTMLElement : Element { var commandChecked: Boolean? get() = noImpl set(value) = noImpl + var offsetParent: Element? + get() = noImpl + set(value) = noImpl + var offsetTop: Double + get() = noImpl + set(value) = noImpl + var offsetLeft: Double + get() = noImpl + set(value) = noImpl + var offsetWidth: Double + get() = noImpl + set(value) = noImpl + var offsetHeight: Double + get() = noImpl + set(value) = noImpl var onabort: ((Event) -> dynamic)? get() = noImpl set(value) = noImpl @@ -3098,6 +3120,42 @@ native public interface Window : EventTarget, UnionMessagePortOrWindow { var applicationCache: ApplicationCache get() = noImpl set(value) = noImpl + var screen: Screen + get() = noImpl + set(value) = noImpl + var innerWidth: Double + get() = noImpl + set(value) = noImpl + var innerHeight: Double + get() = noImpl + set(value) = noImpl + var scrollX: Double + get() = noImpl + set(value) = noImpl + var pageXOffset: Double + get() = noImpl + set(value) = noImpl + var scrollY: Double + get() = noImpl + set(value) = noImpl + var pageYOffset: Double + get() = noImpl + set(value) = noImpl + var screenX: Double + get() = noImpl + set(value) = noImpl + var screenY: Double + get() = noImpl + set(value) = noImpl + var outerWidth: Double + get() = noImpl + set(value) = noImpl + var outerHeight: Double + get() = noImpl + set(value) = noImpl + var devicePixelRatio: Double + get() = noImpl + set(value) = noImpl var onabort: ((Event) -> dynamic)? get() = noImpl set(value) = noImpl @@ -3352,6 +3410,14 @@ native public interface Window : EventTarget, UnionMessagePortOrWindow { fun captureEvents(): Unit = noImpl fun releaseEvents(): Unit = noImpl fun getSelection(): Selection = noImpl + fun matchMedia(query: String): MediaQueryList = noImpl + fun moveTo(x: Double, y: Double): Unit = noImpl + fun moveBy(x: Double, y: Double): Unit = noImpl + fun resizeTo(x: Double, y: Double): Unit = noImpl + fun resizeBy(x: Double, y: Double): Unit = noImpl + fun scroll(x: Double, y: Double, options: ScrollOptions = noImpl): Unit = noImpl + fun scrollTo(x: Double, y: Double, options: ScrollOptions = noImpl): Unit = noImpl + fun scrollBy(x: Double, y: Double, options: ScrollOptions = noImpl): Unit = noImpl fun btoa(btoa: String): String = noImpl fun atob(atob: String): String = noImpl fun setTimeout(handler: () -> dynamic, timeout: Int = 0, vararg arguments: Any?): Int = noImpl @@ -4187,6 +4253,12 @@ native public interface HTMLImageElement : HTMLElement, CanvasImageSource, Image var currentSrc: String get() = noImpl set(value) = noImpl + var x: Double + get() = noImpl + set(value) = noImpl + var y: Double + get() = noImpl + set(value) = noImpl } native public interface HTMLPictureElement : HTMLElement { @@ -4393,7 +4465,7 @@ native public interface DocumentType : Node { fun remove(): Unit = noImpl } -native public interface Element : Node, UnionElementOrHTMLCollection, UnionElementOrRadioNodeList, UnionElementOrMouseEvent, UnionElementOrProcessingInstruction { +native public interface Element : Node, UnionElementOrHTMLCollection, UnionElementOrRadioNodeList, UnionElementOrMouseEvent, UnionElementOrProcessingInstruction, GeometryNode { var innerHTML: String get() = noImpl set(value) = noImpl @@ -4424,6 +4496,30 @@ native public interface Element : Node, UnionElementOrHTMLCollection, UnionEleme var attributes: NamedNodeMap get() = noImpl set(value) = noImpl + var scrollTop: dynamic + get() = noImpl + set(value) = noImpl + var scrollLeft: dynamic + get() = noImpl + set(value) = noImpl + var scrollWidth: Double + get() = noImpl + set(value) = noImpl + var scrollHeight: Double + get() = noImpl + set(value) = noImpl + var clientTop: Double + get() = noImpl + set(value) = noImpl + var clientLeft: Double + get() = noImpl + set(value) = noImpl + var clientWidth: Double + get() = noImpl + set(value) = noImpl + var clientHeight: Double + get() = noImpl + set(value) = noImpl var children: HTMLCollection get() = noImpl set(value) = noImpl @@ -4476,6 +4572,10 @@ native public interface Element : Node, UnionElementOrHTMLCollection, UnionEleme fun getElementsByTagName(localName: String): HTMLCollection = noImpl fun getElementsByTagNameNS(namespace: String?, localName: String): HTMLCollection = noImpl fun getElementsByClassName(classNames: String): HTMLCollection = noImpl + fun getClientRects(): dynamic = noImpl + fun getBoundingClientRect(): DOMRect = noImpl + fun scrollIntoView(): Unit = noImpl + fun scrollIntoView(top: Boolean, options: ScrollOptions = noImpl): Unit = noImpl fun prepend(vararg nodes: dynamic): Unit = noImpl fun append(vararg nodes: dynamic): Unit = noImpl fun query(relativeSelectors: String): Element? = noImpl @@ -4486,6 +4586,10 @@ native public interface Element : Node, UnionElementOrHTMLCollection, UnionEleme fun after(vararg nodes: dynamic): Unit = noImpl fun replaceWith(vararg nodes: dynamic): Unit = noImpl fun remove(): Unit = noImpl + fun getBoxQuads(options: BoxQuadOptions = noImpl): Array = noImpl + fun convertQuadFromNode(quad: DOMQuad, from: GeometryNode, options: ConvertCoordinateOptions = noImpl): DOMQuad = noImpl + fun convertRectFromNode(rect: DOMRectReadOnly, from: GeometryNode, options: ConvertCoordinateOptions = noImpl): DOMQuad = noImpl + fun convertPointFromNode(point: DOMPointInit, from: GeometryNode, options: ConvertCoordinateOptions = noImpl): DOMPoint = noImpl } native public interface NamedNodeMap { @@ -4557,11 +4661,15 @@ native public interface CharacterData : Node { fun remove(): Unit = noImpl } -native public open class Text(data: String = "") : CharacterData { +native public open class Text(data: String = "") : CharacterData, GeometryNode { var wholeText: String get() = noImpl set(value) = noImpl fun splitText(offset: Int): Text = noImpl + fun getBoxQuads(options: BoxQuadOptions = noImpl): Array = noImpl + fun convertQuadFromNode(quad: DOMQuad, from: GeometryNode, options: ConvertCoordinateOptions = noImpl): DOMQuad = noImpl + fun convertRectFromNode(rect: DOMRectReadOnly, from: GeometryNode, options: ConvertCoordinateOptions = noImpl): DOMQuad = noImpl + fun convertPointFromNode(point: DOMPointInit, from: GeometryNode, options: ConvertCoordinateOptions = noImpl): DOMPoint = noImpl } native public interface ProcessingInstruction : CharacterData, UnionElementOrProcessingInstruction { @@ -4616,6 +4724,8 @@ native public open class Range { fun isPointInRange(node: Node, offset: Int): Boolean = noImpl fun comparePoint(node: Node, offset: Int): Short = noImpl fun intersectsNode(node: Node): Boolean = noImpl + fun getClientRects(): dynamic = noImpl + fun getBoundingClientRect(): DOMRect = noImpl companion object { val START_TO_START: Short = 0 @@ -4768,6 +4878,258 @@ native public open class EditingInputEventInit : EventInit() { var value: String } +native public open class DOMPointReadOnly(x: Double, y: Double, z: Double, w: Double) { + var x: Double + get() = noImpl + set(value) = noImpl + var y: Double + get() = noImpl + set(value) = noImpl + var z: Double + get() = noImpl + set(value) = noImpl + var w: Double + get() = noImpl + set(value) = noImpl + fun matrixTransform(matrix: DOMMatrixReadOnly): DOMPoint = noImpl +} + +native public open class DOMPoint(point: DOMPointInit = noImpl) : DOMPointReadOnly(noImpl, noImpl, noImpl, noImpl) { +} + +native public open class DOMPointInit { + var x: Double = 0.0 + var y: Double = 0.0 + var z: Double = 0.0 + var w: Double = 1.0 +} + +native public open class DOMRect(x: Double = 0.0, y: Double = 0.0, width: Double = 0.0, height: Double = 0.0) : DOMRectReadOnly(x, y, width, height) { +} + +native public open class DOMRectReadOnly(x: Double, y: Double, width: Double, height: Double) { + var x: Double + get() = noImpl + set(value) = noImpl + var y: Double + get() = noImpl + set(value) = noImpl + var width: Double + get() = noImpl + set(value) = noImpl + var height: Double + get() = noImpl + set(value) = noImpl + var top: Double + get() = noImpl + set(value) = noImpl + var right: Double + get() = noImpl + set(value) = noImpl + var bottom: Double + get() = noImpl + set(value) = noImpl + var left: Double + get() = noImpl + set(value) = noImpl +} + +native public open class DOMRectInit { + var x: Double = 0.0 + var y: Double = 0.0 + var width: Double = 0.0 + var height: Double = 0.0 +} + +native public open class DOMQuad(p1: DOMPointInit = noImpl, p2: DOMPointInit = noImpl, p3: DOMPointInit = noImpl, p4: DOMPointInit = noImpl) { + var p1: DOMPoint + get() = noImpl + set(value) = noImpl + var p2: DOMPoint + get() = noImpl + set(value) = noImpl + var p3: DOMPoint + get() = noImpl + set(value) = noImpl + var p4: DOMPoint + get() = noImpl + set(value) = noImpl + var bounds: DOMRectReadOnly + get() = noImpl + set(value) = noImpl +} + +native public open class DOMMatrixReadOnly(numberSequence: Array) { + var a: Double + get() = noImpl + set(value) = noImpl + var b: Double + get() = noImpl + set(value) = noImpl + var c: Double + get() = noImpl + set(value) = noImpl + var d: Double + get() = noImpl + set(value) = noImpl + var e: Double + get() = noImpl + set(value) = noImpl + var f: Double + get() = noImpl + set(value) = noImpl + var m11: Double + get() = noImpl + set(value) = noImpl + var m12: Double + get() = noImpl + set(value) = noImpl + var m13: Double + get() = noImpl + set(value) = noImpl + var m14: Double + get() = noImpl + set(value) = noImpl + var m21: Double + get() = noImpl + set(value) = noImpl + var m22: Double + get() = noImpl + set(value) = noImpl + var m23: Double + get() = noImpl + set(value) = noImpl + var m24: Double + get() = noImpl + set(value) = noImpl + var m31: Double + get() = noImpl + set(value) = noImpl + var m32: Double + get() = noImpl + set(value) = noImpl + var m33: Double + get() = noImpl + set(value) = noImpl + var m34: Double + get() = noImpl + set(value) = noImpl + var m41: Double + get() = noImpl + set(value) = noImpl + var m42: Double + get() = noImpl + set(value) = noImpl + var m43: Double + get() = noImpl + set(value) = noImpl + var m44: Double + get() = noImpl + set(value) = noImpl + var is2D: Boolean + get() = noImpl + set(value) = noImpl + var isIdentity: Boolean + get() = noImpl + set(value) = noImpl + fun translate(tx: Double, ty: Double, tz: Double = 0.0): DOMMatrix = noImpl + fun scale(scale: Double, originX: Double = 0.0, originY: Double = 0.0): DOMMatrix = noImpl + fun scale3d(scale: Double, originX: Double = 0.0, originY: Double = 0.0, originZ: Double = 0.0): DOMMatrix = noImpl + fun scaleNonUniform(scaleX: Double, scaleY: Double = 1.0, scaleZ: Double = 1.0, originX: Double = 0.0, originY: Double = 0.0, originZ: Double = 0.0): DOMMatrix = noImpl + fun rotate(angle: Double, originX: Double = 0.0, originY: Double = 0.0): DOMMatrix = noImpl + fun rotateFromVector(x: Double, y: Double): DOMMatrix = noImpl + fun rotateAxisAngle(x: Double, y: Double, z: Double, angle: Double): DOMMatrix = noImpl + fun skewX(sx: Double): DOMMatrix = noImpl + fun skewY(sy: Double): DOMMatrix = noImpl + fun multiply(other: DOMMatrix): DOMMatrix = noImpl + fun flipX(): DOMMatrix = noImpl + fun flipY(): DOMMatrix = noImpl + fun inverse(): DOMMatrix = noImpl + fun transformPoint(point: DOMPointInit = noImpl): DOMPoint = noImpl + fun toFloat32Array(): Float32Array = noImpl + fun toFloat64Array(): Float64Array = noImpl +} + +native public open class DOMMatrix : DOMMatrixReadOnly(noImpl) { + fun multiplySelf(other: DOMMatrix): DOMMatrix = noImpl + fun preMultiplySelf(other: DOMMatrix): DOMMatrix = noImpl + fun translateSelf(tx: Double, ty: Double, tz: Double = 0.0): DOMMatrix = noImpl + fun scaleSelf(scale: Double, originX: Double = 0.0, originY: Double = 0.0): DOMMatrix = noImpl + fun scale3dSelf(scale: Double, originX: Double = 0.0, originY: Double = 0.0, originZ: Double = 0.0): DOMMatrix = noImpl + fun scaleNonUniformSelf(scaleX: Double, scaleY: Double = 1.0, scaleZ: Double = 1.0, originX: Double = 0.0, originY: Double = 0.0, originZ: Double = 0.0): DOMMatrix = noImpl + fun rotateSelf(angle: Double, originX: Double = 0.0, originY: Double = 0.0): DOMMatrix = noImpl + fun rotateFromVectorSelf(x: Double, y: Double): DOMMatrix = noImpl + fun rotateAxisAngleSelf(x: Double, y: Double, z: Double, angle: Double): DOMMatrix = noImpl + fun skewXSelf(sx: Double): DOMMatrix = noImpl + fun skewYSelf(sy: Double): DOMMatrix = noImpl + fun invertSelf(): DOMMatrix = noImpl + fun setMatrixValue(transformList: String): DOMMatrix = noImpl +} + +native public open class ScrollOptions { + var behavior: String = "auto" +} + +native public interface MediaQueryList { + var media: String + get() = noImpl + set(value) = noImpl + var matches: Boolean + get() = noImpl + set(value) = noImpl + fun addListener(listener: (MediaQueryList) -> Unit): Unit = noImpl + fun removeListener(listener: (MediaQueryList) -> Unit): Unit = noImpl +} + +native public interface Screen { + var availWidth: Double + get() = noImpl + set(value) = noImpl + var availHeight: Double + get() = noImpl + set(value) = noImpl + var width: Double + get() = noImpl + set(value) = noImpl + var height: Double + get() = noImpl + set(value) = noImpl + var colorDepth: Int + get() = noImpl + set(value) = noImpl + var pixelDepth: Int + get() = noImpl + set(value) = noImpl +} + +native public interface CaretPosition { + var offsetNode: Node + get() = noImpl + set(value) = noImpl + var offset: Int + get() = noImpl + set(value) = noImpl + fun getClientRect(): DOMRect? = noImpl +} + +native public open class ScrollOptionsHorizontal : ScrollOptions() { + var x: Double +} + +native public open class ScrollOptionsVertical : ScrollOptions() { + var y: Double +} + +native public open class BoxQuadOptions { + var box: String = "border" + var relativeTo: GeometryNode +} + +native public open class ConvertCoordinateOptions { + var fromBox: String = "border" + var toBox: String = "border" +} + native public marker interface UnionElementOrHTMLCollection { } @@ -4804,3 +5166,6 @@ native public marker interface CanvasImageSource { native public marker interface ImageBitmapSource { } +native public marker interface GeometryNode { +} + diff --git a/libraries/idl/org.w3c.dom.idl b/libraries/idl/org.w3c.dom.idl index 0fffd391766..962b07f3808 100644 --- a/libraries/idl/org.w3c.dom.idl +++ b/libraries/idl/org.w3c.dom.idl @@ -5111,4 +5111,578 @@ partial interface Window { }; callback FrameRequestCallback = void (DOMHighResTimeStamp time); +// Downloaded from http://www.w3.org/TR/geometry-1/ +[Constructor(unrestricted double x, unrestricted double y, + unrestricted double z, unrestricted double w), + Exposed=(Window,Worker)] +interface DOMPointReadOnly { + readonly attribute unrestricted double x; + readonly attribute unrestricted double y; + readonly attribute unrestricted double z; + readonly attribute unrestricted double w; + + DOMPoint matrixTransform(DOMMatrixReadOnly matrix); +}; + +[Constructor(optional DOMPointInit point), + Constructor(optional unrestricted double x = 0, optional unrestricted double y = 0, + optional unrestricted double z = 0, optional unrestricted double w = 1), + Exposed=(Window,Worker)] +interface DOMPoint : DOMPointReadOnly { + inherit attribute unrestricted double x; + inherit attribute unrestricted double y; + inherit attribute unrestricted double z; + inherit attribute unrestricted double w; +}; + +dictionary DOMPointInit { + unrestricted double x = 0; + unrestricted double y = 0; + unrestricted double z = 0; + unrestricted double w = 1; +}; +[Constructor(unrestricted double x = 0, unrestricted double y = 0, + unrestricted double width = 0, unrestricted double height = 0), + Exposed=(Window,Worker)] +interface DOMRect : DOMRectReadOnly { + inherit attribute unrestricted double x; + inherit attribute unrestricted double y; + inherit attribute unrestricted double width; + inherit attribute unrestricted double height; +}; + +[Constructor(unrestricted double x, unrestricted double y, + unrestricted double width, unrestricted double height), + Exposed=(Window,Worker)] +interface DOMRectReadOnly { + readonly attribute unrestricted double x; + readonly attribute unrestricted double y; + readonly attribute unrestricted double width; + readonly attribute unrestricted double height; + readonly attribute unrestricted double top; + readonly attribute unrestricted double right; + readonly attribute unrestricted double bottom; + readonly attribute unrestricted double left; +}; + +dictionary DOMRectInit { + unrestricted double x = 0; + unrestricted double y = 0; + unrestricted double width = 0; + unrestricted double height = 0; +}; +[NoInterfaceObject, + ArrayClass] +interface DOMRectList { + readonly attribute unsigned long length; + getter DOMRect? item(unsigned long index); +}; +[Constructor(optional DOMPointInit p1, optional DOMPointInit p2, + optional DOMPointInit p3, optional DOMPointInit p4), + Constructor(optional DOMRectInit rect), + Exposed=(Window,Worker)] +interface DOMQuad { + [SameObject] readonly attribute DOMPoint p1; + [SameObject] readonly attribute DOMPoint p2; + [SameObject] readonly attribute DOMPoint p3; + [SameObject] readonly attribute DOMPoint p4; + [SameObject] readonly attribute DOMRectReadOnly bounds; +}; +[Constructor(sequence numberSequence), + Exposed=(Window,Worker)] +interface DOMMatrixReadOnly { + // These attributes are simple aliases for certain elements of the 4x4 matrix + readonly attribute unrestricted double a; + readonly attribute unrestricted double b; + readonly attribute unrestricted double c; + readonly attribute unrestricted double d; + readonly attribute unrestricted double e; + readonly attribute unrestricted double f; + + readonly attribute unrestricted double m11; + readonly attribute unrestricted double m12; + readonly attribute unrestricted double m13; + readonly attribute unrestricted double m14; + readonly attribute unrestricted double m21; + readonly attribute unrestricted double m22; + readonly attribute unrestricted double m23; + readonly attribute unrestricted double m24; + readonly attribute unrestricted double m31; + readonly attribute unrestricted double m32; + readonly attribute unrestricted double m33; + readonly attribute unrestricted double m34; + readonly attribute unrestricted double m41; + readonly attribute unrestricted double m42; + readonly attribute unrestricted double m43; + readonly attribute unrestricted double m44; + + readonly attribute boolean is2D; + readonly attribute boolean isIdentity; + + // Immutable transform methods + DOMMatrix translate(unrestricted double tx, + unrestricted double ty, + optional unrestricted double tz = 0); + DOMMatrix scale(unrestricted double scale, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0); + DOMMatrix scale3d(unrestricted double scale, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0, + optional unrestricted double originZ = 0); + DOMMatrix scaleNonUniform(unrestricted double scaleX, + optional unrestricted double scaleY = 1, + optional unrestricted double scaleZ = 1, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0, + optional unrestricted double originZ = 0); + DOMMatrix rotate(unrestricted double angle, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0); + DOMMatrix rotateFromVector(unrestricted double x, + unrestricted double y); + DOMMatrix rotateAxisAngle(unrestricted double x, + unrestricted double y, + unrestricted double z, + unrestricted double angle); + DOMMatrix skewX(unrestricted double sx); + DOMMatrix skewY(unrestricted double sy); + DOMMatrix multiply(DOMMatrix other); + DOMMatrix flipX(); + DOMMatrix flipY(); + DOMMatrix inverse(); + + DOMPoint transformPoint(optional DOMPointInit point); + Float32Array toFloat32Array(); + Float64Array toFloat64Array(); + stringifier; +}; + +[Constructor, + Constructor(DOMString transformList), + Constructor(DOMMatrixReadOnly other), + Constructor(Float32Array array32), + Constructor(Float64Array array64), + Constructor(sequence numberSequence), + Exposed=(Window,Worker)] +interface DOMMatrix : DOMMatrixReadOnly { + // These attributes are simple aliases for certain elements of the 4x4 matrix + inherit attribute unrestricted double a; + inherit attribute unrestricted double b; + inherit attribute unrestricted double c; + inherit attribute unrestricted double d; + inherit attribute unrestricted double e; + inherit attribute unrestricted double f; + + inherit attribute unrestricted double m11; + inherit attribute unrestricted double m12; + inherit attribute unrestricted double m13; + inherit attribute unrestricted double m14; + inherit attribute unrestricted double m21; + inherit attribute unrestricted double m22; + inherit attribute unrestricted double m23; + inherit attribute unrestricted double m24; + inherit attribute unrestricted double m31; + inherit attribute unrestricted double m32; + inherit attribute unrestricted double m33; + inherit attribute unrestricted double m34; + inherit attribute unrestricted double m41; + inherit attribute unrestricted double m42; + inherit attribute unrestricted double m43; + inherit attribute unrestricted double m44; + + // Mutable transform methods + DOMMatrix multiplySelf(DOMMatrix other); + DOMMatrix preMultiplySelf(DOMMatrix other); + DOMMatrix translateSelf(unrestricted double tx, + unrestricted double ty, + optional unrestricted double tz = 0); + DOMMatrix scaleSelf(unrestricted double scale, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0); + DOMMatrix scale3dSelf(unrestricted double scale, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0, + optional unrestricted double originZ = 0); + DOMMatrix scaleNonUniformSelf(unrestricted double scaleX, + optional unrestricted double scaleY = 1, + optional unrestricted double scaleZ = 1, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0, + optional unrestricted double originZ = 0); + DOMMatrix rotateSelf(unrestricted double angle, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0); + DOMMatrix rotateFromVectorSelf(unrestricted double x, + unrestricted double y); + DOMMatrix rotateAxisAngleSelf(unrestricted double x, + unrestricted double y, + unrestricted double z, + unrestricted double angle); + DOMMatrix skewXSelf(unrestricted double sx); + DOMMatrix skewYSelf(unrestricted double sy); + DOMMatrix invertSelf(); + + DOMMatrix setMatrixValue(DOMString transformList); +}; +[Constructor(unrestricted double x, unrestricted double y, + unrestricted double z, unrestricted double w), + Exposed=(Window,Worker)] +interface DOMPointReadOnly { + readonly attribute unrestricted double x; + readonly attribute unrestricted double y; + readonly attribute unrestricted double z; + readonly attribute unrestricted double w; + + DOMPoint matrixTransform(DOMMatrixReadOnly matrix); +}; + +[Constructor(optional DOMPointInit point), + Constructor(optional unrestricted double x = 0, optional unrestricted double y = 0, + optional unrestricted double z = 0, optional unrestricted double w = 1), + Exposed=(Window,Worker)] +interface DOMPoint : DOMPointReadOnly { + inherit attribute unrestricted double x; + inherit attribute unrestricted double y; + inherit attribute unrestricted double z; + inherit attribute unrestricted double w; +}; + +dictionary DOMPointInit { + unrestricted double x = 0; + unrestricted double y = 0; + unrestricted double z = 0; + unrestricted double w = 1; +}; + +[Constructor(unrestricted double x = 0, unrestricted double y = 0, + unrestricted double width = 0, unrestricted double height = 0), + Exposed=(Window,Worker)] +interface DOMRect : DOMRectReadOnly { + inherit attribute unrestricted double x; + inherit attribute unrestricted double y; + inherit attribute unrestricted double width; + inherit attribute unrestricted double height; +}; + +[Constructor(unrestricted double x, unrestricted double y, + unrestricted double width, unrestricted double height), + Exposed=(Window,Worker)] +interface DOMRectReadOnly { + readonly attribute unrestricted double x; + readonly attribute unrestricted double y; + readonly attribute unrestricted double width; + readonly attribute unrestricted double height; + readonly attribute unrestricted double top; + readonly attribute unrestricted double right; + readonly attribute unrestricted double bottom; + readonly attribute unrestricted double left; +}; + +dictionary DOMRectInit { + unrestricted double x = 0; + unrestricted double y = 0; + unrestricted double width = 0; + unrestricted double height = 0; +}; + +[NoInterfaceObject, + ArrayClass] +interface DOMRectList { + readonly attribute unsigned long length; + getter DOMRect? item(unsigned long index); +}; + +[Constructor(optional DOMPointInit p1, optional DOMPointInit p2, + optional DOMPointInit p3, optional DOMPointInit p4), + Constructor(optional DOMRectInit rect), + Exposed=(Window,Worker)] +interface DOMQuad { + [SameObject] readonly attribute DOMPoint p1; + [SameObject] readonly attribute DOMPoint p2; + [SameObject] readonly attribute DOMPoint p3; + [SameObject] readonly attribute DOMPoint p4; + [SameObject] readonly attribute DOMRectReadOnly bounds; +}; + +[Constructor(sequence numberSequence), + Exposed=(Window,Worker)] +interface DOMMatrixReadOnly { + // These attributes are simple aliases for certain elements of the 4x4 matrix + readonly attribute unrestricted double a; + readonly attribute unrestricted double b; + readonly attribute unrestricted double c; + readonly attribute unrestricted double d; + readonly attribute unrestricted double e; + readonly attribute unrestricted double f; + + readonly attribute unrestricted double m11; + readonly attribute unrestricted double m12; + readonly attribute unrestricted double m13; + readonly attribute unrestricted double m14; + readonly attribute unrestricted double m21; + readonly attribute unrestricted double m22; + readonly attribute unrestricted double m23; + readonly attribute unrestricted double m24; + readonly attribute unrestricted double m31; + readonly attribute unrestricted double m32; + readonly attribute unrestricted double m33; + readonly attribute unrestricted double m34; + readonly attribute unrestricted double m41; + readonly attribute unrestricted double m42; + readonly attribute unrestricted double m43; + readonly attribute unrestricted double m44; + + readonly attribute boolean is2D; + readonly attribute boolean isIdentity; + + // Immutable transform methods + DOMMatrix translate(unrestricted double tx, + unrestricted double ty, + optional unrestricted double tz = 0); + DOMMatrix scale(unrestricted double scale, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0); + DOMMatrix scale3d(unrestricted double scale, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0, + optional unrestricted double originZ = 0); + DOMMatrix scaleNonUniform(unrestricted double scaleX, + optional unrestricted double scaleY = 1, + optional unrestricted double scaleZ = 1, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0, + optional unrestricted double originZ = 0); + DOMMatrix rotate(unrestricted double angle, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0); + DOMMatrix rotateFromVector(unrestricted double x, + unrestricted double y); + DOMMatrix rotateAxisAngle(unrestricted double x, + unrestricted double y, + unrestricted double z, + unrestricted double angle); + DOMMatrix skewX(unrestricted double sx); + DOMMatrix skewY(unrestricted double sy); + DOMMatrix multiply(DOMMatrix other); + DOMMatrix flipX(); + DOMMatrix flipY(); + DOMMatrix inverse(); + + DOMPoint transformPoint(optional DOMPointInit point); + Float32Array toFloat32Array(); + Float64Array toFloat64Array(); + stringifier; +}; + +[Constructor, + Constructor(DOMString transformList), + Constructor(DOMMatrixReadOnly other), + Constructor(Float32Array array32), + Constructor(Float64Array array64), + Constructor(sequence numberSequence), + Exposed=(Window,Worker)] +interface DOMMatrix : DOMMatrixReadOnly { + // These attributes are simple aliases for certain elements of the 4x4 matrix + inherit attribute unrestricted double a; + inherit attribute unrestricted double b; + inherit attribute unrestricted double c; + inherit attribute unrestricted double d; + inherit attribute unrestricted double e; + inherit attribute unrestricted double f; + + inherit attribute unrestricted double m11; + inherit attribute unrestricted double m12; + inherit attribute unrestricted double m13; + inherit attribute unrestricted double m14; + inherit attribute unrestricted double m21; + inherit attribute unrestricted double m22; + inherit attribute unrestricted double m23; + inherit attribute unrestricted double m24; + inherit attribute unrestricted double m31; + inherit attribute unrestricted double m32; + inherit attribute unrestricted double m33; + inherit attribute unrestricted double m34; + inherit attribute unrestricted double m41; + inherit attribute unrestricted double m42; + inherit attribute unrestricted double m43; + inherit attribute unrestricted double m44; + + // Mutable transform methods + DOMMatrix multiplySelf(DOMMatrix other); + DOMMatrix preMultiplySelf(DOMMatrix other); + DOMMatrix translateSelf(unrestricted double tx, + unrestricted double ty, + optional unrestricted double tz = 0); + DOMMatrix scaleSelf(unrestricted double scale, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0); + DOMMatrix scale3dSelf(unrestricted double scale, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0, + optional unrestricted double originZ = 0); + DOMMatrix scaleNonUniformSelf(unrestricted double scaleX, + optional unrestricted double scaleY = 1, + optional unrestricted double scaleZ = 1, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0, + optional unrestricted double originZ = 0); + DOMMatrix rotateSelf(unrestricted double angle, + optional unrestricted double originX = 0, + optional unrestricted double originY = 0); + DOMMatrix rotateFromVectorSelf(unrestricted double x, + unrestricted double y); + DOMMatrix rotateAxisAngleSelf(unrestricted double x, + unrestricted double y, + unrestricted double z, + unrestricted double angle); + DOMMatrix skewXSelf(unrestricted double sx); + DOMMatrix skewYSelf(unrestricted double sy); + DOMMatrix invertSelf(); + + DOMMatrix setMatrixValue(DOMString transformList); +}; +// Downloaded from http://www.w3.org/TR/cssom-view/ +enum ScrollBehavior { "auto", "instant", "smooth" }; + +dictionary ScrollOptions { + ScrollBehavior behavior = "auto"; +}; + +partial interface Window { + MediaQueryList matchMedia(DOMString query); + [SameObject] readonly attribute Screen screen; + + // browsing context + void moveTo(double x, double y); + void moveBy(double x, double y); + void resizeTo(double x, double y); + void resizeBy(double x, double y); + + // viewport + readonly attribute double innerWidth; + readonly attribute double innerHeight; + + // viewport scrolling + readonly attribute double scrollX; + readonly attribute double pageXOffset; + readonly attribute double scrollY; + readonly attribute double pageYOffset; + void scroll(double x, double y, optional ScrollOptions options); + void scrollTo(double x, double y, optional ScrollOptions options); + void scrollBy(double x, double y, optional ScrollOptions options); + + // client + readonly attribute double screenX; + readonly attribute double screenY; + readonly attribute double outerWidth; + readonly attribute double outerHeight; + readonly attribute double devicePixelRatio; +}; +interface MediaQueryList { + readonly attribute DOMString media; + readonly attribute boolean matches; + void addListener(MediaQueryListListener listener); + void removeListener(MediaQueryListListener listener); +}; + +callback MediaQueryListListener = void (MediaQueryList list); +interface Screen { + readonly attribute double availWidth; + readonly attribute double availHeight; + readonly attribute double width; + readonly attribute double height; + readonly attribute unsigned long colorDepth; + readonly attribute unsigned long pixelDepth; +}; +partial interface Document { + Element? elementFromPoint(double x, double y); + sequence elementsFromPoint(double x, double y); + CaretPosition? caretPositionFromPoint(double x, double y); +}; +interface CaretPosition { + readonly attribute Node offsetNode; + readonly attribute unsigned long offset; + DOMRect? getClientRect(); +}; +dictionary ScrollOptionsHorizontal : ScrollOptions { + double x; +}; +dictionary ScrollOptionsVertical : ScrollOptions { + double y; +}; + +partial interface Element { + DOMRectList getClientRects(); + DOMRect getBoundingClientRect(); + void scrollIntoView(); + void scrollIntoView(boolean top, optional ScrollOptions options); + attribute (double or ScrollOptionsVertical) scrollTop; + attribute (double or ScrollOptionsHorizontal) scrollLeft; + readonly attribute double scrollWidth; + readonly attribute double scrollHeight; + readonly attribute double clientTop; + readonly attribute double clientLeft; + readonly attribute double clientWidth; + readonly attribute double clientHeight; +}; +partial interface HTMLElement { + readonly attribute Element? offsetParent; + readonly attribute double offsetTop; + readonly attribute double offsetLeft; + readonly attribute double offsetWidth; + readonly attribute double offsetHeight; +}; +partial interface HTMLImageElement { + readonly attribute double x; + readonly attribute double y; +}; +partial interface Range { + DOMRectList getClientRects(); + DOMRect getBoundingClientRect(); +}; +partial interface MouseEvent { + readonly attribute double screenX; + readonly attribute double screenY; + readonly attribute double pageX; + readonly attribute double pageY; + readonly attribute double clientX; + readonly attribute double clientY; + readonly attribute double x; + readonly attribute double y; + readonly attribute double offsetX; + readonly attribute double offsetY; +}; + +partial dictionary MouseEventInit { + double screenX = 0.0; + double screenY = 0.0; + double clientX = 0.0; + double clientY = 0.0; +}; +enum CSSBoxType { "margin", "border", "padding", "content" }; +dictionary BoxQuadOptions { + CSSBoxType box = "border"; + GeometryNode relativeTo; +}; + +dictionary ConvertCoordinateOptions { + CSSBoxType fromBox = "border"; + CSSBoxType toBox = "border"; +}; + +[NoInterfaceObject] +interface GeometryUtils { + sequence getBoxQuads(optional BoxQuadOptions options); + DOMQuad convertQuadFromNode(DOMQuad quad, GeometryNode from, optional ConvertCoordinateOptions options); + DOMQuad convertRectFromNode(DOMRectReadOnly rect, GeometryNode from, optional ConvertCoordinateOptions options); + DOMPoint convertPointFromNode(DOMPointInit point, GeometryNode from, optional ConvertCoordinateOptions options); +}; + +Text implements GeometryUtils; +Element implements GeometryUtils; +PseudoElement implements GeometryUtils; +Document implements GeometryUtils; + +typedef (Text or Element or PseudoElement or Document) GeometryNode; diff --git a/libraries/tools/idl2k/src/main/kotlin/config.kt b/libraries/tools/idl2k/src/main/kotlin/config.kt index 88da99553bf..3c80867aa85 100644 --- a/libraries/tools/idl2k/src/main/kotlin/config.kt +++ b/libraries/tools/idl2k/src/main/kotlin/config.kt @@ -21,6 +21,8 @@ val urls = listOf( "https://raw.githubusercontent.com/whatwg/dom/master/dom.html" to "org.w3c.dom", "https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html" to "org.w3c.dom", "http://www.w3.org/TR/animation-timing/" to "org.w3c.dom", + "http://www.w3.org/TR/geometry-1/" to "org.w3c.dom", + "http://www.w3.org/TR/cssom-view/" to "org.w3c.dom", "http://www.w3.org/TR/uievents/" to "org.w3c.dom.events", "http://dev.w3.org/csswg/cssom/" to "org.w3c.dom.css", "http://www.w3.org/TR/DOM-Parsing/" to "org.w3c.dom.parsing", diff --git a/libraries/tools/idl2k/src/main/kotlin/download.kt b/libraries/tools/idl2k/src/main/kotlin/download.kt index 0e07396c6ee..2347cd9b411 100644 --- a/libraries/tools/idl2k/src/main/kotlin/download.kt +++ b/libraries/tools/idl2k/src/main/kotlin/download.kt @@ -27,7 +27,18 @@ fun main(args: Array) { val dir = File("../../idl") dir.mkdirs() - val urlsPerFiles = urls.groupBy { it.second + ".idl" } + var packageFilter: String? = null + val argsIterator = args.iterator() + while (argsIterator.hasNext()) { + val arg = argsIterator.next() + + when (arg) { + "-package", "-pkg", "--package" -> if (argsIterator.hasNext()) packageFilter = argsIterator.next() else throw IllegalArgumentException("argument $arg requires argument") + else -> throw IllegalArgumentException("Argument $arg is unknown") + } + } + + val urlsPerFiles = urls.filter { packageFilter == null || it.second == packageFilter }.groupBy { it.second + ".idl" } urlsPerFiles.forEach { e -> val fileName = e.key diff --git a/libraries/tools/idl2k/src/main/kotlin/render.kt b/libraries/tools/idl2k/src/main/kotlin/render.kt index 338bfaa2c6e..70aff29fe80 100644 --- a/libraries/tools/idl2k/src/main/kotlin/render.kt +++ b/libraries/tools/idl2k/src/main/kotlin/render.kt @@ -39,7 +39,11 @@ private fun Appendable.renderAttributeDeclaration(arg: GenerateAttribute, overri private val keywords = setOf("interface") private fun String.parse() = if (this.startsWith("0x")) BigInteger(this.substring(2), 16) else BigInteger(this) -private fun String.replaceWrongConstants(type: String) = if (this == "noImpl" || type == "Int" && parse() > BigInteger.valueOf(Int.MAX_VALUE.toLong())) "noImpl" else this +private fun String.replaceWrongConstants(type: String) = when { + this == "noImpl" || type == "Int" && parse() > BigInteger.valueOf(Int.MAX_VALUE.toLong()) -> "noImpl" + type == "Double" && this.matches("[0-9]+".toRegex()) -> "${this}.0" + else -> this +} private fun String.replaceKeywords() = if (this in keywords) this + "_" else this private fun Appendable.renderArgumentsDeclaration(args: List, omitDefaults: Boolean) =