rubyjs 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +128 -0
- data/Rakefile +9 -0
- data/bin/rubyjs +140 -0
- data/examples/ex1/Rakefile +7 -0
- data/examples/ex1/ex1.js +771 -0
- data/examples/ex1/ex1.rb +42 -0
- data/examples/ex1/index.html +7 -0
- data/examples/hw/Rakefile +9 -0
- data/examples/hw/hw.js +635 -0
- data/examples/hw/hw.rb +7 -0
- data/examples/hw/index.html +7 -0
- data/patches/parse_tree.rb.diff +34 -0
- data/rubyjs.gemspec +24 -0
- data/src/rubyjs.rb +4 -0
- data/src/rubyjs/code_generator.rb +474 -0
- data/src/rubyjs/compiler.rb +2007 -0
- data/src/rubyjs/debug_name_generator.rb +75 -0
- data/src/rubyjs/encoder.rb +171 -0
- data/src/rubyjs/eval_into.rb +59 -0
- data/src/rubyjs/lib/core.rb +1008 -0
- data/src/rubyjs/lib/json.rb +101 -0
- data/src/rubyjs/model.rb +287 -0
- data/src/rubyjs/name_generator.rb +71 -0
- data/src/rwt/AbsolutePanel.rb +161 -0
- data/src/rwt/DOM.Konqueror.rb +89 -0
- data/src/rwt/DOM.Opera.rb +65 -0
- data/src/rwt/DOM.rb +1044 -0
- data/src/rwt/Event.Opera.rb +35 -0
- data/src/rwt/Event.rb +429 -0
- data/src/rwt/HTTPRequest.IE6.rb +5 -0
- data/src/rwt/HTTPRequest.rb +74 -0
- data/src/rwt/Label.rb +164 -0
- data/src/rwt/Panel.rb +90 -0
- data/src/rwt/RootPanel.rb +16 -0
- data/src/rwt/UIObject.rb +495 -0
- data/src/rwt/Widget.rb +193 -0
- data/src/rwt/ported-from/AbsolutePanel.java +158 -0
- data/src/rwt/ported-from/DOM.java +571 -0
- data/src/rwt/ported-from/DOMImpl.java +426 -0
- data/src/rwt/ported-from/DOMImplOpera.java +82 -0
- data/src/rwt/ported-from/DOMImplStandard.java +234 -0
- data/src/rwt/ported-from/HTTPRequest.java +81 -0
- data/src/rwt/ported-from/HTTPRequestImpl.java +103 -0
- data/src/rwt/ported-from/Label.java +163 -0
- data/src/rwt/ported-from/Panel.java +99 -0
- data/src/rwt/ported-from/UIObject.java +614 -0
- data/src/rwt/ported-from/Widget.java +221 -0
- data/test/benchmark/bm_call_conv1.js +16 -0
- data/test/benchmark/bm_call_conv2.js +14 -0
- data/test/benchmark/bm_var_acc1.js +13 -0
- data/test/benchmark/bm_var_acc2.js +11 -0
- data/test/benchmark/bm_vm1_block.js +15 -0
- data/test/benchmark/bm_vm1_block.rb +15 -0
- data/test/benchmark/bm_vm1_const.js +13 -0
- data/test/benchmark/bm_vm1_const.rb +13 -0
- data/test/benchmark/bm_vm1_ensure.js +17 -0
- data/test/benchmark/bm_vm1_ensure.rb +15 -0
- data/test/benchmark/common.js +4 -0
- data/test/benchmark/common.rb +5 -0
- data/test/benchmark/params.yaml +7 -0
- data/test/browser.test.html +4059 -0
- data/test/browser.test.js +3225 -0
- data/test/common.Browser.rb +13 -0
- data/test/common.rb +8 -0
- data/test/gen_browser_test_suite.rb +129 -0
- data/test/gen_test_suite.rb +41 -0
- data/test/run_benchs.rb +58 -0
- data/test/run_tests.rb +22 -0
- data/test/test_args.rb +24 -0
- data/test/test_array.rb +26 -0
- data/test/test_case.rb +35 -0
- data/test/test_class.rb +55 -0
- data/test/test_eql.rb +9 -0
- data/test/test_exception.rb +61 -0
- data/test/test_expr.rb +12 -0
- data/test/test_hash.rb +29 -0
- data/test/test_if.rb +28 -0
- data/test/test_inspect.rb +10 -0
- data/test/test_lebewesen.rb +39 -0
- data/test/test_massign.rb +66 -0
- data/test/test_new.rb +12 -0
- data/test/test_range.rb +53 -0
- data/test/test_regexp.rb +22 -0
- data/test/test_send.rb +65 -0
- data/test/test_simple_output.rb +5 -0
- data/test/test_splat.rb +21 -0
- data/test/test_string.rb +51 -0
- data/test/test_yield.rb +152 -0
- data/utils/js/Makefile +9 -0
- data/utils/js/RunScript.class +0 -0
- data/utils/js/RunScript.java +73 -0
- data/utils/js/js.jar +0 -0
- data/utils/js/run.sh +3 -0
- data/utils/jsc/Makefile +7 -0
- data/utils/jsc/README +3 -0
- data/utils/jsc/RunScript.c +93 -0
- data/utils/jsc/run.sh +15 -0
- data/utils/yuicompressor/README +1 -0
- data/utils/yuicompressor/yuicompressor-2.2.5.jar +0 -0
- data/vendor/ParseTree-1.7.1-patched/History.txt +217 -0
- data/vendor/ParseTree-1.7.1-patched/Manifest.txt +22 -0
- data/vendor/ParseTree-1.7.1-patched/README.txt +110 -0
- data/vendor/ParseTree-1.7.1-patched/Rakefile +41 -0
- data/vendor/ParseTree-1.7.1-patched/bin/parse_tree_abc +89 -0
- data/vendor/ParseTree-1.7.1-patched/bin/parse_tree_audit +28 -0
- data/vendor/ParseTree-1.7.1-patched/bin/parse_tree_deps +62 -0
- data/vendor/ParseTree-1.7.1-patched/bin/parse_tree_show +49 -0
- data/vendor/ParseTree-1.7.1-patched/demo/printer.rb +20 -0
- data/vendor/ParseTree-1.7.1-patched/lib/composite_sexp_processor.rb +49 -0
- data/vendor/ParseTree-1.7.1-patched/lib/parse_tree.rb +1013 -0
- data/vendor/ParseTree-1.7.1-patched/lib/sexp.rb +235 -0
- data/vendor/ParseTree-1.7.1-patched/lib/sexp_processor.rb +330 -0
- data/vendor/ParseTree-1.7.1-patched/lib/unique.rb +15 -0
- data/vendor/ParseTree-1.7.1-patched/test/pt_testcase.rb +1221 -0
- data/vendor/ParseTree-1.7.1-patched/test/something.rb +53 -0
- data/vendor/ParseTree-1.7.1-patched/test/test_all.rb +13 -0
- data/vendor/ParseTree-1.7.1-patched/test/test_composite_sexp_processor.rb +69 -0
- data/vendor/ParseTree-1.7.1-patched/test/test_parse_tree.rb +216 -0
- data/vendor/ParseTree-1.7.1-patched/test/test_sexp.rb +291 -0
- data/vendor/ParseTree-1.7.1-patched/test/test_sexp_processor.rb +244 -0
- data/vendor/ParseTree-1.7.1-patched/validate.sh +31 -0
- data/vendor/ParseTree-1.7.1/History.txt +217 -0
- data/vendor/ParseTree-1.7.1/Manifest.txt +22 -0
- data/vendor/ParseTree-1.7.1/README.txt +110 -0
- data/vendor/ParseTree-1.7.1/Rakefile +41 -0
- data/vendor/ParseTree-1.7.1/bin/parse_tree_abc +89 -0
- data/vendor/ParseTree-1.7.1/bin/parse_tree_audit +28 -0
- data/vendor/ParseTree-1.7.1/bin/parse_tree_deps +62 -0
- data/vendor/ParseTree-1.7.1/bin/parse_tree_show +49 -0
- data/vendor/ParseTree-1.7.1/demo/printer.rb +20 -0
- data/vendor/ParseTree-1.7.1/lib/composite_sexp_processor.rb +49 -0
- data/vendor/ParseTree-1.7.1/lib/parse_tree.rb +1004 -0
- data/vendor/ParseTree-1.7.1/lib/sexp.rb +235 -0
- data/vendor/ParseTree-1.7.1/lib/sexp_processor.rb +330 -0
- data/vendor/ParseTree-1.7.1/lib/unique.rb +15 -0
- data/vendor/ParseTree-1.7.1/test/pt_testcase.rb +1221 -0
- data/vendor/ParseTree-1.7.1/test/something.rb +53 -0
- data/vendor/ParseTree-1.7.1/test/test_all.rb +13 -0
- data/vendor/ParseTree-1.7.1/test/test_composite_sexp_processor.rb +69 -0
- data/vendor/ParseTree-1.7.1/test/test_parse_tree.rb +216 -0
- data/vendor/ParseTree-1.7.1/test/test_sexp.rb +291 -0
- data/vendor/ParseTree-1.7.1/test/test_sexp_processor.rb +244 -0
- data/vendor/ParseTree-1.7.1/validate.sh +31 -0
- metadata +230 -0
@@ -0,0 +1,426 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2007 Google Inc.
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
5
|
+
* use this file except in compliance with the License. You may obtain a copy of
|
6
|
+
* the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
* License for the specific language governing permissions and limitations under
|
14
|
+
* the License.
|
15
|
+
*/
|
16
|
+
package com.google.gwt.user.client.impl;
|
17
|
+
|
18
|
+
import com.google.gwt.user.client.Element;
|
19
|
+
import com.google.gwt.user.client.Event;
|
20
|
+
import com.google.gwt.user.client.EventListener;
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Native implementation associated with {@link com.google.gwt.user.client.DOM}.
|
24
|
+
*/
|
25
|
+
public abstract class DOMImpl {
|
26
|
+
|
27
|
+
public native void appendChild(Element parent, Element child) /*-{
|
28
|
+
parent.appendChild(child);
|
29
|
+
}-*/;
|
30
|
+
|
31
|
+
public abstract boolean compare(Element elem1, Element elem2);
|
32
|
+
|
33
|
+
public native Element createElement(String tag) /*-{
|
34
|
+
return $doc.createElement(tag);
|
35
|
+
}-*/;
|
36
|
+
|
37
|
+
public native Element createInputElement(String type) /*-{
|
38
|
+
var e = $doc.createElement("INPUT");
|
39
|
+
e.type = type;
|
40
|
+
return e;
|
41
|
+
}-*/;
|
42
|
+
|
43
|
+
public abstract Element createInputRadioElement(String name);
|
44
|
+
|
45
|
+
public Element createSelectElement(boolean multiple) {
|
46
|
+
Element select = createElement("select");
|
47
|
+
if (multiple) {
|
48
|
+
setElementPropertyBoolean(select, "multiple", true);
|
49
|
+
}
|
50
|
+
return select;
|
51
|
+
}
|
52
|
+
|
53
|
+
public native void eventCancelBubble(Event evt, boolean cancel) /*-{
|
54
|
+
evt.cancelBubble = cancel;
|
55
|
+
}-*/;
|
56
|
+
|
57
|
+
public native boolean eventGetAltKey(Event evt) /*-{
|
58
|
+
return !!evt.altKey;
|
59
|
+
}-*/;
|
60
|
+
|
61
|
+
public native int eventGetButton(Event evt) /*-{
|
62
|
+
return evt.button || -1;
|
63
|
+
}-*/;
|
64
|
+
|
65
|
+
public native int eventGetClientX(Event evt) /*-{
|
66
|
+
return evt.clientX || -1;
|
67
|
+
}-*/;
|
68
|
+
|
69
|
+
public native int eventGetClientY(Event evt) /*-{
|
70
|
+
return evt.clientY || -1;
|
71
|
+
}-*/;
|
72
|
+
|
73
|
+
public native boolean eventGetCtrlKey(Event evt) /*-{
|
74
|
+
return !!evt.ctrlKey;
|
75
|
+
}-*/;
|
76
|
+
|
77
|
+
public native Element eventGetCurrentTarget(Event evt) /*-{
|
78
|
+
return evt.currentTarget;
|
79
|
+
}-*/;
|
80
|
+
|
81
|
+
public abstract Element eventGetFromElement(Event evt);
|
82
|
+
|
83
|
+
public native int eventGetKeyCode(Event evt) /*-{
|
84
|
+
// 'which' gives the right key value, except when it doesn't -- in which
|
85
|
+
// case, keyCode gives the right value on all browsers.
|
86
|
+
// If all else fails, return an error code
|
87
|
+
return evt.which || evt.keyCode || -1;
|
88
|
+
}-*/;
|
89
|
+
|
90
|
+
public native boolean eventGetMetaKey(Event evt) /*-{
|
91
|
+
return !!evt.metaKey;
|
92
|
+
}-*/;
|
93
|
+
|
94
|
+
public abstract int eventGetMouseWheelVelocityY(Event evt);
|
95
|
+
|
96
|
+
public native boolean eventGetRepeat(Event evt) /*-{
|
97
|
+
return !!evt.repeat;
|
98
|
+
}-*/;
|
99
|
+
|
100
|
+
public native int eventGetScreenX(Event evt) /*-{
|
101
|
+
return evt.screenX || -1;
|
102
|
+
}-*/;
|
103
|
+
|
104
|
+
public native int eventGetScreenY(Event evt) /*-{
|
105
|
+
return evt.screenY || -1;
|
106
|
+
}-*/;
|
107
|
+
|
108
|
+
public native boolean eventGetShiftKey(Event evt) /*-{
|
109
|
+
return !!evt.shiftKey;
|
110
|
+
}-*/;
|
111
|
+
|
112
|
+
public abstract Element eventGetTarget(Event evt);
|
113
|
+
|
114
|
+
public abstract Element eventGetToElement(Event evt);
|
115
|
+
|
116
|
+
public native String eventGetType(Event evt) /*-{
|
117
|
+
return evt.type;
|
118
|
+
}-*/;
|
119
|
+
|
120
|
+
public native int eventGetTypeInt(Event evt) /*-{
|
121
|
+
switch (evt.type) {
|
122
|
+
case "blur": return 0x01000;
|
123
|
+
case "change": return 0x00400;
|
124
|
+
case "click": return 0x00001;
|
125
|
+
case "dblclick": return 0x00002;
|
126
|
+
case "focus": return 0x00800;
|
127
|
+
case "keydown": return 0x00080;
|
128
|
+
case "keypress": return 0x00100;
|
129
|
+
case "keyup": return 0x00200;
|
130
|
+
case "load": return 0x08000;
|
131
|
+
case "losecapture": return 0x02000;
|
132
|
+
case "mousedown": return 0x00004;
|
133
|
+
case "mousemove": return 0x00040;
|
134
|
+
case "mouseout": return 0x00020;
|
135
|
+
case "mouseover": return 0x00010;
|
136
|
+
case "mouseup": return 0x00008;
|
137
|
+
case "scroll": return 0x04000;
|
138
|
+
case "error": return 0x10000;
|
139
|
+
case "mousewheel": return 0x20000;
|
140
|
+
case "DOMMouseScroll": return 0x20000;
|
141
|
+
}
|
142
|
+
}-*/;
|
143
|
+
|
144
|
+
public abstract void eventPreventDefault(Event evt);
|
145
|
+
|
146
|
+
public native void eventSetKeyCode(Event evt, char key) /*-{
|
147
|
+
evt.keyCode = key;
|
148
|
+
}-*/;
|
149
|
+
|
150
|
+
public abstract String eventToString(Event evt);
|
151
|
+
|
152
|
+
public native int getAbsoluteLeft(Element elem) /*-{
|
153
|
+
var left = 0;
|
154
|
+
var curr = elem;
|
155
|
+
// This intentionally excludes body which has a null offsetParent.
|
156
|
+
while (curr.offsetParent) {
|
157
|
+
left -= curr.scrollLeft;
|
158
|
+
curr = curr.parentNode;
|
159
|
+
}
|
160
|
+
while (elem) {
|
161
|
+
left += elem.offsetLeft;
|
162
|
+
elem = elem.offsetParent;
|
163
|
+
}
|
164
|
+
return left;
|
165
|
+
}-*/;
|
166
|
+
|
167
|
+
public native int getAbsoluteTop(Element elem) /*-{
|
168
|
+
var top = 0;
|
169
|
+
var curr = elem;
|
170
|
+
// This intentionally excludes body which has a null offsetParent.
|
171
|
+
while (curr.offsetParent) {
|
172
|
+
top -= curr.scrollTop;
|
173
|
+
curr = curr.parentNode;
|
174
|
+
}
|
175
|
+
while (elem) {
|
176
|
+
top += elem.offsetTop;
|
177
|
+
elem = elem.offsetParent;
|
178
|
+
}
|
179
|
+
return top;
|
180
|
+
}-*/;
|
181
|
+
|
182
|
+
public abstract Element getChild(Element elem, int index);
|
183
|
+
|
184
|
+
public abstract int getChildCount(Element elem);
|
185
|
+
|
186
|
+
public abstract int getChildIndex(Element parent, Element child);
|
187
|
+
|
188
|
+
public native String getElementAttribute(Element elem, String attr) /*-{
|
189
|
+
var ret = elem.getAttribute(attr);
|
190
|
+
return (ret == null) ? null : ret;
|
191
|
+
}-*/;
|
192
|
+
|
193
|
+
public native Element getElementById(String id) /*-{
|
194
|
+
var elem = $doc.getElementById(id);
|
195
|
+
return elem || null;
|
196
|
+
}-*/;
|
197
|
+
|
198
|
+
public native String getElementProperty(Element elem, String prop) /*-{
|
199
|
+
var ret = elem[prop];
|
200
|
+
return (ret == null) ? null : String(ret);
|
201
|
+
}-*/;
|
202
|
+
|
203
|
+
public native boolean getElementPropertyBoolean(Element elem, String prop) /*-{
|
204
|
+
return !!elem[prop];
|
205
|
+
}-*/;
|
206
|
+
|
207
|
+
public native int getElementPropertyInt(Element elem, String prop) /*-{
|
208
|
+
var i = parseInt(elem[prop]);
|
209
|
+
if (!i) {
|
210
|
+
return 0;
|
211
|
+
}
|
212
|
+
return i;
|
213
|
+
}-*/;
|
214
|
+
|
215
|
+
public native int getEventsSunk(Element elem) /*-{
|
216
|
+
return elem.__eventBits || 0;
|
217
|
+
}-*/;
|
218
|
+
|
219
|
+
public abstract Element getFirstChild(Element elem);
|
220
|
+
|
221
|
+
public native String getImgSrc(Element img) /*-{
|
222
|
+
return img.src;
|
223
|
+
}-*/;
|
224
|
+
|
225
|
+
public native String getInnerHTML(Element elem) /*-{
|
226
|
+
var ret = elem.innerHTML;
|
227
|
+
return (ret == null) ? null : ret;
|
228
|
+
}-*/;
|
229
|
+
|
230
|
+
public native String getInnerText(Element node) /*-{
|
231
|
+
// To mimic IE's 'innerText' property in the W3C DOM, we need to recursively
|
232
|
+
// concatenate all child text nodes (depth first).
|
233
|
+
var text = '', child = node.firstChild;
|
234
|
+
while (child) {
|
235
|
+
// 1 == Element node
|
236
|
+
if (child.nodeType == 1) {
|
237
|
+
text += this.@com.google.gwt.user.client.impl.DOMImpl::getInnerText(Lcom/google/gwt/user/client/Element;)(child);
|
238
|
+
} else if (child.nodeValue) {
|
239
|
+
text += child.nodeValue;
|
240
|
+
}
|
241
|
+
child = child.nextSibling;
|
242
|
+
}
|
243
|
+
return text;
|
244
|
+
}-*/;
|
245
|
+
|
246
|
+
public native int getIntStyleAttribute(Element elem, String attr) /*-{
|
247
|
+
var i = parseInt(elem.style[attr]);
|
248
|
+
if (!i) {
|
249
|
+
return 0;
|
250
|
+
}
|
251
|
+
return i;
|
252
|
+
}-*/;
|
253
|
+
|
254
|
+
public abstract Element getNextSibling(Element elem);
|
255
|
+
|
256
|
+
public abstract Element getParent(Element elem);
|
257
|
+
|
258
|
+
public native String getStyleAttribute(Element elem, String attr) /*-{
|
259
|
+
var ret = elem.style[attr];
|
260
|
+
return (ret == null) ? null : ret;
|
261
|
+
}-*/;
|
262
|
+
|
263
|
+
public abstract void init();
|
264
|
+
|
265
|
+
public native void insertBefore(Element parent, Element child, Element before) /*-{
|
266
|
+
parent.insertBefore(child, before);
|
267
|
+
}-*/;
|
268
|
+
|
269
|
+
public abstract void insertChild(Element parent, Element child,
|
270
|
+
int index);
|
271
|
+
|
272
|
+
/**
|
273
|
+
* @see com.google.gwt.user.client.DOM#insertListItem(Element, String, String, int)
|
274
|
+
*/
|
275
|
+
public native void insertListItem(Element select, String item, String value,
|
276
|
+
int index)/*-{
|
277
|
+
var option = new Option(item, value);
|
278
|
+
if (index == -1 || index > select.options.length - 1) {
|
279
|
+
select.add(option, null);
|
280
|
+
} else {
|
281
|
+
select.add(option, select.options[index]);
|
282
|
+
}
|
283
|
+
}-*/;
|
284
|
+
|
285
|
+
public abstract boolean isOrHasChild(Element parent, Element child);
|
286
|
+
|
287
|
+
public abstract void releaseCapture(Element elem);
|
288
|
+
|
289
|
+
public native void removeChild(Element parent, Element child) /*-{
|
290
|
+
parent.removeChild(child);
|
291
|
+
}-*/;
|
292
|
+
|
293
|
+
public native void removeElementAttribute(Element elem, String attr) /*-{
|
294
|
+
elem.removeAttribute(attr);
|
295
|
+
}-*/;
|
296
|
+
|
297
|
+
public native void scrollIntoView(Element elem) /*-{
|
298
|
+
var left = elem.offsetLeft, top = elem.offsetTop;
|
299
|
+
var width = elem.offsetWidth, height = elem.offsetHeight;
|
300
|
+
|
301
|
+
if (elem.parentNode != elem.offsetParent) {
|
302
|
+
left -= elem.parentNode.offsetLeft;
|
303
|
+
top -= elem.parentNode.offsetTop;
|
304
|
+
}
|
305
|
+
|
306
|
+
var cur = elem.parentNode;
|
307
|
+
while (cur && (cur.nodeType == 1)) {
|
308
|
+
// body tags are implicitly scrollable
|
309
|
+
if ((cur.style.overflow == 'auto') || (cur.style.overflow == 'scroll') ||
|
310
|
+
(cur.tagName == 'BODY')) {
|
311
|
+
|
312
|
+
if (left < cur.scrollLeft) {
|
313
|
+
cur.scrollLeft = left;
|
314
|
+
}
|
315
|
+
if (left + width > cur.scrollLeft + cur.clientWidth) {
|
316
|
+
cur.scrollLeft = (left + width) - cur.clientWidth;
|
317
|
+
}
|
318
|
+
if (top < cur.scrollTop) {
|
319
|
+
cur.scrollTop = top;
|
320
|
+
}
|
321
|
+
if (top + height > cur.scrollTop + cur.clientHeight) {
|
322
|
+
cur.scrollTop = (top + height) - cur.clientHeight;
|
323
|
+
}
|
324
|
+
}
|
325
|
+
|
326
|
+
var offsetLeft = cur.offsetLeft, offsetTop = cur.offsetTop;
|
327
|
+
if (cur.parentNode != cur.offsetParent) {
|
328
|
+
offsetLeft -= cur.parentNode.offsetLeft;
|
329
|
+
offsetTop -= cur.parentNode.offsetTop;
|
330
|
+
}
|
331
|
+
|
332
|
+
left += offsetLeft - cur.scrollLeft;
|
333
|
+
top += offsetTop - cur.scrollTop;
|
334
|
+
cur = cur.parentNode;
|
335
|
+
}
|
336
|
+
}-*/;
|
337
|
+
|
338
|
+
public abstract void setCapture(Element elem);
|
339
|
+
|
340
|
+
public native void setElementAttribute(Element elem, String attr, String value) /*-{
|
341
|
+
elem.setAttribute(attr, value);
|
342
|
+
}-*/;
|
343
|
+
|
344
|
+
public native void setElementProperty(Element elem, String prop, String value) /*-{
|
345
|
+
elem[prop] = value;
|
346
|
+
}-*/;
|
347
|
+
|
348
|
+
public native void setElementPropertyBoolean(Element elem, String prop,
|
349
|
+
boolean value) /*-{
|
350
|
+
elem[prop] = value;
|
351
|
+
}-*/;
|
352
|
+
|
353
|
+
public native void setElementPropertyInt(Element elem, String prop, int value) /*-{
|
354
|
+
elem[prop] = value;
|
355
|
+
}-*/;
|
356
|
+
|
357
|
+
public native void setEventListener(Element elem,
|
358
|
+
EventListener listener) /*-{
|
359
|
+
elem.__listener = listener;
|
360
|
+
}-*/;
|
361
|
+
|
362
|
+
public native void setImgSrc(Element img, String src) /*-{
|
363
|
+
img.src = src;
|
364
|
+
}-*/;
|
365
|
+
|
366
|
+
public native void setInnerHTML(Element elem, String html) /*-{
|
367
|
+
if (!html) {
|
368
|
+
html = '';
|
369
|
+
}
|
370
|
+
elem.innerHTML = html;
|
371
|
+
}-*/;
|
372
|
+
|
373
|
+
public native void setInnerText(Element elem, String text) /*-{
|
374
|
+
// Remove all children first.
|
375
|
+
while (elem.firstChild) {
|
376
|
+
elem.removeChild(elem.firstChild);
|
377
|
+
}
|
378
|
+
// Add a new text node.
|
379
|
+
if (text != null) {
|
380
|
+
elem.appendChild($doc.createTextNode(text));
|
381
|
+
}
|
382
|
+
}-*/;
|
383
|
+
|
384
|
+
public native void setIntStyleAttribute(Element elem, String attr, int value) /*-{
|
385
|
+
elem.style[attr] = value;
|
386
|
+
}-*/;
|
387
|
+
|
388
|
+
public native void setOptionText(Element select, String text, int index) /*-{
|
389
|
+
// IE doesn't properly update the screen when you use
|
390
|
+
// setAttribute("option", text), so we instead directly assign to the
|
391
|
+
// 'option' property, which works correctly on all browsers.
|
392
|
+
var option = select.options[index];
|
393
|
+
option.text = text;
|
394
|
+
}-*/;
|
395
|
+
|
396
|
+
public native void setStyleAttribute(Element elem, String attr,
|
397
|
+
String value) /*-{
|
398
|
+
elem.style[attr] = value;
|
399
|
+
}-*/;
|
400
|
+
|
401
|
+
public abstract void sinkEvents(Element elem, int eventBits);
|
402
|
+
|
403
|
+
public native String toString(Element elem) /*-{
|
404
|
+
return elem.outerHTML;
|
405
|
+
}-*/;
|
406
|
+
|
407
|
+
/**
|
408
|
+
* Gets the height of the browser window's client area excluding the
|
409
|
+
* scroll bar.
|
410
|
+
*
|
411
|
+
* @return the window's client height
|
412
|
+
*/
|
413
|
+
public native int windowGetClientHeight() /*-{
|
414
|
+
return $doc.body.clientHeight;
|
415
|
+
}-*/;
|
416
|
+
|
417
|
+
/**
|
418
|
+
* Gets the width of the browser window's client area excluding the
|
419
|
+
* vertical scroll bar.
|
420
|
+
*
|
421
|
+
* @return the window's client width
|
422
|
+
*/
|
423
|
+
public native int windowGetClientWidth() /*-{
|
424
|
+
return $doc.body.clientWidth;
|
425
|
+
}-*/;
|
426
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2007 Google Inc.
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
5
|
+
* use this file except in compliance with the License. You may obtain a copy of
|
6
|
+
* the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
* License for the specific language governing permissions and limitations under
|
14
|
+
* the License.
|
15
|
+
*/
|
16
|
+
package com.google.gwt.user.client.impl;
|
17
|
+
|
18
|
+
import com.google.gwt.user.client.Element;
|
19
|
+
import com.google.gwt.user.client.Event;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Opera implementation of {@link com.google.gwt.user.client.impl.DOMImpl}.
|
23
|
+
*/
|
24
|
+
public class DOMImplOpera extends DOMImplStandard {
|
25
|
+
|
26
|
+
public native int eventGetButton(Event evt) /*-{
|
27
|
+
// Opera and IE disagree on what the button codes for left button should be.
|
28
|
+
// Translating to match IE standard.
|
29
|
+
var button = evt.button;
|
30
|
+
if(button == 0){
|
31
|
+
return 1;
|
32
|
+
} else {
|
33
|
+
return button || -1;
|
34
|
+
}
|
35
|
+
}-*/;
|
36
|
+
|
37
|
+
public native int eventGetMouseWheelVelocityY(Event evt) /*-{
|
38
|
+
return evt.detail * 4 || -1;
|
39
|
+
}-*/;
|
40
|
+
|
41
|
+
public native int getAbsoluteLeft(Element elem) /*-{
|
42
|
+
var left = 0;
|
43
|
+
var curr = elem.parentNode;
|
44
|
+
// This intentionally excludes body
|
45
|
+
while (curr != $doc.body) {
|
46
|
+
|
47
|
+
// see https://bugs.opera.com/show_bug.cgi?id=249965
|
48
|
+
// The net effect is that TR and TBODY elemnts report the scroll offsets
|
49
|
+
// of the BODY and HTML elements instead of 0.
|
50
|
+
if (curr.tagName != 'TR' && curr.tagName != 'TBODY') {
|
51
|
+
left -= curr.scrollLeft;
|
52
|
+
}
|
53
|
+
curr = curr.parentNode;
|
54
|
+
}
|
55
|
+
|
56
|
+
while (elem) {
|
57
|
+
left += elem.offsetLeft;
|
58
|
+
elem = elem.offsetParent;
|
59
|
+
}
|
60
|
+
return left;
|
61
|
+
}-*/;
|
62
|
+
|
63
|
+
public native int getAbsoluteTop(Element elem) /*-{
|
64
|
+
var top = 0;
|
65
|
+
|
66
|
+
// This intentionally excludes body
|
67
|
+
var curr = elem.parentNode;
|
68
|
+
while (curr != $doc.body) {
|
69
|
+
// see getAbsoluteLeft()
|
70
|
+
if (curr.tagName != 'TR' && curr.tagName != 'TBODY') {
|
71
|
+
top -= curr.scrollTop;
|
72
|
+
}
|
73
|
+
curr = curr.parentNode;
|
74
|
+
}
|
75
|
+
|
76
|
+
while (elem) {
|
77
|
+
top += elem.offsetTop;
|
78
|
+
elem = elem.offsetParent;
|
79
|
+
}
|
80
|
+
return top;
|
81
|
+
}-*/;
|
82
|
+
}
|