A rather large change that adds a DOM module/package, implementing more or less
everything in the DOM Level 2 spec, in an optimally efficient way. It also
updates the existing DOM static methods to pass through to the Document and
Element classes.
See http://code.google.com/p/google-web-toolkit/wiki/JavaScriptObjectRedesign
and http://code.google.com/p/google-web-toolkit/wiki/DomClassHierarchyDesign
for details.
Patch by: jgw
Review by: bruce (desk check)
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2349 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/dom/DOM.gwt.xml b/user/src/com/google/gwt/dom/DOM.gwt.xml
new file mode 100644
index 0000000..6bb3d67
--- /dev/null
+++ b/user/src/com/google/gwt/dom/DOM.gwt.xml
@@ -0,0 +1,47 @@
+<!-- -->
+<!-- Copyright 2007 Google Inc. -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
+<!-- may not use this file except in compliance with the License. You may -->
+<!-- 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. License for the specific language governing permissions and -->
+<!-- limitations under the License. -->
+
+<!-- Deferred binding rules for browser selection. -->
+<!-- -->
+<!-- This module is typically inherited via com.google.gwt.user.User -->
+<!-- -->
+<module>
+ <inherits name="com.google.gwt.core.Core"/>
+ <inherits name="com.google.gwt.user.UserAgent"/>
+
+ <replace-with class="com.google.gwt.dom.client.DOMImplOpera">
+ <when-type-is class="com.google.gwt.dom.client.DOMImpl"/>
+ <when-property-is name="user.agent" value="opera"/>
+ </replace-with>
+
+ <replace-with class="com.google.gwt.dom.client.DOMImplSafari">
+ <when-type-is class="com.google.gwt.dom.client.DOMImpl"/>
+ <when-property-is name="user.agent" value="safari"/>
+ </replace-with>
+
+ <replace-with class="com.google.gwt.dom.client.DOMImplIE6">
+ <when-type-is class="com.google.gwt.dom.client.DOMImpl"/>
+ <when-property-is name="user.agent" value="ie6"/>
+ </replace-with>
+
+ <replace-with class="com.google.gwt.dom.client.DOMImplMozilla">
+ <when-type-is class="com.google.gwt.dom.client.DOMImpl"/>
+ <when-property-is name="user.agent" value="gecko1_8"/>
+ </replace-with>
+
+ <replace-with class="com.google.gwt.dom.client.DOMImplMozillaOld">
+ <when-type-is class="com.google.gwt.dom.client.DOMImpl"/>
+ <when-property-is name="user.agent" value="gecko"/>
+ </replace-with>
+</module>
diff --git a/user/src/com/google/gwt/dom/client/AnchorElement.java b/user/src/com/google/gwt/dom/client/AnchorElement.java
new file mode 100644
index 0000000..52fc824
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/AnchorElement.java
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * The anchor element.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#edef-A
+ */
+public class AnchorElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static AnchorElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("a");
+ return (AnchorElement) elem;
+ }
+
+ protected AnchorElement() {
+ }
+
+ /**
+ * Removes keyboard focus from this element.
+ */
+ public final native void blur() /*-{
+ this.blur();
+ }-*/;
+
+ /**
+ * Gives keyboard focus to this element.
+ */
+ public final native void focus() /*-{
+ this.focus();
+ }-*/;
+
+ /**
+ * A single character access key to give access to the form control.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey
+ */
+ public final native String getAccessKey() /*-{
+ return this.accessKey;
+ }-*/;
+
+ /**
+ * The absolute URI of the linked resource.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href
+ */
+ public final native String getHref() /*-{
+ return this.href;
+ }-*/;
+
+ /**
+ * Language code of the linked resource.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-hreflang
+ */
+ public final native String getHreflang() /*-{
+ return this.hreflang;
+ }-*/;
+
+ /**
+ * Anchor name.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-name-A
+ */
+ public final native String getName() /*-{
+ return this.name;
+ }-*/;
+
+ /**
+ * Forward link type.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-rel
+ */
+ public final native String getRel() /*-{
+ return this.name;
+ }-*/;
+
+ /**
+ * Index that represents the element's position in the tabbing order.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex
+ */
+ public final native int getTabIndex() /*-{
+ return this.tabIndex;
+ }-*/;
+
+ /**
+ * Frame to render the resource in.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-target
+ */
+ public final native String getTarget() /*-{
+ return this.target;
+ }-*/;
+
+ /**
+ * Advisory content type.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-type-A
+ */
+ public final native String getType() /*-{
+ return this.type;
+ }-*/;
+
+ /**
+ * A single character access key to give access to the form control.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey
+ */
+ public final native void setAccessKey(String accessKey) /*-{
+ this.accessKey = accessKey;
+ }-*/;
+
+ /**
+ * The absolute URI of the linked resource.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href
+ */
+ public final native void setHref(String href) /*-{
+ this.href = href;
+ }-*/;
+
+ /**
+ * Language code of the linked resource.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-hreflang
+ */
+ public final native void setHreflang(String hreflang) /*-{
+ this.hreflang = hreflang;
+ }-*/;
+
+ /**
+ * Anchor name.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-name-A
+ */
+ public final native void setName(String name) /*-{
+ this.name = name;
+ }-*/;
+
+ /**
+ * Forward link type.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-rel
+ */
+ public final native void setRel(String name) /*-{
+ this.name = name;
+ }-*/;
+
+ /**
+ * Index that represents the element's position in the tabbing order.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex
+ */
+ public final native void setTabIndex(int tabIndex) /*-{
+ this.tabIndex = tabIndex;
+ }-*/;
+
+ /**
+ * Frame to render the resource in.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-target
+ */
+ public final native void setTarget(String target) /*-{
+ this.target = target;
+ }-*/;
+
+ /**
+ * Advisory content type.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-type-A
+ */
+ public final native void setType(String type) /*-{
+ this.type = type;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/AreaElement.java b/user/src/com/google/gwt/dom/client/AreaElement.java
new file mode 100644
index 0000000..6d62555
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/AreaElement.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Client-side image map area definition.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#edef-AREA
+ */
+public class AreaElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static AreaElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("area");
+ return (AreaElement) elem;
+ }
+
+ protected AreaElement() {
+ }
+
+ /**
+ * A single character access key to give access to the form control.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey
+ */
+ public final native String getAccessKey() /*-{
+ return this.accessKey;
+ }-*/;
+
+ /**
+ * Alternate text for user agents not rendering the normal content of this
+ * element.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-alt
+ */
+ public final native String getAlt() /*-{
+ return this.alt;
+ }-*/;
+
+ /**
+ * Comma-separated list of lengths, defining an active region geometry. See
+ * also shape for the shape of the region.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-coords
+ */
+ public final native String getCoords() /*-{
+ return this.coords;
+ }-*/;
+
+ /**
+ * The URI of the linked resource.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href
+ */
+ public final native String getHref() /*-{
+ return this.href;
+ }-*/;
+
+ /**
+ * The shape of the active area. The coordinates are given by coords.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-shape
+ */
+ public final native String getShape() /*-{
+ return this.shape;
+ }-*/;
+
+ /**
+ * Index that represents the element's position in the tabbing order.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex
+ */
+ public final native int getTabIndex() /*-{
+ return this.tabIndex;
+ }-*/;
+
+ /**
+ * Frame to render the resource in.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-target
+ */
+ public final native String getTarget() /*-{
+ return this.target;
+ }-*/;
+
+ /**
+ * A single character access key to give access to the form control.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey
+ */
+ public final native void setAccessKey(String accessKey) /*-{
+ this.accessKey = accessKey;
+ }-*/;
+
+ /**
+ * Alternate text for user agents not rendering the normal content of this
+ * element.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-alt
+ */
+ public final native void setAlt(String alt) /*-{
+ this.alt = alt;
+ }-*/;
+
+ /**
+ * Comma-separated list of lengths, defining an active region geometry. See
+ * also shape for the shape of the region.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-coords
+ */
+ public final native void setCoords(String coords) /*-{
+ this.coords = coords;
+ }-*/;
+
+ /**
+ * The URI of the linked resource.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href
+ */
+ public final native void setHref(String href) /*-{
+ this.href = href;
+ }-*/;
+
+ /**
+ * The shape of the active area. The coordinates are given by coords.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-shape
+ */
+ public final native void setShape(String shape) /*-{
+ this.shape = shape;
+ }-*/;
+
+ /**
+ * Index that represents the element's position in the tabbing order.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex
+ */
+ public final native void setTabIndex(int tabIndex) /*-{
+ this.tabIndex = tabIndex;
+ }-*/;
+
+ /**
+ * Frame to render the resource in.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-target
+ */
+ public final native void setTarget(String target) /*-{
+ this.target = target;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/BRElement.java b/user/src/com/google/gwt/dom/client/BRElement.java
new file mode 100644
index 0000000..7c44b4d
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/BRElement.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Force a line break.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/text.html#edef-BR
+ */
+public class BRElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static BRElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("br");
+ return (BRElement) elem;
+ }
+
+ protected BRElement() {
+ }
+}
diff --git a/user/src/com/google/gwt/dom/client/BaseElement.java b/user/src/com/google/gwt/dom/client/BaseElement.java
new file mode 100644
index 0000000..5863ca6
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/BaseElement.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Document base URI.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#edef-BASE
+ */
+public class BaseElement extends Element{
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static BaseElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("base");
+ return (BaseElement) elem;
+ }
+
+ protected BaseElement() {
+ }
+
+ /**
+ * The base URI See the href attribute definition in HTML
+ * 4.01.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href-BASE
+ */
+ public final native String getHref() /*-{
+ return this.href;
+ }-*/;
+
+ /**
+ * The base URI See the href attribute definition in HTML
+ * 4.01.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href-BASE
+ */
+ public final native void setHref(String href) /*-{
+ this.href = href;
+ }-*/;
+
+ /**
+ * The default target frame.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-target
+ */
+ public final native String getTarget() /*-{
+ return this.target;
+ }-*/;
+
+ /**
+ * The default target frame.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-target
+ */
+ public final native void setTarget(String target) /*-{
+ this.target = target;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/BodyElement.java b/user/src/com/google/gwt/dom/client/BodyElement.java
new file mode 100644
index 0000000..cc5f60b
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/BodyElement.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * The HTML document body. This element is always present in the DOM API, even
+ * if the tags are not present in the source document.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#edef-BODY
+ */
+public class BodyElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static BodyElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("body");
+ return (BodyElement) elem;
+ }
+
+ protected BodyElement() {
+ }
+}
diff --git a/user/src/com/google/gwt/dom/client/ButtonElement.java b/user/src/com/google/gwt/dom/client/ButtonElement.java
new file mode 100644
index 0000000..0d6608c
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/ButtonElement.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Push button.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#edef-BUTTON
+ */
+public class ButtonElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static ButtonElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("button");
+ return (ButtonElement) elem;
+ }
+
+ protected ButtonElement() {
+ }
+
+ /**
+ * Simulate a mouse-click.
+ */
+ public final native void click() /*-{
+ this.click();
+ }-*/;
+
+ /**
+ * Returns the FORM element containing this control. Returns null if this
+ * control is not within the context of a form.
+ */
+ public final native FormElement getForm() /*-{
+ return this.form;
+ }-*/;
+
+ /**
+ * A single character access key to give access to the form control.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey
+ */
+ public final native String getAccessKey() /*-{
+ return this.accessKey;
+ }-*/;
+
+ /**
+ * A single character access key to give access to the form control.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey
+ */
+ public final native void setAccessKey(String accessKey) /*-{
+ this.accessKey = accessKey;
+ }-*/;
+
+ /**
+ * The control is unavailable in this context.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled
+ */
+ public final native String getDisabled() /*-{
+ return this.disabled;
+ }-*/;
+
+ /**
+ * The control is unavailable in this context.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled
+ */
+ public final native void setDisabled(String disabled) /*-{
+ this.disabled = disabled;
+ }-*/;
+
+ /**
+ * Form control or object name when submitted with a form.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-name-BUTTON
+ */
+ public final native String getName() /*-{
+ return this.name;
+ }-*/;
+
+ /**
+ * Form control or object name when submitted with a form.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-name-BUTTON
+ */
+ public final native void setName(String name) /*-{
+ this.name = name;
+ }-*/;
+
+ /**
+ * Index that represents the element's position in the tabbing order.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex
+ */
+ public final native int getTabIndex() /*-{
+ return this.tabIndex;
+ }-*/;
+
+ /**
+ * Index that represents the element's position in the tabbing order.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex
+ */
+ public final native void setTabIndex(int tabIndex) /*-{
+ this.tabIndex = tabIndex;
+ }-*/;
+
+ /**
+ * The type of button (all lower case).
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-type-BUTTON
+ */
+ public final native String getType() /*-{
+ return this.type;
+ }-*/;
+
+ /**
+ * The current form control value.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-value-BUTTON
+ */
+ public final native String getValue() /*-{
+ return this.value;
+ }-*/;
+
+ /**
+ * The current form control value.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-value-BUTTON
+ */
+ public final native void setValue(String value) /*-{
+ this.value = value;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/DListElement.java b/user/src/com/google/gwt/dom/client/DListElement.java
new file mode 100644
index 0000000..0dd827a
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/DListElement.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Definition list.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/lists.html#edef-DL
+ */
+public class DListElement extends Element {
+
+ public static DListElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("dl");
+ return (DListElement) elem;
+ }
+
+ protected DListElement() {
+ }
+}
diff --git a/user/src/com/google/gwt/dom/client/DOMImpl.java b/user/src/com/google/gwt/dom/client/DOMImpl.java
new file mode 100644
index 0000000..40964fc
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/DOMImpl.java
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+import com.google.gwt.core.client.GWT;
+
+abstract class DOMImpl {
+
+ static final DOMImpl impl = GWT.create(DOMImpl.class);
+
+ public native Element createElement(String tag) /*-{
+ return $doc.createElement(tag);
+ }-*/;
+
+ public native InputElement createInputElement(String type) /*-{
+ var e = $doc.createElement("INPUT");
+ e.type = type;
+ return e;
+ }-*/;
+
+ public abstract InputElement createInputRadioElement(String name);
+
+ public SelectElement createSelectElement(boolean multiple) {
+ SelectElement select = (SelectElement) createElement("select");
+ if (multiple) {
+ select.setMultiple(true);
+ }
+ return select;
+ }
+
+ public native int getAbsoluteLeft(Element elem) /*-{
+ var left = 0;
+ var curr = elem;
+ // This intentionally excludes body which has a null offsetParent.
+ while (curr.offsetParent) {
+ left -= curr.scrollLeft;
+ curr = curr.parentNode;
+ }
+ while (elem) {
+ left += elem.offsetLeft;
+ elem = elem.offsetParent;
+ }
+ return left;
+ }-*/;
+
+ public native int getAbsoluteTop(Element elem) /*-{
+ var top = 0;
+ var curr = elem;
+ // This intentionally excludes body which has a null offsetParent.
+ while (curr.offsetParent) {
+ top -= curr.scrollTop;
+ curr = curr.parentNode;
+ }
+ while (elem) {
+ top += elem.offsetTop;
+ elem = elem.offsetParent;
+ }
+ return top;
+ }-*/;
+
+ public native String getInnerHTML(Element elem) /*-{
+ var ret = elem.innerHTML;
+ return (ret == null) ? null : ret;
+ }-*/;
+
+ public native String getInnerText(Element node) /*-{
+ // To mimic IE's 'innerText' property in the W3C DOM, we need to recursively
+ // concatenate all child text nodes (depth first).
+ var text = '', child = node.firstChild;
+ while (child) {
+ // 1 == Element node
+ if (child.nodeType == 1) {
+ text += this.@com.google.gwt.dom.client.DOMImpl::getInnerText(Lcom/google/gwt/dom/client/Element;)(child);
+ } else if (child.nodeValue) {
+ text += child.nodeValue;
+ }
+ child = child.nextSibling;
+ }
+ return text;
+ }-*/;
+
+ public native int getIntStyleAttribute(Element elem, String attr) /*-{
+ return parseInt(elem.style[attr]) || 0;
+ }-*/;
+
+ public native Element getFirstChildElement(Element elem) /*-{
+ var child = elem.firstChild;
+ while (child && child.nodeType != 1)
+ child = child.nextSibling;
+ return child || null;
+ }-*/;
+
+ public native Element getNextSiblingElement(Element elem) /*-{
+ var sib = elem.nextSibling;
+ while (sib && sib.nodeType != 1)
+ sib = sib.nextSibling;
+ return sib || null;
+ }-*/;
+
+ public native Element getParentElement(Element elem) /*-{
+ var parent = elem.parentNode;
+ if (parent == null) {
+ return null;
+ }
+ if (parent.nodeType != 1)
+ parent = null;
+ return parent || null;
+ }-*/;
+
+ public native String getStyleAttribute(Element elem, String attr) /*-{
+ var ret = elem.style[attr];
+ return (ret == null) ? null : ret;
+ }-*/;
+
+ public native String imgGetSrc(Element img) /*-{
+ return img.src;
+ }-*/;
+
+ public native void imgSetSrc(Element img, String src) /*-{
+ img.src = src;
+ }-*/;
+
+ public abstract boolean isOrHasChild(Element parent, Element child);
+
+ public native void scrollIntoView(Element elem) /*-{
+ var left = elem.offsetLeft, top = elem.offsetTop;
+ var width = elem.offsetWidth, height = elem.offsetHeight;
+
+ if (elem.parentNode != elem.offsetParent) {
+ left -= elem.parentNode.offsetLeft;
+ top -= elem.parentNode.offsetTop;
+ }
+
+ var cur = elem.parentNode;
+ while (cur && (cur.nodeType == 1)) {
+ if (left < cur.scrollLeft) {
+ cur.scrollLeft = left;
+ }
+ if (left + width > cur.scrollLeft + cur.clientWidth) {
+ cur.scrollLeft = (left + width) - cur.clientWidth;
+ }
+ if (top < cur.scrollTop) {
+ cur.scrollTop = top;
+ }
+ if (top + height > cur.scrollTop + cur.clientHeight) {
+ cur.scrollTop = (top + height) - cur.clientHeight;
+ }
+
+ var offsetLeft = cur.offsetLeft, offsetTop = cur.offsetTop;
+ if (cur.parentNode != cur.offsetParent) {
+ offsetLeft -= cur.parentNode.offsetLeft;
+ offsetTop -= cur.parentNode.offsetTop;
+ }
+
+ left += offsetLeft - cur.scrollLeft;
+ top += offsetTop - cur.scrollTop;
+ cur = cur.parentNode;
+ }
+ }-*/;
+
+ public native int selectGetLength(SelectElement select) /*-{
+ return select.options.length;
+ }-*/;
+
+ public native NodeList<OptionElement> selectGetOptions(SelectElement select) /*-{
+ return select.options;
+ }-*/;
+
+ public native void selectAdd(SelectElement select, OptionElement option,
+ OptionElement before) /*-{
+ select.add(option, before);
+ }-*/;
+
+ public native void selectRemoveOption(SelectElement select, int index) /*-{
+ select.remove(index);
+ }-*/;
+
+ public native void setInnerText(Element elem, String text) /*-{
+ // Remove all children first.
+ while (elem.firstChild) {
+ elem.removeChild(elem.firstChild);
+ }
+ // Add a new text node.
+ if (text != null) {
+ elem.appendChild($doc.createTextNode(text));
+ }
+ }-*/;
+
+ public native void setIntStyleAttribute(Element elem, String attr, int value) /*-{
+ elem.style[attr] = value;
+ }-*/;
+
+ public native void setStyleAttribute(Element elem, String attr, String value) /*-{
+ elem.style[attr] = value;
+ }-*/;
+
+ public native String toString(Element elem) /*-{
+ return elem.outerHTML;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/DOMImplIE6.java b/user/src/com/google/gwt/dom/client/DOMImplIE6.java
new file mode 100644
index 0000000..a41f4f5
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/DOMImplIE6.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Internet Explorer 6 implementation of
+ * {@link com.google.gwt.user.client.impl.DOMImpl}.
+ */
+class DOMImplIE6 extends DOMImpl {
+
+ @Override
+ public native InputElement createInputRadioElement(String name) /*-{
+ return $doc.createElement("<INPUT type='RADIO' name='" + name + "'>");
+ }-*/;
+
+ /**
+ * Supports creating a select control with the multiple attribute to work
+ * around a bug in IE6 where changing the multiple attribute in a setAttribute
+ * call can cause subsequent setSelected calls to misbehave. Although this bug
+ * is fixed in IE7, this DOMImpl specialization is used for both IE6 and IE7,
+ * but it should be harmless.
+ */
+ @Override
+ public native SelectElement createSelectElement(boolean multiple) /*-{
+ var html = multiple ? "<SELECT MULTIPLE>" : "<SELECT>";
+ return $doc.createElement(html);
+ }-*/;
+
+ @Override
+ public native int getAbsoluteLeft(Element elem) /*-{
+ return elem.getBoundingClientRect().left
+ + @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.scrollLeft
+ - @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.clientLeft;
+ }-*/;
+
+ @Override
+ public native int getAbsoluteTop(Element elem) /*-{
+ return elem.getBoundingClientRect().top
+ + @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.scrollTop
+ - @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.clientTop;
+ }-*/;
+
+ @Override
+ public native String getInnerText(Element elem) /*-{
+ var ret = elem.innerText;
+ return (ret == null) ? null : ret;
+ }-*/;
+
+ @Override
+ public native Element getParentElement(Element elem) /*-{
+ var parent = elem.parentElement;
+ return parent || null;
+ }-*/;
+
+ /*
+ * The src may not be set yet because of funky logic in setImgSrc(). See
+ * setImgSrc().
+ */
+ @Override
+ public String imgGetSrc(Element img) {
+ return ImageSrcIE6.getImgSrc(img);
+ }
+
+ /**
+ * Works around an IE problem where multiple images trying to load at the same
+ * time will generate a request per image. We fix this by only allowing the
+ * first image of a given URL to set its source immediately, but simultaneous
+ * requests for the same URL don't actually get their source set until the
+ * original load is complete.
+ */
+ @Override
+ public void imgSetSrc(Element img, String src) {
+ ImageSrcIE6.setImgSrc(img, src);
+ }
+
+ @Override
+ public native boolean isOrHasChild(Element parent, Element child) /*-{
+ // An extra equality check is required due to the fact that
+ // elem.contains(elem) is false if elem is not attached to the DOM.
+ return (parent === child) || parent.contains(child);
+ }-*/;
+
+ @Override
+ public native void selectAdd(SelectElement select, OptionElement option,
+ OptionElement before) /*-{
+ // IE only accepts indices for the second argument.
+ if (before) {
+ select.add(option, before.index);
+ } else {
+ select.add(option);
+ }
+ }-*/;
+
+ @Override
+ public native void setInnerText(Element elem, String text) /*-{
+ elem.innerText = text || '';
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/DOMImplMozilla.java b/user/src/com/google/gwt/dom/client/DOMImplMozilla.java
new file mode 100644
index 0000000..3b9d0ec
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/DOMImplMozilla.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Mozilla implementation of StandardBrowser.
+ */
+class DOMImplMozilla extends DOMImplStandard {
+
+ @Override
+ public native int getAbsoluteLeft(Element elem) /*-{
+ // We cannot use DOMImpl here because offsetLeft/Top return erroneous
+ // values when overflow is not visible. We have to difference screenX
+ // here due to a change in getBoxObjectFor which causes inconsistencies
+ // on whether the calculations are inside or outside of the element's
+ // border.
+ try {
+ return $doc.getBoxObjectFor(elem).screenX
+ - $doc.getBoxObjectFor($doc.documentElement).screenX;
+ } catch (e) {
+ // This works around a bug in the FF3 betas. The bug
+ // should be fixed before they release, so this can
+ // be removed at a later date.
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=409111
+ // DOMException.WRONG_DOCUMENT_ERR == 4
+ if (e.code == 4) {
+ return 0;
+ }
+ throw e;
+ }
+ }-*/;
+
+ @Override
+ public native int getAbsoluteTop(Element elem) /*-{
+ // We cannot use DOMImpl here because offsetLeft/Top return erroneous
+ // values when overflow is not visible. We have to difference screenY
+ // here due to a change in getBoxObjectFor which causes inconsistencies
+ // on whether the calculations are inside or outside of the element's
+ // border.
+ try {
+ return $doc.getBoxObjectFor(elem).screenY
+ - $doc.getBoxObjectFor($doc.documentElement).screenY;
+ } catch (e) {
+ // This works around a bug in the FF3 betas. The bug
+ // should be fixed before they release, so this can
+ // be removed at a later date.
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=409111
+ // DOMException.WRONG_DOCUMENT_ERR == 4
+ if (e.code == 4) {
+ return 0;
+ }
+ throw e;
+ }
+ }-*/;
+
+ @Override
+ public native boolean isOrHasChild(Element parent, Element child) /*-{
+ // For more information about compareDocumentPosition, see:
+ // http://www.quirksmode.org/blog/archives/2006/01/contains_for_mo.html
+ return (parent === child) || !!(parent.compareDocumentPosition(child) & 16);
+ }-*/;
+
+ @Override
+ public native String toString(Element elem) /*-{
+ // Basic idea is to use the innerHTML property by copying the node into a
+ // div and getting the innerHTML
+ var temp = elem.cloneNode(true);
+ var tempDiv = $doc.createElement("DIV");
+ tempDiv.appendChild(temp);
+ outer = tempDiv.innerHTML;
+ temp.innerHTML = "";
+ return outer;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/DOMImplMozillaOld.java b/user/src/com/google/gwt/dom/client/DOMImplMozillaOld.java
new file mode 100644
index 0000000..d457fad
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/DOMImplMozillaOld.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * DOM implementation differences for older version of Mozilla (mostly the
+ * hosted mode browser on linux). The main difference is due to changes in
+ * getBoxObjectFor in later versions of mozilla. The relevant bugzilla issues:
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=328881
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=330619
+ */
+public class DOMImplMozillaOld extends DOMImplMozilla {
+
+ @Override
+ public native int getAbsoluteLeft(Element elem) /*-{
+ var style = $doc.defaultView.getComputedStyle(elem, null);
+ var left = $doc.getBoxObjectFor(elem).x - Math.round(
+ style.getPropertyCSSValue('border-left-width').getFloatValue(
+ CSSPrimitiveValue.CSS_PX));
+
+ var parent = elem.parentNode;
+ while (parent) {
+ // Sometimes get NAN.
+ if (parent.scrollLeft > 0) {
+ left -= parent.scrollLeft;
+ }
+ parent = parent.parentNode;
+ }
+
+ return left +
+ @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.scrollLeft;
+ }-*/;
+
+ @Override
+ public native int getAbsoluteTop(Element elem) /*-{
+ var style = $doc.defaultView.getComputedStyle(elem, null);
+ var top = $doc.getBoxObjectFor(elem).y - Math.round(
+ style.getPropertyCSSValue('border-top-width').getFloatValue(
+ CSSPrimitiveValue.CSS_PX));
+
+ var parent = elem.parentNode;
+ while (parent) {
+ // Sometimes get NAN.
+ if (parent.scrollTop > 0) {
+ top -= parent.scrollTop;
+ }
+ parent = parent.parentNode;
+ }
+
+ return top +
+ @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.scrollTop;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/DOMImplOpera.java b/user/src/com/google/gwt/dom/client/DOMImplOpera.java
new file mode 100644
index 0000000..6080d85
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/DOMImplOpera.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Opera implementation of {@link com.google.gwt.user.client.impl.DOMImpl}.
+ */
+public class DOMImplOpera extends DOMImplStandard {
+
+ @Override
+ public native int getAbsoluteLeft(Element elem) /*-{
+ var left = 0;
+ var curr = elem.parentNode;
+ // This intentionally excludes body
+ while (curr != $doc.body) {
+
+ // see https://bugs.opera.com/show_bug.cgi?id=249965
+ // The net effect is that TR and TBODY elemnts report the scroll offsets
+ // of the BODY and HTML elements instead of 0.
+ if (curr.tagName != 'TR' && curr.tagName != 'TBODY') {
+ left -= curr.scrollLeft;
+ }
+ curr = curr.parentNode;
+ }
+
+ while (elem) {
+ left += elem.offsetLeft;
+ elem = elem.offsetParent;
+ }
+ return left;
+ }-*/;
+
+ @Override
+ public native int getAbsoluteTop(Element elem) /*-{
+ var top = 0;
+
+ // This intentionally excludes body
+ var curr = elem.parentNode;
+ while (curr != $doc.body) {
+ // see getAbsoluteLeft()
+ if (curr.tagName != 'TR' && curr.tagName != 'TBODY') {
+ top -= curr.scrollTop;
+ }
+ curr = curr.parentNode;
+ }
+
+ while (elem) {
+ top += elem.offsetTop;
+ elem = elem.offsetParent;
+ }
+ return top;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/DOMImplSafari.java b/user/src/com/google/gwt/dom/client/DOMImplSafari.java
new file mode 100644
index 0000000..6d34d26
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/DOMImplSafari.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Safari implementation of {@link com.google.gwt.user.client.impl.DOMImpl}.
+ */
+class DOMImplSafari extends DOMImplStandard {
+
+ @Override
+ public native int getAbsoluteLeft(Element elem) /*-{
+ // Unattached elements and elements (or their ancestors) with style
+ // 'display: none' have no offsetLeft.
+ if (elem.offsetLeft == null) {
+ return 0;
+ }
+
+ var left = 0;
+ var curr = elem.parentNode;
+ if (curr) {
+ // This intentionally excludes body which has a null offsetParent.
+ while (curr.offsetParent) {
+ left -= curr.scrollLeft;
+ curr = curr.parentNode;
+ }
+ }
+
+ while (elem) {
+ left += elem.offsetLeft;
+
+ // Safari bug: a top-level absolutely positioned element includes the
+ // body's offset position already.
+ var parent = elem.offsetParent;
+ if (parent && (parent.tagName == 'BODY') &&
+ (elem.style.position == 'absolute')) {
+ break;
+ }
+
+ elem = parent;
+ }
+ return left;
+ }-*/;
+
+ @Override
+ public native int getAbsoluteTop(Element elem) /*-{
+ // Unattached elements and elements (or their ancestors) with style
+ // 'display: none' have no offsetTop.
+ if (elem.offsetTop == null) {
+ return 0;
+ }
+
+ var top = 0;
+ var curr = elem.parentNode;
+ if (curr) {
+ // This intentionally excludes body which has a null offsetParent.
+ while (curr.offsetParent) {
+ top -= curr.scrollTop;
+ curr = curr.parentNode;
+ }
+ }
+
+ while (elem) {
+ top += elem.offsetTop;
+
+ // Safari bug: a top-level absolutely positioned element includes the
+ // body's offset position already.
+ var parent = elem.offsetParent;
+ if (parent && (parent.tagName == 'BODY') &&
+ (elem.style.position == 'absolute')) {
+ break;
+ }
+
+ elem = parent;
+ }
+ return top;
+ }-*/;
+
+ @Override
+ public native boolean isOrHasChild(Element parent, Element child) /*-{
+ while (child) {
+ if (parent == child) {
+ return true;
+ }
+ child = child.parentNode;
+ if (child && (child.nodeType != 1)) {
+ child = null;
+ }
+ }
+ return false;
+ }-*/;
+
+ /*
+ * The 'options' array cannot be used due to a bug in the version of WebKit
+ * that ships with GWT (http://bugs.webkit.org/show_bug.cgi?id=10472). The
+ * 'children' array, which is common for all DOM elements in Safari, does not
+ * suffer from the same problem. Ideally, the 'children' array should be used
+ * in all of the traversal methods in the DOM classes. Unfortunately, due to a
+ * bug in Safari 2 (http://bugs.webkit.org/show_bug.cgi?id=3330), this will
+ * not work. However, this bug does not cause problems in the case of <SELECT>
+ * elements, because their descendent elements are only one level deep.
+ */
+
+ @Override
+ public native int selectGetLength(SelectElement select) /*-{
+ return select.children.length;
+ }-*/;
+
+ @Override
+ public native NodeList<OptionElement> selectGetOptions(SelectElement select) /*-{
+ return select.children;
+ }-*/;
+
+ @Override
+ public native void selectRemoveOption(SelectElement select, int index) /*-{
+ select.removeChild(select.children[index]);
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/DOMImplStandard.java b/user/src/com/google/gwt/dom/client/DOMImplStandard.java
new file mode 100644
index 0000000..847b7d3
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/DOMImplStandard.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2007 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Base implementation of {@link com.google.gwt.user.client.impl.DOMImpl} shared
+ * by those browsers that come a bit closer to supporting a common standard (ie,
+ * not IE).
+ */
+abstract class DOMImplStandard extends DOMImpl {
+
+ @Override
+ public native InputElement createInputRadioElement(String name) /*-{
+ var elem = $doc.createElement("INPUT");
+ elem.type = 'radio';
+ elem.name = name;
+ return elem;
+ }-*/;
+
+ @Override
+ public native boolean isOrHasChild(Element parent, Element child) /*-{
+ return parent.contains(child);
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/DivElement.java b/user/src/com/google/gwt/dom/client/DivElement.java
new file mode 100644
index 0000000..b43871a
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/DivElement.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Generic block container.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#edef-DIV
+ */
+public class DivElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static DivElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("div");
+ return (DivElement) elem;
+ }
+
+ protected DivElement() {
+ }
+}
diff --git a/user/src/com/google/gwt/dom/client/Document.java b/user/src/com/google/gwt/dom/client/Document.java
new file mode 100644
index 0000000..d5fde31
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/Document.java
@@ -0,0 +1,315 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * A Document is the root of the HTML hierarchy and holds the entire
+ * content. Besides providing access to the hierarchy, it also provides some
+ * convenience methods for accessing certain sets of information from the
+ * document.
+ */
+public class Document extends Node {
+
+ private static int curUidIndex = 0;
+
+ public static native Document get() /*-{
+ return $doc;
+ }-*/;
+
+ protected Document() {
+ }
+
+ public final AnchorElement createAnchorElement() {
+ return (AnchorElement) DOMImpl.impl.createElement("a");
+ }
+
+ public final AreaElement createAreaElement() {
+ return (AreaElement) DOMImpl.impl.createElement("area");
+ }
+
+ public final BaseElement createBaseElement() {
+ return (BaseElement) DOMImpl.impl.createElement("base");
+ }
+
+ public final QuoteElement createBlockQuoteElement() {
+ return (QuoteElement) DOMImpl.impl.createElement("blockquote");
+ }
+
+ public final BRElement createBRElement() {
+ return (BRElement) DOMImpl.impl.createElement("br");
+ }
+
+ public final ButtonElement createButtonElement() {
+ return (ButtonElement) DOMImpl.impl.createElement("button");
+ }
+
+ public final TableCaptionElement createCaptionElement() {
+ return (TableCaptionElement) DOMImpl.impl.createElement("caption");
+ }
+
+ public final InputElement createCheckInputElement() {
+ return DOMImpl.impl.createInputElement("checkbox");
+ }
+
+ public final TableColElement createColElement() {
+ return (TableColElement) DOMImpl.impl.createElement("col");
+ }
+
+ public final TableColElement createColGroupElement() {
+ return (TableColElement) DOMImpl.impl.createElement("colgroup");
+ }
+
+ public final ModElement createDelElement() {
+ return (ModElement) DOMImpl.impl.createElement("del");
+ }
+
+ public final DivElement createDivElement() {
+ return (DivElement) DOMImpl.impl.createElement("div");
+ }
+
+ public final DListElement createDLElement() {
+ return (DListElement) DOMImpl.impl.createElement("dl");
+ }
+
+ public final Element createElement(String tagName) {
+ return DOMImpl.impl.createElement(tagName);
+ }
+
+ public final FieldSetElement createFieldSetElement() {
+ return (FieldSetElement) DOMImpl.impl.createElement("fieldset");
+ }
+
+ public final InputElement createFileInputElement() {
+ return DOMImpl.impl.createInputElement("file");
+ }
+
+ public final FormElement createFormElement() {
+ return (FormElement) DOMImpl.impl.createElement("form");
+ }
+
+ public final FrameElement createFrameElement() {
+ return (FrameElement) DOMImpl.impl.createElement("frame");
+ }
+
+ public final FrameSetElement createFrameSetElement() {
+ return (FrameSetElement) DOMImpl.impl.createElement("frameset");
+ }
+
+ public final HeadElement createHeadElement() {
+ return (HeadElement) DOMImpl.impl.createElement("head");
+ }
+
+ public final HeadingElement createHElement(int n) {
+ assert (n >= 1) && (n <= 6);
+ return (HeadingElement) DOMImpl.impl.createElement("h" + n);
+ }
+
+ public final InputElement createHiddenInputElement() {
+ return DOMImpl.impl.createInputElement("hidden");
+ }
+
+ public final HRElement createHRElement() {
+ return (HRElement) DOMImpl.impl.createElement("hr");
+ }
+
+ public final IFrameElement createIFrameElement() {
+ return (IFrameElement) DOMImpl.impl.createElement("iframe");
+ }
+
+ public final ImageElement createImageElement() {
+ return (ImageElement) DOMImpl.impl.createElement("img");
+ }
+
+ public final InputElement createImageInputElement() {
+ return DOMImpl.impl.createInputElement("image");
+ }
+
+ public final ModElement createInsElement() {
+ return (ModElement) DOMImpl.impl.createElement("ins");
+ }
+
+ public final LabelElement createLabelElement() {
+ return (LabelElement) DOMImpl.impl.createElement("label");
+ }
+
+ public final LegendElement createLegendElement() {
+ return (LegendElement) DOMImpl.impl.createElement("legend");
+ }
+
+ public final LIElement createLIElement() {
+ return (LIElement) DOMImpl.impl.createElement("li");
+ }
+
+ public final LinkElement createLinkElement() {
+ return (LinkElement) DOMImpl.impl.createElement("link");
+ }
+
+ public final MapElement createMapElement() {
+ return (MapElement) DOMImpl.impl.createElement("map");
+ }
+
+ public final MetaElement createMetaElement() {
+ return (MetaElement) DOMImpl.impl.createElement("meta");
+ }
+
+ public final ObjectElement createObjectElement() {
+ return (ObjectElement) DOMImpl.impl.createElement("object");
+ }
+
+ public final OListElement createOLElement() {
+ return (OListElement) DOMImpl.impl.createElement("ol");
+ }
+
+ public final OptGroupElement createOptGroupElement() {
+ return (OptGroupElement) DOMImpl.impl.createElement("optgroup");
+ }
+
+ public final OptionElement createOptionElement() {
+ return (OptionElement) DOMImpl.impl.createElement("option");
+ }
+
+ public final ParamElement createParamElement() {
+ return (ParamElement) DOMImpl.impl.createElement("param");
+ }
+
+ public final InputElement createPasswordInputElement() {
+ return DOMImpl.impl.createInputElement("password");
+ }
+
+ public final ParagraphElement createPElement() {
+ return (ParagraphElement) DOMImpl.impl.createElement("p");
+ }
+
+ public final PreElement createPreElement() {
+ return (PreElement) DOMImpl.impl.createElement("pre");
+ }
+
+ public final QuoteElement createQElement() {
+ return (QuoteElement) DOMImpl.impl.createElement("q");
+ }
+
+ public final InputElement createRadioInputElement(String name) {
+ return DOMImpl.impl.createInputRadioElement(name);
+ }
+
+ public final ScriptElement createScriptElement() {
+ return (ScriptElement) DOMImpl.impl.createElement("script");
+ }
+
+ public final SelectElement createSelectElement() {
+ return DOMImpl.impl.createSelectElement(false);
+ }
+
+ public final SelectElement createSelectElement(boolean multiple) {
+ return DOMImpl.impl.createSelectElement(multiple);
+ }
+
+ public final SpanElement createSpanElement() {
+ return (SpanElement) DOMImpl.impl.createElement("span");
+ }
+
+ public final StyleElement createStyleElement() {
+ return (StyleElement) DOMImpl.impl.createElement("style");
+ }
+
+ public final TableElement createTableElement() {
+ return (TableElement) DOMImpl.impl.createElement("table");
+ }
+
+ public final TableSectionElement createTBodyElement() {
+ return (TableSectionElement) DOMImpl.impl.createElement("tbody");
+ }
+
+ public final TableCellElement createTDElement() {
+ return (TableCellElement) DOMImpl.impl.createElement("td");
+ }
+
+ public final TextAreaElement createTextAreaElement() {
+ return (TextAreaElement) DOMImpl.impl.createElement("textarea");
+ }
+
+ public final InputElement createTextInputElement() {
+ return DOMImpl.impl.createInputElement("text");
+ }
+
+ public final native Text createTextNode(String data) /*-{
+ return this.createTextNode(data);
+ }-*/;
+
+ public final TableSectionElement createTFootElement() {
+ return (TableSectionElement) DOMImpl.impl.createElement("tfoot");
+ }
+
+ public final TableSectionElement createTHeadElement() {
+ return (TableSectionElement) DOMImpl.impl.createElement("thead");
+ }
+
+ public final TableCellElement createTHElement() {
+ return (TableCellElement) DOMImpl.impl.createElement("th");
+ }
+
+ public final TitleElement createTitleElement() {
+ return (TitleElement) DOMImpl.impl.createElement("title");
+ }
+
+ public final TableRowElement createTRElement() {
+ return (TableRowElement) DOMImpl.impl.createElement("tr");
+ }
+
+ public final UListElement createULElement() {
+ return (UListElement) DOMImpl.impl.createElement("ul");
+ }
+
+ public final String createUniqueId() {
+ return "uid-" + (++curUidIndex);
+ }
+
+ public final native BodyElement getBody() /*-{
+ return this.body;
+ }-*/;
+
+ public final native String getDomain() /*-{
+ return this.domain;
+ }-*/;
+
+ public final native Element getElementById(String id) /*-{
+ return this.getElementById(id);
+ }-*/;
+
+ public final native NodeList<Element> getElementsByTagName(String tagName) /*-{
+ return this.getElementsByTagName(tagName);
+ }-*/;
+
+ public final native String getReferrer() /*-{
+ return this.referrer;
+ }-*/;
+
+ public final native String getTitle() /*-{
+ return this.title;
+ }-*/;
+
+ public final native String getURL() /*-{
+ return this.URL;
+ }-*/;
+
+ public final native void setTitle(String title) /*-{
+ this.title = title;
+ }-*/;
+
+ public final native void importNode(Node node, boolean deep) /*-{
+ this.importNode(node, deep);
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/Element.java b/user/src/com/google/gwt/dom/client/Element.java
new file mode 100644
index 0000000..ed76351
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/Element.java
@@ -0,0 +1,438 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+import com.google.gwt.core.client.JavaScriptObject;
+
+/**
+ * All HTML element interfaces derive from this class.
+ */
+public class Element extends Node {
+
+ /**
+ * Assert that the given {@link Node} is of type {@link Node#ELEMENT_NODE} and
+ * automatically typecast it.
+ */
+ public static Element as(Node node) {
+ assert node.getNodeType() == Node.ELEMENT_NODE;
+ return (Element) node;
+ }
+
+ protected Element() {
+ }
+
+ /**
+ * Gets an element's absolute left coordinate in the document's coordinate
+ * system.
+ */
+ public final int getAbsoluteLeft() {
+ return DOMImpl.impl.getAbsoluteLeft(this);
+ }
+
+ /**
+ * Gets an element's absolute top coordinate in the document's coordinate
+ * system.
+ */
+ public final int getAbsoluteTop() {
+ return DOMImpl.impl.getAbsoluteTop(this);
+ }
+
+ /**
+ * Retrieves an attribute value by name.
+ *
+ * @param name The name of the attribute to retrieve
+ * @return The Attr value as a string, or the empty string if that attribute
+ * does not have a specified or default value
+ */
+ public final native String getAttribute(String name) /*-{
+ return this.getAttribute(name);
+ }-*/;
+
+ /**
+ * The class attribute of the element. This attribute has been renamed due to
+ * conflicts with the "class" keyword exposed by many languages.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#adef-class
+ */
+ public final native String getClassName() /*-{
+ return this.className;
+ }-*/;
+
+ /**
+ * Specifies the base direction of directionally neutral text and the
+ * directionality of tables.
+ */
+ public final native String getDir() /*-{
+ return this.dir;
+ }-*/;
+
+ /**
+ * Returns a NodeList of all descendant Elements with a given tag name, in the
+ * order in which they are encountered in a preorder traversal of this Element
+ * tree.
+ *
+ * @param name The name of the tag to match on. The special value "*" matches
+ * all tags
+ * @return A list of matching Element nodes
+ */
+ public final native NodeList<Element> getElementsByTagName(String name) /*-{
+ return this.getElementsByTagName(name);
+ }-*/;
+
+ /**
+ * The first child of element this element. If there is no such element, this
+ * returns null.
+ */
+ public final Element getFirstChildElement() {
+ return DOMImpl.impl.getFirstChildElement(this);
+ }
+
+ /**
+ * The element's identifier.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#adef-id
+ */
+ public final native String getId() /*-{
+ return this.id;
+ }-*/;
+
+ /**
+ * All of the markup and content within a given element.
+ */
+ public final String getInnerHTML() {
+ return DOMImpl.impl.getInnerHTML(this);
+ }
+
+ /**
+ * The text between the start and end tags of the object.
+ */
+ public final String getInnerText() {
+ return DOMImpl.impl.getInnerText(this);
+ }
+
+ /**
+ * Language code defined in RFC 1766.
+ */
+ public final native String getLang() /*-{
+ return this.lang;
+ }-*/;
+
+ /**
+ * The element immediately following this element. If there is no such
+ * element, this returns null.
+ */
+ public final Element getNextSiblingElement() {
+ return DOMImpl.impl.getNextSiblingElement(this);
+ }
+
+ /**
+ * The height of an element relative to the layout.
+ */
+ public final int getOffsetHeight() {
+ return getPropertyInt("offsetHeight");
+ }
+
+ /**
+ * The number of pixels that the upper left corner of the current element is
+ * offset to the left within the offsetParent node.
+ */
+ public final int getOffsetLeft() {
+ return getPropertyInt("offsetLeft");
+ }
+
+ /**
+ * Returns a reference to the object which is the closest (nearest in the
+ * containment hierarchy) positioned containing element.
+ */
+ public final native Element getOffsetParent() /*-{
+ return this.offsetParent;
+ }-*/;
+
+ /**
+ * The number of pixels that the upper top corner of the current element is
+ * offset to the top within the offsetParent node.
+ */
+ public final int getOffsetTop() {
+ return getPropertyInt("offsetTop");
+ }
+
+ /**
+ * The width of an element relative to the layout.
+ */
+ public final int getOffsetWidth() {
+ return getPropertyInt("offsetWidth");
+ }
+
+ /**
+ * The parent element of this element.
+ */
+ public final Element getParentElement() {
+ return DOMImpl.impl.getParentElement(this);
+ }
+
+ /**
+ * Gets a boolean property from this element.
+ *
+ * @param name the name of the property to be retrieved
+ * @return the property value
+ */
+ public final native boolean getPropertyBoolean(String name) /*-{
+ return !!this[name];
+ }-*/;
+
+ /**
+ * Gets a double property from this element.
+ *
+ * @param name the name of the property to be retrieved
+ * @return the property value
+ */
+ public final native double getPropertyDouble(String name) /*-{
+ return parseFloat(this[name]) || 0.0;
+ }-*/;
+
+ /**
+ * Gets an integer property from this element.
+ *
+ * @param name the name of the property to be retrieved
+ * @return the property value
+ */
+ public final native int getPropertyInt(String name) /*-{
+ return parseInt(this[name]) || 0;
+ }-*/;
+
+ /**
+ * Gets a property from this element.
+ *
+ * @param name the name of the property to be retrieved
+ * @return the property value
+ */
+ public final native String getPropertyString(String name) /*-{
+ var ret = this[name];
+ return (ret == null) ? null : String(ret);
+ }-*/;
+
+ /**
+ * The height of the scroll view of an element.
+ */
+ public final native int getScrollHeight() /*-{
+ return this.scrollHeight;
+ }-*/;
+
+ /**
+ * The number of pixels that an element's content is scrolled to the left.
+ */
+ public final native int getScrollLeft() /*-{
+ return this.scrollLeft;
+ }-*/;
+
+ /**
+ * The number of pixels that an element's content is scrolled to the top.
+ */
+ public final native int getScrollTop() /*-{
+ return this.scrollTop;
+ }-*/;
+
+ /**
+ * The height of the scroll view of an element.
+ */
+ public final native int getScrollWidth() /*-{
+ return this.scrollWidth;
+ }-*/;
+
+ /**
+ * Gets a string representation of this element (as outer HTML).
+ *
+ * We do not override {@link #toString()} because it is final in
+ * {@link JavaScriptObject}.
+ *
+ * @return the string representation of this element
+ */
+ public final String getString() {
+ return DOMImpl.impl.toString(this);
+ }
+
+ /**
+ * Gets this element's {@link Style} object.
+ */
+ public final native Style getStyle() /*-{
+ return this.style;
+ }-*/;
+
+ /**
+ * The name of the element.
+ */
+ public final native String getTagName() /*-{
+ return this.tagName;
+ }-*/;
+
+ /**
+ * The element's advisory title.
+ */
+ public final native String getTitle() /*-{
+ return this.title;
+ }-*/;
+
+ /**
+ * Determine whether an element is equal to, or the child of, this element.
+ *
+ * @param child the potential child element
+ * @return <code>true</code> if the relationship holds
+ */
+ public final boolean isOrHasChild(Element child) {
+ return DOMImpl.impl.isOrHasChild(this, child);
+ }
+
+ /**
+ * Removes an attribute by name.
+ */
+ public final native void removeAttribute(String name) /*-{
+ this.removeAttribute(name);
+ }-*/;
+
+ /**
+ * Scrolls this element into view.
+ *
+ * <p>
+ * This method crawls up the DOM hierarchy, adjusting the scrollLeft and
+ * scrollTop properties of each scrollable element to ensure that the
+ * specified element is completely in view. It adjusts each scroll position by
+ * the minimum amount necessary.
+ * </p>
+ */
+ public final void scrollIntoView() {
+ DOMImpl.impl.scrollIntoView(this);
+ }
+
+ /**
+ * Adds a new attribute. If an attribute with that name is already present in
+ * the element, its value is changed to be that of the value parameter.
+ *
+ * @param name The name of the attribute to create or alter
+ * @param value Value to set in string form
+ */
+ public final native void setAttribute(String name, String value) /*-{
+ this.setAttribute(name, value);
+ }-*/;
+
+ /**
+ * The class attribute of the element. This attribute has been renamed due to
+ * conflicts with the "class" keyword exposed by many languages.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#adef-class
+ */
+ public final native void setClassName(String className) /*-{
+ this.className = className;
+ }-*/;
+
+ /**
+ * Specifies the base direction of directionally neutral text and the
+ * directionality of tables.
+ */
+ public final native void setDir(String dir) /*-{
+ this.dir = dir;
+ }-*/;
+
+ /**
+ * The element's identifier.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#adef-id
+ */
+ public final native void setId(String id) /*-{
+ this.id = id;
+ }-*/;
+
+ /**
+ * All of the markup and content within a given element.
+ */
+ public final native void setInnerHTML(String html) /*-{
+ this.innerHTML = html || '';
+ }-*/;
+
+ /**
+ * The text between the start and end tags of the object.
+ */
+ public final void setInnerText(String text) {
+ DOMImpl.impl.setInnerText(this, text);
+ }
+
+ /**
+ * Language code defined in RFC 1766.
+ */
+ public final native void setLang(String lang) /*-{
+ this.lang = lang;
+ }-*/;
+
+ /**
+ * Sets a boolean property on this element.
+ *
+ * @param name the name of the property to be set
+ * @param value the new property value
+ */
+ public final native void setPropertyBoolean(String name, boolean value) /*-{
+ this[name] = value;
+ }-*/;
+
+ /**
+ * Sets a double property on this element.
+ *
+ * @param name the name of the property to be set
+ * @param value the new property value
+ */
+ public final native void setPropertyDouble(String name, double value) /*-{
+ this[name] = value;
+ }-*/;
+
+ /**
+ * Sets an integer property on this element.
+ *
+ * @param name the name of the property to be set
+ * @param value the new property value
+ */
+ public final native void setPropertyInt(String name, int value) /*-{
+ this[name] = value;
+ }-*/;
+
+ /**
+ * Sets a property on this element.
+ *
+ * @param name the name of the property to be set
+ * @param value the new property value
+ */
+ public final native void setPropertyString(String name, String value) /*-{
+ this[name] = value;
+ }-*/;
+
+ /**
+ * The number of pixels that an element's content is scrolled to the left.
+ */
+ public final native void setScrollLeft(int scrollLeft) /*-{
+ this.scrollLeft = scrollLeft;
+ }-*/;
+
+ /**
+ * The number of pixels that an element's content is scrolled to the top.
+ */
+ public final native void setScrollTop(int scrollTop) /*-{
+ this.scrollTop = scrollTop;
+ }-*/;
+
+ /**
+ * The element's advisory title.
+ */
+ public final native void setTitle(String title) /*-{
+ this.title = title || '';
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/FieldSetElement.java b/user/src/com/google/gwt/dom/client/FieldSetElement.java
new file mode 100644
index 0000000..d1a0e8d
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/FieldSetElement.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Organizes form controls into logical groups.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#edef-FIELDSET
+ */
+public class FieldSetElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static FieldSetElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("fieldset");
+ return (FieldSetElement)elem;
+ }
+
+ protected FieldSetElement() {
+ }
+
+ /**
+ * Returns the FORM element containing this control. Returns null if this
+ * control is not within the context of a form.
+ */
+ public final native FormElement getForm() /*-{
+ return this.form;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/FormElement.java b/user/src/com/google/gwt/dom/client/FormElement.java
new file mode 100644
index 0000000..00ba146
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/FormElement.java
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * The FORM element encompasses behavior similar to a collection and an element.
+ * It provides direct access to the contained form controls as well as the
+ * attributes of the form element.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#edef-FORM
+ */
+public class FormElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static FormElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("form");
+ return (FormElement)elem;
+ }
+
+ protected FormElement() {
+ }
+
+ /**
+ * Returns a collection of all form control elements in the form.
+ */
+ public final native NodeCollection<Element> getElements() /*-{
+ return this.elements;
+ }-*/;
+
+ /**
+ * List of character sets supported by the server.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accept-charset
+ */
+ public final native String getAcceptCharset() /*-{
+ return this.acceptCharset;
+ }-*/;
+
+ /**
+ * Server-side form handler.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-action
+ */
+ public final native String getAction() /*-{
+ return this.action;
+ }-*/;
+
+ /**
+ * The content type of the submitted form, generally
+ * "application/x-www-form-urlencoded".
+ *
+ * Note: The onsubmit even handler is not guaranteed to be triggered when
+ * invoking this method. The behavior is inconsistent for historical reasons
+ * and authors should not rely on a particular one.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-enctype
+ */
+ public final native String getEnctype() /*-{
+ return this.enctype;
+ }-*/;
+
+ /**
+ * HTTP method [IETF RFC 2616] used to submit form.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-method
+ */
+ public final native String getMethod() /*-{
+ return this.method;
+ }-*/;
+
+ /**
+ * Names the form.
+ */
+ public final native String getName() /*-{
+ return this.name;
+ }-*/;
+
+ /**
+ * Frame to render the resource in.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-target
+ */
+ public final native String getTarget() /*-{
+ return this.target;
+ }-*/;
+
+ /**
+ * Restores a form element's default values. It performs the same action as a
+ * reset button.
+ */
+ public final native void reset() /*-{
+ this.reset();
+ }-*/;
+
+ /**
+ * List of character sets supported by the server.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accept-charset
+ */
+ public final native void setAcceptCharset(String acceptCharset) /*-{
+ this.acceptCharset = acceptCharset;
+ }-*/;
+
+ /**
+ * Server-side form handler.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-action
+ */
+ public final native void setAction(String action) /*-{
+ this.action = action;
+ }-*/;
+
+ /**
+ * The content type of the submitted form, generally
+ * "application/x-www-form-urlencoded".
+ *
+ * Note: The onsubmit even handler is not guaranteed to be triggered when
+ * invoking this method. The behavior is inconsistent for historical reasons
+ * and authors should not rely on a particular one.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-enctype
+ */
+ public final native void setEnctype(String enctype) /*-{
+ this.enctype = enctype;
+ }-*/;
+
+ /**
+ * HTTP method [IETF RFC 2616] used to submit form.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-method
+ */
+ public final native void setMethod(String method) /*-{
+ this.method = method;
+ }-*/;
+
+ /**
+ * Names the form.
+ */
+ public final native void setName(String name) /*-{
+ this.name = name;
+ }-*/;
+
+ /**
+ * Frame to render the resource in.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-target
+ */
+ public final native void setTarget(String target) /*-{
+ this.target = target;
+ }-*/;
+
+ /**
+ * Submits the form. It performs the same action as a submit button.
+ */
+ public final native void submit() /*-{
+ this.submit();
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/FrameElement.java b/user/src/com/google/gwt/dom/client/FrameElement.java
new file mode 100644
index 0000000..9049b97
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/FrameElement.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Create a frame.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#edef-FRAME
+ */
+public class FrameElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static FrameElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("frame");
+ return (FrameElement) elem;
+ }
+
+ protected FrameElement() {
+ }
+
+ /**
+ * The document this frame contains, if there is any and it is available, or
+ * null otherwise.
+ */
+ public final native Document getContentDocument() /*-{
+ return this.contentDocument;
+ }-*/;
+
+ /**
+ * Request frame borders.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-frameborder
+ */
+ public final native int getFrameBorder() /*-{
+ return this.frameBorder;
+ }-*/;
+
+ /**
+ * URI designating a long description of this image or frame.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-longdesc-FRAME
+ */
+ public final native String getLongDesc() /*-{
+ return this.longDesc;
+ }-*/;
+
+ /**
+ * Frame margin height, in pixels.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-marginheight
+ */
+ public final native int getMarginHeight() /*-{
+ return this.marginHeight;
+ }-*/;
+
+ /**
+ * Frame margin width, in pixels.
+ *
+ * @see
+ */
+ public final native int getMarginWidth() /*-{
+ return this.marginWidth;
+ }-*/;
+
+ /**
+ * The frame name (object of the target attribute).
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-name-FRAME
+ */
+ public final native String getName() /*-{
+ return this.name;
+ }-*/;
+
+ /**
+ * Specify whether or not the frame should have scrollbars.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-scrolling
+ */
+ public final native String getScrolling() /*-{
+ return this.scrolling;
+ }-*/;
+
+ /**
+ * A URI designating the initial frame contents.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-src-FRAME
+ */
+ public final native String getSrc() /*-{
+ return this.src;
+ }-*/;
+
+ /**
+ * When true, forbid user from resizing frame.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-noresize
+ */
+ public final native boolean isNoResize() /*-{
+ return this.noResize;
+ }-*/;
+
+ /**
+ * Request frame borders.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-frameborder
+ */
+ public final native void setFrameBorder(int frameBorder) /*-{
+ this.frameBorder = frameBorder;
+ }-*/;
+
+ /**
+ * URI designating a long description of this image or frame.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-longdesc-FRAME
+ */
+ public final native void setLongDesc(String longDesc) /*-{
+ this.longDesc = longDesc;
+ }-*/;
+
+ /**
+ * Frame margin height, in pixels.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-marginheight
+ */
+ public final native void setMarginHeight(int marginHeight) /*-{
+ this.marginHeight = marginHeight;
+ }-*/;
+
+ /**
+ * Frame margin width, in pixels.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-marginwidth
+ */
+ public final native void setMarginWidth(int marginWidth) /*-{
+ this.marginWidth = marginWidth;
+ }-*/;
+
+ /**
+ * The frame name (object of the target attribute).
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-name-FRAME
+ */
+ public final native void setName(String name) /*-{
+ this.name = name;
+ }-*/;
+
+ /**
+ * When true, forbid user from resizing frame.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-noresize
+ */
+ public final native void setNoResize(boolean noResize) /*-{
+ this.noResize = noResize;
+ }-*/;
+
+ /**
+ * Specify whether or not the frame should have scrollbars.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-scrolling
+ */
+ public final native void setScrolling(String scrolling) /*-{
+ this.scrolling = scrolling;
+ }-*/;
+
+ /**
+ * A URI designating the initial frame contents.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-src-FRAME
+ */
+ public final native void setSrc(String src) /*-{
+ this.src = src;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/FrameSetElement.java b/user/src/com/google/gwt/dom/client/FrameSetElement.java
new file mode 100644
index 0000000..8fe92d7
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/FrameSetElement.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Create a grid of frames.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#edef-FRAMESET
+ */
+public class FrameSetElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static FrameSetElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("frameset");
+ return (FrameSetElement) elem;
+ }
+
+ protected FrameSetElement() {
+ }
+
+ /**
+ * The number of columns of frames in the frameset.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-cols-FRAMESET
+ */
+ public final native String getCols() /*-{
+ return this.cols;
+ }-*/;
+
+ /**
+ * The number of rows of frames in the frameset.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-rows-FRAMESET
+ */
+ public final native String getRows() /*-{
+ return this.rows;
+ }-*/;
+
+ /**
+ * The number of columns of frames in the frameset.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-cols-FRAMESET
+ */
+ public final native void setCols(String cols) /*-{
+ this.cols = cols;
+ }-*/;
+
+ /**
+ * The number of rows of frames in the frameset.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-rows-FRAMESET
+ */
+ public final native void setRows(String rows) /*-{
+ this.rows = rows;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/HRElement.java b/user/src/com/google/gwt/dom/client/HRElement.java
new file mode 100644
index 0000000..15fffaf
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/HRElement.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Create a horizontal rule.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/graphics.html#edef-HR
+ */
+public class HRElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static HRElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("hr");
+ return (HRElement) elem;
+ }
+
+ protected HRElement() {
+ }
+}
diff --git a/user/src/com/google/gwt/dom/client/HeadElement.java b/user/src/com/google/gwt/dom/client/HeadElement.java
new file mode 100644
index 0000000..e361112
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/HeadElement.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Document head information.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#edef-HEAD
+ */
+public class HeadElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static HeadElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("head");
+ return (HeadElement) elem;
+ }
+
+ protected HeadElement() {
+ }
+}
diff --git a/user/src/com/google/gwt/dom/client/HeadingElement.java b/user/src/com/google/gwt/dom/client/HeadingElement.java
new file mode 100644
index 0000000..fe21822
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/HeadingElement.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * For the H1 to H6 elements.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#edef-H1
+ */
+public class HeadingElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static HeadingElement as(Element elem) {
+ if (HeadingElement.class.desiredAssertionStatus()) {
+ // Assert that this element's tag name is one of [h1 .. h6].
+ String tag = elem.getTagName().toLowerCase();
+ assert tag.length() == 2;
+ assert tag.charAt(0) == 'h';
+
+ int n = Integer.parseInt(tag.substring(1, 1));
+ assert (n >= 1) && (n <= 6);
+ }
+
+ return (HeadingElement) elem;
+ }
+
+ protected HeadingElement() {
+ }
+}
diff --git a/user/src/com/google/gwt/dom/client/IFrameElement.java b/user/src/com/google/gwt/dom/client/IFrameElement.java
new file mode 100644
index 0000000..7ee5f23
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/IFrameElement.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Inline subwindows.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#edef-IFRAME
+ */
+public class IFrameElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static IFrameElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("iframe");
+ return (IFrameElement)elem;
+ }
+
+ protected IFrameElement() {
+ }
+
+ /**
+ * The document this frame contains, if there is any and it is available, or
+ * null otherwise.
+ */
+ public final native Document getContentDocument() /*-{
+ return this.contentDocument;
+ }-*/;
+
+ /**
+ * Request frame borders.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-frameborder
+ */
+ public final native int getFrameBorder() /*-{
+ return this.frameBorder;
+ }-*/;
+
+ /**
+ * Frame margin height, in pixels.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-marginheight
+ */
+ public final native int getMarginHeight() /*-{
+ return this.marginHeight;
+ }-*/;
+
+ /**
+ * Frame margin width, in pixels.
+ *
+ * @see
+ */
+ public final native int getMarginWidth() /*-{
+ return this.marginWidth;
+ }-*/;
+
+ /**
+ * The frame name (object of the target attribute).
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-name-FRAME
+ */
+ public final native String getName() /*-{
+ return this.name;
+ }-*/;
+
+ /**
+ * Specify whether or not the frame should have scrollbars.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-scrolling
+ */
+ public final native String getScrolling() /*-{
+ return this.scrolling;
+ }-*/;
+
+ /**
+ * A URI designating the initial frame contents.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-src-FRAME
+ */
+ public final native String getSrc() /*-{
+ return this.src;
+ }-*/;
+
+ /**
+ * When true, forbid user from resizing frame.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-noresize
+ */
+ public final native boolean isNoResize() /*-{
+ return this.noResize;
+ }-*/;
+
+ /**
+ * Request frame borders.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-frameborder
+ */
+ public final native void setFrameBorder(int frameBorder) /*-{
+ this.frameBorder = frameBorder;
+ }-*/;
+
+ /**
+ * Frame margin height, in pixels.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-marginheight
+ */
+ public final native void setMarginHeight(int marginHeight) /*-{
+ this.marginHeight = marginHeight;
+ }-*/;
+
+ /**
+ * Frame margin width, in pixels.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-marginwidth
+ */
+ public final native void setMarginWidth(int marginWidth) /*-{
+ this.marginWidth = marginWidth;
+ }-*/;
+
+ /**
+ * The frame name (object of the target attribute).
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-name-FRAME
+ */
+ public final native void setName(String name) /*-{
+ this.name = name;
+ }-*/;
+
+ /**
+ * When true, forbid user from resizing frame.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-noresize
+ */
+ public final native void setNoResize(boolean noResize) /*-{
+ this.noResize = noResize;
+ }-*/;
+
+ /**
+ * Specify whether or not the frame should have scrollbars.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-scrolling
+ */
+ public final native void setScrolling(String scrolling) /*-{
+ this.scrolling = scrolling;
+ }-*/;
+
+ /**
+ * A URI designating the initial frame contents.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-src-FRAME
+ */
+ public final native void setSrc(String src) /*-{
+ this.src = src;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/ImageElement.java b/user/src/com/google/gwt/dom/client/ImageElement.java
new file mode 100644
index 0000000..c2d4631
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/ImageElement.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Embedded image.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#edef-IMG
+ */
+public class ImageElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static ImageElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("img");
+ return (ImageElement)elem;
+ }
+
+ protected ImageElement() {
+ }
+
+ /**
+ * Alternate text for user agents not rendering the normal content of this
+ * element.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-alt
+ */
+ public final native String getAlt() /*-{
+ return this.alt;
+ }-*/;
+
+ /**
+ * Height of the image in pixels.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-height-IMG
+ */
+ public final native int getHeight() /*-{
+ return this.height;
+ }-*/;
+
+ /**
+ * URI designating the source of this image.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-src-IMG
+ */
+ public final String getSrc() {
+ return DOMImpl.impl.imgGetSrc(this);
+ }
+
+ /**
+ * The width of the image in pixels.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-width-IMG
+ */
+ public final native int getWidth() /*-{
+ return this.width;
+ }-*/;
+
+ /**
+ * Use server-side image map.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-ismap
+ */
+ public final native boolean isMap() /*-{
+ return this.isMap;
+ }-*/;
+
+ /**
+ * Alternate text for user agents not rendering the normal content of this
+ * element.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-alt
+ */
+ public final native void setAlt(String alt) /*-{
+ this.alt = alt;
+ }-*/;
+
+ /**
+ * Height of the image in pixels.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-height-IMG
+ */
+ public final native void setHeight(int height) /*-{
+ this.height = height;
+ }-*/;
+
+ /**
+ * Use server-side image map.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-ismap
+ */
+ public final native void setIsMap(boolean isMap) /*-{
+ this.isMap = isMap;
+ }-*/;
+
+ /**
+ * URI designating the source of this image.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-src-IMG
+ */
+ public final void setSrc(String src) {
+ DOMImpl.impl.imgSetSrc(this, src);
+ }
+
+ /**
+ * Use client-side image map.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-usemap
+ */
+ public final native void setUseMap(boolean useMap) /*-{
+ this.useMap = useMap;
+ }-*/;
+
+ /**
+ * The width of the image in pixels.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-width-IMG
+ */
+ public final native void setWidth(int width) /*-{
+ this.width = width;
+ }-*/;
+
+ /**
+ * Use client-side image map.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-usemap
+ */
+ public final native boolean useMap() /*-{
+ return this.useMap;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/user/client/impl/ImageSrcIE6.java b/user/src/com/google/gwt/dom/client/ImageSrcIE6.java
similarity index 95%
rename from user/src/com/google/gwt/user/client/impl/ImageSrcIE6.java
rename to user/src/com/google/gwt/dom/client/ImageSrcIE6.java
index d4d0d95..6520bd0 100644
--- a/user/src/com/google/gwt/user/client/impl/ImageSrcIE6.java
+++ b/user/src/com/google/gwt/dom/client/ImageSrcIE6.java
@@ -13,10 +13,9 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.user.client.impl;
+package com.google.gwt.dom.client;
import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.user.client.Element;
/**
* Works around an IE problem where multiple images trying to load at the same
@@ -207,7 +206,7 @@
if (img = kids[0]) {
// Try to elect a new top node.
img.__pendingSrc = null;
- @com.google.gwt.user.client.impl.ImageSrcIE6::addTop(Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/user/client/Element;Ljava/lang/String;)(srcImgMap, img, src);
+ @com.google.gwt.dom.client.ImageSrcIE6::addTop(Lcom/google/gwt/core/client/JavaScriptObject;Lcom/google/gwt/dom/client/Element;Ljava/lang/String;)(srcImgMap, img, src);
if (img.__pendingSrc) {
// It became a top node, add the rest as children.
kids.splice(0, 1);
diff --git a/user/src/com/google/gwt/dom/client/InputElement.java b/user/src/com/google/gwt/dom/client/InputElement.java
new file mode 100644
index 0000000..9a27a0a
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/InputElement.java
@@ -0,0 +1,412 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Form control.
+ *
+ * Note: Depending upon the environment in which the page is being viewed, the
+ * value property may be read-only for the file upload input type. For the
+ * "password" input type, the actual value returned may be masked to prevent
+ * unauthorized use.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#edef-INPUT
+ */
+public class InputElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static InputElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("input");
+ return (InputElement) elem;
+ }
+
+ protected InputElement() {
+ }
+
+ /**
+ * Removes keyboard focus from this element.
+ */
+ public final native void blur() /*-{
+ this.blur();
+ }-*/;
+
+ /**
+ * Simulate a mouse-click. For INPUT elements whose type attribute has one of
+ * the following values: "button", "checkbox", "radio", "reset", or "submit".
+ */
+ public final native void click() /*-{
+ this.click;
+ }-*/;
+
+ /**
+ * Gives keyboard focus to this element.
+ */
+ public final native void focus() /*-{
+ this.focus();
+ }-*/;
+
+ /**
+ * A comma-separated list of content types that a server processing this form
+ * will handle correctly.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accept
+ */
+ public final native String getAccept() /*-{
+ return this.accept;
+ }-*/;
+
+ /**
+ * A single character access key to give access to the form control.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey
+ */
+ public final native String getAccessKey() /*-{
+ return this.accessKey;
+ }-*/;
+
+ /**
+ * Alternate text for user agents not rendering the normal content of this
+ * element.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-alt
+ */
+ public final native String getAlt() /*-{
+ return this.alt;
+ }-*/;
+
+ /**
+ * When the type attribute of the element has the value "text", "file" or
+ * "password", this represents the HTML value attribute of the element. The
+ * value of this attribute does not change if the contents of the
+ * corresponding form control, in an interactive user agent, changes.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-value-INPUT
+ */
+ public final native String getDefaultValue() /*-{
+ return this.defaultValue;
+ }-*/;
+
+ /**
+ * Returns the FORM element containing this control. Returns null if this
+ * control is not within the context of a form.
+ */
+ public final native FormElement getForm() /*-{
+ return this.form;
+ }-*/;
+
+ /**
+ * Maximum number of characters for text fields, when type has the value
+ * "text" or "password".
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-maxlength
+ */
+ public final native int getMaxLength() /*-{
+ return this.maxLength;
+ }-*/;
+
+ /**
+ * Form control or object name when submitted with a form.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-name-INPUT
+ */
+ public final native String getName() /*-{
+ return this.name;
+ }-*/;
+
+ /**
+ * Size information. The precise meaning is specific to each type of field.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-size-INPUT
+ */
+ public final native int getSize() /*-{
+ return this.size;
+ }-*/;
+
+ /**
+ * When the type attribute has the value "image", this attribute specifies the
+ * location of the image to be used to decorate the graphical submit button.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-src
+ */
+ public final native String getSrc() /*-{
+ return this.src;
+ }-*/;
+
+ /**
+ * Index that represents the element's position in the tabbing order.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex
+ */
+ public final native int getTabIndex() /*-{
+ return this.tabIndex;
+ }-*/;
+
+ /**
+ * The type of control created (all lower case).
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-type-INPUT
+ */
+ public final native String getType() /*-{
+ return this.type;
+ }-*/;
+
+ /**
+ * When the type attribute of the element has the value "text", "file" or
+ * "password", this represents the current contents of the corresponding form
+ * control, in an interactive user agent. Changing this attribute changes the
+ * contents of the form control, but does not change the value of the HTML
+ * value attribute of the element. When the type attribute of the element has
+ * the value "button", "hidden", "submit", "reset", "image", "checkbox" or
+ * "radio", this represents the HTML value attribute of the element.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-value-INPUT
+ */
+ public final native String getValue() /*-{
+ return this.value;
+ }-*/;
+
+ /**
+ * When the type attribute of the element has the value "radio" or "checkbox",
+ * this represents the current state of the form control, in an interactive
+ * user agent. Changes to this attribute change the state of the form control,
+ * but do not change the value of the HTML checked attribute of the INPUT
+ * element.
+ *
+ * Note: During the handling of a click event on an input element with a type
+ * attribute that has the value "radio" or "checkbox", some implementations
+ * may change the value of this property before the event is being dispatched
+ * in the document. If the default action of the event is canceled, the value
+ * of the property may be changed back to its original value. This means that
+ * the value of this property during the handling of click events is
+ * implementation dependent.
+ */
+ public final native boolean isChecked() /*-{
+ return this.checked;
+ }-*/;
+
+ /**
+ * When type has the value "radio" or "checkbox", this represents the HTML
+ * checked attribute of the element. The value of this attribute does not
+ * change if the state of the corresponding form control, in an interactive
+ * user agent, changes.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-checked
+ */
+ public final native boolean isDefaultChecked() /*-{
+ return this.defaultChecked;
+ }-*/;
+
+ /**
+ * The control is unavailable in this context.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled
+ */
+ public final native boolean isDisabled() /*-{
+ return this.disabled;
+ }-*/;
+
+ /**
+ * This control is read-only. Relevant only when type has the value "text" or
+ * "password".
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-readonly
+ */
+ public final native boolean isReadOnly() /*-{
+ return this.readOnly;
+ }-*/;
+
+ /**
+ * Use client-side image map.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-usemap
+ */
+ public final native boolean useMap() /*-{
+ return this.useMap;
+ }-*/;
+
+ /**
+ * Select the contents of the text area. For INPUT elements whose type
+ * attribute has one of the following values: "text", "file", or "password".
+ */
+ public final native void select() /*-{
+ this.select();
+ }-*/;
+
+ /**
+ * A comma-separated list of content types that a server processing this form
+ * will handle correctly.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accept
+ */
+ public final native void setAccept(String accept) /*-{
+ this.accept = accept;
+ }-*/;
+
+ /**
+ * A single character access key to give access to the form control.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey
+ */
+ public final native void setAccessKey(String accessKey) /*-{
+ this.accessKey = accessKey;
+ }-*/;
+
+ /**
+ * Alternate text for user agents not rendering the normal content of this
+ * element.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-alt
+ */
+ public final native void setAlt(String alt) /*-{
+ this.alt = alt;
+ }-*/;
+
+ /**
+ * When the type attribute of the element has the value "radio" or "checkbox",
+ * this represents the current state of the form control, in an interactive
+ * user agent. Changes to this attribute change the state of the form control,
+ * but do not change the value of the HTML checked attribute of the INPUT
+ * element.
+ *
+ * Note: During the handling of a click event on an input element with a type
+ * attribute that has the value "radio" or "checkbox", some implementations
+ * may change the value of this property before the event is being dispatched
+ * in the document. If the default action of the event is canceled, the value
+ * of the property may be changed back to its original value. This means that
+ * the value of this property during the handling of click events is
+ * implementation dependent.
+ */
+ public final native void setChecked(boolean checked) /*-{
+ this.checked = checked;
+ }-*/;
+
+ /**
+ * When type has the value "radio" or "checkbox", this represents the HTML
+ * checked attribute of the element. The value of this attribute does not
+ * change if the state of the corresponding form control, in an interactive
+ * user agent, changes.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-checked
+ */
+ public final native void setDefaultChecked(boolean defaultChecked) /*-{
+ this.defaultChecked = defaultChecked;
+ }-*/;
+
+ /**
+ * When the type attribute of the element has the value "text", "file" or
+ * "password", this represents the HTML value attribute of the element. The
+ * value of this attribute does not change if the contents of the
+ * corresponding form control, in an interactive user agent, changes.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-value-INPUT
+ */
+ public final native void setDefaultValue(String defaultValue) /*-{
+ this.defaultValue = defaultValue;
+ }-*/;
+
+ /**
+ * The control is unavailable in this context.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled
+ */
+ public final native void setDisabled(boolean disabled) /*-{
+ this.disabled = disabled;
+ }-*/;
+
+ /**
+ * Maximum number of characters for text fields, when type has the value
+ * "text" or "password".
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-maxlength
+ */
+ public final native void setMaxLength(int maxLength) /*-{
+ this.maxLength = maxLength;
+ }-*/;
+
+ /**
+ * Form control or object name when submitted with a form.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-name-INPUT
+ */
+ public final native void setName(String name) /*-{
+ this.name = name;
+ }-*/;
+
+ /**
+ * This control is read-only. Relevant only when type has the value "text" or
+ * "password".
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-readonly
+ */
+ public final native void setReadOnly(boolean readOnly) /*-{
+ this.readOnly = readOnly;
+ }-*/;
+
+ /**
+ * Size information. The precise meaning is specific to each type of field.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-size-INPUT
+ */
+ public final native void setSize(int size) /*-{
+ this.size = size;
+ }-*/;
+
+ /**
+ * When the type attribute has the value "image", this attribute specifies the
+ * location of the image to be used to decorate the graphical submit button.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-src
+ */
+ public final native void setSrc(String src) /*-{
+ this.src = src;
+ }-*/;
+
+ /**
+ * Index that represents the element's position in the tabbing order.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex
+ */
+ public final native void setTabIndex(int tabIndex) /*-{
+ this.tabIndex = tabIndex;
+ }-*/;
+
+ /**
+ * Use client-side image map.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-usemap
+ */
+ public final native void setUseMap(boolean useMap) /*-{
+ this.useMap = useMap;
+ }-*/;
+
+ /**
+ * When the type attribute of the element has the value "text", "file" or
+ * "password", this represents the current contents of the corresponding form
+ * control, in an interactive user agent. Changing this attribute changes the
+ * contents of the form control, but does not change the value of the HTML
+ * value attribute of the element. When the type attribute of the element has
+ * the value "button", "hidden", "submit", "reset", "image", "checkbox" or
+ * "radio", this represents the HTML value attribute of the element.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-value-INPUT
+ */
+ public final native void setValue(String value) /*-{
+ this.value = value;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/LIElement.java b/user/src/com/google/gwt/dom/client/LIElement.java
new file mode 100644
index 0000000..a910143
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/LIElement.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * List item.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/lists.html#edef-LI
+ */
+public class LIElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static LIElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("li");
+ return (LIElement) elem;
+ }
+
+ protected LIElement() {
+ }
+}
diff --git a/user/src/com/google/gwt/dom/client/LabelElement.java b/user/src/com/google/gwt/dom/client/LabelElement.java
new file mode 100644
index 0000000..0d91631
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/LabelElement.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Form field label text.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#edef-LABEL
+ */
+public class LabelElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static LabelElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("label");
+ return (LabelElement) elem;
+ }
+
+ protected LabelElement() {
+ }
+
+ /**
+ * A single character access key to give access to the form control.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey
+ */
+ public final native String getAccessKey() /*-{
+ return this.accessKey;
+ }-*/;
+
+ /**
+ * Returns the FORM element containing this control. Returns null if this
+ * control is not within the context of a form.
+ */
+ public final native FormElement getForm() /*-{
+ return this.form;
+ }-*/;
+
+ /**
+ * This attribute links this label with another form control by id attribute.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-for
+ */
+ public final native String getHtmlFor() /*-{
+ return this.htmlFor;
+ }-*/;
+
+ /**
+ * A single character access key to give access to the form control.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey
+ */
+ public final native void setAccessKey(String accessKey) /*-{
+ this.accessKey = accessKey;
+ }-*/;
+
+ /**
+ * This attribute links this label with another form control by id attribute.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-for
+ */
+ public final native void setHtmlFor(String htmlFor) /*-{
+ this.htmlFor = htmlFor;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/LegendElement.java b/user/src/com/google/gwt/dom/client/LegendElement.java
new file mode 100644
index 0000000..498afd8
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/LegendElement.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Provides a caption for a FIELDSET grouping.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#edef-LEGEND
+ */
+public class LegendElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static LegendElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("legend");
+ return (LegendElement) elem;
+ }
+
+ protected LegendElement() {
+ }
+
+ /**
+ * A single character access key to give access to the form control.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey
+ */
+ public final native String getAccessKey() /*-{
+ return this.accessKey;
+ }-*/;
+
+ /**
+ * Returns the FORM element containing this control. Returns null if this
+ * control is not within the context of a form.
+ */
+ public final native FormElement getForm() /*-{
+ return this.form;
+ }-*/;
+
+ /**
+ * A single character access key to give access to the form control.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey
+ */
+ public final native void setAccessKey(String accessKey) /*-{
+ this.accessKey = accessKey;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/LinkElement.java b/user/src/com/google/gwt/dom/client/LinkElement.java
new file mode 100644
index 0000000..ef23341
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/LinkElement.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * The LINK element specifies a link to an external resource, and defines this
+ * document's relationship to that resource (or vice versa).
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#edef-LINK
+ */
+public class LinkElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static HeadElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("head");
+ return (HeadElement) elem;
+ }
+
+ protected LinkElement() {
+ }
+
+ /**
+ * Enables/disables the link. This is currently only used for style sheet
+ * links, and may be used to activate or deactivate style sheets.
+ */
+ public final native boolean getDisabled() /*-{
+ return this.disabled;
+ }-*/;
+
+ /**
+ * The URI of the linked resource.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href
+ */
+ public final native String getHref() /*-{
+ return this.href;
+ }-*/;
+
+ /**
+ * Language code of the linked resource.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-hreflang
+ */
+ public final native String getHreflang() /*-{
+ return this.hreflang;
+ }-*/;
+
+ /**
+ * Designed for use with one or more target media.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/styles.html#adef-media
+ */
+ public final native String getMedia() /*-{
+ return this.media;
+ }-*/;
+
+ /**
+ * Forward link type.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-rel
+ */
+ public final native String getRel() /*-{
+ return this.rel;
+ }-*/;
+
+ /**
+ * Frame to render the resource in.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-target
+ */
+ public final native String getTarget() /*-{
+ return this.target;
+ }-*/;
+
+ /**
+ * Advisory content type.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-type-A
+ */
+ public final native String getType() /*-{
+ return this.type;
+ }-*/;
+
+ /**
+ * Enables/disables the link. This is currently only used for style sheet
+ * links, and may be used to activate or deactivate style sheets.
+ */
+ public final native void setDisabled(boolean disabled) /*-{
+ this.disabled = disabled;
+ }-*/;
+
+ /**
+ * The URI of the linked resource.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href
+ */
+ public final native void setHref(String href) /*-{
+ this.href = href;
+ }-*/;
+
+ /**
+ * Language code of the linked resource.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-hreflang
+ */
+ public final native void setHreflang(String hreflang) /*-{
+ this.hreflang = hreflang;
+ }-*/;
+
+ /**
+ * Designed for use with one or more target media.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/styles.html#adef-media
+ */
+ public final native void setMedia(String media) /*-{
+ this.media = media;
+ }-*/;
+
+ /**
+ * Forward link type.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-rel
+ */
+ public final native void setRel(String rel) /*-{
+ this.rel = rel;
+ }-*/;
+
+ /**
+ * Frame to render the resource in.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-target
+ */
+ public final native void setTarget(String target) /*-{
+ this.target = target;
+ }-*/;
+
+ /**
+ * Advisory content type.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-type-A
+ */
+ public final native void setType(String type) /*-{
+ this.type = type;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/MapElement.java b/user/src/com/google/gwt/dom/client/MapElement.java
new file mode 100644
index 0000000..55dfce1
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/MapElement.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Client-side image map.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#edef-MAP
+ */
+public class MapElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static MapElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("map");
+ return (MapElement) elem;
+ }
+
+ protected MapElement() {
+ }
+
+ /**
+ * The list of areas defined for the image map.
+ */
+ public final native NodeList<AreaElement> getAreas() /*-{
+ return this.areas;
+ }-*/;
+
+ /**
+ * Names the map (for use with usemap).
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-name-MAP
+ */
+ public final native String getName() /*-{
+ return this.name;
+ }-*/;
+
+ /**
+ * Names the map (for use with usemap).
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-name-MAP
+ */
+ public final native void setName(String name) /*-{
+ this.name = name;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/MetaElement.java b/user/src/com/google/gwt/dom/client/MetaElement.java
new file mode 100644
index 0000000..d57c7f0
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/MetaElement.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * This contains generic meta-information about the document.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#edef-META
+ */
+public class MetaElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static MetaElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("meta");
+ return (MetaElement) elem;
+ }
+
+ protected MetaElement() {
+ }
+
+ /**
+ * Associated information.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#adef-content
+ */
+ public final native String getContent() /*-{
+ return this.content;
+ }-*/;
+
+ /**
+ * HTTP response header name [IETF RFC 2616].
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#adef-http-equiv
+ */
+ public final native String getHttpEquiv() /*-{
+ return this.httpEquiv;
+ }-*/;
+
+ /**
+ * Meta information name.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#adef-name-META
+ */
+ public final native String getName() /*-{
+ return this.name;
+ }-*/;
+
+ /**
+ * Associated information.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#adef-content
+ */
+ public final native void setContent(String content) /*-{
+ this.content = content;
+ }-*/;
+
+ /**
+ * HTTP response header name [IETF RFC 2616].
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#adef-http-equiv
+ */
+ public final native void setHttpEquiv(String httpEquiv) /*-{
+ this.httpEquiv = httpEquiv;
+ }-*/;
+
+ /**
+ * Meta information name.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#adef-name-META
+ */
+ public final native void setName(String name) /*-{
+ this.name = name;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/ModElement.java b/user/src/com/google/gwt/dom/client/ModElement.java
new file mode 100644
index 0000000..f790510
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/ModElement.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Notice of modification to part of a document.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/text.html#edef-ins
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/text.html#edef-del
+ */
+public class ModElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static ModElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("ins")
+ || elem.getTagName().equalsIgnoreCase("del");
+ return (ModElement) elem;
+ }
+
+ protected ModElement() {
+ }
+
+ /**
+ * A URI designating a document that describes the reason for the change.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/
+ */
+ public final native String getCite() /*-{
+ return this.cite;
+ }-*/;
+
+ /**
+ * The date and time of the change.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/text.html#adef-datetime
+ */
+ public final native String getDateTime() /*-{
+ return this.dateTime;
+ }-*/;
+
+ /**
+ * A URI designating a document that describes the reason for the change.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/
+ */
+ public final native void setCite(String cite) /*-{
+ this.cite = cite;
+ }-*/;
+
+ /**
+ * The date and time of the change.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/text.html#adef-datetime
+ */
+ public final native void setDateTime(String dateTime) /*-{
+ this.dateTime = dateTime;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/Node.java b/user/src/com/google/gwt/dom/client/Node.java
new file mode 100644
index 0000000..b0fd27e
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/Node.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+import com.google.gwt.core.client.JavaScriptObject;
+
+/**
+ * The Node interface is the primary datatype for the entire Document Object
+ * Model. It represents a single node in the document tree. While all objects
+ * implementing the Node interface expose methods for dealing with children, not
+ * all objects implementing the Node interface may have children.
+ */
+public class Node extends JavaScriptObject {
+
+ /**
+ * The node is an {@link Element}.
+ */
+ public static final short ELEMENT_NODE = 1;
+
+ /**
+ * The node is a {@link Text} node.
+ */
+ public static final short TEXT_NODE = 3;
+
+ /**
+ * The node is a {@link Document}.
+ */
+ public static final short DOCUMENT_NODE = 9;
+
+ protected Node() {
+ }
+
+ /**
+ * Adds the node newChild to the end of the list of children of this node. If
+ * the newChild is already in the tree, it is first removed.
+ *
+ * @param newChild The node to add
+ * @return The node added
+ */
+ public final native Node appendChild(Node newChild) /*-{
+ return this.appendChild(newChild);
+ }-*/;
+
+ /**
+ * Returns a duplicate of this node, i.e., serves as a generic copy
+ * constructor for nodes. The duplicate node has no parent; (parentNode is
+ * null.).
+ *
+ * Cloning an Element copies all attributes and their values, including those
+ * generated by the XML processor to represent defaulted attributes, but this
+ * method does not copy any text it contains unless it is a deep clone, since
+ * the text is contained in a child Text node. Cloning an Attribute directly,
+ * as opposed to be cloned as part of an Element cloning operation, returns a
+ * specified attribute (specified is true). Cloning any other type of node
+ * simply returns a copy of this node.
+ *
+ * @param deep If true, recursively clone the subtree under the specified
+ * node; if false, clone only the node itself (and its attributes, if
+ * it is an {@link Element})
+ * @return The duplicate node
+ */
+ public final native Node cloneNode(boolean deep) /*-{
+ return this.cloneNode(deep);
+ }-*/;
+
+ /**
+ * A NodeList that contains all children of this node. If there are no
+ * children, this is a NodeList containing no nodes.
+ */
+ public final native NodeList<Node> getChildNodes() /*-{
+ return this.childNodes;
+ }-*/;
+
+ /**
+ * The first child of this node. If there is no such node, this returns null.
+ */
+ public final native Node getFirstChild() /*-{
+ return this.firstChild;
+ }-*/;
+
+ /**
+ * The last child of this node. If there is no such node, this returns null.
+ */
+ public final native Node getLastChild() /*-{
+ return this.lastChild;
+ }-*/;
+
+ /**
+ * The node immediately following this node. If there is no such node, this
+ * returns null.
+ */
+ public final native Node getNextSibling() /*-{
+ return this.nextSibling;
+ }-*/;
+
+ /**
+ * The name of this node, depending on its type; see the table above.
+ */
+ public final native String getNodeName() /*-{
+ return this.nodeName;
+ }-*/;
+
+ /**
+ * A code representing the type of the underlying object, as defined above.
+ */
+ public final native short getNodeType() /*-{
+ return this.nodeType;
+ }-*/;
+
+ /**
+ * The value of this node, depending on its type; see the table above. When it
+ * is defined to be null, setting it has no effect.
+ */
+ public final native String getNodeValue() /*-{
+ return this.nodeValue;
+ }-*/;
+
+ /**
+ * The Document object associated with this node. This is also the
+ * {@link Document} object used to create new nodes.
+ */
+ public final native Document getOwnerDocument() /*-{
+ return this.ownerDocument;
+ }-*/;
+
+ /**
+ * The parent of this node. All nodes except Document may have a parent.
+ * However, if a node has just been created and not yet added to the tree, or
+ * if it has been removed from the tree, this is null.
+ */
+ public final native Node getParentNode() /*-{
+ return this.parentNode;
+ }-*/;
+
+ /**
+ * The node immediately preceding this node. If there is no such node, this
+ * returns null.
+ */
+ public final native Node getPreviousSibling() /*-{
+ return this.previousSibling;
+ }-*/;
+
+ /**
+ * Returns whether this node has any children.
+ */
+ public final native boolean hasChildNodes() /*-{
+ return this.hasChildNodes();
+ }-*/;
+
+ /**
+ * Inserts the node newChild before the existing child node refChild. If
+ * refChild is null, insert newChild at the end of the list of children.
+ *
+ * @param newChild The node to insert
+ * @param refChild The reference node, i.e., the node before which the new
+ * node must be inserted
+ * @return The node being inserted
+ */
+ public final native Node insertBefore(Node newChild, Node refChild) /*-{
+ return this.insertBefore(newChild, refChild);
+ }-*/;
+
+ /**
+ * Removes the child node indicated by oldChild from the list of children, and
+ * returns it.
+ *
+ * @param oldChild The node being removed
+ * @return The node removed
+ */
+ public final native Node removeChild(Node oldChild) /*-{
+ return this.removeChild(oldChild);
+ }-*/;
+
+ /**
+ * Replaces the child node oldChild with newChild in the list of children, and
+ * returns the oldChild node.
+ *
+ * @param newChild The new node to put in the child list
+ * @param oldChild The node being replaced in the list
+ * @return The node replaced
+ */
+ public final native Node replaceChild(Node newChild, Node oldChild) /*-{
+ return this.replaceChild(newChild, oldChild);
+ }-*/;
+
+ /**
+ * The value of this node, depending on its type; see the table above. When it
+ * is defined to be null, setting it has no effect.
+ */
+ public final native void setNodeValue(String nodeValue) /*-{
+ this.nodeValue = nodeValue;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/NodeCollection.java b/user/src/com/google/gwt/dom/client/NodeCollection.java
new file mode 100644
index 0000000..a40b556
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/NodeCollection.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+import com.google.gwt.core.client.JavaScriptObject;
+
+/**
+ * An ElementCollection is a list of nodes. An individual node may be accessed by
+ * either ordinal index or the node's name or id attributes.
+ *
+ * Note: Collections in the HTML DOM are assumed to be live meaning that they
+ * are automatically updated when the underlying document is changed.
+ */
+public class NodeCollection<T extends Node> extends JavaScriptObject {
+
+ protected NodeCollection() {
+ }
+
+ /**
+ * This attribute specifies the length or size of the list.
+ */
+ public final native int getLength() /*-{
+ return this.length;
+ }-*/;
+
+ /**
+ * This method retrieves a node specified by ordinal index. Nodes are numbered
+ * in tree order (depth-first traversal order).
+ *
+ * @param index The index of the node to be fetched. The index origin is 0.
+ * @return The element at the corresponding position upon success. A value of
+ * null is returned if the index is out of range.
+ */
+ public final native T getItem(int index) /*-{
+ return this[index];
+ }-*/;
+
+ /**
+ * This method retrieves a Node using a name. With [HTML 4.01] documents, it
+ * first searches for a Node with a matching id attribute. If it doesn't find
+ * one, it then searches for a Node with a matching name attribute, but only
+ * on those elements that are allowed a name attribute. With [XHTML 1.0]
+ * documents, this method only searches for Nodes with a matching id
+ * attribute. This method is case insensitive in HTML documents and case
+ * sensitive in XHTML documents.
+ *
+ * @param name The name of the Node to be fetched.
+ * @return The element with a name or id attribute whose value corresponds to
+ * the specified string. Upon failure (e.g., no element with this name
+ * exists), returns null.
+ */
+ public final native T getNamedItem(String name) /*-{
+ return this[name];
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/NodeList.java b/user/src/com/google/gwt/dom/client/NodeList.java
new file mode 100644
index 0000000..2e3fa0b
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/NodeList.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+import com.google.gwt.core.client.JavaScriptObject;
+
+/**
+ * The NodeList interface provides the abstraction of an ordered collection of
+ * nodes, without defining or constraining how this collection is implemented.
+ * NodeList objects in the DOM are live.
+ *
+ * The items in the NodeList are accessible via an integral index, starting from
+ * 0.
+ */
+public class NodeList<T extends Node> extends JavaScriptObject {
+
+ protected NodeList() {
+ }
+
+ /**
+ * Returns the indexth item in the collection. If index is greater than or
+ * equal to the number of nodes in the list, this returns null.
+ *
+ * @param index Index into the collection
+ * @return the node at the indexth position in the NodeList, or null if that
+ * is not a valid index.
+ */
+ public final native T getItem(int index) /*-{
+ return this[index];
+ }-*/;
+
+ /**
+ * The number of nodes in the list. The range of valid child node indices is 0
+ * to length-1 inclusive.
+ */
+ public final native int getLength() /*-{
+ return this.length;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/OListElement.java b/user/src/com/google/gwt/dom/client/OListElement.java
new file mode 100644
index 0000000..b0b0a58
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/OListElement.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Ordered list.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/lists.html#edef-OL
+ */
+public class OListElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static OListElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("ol");
+ return (OListElement) elem;
+ }
+
+ protected OListElement() {
+ }
+}
diff --git a/user/src/com/google/gwt/dom/client/ObjectElement.java b/user/src/com/google/gwt/dom/client/ObjectElement.java
new file mode 100644
index 0000000..90e54a8
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/ObjectElement.java
@@ -0,0 +1,196 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Generic embedded object.
+ *
+ * Note: In principle, all properties on the object element are read-write but
+ * in some environments some properties may be read-only once the underlying
+ * object is instantiated.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#edef-OBJECT
+ */
+public class ObjectElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static ObjectElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("object");
+ return (ObjectElement) elem;
+ }
+
+ protected ObjectElement() {
+ }
+
+ /**
+ * Applet class file.
+ */
+ public final native String getCode() /*-{
+ return this.code;
+ }-*/;
+
+ /**
+ * The document this object contains, if there is any and it is available, or
+ * null otherwise.
+ */
+ public final native Document getContentDocument() /*-{
+ return this.contentDocument;
+ }-*/;
+
+ /**
+ * A URI specifying the location of the object's data.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-data
+ */
+ public final native String getData() /*-{
+ return this.data;
+ }-*/;
+
+ /**
+ * Returns the FORM element containing this control. Returns null if this
+ * control is not within the context of a form.
+ */
+ public final native FormElement getForm() /*-{
+ return this.form;
+ }-*/;
+
+ /**
+ * Override height.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-height-IMG
+ */
+ public final native String getHeight() /*-{
+ return this.height;
+ }-*/;
+
+ /**
+ * Form control or object name when submitted with a form.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-name-INPUT
+ */
+ public final native String getName() /*-{
+ return this.name;
+ }-*/;
+
+ /**
+ * Index that represents the element's position in the tabbing order.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex
+ */
+ public final native int getTabIndex() /*-{
+ return this.tabIndex;
+ }-*/;
+
+ /**
+ * Content type for data downloaded via data attribute.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-type-OBJECT
+ */
+ public final native String getType() /*-{
+ return this.type;
+ }-*/;
+
+ /**
+ * Use client-side image map.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-usemap
+ */
+ public final native boolean useMap() /*-{
+ return this.useMap;
+ }-*/;
+
+ /**
+ * Override width.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-width-IMG
+ */
+ public final native String getWidth() /*-{
+ return this.width;
+ }-*/;
+
+ /**
+ * Applet class file.
+ */
+ public final native void setCode(String code) /*-{
+ this.code = code;
+ }-*/;
+
+ /**
+ * A URI specifying the location of the object's data.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-data
+ */
+ public final native void setData(String data) /*-{
+ this.data = data;
+ }-*/;
+
+ /**
+ * Override height.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-height-IMG
+ */
+ public final native void setHeight(String height) /*-{
+ this.height = height;
+ }-*/;
+
+ /**
+ * Form control or object name when submitted with a form.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-name-INPUT
+ */
+ public final native void setName(String name) /*-{
+ this.name = name;
+ }-*/;
+
+ /**
+ * Index that represents the element's position in the tabbing order.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex
+ */
+ public final native void setTabIndex(int tabIndex) /*-{
+ this.tabIndex = tabIndex;
+ }-*/;
+
+ /**
+ * Content type for data downloaded via data attribute.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-type-OBJECT
+ */
+ public final native void setType(String type) /*-{
+ this.type = type;
+ }-*/;
+
+ /**
+ * Use client-side image map.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-usemap
+ */
+ public final native void setUseMap(boolean useMap) /*-{
+ this.useMap = useMap;
+ }-*/;
+
+ /**
+ * Override width.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-width-IMG
+ */
+ public final native void setWidth(String width) /*-{
+ this.width = width;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/OptGroupElement.java b/user/src/com/google/gwt/dom/client/OptGroupElement.java
new file mode 100644
index 0000000..c2db673
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/OptGroupElement.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Group options together in logical subdivisions.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#edef-OPTGROUP
+ */
+public class OptGroupElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static OptGroupElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("optgroup");
+ return (OptGroupElement) elem;
+ }
+
+ protected OptGroupElement() {
+ }
+
+ /**
+ * The control is unavailable in this context.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled
+ */
+ public final native String getDisabled() /*-{
+ return this.disabled;
+ }-*/;
+
+ /**
+ * The control is unavailable in this context.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled
+ */
+ public final native void setDisabled(String disabled) /*-{
+ this.disabled = disabled;
+ }-*/;
+
+ /**
+ * Assigns a label to this option group.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-label-OPTGROUP
+ */
+ public final native String getLabel() /*-{
+ return this.label;
+ }-*/;
+
+ /**
+ * Assigns a label to this option group.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-label-OPTGROUP
+ */
+ public final native void setLabel(String label) /*-{
+ this.label = label;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/OptionElement.java b/user/src/com/google/gwt/dom/client/OptionElement.java
new file mode 100644
index 0000000..d87a3e1
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/OptionElement.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * A selectable choice.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#edef-OPTION
+ */
+public class OptionElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static OptionElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("option");
+ return (OptionElement) elem;
+ }
+
+ protected OptionElement() {
+ }
+
+ /**
+ * Returns the FORM element containing this control. Returns null if this
+ * control is not within the context of a form.
+ */
+ public native final FormElement getForm() /*-{
+ return form;
+ }-*/;
+
+ /**
+ * The index of this OPTION in its parent SELECT, starting from 0.
+ */
+ public native final int getIndex() /*-{
+ return this.index;
+ }-*/;
+
+ /**
+ * Option label for use in hierarchical menus.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-label-OPTION
+ */
+ public native final String getLabel() /*-{
+ return this.label;
+ }-*/;
+
+ /**
+ * The text contained within the option element.
+ */
+ public native final String getText() /*-{
+ return this.text;
+ }-*/;
+
+ /**
+ * The current form control value.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-value-OPTION
+ */
+ public native final String getValue() /*-{
+ return this.value;
+ }-*/;
+
+ /**
+ * Represents the value of the HTML selected attribute. The value of this
+ * attribute does not change if the state of the corresponding form control,
+ * in an interactive user agent, changes.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-selected
+ */
+ public native final boolean isDefaultSelected() /*-{
+ return this.defaultSelected;
+ }-*/;
+
+ /**
+ * The control is unavailable in this context.
+ *
+ * @param see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled
+ */
+ public native final boolean isDisabled() /*-{
+ return this.disabled;
+ }-*/;
+
+ /**
+ * Represents the current state of the corresponding form control, in an
+ * interactive user agent. Changing this attribute changes the state of the
+ * form control, but does not change the value of the HTML selected attribute
+ * of the element.
+ */
+ public native final boolean isSelected() /*-{
+ return this.selected;
+ }-*/;
+
+ /**
+ * Represents the value of the HTML selected attribute. The value of this
+ * attribute does not change if the state of the corresponding form control,
+ * in an interactive user agent, changes.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-selected
+ */
+ public native final void setDefaultSelected(boolean selected) /*-{
+ this.defaultSelected = selected;
+ }-*/;
+
+ /**
+ * The control is unavailable in this context.
+ *
+ * @param see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled
+ */
+ public native final void setDisabled(boolean disabled) /*-{
+ return this.disabled = disabled;
+ }-*/;
+
+ /**
+ * Option label for use in hierarchical menus.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-label-OPTION
+ */
+ public native final void setLabel(String label) /*-{
+ return this.label = label;
+ }-*/;
+
+ /**
+ * Represents the current state of the corresponding form control, in an
+ * interactive user agent. Changing this attribute changes the state of the
+ * form control, but does not change the value of the HTML selected attribute
+ * of the element.
+ */
+ public native final void setSelected(boolean selected) /*-{
+ this.selected = selected;
+ }-*/;
+
+ /**
+ * The text contained within the option element.
+ */
+ public native final void setText(String text) /*-{
+ this.text = text;
+ }-*/;
+
+ /**
+ * The current form control value.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-value-OPTION
+ */
+ public native final void setValue(String value) /*-{
+ this.value = value;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/ParagraphElement.java b/user/src/com/google/gwt/dom/client/ParagraphElement.java
new file mode 100644
index 0000000..16d926e
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/ParagraphElement.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Paragraphs.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/text.html#edef-P
+ */
+public class ParagraphElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static ParagraphElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("p");
+ return (ParagraphElement) elem;
+ }
+
+ protected ParagraphElement() {
+ }
+}
diff --git a/user/src/com/google/gwt/dom/client/ParamElement.java b/user/src/com/google/gwt/dom/client/ParamElement.java
new file mode 100644
index 0000000..de364ea
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/ParamElement.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Parameters fed to the OBJECT element.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#edef-PARAM
+ */
+public class ParamElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static ParamElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("param");
+ return (ParamElement) elem;
+ }
+
+ protected ParamElement() {
+ }
+
+ /**
+ * The name of a run-time parameter.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-name-PARAM
+ */
+ public final native String getName() /*-{
+ return this.name;
+ }-*/;
+
+ /**
+ * The value of a run-time parameter.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-value-PARAM
+ */
+ public final native String getValue() /*-{
+ return this.value;
+ }-*/;
+
+ /**
+ * The name of a run-time parameter.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-name-PARAM
+ */
+ public final native void setName(String name) /*-{
+ this.name = name;
+ }-*/;
+
+ /**
+ * The value of a run-time parameter.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-value-PARAM
+ */
+ public final native void setValue(String value) /*-{
+ this.value = value;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/PreElement.java b/user/src/com/google/gwt/dom/client/PreElement.java
new file mode 100644
index 0000000..9018347
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/PreElement.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Preformatted text.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/text.html#edef-PRE
+ */
+public class PreElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static PreElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("pre");
+ return (PreElement) elem;
+ }
+
+ protected PreElement() {
+ }
+}
diff --git a/user/src/com/google/gwt/dom/client/QuoteElement.java b/user/src/com/google/gwt/dom/client/QuoteElement.java
new file mode 100644
index 0000000..7c5c487
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/QuoteElement.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * For the Q and BLOCKQUOTE elements.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/text.html#edef-Q
+ */
+public class QuoteElement extends Element {
+
+ /**
+ * TODO
+ */
+ public static QuoteElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("q")
+ || elem.getTagName().equalsIgnoreCase("blockquote");
+ return (QuoteElement) elem;
+ }
+
+ protected QuoteElement() {
+ }
+
+ /**
+ * A URI designating a source document or message.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/text.html#adef-cite-Q
+ */
+ public final native String getCite() /*-{
+ return this.cite;
+ }-*/;
+
+ /**
+ * A URI designating a source document or message.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/text.html#adef-cite-Q
+ */
+ public final native void setCite(String cite) /*-{
+ this.cite = cite;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/ScriptElement.java b/user/src/com/google/gwt/dom/client/ScriptElement.java
new file mode 100644
index 0000000..dd0a62c
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/ScriptElement.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Script statements.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/scripts.html#edef-SCRIPT
+ */
+public class ScriptElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static ScriptElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("script");
+ return (ScriptElement) elem;
+ }
+
+ protected ScriptElement() {
+ }
+
+ /**
+ * Indicates that the user agent can defer processing of the script.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/scripts.html#adef-defer
+ */
+ public final native String getDefer() /*-{
+ return this.defer;
+ }-*/;
+
+ /**
+ * URI designating an external script.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/scripts.html#adef-src-SCRIPT
+ */
+ public final native String getSrc() /*-{
+ return this.src;
+ }-*/;
+
+ /**
+ * The script content of the element.
+ */
+ public final native String getText() /*-{
+ return this.text;
+ }-*/;
+
+ /**
+ * The content type of the script language.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/scripts.html#adef-type-SCRIPT
+ */
+ public final native String getType() /*-{
+ return this.type;
+ }-*/;
+
+ /**
+ * Indicates that the user agent can defer processing of the script.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/scripts.html#adef-defer
+ */
+ public final native void setDefer(String defer) /*-{
+ this.defer = defer;
+ }-*/;
+
+ /**
+ * URI designating an external script.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/scripts.html#adef-src-SCRIPT
+ */
+ public final native void setSrc(String src) /*-{
+ this.src = src;
+ }-*/;
+
+ /**
+ * The script content of the element.
+ */
+ public final native void setText(String text) /*-{
+ this.text = text;
+ }-*/;
+
+ /**
+ * The content type of the script language.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/scripts.html#adef-type-SCRIPT
+ */
+ public final native void setType(String type) /*-{
+ this.type = type;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/SelectElement.java b/user/src/com/google/gwt/dom/client/SelectElement.java
new file mode 100644
index 0000000..6375b15
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/SelectElement.java
@@ -0,0 +1,233 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * The select element allows the selection of an option.
+ *
+ * The contained options can be directly accessed through the select element as
+ * a collection.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#edef-SELECT
+ */
+public class SelectElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static SelectElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("select");
+ return (SelectElement) elem;
+ }
+
+ protected SelectElement() {
+ }
+
+ /**
+ * Add a new element to the collection of OPTION elements for this SELECT.
+ * This method is the equivalent of the appendChild method of the Node
+ * interface if the before parameter is null. It is equivalent to the
+ * insertBefore method on the parent of before in all other cases. This method
+ * may have no effect if the new element is not an OPTION or an OPTGROUP.
+ *
+ * @param option The element to add
+ * @param before The element to insert before, or null for the tail of the
+ * list
+ */
+ public final void add(OptionElement option, OptionElement before) {
+ DOMImpl.impl.selectAdd(this, option, before);
+ }
+
+ /**
+ * Removes keyboard focus from this element.
+ */
+ public final native void blur() /*-{
+ this.blur();
+ }-*/;
+
+ /**
+ * Gives keyboard focus to this element.
+ */
+ public final native void focus() /*-{
+ this.focus();
+ }-*/;
+
+ /**
+ * The control is unavailable in this context.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled
+ */
+ public final native String getDisabled() /*-{
+ return this.disabled;
+ }-*/;
+
+ /**
+ * Returns the FORM element containing this control. Returns null if this
+ * control is not within the context of a form.
+ */
+ public final native FormElement getForm() /*-{
+ return this.form;
+ }-*/;
+
+ /**
+ * The number of options in this SELECT.
+ */
+ public final int getLength() {
+ return DOMImpl.impl.selectGetLength(this);
+ }
+
+ /**
+ * If true, multiple OPTION elements may be selected in this SELECT.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-multiple
+ */
+ public final native String getMultiple() /*-{
+ return this.multiple;
+ }-*/;
+
+ /**
+ * Form control or object name when submitted with a form.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-name-SELECT
+ */
+ public final native String getName() /*-{
+ return this.name;
+ }-*/;
+
+ /**
+ * The collection of OPTION elements contained by this element.
+ */
+ public final NodeList<OptionElement> getOptions() {
+ return DOMImpl.impl.selectGetOptions(this);
+ }
+
+ /**
+ * The ordinal index of the selected option, starting from 0. The value -1 is
+ * returned if no element is selected. If multiple options are selected, the
+ * index of the first selected option is returned.
+ */
+ public final native int getSelectedIndex() /*-{
+ return this.selectedIndex;
+ }-*/;
+
+ /**
+ * Number of visible rows.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-size-SELECT
+ */
+ public final native int getSize() /*-{
+ return this.size;
+ }-*/;
+
+ /**
+ * The type of this form control. This is the string "select-multiple" when
+ * the multiple attribute is true and the string "select-one" when false.
+ */
+ public final native String getType() /*-{
+ return this.type;
+ }-*/;
+
+ /**
+ * The current form control value (i.e. the value of the currently selected
+ * option), if multiple options are selected this is the value of the first
+ * selected option.
+ */
+ public final native String getValue() /*-{
+ return this.value;
+ }-*/;
+
+ /**
+ * If true, multiple OPTION elements may be selected in this SELECT.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-multiple
+ */
+ public final native boolean isMultiple() /*-{
+ return this.multiple;
+ }-*/;
+
+ /**
+ * Remove an element from the collection of OPTION elements for this SELECT.
+ * Does nothing if no element has the given index.
+ *
+ * @param index The index of the item to remove, starting from 0.
+ */
+ public final void remove(int index) {
+ DOMImpl.impl.selectRemoveOption(this, index);
+ }
+
+ /**
+ * The control is unavailable in this context.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled
+ */
+ public final native void setDisabled(String disabled) /*-{
+ this.disabled = disabled;
+ }-*/;
+
+ /**
+ * If true, multiple OPTION elements may be selected in this SELECT.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-multiple
+ */
+ public final native void setMultiple(boolean multiple) /*-{
+ this.multiple = multiple;
+ }-*/;
+
+ /**
+ * Form control or object name when submitted with a form.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-name-SELECT
+ */
+ public final native void setName(String name) /*-{
+ this.name = name;
+ }-*/;
+
+ /**
+ * The ordinal index of the selected option, starting from 0. The value -1 is
+ * returned if no element is selected. If multiple options are selected, the
+ * index of the first selected option is returned.
+ */
+ public final native void setSelectedIndex(int index) /*-{
+ this.selectedIndex = index;
+ }-*/;
+
+ /**
+ * Number of visible rows.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-size-SELECT
+ */
+ public final native void setSize(int size) /*-{
+ this.size = size;
+ }-*/;
+
+ /**
+ * The type of this form control. This is the string "select-multiple" when
+ * the multiple attribute is true and the string "select-one" when false.
+ */
+ public final native void setType(String type) /*-{
+ this.type = type;
+ }-*/;
+
+ /**
+ * The current form control value (i.e. the value of the currently selected
+ * option), if multiple options are selected this is the value of the first
+ * selected option.
+ */
+ public final native void setValue(String value) /*-{
+ this.value = value;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/SpanElement.java b/user/src/com/google/gwt/dom/client/SpanElement.java
new file mode 100644
index 0000000..03e6eec
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/SpanElement.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Generic inline container.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#edef-SPAN
+ */
+public class SpanElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static SpanElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("span");
+ return (SpanElement) elem;
+ }
+
+ protected SpanElement() {
+ }
+}
diff --git a/user/src/com/google/gwt/dom/client/Style.java b/user/src/com/google/gwt/dom/client/Style.java
new file mode 100644
index 0000000..76e0fd0
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/Style.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+import com.google.gwt.core.client.JavaScriptObject;
+
+/**
+ * TODO
+ */
+public class Style extends JavaScriptObject {
+
+ protected Style() {
+ }
+
+ /**
+ * TODO
+ */
+ public final native String getProperty(String name) /*-{
+ return this[name] || '';
+ }-*/;
+
+ /**
+ * TODO
+ */
+ public final native void setProperty(String name, String value) /*-{
+ this[name] = value;
+ }-*/;
+
+ /**
+ * TODO
+ */
+ public final native void setPropertyPx(String name, int value) /*-{
+ this[name] = value + "px";
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/StyleElement.java b/user/src/com/google/gwt/dom/client/StyleElement.java
new file mode 100644
index 0000000..3a5d025
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/StyleElement.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Style information.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/styles.html#edef-STYLE
+ * @see http://www.w3.org/TR/DOM-Level-2-HTML/references.html#DOMStyle
+ * @see http://www.w3.org/TR/DOM-Level-2-HTML/references.html#DOMStyle-inf
+ */
+public class StyleElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static StyleElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("style");
+ return (StyleElement) elem;
+ }
+
+ protected StyleElement() {
+ }
+
+ /**
+ * Enables/disables the style sheet.
+ */
+ public final native boolean getDisabled() /*-{
+ return this.disabled;
+ }-*/;
+
+ /**
+ * Enables/disables the style sheet.
+ */
+ public final native void setDisabled(boolean disabled) /*-{
+ this.disabled = disabled;
+ }-*/;
+
+ /**
+ * Designed for use with one or more target media.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/styles.html#adef-media
+ */
+ public final native String getMedia() /*-{
+ return this.media;
+ }-*/;
+
+ /**
+ * Designed for use with one or more target media.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/styles.html#adef-media
+ */
+ public final native void setMedia(String media) /*-{
+ this.media = media;
+ }-*/;
+
+ /**
+ * The content type of the style sheet language.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/styles.html#adef-type-STYLE
+ */
+ public final native String getType() /*-{
+ return this.type;
+ }-*/;
+
+ /**
+ * The content type of the style sheet language.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/present/styles.html#adef-type-STYLE
+ */
+ public final native void setType(String type) /*-{
+ this.type = type;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/TableCaptionElement.java b/user/src/com/google/gwt/dom/client/TableCaptionElement.java
new file mode 100644
index 0000000..e2305e6
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/TableCaptionElement.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Table caption.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#edef-CAPTION
+ */
+public class TableCaptionElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static TableCaptionElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("caption");
+ return (TableCaptionElement) elem;
+ }
+
+ protected TableCaptionElement() {
+ }
+}
diff --git a/user/src/com/google/gwt/dom/client/TableCellElement.java b/user/src/com/google/gwt/dom/client/TableCellElement.java
new file mode 100644
index 0000000..45b21dc
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/TableCellElement.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * The object used to represent the TH and TD elements.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#edef-TD
+ */
+public class TableCellElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static TableCellElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("td");
+ return (TableCellElement) elem;
+ }
+
+ protected TableCellElement() {
+ }
+
+ /**
+ * The index of this cell in the row, starting from 0. This index is in
+ * document tree order and not display order.
+ */
+ public final native int getCellIndex() /*-{
+ return this.cellIndex;
+ }-*/;
+
+ /**
+ * Horizontal alignment of data in cell.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-align-TD
+ */
+ public final native String getAlign() /*-{
+ return this.align;
+ }-*/;
+
+ /**
+ * Horizontal alignment of data in cell.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-align-TD
+ */
+ public final native void setAlign(String align) /*-{
+ this.align = align;
+ }-*/;
+
+ /**
+ * Alignment character for cells in a column.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-char
+ */
+ public final native String getCh() /*-{
+ return this.ch;
+ }-*/;
+
+ /**
+ * Alignment character for cells in a column.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-char
+ */
+ public final native void setCh(String ch) /*-{
+ this.ch = ch;
+ }-*/;
+
+ /**
+ * Offset of alignment character.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-charoff
+ */
+ public final native String getChOff() /*-{
+ return this.chOff;
+ }-*/;
+
+ /**
+ * Offset of alignment character.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-charoff
+ */
+ public final native void setChOff(String chOff) /*-{
+ this.chOff = chOff;
+ }-*/;
+
+ /**
+ * Number of columns spanned by cell.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-colspan
+ */
+ public final native int getColSpan() /*-{
+ return this.colSpan;
+ }-*/;
+
+ /**
+ * Number of columns spanned by cell.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-colspan
+ */
+ public final native void setColSpan(int colSpan) /*-{
+ this.colSpan = colSpan;
+ }-*/;
+
+ /**
+ * List of id attribute values for header cells.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-headers
+ */
+ public final native String getHeaders() /*-{
+ return this.headers;
+ }-*/;
+
+ /**
+ * List of id attribute values for header cells.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-headers
+ */
+ public final native void setHeaders(String headers) /*-{
+ this.headers = headers;
+ }-*/;
+
+ /**
+ * Number of rows spanned by cell.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-rowspan
+ */
+ public final native int getRowSpan() /*-{
+ return this.rowSpan;
+ }-*/;
+
+ /**
+ * Number of rows spanned by cell.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-rowspan
+ */
+ public final native void setRowSpan(int rowSpan) /*-{
+ this.rowSpan = rowSpan;
+ }-*/;
+
+ /**
+ * Vertical alignment of data in cell.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-valign
+ */
+ public final native String getVAlign() /*-{
+ return this.vAlign;
+ }-*/;
+
+ /**
+ * Vertical alignment of data in cell.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-valign
+ */
+ public final native void setVAlign(String vAlign) /*-{
+ this.vAlign = vAlign;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/TableColElement.java b/user/src/com/google/gwt/dom/client/TableColElement.java
new file mode 100644
index 0000000..74831de
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/TableColElement.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Regroups the COL and COLGROUP elements.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#edef-COL
+ */
+public class TableColElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static TableColElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("col")
+ || elem.getTagName().equalsIgnoreCase("colgroup");
+ return (TableColElement) elem;
+ }
+
+ protected TableColElement() {
+ }
+
+ /**
+ * Horizontal alignment of cell data in column.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-align-TD
+ */
+ public final native String getAlign() /*-{
+ return this.align;
+ }-*/;
+
+ /**
+ * Alignment character for cells in a column.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-char
+ */
+ public final native String getCh() /*-{
+ return this.ch;
+ }-*/;
+
+ /**
+ * Offset of alignment character.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-charoff
+ */
+ public final native String getChOff() /*-{
+ return this.chOff;
+ }-*/;
+
+ /**
+ * Indicates the number of columns in a group or affected by a grouping.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-span-COL
+ */
+ public final native int getSpan() /*-{
+ return this.span;
+ }-*/;
+
+ /**
+ * Vertical alignment of cell data in column.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-valign
+ */
+ public final native String getVAlign() /*-{
+ return this.vAlign;
+ }-*/;
+
+ /**
+ * Default column width.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-width-COL
+ */
+ public final native String getWidth() /*-{
+ return this.width;
+ }-*/;
+
+ /**
+ * Horizontal alignment of cell data in column.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-align-TD
+ */
+ public final native void setAlign(String align) /*-{
+ this.align = align;
+ }-*/;
+
+ /**
+ * Alignment character for cells in a column.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-char
+ */
+ public final native void setCh(String ch) /*-{
+ this.ch = ch;
+ }-*/;
+
+ /**
+ * Offset of alignment character.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-charoff
+ */
+ public final native void setChOff(String chOff) /*-{
+ this.chOff = chOff;
+ }-*/;
+
+ /**
+ * Indicates the number of columns in a group or affected by a grouping.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-span-COL
+ */
+ public final native void setSpan(int span) /*-{
+ this.span = span;
+ }-*/;
+
+ /**
+ * Vertical alignment of cell data in column.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-valign
+ */
+ public final native void setVAlign(String vAlign) /*-{
+ this.vAlign = vAlign;
+ }-*/;
+
+ /**
+ * Default column width.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-width-COL
+ */
+ public final native void setWidth(String width) /*-{
+ this.width = width;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/TableElement.java b/user/src/com/google/gwt/dom/client/TableElement.java
new file mode 100644
index 0000000..f0c0a69
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/TableElement.java
@@ -0,0 +1,285 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * The create* and delete* methods on the table allow authors to construct and
+ * modify tables. [HTML 4.01] specifies that only one of each of the CAPTION,
+ * THEAD, and TFOOT elements may exist in a table. Therefore, if one exists, and
+ * the createTHead() or createTFoot() method is called, the method returns the
+ * existing THead or TFoot element.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#edef-TABLE
+ */
+public class TableElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static TableElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("table");
+ return (TableElement) elem;
+ }
+
+ protected TableElement() {
+ }
+
+ /**
+ * Create a new table caption object or return an existing one.
+ *
+ * @return A CAPTION element.
+ */
+ public final native TableCaptionElement createCaption() /*-{
+ return this.createCaption();
+ }-*/;
+
+ /**
+ * Create a table footer row or return an existing one.
+ *
+ * @return A footer element (TFOOT)
+ */
+ public final native TableSectionElement createTFoot() /*-{
+ return this.createTFoot();
+ }-*/;
+
+ /**
+ * Create a table header row or return an existing one.
+ *
+ * @return A new table header element (THEAD)
+ */
+ public final native TableSectionElement createTHead() /*-{
+ return this.createTHead();
+ }-*/;
+
+ /**
+ * Delete the table caption, if one exists.
+ */
+ public final native void deleteCaption() /*-{
+ this.deleteCaption();
+ }-*/;
+
+ /**
+ * Delete a table row.
+ *
+ * @param index The index of the row to be deleted. This index starts from 0
+ * and is relative to the logical order (not document order) of all
+ * the rows contained inside the table. If the index is -1 the last
+ * row in the table is deleted
+ */
+ public final native void deleteRow(int index) /*-{
+ this.deleteRow(index);
+ }-*/;
+
+ /**
+ * Delete the header from the table, if one exists.
+ */
+ public final native void deleteTFoot() /*-{
+ this.deleteTFoot();
+ }-*/;
+
+ /**
+ * Delete the header from the table, if one exists.
+ */
+ public final native void deleteTHead() /*-{
+ this.deleteTHead();
+ }-*/;
+
+ /**
+ * The width of the border around the table.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-border-TABLE
+ */
+ public final native int getBorder() /*-{
+ return this.border;
+ }-*/;
+
+ /**
+ * The table's CAPTION, or null if none exists.
+ */
+ public final native TableCaptionElement getCaption() /*-{
+ return this.caption;
+ }-*/;
+
+ /**
+ * Specifies the horizontal and vertical space between cell content and cell
+ * borders.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-cellpadding
+ */
+ public final native int getCellPadding() /*-{
+ return this.cellPadding;
+ }-*/;
+
+ /**
+ * Specifies the horizontal and vertical separation between cells.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-cellspacing
+ */
+ public final native int getCellSpacing() /*-{
+ return this.cellSpacing;
+ }-*/;
+
+ /**
+ * Specifies which external table borders to render.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-frame
+ */
+ public final native String getFrame() /*-{
+ return this.frame;
+ }-*/;
+
+ /**
+ * Returns a collection of all the rows in the table, including all in THEAD,
+ * TFOOT, all TBODY elements.
+ */
+ public final native NodeList<TableRowElement> getRows() /*-{
+ return this.rows;
+ }-*/;
+
+ /**
+ * Specifies which internal table borders to render.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-rules
+ */
+ public final native String getRules() /*-{
+ return this.rules;
+ }-*/;
+
+ /**
+ * Returns a collection of the table bodies (including implicit ones).
+ */
+ public final native NodeList<TableSectionElement> getTBodies() /*-{
+ return this.tBodies;
+ }-*/;
+
+ /**
+ * The table's TFOOT, or null if none exists.
+ */
+ public final native TableSectionElement getTFoot() /*-{
+ return this.tFoot;
+ }-*/;
+
+ /**
+ * The table's THEAD, or null if none exists.
+ */
+ public final native TableSectionElement getTHead() /*-{
+ return this.tHead;
+ }-*/;
+
+ /**
+ * Specifies the desired table width.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-width-TABLE
+ */
+ public final native String getWidth() /*-{
+ return this.width;
+ }-*/;
+
+ /**
+ * Insert a new empty row in the table. The new row is inserted immediately
+ * before and in the same section as the current indexth row in the table. If
+ * index is -1 or equal to the number of rows, the new row is appended. In
+ * addition, when the table is empty the row is inserted into a TBODY which is
+ * created and inserted into the table.
+ *
+ * Note: A table row cannot be empty according to [HTML 4.01].
+ *
+ * @param index The row number where to insert a new row. This index starts
+ * from 0 and is relative to the logical order (not document order)
+ * of all the rows contained inside the table
+ * @return The newly created row
+ */
+ public final native TableRowElement insertRow(int index) /*-{
+ return this.insertRow(index);
+ }-*/;
+
+ /**
+ * The width of the border around the table.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-border-TABLE
+ */
+ public final native void setBorder(int border) /*-{
+ this.border = border;
+ }-*/;
+
+ /**
+ * The table's CAPTION, or null if none exists.
+ */
+ public final native void setCaption(TableCaptionElement caption) /*-{
+ this.caption = caption;
+ }-*/;
+
+ /**
+ * Specifies the horizontal and vertical space between cell content and cell
+ * borders.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-cellpadding
+ */
+ public final native void setCellPadding(int cellPadding) /*-{
+ this.cellPadding = cellPadding;
+ }-*/;
+
+ /**
+ * Specifies the horizontal and vertical separation between cells.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-cellspacing
+ */
+ public final native void setCellSpacing(int cellSpacing) /*-{
+ this.cellSpacing = cellSpacing;
+ }-*/;
+
+ /**
+ * Specifies which external table borders to render.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-frame
+ */
+ public final native void setFrame(String frame) /*-{
+ this.frame = frame;
+ }-*/;
+
+ /**
+ * Specifies which internal table borders to render.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-rules
+ */
+ public final native void setRules(String rules) /*-{
+ this.rules = rules;
+ }-*/;
+
+ /**
+ * The table's TFOOT, or null if none exists.
+ */
+ public final native void setTFoot(TableSectionElement tFoot) /*-{
+ this.tFoot = tFoot;
+ }-*/;
+
+ /**
+ * The table's THEAD, or null if none exists.
+ */
+ public final native void setTHead(TableSectionElement tHead) /*-{
+ this.tHead = tHead;
+ }-*/;
+
+ /**
+ * Specifies the desired table width.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-width-TABLE
+ */
+ public final native void setWidth(String width) /*-{
+ this.width = width;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/TableRowElement.java b/user/src/com/google/gwt/dom/client/TableRowElement.java
new file mode 100644
index 0000000..689d7b9
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/TableRowElement.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * A row in a table.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#edef-TR
+ */
+public class TableRowElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static TableRowElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("tr");
+ return (TableRowElement) elem;
+ }
+
+ protected TableRowElement() {
+ }
+
+ public final native void deleteCell(int index) /*-{
+ this.deleteCell(index);
+ }-*/;
+
+ /**
+ * Horizontal alignment of data within cells of this row.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-align-TD
+ */
+ public final native String getAlign() /*-{
+ return this.align;
+ }-*/;
+
+ /**
+ * The collection of cells in this row.
+ */
+ public final native NodeList<TableCellElement> getCells() /*-{
+ return this.cells;
+ }-*/;
+
+ /**
+ * Alignment character for cells in a column.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-char
+ */
+ public final native String getCh() /*-{
+ return this.ch;
+ }-*/;
+
+ /**
+ * Offset of alignment character.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-charoff
+ */
+ public final native String getChOff() /*-{
+ return this.chOff;
+ }-*/;
+
+ /**
+ * This is in logical order and not in document order. The rowIndex does take
+ * into account sections (THEAD, TFOOT, or TBODY) within the table, placing
+ * THEAD rows first in the index, followed by TBODY rows, followed by TFOOT
+ * rows.
+ */
+ public final native int getRowIndex() /*-{
+ return this.rowIndex;
+ }-*/;
+
+ /**
+ * The index of this row, relative to the current section (THEAD, TFOOT, or
+ * TBODY), starting from 0.
+ */
+ public final native int getSectionRowIndex() /*-{
+ return this.sectionRowIndex;
+ }-*/;
+
+ /**
+ * Vertical alignment of data within cells of this row.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-valign
+ */
+ public final native String getVAlign() /*-{
+ return this.vAlign;
+ }-*/;
+
+ public final native TableCellElement insertCell(int index) /*-{
+ return this.insertCell(index);
+ }-*/;
+
+ /**
+ * Horizontal alignment of data within cells of this row.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-align-TD
+ */
+ public final native void setAlign(String align) /*-{
+ this.align = align;
+ }-*/;
+
+ /**
+ * Alignment character for cells in a column.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-char
+ */
+ public final native void setCh(String ch) /*-{
+ this.ch = ch;
+ }-*/;
+
+ /**
+ * Offset of alignment character.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-charoff
+ */
+ public final native void setChOff(String chOff) /*-{
+ this.chOff = chOff;
+ }-*/;
+
+ /**
+ * Vertical alignment of data within cells of this row.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-valign
+ */
+ public final native void setVAlign(String vAlign) /*-{
+ this.vAlign = vAlign;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/TableSectionElement.java b/user/src/com/google/gwt/dom/client/TableSectionElement.java
new file mode 100644
index 0000000..b223a60
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/TableSectionElement.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * The THEAD, TFOOT, and TBODY elements.
+ */
+public class TableSectionElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static TableSectionElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("thead")
+ || elem.getTagName().equalsIgnoreCase("tfoot")
+ || elem.getTagName().equalsIgnoreCase("tbody");
+ return (TableSectionElement) elem;
+ }
+
+ protected TableSectionElement() {
+ }
+
+ /**
+ * Delete a row from this section.
+ *
+ * @param index The index of the row to be deleted, or -1 to delete the last
+ * row. This index starts from 0 and is relative only to the rows
+ * contained inside this section, not all the rows in the table.
+ */
+ public final native void deleteRow(int index) /*-{
+ this.deleteRow(index);
+ }-*/;
+
+ /**
+ * Horizontal alignment of data in cells. See the align attribute for
+ * HTMLTheadElement for details.
+ */
+ public final native String getAlign() /*-{
+ return this.align;
+ }-*/;
+
+ /**
+ * Alignment character for cells in a column.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-char
+ */
+ public final native String getCh() /*-{
+ return this.ch;
+ }-*/;
+
+ /**
+ * Offset of alignment character.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-charoff
+ */
+ public final native String getChOff() /*-{
+ return this.chOff;
+ }-*/;
+
+ /**
+ * The collection of rows in this table section.
+ */
+ public final native NodeList<TableRowElement> getRows() /*-{
+ return this.rows;
+ }-*/;
+
+ /**
+ * Vertical alignment of data in cells. See the valign attribute for
+ * HTMLTheadElement for details.
+ */
+ public final native String getVAlign() /*-{
+ return this.valign;
+ }-*/;
+
+ /**
+ * Insert a row into this section. The new row is inserted immediately before
+ * the current indexth row in this section. If index is -1 or equal to the
+ * number of rows in this section, the new row is appended.
+ *
+ * @param index The row number where to insert a new row. This index starts
+ * from 0 and is relative only to the rows contained inside this
+ * section, not all the rows in the table.
+ * @return The newly created row.
+ */
+ public final native TableRowElement insertRow(int index) /*-{
+ return this.insertRow(index);
+ }-*/;
+
+ /**
+ * Horizontal alignment of data in cells. See the align attribute for
+ * HTMLTheadElement for details.
+ */
+ public final native void setAlign(String align) /*-{
+ this.align = align;
+ }-*/;
+
+ /**
+ * Alignment character for cells in a column.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-char
+ */
+ public final native void setCh(String ch) /*-{
+ this.ch = ch;
+ }-*/;
+
+ /**
+ * Offset of alignment character.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-charoff
+ */
+ public final native void setChOff(String chOff) /*-{
+ this.chOff = chOff;
+ }-*/;
+
+ /**
+ * Vertical alignment of data in cells. See the valign attribute for
+ * HTMLTheadElement for details.
+ */
+ public final native void setVAlign(String vAlign) /*-{
+ this.valign = valign;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/Text.java b/user/src/com/google/gwt/dom/client/Text.java
new file mode 100644
index 0000000..c122368
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/Text.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * The Text interface represents textual content.
+ */
+public class Text extends Node {
+
+ /**
+ * Assert that the given {@link Node} is of type {@link Node#TEXT_NODE} and
+ * automatically typecast it.
+ */
+ public static Text as(Node node) {
+ assert node.getNodeType() == Node.TEXT_NODE;
+ return (Text)node;
+ }
+
+ protected Text() {
+ }
+
+ /**
+ * The character data of this text node.
+ */
+ public final native String getData() /*-{
+ return this.data;
+ }-*/;
+
+ /**
+ * The character data of this text node.
+ */
+ public final native void setData(String data) /*-{
+ this.data = data;
+ }-*/;
+
+ /**
+ * The number of characters available through the data property.
+ */
+ public final native int getLength() /*-{
+ return this.length;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/TextAreaElement.java b/user/src/com/google/gwt/dom/client/TextAreaElement.java
new file mode 100644
index 0000000..406707d
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/TextAreaElement.java
@@ -0,0 +1,246 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Multi-line text field.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#edef-TEXTAREA
+ */
+public class TextAreaElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static TextAreaElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("textarea");
+ return (TextAreaElement) elem;
+ }
+
+ protected TextAreaElement() {
+ }
+
+ /**
+ * Removes keyboard focus from this element.
+ */
+ public final native void blur() /*-{
+ this.blur();
+ }-*/;
+
+ /**
+ * Gives keyboard focus to this element.
+ */
+ public final native void focus() /*-{
+ this.focus();
+ }-*/;
+
+ /**
+ * A single character access key to give access to the form control.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey
+ */
+ public final native String getAccessKey() /*-{
+ return this.accessKey;
+ }-*/;
+
+ /**
+ * Width of control (in characters).
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-cols-TEXTAREA
+ */
+ public final native int getCols() /*-{
+ return this.cols;
+ }-*/;
+
+ /**
+ * Represents the contents of the element. The value of this attribute does
+ * not change if the contents of the corresponding form control, in an
+ * interactive user agent, changes.
+ */
+ public final native String getDefaultValue() /*-{
+ return this.defaultValue;
+ }-*/;
+
+ public final native boolean getDisabled() /*-{
+ return this.disabled;
+ }-*/;
+
+ /**
+ * Returns the FORM element containing this control. Returns null if this
+ * control is not within the context of a form.
+ */
+ public final native FormElement getForm() /*-{
+ return this.form;
+ }-*/;
+
+ /**
+ * Form control or object name when submitted with a form.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-name-TEXTAREA
+ */
+ public final native String getName() /*-{
+ return this.name;
+ }-*/;
+
+ public final native boolean getReadOnly() /*-{
+ return this.readOnly;
+ }-*/;
+
+ /**
+ * Number of text rows.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-rows-TEXTAREA
+ */
+ public final native int getRows() /*-{
+ return this.rows;
+ }-*/;
+
+ /**
+ * Index that represents the element's position in the tabbing order.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex
+ */
+ public final native int getTabIndex() /*-{
+ return this.tabIndex;
+ }-*/;
+
+ /**
+ * The type of this form control. This the string "textarea".
+ */
+ public final native String getType() /*-{
+ return this.type;
+ }-*/;
+
+ /**
+ * Represents the current contents of the corresponding form control, in an
+ * interactive user agent. Changing this attribute changes the contents of the
+ * form control, but does not change the contents of the element. If the
+ * entirety of the data can not fit into a single string, the implementation
+ * may truncate the data.
+ */
+ public final native String getValue() /*-{
+ return this.value;
+ }-*/;
+
+ /**
+ * Select the contents of the TEXTAREA.
+ */
+ public final native void select() /*-{
+ this.select();
+ }-*/;
+
+ /**
+ * A single character access key to give access to the form control.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey
+ */
+ public final native void setAccessKey(String accessKey) /*-{
+ this.accessKey = accessKey;
+ }-*/;
+
+ /**
+ * Width of control (in characters).
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-cols-TEXTAREA
+ */
+ public final native void setCols(int cols) /*-{
+ this.cols = cols;
+ }-*/;
+
+ /**
+ * Represents the contents of the element. The value of this attribute does
+ * not change if the contents of the corresponding form control, in an
+ * interactive user agent, changes.
+ */
+ public final native void setDefaultValue(String defaultValue) /*-{
+ this.defaultValue = defaultValue;
+ }-*/;
+
+ /**
+ * The control is unavailable in this context.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled
+ */
+ public final native boolean isDisabled() /*-{
+ return this.disabled;
+ }-*/;
+
+ /**
+ * The control is unavailable in this context.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled
+ */
+ public final native void setDisabled(boolean disabled) /*-{
+ this.disabled = disabled;
+ }-*/;
+
+ /**
+ * Form control or object name when submitted with a form.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-name-TEXTAREA
+ */
+ public final native void setName(String name) /*-{
+ this.name = name;
+ }-*/;
+
+ /**
+ * This control is read-only.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-readonly
+ */
+ public final native boolean isReadOnly() /*-{
+ return this.readOnly;
+ }-*/;
+
+ /**
+ * This control is read-only.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-readonly
+ */
+ public final native void setReadOnly(boolean readOnly) /*-{
+ this.readOnly = readOnly;
+ }-*/;
+
+ /**
+ * Number of text rows.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-rows-TEXTAREA
+ */
+ public final native void setRows(int rows) /*-{
+ this.rows = rows;
+ }-*/;
+
+ /**
+ * Index that represents the element's position in the tabbing order.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex
+ */
+ public final native void setTabIndex(int tabIndex) /*-{
+ this.tabIndex = tabIndex;
+ }-*/;
+
+ /**
+ * Represents the current contents of the corresponding form control, in an
+ * interactive user agent. Changing this attribute changes the contents of the
+ * form control, but does not change the contents of the element. If the
+ * entirety of the data can not fit into a single string, the implementation
+ * may truncate the data.
+ */
+ public final native void setValue(String value) /*-{
+ this.value = value;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/TitleElement.java b/user/src/com/google/gwt/dom/client/TitleElement.java
new file mode 100644
index 0000000..6821bdd
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/TitleElement.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * The document title.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/global.html#edef-TITLE
+ */
+public class TitleElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static TitleElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("title");
+ return (TitleElement) elem;
+ }
+
+ protected TitleElement() {
+ }
+
+ /**
+ * The specified title as a string.
+ */
+ public final native String getText() /*-{
+ return this.text;
+ }-*/;
+
+ /**
+ * The specified title as a string.
+ */
+ public final native void setText(String text) /*-{
+ this.text = text;
+ }-*/;
+}
diff --git a/user/src/com/google/gwt/dom/client/UListElement.java b/user/src/com/google/gwt/dom/client/UListElement.java
new file mode 100644
index 0000000..d6020c2
--- /dev/null
+++ b/user/src/com/google/gwt/dom/client/UListElement.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+/**
+ * Unordered list.
+ *
+ * @see http://www.w3.org/TR/1999/REC-html401-19991224/struct/lists.html#edef-UL
+ */
+public class UListElement extends Element {
+
+ /**
+ * Assert that the given {@link Element} is compatible with this class and
+ * automatically typecast it.
+ */
+ public static UListElement as(Element elem) {
+ assert elem.getTagName().equalsIgnoreCase("ul");
+ return (UListElement) elem;
+ }
+
+ protected UListElement() {
+ }
+}
diff --git a/user/src/com/google/gwt/user/DOM.gwt.xml b/user/src/com/google/gwt/user/DOM.gwt.xml
index f504f46..936c6e3 100644
--- a/user/src/com/google/gwt/user/DOM.gwt.xml
+++ b/user/src/com/google/gwt/user/DOM.gwt.xml
@@ -18,6 +18,7 @@
<!-- -->
<module>
<inherits name="com.google.gwt.core.Core"/>
+ <inherits name="com.google.gwt.dom.DOM"/>
<inherits name="com.google.gwt.user.UserAgent"/>
<replace-with class="com.google.gwt.user.client.impl.DOMImplOpera">
diff --git a/user/src/com/google/gwt/user/client/DOM.java b/user/src/com/google/gwt/user/client/DOM.java
index 5e6184f..ca42517 100644
--- a/user/src/com/google/gwt/user/client/DOM.java
+++ b/user/src/com/google/gwt/user/client/DOM.java
@@ -15,12 +15,16 @@
*/
package com.google.gwt.user.client;
+import java.util.ArrayList;
+
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.GWT.UncaughtExceptionHandler;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.ImageElement;
+import com.google.gwt.dom.client.OptionElement;
+import com.google.gwt.dom.client.SelectElement;
import com.google.gwt.user.client.impl.DOMImpl;
-import java.util.ArrayList;
-
/**
* This class provides a set of static methods that allow you to manipulate the
* browser's Document Object Model (DOM). It contains methods for manipulating
@@ -33,8 +37,6 @@
private static Event currentEvent = null;
private static final DOMImpl impl = GWT.create(DOMImpl.class);
private static Element sCaptureElem;
- // Used to generate unique DOM ids.
- private static int nextDOMId = 0;
// <BrowserEventPreview>
private static ArrayList<EventPreview> sEventPreviewStack;
@@ -64,7 +66,7 @@
* @param child its new child
*/
public static void appendChild(Element parent, Element child) {
- impl.appendChild(parent, child);
+ parent.appendChild(child);
}
/**
@@ -74,11 +76,11 @@
* @param deep should children be cloned as well?
*/
public static Element clone(Element elem, boolean deep) {
- return impl.clone(elem, deep);
+ return elem.cloneNode(deep).cast();
}
/**
- * Compares two elements for equality. Note that this method is now deprecated
+ * Compares two elements for equality. Note that this method is now deprecated
* because reference identity accurately reports equality.
*
* @param elem1 the first element to be compared
@@ -96,7 +98,7 @@
* @return the newly-created element
*/
public static Element createAnchor() {
- return impl.createElement("A");
+ return Document.get().createAnchorElement().cast();
}
/**
@@ -105,7 +107,7 @@
* @return the newly-created element
*/
public static Element createButton() {
- return impl.createElement("button");
+ return Document.get().createButtonElement().cast();
}
/**
@@ -114,7 +116,7 @@
* @return the newly-created element
*/
public static Element createCaption() {
- return impl.createElement("caption");
+ return Document.get().createCaptionElement().cast();
}
/**
@@ -123,7 +125,7 @@
* @return the newly-created element
*/
public static Element createCol() {
- return impl.createElement("col");
+ return Document.get().createColElement().cast();
}
/**
@@ -132,7 +134,7 @@
* @return the newly-created element
*/
public static Element createColGroup() {
- return impl.createElement("colgroup");
+ return Document.get().createColGroupElement().cast();
}
/**
@@ -141,7 +143,7 @@
* @return the newly-created element
*/
public static Element createDiv() {
- return impl.createElement("div");
+ return Document.get().createDivElement().cast();
}
/**
@@ -151,7 +153,7 @@
* @return the newly-created element
*/
public static Element createElement(String tagName) {
- return impl.createElement(tagName);
+ return Document.get().createElement(tagName).cast();
}
/**
@@ -160,7 +162,7 @@
* @return the newly-created element
*/
public static Element createFieldSet() {
- return impl.createElement("fieldset");
+ return Document.get().createFieldSetElement().cast();
}
/**
@@ -169,7 +171,7 @@
* @return the newly-created element
*/
public static Element createForm() {
- return impl.createElement("form");
+ return Document.get().createFormElement().cast();
}
/**
@@ -178,7 +180,7 @@
* @return the newly-created element
*/
public static Element createIFrame() {
- return impl.createElement("iframe");
+ return Document.get().createIFrameElement().cast();
}
/**
@@ -187,7 +189,7 @@
* @return the newly-created element
*/
public static Element createImg() {
- return impl.createElement("img");
+ return Document.get().createImageElement().cast();
}
/**
@@ -196,7 +198,7 @@
* @return the newly-created element
*/
public static Element createInputCheck() {
- return impl.createInputElement("checkbox");
+ return Document.get().createCheckInputElement().cast();
}
/**
@@ -205,7 +207,7 @@
* @return the newly-created element
*/
public static Element createInputPassword() {
- return impl.createInputElement("password");
+ return Document.get().createPasswordInputElement().cast();
}
/**
@@ -216,7 +218,7 @@
* @return the newly-created element
*/
public static Element createInputRadio(String name) {
- return impl.createInputRadioElement(name);
+ return Document.get().createRadioInputElement(name).cast();
}
/**
@@ -225,7 +227,7 @@
* @return the newly-created element
*/
public static Element createInputText() {
- return impl.createInputElement("text");
+ return Document.get().createTextInputElement().cast();
}
/**
@@ -234,7 +236,7 @@
* @return the newly-created element
*/
public static Element createLabel() {
- return impl.createElement("label");
+ return Document.get().createLabelElement().cast();
}
/**
@@ -243,16 +245,28 @@
* @return the newly-created element
*/
public static Element createLegend() {
- return impl.createElement("legend");
+ return Document.get().createLegendElement().cast();
+ }
+
+ /**
+ * Creates an HTML OPTION element.
+ *
+ * @return the newly-created element
+ */
+ public static Element createOption() {
+ return Document.get().createOptionElement().cast();
}
/**
* Creates an HTML OPTIONS element.
*
* @return the newly-created element
+ * @deprecated there is no "options" element; use {@link #createOption()}
+ * instead
*/
+ @Deprecated
public static Element createOptions() {
- return impl.createElement("options");
+ return Document.get().createElement("options").cast();
}
/**
@@ -265,7 +279,7 @@
* @return the newly-created element
*/
public static Element createSelect() {
- return DOM.createSelect(false);
+ return Document.get().createSelectElement().cast();
}
/**
@@ -275,7 +289,7 @@
* @return the newly-created element
*/
public static Element createSelect(boolean multiple) {
- return impl.createSelectElement(multiple);
+ return Document.get().createSelectElement(multiple).cast();
}
/**
@@ -284,7 +298,7 @@
* @return the newly-created element
*/
public static Element createSpan() {
- return impl.createElement("span");
+ return Document.get().createSpanElement().cast();
}
/**
@@ -293,7 +307,7 @@
* @return the newly-created element
*/
public static Element createTable() {
- return impl.createElement("table");
+ return Document.get().createTableElement().cast();
}
/**
@@ -302,7 +316,7 @@
* @return the newly-created element
*/
public static Element createTBody() {
- return impl.createElement("tbody");
+ return Document.get().createTBodyElement().cast();
}
/**
@@ -311,7 +325,7 @@
* @return the newly-created element
*/
public static Element createTD() {
- return impl.createElement("td");
+ return Document.get().createTDElement().cast();
}
/**
@@ -320,7 +334,7 @@
* @return the newly-created element
*/
public static Element createTextArea() {
- return impl.createElement("textarea");
+ return Document.get().createTextAreaElement().cast();
}
/**
@@ -329,7 +343,7 @@
* @return the newly-created element
*/
public static Element createTFoot() {
- return impl.createElement("tfoot");
+ return Document.get().createTFootElement().cast();
}
/**
@@ -338,7 +352,7 @@
* @return the newly-created element
*/
public static Element createTH() {
- return impl.createElement("th");
+ return Document.get().createTHElement().cast();
}
/**
@@ -347,7 +361,7 @@
* @return the newly-created element
*/
public static Element createTHead() {
- return impl.createElement("thead");
+ return Document.get().createTHeadElement().cast();
}
/**
@@ -356,16 +370,17 @@
* @return the newly-created element
*/
public static Element createTR() {
- return impl.createElement("tr");
+ return Document.get().createTRElement().cast();
}
/**
- * Generates a unique DOM id. The id is of the form "gwt-id-<unique integer>".
- *
+ * Generates a unique DOM id. The id is of the form "gwt-id-<unique
+ * integer>".
+ *
* @return a unique DOM id
*/
public static String createUniqueId() {
- return "gwt-id-" + nextDOMId++;
+ return Document.get().createUniqueId();
}
/**
@@ -618,7 +633,7 @@
* @return a string form of the event
*/
public static String eventToString(Event evt) {
- return impl.eventToString(evt);
+ return evt.getString();
}
/**
@@ -629,7 +644,7 @@
* @return the element's absolute left coordinate
*/
public static int getAbsoluteLeft(Element elem) {
- return impl.getAbsoluteLeft(elem);
+ return elem.getAbsoluteLeft();
}
/**
@@ -640,7 +655,7 @@
* @return the element's absolute top coordinate
*/
public static int getAbsoluteTop(Element elem) {
- return impl.getAbsoluteTop(elem);
+ return elem.getAbsoluteTop();
}
/**
@@ -654,7 +669,7 @@
*/
@Deprecated
public static String getAttribute(Element elem, String attr) {
- return getElementProperty(elem, attr);
+ return elem.getPropertyString(attr);
}
/**
@@ -668,7 +683,7 @@
*/
@Deprecated
public static boolean getBooleanAttribute(Element elem, String attr) {
- return getElementPropertyBoolean(elem, attr);
+ return elem.getPropertyBoolean(attr);
}
/**
@@ -722,7 +737,7 @@
* @return the value of the attribute
*/
public static String getElementAttribute(Element elem, String attr) {
- return impl.getElementAttribute(elem, attr);
+ return elem.getAttribute(attr);
}
/**
@@ -733,7 +748,7 @@
* @return the associated element, or <code>null</code> if none is found
*/
public static Element getElementById(String id) {
- return impl.getElementById(id);
+ return Document.get().getElementById(id).cast();
}
/**
@@ -744,7 +759,7 @@
* @return the property's value
*/
public static String getElementProperty(Element elem, String prop) {
- return impl.getElementProperty(elem, prop);
+ return elem.getPropertyString(prop);
}
/**
@@ -755,7 +770,7 @@
* @return the property's value as a boolean
*/
public static boolean getElementPropertyBoolean(Element elem, String prop) {
- return impl.getElementPropertyBoolean(elem, prop);
+ return elem.getPropertyBoolean(prop);
}
/**
@@ -766,7 +781,7 @@
* @return the property's value as an int
*/
public static int getElementPropertyInt(Element elem, String prop) {
- return impl.getElementPropertyInt(elem, prop);
+ return elem.getPropertyInt(prop);
}
/**
@@ -787,7 +802,7 @@
* @return the child element
*/
public static Element getFirstChild(Element elem) {
- return impl.getFirstChild(elem);
+ return elem.getFirstChildElement().cast();
}
/**
@@ -799,7 +814,7 @@
* @return the src url of the img
*/
public static String getImgSrc(Element img) {
- return impl.getImgSrc(img);
+ return img.<ImageElement> cast().getSrc();
}
/**
@@ -809,7 +824,7 @@
* @return the HTML representation of the element's children
*/
public static String getInnerHTML(Element elem) {
- return impl.getInnerHTML(elem);
+ return elem.getInnerHTML();
}
/**
@@ -820,7 +835,7 @@
* @return the text inside this element
*/
public static String getInnerText(Element elem) {
- return impl.getInnerText(elem);
+ return elem.getInnerText();
}
/**
@@ -834,7 +849,7 @@
*/
@Deprecated
public static int getIntAttribute(Element elem, String attr) {
- return getElementPropertyInt(elem, attr);
+ return elem.getPropertyInt(attr);
}
/**
@@ -845,7 +860,7 @@
* @return the style attribute's value as an integer
*/
public static int getIntStyleAttribute(Element elem, String attr) {
- return impl.getIntStyleAttribute(elem, attr);
+ return Integer.parseInt(elem.getStyle().getProperty(attr));
}
/**
@@ -855,7 +870,7 @@
* @return the sibling element
*/
public static Element getNextSibling(Element elem) {
- return impl.getNextSibling(elem);
+ return elem.getNextSibling().cast();
}
/**
@@ -865,7 +880,7 @@
* @return the parent element
*/
public static Element getParent(Element elem) {
- return impl.getParent(elem);
+ return elem.getParentElement().cast();
}
/**
@@ -876,7 +891,7 @@
* @return the style attribute's value
*/
public static String getStyleAttribute(Element elem, String attr) {
- return impl.getStyleAttribute(elem, attr);
+ return elem.getStyle().getProperty(attr);
}
/**
@@ -889,7 +904,7 @@
* which <code>child</code> will be inserted
*/
public static void insertBefore(Element parent, Element child, Element before) {
- impl.insertBefore(parent, child, before);
+ parent.insertBefore(child, before);
}
/**
@@ -917,9 +932,19 @@
* <code><option></code>; cannot be <code>null</code>
* @param index the index at which to insert the child
*/
- public static void insertListItem(Element select, String item, String value,
+ public static void insertListItem(Element selectElem, String item, String value,
int index) {
- impl.insertListItem(select, item, value, index);
+ SelectElement select = selectElem.<SelectElement> cast();
+ OptionElement option = Document.get().createOptionElement();
+ option.setText(item);
+ option.setValue(value);
+
+ if ((index == -1) || (index == select.getLength())) {
+ select.add(option, null);
+ } else {
+ OptionElement before = select.getOptions().getItem(index);
+ select.add(option, before);
+ }
}
/**
@@ -928,10 +953,9 @@
* @param parent the potential parent element
* @param child the potential child element
* @return <code>true</code> if the relationship holds
- * @see #compare(Element, Element)
*/
public static boolean isOrHasChild(Element parent, Element child) {
- return impl.isOrHasChild(parent, child);
+ return parent.isOrHasChild(child);
}
/**
@@ -955,7 +979,7 @@
* @param child the child element to be removed
*/
public static void removeChild(Element parent, Element child) {
- impl.removeChild(parent, child);
+ parent.removeChild(child);
}
/**
@@ -965,7 +989,7 @@
* @param attr the name of the element to remove
*/
public static void removeElementAttribute(Element elem, String attr) {
- impl.removeElementAttribute(elem, attr);
+ elem.removeAttribute(attr);
}
/**
@@ -996,7 +1020,7 @@
* @param elem the element to be made visible
*/
public static void scrollIntoView(Element elem) {
- impl.scrollIntoView(elem);
+ elem.scrollIntoView();
}
/**
@@ -1048,7 +1072,7 @@
* @param value the value to which the attribute should be set
*/
public static void setElementAttribute(Element elem, String attr, String value) {
- impl.setElementAttribute(elem, attr, value);
+ elem.setAttribute(attr, value);
}
/**
@@ -1059,7 +1083,7 @@
* @param value the new property value
*/
public static void setElementProperty(Element elem, String prop, String value) {
- impl.setElementProperty(elem, prop, value);
+ elem.setPropertyString(prop, value);
}
/**
@@ -1071,7 +1095,7 @@
*/
public static void setElementPropertyBoolean(Element elem, String prop,
boolean value) {
- impl.setElementPropertyBoolean(elem, prop, value);
+ elem.setPropertyBoolean(prop, value);
}
/**
@@ -1082,7 +1106,7 @@
* @param value the new property value as an int
*/
public static void setElementPropertyInt(Element elem, String prop, int value) {
- impl.setElementPropertyInt(elem, prop, value);
+ elem.setPropertyInt(prop, value);
}
/**
@@ -1104,7 +1128,7 @@
* @param src a non-null url for the img
*/
public static void setImgSrc(Element img, String src) {
- impl.setImgSrc(img, src);
+ img.<ImageElement> cast().setSrc(src);
}
/**
@@ -1114,7 +1138,7 @@
* @param html the new html
*/
public static void setInnerHTML(Element elem, String html) {
- impl.setInnerHTML(elem, html);
+ elem.setInnerHTML(html);
}
/**
@@ -1125,7 +1149,7 @@
* @param text the new text
*/
public static void setInnerText(Element elem, String text) {
- impl.setInnerText(elem, text);
+ elem.setInnerText(text);
}
/**
@@ -1150,7 +1174,7 @@
* @param value the style attribute's new integer value
*/
public static void setIntStyleAttribute(Element elem, String attr, int value) {
- impl.setIntStyleAttribute(elem, attr, value);
+ elem.getStyle().setProperty(attr, Integer.toString(value));
}
/**
@@ -1161,7 +1185,7 @@
* @param index the index of the option whose text should be set
*/
public static void setOptionText(Element select, String text, int index) {
- impl.setOptionText(select, text, index);
+ select.<SelectElement> cast().getOptions().getItem(index).setText(text);
}
/**
@@ -1172,7 +1196,7 @@
* @param value the style attribute's new value
*/
public static void setStyleAttribute(Element elem, String attr, String value) {
- impl.setStyleAttribute(elem, attr, value);
+ elem.getStyle().setProperty(attr, value);
}
/**
@@ -1196,11 +1220,11 @@
* @return a string form of the element
*/
public static String toString(Element elem) {
- return impl.toString(elem);
+ return elem.getString();
}
/**
- * @deprecated As of GWT 1.5, replaced by {@link Window#getClientHeight()}
+ * @deprecated As of GWT 1.5, replaced by {@link Window#getClientHeight()}
*/
@Deprecated
public static int windowGetClientHeight() {
@@ -1208,7 +1232,7 @@
}
/**
- * @deprecated As of GWT 1.5, replaced by {@link Window#getClientWidth()}
+ * @deprecated As of GWT 1.5, replaced by {@link Window#getClientWidth()}
*/
@Deprecated
public static int windowGetClientWidth() {
diff --git a/user/src/com/google/gwt/user/client/Element.java b/user/src/com/google/gwt/user/client/Element.java
index b6c5be7..54a5d33 100644
--- a/user/src/com/google/gwt/user/client/Element.java
+++ b/user/src/com/google/gwt/user/client/Element.java
@@ -15,8 +15,6 @@
*/
package com.google.gwt.user.client;
-import com.google.gwt.core.client.JavaScriptObject;
-
/**
* An opaque handle to a native DOM Element. An <code>Element</code> cannot be
* created directly. Instead, use the <code>Element</code> type when returning
@@ -26,12 +24,11 @@
* typically done by calling methods in the
* {@link com.google.gwt.user.client.DOM} class.
*/
-public final class Element extends JavaScriptObject {
+public final class Element extends com.google.gwt.dom.client.Element {
/**
- * Not directly instantiable. Subclasses should also define a protected
- * no-arg constructor to prevent client code from directly instantiating
- * the class.
+ * Not directly instantiable. Subclasses should also define a protected no-arg
+ * constructor to prevent client code from directly instantiating the class.
*/
protected Element() {
}
diff --git a/user/src/com/google/gwt/user/client/Event.java b/user/src/com/google/gwt/user/client/Event.java
index 09cf5af..01c2b86 100644
--- a/user/src/com/google/gwt/user/client/Event.java
+++ b/user/src/com/google/gwt/user/client/Event.java
@@ -1,12 +1,12 @@
/*
* Copyright 2007 Google Inc.
- *
+ *
* 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
@@ -15,6 +15,7 @@
*/
package com.google.gwt.user.client;
+import com.google.gwt.dom.client.Element;
import com.google.gwt.core.client.JavaScriptObject;
/**
@@ -148,23 +149,260 @@
* not click, dblclick, or wheel events.
*/
public static final int MOUSEEVENTS = ONMOUSEDOWN | ONMOUSEUP | ONMOUSEMOVE
- | ONMOUSEOVER | ONMOUSEOUT;
+ | ONMOUSEOVER | ONMOUSEOUT;
/**
* Error code returned by DOM.getEventXXX methods when the actual integer
- * value is undefined. For example, DOM.getEventKeyCode returns UNDEFINED
- * for some non-keyboard events.
+ * value is undefined. For example, DOM.getEventKeyCode returns UNDEFINED for
+ * some non-keyboard events.
*
* For some events, some browsers return undefined while others return data
* for certain events.
*/
public static final int UNDEFINED = -1;
-
+
/**
- * Not directly instantiable. Subclasses should also define a protected
- * no-arg constructor to prevent client code from directly instantiating
- * the class.
+ * Gets the current event that is being fired. The current event is only
+ * available within the lifetime of the onBrowserEvent function. Once the
+ * onBrowserEvent method returns, the current event is reset to null.
+ *
+ * @return the current event
+ */
+ public static Event getCurrentEvent() {
+ return DOM.eventGetCurrentEvent();
+ }
+
+ /**
+ * TODO
+ */
+ public static void sinkEvents(Element elem, int eventBits) {
+ DOM.sinkEvents((com.google.gwt.user.client.Element)elem, eventBits);
+ }
+
+ /**
+ * TODO
+ */
+ public static int getEventsSunk(Element elem) {
+ return DOM.getEventsSunk((com.google.gwt.user.client.Element)elem);
+ }
+
+ /**
+ * Not directly instantiable. Subclasses should also define a protected no-arg
+ * constructor to prevent client code from directly instantiating the class.
*/
protected Event() {
}
+
+ /**
+ * Gets the current target element of this event. This is the element whose
+ * listener fired last, not the element which fired the event initially.
+ *
+ * @return the event's current target element
+ */
+ public final Element getCurrentTarget() {
+ return DOM.eventGetCurrentTarget(this);
+ }
+
+ /**
+ * Gets the enumerated type of this event, as defined by {@link #ONCLICK},
+ * {@link #ONMOUSEDOWN}, and so forth.
+ *
+ * @return the event's enumerated type
+ */
+ public final int getTypeInt() {
+ return DOM.eventGetType(this);
+ }
+
+ /**
+ * Cancels bubbling for the given event. This will stop the event from being
+ * propagated to parent elements.
+ *
+ * @param cancel <code>true</code> to cancel bubbling
+ */
+ public final void cancelBubble(boolean cancel) {
+ DOM.eventCancelBubble(this, cancel);
+ }
+
+ /**
+ * Gets whether the ALT key was depressed when the given event occurred.
+ *
+ * @return <code>true</code> if ALT was depressed when the event occurred
+ */
+ public final boolean getAltKey() {
+ return DOM.eventGetAltKey(this);
+ }
+
+ /**
+ * Gets the mouse buttons that were depressed when the given event occurred.
+ *
+ * @return a bit-field, defined by {@link Event#BUTTON_LEFT},
+ * {@link Event#BUTTON_MIDDLE}, and {@link Event#BUTTON_RIGHT}
+ */
+ public final int getButton() {
+ return DOM.eventGetButton(this);
+ }
+
+ /**
+ * Gets the mouse x-position within the browser window's client area.
+ *
+ * @return the mouse x-position
+ */
+ public final int getClientX() {
+ return DOM.eventGetClientX(this);
+ }
+
+ /**
+ * Gets the mouse y-position within the browser window's client area.
+ *
+ * @return the mouse y-position
+ */
+ public final int getClientY() {
+ return DOM.eventGetClientY(this);
+ }
+
+ /**
+ * Gets whether the CTRL key was depressed when the given event occurred.
+ *
+ * @return <code>true</code> if CTRL was depressed when the event occurred
+ */
+ public final boolean getCtrlKey() {
+ return DOM.eventGetCtrlKey(this);
+ }
+
+ /**
+ * Gets the element from which the mouse pointer was moved (only valid for
+ * {@link Event#ONMOUSEOVER}).
+ *
+ * @return the element from which the mouse pointer was moved
+ */
+ public final Element getFromElement() {
+ return DOM.eventGetFromElement(this);
+ }
+
+ /**
+ * Gets the key code associated with this event.
+ *
+ * <p>
+ * For {@link Event#ONKEYPRESS}, this method returns the Unicode value of the
+ * character generated. For {@link Event#ONKEYDOWN} and {@link Event#ONKEYUP},
+ * it returns the code associated with the physical key.
+ * </p>
+ *
+ * @return the Unicode character or key code.
+ * @see com.google.gwt.user.client.ui.KeyboardListener
+ */
+ public final int getKeyCode() {
+ return DOM.eventGetKeyCode(this);
+ }
+
+ /**
+ * Gets whether the META key was depressed when the given event occurred.
+ *
+ * @return <code>true</code> if META was depressed when the event occurred
+ */
+ public final boolean getMetaKey() {
+ return DOM.eventGetMetaKey(this);
+ }
+
+ /**
+ * Gets the velocity of the mouse wheel associated with the event along the Y
+ * axis.
+ * <p>
+ * The velocity of the event is an artifical measurement for relative
+ * comparisons of wheel activity. It is affected by some non-browser factors,
+ * including choice of input hardware and mouse acceleration settings. The
+ * sign of the velocity measurement agrees with the screen coordinate system;
+ * negative values are towards the origin and positive values are away from
+ * the origin. Standard scrolling speed is approximately ten units per event.
+ * </p>
+ *
+ * @return The velocity of the mouse wheel.
+ */
+ public final int getMouseWheelVelocityY() {
+ return DOM.eventGetMouseWheelVelocityY(this);
+ }
+
+ /**
+ * Gets the key-repeat state of this event.
+ *
+ * @return <code>true</code> if this key event was an auto-repeat
+ */
+ public final boolean getRepeat() {
+ return DOM.eventGetRepeat(this);
+ }
+
+ /**
+ * Gets the mouse x-position on the user's display.
+ *
+ * @return the mouse x-position
+ */
+ public final int getScreenX() {
+ return DOM.eventGetScreenX(this);
+ }
+
+ /**
+ * Gets the mouse y-position on the user's display.
+ *
+ * @return the mouse y-position
+ */
+ public final int getScreenY() {
+ return DOM.eventGetScreenY(this);
+ }
+
+ /**
+ * Gets whether the shift key was depressed when the given event occurred.
+ *
+ * @return <code>true</code> if shift was depressed when the event occurred
+ */
+ public final boolean getShiftKey() {
+ return DOM.eventGetShiftKey(this);
+ }
+
+ /**
+ * Returns the element that was the actual target of the given event.
+ *
+ * @return the target element
+ */
+ public final Element getTarget() {
+ return DOM.eventGetTarget(this);
+ }
+
+ /**
+ * Gets the element to which the mouse pointer was moved (only valid for
+ * {@link Event#ONMOUSEOUT}).
+ *
+ * @return the element to which the mouse pointer was moved
+ */
+ public final Element getToElement() {
+ return DOM.eventGetToElement(this);
+ }
+
+ /**
+ * Gets the enumerated type of this event (as defined in {@link Event}).
+ *
+ * @param evt the event to be tested
+ * @return the event's enumerated type
+ */
+ public final String getType() {
+ return DOM.eventGetTypeString(this);
+ }
+
+ /**
+ * Prevents the browser from taking its default action for the given event.
+ */
+ public final void preventDefault() {
+ DOM.eventPreventDefault(this);
+ }
+
+ /**
+ * Gets a string representation of this event.
+ *
+ * We do not override {@link #toString()} because it is final in
+ * {@link JavaScriptObject}.
+ *
+ * @return the string representation of this event
+ */
+ public final String getString() {
+ return DOM.eventToString(this);
+ }
}
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImpl.java b/user/src/com/google/gwt/user/client/impl/DOMImpl.java
index e0e8c75..298b8c9 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImpl.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImpl.java
@@ -25,62 +25,34 @@
public abstract class DOMImpl {
protected static boolean eventSystemIsInitialized;
-
- public native void appendChild(Element parent, Element child) /*-{
- parent.appendChild(child);
- }-*/;
-
- public native Element clone(Element elem, boolean deep) /*-{
- return elem.cloneNode(deep);
- }-*/;
-
- public native Element createElement(String tag) /*-{
- return $doc.createElement(tag);
- }-*/;
-
- public native Element createInputElement(String type) /*-{
- var e = $doc.createElement("INPUT");
- e.type = type;
- return e;
- }-*/;
-
- public abstract Element createInputRadioElement(String name);
-
- public Element createSelectElement(boolean multiple) {
- Element select = createElement("select");
- if (multiple) {
- setElementPropertyBoolean(select, "multiple", true);
- }
- return select;
- }
public native void eventCancelBubble(Event evt, boolean cancel) /*-{
evt.cancelBubble = cancel;
- }-*/;
+ }-*/;
public native boolean eventGetAltKey(Event evt) /*-{
return !!evt.altKey;
- }-*/;
+ }-*/;
public native int eventGetButton(Event evt) /*-{
return evt.button || -1;
- }-*/;
+ }-*/;
public native int eventGetClientX(Event evt) /*-{
return evt.clientX || -1;
- }-*/;
+ }-*/;
public native int eventGetClientY(Event evt) /*-{
return evt.clientY || -1;
- }-*/;
+ }-*/;
public native boolean eventGetCtrlKey(Event evt) /*-{
return !!evt.ctrlKey;
- }-*/;
+ }-*/;
public native Element eventGetCurrentTarget(Event evt) /*-{
return evt.currentTarget;
- }-*/;
+ }-*/;
public abstract Element eventGetFromElement(Event evt);
@@ -89,29 +61,29 @@
// case, keyCode gives the right value on all browsers.
// If all else fails, return an error code
return evt.which || evt.keyCode || -1;
- }-*/;
+ }-*/;
public native boolean eventGetMetaKey(Event evt) /*-{
return !!evt.metaKey;
- }-*/;
+ }-*/;
public abstract int eventGetMouseWheelVelocityY(Event evt);
public native boolean eventGetRepeat(Event evt) /*-{
return !!evt.repeat;
- }-*/;
+ }-*/;
public native int eventGetScreenX(Event evt) /*-{
return evt.screenX || -1;
- }-*/;
+ }-*/;
public native int eventGetScreenY(Event evt) /*-{
return evt.screenY || -1;
- }-*/;
+ }-*/;
public native boolean eventGetShiftKey(Event evt) /*-{
return !!evt.shiftKey;
- }-*/;
+ }-*/;
public abstract Element eventGetTarget(Event evt);
@@ -119,282 +91,67 @@
public native String eventGetType(Event evt) /*-{
return evt.type;
- }-*/;
+ }-*/;
public native int eventGetTypeInt(Event evt) /*-{
- switch (evt.type) {
- case "blur": return 0x01000;
- case "change": return 0x00400;
- case "click": return 0x00001;
- case "dblclick": return 0x00002;
- case "focus": return 0x00800;
- case "keydown": return 0x00080;
- case "keypress": return 0x00100;
- case "keyup": return 0x00200;
- case "load": return 0x08000;
- case "losecapture": return 0x02000;
- case "mousedown": return 0x00004;
- case "mousemove": return 0x00040;
- case "mouseout": return 0x00020;
- case "mouseover": return 0x00010;
- case "mouseup": return 0x00008;
- case "scroll": return 0x04000;
- case "error": return 0x10000;
- case "mousewheel": return 0x20000;
- case "DOMMouseScroll": return 0x20000;
- }
- }-*/;
+ switch (evt.type) {
+ case "blur": return 0x01000;
+ case "change": return 0x00400;
+ case "click": return 0x00001;
+ case "dblclick": return 0x00002;
+ case "focus": return 0x00800;
+ case "keydown": return 0x00080;
+ case "keypress": return 0x00100;
+ case "keyup": return 0x00200;
+ case "load": return 0x08000;
+ case "losecapture": return 0x02000;
+ case "mousedown": return 0x00004;
+ case "mousemove": return 0x00040;
+ case "mouseout": return 0x00020;
+ case "mouseover": return 0x00010;
+ case "mouseup": return 0x00008;
+ case "scroll": return 0x04000;
+ case "error": return 0x10000;
+ case "mousewheel": return 0x20000;
+ case "DOMMouseScroll": return 0x20000;
+ }
+ }-*/;
public abstract void eventPreventDefault(Event evt);
public native void eventSetKeyCode(Event evt, char key) /*-{
- evt.keyCode = key;
- }-*/;
+ evt.keyCode = key;
+ }-*/;
public abstract String eventToString(Event evt);
- public native int getAbsoluteLeft(Element elem) /*-{
- var left = 0;
- var curr = elem;
- // This intentionally excludes body which has a null offsetParent.
- while (curr.offsetParent) {
- left -= curr.scrollLeft;
- curr = curr.parentNode;
- }
- while (elem) {
- left += elem.offsetLeft;
- elem = elem.offsetParent;
- }
- return left;
- }-*/;
-
- public native int getAbsoluteTop(Element elem) /*-{
- var top = 0;
- var curr = elem;
- // This intentionally excludes body which has a null offsetParent.
- while (curr.offsetParent) {
- top -= curr.scrollTop;
- curr = curr.parentNode;
- }
- while (elem) {
- top += elem.offsetTop;
- elem = elem.offsetParent;
- }
- return top;
- }-*/;
-
public abstract Element getChild(Element elem, int index);
public abstract int getChildCount(Element elem);
public abstract int getChildIndex(Element parent, Element child);
- public native String getElementAttribute(Element elem, String attr) /*-{
- var ret = elem.getAttribute(attr);
- return (ret == null) ? null : ret;
- }-*/;
-
- public native Element getElementById(String id) /*-{
- return $doc.getElementById(id) || null;
- }-*/;
-
- public native String getElementProperty(Element elem, String prop) /*-{
- var ret = elem[prop];
- return (ret == null) ? null : String(ret);
- }-*/;
-
- public native boolean getElementPropertyBoolean(Element elem, String prop) /*-{
- return !!elem[prop];
- }-*/;
-
- public native int getElementPropertyInt(Element elem, String prop) /*-{
- return parseInt(elem[prop]) || 0;
- }-*/;
-
public native int getEventsSunk(Element elem) /*-{
- return elem.__eventBits || 0;
- }-*/;
-
- public abstract Element getFirstChild(Element elem);
-
- public native String getImgSrc(Element img) /*-{
- return img.src;
- }-*/;
-
- public native String getInnerHTML(Element elem) /*-{
- var ret = elem.innerHTML;
- return (ret == null) ? null : ret;
- }-*/;
-
- public native String getInnerText(Element node) /*-{
- // To mimic IE's 'innerText' property in the W3C DOM, we need to recursively
- // concatenate all child text nodes (depth first).
- var text = '', child = node.firstChild;
- while (child) {
- // 1 == Element node
- if (child.nodeType == 1) {
- text += this.@com.google.gwt.user.client.impl.DOMImpl::getInnerText(Lcom/google/gwt/user/client/Element;)(child);
- } else if (child.nodeValue) {
- text += child.nodeValue;
- }
- child = child.nextSibling;
- }
- return text;
- }-*/;
-
- public native int getIntStyleAttribute(Element elem, String attr) /*-{
- return parseInt(elem.style[attr]) || 0;
- }-*/;
-
- public abstract Element getNextSibling(Element elem);
-
- public abstract Element getParent(Element elem);
-
- public native String getStyleAttribute(Element elem, String attr) /*-{
- var ret = elem.style[attr];
- return (ret == null) ? null : ret;
- }-*/;
-
- public native void insertBefore(Element parent, Element child, Element before) /*-{
- parent.insertBefore(child, before);
- }-*/;
+ return elem.__eventBits || 0;
+ }-*/;
public abstract void insertChild(Element parent, Element child, int index);
- /**
- * @see com.google.gwt.user.client.DOM#insertListItem(Element, String, String,
- * int)
- */
- public native void insertListItem(Element select, String item, String value,
- int index) /*-{
- var option = new $wnd.Option(item, value);
- if (index == -1 || index > select.options.length - 1) {
- select.add(option, null);
- } else {
- select.add(option, select.options[index]);
- }
- }-*/;
-
- public abstract boolean isOrHasChild(Element parent, Element child);
-
public abstract void releaseCapture(Element elem);
- public native void removeChild(Element parent, Element child) /*-{
- parent.removeChild(child);
- }-*/;
-
- public native void removeElementAttribute(Element elem, String attr) /*-{
- elem.removeAttribute(attr);
- }-*/;
-
- public native void scrollIntoView(Element elem) /*-{
- var left = elem.offsetLeft, top = elem.offsetTop;
- var width = elem.offsetWidth, height = elem.offsetHeight;
-
- if (elem.parentNode != elem.offsetParent) {
- left -= elem.parentNode.offsetLeft;
- top -= elem.parentNode.offsetTop;
- }
-
- var cur = elem.parentNode;
- while (cur && (cur.nodeType == 1)) {
- if (left < cur.scrollLeft) {
- cur.scrollLeft = left;
- }
- if (left + width > cur.scrollLeft + cur.clientWidth) {
- cur.scrollLeft = (left + width) - cur.clientWidth;
- }
- if (top < cur.scrollTop) {
- cur.scrollTop = top;
- }
- if (top + height > cur.scrollTop + cur.clientHeight) {
- cur.scrollTop = (top + height) - cur.clientHeight;
- }
-
- var offsetLeft = cur.offsetLeft, offsetTop = cur.offsetTop;
- if (cur.parentNode != cur.offsetParent) {
- offsetLeft -= cur.parentNode.offsetLeft;
- offsetTop -= cur.parentNode.offsetTop;
- }
-
- left += offsetLeft - cur.scrollLeft;
- top += offsetTop - cur.scrollTop;
- cur = cur.parentNode;
- }
- }-*/;
-
public abstract void setCapture(Element elem);
- public native void setElementAttribute(Element elem, String attr, String value) /*-{
- elem.setAttribute(attr, value);
- }-*/;
-
- public native void setElementProperty(Element elem, String prop, String value) /*-{
- elem[prop] = value;
- }-*/;
-
- public native void setElementPropertyBoolean(Element elem, String prop,
- boolean value) /*-{
- elem[prop] = value;
- }-*/;
-
- public native void setElementPropertyInt(Element elem, String prop, int value) /*-{
- elem[prop] = value;
- }-*/;
-
public native void setEventListener(Element elem, EventListener listener) /*-{
- elem.__listener = listener;
- }-*/;
-
- public native void setImgSrc(Element img, String src) /*-{
- img.src = src;
- }-*/;
-
- public native void setInnerHTML(Element elem, String html) /*-{
- if (!html) {
- html = '';
- }
- elem.innerHTML = html;
- }-*/;
-
- public native void setInnerText(Element elem, String text) /*-{
- // Remove all children first.
- while (elem.firstChild) {
- elem.removeChild(elem.firstChild);
- }
- // Add a new text node.
- if (text != null) {
- elem.appendChild($doc.createTextNode(text));
- }
- }-*/;
-
- public native void setIntStyleAttribute(Element elem, String attr, int value) /*-{
- elem.style[attr] = value;
- }-*/;
-
- public native void setOptionText(Element select, String text, int index) /*-{
- // IE doesn't properly update the screen when you use
- // setAttribute("option", text), so we instead directly assign to the
- // 'option' property, which works correctly on all browsers.
- var option = select.options[index];
- option.text = text;
- }-*/;
-
- public native void setStyleAttribute(Element elem, String attr, String value) /*-{
- elem.style[attr] = value;
- }-*/;
+ elem.__listener = listener;
+ }-*/;
public abstract void sinkEvents(Element elem, int eventBits);
- public native String toString(Element elem) /*-{
- return elem.outerHTML;
- }-*/;
-
/**
* Initializes the event dispatch system.
*/
protected abstract void initEventSystem();
-
+
/**
* Initialize the event system if it has not already been initialized.
*/
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImplIE6.java b/user/src/com/google/gwt/user/client/impl/DOMImplIE6.java
index dc95391..11cda6c 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImplIE6.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImplIE6.java
@@ -31,24 +31,6 @@
private static Element currentEventTarget;
@Override
- public native Element createInputRadioElement(String name) /*-{
- return $doc.createElement("<INPUT type='RADIO' name='" + name + "'>");
- }-*/;
-
- /**
- * Supports creating a select control with the multiple attribute to work
- * around a bug in IE6 where changing the multiple attribute in a setAttribute
- * call can cause subsequent setSelected calls to misbehave. Although this bug
- * is fixed in IE7, this DOMImpl specialization is used for both IE6 and IE7,
- * but it should be harmless.
- */
- @Override
- public native Element createSelectElement(boolean multiple) /*-{
- var html = multiple ? "<SELECT MULTIPLE>" : "<SELECT>";
- return $doc.createElement(html);
- }-*/;
-
- @Override
public native int eventGetClientX(Event evt) /*-{
return evt.clientX -
@com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.clientLeft;
@@ -97,20 +79,6 @@
}-*/;
@Override
- public native int getAbsoluteLeft(Element elem) /*-{
- return elem.getBoundingClientRect().left
- + @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.scrollLeft
- - @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.clientLeft;
- }-*/;
-
- @Override
- public native int getAbsoluteTop(Element elem) /*-{
- return elem.getBoundingClientRect().top
- + @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.scrollTop
- - @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.clientTop;
- }-*/;
-
- @Override
public native Element getChild(Element elem, int index) /*-{
var child = elem.children[index];
return child || null;
@@ -133,42 +101,6 @@
}-*/;
@Override
- public native Element getFirstChild(Element elem) /*-{
- var child = elem.firstChild;
- return child || null;
- }-*/;
-
- /*
- * The src may not be set yet because of funky logic in setImgSrc(). See
- * setImgSrc().
- */
- @Override
- public String getImgSrc(Element img) {
- return ImageSrcIE6.getImgSrc(img);
- }
-
- @Override
- public native String getInnerText(Element elem) /*-{
- var ret = elem.innerText;
- return (ret == null) ? null : ret;
- }-*/;
-
- @Override
- public native Element getNextSibling(Element elem) /*-{
- return elem.nextSibling || null;
- }-*/;
-
- @Override
- public native Element getParent(Element elem) /*-{
- var parent = elem.parentElement;
- return parent || null;
- }-*/;
-
- public native String iframeGetSrc(Element elem) /*-{
- return elem.src;
- }-*/;
-
- @Override
public native void initEventSystem() /*-{
// Set up event dispatchers.
$wnd.__dispatchEvent = function() {
@@ -226,26 +158,6 @@
}-*/;
@Override
- public native void insertListItem(Element select, String text, String value,
- int index) /*-{
- // When we try to pass the populated option into this method, IE
- // chokes, so we create the option here instead.
- var newOption = new Option(text, value);
- if (index == -1 || index > select.options.length - 1) {
- select.add(newOption);
- } else{
- select.add(newOption, index);
- }
- }-*/;
-
- @Override
- public native boolean isOrHasChild(Element parent, Element child) /*-{
- // An extra equality check is required due to the fact that
- // elem.contains(elem) is false if elem is not attached to the DOM.
- return (parent === child) || parent.contains(child);
- }-*/;
-
- @Override
public void releaseCapture(Element elem) {
maybeInitializeEventSystem();
releaseCaptureImpl(elem);
@@ -257,23 +169,6 @@
setCaptureImpl(elem);
}
- /**
- * Works around an IE problem where multiple images trying to load at the same
- * time will generate a request per image. We fix this by only allowing the
- * first image of a given URL to set its source immediately, but simultaneous
- * requests for the same URL don't actually get their source set until the
- * original load is complete.
- */
- @Override
- public void setImgSrc(Element img, String src) {
- ImageSrcIE6.setImgSrc(img, src);
- }
-
- @Override
- public native void setInnerText(Element elem, String text) /*-{
- elem.innerText = text || '';
- }-*/;
-
@Override
public void sinkEvents(Element elem, int bits) {
maybeInitializeEventSystem();
@@ -332,5 +227,4 @@
if (chMask & 0x20000) elem.onmousewheel = (bits & 0x20000) ?
$wnd.__dispatchEvent : null;
}-*/;
-
}
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java b/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java
index 5b9c8d3..9474037 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java
@@ -29,59 +29,6 @@
}-*/;
@Override
- public native int getAbsoluteLeft(Element elem) /*-{
- // We cannot use DOMImpl here because offsetLeft/Top return erroneous
- // values when overflow is not visible. We have to difference screenX
- // here due to a change in getBoxObjectFor which causes inconsistencies
- // on whether the calculations are inside or outside of the element's
- // border.
- try {
- return $doc.getBoxObjectFor(elem).screenX
- - $doc.getBoxObjectFor($doc.documentElement).screenX;
- } catch (e) {
- // This works around a bug in the FF3 betas. The bug
- // should be fixed before they release, so this can
- // be removed at a later date.
- // https://bugzilla.mozilla.org/show_bug.cgi?id=409111
- // DOMException.WRONG_DOCUMENT_ERR == 4
- if (e.code == 4) {
- return 0;
- }
- throw e;
- }
- }-*/;
-
- @Override
- public native int getAbsoluteTop(Element elem) /*-{
- // We cannot use DOMImpl here because offsetLeft/Top return erroneous
- // values when overflow is not visible. We have to difference screenY
- // here due to a change in getBoxObjectFor which causes inconsistencies
- // on whether the calculations are inside or outside of the element's
- // border.
- try {
- return $doc.getBoxObjectFor(elem).screenY
- - $doc.getBoxObjectFor($doc.documentElement).screenY;
- } catch (e) {
- // This works around a bug in the FF3 betas. The bug
- // should be fixed before they release, so this can
- // be removed at a later date.
- // https://bugzilla.mozilla.org/show_bug.cgi?id=409111
- // DOMException.WRONG_DOCUMENT_ERR == 4
- if (e.code == 4) {
- return 0;
- }
- throw e;
- }
- }-*/;
-
- @Override
- public native boolean isOrHasChild(Element parent, Element child) /*-{
- // For more information about compareDocumentPosition, see:
- // http://www.quirksmode.org/blog/archives/2006/01/contains_for_mo.html
- return (parent === child) || !!(parent.compareDocumentPosition(child) & 16);
- }-*/;
-
- @Override
public void sinkEvents(Element elem, int bits) {
super.sinkEvents(elem, bits);
sinkEventsMozilla(elem, bits);
@@ -94,18 +41,6 @@
}-*/;
@Override
- public native String toString(Element elem) /*-{
- // Basic idea is to use the innerHTML property by copying the node into a
- // div and getting the innerHTML
- var temp = elem.cloneNode(true);
- var tempDiv = $doc.createElement("DIV");
- tempDiv.appendChild(temp);
- outer = tempDiv.innerHTML;
- temp.innerHTML = "";
- return outer;
- }-*/;
-
- @Override
protected void initEventSystem() {
super.initEventSystem();
initSyntheticMouseUpEvents();
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImplMozillaOld.java b/user/src/com/google/gwt/user/client/impl/DOMImplMozillaOld.java
index 830a92e..cbed87e 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImplMozillaOld.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImplMozillaOld.java
@@ -15,8 +15,6 @@
*/
package com.google.gwt.user.client.impl;
-import com.google.gwt.user.client.Element;
-
/**
* DOM implementation differences for older version of Mozilla (mostly the
* hosted mode browser on linux). The main difference is due to changes in
@@ -25,43 +23,4 @@
* https://bugzilla.mozilla.org/show_bug.cgi?id=330619
*/
public class DOMImplMozillaOld extends DOMImplMozilla {
- @Override
- public native int getAbsoluteLeft(Element elem) /*-{
- var style = $doc.defaultView.getComputedStyle(elem, null);
- var left = $doc.getBoxObjectFor(elem).x - Math.round(
- style.getPropertyCSSValue('border-left-width').getFloatValue(
- CSSPrimitiveValue.CSS_PX));
-
- var parent = elem.parentNode;
- while (parent) {
- // Sometimes get NAN.
- if (parent.scrollLeft > 0) {
- left -= parent.scrollLeft;
- }
- parent = parent.parentNode;
- }
-
- return left +
- @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.scrollLeft;
- }-*/;
-
- @Override
- public native int getAbsoluteTop(Element elem) /*-{
- var style = $doc.defaultView.getComputedStyle(elem, null);
- var top = $doc.getBoxObjectFor(elem).y - Math.round(
- style.getPropertyCSSValue('border-top-width').getFloatValue(
- CSSPrimitiveValue.CSS_PX));
-
- var parent = elem.parentNode;
- while (parent) {
- // Sometimes get NAN.
- if (parent.scrollTop > 0) {
- top -= parent.scrollTop;
- }
- parent = parent.parentNode;
- }
-
- return top +
- @com.google.gwt.user.client.impl.DocumentRootImpl::documentRoot.scrollTop;
- }-*/;
}
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImplOpera.java b/user/src/com/google/gwt/user/client/impl/DOMImplOpera.java
index 6bb87ef..6abbd11 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImplOpera.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImplOpera.java
@@ -28,55 +28,12 @@
return evt.detail * 4 || -1;
}-*/;
- @Override
- public native int getAbsoluteLeft(Element elem) /*-{
- var left = 0;
- var curr = elem.parentNode;
- // This intentionally excludes body
- while (curr != $doc.body) {
-
- // see https://bugs.opera.com/show_bug.cgi?id=249965
- // The net effect is that TR and TBODY elemnts report the scroll offsets
- // of the BODY and HTML elements instead of 0.
- if (curr.tagName != 'TR' && curr.tagName != 'TBODY') {
- left -= curr.scrollLeft;
- }
- curr = curr.parentNode;
- }
-
- while (elem) {
- left += elem.offsetLeft;
- elem = elem.offsetParent;
- }
- return left;
- }-*/;
-
- @Override
- public native int getAbsoluteTop(Element elem) /*-{
- var top = 0;
-
- // This intentionally excludes body
- var curr = elem.parentNode;
- while (curr != $doc.body) {
- // see getAbsoluteLeft()
- if (curr.tagName != 'TR' && curr.tagName != 'TBODY') {
- top -= curr.scrollTop;
- }
- curr = curr.parentNode;
- }
-
- while (elem) {
- top += elem.offsetTop;
- elem = elem.offsetParent;
- }
- return top;
- }-*/;
-
/**
* As Opera sinks events very quickly, adding guards to prevent the sinking of
* events actually slows Opera down.
*/
- private native void sinkEventsImpl(Element elem, int bits) /*-{
+ @Override
+ public native void sinkEvents(Element elem, int bits) /*-{
elem.__eventBits = bits;
elem.onclick = (bits & 0x00001) ? $wnd.__dispatchEvent : null;
elem.ondblclick = (bits & 0x00002) ? $wnd.__dispatchEvent : null;
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImplSafari.java b/user/src/com/google/gwt/user/client/impl/DOMImplSafari.java
index 155e084..bbaf894 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImplSafari.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImplSafari.java
@@ -15,13 +15,13 @@
*/
package com.google.gwt.user.client.impl;
-import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
/**
* Safari implementation of {@link com.google.gwt.user.client.impl.DOMImpl}.
*/
class DOMImplSafari extends DOMImplStandard {
+
@Override
public native int eventGetClientX(Event evt) /*-{
// In Safari2: clientX is wrong and pageX is returned instead.
@@ -38,100 +38,4 @@
public native int eventGetMouseWheelVelocityY(Event evt) /*-{
return Math.round(-evt.wheelDelta / 40) || -1;
}-*/;
-
- @Override
- public native int getAbsoluteLeft(Element elem) /*-{
- // Unattached elements and elements (or their ancestors) with style
- // 'display: none' have no offsetLeft.
- if (elem.offsetLeft == null) {
- return 0;
- }
-
- var left = 0;
- var curr = elem.parentNode;
- if (curr) {
- // This intentionally excludes body which has a null offsetParent.
- while (curr.offsetParent) {
- left -= curr.scrollLeft;
- curr = curr.parentNode;
- }
- }
-
- while (elem) {
- left += elem.offsetLeft;
-
- // Safari bug: a top-level absolutely positioned element includes the
- // body's offset position already.
- var parent = elem.offsetParent;
- if (parent && (parent.tagName == 'BODY') &&
- (elem.style.position == 'absolute')) {
- break;
- }
-
- elem = parent;
- }
- return left;
- }-*/;
-
- @Override
- public native int getAbsoluteTop(Element elem) /*-{
- // Unattached elements and elements (or their ancestors) with style
- // 'display: none' have no offsetTop.
- if (elem.offsetTop == null) {
- return 0;
- }
-
- var top = 0;
- var curr = elem.parentNode;
- if (curr) {
- // This intentionally excludes body which has a null offsetParent.
- while (curr.offsetParent) {
- top -= curr.scrollTop;
- curr = curr.parentNode;
- }
- }
-
- while (elem) {
- top += elem.offsetTop;
-
- // Safari bug: a top-level absolutely positioned element includes the
- // body's offset position already.
- var parent = elem.offsetParent;
- if (parent && (parent.tagName == 'BODY') &&
- (elem.style.position == 'absolute')) {
- break;
- }
-
- elem = parent;
- }
- return top;
- }-*/;
-
- @Override
- public native void insertListItem(Element select, String text, String value,
- int index) /*-{
- // We can't use the 'options' array due to a bug in Safari.
- // Read the comment above com.google.gwt.user.client.ui.ListBox.ImplSafari
- // for more information.
- var newOption = new Option(text, value);
- if (index == -1 || index > select.children.length - 1) {
- select.appendChild(newOption);
- } else{
- select.insertBefore(newOption, select.children[index]);
- }
- }-*/;
-
- @Override
- public native boolean isOrHasChild(Element parent, Element child) /*-{
- while (child) {
- if (parent == child) {
- return true;
- }
- child = child.parentNode;
- if (child && (child.nodeType != 1)) {
- child = null;
- }
- }
- return false;
- }-*/;
}
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImplStandard.java b/user/src/com/google/gwt/user/client/impl/DOMImplStandard.java
index 82812a3..06cdafb 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImplStandard.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImplStandard.java
@@ -26,14 +26,6 @@
abstract class DOMImplStandard extends DOMImpl {
@Override
- public native Element createInputRadioElement(String name) /*-{
- var elem = $doc.createElement("INPUT");
- elem.type = 'radio';
- elem.name = name;
- return elem;
- }-*/;
-
- @Override
public native int eventGetButton(Event evt) /*-{
// Standard browsers and IE disagree on what the button codes for buttons
// should be. Translating to match IE standard.
@@ -122,37 +114,6 @@
}-*/;
@Override
- public native Element getFirstChild(Element elem) /*-{
- var child = elem.firstChild;
- while (child && child.nodeType != 1)
- child = child.nextSibling;
- return child || null;
- }-*/;
-
- @Override
- public native Element getNextSibling(Element elem) /*-{
- var sib = elem.nextSibling;
- while (sib && sib.nodeType != 1)
- sib = sib.nextSibling;
- return sib || null;
- }-*/;
-
- @Override
- public native Element getParent(Element elem) /*-{
- var parent = elem.parentNode;
- if(parent == null) {
- return null;
- }
- if (parent.nodeType != 1)
- parent = null;
- return parent || null;
- }-*/;
-
- public native String iframeGetSrc(Element elem) /*-{
- return elem.src;
- }-*/;
-
- @Override
public native void insertChild(Element parent, Element toAdd, int index) /*-{
var count = 0, child = parent.firstChild, before = null;
while (child) {
@@ -170,11 +131,6 @@
}-*/;
@Override
- public native boolean isOrHasChild(Element parent, Element child) /*-{
- return parent.contains(child);
- }-*/;
-
- @Override
public void releaseCapture(Element elem) {
maybeInitializeEventSystem();
releaseCaptureImpl(elem);
@@ -291,6 +247,5 @@
$wnd.__dispatchEvent : null;
if (chMask & 0x20000) elem.onmousewheel = (bits & 0x20000) ?
$wnd.__dispatchEvent : null;
-
}-*/;
}
diff --git a/user/src/com/google/gwt/user/client/ui/UIObject.java b/user/src/com/google/gwt/user/client/ui/UIObject.java
index 6d395a2..617b213 100644
--- a/user/src/com/google/gwt/user/client/ui/UIObject.java
+++ b/user/src/com/google/gwt/user/client/ui/UIObject.java
@@ -17,7 +17,7 @@
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Element;
+import com.google.gwt.dom.client.Element;
/**
* The superclass for all user-interface objects. It simply wraps a DOM element,
@@ -140,7 +140,8 @@
protected static void ensureDebugId(Element elem, String baseID, String id) {
assert baseID != null;
baseID = (baseID.length() > 0) ? baseID + "-" : "";
- DOM.setElementProperty(elem, "id", DEBUG_ID_PREFIX + baseID + id);
+ DOM.setElementProperty(elem.<com.google.gwt.user.client.Element> cast(),
+ "id", DEBUG_ID_PREFIX + baseID + id);
}
/**
@@ -150,7 +151,8 @@
* @return the objects's space-separated style names
*/
protected static String getStyleName(Element elem) {
- return DOM.getElementProperty(elem, "className");
+ return DOM.getElementProperty(
+ elem.<com.google.gwt.user.client.Element> cast(), "className");
}
/**
@@ -179,7 +181,8 @@
* @param styleName the new style name
*/
protected static void setStyleName(Element elem, String styleName) {
- DOM.setElementProperty(elem, "className", styleName);
+ DOM.setElementProperty(elem.<com.google.gwt.user.client.Element> cast(),
+ "className", styleName);
}
/**
@@ -227,7 +230,9 @@
if (oldStyle.length() > 0) {
oldStyle += " ";
}
- DOM.setElementProperty(elem, "className", oldStyle + style);
+ DOM.setElementProperty(
+ elem.<com.google.gwt.user.client.Element> cast(), "className",
+ oldStyle + style);
}
} else {
// Don't try to remove the style if it's not there.
@@ -246,7 +251,9 @@
newClassName = begin + " " + end;
}
- DOM.setElementProperty(elem, "className", newClassName);
+ DOM.setElementProperty(
+ elem.<com.google.gwt.user.client.Element> cast(), "className",
+ newClassName);
}
}
}
@@ -452,13 +459,14 @@
* This method should not be overridden. It is non-final solely to support
* legacy code that depends upon overriding it. If it is overridden, the
* subclass implementation must not return a different element than was
- * previously set using {@link #setElement(Element)}.
+ * previously set using
+ * {@link #setElement(com.google.gwt.user.client.Element)}.
*
* @return the object's browser element
*/
- public Element getElement() {
+ public com.google.gwt.user.client.Element getElement() {
assert (element != null) : MISSING_ELEMENT_ERROR;
- return element;
+ return (com.google.gwt.user.client.Element)element;
}
/**
@@ -733,7 +741,21 @@
*
* @param elem the object's element
*/
- protected void setElement(Element elem) {
+ protected final void setElement(Element elem) {
+ setElement((com.google.gwt.user.client.Element)elem);
+ }
+
+ /**
+ * Sets this object's browser element. UIObject subclasses must call this
+ * method before attempting to call any other methods, and it may only be
+ * called once.
+ *
+ * This method exists for backwards compatibility with pre-1.5 code.
+ * As of GWT 1.5, {@link #setElement(Element)} is the preferred method.
+ *
+ * @param elem the object's element
+ */
+ protected void setElement(com.google.gwt.user.client.Element elem) {
assert (element == null) : SETELEMENT_TWICE_ERROR;
this.element = elem;
}
diff --git a/user/src/com/google/gwt/user/client/ui/Widget.java b/user/src/com/google/gwt/user/client/ui/Widget.java
index 054237c..597a712 100644
--- a/user/src/com/google/gwt/user/client/ui/Widget.java
+++ b/user/src/com/google/gwt/user/client/ui/Widget.java
@@ -16,7 +16,6 @@
package com.google.gwt.user.client.ui;
import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.EventListener;
@@ -175,7 +174,7 @@
}
@Override
- void replaceElement(Element elem) {
+ void replaceElement(com.google.gwt.dom.client.Element elem) {
if (isAttached()) {
// Remove old event listener to avoid leaking. onDetach will not do this
// for us, because it is only called when the widget itself is detached
@@ -184,11 +183,12 @@
}
super.replaceElement(elem);
+
if (isAttached()) {
// Hook the event listener back up on the new element. onAttach will not
// do this for us, because it is only called when the widget itself is
// attached to the document.
- DOM.setEventListener(elem, this);
+ DOM.setEventListener(getElement(), this);
}
}
diff --git a/user/test/com/google/gwt/dom/DOMSuite.java b/user/test/com/google/gwt/dom/DOMSuite.java
new file mode 100644
index 0000000..54d66ab
--- /dev/null
+++ b/user/test/com/google/gwt/dom/DOMSuite.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom;
+
+import junit.framework.Test;
+
+import com.google.gwt.dom.client.DocumentTest;
+import com.google.gwt.dom.client.ElementTest;
+import com.google.gwt.dom.client.FormTests;
+import com.google.gwt.dom.client.MapTests;
+import com.google.gwt.dom.client.NodeTest;
+import com.google.gwt.dom.client.SelectTests;
+import com.google.gwt.dom.client.TableTests;
+import com.google.gwt.junit.tools.GWTTestSuite;
+
+public class DOMSuite {
+ public static Test suite() {
+ GWTTestSuite suite = new GWTTestSuite(
+ "Test for suite for the com.google.gwt.dom module");
+
+ suite.addTestSuite(DocumentTest.class);
+ suite.addTestSuite(NodeTest.class);
+ suite.addTestSuite(ElementTest.class);
+ suite.addTestSuite(FormTests.class);
+ suite.addTestSuite(MapTests.class);
+ suite.addTestSuite(SelectTests.class);
+ suite.addTestSuite(TableTests.class);
+
+ return suite;
+ }
+}
diff --git a/user/test/com/google/gwt/dom/DOMTest.gwt.xml b/user/test/com/google/gwt/dom/DOMTest.gwt.xml
new file mode 100644
index 0000000..d503c7c
--- /dev/null
+++ b/user/test/com/google/gwt/dom/DOMTest.gwt.xml
@@ -0,0 +1,16 @@
+<!-- -->
+<!-- Copyright 2008 Google Inc. -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
+<!-- may not use this file except in compliance with the License. You may -->
+<!-- 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. License for the specific language governing permissions and -->
+<!-- limitations under the License. -->
+<module>
+ <inherits name="com.google.gwt.dom.DOM"/>
+</module>
diff --git a/user/test/com/google/gwt/dom/client/DocumentTest.java b/user/test/com/google/gwt/dom/client/DocumentTest.java
new file mode 100644
index 0000000..6d10b86
--- /dev/null
+++ b/user/test/com/google/gwt/dom/client/DocumentTest.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Tests the {@link Document} class.
+ */
+public class DocumentTest extends GWTTestCase {
+
+ @Override
+ public String getModuleName() {
+ return "com.google.gwt.dom.DOMTest";
+ }
+
+ // create*Element
+ public void testElementCreators() {
+ Document doc = Document.get();
+
+ assertEquals("a", doc.createAnchorElement().getTagName().toLowerCase());
+ assertEquals("area", doc.createAreaElement().getTagName().toLowerCase());
+ assertEquals("base", doc.createBaseElement().getTagName().toLowerCase());
+ assertEquals("blockquote",
+ doc.createBlockQuoteElement().getTagName().toLowerCase());
+ assertEquals("br", doc.createBRElement().getTagName().toLowerCase());
+ assertEquals("button", doc.createButtonElement().getTagName().toLowerCase());
+ assertEquals("caption",
+ doc.createCaptionElement().getTagName().toLowerCase());
+ assertEquals("col", doc.createColElement().getTagName().toLowerCase());
+ assertEquals("colgroup",
+ doc.createColGroupElement().getTagName().toLowerCase());
+ assertEquals("del", doc.createDelElement().getTagName().toLowerCase());
+ assertEquals("div", doc.createDivElement().getTagName().toLowerCase());
+ assertEquals("dl", doc.createDLElement().getTagName().toLowerCase());
+ assertEquals("fieldset",
+ doc.createFieldSetElement().getTagName().toLowerCase());
+ assertEquals("form", doc.createFormElement().getTagName().toLowerCase());
+ assertEquals("frame", doc.createFrameElement().getTagName().toLowerCase());
+ assertEquals("frameset",
+ doc.createFrameSetElement().getTagName().toLowerCase());
+ assertEquals("head", doc.createHeadElement().getTagName().toLowerCase());
+ assertEquals("h1", doc.createHElement(1).getTagName().toLowerCase());
+ assertEquals("hr", doc.createHRElement().getTagName().toLowerCase());
+ assertEquals("iframe", doc.createIFrameElement().getTagName().toLowerCase());
+ assertEquals("img", doc.createImageElement().getTagName().toLowerCase());
+ assertEquals("ins", doc.createInsElement().getTagName().toLowerCase());
+ assertEquals("label", doc.createLabelElement().getTagName().toLowerCase());
+ assertEquals("legend", doc.createLegendElement().getTagName().toLowerCase());
+ assertEquals("li", doc.createLIElement().getTagName().toLowerCase());
+ assertEquals("link", doc.createLinkElement().getTagName().toLowerCase());
+ assertEquals("map", doc.createMapElement().getTagName().toLowerCase());
+ assertEquals("meta", doc.createMetaElement().getTagName().toLowerCase());
+ assertEquals("object", doc.createObjectElement().getTagName().toLowerCase());
+ assertEquals("ol", doc.createOLElement().getTagName().toLowerCase());
+ assertEquals("optgroup",
+ doc.createOptGroupElement().getTagName().toLowerCase());
+ assertEquals("option", doc.createOptionElement().getTagName().toLowerCase());
+ assertEquals("param", doc.createParamElement().getTagName().toLowerCase());
+ assertEquals("p", doc.createPElement().getTagName().toLowerCase());
+ assertEquals("pre", doc.createPreElement().getTagName().toLowerCase());
+ assertEquals("q", doc.createQElement().getTagName().toLowerCase());
+ assertEquals("script", doc.createScriptElement().getTagName().toLowerCase());
+ assertEquals("select", doc.createSelectElement().getTagName().toLowerCase());
+ assertEquals("select",
+ doc.createSelectElement(false).getTagName().toLowerCase());
+ assertEquals("span", doc.createSpanElement().getTagName().toLowerCase());
+ assertEquals("style", doc.createStyleElement().getTagName().toLowerCase());
+ assertEquals("table", doc.createTableElement().getTagName().toLowerCase());
+ assertEquals("tbody", doc.createTBodyElement().getTagName().toLowerCase());
+ assertEquals("td", doc.createTDElement().getTagName().toLowerCase());
+ assertEquals("textarea",
+ doc.createTextAreaElement().getTagName().toLowerCase());
+ assertEquals("tfoot", doc.createTFootElement().getTagName().toLowerCase());
+ assertEquals("thead", doc.createTHeadElement().getTagName().toLowerCase());
+ assertEquals("th", doc.createTHElement().getTagName().toLowerCase());
+ assertEquals("title", doc.createTitleElement().getTagName().toLowerCase());
+ assertEquals("tr", doc.createTRElement().getTagName().toLowerCase());
+ assertEquals("ul", doc.createULElement().getTagName().toLowerCase());
+
+ assertEquals("input",
+ doc.createCheckInputElement().getTagName().toLowerCase());
+ assertEquals("input",
+ doc.createFileInputElement().getTagName().toLowerCase());
+ assertEquals("input",
+ doc.createHiddenInputElement().getTagName().toLowerCase());
+ assertEquals("input",
+ doc.createImageInputElement().getTagName().toLowerCase());
+ assertEquals("input",
+ doc.createPasswordInputElement().getTagName().toLowerCase());
+ assertEquals("input",
+ doc.createRadioInputElement("foo").getTagName().toLowerCase());
+ assertEquals("input",
+ doc.createTextInputElement().getTagName().toLowerCase());
+
+ assertEquals("checkbox",
+ doc.createCheckInputElement().getType().toLowerCase());
+ assertEquals("file", doc.createFileInputElement().getType().toLowerCase());
+ assertEquals("hidden",
+ doc.createHiddenInputElement().getType().toLowerCase());
+ assertEquals("image", doc.createImageInputElement().getType().toLowerCase());
+ assertEquals("password",
+ doc.createPasswordInputElement().getType().toLowerCase());
+ assertEquals("radio",
+ doc.createRadioInputElement("foo").getType().toLowerCase());
+ assertEquals("text", doc.createTextInputElement().getType().toLowerCase());
+ }
+
+ /**
+ * getElementById, getElementsByTagName
+ */
+ public void testGetElements() {
+ Document doc = Document.get();
+
+ DivElement div = doc.createDivElement();
+ doc.getBody().appendChild(div);
+
+ div.setInnerHTML("<span><button id='foo'>foo</button><span><button>bar</button></span></span>");
+
+ NodeList<Element> nodes = doc.getElementsByTagName("button");
+ assertEquals(2, nodes.getLength());
+ assertEquals("foo", nodes.getItem(0).getInnerText());
+ assertEquals("bar", nodes.getItem(1).getInnerText());
+
+ Element foo = doc.getElementById("foo");
+ assertEquals("foo", foo.getId());
+ }
+
+ /**
+ * domain, referrer, title, url
+ */
+ public void testProperties() {
+ Document doc = Document.get();
+
+ assertTrue(doc.getURL().startsWith("http"));
+ // TODO: referrer
+ // TODO: domain
+
+ doc.setTitle("myTitle");
+ assertEquals("myTitle", doc.getTitle());
+ }
+}
diff --git a/user/test/com/google/gwt/dom/client/ElementTest.java b/user/test/com/google/gwt/dom/client/ElementTest.java
new file mode 100644
index 0000000..f218d39
--- /dev/null
+++ b/user/test/com/google/gwt/dom/client/ElementTest.java
@@ -0,0 +1,307 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+import com.google.gwt.junit.client.GWTTestCase;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.DeferredCommand;
+
+/**
+ * Element tests (many stolen from DOMTest).
+ */
+public class ElementTest extends GWTTestCase {
+
+ @Override
+ public String getModuleName() {
+ return "com.google.gwt.dom.DOMTest";
+ }
+
+ /**
+ * [get|set|remove]Attribute
+ */
+ public void testElementAttribute() {
+ DivElement div = Document.get().createDivElement();
+ div.setAttribute("class", "testClass");
+ String cssClass = div.getAttribute("class");
+ assertEquals("testClass", cssClass);
+ div.removeAttribute("class");
+ cssClass = div.getAttribute("class");
+ assertNull(cssClass);
+ }
+
+ /**
+ * getAbsolute[Left|Top]
+ */
+ public void testGetAbsolutePosition() {
+ final int border = 8;
+ final int margin = 9;
+ final int padding = 10;
+
+ final int top = 15;
+ final int left = 14;
+
+ Document doc = Document.get();
+ final DivElement elem = doc.createDivElement();
+ doc.getBody().appendChild(elem);
+
+ elem.getStyle().setProperty("position", "absolute");
+ elem.getStyle().setProperty("border", border + "px solid #000");
+ elem.getStyle().setProperty("padding", padding + "px");
+ elem.getStyle().setProperty("margin", margin + "px");
+
+ elem.getStyle().setProperty("top", top + "px");
+ elem.getStyle().setProperty("left", left + "px");
+
+ delayTestFinish(1000);
+ DeferredCommand.addCommand(new Command() {
+ public void execute() {
+ assertEquals(top + margin, elem.getAbsoluteTop());
+ assertEquals(left + margin, elem.getAbsoluteLeft());
+ finishTest();
+ }
+ });
+ }
+
+ /**
+ * scroll[Left|Top], scrollIntoView
+ */
+ public void testGetAbsolutePositionWhenScrolled() {
+ final DivElement outer = Document.get().createDivElement();
+ final DivElement inner = Document.get().createDivElement();
+
+ outer.getStyle().setProperty("position", "absolute");
+ outer.getStyle().setProperty("top", "0px");
+ outer.getStyle().setProperty("left", "0px");
+ outer.getStyle().setProperty("overflow", "auto");
+ outer.getStyle().setProperty("width", "200px");
+ outer.getStyle().setProperty("height", "200px");
+
+ inner.getStyle().setProperty("marginTop", "800px");
+ inner.getStyle().setProperty("marginLeft", "800px");
+
+ outer.appendChild(inner);
+ Document.get().getBody().appendChild(outer);
+ inner.setInnerText(":-)");
+ inner.scrollIntoView();
+
+ // Ensure that we are scrolled.
+ assertTrue(outer.getScrollTop() > 0);
+ assertTrue(outer.getScrollLeft() > 0);
+
+ outer.setScrollLeft(0);
+ outer.setScrollTop(0);
+
+ // Ensure that we are no longer scrolled.
+ assertEquals(outer.getScrollTop(), 0);
+ assertEquals(outer.getScrollLeft(), 0);
+ }
+
+ /**
+ * getParentElement
+ */
+ public void testGetParent() {
+ Element element = Document.get().getBody();
+ int i = 0;
+ while (i < 10 && element != null) {
+ element = element.getParentElement();
+ i++;
+ }
+
+ // If we got here we looped "forever" or passed, as no exception was thrown.
+ if (i == 10) {
+ fail("Cyclic parent structure detected.");
+ }
+
+ // If we get here, we pass, because we encountered no errors going to the
+ // top of the parent hierarchy.
+ }
+
+ /**
+ * firstChildElement, nextSiblingElement
+ */
+ public void testChildElements() {
+ Document doc = Document.get();
+ DivElement parent = doc.createDivElement();
+ DivElement div0 = doc.createDivElement();
+ DivElement div1 = doc.createDivElement();
+
+ parent.appendChild(doc.createTextNode("foo"));
+ parent.appendChild(div0);
+ parent.appendChild(doc.createTextNode("bar"));
+ parent.appendChild(div1);
+
+ Element fc = parent.getFirstChildElement();
+ Element ns = fc.getNextSiblingElement();
+ assertEquals(div0, fc);
+ assertEquals(div1, ns);
+ }
+
+ /**
+ * isOrHasChild
+ */
+ public void testIsOrHasChild() {
+ DivElement div = Document.get().createDivElement();
+ DivElement childDiv = Document.get().createDivElement();
+
+ assertFalse(div.isOrHasChild(childDiv));
+ assertTrue(div.isOrHasChild(div));
+
+ div.appendChild(childDiv);
+ assertTrue(div.isOrHasChild(childDiv));
+ assertFalse(childDiv.isOrHasChild(div));
+
+ Document.get().getBody().appendChild(div);
+ assertTrue(div.isOrHasChild(childDiv));
+ assertTrue(div.isOrHasChild(div));
+ assertFalse(childDiv.isOrHasChild(div));
+ }
+
+ /**
+ * innerText
+ */
+ public void testSetInnerText() {
+ Document doc = Document.get();
+
+ TableElement tableElem = doc.createTableElement();
+ TableRowElement trElem = doc.createTRElement();
+ TableCellElement tdElem = doc.createTDElement();
+ tdElem.setInnerText("Some Table Heading Data");
+
+ // Add a <em> element as a child to the td element
+ Element emElem = doc.createElement("em");
+ emElem.setInnerText("Some emphasized text");
+ tdElem.appendChild(emElem);
+
+ trElem.appendChild(tdElem);
+ tableElem.appendChild(trElem);
+ doc.getBody().appendChild(tableElem);
+ tdElem.setInnerText(null);
+
+ // Once we set the inner text on an element to null, all of the element's
+ // child nodes should be deleted, including any text nodes, for all
+ // supported browsers.
+ assertTrue(tdElem.getChildNodes().getLength() == 0);
+ }
+
+ /**
+ * innerHTML
+ */
+ public void testSetInnerHTML() {
+ DivElement div = Document.get().createDivElement();
+ div.setInnerHTML("<button><img src='foo.gif'></button>");
+
+ Element button = div.getFirstChildElement();
+ Element img = button.getFirstChildElement();
+
+ assertEquals("button", button.getTagName().toLowerCase());
+ assertEquals("img", img.getTagName().toLowerCase());
+ assertTrue(((ImageElement) img).getSrc().endsWith("foo.gif"));
+ }
+
+ /**
+ * setProperty*, getProperty*
+ */
+ public void testProperties() {
+ DivElement div = Document.get().createDivElement();
+
+ div.setPropertyString("foo", "bar");
+ assertEquals("bar", div.getPropertyString("foo"));
+
+ div.setPropertyInt("foo", 42);
+ assertEquals(42, div.getPropertyInt("foo"));
+
+ div.setPropertyBoolean("foo", true);
+ div.setPropertyBoolean("bar", false);
+ assertEquals(true, div.getPropertyBoolean("foo"));
+ assertEquals(false, div.getPropertyBoolean("bar"));
+ }
+
+ /**
+ * className, id, tagName, title, dir, lang
+ */
+ public void testNativeProperties() {
+ DivElement div = Document.get().createDivElement();
+
+ assertEquals("div", div.getTagName().toLowerCase());
+
+ div.setClassName("myClass");
+ assertEquals(div.getClassName(), "myClass");
+
+ div.setId("myId");
+ assertEquals(div.getId(), "myId");
+
+ div.setTitle("myTitle");
+ assertEquals(div.getTitle(), "myTitle");
+
+ div.setDir("rtl");
+ assertEquals(div.getDir(), "rtl");
+
+ div.setLang("fr-FR");
+ assertEquals(div.getLang(), "fr-FR");
+ }
+
+ /**
+ * style
+ */
+ public void testStyle() {
+ DivElement div = Document.get().createDivElement();
+
+ div.getStyle().setProperty("color", "black");
+ assertEquals("black", div.getStyle().getProperty("color"));
+
+ div.getStyle().setPropertyPx("width", 42);
+ assertEquals("42px", div.getStyle().getProperty("width"));
+ }
+
+ /**
+ * offset[Left|Top|Width|Height], offsetParent
+ */
+ public void testOffsets() {
+ DivElement outer = Document.get().createDivElement();
+ DivElement middle = Document.get().createDivElement();
+ DivElement inner = Document.get().createDivElement();
+
+ Document.get().getBody().appendChild(outer);
+ outer.appendChild(middle);
+ middle.appendChild(inner);
+
+ outer.getStyle().setProperty("position", "absolute");
+ inner.getStyle().setProperty("position", "relative");
+ inner.getStyle().setPropertyPx("left", 19);
+ inner.getStyle().setPropertyPx("top", 23);
+ inner.getStyle().setPropertyPx("width", 29);
+ inner.getStyle().setPropertyPx("height", 31);
+
+ assertEquals(outer, inner.getOffsetParent());
+ assertEquals(19, inner.getOffsetLeft());
+ assertEquals(23, inner.getOffsetTop());
+ assertEquals(29, inner.getOffsetWidth());
+ assertEquals(31, inner.getOffsetHeight());
+ }
+
+ /**
+ * getElementsByTagName
+ */
+ public void testGetElementsByTagName() {
+ DivElement div = Document.get().createDivElement();
+ div.setInnerHTML("<span><button>foo</button><span><button>bar</button></span></span>");
+
+ NodeList<Element> nodes = div.getElementsByTagName("button");
+ assertEquals(2, nodes.getLength());
+ assertEquals("foo", nodes.getItem(0).getInnerText());
+ assertEquals("bar", nodes.getItem(1).getInnerText());
+ }
+}
diff --git a/user/test/com/google/gwt/dom/client/FormTests.java b/user/test/com/google/gwt/dom/client/FormTests.java
new file mode 100644
index 0000000..6b7cfcd
--- /dev/null
+++ b/user/test/com/google/gwt/dom/client/FormTests.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Tests the {@link FormElement} and {@link InputElement} classes.
+ */
+public class FormTests extends GWTTestCase {
+
+ @Override
+ public String getModuleName() {
+ return "com.google.gwt.dom.DOMTest";
+ }
+
+ /**
+ * getElements
+ */
+ public void testGetElements() {
+ Document doc = Document.get();
+ FormElement form = doc.createFormElement();
+ form.setInnerHTML("<div>" + "<input name='text' id='text' type='text'>"
+ + "<input name='hidden' id='hidden' type='hidden'>"
+ + "<textarea name='textarea' id='textarea'>" + "</div>");
+
+ NodeCollection<Element> formElems = form.getElements();
+ assertEquals(3, formElems.getLength());
+
+ assertEquals("text", formElems.getItem(0).getId());
+ assertEquals("hidden", formElems.getItem(1).getId());
+ assertEquals("textarea", formElems.getItem(2).getId());
+
+ assertEquals("text", formElems.getNamedItem("text").getId());
+ assertEquals("hidden", formElems.getNamedItem("hidden").getId());
+ assertEquals("textarea", formElems.getNamedItem("textarea").getId());
+ }
+}
diff --git a/user/test/com/google/gwt/dom/client/MapTests.java b/user/test/com/google/gwt/dom/client/MapTests.java
new file mode 100644
index 0000000..4cb130d
--- /dev/null
+++ b/user/test/com/google/gwt/dom/client/MapTests.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Tests the {@link MapElement} and {@link AreaElement} classes.
+ */
+public class MapTests extends GWTTestCase {
+
+ @Override
+ public String getModuleName() {
+ return "com.google.gwt.dom.DOMTest";
+ }
+
+ /**
+ * getAreas
+ */
+ public void testGetArea() {
+ Document doc = Document.get();
+ MapElement map = doc.createMapElement();
+ AreaElement area0 = doc.createAreaElement();
+ AreaElement area1 = doc.createAreaElement();
+ AreaElement area2 = doc.createAreaElement();
+
+ map.appendChild(area0);
+ map.appendChild(area1);
+ map.appendChild(area2);
+
+ NodeList<AreaElement> areaElems = map.getAreas();
+ assertEquals(3, areaElems.getLength());
+
+ assertEquals(area0, areaElems.getItem(0));
+ assertEquals(area1, areaElems.getItem(1));
+ assertEquals(area2, areaElems.getItem(2));
+ }
+}
diff --git a/user/test/com/google/gwt/dom/client/NodeTest.java b/user/test/com/google/gwt/dom/client/NodeTest.java
new file mode 100644
index 0000000..3aa2c5b
--- /dev/null
+++ b/user/test/com/google/gwt/dom/client/NodeTest.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Tests the {@link Node} class.
+ */
+public class NodeTest extends GWTTestCase {
+
+ @Override
+ public String getModuleName() {
+ return "com.google.gwt.dom.DOMTest";
+ }
+
+ /**
+ * nodeType
+ */
+ public void testNodeType() {
+ Document doc = Document.get();
+ DivElement div = doc.createDivElement();
+ Text txt0 = doc.createTextNode("foo");
+
+ assertEquals(Node.DOCUMENT_NODE, doc.getNodeType());
+ assertEquals(Node.ELEMENT_NODE, div.getNodeType());
+ assertEquals(Node.TEXT_NODE, txt0.getNodeType());
+ }
+
+ /**
+ * nodeName, nodeValue
+ */
+ public void testNodeNameAndValue() {
+ Document doc = Document.get();
+ DivElement div = doc.createDivElement();
+ Text txt0 = doc.createTextNode("foo");
+
+ assertEquals("div", div.getNodeName().toLowerCase());
+
+ assertEquals("foo", txt0.getNodeValue());
+ txt0.setNodeValue("bar");
+ assertEquals("bar", txt0.getNodeValue());
+ }
+
+ /**
+ * setAttribute, getAttribute, hasAttributes, hasAttribute
+ */
+ public void testAttributes() {
+ Document doc = Document.get();
+ DivElement div = doc.createDivElement();
+
+ div.setAttribute("id", "myId");
+ assertEquals("myId", div.getAttribute("id"));
+ }
+
+ /**
+ * getParentNode, firstChild, lastChild, nextSibling, previousSibling
+ */
+ public void testParentAndSiblings() {
+ Document doc = Document.get();
+ BodyElement body = doc.getBody();
+
+ // <div>foo<button/>bar</div>
+ DivElement div = doc.createDivElement();
+ Text txt0 = doc.createTextNode("foo");
+ ButtonElement btn0 = doc.createButtonElement();
+ Text txt1 = doc.createTextNode("bar");
+
+ body.appendChild(div);
+ div.appendChild(txt0);
+ div.appendChild(btn0);
+ div.appendChild(txt1);
+
+ assertEquals(div, btn0.getParentNode());
+
+ assertEquals(txt0, div.getFirstChild());
+ assertEquals(txt1, div.getLastChild());
+ assertEquals(btn0, txt0.getNextSibling());
+ assertEquals(btn0, txt1.getPreviousSibling());
+ assertEquals(null, txt0.getPreviousSibling());
+ assertEquals(null, txt1.getNextSibling());
+ }
+
+ /**
+ * ownerDocument
+ */
+ public void testOwnerDocument() {
+ Document doc = Document.get();
+ BodyElement body = doc.getBody();
+
+ // <div>foo<button/>bar</div>
+ DivElement div = doc.createDivElement();
+ Text txt0 = doc.createTextNode("foo");
+ ButtonElement btn0 = doc.createButtonElement();
+ Text txt1 = doc.createTextNode("bar");
+
+ body.appendChild(div);
+ div.appendChild(txt0);
+ div.appendChild(btn0);
+ div.appendChild(txt1);
+
+ // ownerDocument
+ assertEquals(doc, div.getOwnerDocument());
+ assertEquals(doc, txt0.getOwnerDocument());
+ }
+
+ /**
+ * childNodes, hasChildNodes
+ */
+ public void testChildNodeList() {
+ Document doc = Document.get();
+ BodyElement body = doc.getBody();
+
+ // <div>foo<button/>bar</div>
+ DivElement div = doc.createDivElement();
+ Text txt0 = doc.createTextNode("foo");
+ ButtonElement btn0 = doc.createButtonElement();
+ Text txt1 = doc.createTextNode("bar");
+
+ body.appendChild(div);
+ div.appendChild(txt0);
+ div.appendChild(btn0);
+ div.appendChild(txt1);
+
+ NodeList<Node> children = div.getChildNodes();
+ assertEquals(3, children.getLength());
+ assertEquals(txt0, children.getItem(0));
+ assertEquals(btn0, children.getItem(1));
+ assertEquals(txt1, children.getItem(2));
+
+ assertFalse(txt0.hasChildNodes());
+ assertTrue(div.hasChildNodes());
+ }
+
+ /**
+ * appendChild, insertBefore, removeChild, replaceChild
+ */
+ public void testAppendRemoveReplace() {
+ Document doc = Document.get();
+ BodyElement body = doc.getBody();
+
+ // <div>foo<button/>bar</div>
+ DivElement div = doc.createDivElement();
+ Text txt0 = doc.createTextNode("foo");
+ ButtonElement btn0 = doc.createButtonElement();
+ Text txt1 = doc.createTextNode("bar");
+
+ body.appendChild(div);
+ div.appendChild(txt0);
+ div.appendChild(btn0);
+ div.appendChild(txt1);
+
+ // appendChild, insertBefore
+ ButtonElement btn1 = doc.createButtonElement();
+
+ // <div>foo<button/>bar<button/></div>
+ div.appendChild(btn1);
+ assertEquals(btn1, div.getLastChild());
+
+ // <div>foo<button/><button/>bar</div>
+ div.insertBefore(btn1, txt1);
+ assertEquals(4, div.getChildNodes().getLength());
+ assertEquals(btn1, div.getChildNodes().getItem(2));
+
+ // removeChild
+ // <div>foo<button/>bar</div> (back to original)
+ div.removeChild(btn1);
+ assertEquals(3, div.getChildNodes().getLength());
+
+ // replaceChild
+ div.replaceChild(btn1, btn0);
+ assertEquals(btn1, txt0.getNextSibling());
+ assertEquals(btn1, txt1.getPreviousSibling());
+ }
+}
diff --git a/user/test/com/google/gwt/dom/client/SelectTests.java b/user/test/com/google/gwt/dom/client/SelectTests.java
new file mode 100644
index 0000000..d8bfc6c
--- /dev/null
+++ b/user/test/com/google/gwt/dom/client/SelectTests.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Tests the {@link SelectElement} and {@link OptionElement} classes.
+ */
+public class SelectTests extends GWTTestCase {
+
+ @Override
+ public String getModuleName() {
+ return "com.google.gwt.dom.DOMTest";
+ }
+
+ /**
+ * add, remove
+ */
+ public void testAddRemove() {
+ Document doc = Document.get();
+ SelectElement select = doc.createSelectElement();
+ doc.getBody().appendChild(select);
+
+ OptionElement opt0 = doc.createOptionElement();
+ OptionElement opt1 = doc.createOptionElement();
+ OptionElement opt2 = doc.createOptionElement();
+ opt0.setText("foo");
+ opt1.setText("bar");
+ opt2.setText("baz");
+ opt0.setValue("0");
+ opt1.setValue("1");
+ opt2.setValue("2");
+
+ select.appendChild(opt0);
+ select.appendChild(opt1);
+ select.appendChild(opt2);
+
+ assertEquals("3 options expected", 3, select.getOptions().getLength());
+ assertEquals("[0] == opt0", opt0, select.getOptions().getItem(0));
+ assertEquals("[1] == opt1", opt1, select.getOptions().getItem(1));
+ assertEquals("[2] == opt2", opt2, select.getOptions().getItem(2));
+
+ select.remove(1);
+ assertNull("null parent expected when removed", opt1.getParentElement());
+
+ select.add(opt1, opt0);
+ assertEquals("[0] == opt1", opt1, select.getOptions().getItem(0));
+ assertEquals("[1] == opt0", opt0, select.getOptions().getItem(1));
+ }
+
+ /**
+ * selectedIndex, option.selected
+ */
+ public void testSelection() {
+ Document doc = Document.get();
+ SelectElement select = doc.createSelectElement();
+ doc.getBody().appendChild(select);
+
+ OptionElement opt0 = doc.createOptionElement();
+ OptionElement opt1 = doc.createOptionElement();
+ OptionElement opt2 = doc.createOptionElement();
+ opt0.setText("foo");
+ opt1.setText("bar");
+ opt2.setText("baz");
+ opt0.setValue("0");
+ opt1.setValue("1");
+ opt2.setValue("2");
+
+ select.appendChild(opt0);
+ select.appendChild(opt1);
+ select.appendChild(opt2);
+
+ // Single selection.
+ opt0.setSelected(true);
+ assertTrue(opt0.isSelected());
+ assertEquals(0, select.getSelectedIndex());
+
+ opt1.setSelected(true);
+ assertFalse(opt0.isSelected());
+ assertTrue(opt1.isSelected());
+ assertEquals(1, select.getSelectedIndex());
+ }
+
+ /**
+ * multiple
+ */
+ public void testMultipleSelection() {
+ Document doc = Document.get();
+ SelectElement select = doc.createSelectElement(true);
+ doc.getBody().appendChild(select);
+
+ OptionElement opt0 = doc.createOptionElement();
+ OptionElement opt1 = doc.createOptionElement();
+ OptionElement opt2 = doc.createOptionElement();
+ opt0.setText("foo");
+ opt1.setText("bar");
+ opt2.setText("baz");
+ opt0.setValue("0");
+ opt1.setValue("1");
+ opt2.setValue("2");
+
+ select.appendChild(opt0);
+ select.appendChild(opt1);
+ select.appendChild(opt2);
+
+ // Multiple selection.
+ opt0.setSelected(true);
+ opt1.setSelected(true);
+ opt2.setSelected(true);
+
+ assertTrue(select.isMultiple());
+ assertTrue(opt0.isSelected());
+ assertTrue(opt1.isSelected());
+ assertTrue(opt2.isSelected());
+ }
+}
diff --git a/user/test/com/google/gwt/dom/client/TableTests.java b/user/test/com/google/gwt/dom/client/TableTests.java
new file mode 100644
index 0000000..8114cdc
--- /dev/null
+++ b/user/test/com/google/gwt/dom/client/TableTests.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * 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 com.google.gwt.dom.client;
+
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Tests the {@link TableElement}, {@link TableCaptionElement},
+ * {@link TableCellElement}, {@link TableRowElement}, and
+ * {@link TableSectionElement} classes.
+ */
+public class TableTests extends GWTTestCase {
+
+ @Override
+ public String getModuleName() {
+ return "com.google.gwt.dom.DOMTest";
+ }
+
+ /**
+ * insertRow, getRows, rowIndex
+ */
+ public void testInsertRow() {
+ TableElement table = Document.get().createTableElement();
+ TableRowElement row1 = table.insertRow(-1);
+ TableRowElement row2 = table.insertRow(-1);
+ TableRowElement row3 = table.insertRow(-1);
+
+ assertEquals(row1, table.getRows().getItem(0));
+ assertEquals(row2, table.getRows().getItem(1));
+ assertEquals(row3, table.getRows().getItem(2));
+
+ TableRowElement row0 = table.insertRow(0);
+ assertEquals(row0, table.getRows().getItem(0));
+ assertEquals(row1, table.getRows().getItem(1));
+ assertEquals(row2, table.getRows().getItem(2));
+ assertEquals(row3, table.getRows().getItem(3));
+
+ assertEquals(0, row0.getRowIndex());
+ assertEquals(1, row1.getRowIndex());
+ assertEquals(2, row2.getRowIndex());
+ assertEquals(3, row3.getRowIndex());
+ }
+
+ /**
+ * insertCell, getCells, cellIndex
+ */
+ public void testInsertCell() {
+ TableElement table = Document.get().createTableElement();
+ TableRowElement row = table.insertRow(0);
+
+ TableCellElement cell1 = row.insertCell(-1);
+ TableCellElement cell2 = row.insertCell(-1);
+ TableCellElement cell3 = row.insertCell(-1);
+
+ assertEquals(cell1, row.getCells().getItem(0));
+ assertEquals(cell2, row.getCells().getItem(1));
+ assertEquals(cell3, row.getCells().getItem(2));
+
+ TableCellElement cell0 = row.insertCell(0);
+ assertEquals(cell0, row.getCells().getItem(0));
+ assertEquals(cell1, row.getCells().getItem(1));
+ assertEquals(cell2, row.getCells().getItem(2));
+ assertEquals(cell3, row.getCells().getItem(3));
+
+ assertEquals(0, cell0.getCellIndex());
+ assertEquals(1, cell1.getCellIndex());
+ assertEquals(2, cell2.getCellIndex());
+ assertEquals(3, cell3.getCellIndex());
+ }
+
+ /**
+ * createTHead, thead, tfoot, createTFoot, tBodies, section.insertRow,
+ * section.rows, deleteTHead, deleteTFoot
+ */
+ public void testSections() {
+ TableElement table = Document.get().createTableElement();
+
+ // Put some rows in the body.
+ TableRowElement row0 = table.insertRow(-1);
+ TableRowElement row1 = table.insertRow(-1);
+ TableRowElement row2 = table.insertRow(-1);
+
+ // Add header and footer rows.
+ TableSectionElement thead = table.createTHead();
+ TableSectionElement tfoot = table.createTFoot();
+ TableRowElement headRow = thead.insertRow(-1);
+ TableRowElement footRow = tfoot.insertRow(-1);
+
+ // Add a cell to each row (this is technically required).
+ row0.insertCell(-1);
+ row1.insertCell(-1);
+ row2.insertCell(-1);
+ headRow.insertCell(-1);
+ footRow.insertCell(-1);
+
+ // Check tbodies, thead, tfoot.
+ TableSectionElement tbody = table.getTBodies().getItem(0);
+ assertEquals("one tbody expected", 1, table.getTBodies().getLength());
+ assertEquals("one tbody expected", tbody, table.getTBodies().getItem(0));
+ assertEquals("thead should exist", thead, table.getTHead());
+ assertEquals("tfoot should exist", tfoot, table.getTFoot());
+
+ assertEquals("<thead> expected", "thead", thead.getTagName().toLowerCase());
+ assertEquals("<tbody> expected", "tbody", tbody.getTagName().toLowerCase());
+ assertEquals("<tfoot> expected", "tfoot", tfoot.getTagName().toLowerCase());
+
+ // Ensure table row enumeration contains all rows (order of section rows is
+ // not guaranteed across browsers).
+ NodeList<TableRowElement> allRows = table.getRows();
+
+ assertEquals("5 rows expected", 5, allRows.getLength());
+ assertContains("[0] == headRow", headRow, allRows);
+ assertContains("[1] == footRow", footRow, allRows);
+ assertContains("[2] == row0", row0, allRows);
+ assertContains("[3] == row1", row1, allRows);
+ assertContains("[4] == row2", row2, allRows);
+
+ // Ensure tbody section row enumeration is correct.
+ NodeList<TableRowElement> bodyRows = tbody.getRows();
+ assertEquals("[0] == row0", row0, bodyRows.getItem(0));
+ assertEquals("[1] == row1", row1, bodyRows.getItem(1));
+ assertEquals("[2] == row2", row2, bodyRows.getItem(2));
+
+ // Remove the header and footer.
+ table.deleteTHead();
+ table.deleteTFoot();
+ assertNull("no thead expected", table.getTHead());
+ assertNull("no tfoot expected", table.getTFoot());
+ }
+
+ private void assertContains(String msg, Node n, NodeList<?> list) {
+ for (int i = 0; i < list.getLength(); ++i) {
+ if (list.getItem(i) == n) {
+ return;
+ }
+ }
+
+ fail(msg);
+ }
+}