I uploaded a patch to rietveld for issue 5998 but until now I did not see it
appear in the GWT-Contributors newsgroup ...
Is that normal ? What did I do wrong ?
Anyway, here is a copy of the message in question. If anybody wants to
review this and hopefully commit it then I would be a happy man. I need this
fix for a project that I am working on (involving using SafeHtml to bulk
render my gui based on XML/Schemas). It really flies, but without this patch
I can not wrap the Image widgets correctly.
Reviewers: jlabanca, rjrjr,
Description:
See:
http://code.google.com/p/google-web-toolkit/issues/detail?id=5998
This http://code.google.com/p/google-web-toolkit/issues/detail?id=5998Thisis
my first patch, so sorry if I did something wrong.
I added a unittest on Image that checks if a subclass can now implement
a wrap method.
Please review this at http://gwt-code-reviews.appspot.com/1370804/
Affected http://gwt-code-reviews.appspot.com/1370804/Affected files:
user/src/com/google/gwt/user/client/ui/Image.java
user/test/com/google/gwt/user/client/ui/ImageTest.java
Index: user/test/com/google/gwt/user/client/ui/ImageTest.java
===
--- user/test/com/google/gwt/user/client/ui/ImageTest.java (revision
9789)
+++ user/test/com/google/gwt/user/client/ui/ImageTest.java (working
copy)
@@ -18,6 +18,7 @@
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ErrorEvent;
import com.google.gwt.event.dom.client.ErrorHandler;
import com.google.gwt.event.dom.client.LoadEvent;
@@ -50,6 +51,25 @@
}
}
+ private static class TestImage extends Image {
+public TestImage( Element element ) {
+ super(element);
+}
+
+public static TestImage wrap( Element element ) {
+ // Assert that the element is attached.
+ assert Document.get().getBody().isOrHasChild(element);
+
+ TestImage image = new TestImage(element);
+
+ // Mark it attached and remember it for cleanup.
+ image.onAttach();
+ RootPanel.detachOnWindowClose(image);
+
+ return image;
+}
+ }
+
private abstract static class TestLoadHandler implements LoadHandler {
private boolean finished = false;
@@ -581,7 +601,21 @@
assertEquals(16, image.getHeight());
assertEquals(clipped, getCurrentImageStateName(image));
}
+
+ /**
+ * Tests that it is possible to make a subclass of Image that can be
wrapped.
+ */
+ public void testWrapOfSubclass() {
+String uid = Document.get().createUniqueId();
+DivElement div = Document.get().createDivElement();
+div.setInnerHTML(img id=' + uid + ' src='counting-forward.png');
+Document.get().getBody().appendChild(div);
+final TestImage image =
TestImage.wrap(Document.get().getElementById(uid));
+
+assertNotNull(image);
+ }
+
private void assertResourceWorked(Image image, ImageResource prettyPiccy)
{
assertEquals(prettyPiccy.getURL(), image.getUrl());
assertEquals(prettyPiccy.getTop(), image.getOriginTop());
Index: user/src/com/google/gwt/user/client/ui/Image.java
===
--- user/src/com/google/gwt/user/client/ui/Image.java (revision 9789)
+++ user/src/com/google/gwt/user/client/ui/Image.java (working copy)
@@ -409,8 +409,6 @@
assert Document.get().getBody().isOrHasChild(element);
Image image = new Image(element);
-image.changeState(new UnclippedState(element));
-
// Mark it attached and remember it for cleanup.
image.onAttach();
RootPanel.detachOnWindowClose(image);
@@ -481,6 +479,7 @@
protected Image(Element element) {
ImageElement.as(element);
setElement(element);
+changeState(new UnclippedState(element));
}
public HandlerRegistration addClickHandler(ClickHandler handler) {
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors