Tuesday, September 13, 2016

Strange (BAD?) code generated

Hi, I have the following code:

public static Vec2i elementSizeToDeviceSize(Element element) {
float devicePixelRatio = devicePixelRatio();
ClientRect rect = GwtNativeUtil.getBoundingClientRect(element);
float x0 = (float) (rect.getLeft() * devicePixelRatio);
float x1 = (float) (rect.getRight() * devicePixelRatio);
float y0 = (float) (rect.getTop() * devicePixelRatio);
float y1 = (float) (rect.getBottom() * devicePixelRatio);

return new Vec2i(Math.round(x1 - x0), Math.round(y1 - y0));
}

GwtNativeUtil.getBoundingClientRect is native JSNI function.

It returns 
  public interface ClientRect extends JSObject 
which has 
  @JsProperty double getLeft();

And the GWT compiler 2.8-rc2 emits the following code:

function hEb(a) {
var b, c, d, e, f;
b = gEb();
a.getBoundingClientRect();
c = null.hf() * b;
d = null.hf() * b;
e = null.hf() * b;
f = null.hf() * b;
return new Tvb(Oj($wnd.Math.round(d - c)), Oj($wnd.Math.round(f - e)))
}



This code is not a valid code. Is this a bug ?  
The compiler did not throw an any message. 

I`m using -Dgwt.style=PRETTY





--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment