GWT 2.5.0.rc2

com.google.gwt.user.client
Class DOM

java.lang.Object
  extended by com.google.gwt.user.client.DOM

public class DOM
extends java.lang.Object

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 both elements and events.


Field Summary
(package private) static com.google.gwt.user.client.impl.DOMImpl impl
           
 
Constructor Summary
DOM()
           
 
Method Summary
static void addEventPreview(EventPreview preview)
          Deprecated. replaced by Event.addNativePreviewHandler(Event.NativePreviewHandler)
static void appendChild(Element parent, Element child)
          Appends one element to another's list of children.
static Element clone(Element elem, boolean deep)
          Clones an element.
static boolean compare(Element elem1, Element elem2)
          Deprecated. Use identity comparison.
static Element createAnchor()
          Creates an HTML A element.
static Element createButton()
          Creates an HTML BUTTON element.
static Element createCaption()
          Creates an HTML CAPTION element.
static Element createCol()
          Creates an HTML COL element.
static Element createColGroup()
          Creates an HTML COLGROUP element.
static Element createDiv()
          Creates an HTML DIV element.
static Element createElement(java.lang.String tagName)
          Creates an HTML element.
static Element createFieldSet()
          Creates an HTML FIELDSET element.
static Element createForm()
          Creates an HTML FORM element.
static Element createIFrame()
          Creates an HTML IFRAME element.
static Element createImg()
          Creates an HTML IMG element.
static Element createInputCheck()
          Creates an HTML INPUT type='CHECK' element.
static Element createInputPassword()
          Creates an HTML INPUT type='PASSWORD' element.
static Element createInputRadio(java.lang.String name)
          Creates an HTML INPUT type='RADIO' element.
static Element createInputText()
          Creates an HTML INPUT type='TEXT' element.
static Element createLabel()
          Creates an HTML LABEL element.
static Element createLegend()
          Creates an HTML LEGEND element.
static Element createOption()
          Creates an HTML OPTION element.
static Element createOptions()
          Deprecated. there is no "options" element; use createOption() instead
static Element createSelect()
          Creates a single-selection HTML SELECT element.
static Element createSelect(boolean multiple)
          Creates an HTML SELECT element.
static Element createSpan()
          Creates an HTML SPAN element.
static Element createTable()
          Creates an HTML TABLE element.
static Element createTBody()
          Creates an HTML TBODY element.
static Element createTD()
          Creates an HTML TD element.
static Element createTextArea()
          Creates an HTML TEXTAREA element.
static Element createTFoot()
          Creates an HTML TFOOT element.
static Element createTH()
          Creates an HTML TH element.
static Element createTHead()
          Creates an HTML THEAD element.
static Element createTR()
          Creates an HTML TR element.
static java.lang.String createUniqueId()
          Generates a unique DOM id.
(package private) static void dispatchEvent(Event evt, Element elem, EventListener listener)
          This method is called directly by native code when any event is fired.
static void eventCancelBubble(Event evt, boolean cancel)
          Cancels bubbling for the given event.
static boolean eventGetAltKey(Event evt)
          Gets whether the ALT key was depressed when the given event occurred.
static int eventGetButton(Event evt)
          Gets the mouse buttons that were depressed when the given event occurred.
static int eventGetClientX(Event evt)
          Gets the mouse x-position within the browser window's client area.
static int eventGetClientY(Event evt)
          Gets the mouse y-position within the browser window's client area.
static boolean eventGetCtrlKey(Event evt)
          Gets whether the CTRL key was depressed when the given event occurred.
static Event eventGetCurrentEvent()
          Gets the current event that is being fired.
static Element eventGetCurrentTarget(Event evt)
          Gets the current target element of the given event.
static Element eventGetFromElement(Event evt)
          Gets the element from which the mouse pointer was moved (valid for Event.ONMOUSEOVER and Event.ONMOUSEOUT).
static int eventGetKeyCode(Event evt)
          Gets the key code associated with this event.
static boolean eventGetMetaKey(Event evt)
          Gets whether the META key was depressed when the given event occurred.
static int eventGetMouseWheelVelocityY(Event evt)
          Gets the velocity of the mouse wheel associated with the event along the Y axis.
static boolean eventGetRepeat(Event evt)
          Deprecated. not supported in any browser but IE
static int eventGetScreenX(Event evt)
          Gets the mouse x-position on the user's display.
static int eventGetScreenY(Event evt)
          Gets the mouse y-position on the user's display.
static boolean eventGetShiftKey(Event evt)
          Gets whether the shift key was depressed when the given event occurred.
static Element eventGetTarget(Event evt)
          Returns the element that was the actual target of the given event.
static Element eventGetToElement(Event evt)
          Gets the element to which the mouse pointer was moved (only valid for Event.ONMOUSEOUT and Event.ONMOUSEOVER).
static int eventGetType(Event evt)
          Gets the enumerated type of this event (as defined in Event).
static java.lang.String eventGetTypeString(Event evt)
          Gets the type of the given event as a string.
static void eventPreventDefault(Event evt)
          Prevents the browser from taking its default action for the given event.
static void eventSetKeyCode(Event evt, char key)
          Deprecated. this method only works in IE and should not have been added to the API
static java.lang.String eventToString(Event evt)
          Returns a stringized version of the event.
static int getAbsoluteLeft(Element elem)
          Gets an element's absolute left coordinate in the document's coordinate system.
static int getAbsoluteTop(Element elem)
          Gets an element's absolute top coordinate in the document's coordinate system.
static java.lang.String getAttribute(Element elem, java.lang.String attr)
          Deprecated. Use the more appropriately named getElementProperty(Element, String) instead.
static boolean getBooleanAttribute(Element elem, java.lang.String attr)
          Deprecated. Use the more appropriately named getElementPropertyBoolean(Element, String) instead.
static Element getCaptureElement()
          Gets the element that currently has mouse capture.
static Element getChild(Element parent, int index)
          Gets an element's n-th child element.
static int getChildCount(Element parent)
          Gets the number of child elements present in a given parent element.
static int getChildIndex(Element parent, Element child)
          Gets the index of a given child element within its parent.
static java.lang.String getElementAttribute(Element elem, java.lang.String attr)
          Gets the named attribute from the element.
static Element getElementById(java.lang.String id)
          Gets the element associated with the given unique id within the entire document.
static java.lang.String getElementProperty(Element elem, java.lang.String prop)
          Gets any named property from an element, as a string.
static boolean getElementPropertyBoolean(Element elem, java.lang.String prop)
          Gets any named property from an element, as a boolean.
static int getElementPropertyInt(Element elem, java.lang.String prop)
          Gets any named property from an element, as an int.
static EventListener getEventListener(Element elem)
          Gets the EventListener that will receive events for the given element.
static int getEventsSunk(Element elem)
          Gets the current set of events sunk by a given element.
static Element getFirstChild(Element elem)
          Gets the first child element of the given element.
static java.lang.String getImgSrc(Element img)
          Gets the src attribute of an img element.
static java.lang.String getInnerHTML(Element elem)
          Gets an HTML representation of an element's children.
static java.lang.String getInnerText(Element elem)
          Gets the text contained within an element.
static int getIntAttribute(Element elem, java.lang.String attr)
          Deprecated. Use the more appropriately named getElementPropertyInt(Element, String) instead.
static int getIntStyleAttribute(Element elem, java.lang.String attr)
          Gets an integer attribute on a given element's style.
static Element getNextSibling(Element elem)
          Gets an element's next sibling element.
static Element getParent(Element elem)
          Gets an element's parent element.
static java.lang.String getStyleAttribute(Element elem, java.lang.String attr)
          Gets an attribute of the given element's style.
static void insertBefore(Element parent, Element child, Element before)
          Inserts an element as a child of the given parent element, before another child of that parent.
static void insertChild(Element parent, Element child, int index)
          Inserts an element as a child of the given parent element.
static void insertListItem(Element selectElem, java.lang.String item, java.lang.String value, int index)
          Creates an <option> element and inserts it as a child of the specified <select> element.
static boolean isOrHasChild(Element parent, Element child)
          Determine whether one element is equal to, or the child of, another.
(package private) static void maybeInitializeEventSystem()
          Initialize the event system if it has not already been initialized.
(package private) static boolean previewEvent(Event evt)
          This method is called directly by native code when event preview is being used.
static void releaseCapture(Element elem)
          Releases mouse/touch/gesture capture on the given element.
static void removeChild(Element parent, Element child)
          Removes a child element from the given parent element.
static void removeElementAttribute(Element elem, java.lang.String attr)
          Removes the named attribute from the given element.
static void removeEventPreview(EventPreview preview)
          Deprecated. use HandlerRegistration returned from Event.addNativePreviewHandler(Event.NativePreviewHandler)
static void scrollIntoView(Element elem)
          Scrolls the given element into view.
static void setAttribute(Element elem, java.lang.String attr, java.lang.String value)
          Deprecated. Use the more appropriately named setElementProperty(Element, String, String) instead.
static void setBooleanAttribute(Element elem, java.lang.String attr, boolean value)
          Deprecated. Use the more appropriately named setElementPropertyBoolean(Element, String, boolean) instead.
static void setCapture(Element elem)
          Sets mouse/touch/gesture capture on the given element.
static void setElementAttribute(Element elem, java.lang.String attr, java.lang.String value)
          Sets an attribute on a given element.
static void setElementProperty(Element elem, java.lang.String prop, java.lang.String value)
          Sets a property on the given element.
static void setElementPropertyBoolean(Element elem, java.lang.String prop, boolean value)
          Sets a boolean property on the given element.
static void setElementPropertyInt(Element elem, java.lang.String prop, int value)
          Sets an int property on the given element.
static void setEventListener(Element elem, EventListener listener)
          Sets the EventListener to receive events for the given element.
static void setImgSrc(Element img, java.lang.String src)
          Sets the src attribute of an img element.
static void setInnerHTML(Element elem, java.lang.String html)
          Sets the HTML contained within an element.
static void setInnerText(Element elem, java.lang.String text)
          Sets the text contained within an element.
static void setIntAttribute(Element elem, java.lang.String attr, int value)
          Deprecated. Use the more appropriately named setElementPropertyInt(Element, String, int) instead.
static void setIntStyleAttribute(Element elem, java.lang.String attr, int value)
          Sets an integer attribute on the given element's style.
static void setOptionText(Element select, java.lang.String text, int index)
          Sets the option text of the given select object.
static void setStyleAttribute(Element elem, java.lang.String attr, java.lang.String value)
          Sets an attribute on the given element's style.
static void sinkBitlessEvent(Element elem, java.lang.String eventTypeName)
          Sinks a named event.
static void sinkEvents(Element elem, int eventBits)
          Sets the current set of events sunk by a given element.
static java.lang.String toString(Element elem)
          Returns a stringized version of the element.
static int windowGetClientHeight()
          Deprecated. As of GWT 1.5, replaced by Window.getClientHeight()
static int windowGetClientWidth()
          Deprecated. As of GWT 1.5, replaced by Window.getClientWidth()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

impl

static final com.google.gwt.user.client.impl.DOMImpl impl
Constructor Detail

DOM

public DOM()
Method Detail

addEventPreview

@Deprecated
public static void addEventPreview(EventPreview preview)
Deprecated. replaced by Event.addNativePreviewHandler(Event.NativePreviewHandler)

Adds an event preview to the preview stack. As long as this preview remains on the top of the stack, it will receive all events before they are fired to their listeners. Note that the event preview will receive all events, including those received due to bubbling, whereas normal event handlers only receive explicitly sunk events.

Parameters:
preview - the event preview to be added to the stack.

appendChild

public static void appendChild(Element parent,
                               Element child)
Appends one element to another's list of children.

If the child element is a PotentialElement, it is first resolved.

Parameters:
parent - the parent element
child - its new child
See Also:
PotentialElement.resolve(Element)

clone

public static Element clone(Element elem,
                            boolean deep)
Clones an element.

Parameters:
elem - the element to be cloned
deep - should children be cloned as well?

compare

@Deprecated
public static boolean compare(Element elem1,
                                         Element elem2)
Deprecated. Use identity comparison.

Compares two elements for equality. Note that this method is now deprecated because reference identity accurately reports equality.

Parameters:
elem1 - the first element to be compared
elem2 - the second element to be compared
Returns:
true if they are in fact the same element

createAnchor

public static Element createAnchor()
Creates an HTML A element.

Returns:
the newly-created element

createButton

public static Element createButton()
Creates an HTML BUTTON element.

Returns:
the newly-created element

createCaption

public static Element createCaption()
Creates an HTML CAPTION element.

Returns:
the newly-created element

createCol

public static Element createCol()
Creates an HTML COL element.

Returns:
the newly-created element

createColGroup

public static Element createColGroup()
Creates an HTML COLGROUP element.

Returns:
the newly-created element

createDiv

public static Element createDiv()
Creates an HTML DIV element.

Returns:
the newly-created element

createElement

public static Element createElement(java.lang.String tagName)
Creates an HTML element.

Parameters:
tagName - the HTML tag of the element to be created
Returns:
the newly-created element

createFieldSet

public static Element createFieldSet()
Creates an HTML FIELDSET element.

Returns:
the newly-created element

createForm

public static Element createForm()
Creates an HTML FORM element.

Returns:
the newly-created element

createIFrame

public static Element createIFrame()
Creates an HTML IFRAME element.

Returns:
the newly-created element

createImg

public static Element createImg()
Creates an HTML IMG element.

Returns:
the newly-created element

createInputCheck

public static Element createInputCheck()
Creates an HTML INPUT type='CHECK' element.

Returns:
the newly-created element

createInputPassword

public static Element createInputPassword()
Creates an HTML INPUT type='PASSWORD' element.

Returns:
the newly-created element

createInputRadio

public static Element createInputRadio(java.lang.String name)
Creates an HTML INPUT type='RADIO' element.

Parameters:
name - the name of the group with which this radio button will be associated
Returns:
the newly-created element

createInputText

public static Element createInputText()
Creates an HTML INPUT type='TEXT' element.

Returns:
the newly-created element

createLabel

public static Element createLabel()
Creates an HTML LABEL element.

Returns:
the newly-created element

createLegend

public static Element createLegend()
Creates an HTML LEGEND element.

Returns:
the newly-created element

createOption

public static Element createOption()
Creates an HTML OPTION element.

Returns:
the newly-created element

createOptions

@Deprecated
public static Element createOptions()
Deprecated. there is no "options" element; use createOption() instead

Creates an HTML OPTIONS element.

Returns:
the newly-created element

createSelect

public static Element createSelect()
Creates a single-selection HTML SELECT element. Equivalent to
 createSelect(false)
 

Returns:
the newly-created element

createSelect

public static Element createSelect(boolean multiple)
Creates an HTML SELECT element.

Parameters:
multiple - true if multiple selection of options is allowed
Returns:
the newly-created element

createSpan

public static Element createSpan()
Creates an HTML SPAN element.

Returns:
the newly-created element

createTable

public static Element createTable()
Creates an HTML TABLE element.

Returns:
the newly-created element

createTBody

public static Element createTBody()
Creates an HTML TBODY element.

Returns:
the newly-created element

createTD

public static Element createTD()
Creates an HTML TD element.

Returns:
the newly-created element

createTextArea

public static Element createTextArea()
Creates an HTML TEXTAREA element.

Returns:
the newly-created element

createTFoot

public static Element createTFoot()
Creates an HTML TFOOT element.

Returns:
the newly-created element

createTH

public static Element createTH()
Creates an HTML TH element.

Returns:
the newly-created element

createTHead

public static Element createTHead()
Creates an HTML THEAD element.

Returns:
the newly-created element

createTR

public static Element createTR()
Creates an HTML TR element.

Returns:
the newly-created element

createUniqueId

public static java.lang.String createUniqueId()
Generates a unique DOM id. The id is of the form "gwt-id-".

Returns:
a unique DOM id

eventCancelBubble

public static void eventCancelBubble(Event evt,
                                     boolean cancel)
Cancels bubbling for the given event. This will stop the event from being propagated to parent elements.

Parameters:
evt - the event on which to cancel bubbling
cancel - true to cancel bubbling

eventGetAltKey

public static boolean eventGetAltKey(Event evt)
Gets whether the ALT key was depressed when the given event occurred.

Parameters:
evt - the event to be tested
Returns:
true if ALT was depressed when the event occurred

eventGetButton

public static int eventGetButton(Event evt)
Gets the mouse buttons that were depressed when the given event occurred.

Parameters:
evt - the event to be tested
Returns:
a bit-field, defined by NativeEvent.BUTTON_LEFT, NativeEvent.BUTTON_MIDDLE, and NativeEvent.BUTTON_RIGHT

eventGetClientX

public static int eventGetClientX(Event evt)
Gets the mouse x-position within the browser window's client area.

Parameters:
evt - the event to be tested
Returns:
the mouse x-position

eventGetClientY

public static int eventGetClientY(Event evt)
Gets the mouse y-position within the browser window's client area.

Parameters:
evt - the event to be tested
Returns:
the mouse y-position

eventGetCtrlKey

public static boolean eventGetCtrlKey(Event evt)
Gets whether the CTRL key was depressed when the given event occurred.

Parameters:
evt - the event to be tested
Returns:
true if CTRL was depressed when the event occurred

eventGetCurrentEvent

public static Event eventGetCurrentEvent()
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.

Returns:
the current event

eventGetCurrentTarget

public static Element eventGetCurrentTarget(Event evt)
Gets the current target element of the given event. This is the element whose listener fired last, not the element which fired the event initially.

Parameters:
evt - the event
Returns:
the event's current target element
See Also:
eventGetTarget(Event)

eventGetFromElement

public static Element eventGetFromElement(Event evt)
Gets the element from which the mouse pointer was moved (valid for Event.ONMOUSEOVER and Event.ONMOUSEOUT).

Parameters:
evt - the event to be tested
Returns:
the element from which the mouse pointer was moved

eventGetKeyCode

public static int eventGetKeyCode(Event evt)
Gets the key code associated with this event.

For Event.ONKEYPRESS, this method returns the Unicode value of the character generated. For Event.ONKEYDOWN and Event.ONKEYUP, it returns the code associated with the physical key.

Parameters:
evt - the event to be tested
Returns:
the Unicode character or key code.
See Also:
KeyboardListener

eventGetMetaKey

public static boolean eventGetMetaKey(Event evt)
Gets whether the META key was depressed when the given event occurred.

Parameters:
evt - the event to be tested
Returns:
true if META was depressed when the event occurred

eventGetMouseWheelVelocityY

public static int eventGetMouseWheelVelocityY(Event evt)
Gets the velocity of the mouse wheel associated with the event along the Y axis.

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.

Parameters:
evt - the event to be examined.
Returns:
The velocity of the mouse wheel.

eventGetRepeat

@Deprecated
public static boolean eventGetRepeat(Event evt)
Deprecated. not supported in any browser but IE

Gets the key-repeat state of this event. Only IE supports this attribute.

Parameters:
evt - the event to be tested
Returns:
true if this key event was an auto-repeat

eventGetScreenX

public static int eventGetScreenX(Event evt)
Gets the mouse x-position on the user's display.

Parameters:
evt - the event to be tested
Returns:
the mouse x-position

eventGetScreenY

public static int eventGetScreenY(Event evt)
Gets the mouse y-position on the user's display.

Parameters:
evt - the event to be tested
Returns:
the mouse y-position

eventGetShiftKey

public static boolean eventGetShiftKey(Event evt)
Gets whether the shift key was depressed when the given event occurred.

Parameters:
evt - the event to be tested
Returns:
true if shift was depressed when the event occurred

eventGetTarget

public static Element eventGetTarget(Event evt)
Returns the element that was the actual target of the given event.

Parameters:
evt - the event to be tested
Returns:
the target element

eventGetToElement

public static Element eventGetToElement(Event evt)
Gets the element to which the mouse pointer was moved (only valid for Event.ONMOUSEOUT and Event.ONMOUSEOVER).

Parameters:
evt - the event to be tested
Returns:
the element to which the mouse pointer was moved

eventGetType

public static int eventGetType(Event evt)
Gets the enumerated type of this event (as defined in Event).

Parameters:
evt - the event to be tested
Returns:
the event's enumerated type, or -1 if not defined

eventGetTypeString

public static java.lang.String eventGetTypeString(Event evt)
Gets the type of the given event as a string.

Parameters:
evt - the event to be tested
Returns:
the event's type name

eventPreventDefault

public static void eventPreventDefault(Event evt)
Prevents the browser from taking its default action for the given event.

Parameters:
evt - the event whose default action is to be prevented

eventSetKeyCode

@Deprecated
public static void eventSetKeyCode(Event evt,
                                              char key)
Deprecated. this method only works in IE and should not have been added to the API

Sets the key code associated with the given keyboard event.

Parameters:
evt - the event whose key code is to be set
key - the new key code

eventToString

public static java.lang.String eventToString(Event evt)
Returns a stringized version of the event. This string is for debugging purposes and will NOT be consistent on different browsers.

Parameters:
evt - the event to stringize
Returns:
a string form of the event

getAbsoluteLeft

public static int getAbsoluteLeft(Element elem)
Gets an element's absolute left coordinate in the document's coordinate system.

Parameters:
elem - the element to be measured
Returns:
the element's absolute left coordinate

getAbsoluteTop

public static int getAbsoluteTop(Element elem)
Gets an element's absolute top coordinate in the document's coordinate system.

Parameters:
elem - the element to be measured
Returns:
the element's absolute top coordinate

getAttribute

@Deprecated
public static java.lang.String getAttribute(Element elem,
                                                       java.lang.String attr)
Deprecated. Use the more appropriately named getElementProperty(Element, String) instead.

Gets any named attribute from an element, as a string.

Parameters:
elem - the element whose attribute is to be retrieved
attr - the name of the attribute
Returns:
the attribute's value

getBooleanAttribute

@Deprecated
public static boolean getBooleanAttribute(Element elem,
                                                     java.lang.String attr)
Deprecated. Use the more appropriately named getElementPropertyBoolean(Element, String) instead.

Gets a boolean attribute on the given element.

Parameters:
elem - the element whose attribute is to be set
attr - the name of the attribute to be set
Returns:
the attribute's value as a boolean

getCaptureElement

public static Element getCaptureElement()
Gets the element that currently has mouse capture.

Returns:
a handle to the capture element, or null if none exists

getChild

public static Element getChild(Element parent,
                               int index)
Gets an element's n-th child element.

Parameters:
parent - the element whose child is to be retrieved
index - the index of the child element
Returns:
the n-th child element

getChildCount

public static int getChildCount(Element parent)
Gets the number of child elements present in a given parent element.

Parameters:
parent - the element whose children are to be counted
Returns:
the number of children

getChildIndex

public static int getChildIndex(Element parent,
                                Element child)
Gets the index of a given child element within its parent.

Parameters:
parent - the parent element
child - the child element
Returns:
the child's index within its parent, or -1 if it is not a child of the given parent

getElementAttribute

public static java.lang.String getElementAttribute(Element elem,
                                                   java.lang.String attr)
Gets the named attribute from the element.

Parameters:
elem - the element whose property is to be retrieved
attr - the name of the attribute
Returns:
the value of the attribute

getElementById

public static Element getElementById(java.lang.String id)
Gets the element associated with the given unique id within the entire document.

Parameters:
id - the id whose associated element is to be retrieved
Returns:
the associated element, or null if none is found

getElementProperty

public static java.lang.String getElementProperty(Element elem,
                                                  java.lang.String prop)
Gets any named property from an element, as a string.

Parameters:
elem - the element whose property is to be retrieved
prop - the name of the property
Returns:
the property's value

getElementPropertyBoolean

public static boolean getElementPropertyBoolean(Element elem,
                                                java.lang.String prop)
Gets any named property from an element, as a boolean.

Parameters:
elem - the element whose property is to be retrieved
prop - the name of the property
Returns:
the property's value as a boolean

getElementPropertyInt

public static int getElementPropertyInt(Element elem,
                                        java.lang.String prop)
Gets any named property from an element, as an int.

Parameters:
elem - the element whose property is to be retrieved
prop - the name of the property
Returns:
the property's value as an int

getEventListener

public static EventListener getEventListener(Element elem)
Gets the EventListener that will receive events for the given element. Only one such listener may exist for a single element.

Parameters:
elem - the element whose listener is to be set
Returns:
the element's event listener

getEventsSunk

public static int getEventsSunk(Element elem)
Gets the current set of events sunk by a given element.

Parameters:
elem - the element whose events are to be retrieved
Returns:
a bitfield describing the events sunk on this element (its possible values are described in Event)

getFirstChild

public static Element getFirstChild(Element elem)
Gets the first child element of the given element.

Parameters:
elem - the element whose child is to be retrieved
Returns:
the child element

getImgSrc

public static java.lang.String getImgSrc(Element img)
Gets the src attribute of an img element. This method is paired with setImgSrc(Element, String) so that it always returns the correct url.

Parameters:
img - a non-null img whose src attribute is to be read.
Returns:
the src url of the img

getInnerHTML

public static java.lang.String getInnerHTML(Element elem)
Gets an HTML representation of an element's children.

Parameters:
elem - the element whose HTML is to be retrieved
Returns:
the HTML representation of the element's children

getInnerText

public static java.lang.String getInnerText(Element elem)
Gets the text contained within an element. If the element has child elements, only the text between them will be retrieved.

Parameters:
elem - the element whose inner text is to be retrieved
Returns:
the text inside this element

getIntAttribute

@Deprecated
public static int getIntAttribute(Element elem,
                                             java.lang.String attr)
Deprecated. Use the more appropriately named getElementPropertyInt(Element, String) instead.

Gets an integer attribute on a given element.

Parameters:
elem - the element whose attribute is to be retrieved
attr - the name of the attribute to be retrieved
Returns:
the attribute's value as an integer

getIntStyleAttribute

public static int getIntStyleAttribute(Element elem,
                                       java.lang.String attr)
Gets an integer attribute on a given element's style.

Parameters:
elem - the element whose style attribute is to be retrieved
attr - the name of the attribute to be retrieved
Returns:
the style attribute's value as an integer

getNextSibling

public static Element getNextSibling(Element elem)
Gets an element's next sibling element.

Parameters:
elem - the element whose sibling is to be retrieved
Returns:
the sibling element

getParent

public static Element getParent(Element elem)
Gets an element's parent element.

Parameters:
elem - the element whose parent is to be retrieved
Returns:
the parent element

getStyleAttribute

public static java.lang.String getStyleAttribute(Element elem,
                                                 java.lang.String attr)
Gets an attribute of the given element's style.

Parameters:
elem - the element whose style attribute is to be retrieved
attr - the name of the style attribute to be retrieved
Returns:
the style attribute's value

insertBefore

public static void insertBefore(Element parent,
                                Element child,
                                Element before)
Inserts an element as a child of the given parent element, before another child of that parent.

If the child element is a PotentialElement, it is first resolved.

Parameters:
parent - the parent element
child - the child element to add to parent
before - an existing child element of parent before which child will be inserted
See Also:
PotentialElement.resolve(Element)

insertChild

public static void insertChild(Element parent,
                               Element child,
                               int index)
Inserts an element as a child of the given parent element.

If the child element is a PotentialElement, it is first resolved.

Parameters:
parent - the parent element
child - the child element to add to parent
index - the index before which the child will be inserted (any value greater than the number of existing children will cause the child to be appended)
See Also:
PotentialElement.resolve(Element)

insertListItem

public static void insertListItem(Element selectElem,
                                  java.lang.String item,
                                  java.lang.String value,
                                  int index)
Creates an <option> element and inserts it as a child of the specified <select> element. If the index is less than zero, or greater than or equal to the length of the list, then the option element will be appended to the end of the list.

Parameters:
selectElem - the <select> element
item - the text of the new item; cannot be null
value - the value attribute for the new <option>; cannot be null
index - the index at which to insert the child

isOrHasChild

public static boolean isOrHasChild(Element parent,
                                   Element child)
Determine whether one element is equal to, or the child of, another.

Parameters:
parent - the potential parent element
child - the potential child element
Returns:
true if the relationship holds

releaseCapture

public static void releaseCapture(Element elem)
Releases mouse/touch/gesture capture on the given element. Calling this method has no effect if the element does not currently have mouse/touch/gesture capture.

Parameters:
elem - the element to release capture
See Also:
setCapture(Element)

removeChild

public static void removeChild(Element parent,
                               Element child)
Removes a child element from the given parent element.

Parameters:
parent - the parent element
child - the child element to be removed

removeElementAttribute

public static void removeElementAttribute(Element elem,
                                          java.lang.String attr)
Removes the named attribute from the given element.

Parameters:
elem - the element whose attribute is to be removed
attr - the name of the element to remove

removeEventPreview

@Deprecated
public static void removeEventPreview(EventPreview preview)
Deprecated. use HandlerRegistration returned from Event.addNativePreviewHandler(Event.NativePreviewHandler)

Removes an element from the preview stack. This element will no longer capture events, though any preview underneath it will begin to do so.

Parameters:
preview - the event preview to be removed from the stack

scrollIntoView

public static void scrollIntoView(Element elem)
Scrolls the given element into view.

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.

Parameters:
elem - the element to be made visible

setAttribute

@Deprecated
public static void setAttribute(Element elem,
                                           java.lang.String attr,
                                           java.lang.String value)
Deprecated. Use the more appropriately named setElementProperty(Element, String, String) instead.

Sets an attribute on the given element.

Parameters:
elem - the element whose attribute is to be set
attr - the name of the attribute to be set
value - the new attribute value

setBooleanAttribute

@Deprecated
public static void setBooleanAttribute(Element elem,
                                                  java.lang.String attr,
                                                  boolean value)
Deprecated. Use the more appropriately named setElementPropertyBoolean(Element, String, boolean) instead.

Sets a boolean attribute on the given element.

Parameters:
elem - the element whose attribute is to be set
attr - the name of the attribute to be set
value - the attribute's new boolean value

setCapture

public static void setCapture(Element elem)
Sets mouse/touch/gesture capture on the given element. This element will directly receive all mouse events until releaseCapture(Element) is called on it.

Parameters:
elem - the element on which to set mouse/touch/gesture capture

setElementAttribute

public static void setElementAttribute(Element elem,
                                       java.lang.String attr,
                                       java.lang.String value)
Sets an attribute on a given element.

Parameters:
elem - element whose attribute is to be set
attr - the name of the attribute
value - the value to which the attribute should be set

setElementProperty

public static void setElementProperty(Element elem,
                                      java.lang.String prop,
                                      java.lang.String value)
Sets a property on the given element.

Parameters:
elem - the element whose property is to be set
prop - the name of the property to be set
value - the new property value

setElementPropertyBoolean

public static void setElementPropertyBoolean(Element elem,
                                             java.lang.String prop,
                                             boolean value)
Sets a boolean property on the given element.

Parameters:
elem - the element whose property is to be set
prop - the name of the property to be set
value - the new property value as a boolean

setElementPropertyInt

public static void setElementPropertyInt(Element elem,
                                         java.lang.String prop,
                                         int value)
Sets an int property on the given element.

Parameters:
elem - the element whose property is to be set
prop - the name of the property to be set
value - the new property value as an int

setEventListener

public static void setEventListener(Element elem,
                                    EventListener listener)
Sets the EventListener to receive events for the given element. Only one such listener may exist for a single element.

Parameters:
elem - the element whose listener is to be set
listener - the listener to receive events

setImgSrc

public static void setImgSrc(Element img,
                             java.lang.String src)
Sets the src attribute of an img element. This method ensures that imgs only ever have their contents requested one single time from the server.

Parameters:
img - a non-null img whose src attribute will be set.
src - a non-null url for the img

setInnerHTML

public static void setInnerHTML(Element elem,
                                java.lang.String html)
Sets the HTML contained within an element.

Parameters:
elem - the element whose inner HTML is to be set
html - the new html

setInnerText

public static void setInnerText(Element elem,
                                java.lang.String text)
Sets the text contained within an element. If the element already has children, they will be destroyed.

Parameters:
elem - the element whose inner text is to be set
text - the new text

setIntAttribute

@Deprecated
public static void setIntAttribute(Element elem,
                                              java.lang.String attr,
                                              int value)
Deprecated. Use the more appropriately named setElementPropertyInt(Element, String, int) instead.

Sets an integer attribute on the given element.

Parameters:
elem - the element whose attribute is to be set
attr - the name of the attribute to be set
value - the attribute's new integer value

setIntStyleAttribute

public static void setIntStyleAttribute(Element elem,
                                        java.lang.String attr,
                                        int value)
Sets an integer attribute on the given element's style.

Parameters:
elem - the element whose style attribute is to be set
attr - the name of the style attribute to be set
value - the style attribute's new integer value

setOptionText

public static void setOptionText(Element select,
                                 java.lang.String text,
                                 int index)
Sets the option text of the given select object.

Parameters:
select - the select object whose option text is being set
text - the text to set
index - the index of the option whose text should be set

setStyleAttribute

public static void setStyleAttribute(Element elem,
                                     java.lang.String attr,
                                     java.lang.String value)
Sets an attribute on the given element's style.

Parameters:
elem - the element whose style attribute is to be set
attr - the name of the style attribute to be set
value - the style attribute's new value

sinkBitlessEvent

public static void sinkBitlessEvent(Element elem,
                                    java.lang.String eventTypeName)
Sinks a named event. Events will be fired to the nearest EventListener specified on any of the element's parents.

Parameters:
elem - the element whose events are to be retrieved
eventTypeName - name of the event to sink on this element

sinkEvents

public static void sinkEvents(Element elem,
                              int eventBits)
Sets the current set of events sunk by a given element. These events will be fired to the nearest EventListener specified on any of the element's parents.

Parameters:
elem - the element whose events are to be retrieved
eventBits - a bitfield describing the events sunk on this element (its possible values are described in Event)

toString

public static java.lang.String toString(Element elem)
Returns a stringized version of the element. This string is for debugging purposes and will NOT be consistent on different browsers.

Parameters:
elem - the element to stringize
Returns:
a string form of the element

windowGetClientHeight

@Deprecated
public static int windowGetClientHeight()
Deprecated. As of GWT 1.5, replaced by Window.getClientHeight()


windowGetClientWidth

@Deprecated
public static int windowGetClientWidth()
Deprecated. As of GWT 1.5, replaced by Window.getClientWidth()


dispatchEvent

static void dispatchEvent(Event evt,
                          Element elem,
                          EventListener listener)
This method is called directly by native code when any event is fired.

Parameters:
evt - the handle to the event being fired.
elem - the handle to the element that received the event.
listener - the listener associated with the element that received the event.

maybeInitializeEventSystem

static void maybeInitializeEventSystem()
Initialize the event system if it has not already been initialized.


previewEvent

static boolean previewEvent(Event evt)
This method is called directly by native code when event preview is being used.

Parameters:
evt - a handle to the event being previewed
Returns:
false to cancel the event

GWT 2.5.0.rc2