Author: [email protected] Date: Fri May 15 13:11:37 2009 New Revision: 5396 Modified: trunk/user/src/com/google/gwt/dom/client/ButtonElement.java trunk/user/src/com/google/gwt/dom/client/FrameElement.java trunk/user/src/com/google/gwt/dom/client/IFrameElement.java trunk/user/src/com/google/gwt/dom/client/ImageElement.java trunk/user/src/com/google/gwt/dom/client/InputElement.java trunk/user/src/com/google/gwt/dom/client/LinkElement.java trunk/user/src/com/google/gwt/dom/client/OptionElement.java trunk/user/src/com/google/gwt/dom/client/SelectElement.java trunk/user/src/com/google/gwt/dom/client/StyleElement.java trunk/user/src/com/google/gwt/dom/client/TextAreaElement.java trunk/user/test/com/google/gwt/dom/client/ElementTest.java
Log: Fixes boolean argument and coercion issues in Element classes. Issue: 3527 Review: http://gwt-code-reviews.appspot.com/33823 Modified: trunk/user/src/com/google/gwt/dom/client/ButtonElement.java ============================================================================== --- trunk/user/src/com/google/gwt/dom/client/ButtonElement.java (original) +++ trunk/user/src/com/google/gwt/dom/client/ButtonElement.java Fri May 15 13:11:37 2009 @@ -57,6 +57,7 @@ * The control is unavailable in this context. * * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled">W3C HTML Specification</a> + * @deprecated use {...@link #isDisabled()} instead. */ public final native String getDisabled() /*-{ return this.disabled; @@ -107,6 +108,15 @@ }-*/; /** + * The control is unavailable in this context. + * + * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled">W3C HTML Specification</a> + */ + public final native boolean isDisabled() /*-{ + return !!this.disabled; + }-*/; + + /** * A single character access key to give access to the form control. * * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-accesskey">W3C HTML Specification</a> @@ -119,6 +129,16 @@ * The control is unavailable in this context. * * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled">W3C HTML Specification</a> + */ + public final native void setDisabled(boolean disabled) /*-{ + this.disabled = disabled; + }-*/; + + /** + * The control is unavailable in this context. + * + * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled">W3C HTML Specification</a> + * @deprecated use {...@link #setDisabled(boolean)} instead */ public final native void setDisabled(String disabled) /*-{ this.disabled = disabled; Modified: trunk/user/src/com/google/gwt/dom/client/FrameElement.java ============================================================================== --- trunk/user/src/com/google/gwt/dom/client/FrameElement.java (original) +++ trunk/user/src/com/google/gwt/dom/client/FrameElement.java Fri May 15 13:11:37 2009 @@ -115,7 +115,7 @@ * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-noresize">W3C HTML Specification</a> */ public final native boolean isNoResize() /*-{ - return this.noResize; + return !!this.noResize; }-*/; /** Modified: trunk/user/src/com/google/gwt/dom/client/IFrameElement.java ============================================================================== --- trunk/user/src/com/google/gwt/dom/client/IFrameElement.java (original) +++ trunk/user/src/com/google/gwt/dom/client/IFrameElement.java Fri May 15 13:11:37 2009 @@ -106,7 +106,7 @@ * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-noresize">W3C HTML Specification</a> */ public final native boolean isNoResize() /*-{ - return this.noResize; + return !!this.noResize; }-*/; /** Modified: trunk/user/src/com/google/gwt/dom/client/ImageElement.java ============================================================================== --- trunk/user/src/com/google/gwt/dom/client/ImageElement.java (original) +++ trunk/user/src/com/google/gwt/dom/client/ImageElement.java Fri May 15 13:11:37 2009 @@ -80,7 +80,7 @@ * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-ismap">W3C HTML Specification</a> */ public final native boolean isMap() /*-{ - return this.isMap; + return !!this.isMap; }-*/; /** @@ -144,6 +144,6 @@ * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-usemap">W3C HTML Specification</a> */ public final native boolean useMap() /*-{ - return this.useMap; + return !!this.useMap; }-*/; } Modified: trunk/user/src/com/google/gwt/dom/client/InputElement.java ============================================================================== --- trunk/user/src/com/google/gwt/dom/client/InputElement.java (original) +++ trunk/user/src/com/google/gwt/dom/client/InputElement.java Fri May 15 13:11:37 2009 @@ -200,7 +200,7 @@ * implementation dependent. */ public final native boolean isChecked() /*-{ - return this.checked; + return !!this.checked; }-*/; /** @@ -212,7 +212,7 @@ * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-checked">W3C HTML Specification</a> */ public final native boolean isDefaultChecked() /*-{ - return this.defaultChecked; + return !!this.defaultChecked; }-*/; /** @@ -221,7 +221,7 @@ * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled">W3C HTML Specification</a> */ public final native boolean isDisabled() /*-{ - return this.disabled; + return !!this.disabled; }-*/; /** @@ -231,7 +231,7 @@ * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-readonly">W3C HTML Specification</a> */ public final native boolean isReadOnly() /*-{ - return this.readOnly; + return !!this.readOnly; }-*/; /** @@ -410,6 +410,6 @@ * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-usemap">W3C HTML Specification</a> */ public final native boolean useMap() /*-{ - return this.useMap; + return !!this.useMap; }-*/; } Modified: trunk/user/src/com/google/gwt/dom/client/LinkElement.java ============================================================================== --- trunk/user/src/com/google/gwt/dom/client/LinkElement.java (original) +++ trunk/user/src/com/google/gwt/dom/client/LinkElement.java Fri May 15 13:11:37 2009 @@ -41,9 +41,10 @@ /** * Enables/disables the link. This is currently only used for style sheet * links, and may be used to activate or deactivate style sheets. + * @deprecated use {...@link #isDisabled()} instead. */ public final native boolean getDisabled() /*-{ - return this.disabled; + return !!this.disabled; }-*/; /** @@ -99,6 +100,14 @@ 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 boolean isDisabled() /*-{ + return !!this.disabled; + }-*/; /** * Enables/disables the link. This is currently only used for style sheet Modified: trunk/user/src/com/google/gwt/dom/client/OptionElement.java ============================================================================== --- trunk/user/src/com/google/gwt/dom/client/OptionElement.java (original) +++ trunk/user/src/com/google/gwt/dom/client/OptionElement.java Fri May 15 13:11:37 2009 @@ -85,7 +85,7 @@ * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-selected">W3C HTML Specification</a> */ public final native boolean isDefaultSelected() /*-{ - return this.defaultSelected; + return !!this.defaultSelected; }-*/; /** @@ -94,7 +94,7 @@ * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled">W3C HTML Specification</a> */ public final native boolean isDisabled() /*-{ - return this.disabled; + return !!this.disabled; }-*/; /** @@ -104,7 +104,7 @@ * of the element. */ public final native boolean isSelected() /*-{ - return this.selected; + return !!this.selected; }-*/; /** Modified: trunk/user/src/com/google/gwt/dom/client/SelectElement.java ============================================================================== --- trunk/user/src/com/google/gwt/dom/client/SelectElement.java (original) +++ trunk/user/src/com/google/gwt/dom/client/SelectElement.java Fri May 15 13:11:37 2009 @@ -166,7 +166,7 @@ * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-multiple">W3C HTML Specification</a> */ public final native boolean isMultiple() /*-{ - return this.multiple; + return !!this.multiple; }-*/; /** Modified: trunk/user/src/com/google/gwt/dom/client/StyleElement.java ============================================================================== --- trunk/user/src/com/google/gwt/dom/client/StyleElement.java (original) +++ trunk/user/src/com/google/gwt/dom/client/StyleElement.java Fri May 15 13:11:37 2009 @@ -41,9 +41,10 @@ /** * Enables/disables the style sheet. + * @deprecated use {...@link #isDisabled()} instead */ public final native boolean getDisabled() /*-{ - return this.disabled; + return !!this.disabled; }-*/; /** @@ -62,6 +63,13 @@ */ public final native String getType() /*-{ return this.type; + }-*/; + + /** + * Enables/disables the style sheet. + */ + public final native boolean isDisabled() /*-{ + return !!this.disabled; }-*/; /** Modified: trunk/user/src/com/google/gwt/dom/client/TextAreaElement.java ============================================================================== --- trunk/user/src/com/google/gwt/dom/client/TextAreaElement.java (original) +++ trunk/user/src/com/google/gwt/dom/client/TextAreaElement.java Fri May 15 13:11:37 2009 @@ -78,8 +78,11 @@ return this.defaultValue; }-*/; + /** + * @deprecated use {...@link #isDisabled()} instead + */ public final native boolean getDisabled() /*-{ - return this.disabled; + return !!this.disabled; }-*/; /** @@ -99,8 +102,11 @@ return this.name; }-*/; + /** + * @deprecated use {...@link #isReadOnly()} instead. + */ public final native boolean getReadOnly() /*-{ - return this.readOnly; + return !!this.readOnly; }-*/; /** @@ -145,7 +151,7 @@ * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled">W3C HTML Specification</a> */ public final native boolean isDisabled() /*-{ - return this.disabled; + return !!this.disabled; }-*/; /** @@ -154,7 +160,7 @@ * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-readonly">W3C HTML Specification</a> */ public final native boolean isReadOnly() /*-{ - return this.readOnly; + return !!this.readOnly; }-*/; /** Modified: trunk/user/test/com/google/gwt/dom/client/ElementTest.java ============================================================================== --- trunk/user/test/com/google/gwt/dom/client/ElementTest.java (original) +++ trunk/user/test/com/google/gwt/dom/client/ElementTest.java Fri May 15 13:11:37 2009 @@ -68,6 +68,21 @@ } /** + * Test round-trip of the 'disabled' property. + */ + public void testDisabled() { + ButtonElement button = Document.get().createButtonElement(); + assertFalse(button.isDisabled()); + button.setDisabled(true); + assertTrue(button.isDisabled()); + + InputElement input = Document.get().createTextInputElement(); + assertFalse(input.isDisabled()); + input.setDisabled(true); + assertTrue(input.isDisabled()); + } + + /** * [get|set|remove]Attribute. */ public void testElementAttribute() { @@ -196,11 +211,6 @@ }); } - private native boolean isIE() /*-{ - var ua = navigator.userAgent.toLowerCase(); - return ua.indexOf("msie") != -1; - }-*/; - /** * scroll[Left|Top], scrollIntoView. */ @@ -519,5 +529,10 @@ private native JavaScriptObject createTrivialJSO() /*-{ return {}; + }-*/; + + private native boolean isIE() /*-{ + var ua = navigator.userAgent.toLowerCase(); + return ua.indexOf("msie") != -1; }-*/; } --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
