Matthew Dempsky has uploaded a new change for review.
https://gwt-review.googlesource.com/2663
Change subject: Add more SafeUri overloads for existing methods
......................................................................
Add more SafeUri overloads for existing methods
Change-Id: I8ab7a472b0c0c4470f00f7178de216f7c7e4e415
---
M tools/api-checker/config/gwt25_26userApi.conf
M user/src/com/google/gwt/dom/builder/client/DomAnchorBuilder.java
M user/src/com/google/gwt/dom/builder/client/DomAreaBuilder.java
M user/src/com/google/gwt/dom/builder/client/DomBaseBuilder.java
M user/src/com/google/gwt/dom/builder/client/DomLinkBuilder.java
M user/src/com/google/gwt/dom/builder/shared/AnchorBuilder.java
M user/src/com/google/gwt/dom/builder/shared/AreaBuilder.java
M user/src/com/google/gwt/dom/builder/shared/BaseBuilder.java
M user/src/com/google/gwt/dom/builder/shared/HtmlAnchorBuilder.java
M user/src/com/google/gwt/dom/builder/shared/HtmlAreaBuilder.java
M user/src/com/google/gwt/dom/builder/shared/HtmlBaseBuilder.java
M user/src/com/google/gwt/dom/builder/shared/HtmlLinkBuilder.java
M user/src/com/google/gwt/dom/builder/shared/LinkBuilder.java
M user/src/com/google/gwt/dom/client/AreaElement.java
M user/src/com/google/gwt/dom/client/BaseElement.java
M user/src/com/google/gwt/dom/client/LinkElement.java
M user/src/com/google/gwt/user/client/ui/Anchor.java
17 files changed, 202 insertions(+), 2 deletions(-)
diff --git a/tools/api-checker/config/gwt25_26userApi.conf
b/tools/api-checker/config/gwt25_26userApi.conf
index ce95c2e..e52943d 100644
--- a/tools/api-checker/config/gwt25_26userApi.conf
+++ b/tools/api-checker/config/gwt25_26userApi.conf
@@ -154,3 +154,10 @@
# Split BaseListenerWrapper
com.google.gwt.user.client.BaseListenerWrapper::getSource(Lcom/google/gwt/event/shared/GwtEvent;)
MISSING
com.google.gwt.user.client.BaseListenerWrapper::setSource(Lcom/google/gwt/user/client/ui/Widget;)
MISSING
+
+# Add SafeUri variants of more existing String methods.
+com.google.gwt.user.client.ui.Anchor::setHref(Ljava/lang/String;)
OVERLOADED_METHOD_CALL
+com.google.gwt.dom.builder.shared.AnchorBuilder::href(Ljava/lang/String;)
OVERLOADED_METHOD_CALL
+com.google.gwt.dom.builder.shared.AreaBuilder::href(Ljava/lang/String;)
OVERLOADED_METHOD_CALL
+com.google.gwt.dom.builder.shared.BaseBuilder(Ljava/lang/String;)
OVERLOADED_METHOD_CALL
+com.google.gwt.dom.builder.shared.LinkBuilder(Ljava/lang/String;)
OVERLOADED_METHOD_CALL
diff --git
a/user/src/com/google/gwt/dom/builder/client/DomAnchorBuilder.java
b/user/src/com/google/gwt/dom/builder/client/DomAnchorBuilder.java
index b290670..0da4b47 100644
--- a/user/src/com/google/gwt/dom/builder/client/DomAnchorBuilder.java
+++ b/user/src/com/google/gwt/dom/builder/client/DomAnchorBuilder.java
@@ -17,6 +17,7 @@
import com.google.gwt.dom.builder.shared.AnchorBuilder;
import com.google.gwt.dom.client.AnchorElement;
+import com.google.gwt.safehtml.shared.SafeUri;
/**
* DOM-based implementation of {@link AnchorBuilder}.
@@ -35,6 +36,12 @@
}
@Override
+ public AnchorBuilder href(SafeUri href) {
+ assertCanAddAttribute().setSafeHref(href);
+ return this;
+ }
+
+ @Override
public AnchorBuilder href(String href) {
assertCanAddAttribute().setHref(href);
return this;
diff --git a/user/src/com/google/gwt/dom/builder/client/DomAreaBuilder.java
b/user/src/com/google/gwt/dom/builder/client/DomAreaBuilder.java
index 417eeeb..eb127bf 100644
--- a/user/src/com/google/gwt/dom/builder/client/DomAreaBuilder.java
+++ b/user/src/com/google/gwt/dom/builder/client/DomAreaBuilder.java
@@ -17,6 +17,7 @@
import com.google.gwt.dom.builder.shared.AreaBuilder;
import com.google.gwt.dom.client.AreaElement;
+import com.google.gwt.safehtml.shared.SafeUri;
/**
* DOM-based implementation of {@link AreaBuilder}.
@@ -47,6 +48,12 @@
}
@Override
+ public AreaBuilder href(SafeUri href) {
+ assertCanAddAttribute().setSafeHref(href);
+ return this;
+ }
+
+ @Override
public AreaBuilder href(String href) {
assertCanAddAttribute().setHref(href);
return this;
diff --git a/user/src/com/google/gwt/dom/builder/client/DomBaseBuilder.java
b/user/src/com/google/gwt/dom/builder/client/DomBaseBuilder.java
index 07e001e..0be64db 100644
--- a/user/src/com/google/gwt/dom/builder/client/DomBaseBuilder.java
+++ b/user/src/com/google/gwt/dom/builder/client/DomBaseBuilder.java
@@ -17,6 +17,7 @@
import com.google.gwt.dom.builder.shared.BaseBuilder;
import com.google.gwt.dom.client.BaseElement;
+import com.google.gwt.safehtml.shared.SafeUri;
/**
* DOM-based implementation of {@link BaseBuilder}.
@@ -29,6 +30,12 @@
}
@Override
+ public BaseBuilder href(SafeUri href) {
+ assertCanAddAttribute().setSafeHref(href);
+ return this;
+ }
+
+ @Override
public BaseBuilder href(String href) {
assertCanAddAttribute().setHref(href);
return this;
diff --git a/user/src/com/google/gwt/dom/builder/client/DomLinkBuilder.java
b/user/src/com/google/gwt/dom/builder/client/DomLinkBuilder.java
index 8476db8..5a77fbb 100644
--- a/user/src/com/google/gwt/dom/builder/client/DomLinkBuilder.java
+++ b/user/src/com/google/gwt/dom/builder/client/DomLinkBuilder.java
@@ -17,6 +17,7 @@
import com.google.gwt.dom.builder.shared.LinkBuilder;
import com.google.gwt.dom.client.LinkElement;
+import com.google.gwt.safehtml.shared.SafeUri;
/**
* DOM-based implementation of {@link LinkBuilder}.
@@ -35,6 +36,12 @@
}
@Override
+ public LinkBuilder href(SafeUri href) {
+ assertCanAddAttribute().setSafeHref(href);
+ return this;
+ }
+
+ @Override
public LinkBuilder href(String href) {
assertCanAddAttribute().setHref(href);
return this;
diff --git a/user/src/com/google/gwt/dom/builder/shared/AnchorBuilder.java
b/user/src/com/google/gwt/dom/builder/shared/AnchorBuilder.java
index f26ad97..28f057d 100644
--- a/user/src/com/google/gwt/dom/builder/shared/AnchorBuilder.java
+++ b/user/src/com/google/gwt/dom/builder/shared/AnchorBuilder.java
@@ -15,6 +15,8 @@
*/
package com.google.gwt.dom.builder.shared;
+import com.google.gwt.safehtml.shared.SafeUri;
+
/**
* Builds an anchor element.
*/
@@ -36,6 +38,15 @@
*
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href">W3C
* HTML Specification</a>
*/
+ AnchorBuilder href(SafeUri href);
+
+ /**
+ * The absolute URI of the linked resource.
+ *
+ * @see <a
+ *
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href">W3C
+ * HTML Specification</a>
+ */
AnchorBuilder href(String href);
/**
diff --git a/user/src/com/google/gwt/dom/builder/shared/AreaBuilder.java
b/user/src/com/google/gwt/dom/builder/shared/AreaBuilder.java
index 3095dbc..f59968a 100644
--- a/user/src/com/google/gwt/dom/builder/shared/AreaBuilder.java
+++ b/user/src/com/google/gwt/dom/builder/shared/AreaBuilder.java
@@ -15,6 +15,8 @@
*/
package com.google.gwt.dom.builder.shared;
+import com.google.gwt.safehtml.shared.SafeUri;
+
/**
* Builds an area element.
*/
@@ -56,6 +58,15 @@
*
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href">W3C
* HTML Specification</a>
*/
+ AreaBuilder href(SafeUri href);
+
+ /**
+ * The URI of the linked resource.
+ *
+ * @see <a
+ *
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href">W3C
+ * HTML Specification</a>
+ */
AreaBuilder href(String href);
/**
diff --git a/user/src/com/google/gwt/dom/builder/shared/BaseBuilder.java
b/user/src/com/google/gwt/dom/builder/shared/BaseBuilder.java
index 5bbb90b..a4615f2 100644
--- a/user/src/com/google/gwt/dom/builder/shared/BaseBuilder.java
+++ b/user/src/com/google/gwt/dom/builder/shared/BaseBuilder.java
@@ -15,6 +15,8 @@
*/
package com.google.gwt.dom.builder.shared;
+import com.google.gwt.safehtml.shared.SafeUri;
+
/**
* Builds an base element.
*/
@@ -27,6 +29,15 @@
*
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href-BASE">W3C
* HTML Specification</a>
*/
+ BaseBuilder href(SafeUri href);
+
+ /**
+ * The base URI See the href attribute definition in HTML 4.01.
+ *
+ * @see <a
+ *
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href-BASE">W3C
+ * HTML Specification</a>
+ */
BaseBuilder href(String href);
/**
diff --git
a/user/src/com/google/gwt/dom/builder/shared/HtmlAnchorBuilder.java
b/user/src/com/google/gwt/dom/builder/shared/HtmlAnchorBuilder.java
index bc5dc7b..759cec4 100644
--- a/user/src/com/google/gwt/dom/builder/shared/HtmlAnchorBuilder.java
+++ b/user/src/com/google/gwt/dom/builder/shared/HtmlAnchorBuilder.java
@@ -15,6 +15,8 @@
*/
package com.google.gwt.dom.builder.shared;
+import com.google.gwt.safehtml.shared.SafeUri;
+
/**
* HTML-based implementation of {@link AnchorBuilder}.
*/
@@ -31,6 +33,11 @@
}
@Override
+ public AnchorBuilder href(SafeUri href) {
+ return href(href.asString());
+ }
+
+ @Override
public AnchorBuilder href(String href) {
return trustedAttribute("href", href);
}
diff --git
a/user/src/com/google/gwt/dom/builder/shared/HtmlAreaBuilder.java
b/user/src/com/google/gwt/dom/builder/shared/HtmlAreaBuilder.java
index d821e28..dc22dc0 100644
--- a/user/src/com/google/gwt/dom/builder/shared/HtmlAreaBuilder.java
+++ b/user/src/com/google/gwt/dom/builder/shared/HtmlAreaBuilder.java
@@ -15,6 +15,8 @@
*/
package com.google.gwt.dom.builder.shared;
+import com.google.gwt.safehtml.shared.SafeUri;
+
/**
* HTML-based implementation of {@link AreaBuilder}.
*/
@@ -40,6 +42,11 @@
}
@Override
+ public AreaBuilder href(SafeUri href) {
+ return href(href.asString());
+ }
+
+ @Override
public AreaBuilder href(String href) {
return trustedAttribute("href", href);
}
diff --git
a/user/src/com/google/gwt/dom/builder/shared/HtmlBaseBuilder.java
b/user/src/com/google/gwt/dom/builder/shared/HtmlBaseBuilder.java
index 4e8beda..28562d8 100644
--- a/user/src/com/google/gwt/dom/builder/shared/HtmlBaseBuilder.java
+++ b/user/src/com/google/gwt/dom/builder/shared/HtmlBaseBuilder.java
@@ -15,6 +15,8 @@
*/
package com.google.gwt.dom.builder.shared;
+import com.google.gwt.safehtml.shared.SafeUri;
+
/**
* HTML-based implementation of {@link BaseBuilder}.
*/
@@ -25,6 +27,11 @@
}
@Override
+ public BaseBuilder href(SafeUri href) {
+ return href(href.asString());
+ }
+
+ @Override
public BaseBuilder href(String href) {
return trustedAttribute("href", href);
}
diff --git
a/user/src/com/google/gwt/dom/builder/shared/HtmlLinkBuilder.java
b/user/src/com/google/gwt/dom/builder/shared/HtmlLinkBuilder.java
index 79ff254..3cffc7b 100644
--- a/user/src/com/google/gwt/dom/builder/shared/HtmlLinkBuilder.java
+++ b/user/src/com/google/gwt/dom/builder/shared/HtmlLinkBuilder.java
@@ -15,6 +15,8 @@
*/
package com.google.gwt.dom.builder.shared;
+import com.google.gwt.safehtml.shared.SafeUri;
+
/**
* HTML-based implementation of {@link LinkBuilder}.
*/
@@ -30,6 +32,11 @@
}
@Override
+ public LinkBuilder href(SafeUri href) {
+ return href(href.asString());
+ }
+
+ @Override
public LinkBuilder href(String href) {
return trustedAttribute("href", href);
}
diff --git a/user/src/com/google/gwt/dom/builder/shared/LinkBuilder.java
b/user/src/com/google/gwt/dom/builder/shared/LinkBuilder.java
index c0848db..84a5dc6 100644
--- a/user/src/com/google/gwt/dom/builder/shared/LinkBuilder.java
+++ b/user/src/com/google/gwt/dom/builder/shared/LinkBuilder.java
@@ -15,6 +15,8 @@
*/
package com.google.gwt.dom.builder.shared;
+import com.google.gwt.safehtml.shared.SafeUri;
+
/**
* Builds an link element.
*/
@@ -33,6 +35,15 @@
*
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href">W3C
* HTML Specification</a>
*/
+ LinkBuilder href(SafeUri href);
+
+ /**
+ * The URI of the linked resource.
+ *
+ * @see <a
+ *
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href">W3C
+ * HTML Specification</a>
+ */
LinkBuilder href(String href);
/**
diff --git a/user/src/com/google/gwt/dom/client/AreaElement.java
b/user/src/com/google/gwt/dom/client/AreaElement.java
index af2fe3a..f752ad6 100644
--- a/user/src/com/google/gwt/dom/client/AreaElement.java
+++ b/user/src/com/google/gwt/dom/client/AreaElement.java
@@ -15,6 +15,8 @@
*/
package com.google.gwt.dom.client;
+import com.google.gwt.safehtml.shared.SafeUri;
+
/**
* Client-side image map area definition.
*
@@ -132,6 +134,15 @@
}-*/;
/**
+ * The URI of the linked resource.
+ *
+ * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href">W3C
HTML Specification</a>
+ */
+ public final void setSafeHref(SafeUri href) {
+ setHref(href.asString());
+ }
+
+ /**
* The shape of the active area. The coordinates are given by coords.
*
* @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-shape">W3C
HTML Specification</a>
diff --git a/user/src/com/google/gwt/dom/client/BaseElement.java
b/user/src/com/google/gwt/dom/client/BaseElement.java
index 2bbea53..5acff09 100644
--- a/user/src/com/google/gwt/dom/client/BaseElement.java
+++ b/user/src/com/google/gwt/dom/client/BaseElement.java
@@ -15,6 +15,8 @@
*/
package com.google.gwt.dom.client;
+import com.google.gwt.safehtml.shared.SafeUri;
+
/**
* Document base URI.
*
@@ -38,7 +40,7 @@
}
/**
- * The base URI See the href attribute definition in HTML
+ * The base URI. See the href attribute definition in HTML
* 4.01.
*
* @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href-BASE">W3C
HTML Specification</a>
@@ -57,7 +59,7 @@
}-*/;
/**
- * The base URI See the href attribute definition in HTML
+ * The base URI. See the href attribute definition in HTML
* 4.01.
*
* @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href-BASE">W3C
HTML Specification</a>
@@ -67,6 +69,16 @@
}-*/;
/**
+ * The base URI. See the href attribute definition in HTML
+ * 4.01.
+ *
+ * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href-BASE">W3C
HTML Specification</a>
+ */
+ public final void setSafeHref(SafeUri href) {
+ setHref(href.asString());
+ }
+
+ /**
* The default target frame.
*
* @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-target">W3C
HTML Specification</a>
diff --git a/user/src/com/google/gwt/dom/client/LinkElement.java
b/user/src/com/google/gwt/dom/client/LinkElement.java
index e93e529..7a6f813 100644
--- a/user/src/com/google/gwt/dom/client/LinkElement.java
+++ b/user/src/com/google/gwt/dom/client/LinkElement.java
@@ -15,6 +15,8 @@
*/
package com.google.gwt.dom.client;
+import com.google.gwt.safehtml.shared.SafeUri;
+
/**
* The LINK element specifies a link to an external resource, and defines
this
* document's relationship to that resource (or vice versa).
@@ -128,6 +130,15 @@
}-*/;
/**
+ * The URI of the linked resource.
+ *
+ * @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-href">W3C
HTML Specification</a>
+ */
+ public final void setSafeHref(SafeUri href) {
+ setHref(href.asString());
+ }
+
+ /**
* Language code of the linked resource.
*
* @see <a
href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#adef-hreflang">W3C
HTML Specification</a>
diff --git a/user/src/com/google/gwt/user/client/ui/Anchor.java
b/user/src/com/google/gwt/user/client/ui/Anchor.java
index 41816df..8ca0735 100644
--- a/user/src/com/google/gwt/user/client/ui/Anchor.java
+++ b/user/src/com/google/gwt/user/client/ui/Anchor.java
@@ -24,6 +24,7 @@
import com.google.gwt.i18n.shared.DirectionEstimator;
import com.google.gwt.i18n.shared.HasDirectionEstimator;
import com.google.gwt.safehtml.shared.SafeHtml;
+import com.google.gwt.safehtml.shared.SafeUri;
/**
* A widget that represents a simple <a> element.
@@ -224,6 +225,16 @@
}
/**
+ * Creates an anchor with its html and href (target URL) specified.
+ *
+ * @param html the anchor's html
+ * @param href the url to which it will link
+ */
+ public Anchor(SafeHtml html, SafeUri href) {
+ this(html.asString(), true, href.asString());
+ }
+
+ /**
* Creates an anchor with its html and href (target URL) specified.
*
* @param html the anchor's html
@@ -238,6 +249,17 @@
* Creates an anchor with its html and href (target URL) specified.
*
* @param html the anchor's html
+ * @param dir the html's direction
+ * @param href the url to which it will link
+ */
+ public Anchor(SafeHtml html, Direction dir, SafeUri href) {
+ this(html.asString(), true, dir, href.asString());
+ }
+
+ /**
+ * Creates an anchor with its html and href (target URL) specified.
+ *
+ * @param html the anchor's html
* @param directionEstimator A DirectionEstimator object used for
automatic
* direction adjustment. For convenience,
* {@link #DEFAULT_DIRECTION_ESTIMATOR} can be used.
@@ -246,6 +268,20 @@
public Anchor(SafeHtml html, DirectionEstimator directionEstimator,
String href) {
this(html.asString(), true, directionEstimator, href);
+ }
+
+ /**
+ * Creates an anchor with its html and href (target URL) specified.
+ *
+ * @param html the anchor's html
+ * @param directionEstimator A DirectionEstimator object used for
automatic
+ * direction adjustment. For convenience,
+ * {@link #DEFAULT_DIRECTION_ESTIMATOR} can be used.
+ * @param href the url to which it will link
+ */
+ public Anchor(SafeHtml html, DirectionEstimator directionEstimator,
+ SafeUri href) {
+ this(html.asString(), true, directionEstimator, href.asString());
}
/**
@@ -308,6 +344,20 @@
*/
public Anchor(SafeHtml html, String href, String target) {
this(html.asString(), true, href, target);
+ }
+
+ /**
+ * Creates a source anchor (link to URI).
+ *
+ * That is, an anchor with an href attribute specifying the destination
URI.
+ *
+ * @param html the anchor's html
+ * @param href the url to which it will link
+ * @param target the target frame (e.g. "_blank" to open the link in a
new
+ * window)
+ */
+ public Anchor(SafeHtml html, SafeUri href, String target) {
+ this(html.asString(), true, href.asString(), target);
}
/**
@@ -506,6 +556,15 @@
*
* @param href the anchor's href
*/
+ public void setHref(SafeUri href) {
+ getAnchorElement().setSafeHref(href);
+ }
+
+ /**
+ * Sets the anchor's href (the url to which it links).
+ *
+ * @param href the anchor's href
+ */
public void setHref(String href) {
getAnchorElement().setHref(href);
}
--
To view, visit https://gwt-review.googlesource.com/2663
To unsubscribe, visit https://gwt-review.googlesource.com/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ab7a472b0c0c4470f00f7178de216f7c7e4e415
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Matthew Dempsky <[email protected]>
--
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
---
You received this message because you are subscribed to the Google Groups "Google Web Toolkit Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.