Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
cd0bc436
K
kotlin
项目概览
硅谷海盗
/
kotlin
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kotlin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
cd0bc436
编写于
5月 31, 2012
作者:
P
pTalanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adding an early version of js dom library. Fancy lines example passing (others failing)
上级
959233ac
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
863 addition
and
65 deletion
+863
-65
js/js.libraries/src/dom/domcore.kt
js/js.libraries/src/dom/domcore.kt
+18
-18
js/js.libraries/src/dom/html/htmlcore.kt
js/js.libraries/src/dom/html/htmlcore.kt
+702
-0
js/js.libraries/src/dom/html/window.kt
js/js.libraries/src/dom/html/window.kt
+6
-0
js/js.libraries/src/dom/html5/canvas.kt
js/js.libraries/src/dom/html5/canvas.kt
+89
-0
js/js.tests/test/org/jetbrains/k2js/test/semantics/WebDemoCanvasExamplesTest.java
...brains/k2js/test/semantics/WebDemoCanvasExamplesTest.java
+1
-1
js/js.translator/src/org/jetbrains/k2js/config/Config.java
js/js.translator/src/org/jetbrains/k2js/config/Config.java
+5
-6
js/js.translator/testFiles/webDemoCanvasExamples/cases/Fancy lines.kt
...ator/testFiles/webDemoCanvasExamples/cases/Fancy lines.kt
+42
-40
未找到文件。
js/js.libraries/src/
core/dom/
core.kt
→
js/js.libraries/src/
dom/dom
core.kt
浏览文件 @
cd0bc436
package
js.dom
package
js.dom
.core
import
js.native
import
js.noImpl
...
...
@@ -9,17 +9,17 @@ public native trait DOMImplementationRegistry {
}
public
native
trait
DOMException
{
public
native
var
code
:
Number
=
js
.
noImpl
public
native
var
code
:
Double
=
js
.
noImpl
}
public
native
trait
DOMStringList
{
public
native
val
length
:
Number
=
js
.
noImpl
public
native
val
length
:
Double
=
js
.
noImpl
public
native
fun
item
(
index
:
Number
):
String
=
js
.
noImpl
public
native
fun
contains
(
str
:
String
):
Boolean
=
js
.
noImpl
}
public
native
trait
NameList
{
public
native
val
length
:
Number
=
js
.
noImpl
public
native
val
length
:
Double
=
js
.
noImpl
public
native
fun
getName
(
index
:
Number
):
String
=
js
.
noImpl
public
native
fun
getNamespaceURI
(
index
:
Number
):
String
=
js
.
noImpl
public
native
fun
contains
(
str
:
String
):
Boolean
=
js
.
noImpl
...
...
@@ -27,7 +27,7 @@ public native trait NameList {
}
public
native
trait
DOMImplementationList
{
public
native
val
length
:
Number
=
js
.
noImpl
public
native
val
length
:
Double
=
js
.
noImpl
public
native
fun
item
(
index
:
Number
):
DOMImplementation
?
=
js
.
noImpl
}
...
...
@@ -66,11 +66,11 @@ public native trait Document : Node {
public
native
fun
createProcessingInstruction
(
target
:
String
,
data
:
String
):
ProcessingInstruction
?
=
js
.
noImpl
public
native
fun
createAttribute
(
name
:
String
):
Attr
?
=
js
.
noImpl
public
native
fun
createEntityReference
(
name
:
String
):
EntityReference
?
=
js
.
noImpl
public
native
fun
getElementsByTagName
(
tagname
:
String
):
NodeList
?
=
js
.
noImpl
public
native
fun
getElementsByTagName
(
tagname
:
String
):
NodeList
=
js
.
noImpl
public
native
fun
importNode
(
importedNode
:
Node
,
deep
:
Boolean
):
Node
?
=
js
.
noImpl
public
native
fun
createElementNS
(
namespaceURI
:
String
,
qualifiedName
:
String
):
Element
?
=
js
.
noImpl
public
native
fun
createAttributeNS
(
namespaceURI
:
String
,
qualifiedName
:
String
):
Attr
?
=
js
.
noImpl
public
native
fun
getElementsByTagNameNS
(
namespaceURI
:
String
,
localName
:
String
):
NodeList
?
=
js
.
noImpl
public
native
fun
getElementsByTagNameNS
(
namespaceURI
:
String
,
localName
:
String
):
NodeList
=
js
.
noImpl
public
native
fun
getElementById
(
elementId
:
String
):
Element
?
=
js
.
noImpl
public
native
fun
adoptNode
(
source
:
Node
):
Node
?
=
js
.
noImpl
public
native
fun
normalizeDocument
():
Unit
=
js
.
noImpl
...
...
@@ -80,7 +80,7 @@ public native trait Document : Node {
public
native
trait
Node
{
public
native
val
nodeName
:
String
=
js
.
noImpl
public
native
var
nodeValue
:
String
=
js
.
noImpl
public
native
val
nodeType
:
Number
=
js
.
noImpl
public
native
val
nodeType
:
Double
=
js
.
noImpl
public
native
val
parentNode
:
Node
=
js
.
noImpl
public
native
val
childNodes
:
NodeList
=
js
.
noImpl
public
native
val
firstChild
:
Node
=
js
.
noImpl
...
...
@@ -115,12 +115,12 @@ public native trait Node {
}
public
native
trait
NodeList
{
public
native
val
length
:
Number
=
js
.
noImpl
public
native
val
length
:
Double
=
js
.
noImpl
public
native
fun
item
(
index
:
Number
):
Node
?
=
js
.
noImpl
}
public
native
trait
NamedNodeMap
{
public
native
val
length
:
Number
=
js
.
noImpl
public
native
val
length
:
Double
=
js
.
noImpl
public
native
fun
getNamedItem
(
name
:
String
):
Node
?
=
js
.
noImpl
public
native
fun
setNamedItem
(
arg
:
Node
):
Node
?
=
js
.
noImpl
public
native
fun
removeNamedItem
(
name
:
String
):
Node
?
=
js
.
noImpl
...
...
@@ -132,7 +132,7 @@ public native trait NamedNodeMap {
public
native
trait
CharacterData
:
Node
{
public
native
var
data
:
String
=
js
.
noImpl
public
native
val
length
:
Number
=
js
.
noImpl
public
native
val
length
:
Double
=
js
.
noImpl
public
native
fun
substringData
(
offset
:
Number
,
count
:
Number
):
String
=
js
.
noImpl
public
native
fun
appendData
(
arg
:
String
):
Unit
=
js
.
noImpl
public
native
fun
insertData
(
offset
:
Number
,
arg
:
String
):
Unit
=
js
.
noImpl
...
...
@@ -158,13 +158,13 @@ public native trait Element : Node {
public
native
fun
getAttributeNode
(
name
:
String
):
Attr
?
=
js
.
noImpl
public
native
fun
setAttributeNode
(
newAttr
:
Attr
):
Attr
?
=
js
.
noImpl
public
native
fun
removeAttributeNode
(
oldAttr
:
Attr
):
Attr
?
=
js
.
noImpl
public
native
fun
getElementsByTagName
(
name
:
String
):
NodeList
?
=
js
.
noImpl
public
native
fun
getElementsByTagName
(
name
:
String
):
NodeList
=
js
.
noImpl
public
native
fun
getAttributeNS
(
namespaceURI
:
String
,
localName
:
String
):
String
=
js
.
noImpl
public
native
fun
setAttributeNS
(
namespaceURI
:
String
,
qualifiedName
:
String
,
value
:
String
):
Unit
=
js
.
noImpl
public
native
fun
removeAttributeNS
(
namespaceURI
:
String
,
localName
:
String
):
Unit
=
js
.
noImpl
public
native
fun
getAttributeNodeNS
(
namespaceURI
:
String
,
localName
:
String
):
Unit
=
js
.
noImpl
public
native
fun
setAttributeNodeNS
(
newAttr
:
Attr
):
Unit
=
js
.
noImpl
public
native
fun
getElementsByTagNameNS
(
namespaceURI
:
String
,
localName
:
String
):
NodeList
?
=
js
.
noImpl
public
native
fun
getElementsByTagNameNS
(
namespaceURI
:
String
,
localName
:
String
):
NodeList
=
js
.
noImpl
public
native
fun
hasAttribute
(
name
:
String
):
Boolean
=
js
.
noImpl
public
native
fun
hasAttributeNS
(
namespaceURI
:
String
,
localName
:
String
):
Boolean
=
js
.
noImpl
public
native
fun
setIdAttribute
(
name
:
String
,
isId
:
Boolean
):
Unit
=
js
.
noImpl
...
...
@@ -194,7 +194,7 @@ public native trait UserDataHandler {
}
public
native
trait
DOMError
{
public
native
var
severity
:
Number
=
js
.
noImpl
public
native
var
severity
:
Double
=
js
.
noImpl
public
native
var
message
:
String
=
js
.
noImpl
public
native
var
`type`
:
String
=
js
.
noImpl
public
native
var
relatedException
:
Any
=
js
.
noImpl
...
...
@@ -207,10 +207,10 @@ public native trait DOMErrorHandler {
}
public
native
trait
DOMLocator
{
public
native
var
lineNumber
:
Number
=
js
.
noImpl
public
native
var
columnNumber
:
Number
=
js
.
noImpl
public
native
var
byteOffset
:
Number
=
js
.
noImpl
public
native
var
utf16Offset
:
Number
=
js
.
noImpl
public
native
var
lineNumber
:
Double
=
js
.
noImpl
public
native
var
columnNumber
:
Double
=
js
.
noImpl
public
native
var
byteOffset
:
Double
=
js
.
noImpl
public
native
var
utf16Offset
:
Double
=
js
.
noImpl
public
native
var
relatedNode
:
Node
=
js
.
noImpl
public
native
var
uri
:
String
=
js
.
noImpl
}
...
...
js/js.libraries/src/dom/html/htmlcore.kt
0 → 100644
浏览文件 @
cd0bc436
此差异已折叠。
点击以展开。
js/js.libraries/src/dom/html/window.kt
0 → 100644
浏览文件 @
cd0bc436
package
js.dom.html
import
js.noImpl
native
val
window
:
Window
=
js
.
noImpl
\ No newline at end of file
js/js.libraries/src/dom/html5/canvas.kt
0 → 100644
浏览文件 @
cd0bc436
package
js.dom.html5
import
js.native
import
js.noImpl
import
js.dom.html.HTMLElement
import
js.dom.core.Element
public
native
trait
HTMLImageElement
{
public
native
var
crossOrigin
:
String
=
js
.
noImpl
}
public
native
trait
HTMLCanvasElement
:
HTMLElement
{
public
native
var
width
:
Double
=
js
.
noImpl
public
native
var
height
:
Double
=
js
.
noImpl
public
native
fun
getContext
(
context
:
String
):
CanvasContext
?
=
js
.
noImpl
public
native
fun
toDataURL
(
string
:
String
,
args
:
Any
):
String
=
js
.
noImpl
}
public
native
trait
CanvasContext
{
public
native
var
canvas
:
HTMLCanvasElement
=
js
.
noImpl
public
native
fun
save
():
Unit
=
js
.
noImpl
public
native
fun
restore
():
Unit
=
js
.
noImpl
public
native
fun
scale
(
x
:
Number
,
y
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
rotate
(
angle
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
translate
(
x
:
Number
,
y
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
transform
(
m11
:
Number
,
m12
:
Number
,
m21
:
Number
,
m22
:
Number
,
dx
:
Number
,
dy
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
setTransform
(
m11
:
Number
,
m12
:
Number
,
m21
:
Number
,
m22
:
Number
,
dx
:
Number
,
dy
:
Number
):
Unit
=
js
.
noImpl
public
native
var
globalAlpha
:
Double
=
js
.
noImpl
public
native
var
globalCompositeOperation
:
String
=
js
.
noImpl
public
native
var
fillStyle
:
String
=
js
.
noImpl
public
native
var
strokeStyle
:
String
=
js
.
noImpl
public
native
fun
createLinearGradient
(
x0
:
Number
,
y0
:
Number
,
x1
:
Number
,
y1
:
Number
):
CanvasGradient
?
=
js
.
noImpl
public
native
fun
createRadialGradient
(
x0
:
Number
,
y0
:
Number
,
r0
:
Number
,
x1
:
Number
,
y1
:
Number
,
r1
:
Number
):
CanvasGradient
?
=
js
.
noImpl
public
native
var
lineWidth
:
Double
=
js
.
noImpl
public
native
var
lineCap
:
String
=
js
.
noImpl
public
native
var
lineJoin
:
String
=
js
.
noImpl
public
native
var
miterLimit
:
Double
=
js
.
noImpl
public
native
var
shadowOffsetX
:
Double
=
js
.
noImpl
public
native
var
shadowOffsetY
:
Double
=
js
.
noImpl
public
native
var
shadowBlur
:
Double
=
js
.
noImpl
public
native
var
shadowColor
:
String
=
js
.
noImpl
public
native
fun
clearRect
(
x
:
Number
,
y
:
Number
,
w
:
Number
,
h
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
fillRect
(
x
:
Number
,
y
:
Number
,
w
:
Number
,
h
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
strokeRect
(
x
:
Number
,
y
:
Number
,
w
:
Number
,
h
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
beginPath
():
Unit
=
js
.
noImpl
public
native
fun
closePath
():
Unit
=
js
.
noImpl
public
native
fun
moveTo
(
x
:
Number
,
y
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
lineTo
(
x
:
Number
,
y
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
quadraticCurveTo
(
cpx
:
Number
,
cpy
:
Number
,
x
:
Number
,
y
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
bezierCurveTo
(
cp1x
:
Number
,
cp1y
:
Number
,
cp2x
:
Number
,
cp2y
:
Number
,
x
:
Number
,
y
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
arcTo
(
x1
:
Number
,
y1
:
Number
,
x2
:
Number
,
y2
:
Number
,
radius
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
rect
(
x
:
Number
,
y
:
Number
,
w
:
Number
,
h
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
arc
(
x
:
Number
,
y
:
Number
,
radius
:
Number
,
startAngle
:
Number
,
endAngle
:
Number
,
anticlockwise
:
Boolean
):
Unit
=
js
.
noImpl
public
native
fun
fill
():
Unit
=
js
.
noImpl
public
native
fun
stroke
():
Unit
=
js
.
noImpl
public
native
fun
clip
():
Unit
=
js
.
noImpl
public
native
fun
isPointInPath
(
x
:
Number
,
y
:
Number
):
Boolean
=
js
.
noImpl
public
native
fun
drawFocusRing
(
element
:
Element
,
xCaret
:
Number
,
yCaret
:
Number
,
canDrawCustom
:
Boolean
):
Unit
=
js
.
noImpl
public
native
var
font
:
String
=
js
.
noImpl
public
native
var
textAlign
:
String
=
js
.
noImpl
public
native
var
textBaseline
:
String
=
js
.
noImpl
public
native
fun
fillText
(
text
:
String
,
x
:
Number
,
y
:
Number
,
maxWidth
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
strokeText
(
text
:
String
,
x
:
Number
,
y
:
Number
,
maxWidth
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
measureText
(
text
:
String
):
TextMetrics
?
=
js
.
noImpl
public
native
fun
drawImage
(
img_elem
:
HTMLElement
,
dx_or_sx
:
Number
,
dy_or_sy
:
Number
,
dw_or_sw
:
Number
,
dh_or_sh
:
Number
,
dx
:
Number
,
dy
:
Number
,
dw
:
Number
,
dh
:
Number
):
Unit
=
js
.
noImpl
public
native
fun
createImageData
(
imagedata
:
ImageData
,
sh
:
Number
):
ImageData
?
=
js
.
noImpl
public
native
fun
createImageData
(
sw
:
Number
,
sh
:
Number
):
ImageData
?
=
js
.
noImpl
public
native
fun
getImageData
(
sx
:
Number
,
sy
:
Number
,
sw
:
Number
,
sh
:
Number
):
ImageData
?
=
js
.
noImpl
public
native
fun
putImageData
(
image_data
:
ImageData
,
dx
:
Number
,
dy
:
Number
,
dirtyX
:
Number
,
dirtyY
:
Number
,
dirtyWidth
:
Number
,
dirtyHeight
:
Number
):
Unit
=
js
.
noImpl
}
public
native
trait
CanvasGradient
{
public
native
fun
addColorStop
(
offset
:
Number
,
color
:
String
):
Unit
=
js
.
noImpl
}
public
native
trait
ImageData
{
public
native
var
data
:
CanvasPixelArray
=
js
.
noImpl
public
native
var
width
:
Double
=
js
.
noImpl
public
native
var
height
:
Double
=
js
.
noImpl
}
public
native
trait
CanvasPixelArray
{
public
native
var
length
:
Double
=
js
.
noImpl
}
public
native
trait
TextMetrics
{
public
native
var
width
:
Double
=
js
.
noImpl
}
js/js.tests/test/org/jetbrains/k2js/test/semantics/WebDemoCanvasExamplesTest.java
浏览文件 @
cd0bc436
...
...
@@ -48,7 +48,7 @@ public final class WebDemoCanvasExamplesTest extends SingleFileTranslationTest {
}
public
void
testFancyLines
()
throws
Exception
{
doTest
(
"Fancy lines.kt"
,
"
$
"
);
doTest
(
"Fancy lines.kt"
,
"
window
"
);
}
public
void
testTrafficLight
()
throws
Exception
{
...
...
js/js.translator/src/org/jetbrains/k2js/config/Config.java
浏览文件 @
cd0bc436
...
...
@@ -62,14 +62,13 @@ public abstract class Config {
"/core/math.kt"
,
"/core/json.kt"
,
"/raphael/raphael.kt"
,
"/html5/canvas.kt"
,
"/html5/files.kt"
,
"/html5/image.kt"
,
"/stdlib/JUMaps.kt"
,
"/stdlib/browser.kt"
,
"/core/dom.kt"
// TODO
// "/core/dom/core.kt"
"/core/dom.kt"
,
"/dom/domcore.kt"
,
"/dom/html/htmlcore.kt"
,
"/dom/html/window.kt"
,
"/dom/html5/canvas.kt"
);
public
static
final
String
LIBRARIES_LOCATION
=
"js/js.libraries/src"
;
...
...
js/js.translator/testFiles/webDemoCanvasExamples/cases/Fancy lines.kt
浏览文件 @
cd0bc436
...
...
@@ -6,59 +6,61 @@ Note that only a subset of the api is supported for now.
package
fancylines
import
js.*;
import
html5.*;
import
jquery.*;
fun
main
(
args
:
Array
<
String
>)
{
//jq is a name for JQuery function
jq
{
FancyLines
().
run
();
}
import
js.dom.html5.*
import
js.dom.html.window
fun
main
(
args
:
Array
<
String
>)
{
window
.
onload
=
{
FancyLines
().
run
()
}
}
val
canvas
:
HTMLCanvasElement
get
()
{
return
window
.
document
.
getElementsByTagName
(
"canvas"
).
item
(
0
)
as
HTMLCanvasElement
}
class
FancyLines
()
{
// we use two 'magic' functions here getContext() and getCanvas()
val
context
=
getContext
();
val
height
=
getCanvas
().
height
;
val
width
=
getCanvas
().
width
;
var
x
=
width
*
Math
.
random
();
var
y
=
height
*
Math
.
random
();
var
hue
=
0
;
val
context
=
canvas
.
getContext
(
"2d"
)
!!
val
height
=
canvas
.
height
val
width
=
canvas
.
width
var
x
=
width
*
Math
.
random
()
var
y
=
height
*
Math
.
random
()
var
hue
=
0
;
fun
line
()
{
context
.
save
();
fun
line
()
{
context
.
save
()
context
.
beginPath
();
context
.
beginPath
()
context
.
lineWidth
=
20.0
*
Math
.
random
();
context
.
moveTo
(
x
.
toInt
(),
y
.
toInt
());
context
.
lineWidth
=
20.0
*
Math
.
random
()
context
.
moveTo
(
x
.
toInt
(),
y
.
toInt
());
x
=
width
*
Math
.
random
();
y
=
height
*
Math
.
random
();
x
=
width
*
Math
.
random
();
y
=
height
*
Math
.
random
()
context
.
bezierCurveTo
(
width
*
Math
.
random
(),
height
*
Math
.
random
(),
width
*
Math
.
random
(),
height
*
Math
.
random
(),
x
,
y
);
context
.
bezierCurveTo
(
width
*
Math
.
random
(),
height
*
Math
.
random
(),
width
*
Math
.
random
(),
height
*
Math
.
random
(),
x
,
y
);
hue
+=
Math
.
random
()
*
10
;
hue
+=
Math
.
random
()
*
10
;
context
.
strokeStyle
=
"hsl($hue, 50%, 50%)"
;
context
.
strokeStyle
=
"hsl($hue, 50%, 50%)"
;
context
.
shadowColor
=
"white"
;
context
.
shadowBlur
=
10.0
;
context
.
shadowColor
=
"white"
;
context
.
shadowBlur
=
10.0
;
context
.
stroke
();
context
.
stroke
();
context
.
restore
();
}
context
.
restore
();
}
fun
blank
()
{
context
.
fillStyle
=
"rgba(255,255,1,0.1)"
;
context
.
fillRect
(
0
,
0
,
width
,
height
);
}
fun
blank
()
{
context
.
fillStyle
=
"rgba(255,255,1,0.1)"
;
context
.
fillRect
(
0
,
0
,
width
,
height
);
}
fun
run
()
{
setInterval
({
line
()},
40
);
setInterval
({
blank
()},
100
);
}
fun
run
()
{
setInterval
({
line
()},
40
);
setInterval
({
blank
()},
100
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录