John Ahlroos has uploaded a new change for review.

  https://gwt-review.googlesource.com/3090


Change subject: Ensures integer pixel values and adds getters for subpixel values
......................................................................

Ensures integer pixel values and adds getters for subpixel values

Newer browsers are returning pixel values as doubles instead of
integers especially when using zooming. This is causing problems where
existing code is assuming integer values are returned and getting
doubles instead.

To fix this this patch introduces subpixel variants of most DOM
methods dealing with pixels and makes sure the existing methods
are returning only valid integers by 'x|0' them.

Issue: http://code.google.com/p/google-web-toolkit/issues/detail?id=6130
Change-Id: I27e98f0ad3c1c236b2d85d24f197719fa4cd352a
Rietveld: http://gwt-code-reviews.appspot.com/1815803
---
M user/src/com/google/gwt/dom/client/DOMImpl.java
M user/src/com/google/gwt/dom/client/DOMImplIE6.java
M user/src/com/google/gwt/dom/client/DOMImplIE8.java
M user/src/com/google/gwt/dom/client/DOMImplIE9.java
M user/src/com/google/gwt/dom/client/DOMImplMozilla.java
M user/src/com/google/gwt/dom/client/DOMImplOpera.java
M user/src/com/google/gwt/dom/client/DOMImplStandard.java
M user/src/com/google/gwt/dom/client/DOMImplStandardBase.java
M user/src/com/google/gwt/dom/client/DOMImplTrident.java
M user/src/com/google/gwt/dom/client/Element.java
M user/src/com/google/gwt/dom/client/NativeEvent.java
11 files changed, 377 insertions(+), 150 deletions(-)



diff --git a/user/src/com/google/gwt/dom/client/DOMImpl.java b/user/src/com/google/gwt/dom/client/DOMImpl.java
index 56f1450..ddbc8aa 100644
--- a/user/src/com/google/gwt/dom/client/DOMImpl.java
+++ b/user/src/com/google/gwt/dom/client/DOMImpl.java
@@ -68,8 +68,8 @@
       int charCode);

   public abstract NativeEvent createMouseEvent(Document doc, String type,
-      boolean canBubble, boolean cancelable, int detail, int screenX,
- int screenY, int clientX, int clientY, boolean ctrlKey, boolean altKey,
+      boolean canBubble, boolean cancelable, int detail, double screenX,
+ double screenY, double clientX, double clientY, boolean ctrlKey, boolean altKey, boolean shiftKey, boolean metaKey, int button, Element relatedTarget);

   public ScriptElement createScriptElement(Document doc, String source) {
@@ -110,13 +110,13 @@

   public abstract int eventGetCharCode(NativeEvent evt);

-  public native int eventGetClientX(NativeEvent evt) /*-{
-    return evt.clientX || 0;
-  }-*/;
+  public final int eventGetClientX(NativeEvent evt) {
+    return (int) eventGetSubpixelClientX(evt) | 0;
+  }

-  public native int eventGetClientY(NativeEvent evt) /*-{
-    return evt.clientY || 0;
-  }-*/;
+  public final int eventGetClientY(NativeEvent evt) {
+    return (int) eventGetSubpixelClientY(evt) | 0;
+  }

   public native boolean eventGetCtrlKey(NativeEvent evt) /*-{
     return !!evt.ctrlKey;
@@ -146,16 +146,32 @@
     return evt.scale;
   }-*/;

-  public native int eventGetScreenX(NativeEvent evt) /*-{
-    return evt.screenX || 0;
-  }-*/;
+  public final int eventGetScreenX(NativeEvent evt) {
+    return (int) eventGetSubpixelScreenX(evt) | 0;
+  }

-  public native int eventGetScreenY(NativeEvent evt) /*-{
-    return evt.screenY || 0;
-  }-*/;
+  public final int eventGetScreenY(NativeEvent evt) {
+    return (int) eventGetSubpixelScreenY(evt) | 0;
+  }

   public native boolean eventGetShiftKey(NativeEvent evt) /*-{
     return !!evt.shiftKey;
+  }-*/;
+
+  public native double eventGetSubpixelClientX(NativeEvent evt) /*-{
+    return evt.clientX || 0;
+  }-*/;
+
+  public native double eventGetSubpixelClientY(NativeEvent evt) /*-{
+    return evt.clientY || 0;
+  }-*/;
+
+  public native double eventGetSubpixelScreenX(NativeEvent evt) /*-{
+    return evt.screenX || 0;
+  }-*/;
+
+  public native double eventGetSubpixelScreenY(NativeEvent evt) /*-{
+    return evt.screenY || 0;
   }-*/;

   public abstract EventTarget eventGetTarget(NativeEvent evt);
@@ -176,47 +192,25 @@

   public abstract String eventToString(NativeEvent evt);

-  public native int getAbsoluteLeft(Element elem) /*-{
-    var left = 0;
-    var curr = elem;
-    // This intentionally excludes body which has a null offsetParent.
-    while (curr.offsetParent) {
-      left -= curr.scrollLeft;
-      curr = curr.parentNode;
-    }
-    while (elem) {
-      left += elem.offsetLeft;
-      elem = elem.offsetParent;
-    }
-    return left;
-  }-*/;
+  public final int getAbsoluteLeft(Element elem) {
+    return (int) getSubpixelAbsoluteLeft(elem) | 0;
+  }

-  public native int getAbsoluteTop(Element elem) /*-{
-    var top = 0;
-    var curr = elem;
-    // This intentionally excludes body which has a null offsetParent.
-    while (curr.offsetParent) {
-      top -= curr.scrollTop;
-      curr = curr.parentNode;
-    }
-    while (elem) {
-      top += elem.offsetTop;
-      elem = elem.offsetParent;
-    }
-    return top;
-  }-*/;
+  public final int getAbsoluteTop(Element elem) {
+    return (int) getSubpixelAbsoluteTop(elem) | 0;
+  }

   public native String getAttribute(Element elem, String name) /*-{
     return elem.getAttribute(name) || '';
   }-*/;

-  public native int getBodyOffsetLeft(Document doc) /*-{
-    return 0;
-  }-*/;
+  public final int getBodyOffsetLeft(Document doc) {
+    return (int) getSubpixelBodyOffsetLeft(doc) | 0;
+  }

-  public native int getBodyOffsetTop(Document doc) /*-{
-    return 0;
-  }-*/;
+  public final int getBodyOffsetTop(Document doc) {
+    return (int) getSubpixelBodyOffsetTop(doc) | 0;
+  }

   public native JsArray<Touch> getChangedTouches(NativeEvent evt) /*-{
     return evt.changedTouches;
@@ -283,21 +277,71 @@
     return sib;
   }-*/;

-  public int getScrollLeft(Document doc) {
-    return doc.getViewportElement().getScrollLeft();
+  public final int getScrollLeft(Document doc) {
+    return (int) getSubpixelScrollLeft(doc) | 0;
   }

-  public native int getScrollLeft(Element elem) /*-{
-    return elem.scrollLeft || 0;
-  }-*/;
+  public final int getScrollLeft(Element elem) {
+    return (int) getSubpixelScrollLeft(elem) | 0;
+  }

-  public int getScrollTop(Document doc) {
-    return doc.getViewportElement().getScrollTop();
+  public final int getScrollTop(Document doc) {
+    return (int) getSubpixelScrollTop(doc) | 0;
   }

   public native String getStyleProperty(Style style, String name) /*-{
     return style[name];
   }-*/;
+
+  public native double getSubpixelAbsoluteLeft(Element elem) /*-{
+    var left = 0;
+    var curr = elem;
+    // This intentionally excludes body which has a null offsetParent.
+    while (curr.offsetParent) {
+      left -= curr.scrollLeft;
+      curr = curr.parentNode;
+    }
+    while (elem) {
+      left += elem.offsetLeft;
+      elem = elem.offsetParent;
+    }
+    return left;
+  }-*/;
+
+  public native double getSubpixelAbsoluteTop(Element elem) /*-{
+    var top = 0;
+    var curr = elem;
+    // This intentionally excludes body which has a null offsetParent.
+    while (curr.offsetParent) {
+      top -= curr.scrollTop;
+      curr = curr.parentNode;
+    }
+    while (elem) {
+      top += elem.offsetTop;
+      elem = elem.offsetParent;
+    }
+    return top;
+  }-*/;
+
+  public native double getSubpixelBodyOffsetLeft(Document doc) /*-{
+    return 0;
+  }-*/;
+
+  public native double getSubpixelBodyOffsetTop(Document doc) /*-{
+    return 0;
+  }-*/;
+
+  public double getSubpixelScrollLeft(Document doc) {
+    return doc.getViewportElement().getSubpixelScrollLeft();
+  }
+
+  public native double getSubpixelScrollLeft(Element elem) /*-{
+    return elem.scrollLeft || 0;
+  }-*/;
+
+  public double getSubpixelScrollTop(Document doc) {
+    return doc.getViewportElement().getSubpixelScrollTop();
+  }

   public native int getTabIndex(Element elem) /*-{
     return elem.tabIndex;
@@ -417,31 +461,55 @@
     return elem.outerHTML;
   }-*/;

-  public native int touchGetClientX(Touch touch)/*-{
-    return touch.clientX;
-  }-*/;
+  public final int touchGetClientX(Touch touch) {
+    return (int) touchGetSubpixelClientX(touch) | 0;
+  }

-  public native int touchGetClientY(Touch touch)/*-{
-    return touch.clientY;
-  }-*/;
+  public final int touchGetClientY(Touch touch) {
+    return (int) touchGetSubpixelClientY(touch) | 0;
+  }

   public native int touchGetIdentifier(Touch touch)/*-{
     return touch.identifier;
   }-*/;

-  public native int touchGetPageX(Touch touch)/*-{
+  public final int touchGetPageX(Touch touch) {
+    return (int) touchGetSubpixelPageX(touch) | 0;
+  }
+
+  public final int touchGetPageY(Touch touch) {
+    return (int) touchGetSubpixelPageY(touch) | 0;
+  }
+
+  public final int touchGetScreenX(Touch touch) {
+    return (int) touchGetSubpixelScreenX(touch) | 0;
+  }
+
+  public final int touchGetScreenY(Touch touch) {
+    return (int) touchGetSubpixelScreenY(touch) | 0;
+  }
+
+  public native double touchGetSubpixelClientX(Touch touch)/*-{
+    return touch.clientX;
+  }-*/;
+
+  public native double touchGetSubpixelClientY(Touch touch)/*-{
+    return touch.clientY;
+  }-*/;
+
+  public native double touchGetSubpixelPageX(Touch touch)/*-{
     return touch.pageX;
   }-*/;

-  public native int touchGetPageY(Touch touch)/*-{
+  public native double touchGetSubpixelPageY(Touch touch)/*-{
     return touch.pageY;
   }-*/;

-  public native int touchGetScreenX(Touch touch)/*-{
+  public native double touchGetSubpixelScreenX(Touch touch)/*-{
     return touch.screenX;
   }-*/;

-  public native int touchGetScreenY(Touch touch)/*-{
+  public native double touchGetSubpixelScreenY(Touch touch)/*-{
     return touch.screenY;
   }-*/;

diff --git a/user/src/com/google/gwt/dom/client/DOMImplIE6.java b/user/src/com/google/gwt/dom/client/DOMImplIE6.java
index 843f931..6f0b60d 100644
--- a/user/src/com/google/gwt/dom/client/DOMImplIE6.java
+++ b/user/src/com/google/gwt/dom/client/DOMImplIE6.java
@@ -71,21 +71,21 @@
   }-*/;

   @Override
-  public int getAbsoluteLeft(Element elem) {
+  public double getSubpixelAbsoluteLeft(Element elem) {
     Document doc = elem.getOwnerDocument();
-    return (int) Math.floor(getBoundingClientRectLeft(elem)
+    return Math.floor(getBoundingClientRectLeft(elem)
         / getZoomMultiple(doc) + doc.getScrollLeft());
   }

   @Override
-  public int getAbsoluteTop(Element elem) {
+  public double getSubpixelAbsoluteTop(Element elem) {
     Document doc = elem.getOwnerDocument();
-    return (int) Math.floor(getBoundingClientRectTop(elem)
+    return Math.floor(getBoundingClientRectTop(elem)
         / getZoomMultiple(doc) + doc.getScrollTop());
   }

   @Override
-  public int getScrollLeft(Element elem) {
+  public double getSubpixelScrollLeft(Element elem) {
     if (isRTL(elem)) {
return super.getScrollLeft(elem) - (elem.getScrollWidth() - elem.getClientWidth());
     }
diff --git a/user/src/com/google/gwt/dom/client/DOMImplIE8.java b/user/src/com/google/gwt/dom/client/DOMImplIE8.java
index 1772c44..b904057 100644
--- a/user/src/com/google/gwt/dom/client/DOMImplIE8.java
+++ b/user/src/com/google/gwt/dom/client/DOMImplIE8.java
@@ -62,19 +62,19 @@
   }

   @Override
-  public int getAbsoluteLeft(Element elem) {
+  public double getSubpixelAbsoluteLeft(Element elem) {
     Document doc = elem.getOwnerDocument();
     return getBoundingClientRectLeft(elem) + doc.getScrollLeft();
   }

   @Override
-  public int getAbsoluteTop(Element elem) {
+  public double getSubpixelAbsoluteTop(Element elem) {
     Document doc = elem.getOwnerDocument();
     return getBoundingClientRectTop(elem) + doc.getScrollTop();
   }

   @Override
-  public int getScrollLeft(Element elem) {
+  public double getSubpixelScrollLeft(Element elem) {
     if (isRTL(elem)) {
// IE8 returns increasingly *positive* values as you scroll left in RTL.
       return -super.getScrollLeft(elem);
diff --git a/user/src/com/google/gwt/dom/client/DOMImplIE9.java b/user/src/com/google/gwt/dom/client/DOMImplIE9.java
index 6564bb2..2272ff4 100644
--- a/user/src/com/google/gwt/dom/client/DOMImplIE9.java
+++ b/user/src/com/google/gwt/dom/client/DOMImplIE9.java
@@ -21,8 +21,8 @@
 class DOMImplIE9 extends DOMImplStandardBase {

   @Override
-  public int getAbsoluteLeft(Element elem) {
- int left = getBoundingClientRectLeft(elem) + getDocumentScrollLeftImpl();
+  public double getSubpixelAbsoluteLeft(Element elem) {
+ double left = getBoundingClientRectLeft(elem) + getDocumentScrollLeftImpl(); if (isRTL(elem)) { // in RTL, account for the scroll bar shift if present
       left += getParentOffsetDelta(elem);
     }
@@ -30,7 +30,7 @@
   }

   @Override
-  public int getAbsoluteTop(Element elem) {
+  public double getSubpixelAbsoluteTop(Element elem) {
     return getBoundingClientRectTop(elem) + getDocumentScrollTopImpl();
   }

@@ -44,13 +44,13 @@
   }-*/;

   @Override
-  public int getScrollLeft(Document doc) {
+  public double getSubpixelScrollLeft(Document doc) {
     return getDocumentScrollLeftImpl();
   }

   @Override
-  public int getScrollLeft(Element elem) {
-    int left = getScrollLeftImpl(elem);
+  public double getSubpixelScrollLeft(Element elem) {
+    double left = getScrollLeftImpl(elem);
     if (isRTL(elem)) {
       left = -left;
     }
@@ -58,7 +58,7 @@
   }

   @Override
-  public int getScrollTop(Document doc) {
+  public double getSubpixelScrollTop(Document doc) {
     return getDocumentScrollTopImpl();
   }

@@ -95,7 +95,7 @@
// getBoundingClientRect() throws a JS exception if the elem is not attached
   // to the document, so we wrap it in a try/catch block
     try {
-      return elem.getBoundingClientRect().left;
+      return elem.getBoundingClientRect().left | 0;
     } catch (e) {
       // if not attached return 0
       return 0;
@@ -106,22 +106,22 @@
// getBoundingClientRect() throws a JS exception if the elem is not attached
     // to the document, so we wrap it in a try/catch block
     try {
-      return elem.getBoundingClientRect().top;
+      return elem.getBoundingClientRect().top | 0;
     } catch (e) {
       // if not attached return 0
       return 0;
     }
   }-*/;

-  private native int getDocumentScrollLeftImpl() /*-{
+  private native double getDocumentScrollLeftImpl() /*-{
     return $wnd.pageXOffset;
   }-*/;

-  private native int getDocumentScrollTopImpl() /*-{
+  private native double getDocumentScrollTopImpl() /*-{
     return $wnd.pageYOffset;
   }-*/;

-  private native int getParentOffsetDelta(Element elem) /*-{
+  private native double getParentOffsetDelta(Element elem) /*-{
     var offsetParent = elem.offsetParent;
     if (offsetParent) {
       return offsetParent.offsetWidth - offsetParent.clientWidth;
@@ -129,11 +129,11 @@
     return 0;
   }-*/;

-  private native int getScrollLeftImpl(Element elem) /*-{
+  private native double getScrollLeftImpl(Element elem) /*-{
     return elem.scrollLeft || 0;
   }-*/;

-  private native void setScrollLeftImpl(Element elem, int left) /*-{
+  private native double setScrollLeftImpl(Element elem, int left) /*-{
     elem.scrollLeft = left;
   }-*/;
 }
diff --git a/user/src/com/google/gwt/dom/client/DOMImplMozilla.java b/user/src/com/google/gwt/dom/client/DOMImplMozilla.java
index 5dd8343..fb07661 100644
--- a/user/src/com/google/gwt/dom/client/DOMImplMozilla.java
+++ b/user/src/com/google/gwt/dom/client/DOMImplMozilla.java
@@ -128,19 +128,19 @@
   }-*/;

   @Override
-  public int getAbsoluteLeft(Element elem) {
+  public double getSubpixelAbsoluteLeft(Element elem) {
return getAbsoluteLeftImpl(elem.getOwnerDocument().getViewportElement(),
         elem);
   }

   @Override
-  public int getAbsoluteTop(Element elem) {
+  public double getSubpixelAbsoluteTop(Element elem) {
     return getAbsoluteTopImpl(elem.getOwnerDocument().getViewportElement(),
         elem);
   }

   @Override
-  public native int getBodyOffsetLeft(Document doc) /*-{
+  public native double getSubpixelBodyOffsetLeft(Document doc) /*-{
     var style = $wnd.getComputedStyle(doc.documentElement, null);
     if (style == null) {
       // Works around https://bugzilla.mozilla.org/show_bug.cgi?id=548397
@@ -150,7 +150,7 @@
   }-*/;

   @Override
-  public native int getBodyOffsetTop(Document doc) /*-{
+  public native double getSubpixelBodyOffsetTop(Document doc) /*-{
     var style = $wnd.getComputedStyle(doc.documentElement, null);
     if (style == null) {
       // Works around https://bugzilla.mozilla.org/show_bug.cgi?id=548397
@@ -175,7 +175,7 @@
   }-*/;

   @Override
-  public int getScrollLeft(Element elem) {
+  public double getSubpixelScrollLeft(Element elem) {
     if (!isGecko19() && isRTL(elem)) {
       return super.getScrollLeft(elem)
           - (elem.getScrollWidth() - elem.getClientWidth());
diff --git a/user/src/com/google/gwt/dom/client/DOMImplOpera.java b/user/src/com/google/gwt/dom/client/DOMImplOpera.java
index a205126..5c2983a 100644
--- a/user/src/com/google/gwt/dom/client/DOMImplOpera.java
+++ b/user/src/com/google/gwt/dom/client/DOMImplOpera.java
@@ -60,7 +60,7 @@
   }-*/;

   @Override
-  public native int getAbsoluteLeft(Element elem) /*-{
+  public native double getSubpixelAbsoluteLeft(Element elem) /*-{
     var left = 0;

     // This intentionally excludes body and its ancestors
@@ -83,7 +83,7 @@
   }-*/;

   @Override
-  public native int getAbsoluteTop(Element elem) /*-{
+  public native double getSubpixelAbsoluteTop(Element elem) /*-{
     var top = 0;

     // This intentionally excludes body and its ancestors
diff --git a/user/src/com/google/gwt/dom/client/DOMImplStandard.java b/user/src/com/google/gwt/dom/client/DOMImplStandard.java
index 9811b27..0705d01 100644
--- a/user/src/com/google/gwt/dom/client/DOMImplStandard.java
+++ b/user/src/com/google/gwt/dom/client/DOMImplStandard.java
@@ -42,8 +42,8 @@

   @Override
   public native NativeEvent createMouseEvent(Document doc, String type,
-      boolean canBubble, boolean cancelable, int detail, int screenX,
- int screenY, int clientX, int clientY, boolean ctrlKey, boolean altKey,
+      boolean canBubble, boolean cancelable, int detail, double screenX,
+ double screenY, double clientX, double clientY, boolean ctrlKey, boolean altKey, boolean shiftKey, boolean metaKey, int button, Element relatedTarget) /*-{ // Because Event.getButton() returns bitfield values [1, 4, 2] for [left,
     // middle, right], we need to translate them to the standard [0, 1, 2]
diff --git a/user/src/com/google/gwt/dom/client/DOMImplStandardBase.java b/user/src/com/google/gwt/dom/client/DOMImplStandardBase.java
index 5d698f7..1be5a1d 100644
--- a/user/src/com/google/gwt/dom/client/DOMImplStandardBase.java
+++ b/user/src/com/google/gwt/dom/client/DOMImplStandardBase.java
@@ -199,30 +199,14 @@
   }-*/;

   @Override
-  public int getAbsoluteLeft(Element elem) {
-    ClientRect rect = getBoundingClientRect(elem);
-    return rect != null ? rect.getLeft()
-        + elem.getOwnerDocument().getBody().getScrollLeft()
-        : getAbsoluteLeftUsingOffsets(elem);
-  }
-
-  @Override
-  public int getAbsoluteTop(Element elem) {
-    ClientRect rect = getBoundingClientRect(elem);
-    return rect != null ? rect.getTop()
-        + elem.getOwnerDocument().getBody().getScrollTop()
-        : getAbsoluteTopUsingOffsets(elem);
-  }
-
-  @Override
-  public int getScrollLeft(Document doc) {
+  public double getSubpixelScrollLeft(Document doc) {
// Safari always applies document scrolling to the body element, even in
     // strict mode.
     return doc.getBody().getScrollLeft();
   }

   @Override
-  public int getScrollLeft(Element elem) {
+  public double getSubpixelScrollLeft(Element elem) {
     if (isRTL(elem)) {
       return super.getScrollLeft(elem)
           - (elem.getScrollWidth() - elem.getClientWidth());
@@ -231,13 +215,29 @@
   }

   @Override
-  public int getScrollTop(Document doc) {
+  public double getSubpixelScrollTop(Document doc) {
// Safari always applies document scrolling to the body element, even in
     // strict mode.
     return doc.getBody().getScrollTop();
   }

   @Override
+  public double getSubpixelAbsoluteLeft(Element elem) {
+    ClientRect rect = getBoundingClientRect(elem);
+    return rect != null ? rect.getLeft()
+        + elem.getOwnerDocument().getBody().getScrollLeft()
+        : getAbsoluteLeftUsingOffsets(elem);
+  }
+
+  @Override
+  public double getSubpixelAbsoluteTop(Element elem) {
+    ClientRect rect = getBoundingClientRect(elem);
+    return rect != null ? rect.getTop()
+        + elem.getOwnerDocument().getBody().getScrollTop()
+        : getAbsoluteTopUsingOffsets(elem);
+  }
+
+  @Override
   public native int getTabIndex(Element elem) /*-{
// tabIndex is undefined for divs and other non-focusable elements prior to
     // Safari 4.
diff --git a/user/src/com/google/gwt/dom/client/DOMImplTrident.java b/user/src/com/google/gwt/dom/client/DOMImplTrident.java
index fe71941..57345c3 100644
--- a/user/src/com/google/gwt/dom/client/DOMImplTrident.java
+++ b/user/src/com/google/gwt/dom/client/DOMImplTrident.java
@@ -132,8 +132,8 @@

   @Override
   public native NativeEvent createMouseEvent(Document doc, String type,
-      boolean canBubble, boolean cancelable, int detail, int screenX,
- int screenY, int clientX, int clientY, boolean ctrlKey, boolean altKey,
+      boolean canBubble, boolean cancelable, int detail, double screenX,
+ double screenY, double clientX, double clientY, boolean ctrlKey, boolean altKey, boolean shiftKey, boolean metaKey, int button, Element relatedTarget) /*-{ // NOTE: IE doesn't support changing bubbling and canceling behavior (this
     // is documented publicly in Document.createMouseEvent()).
@@ -238,12 +238,12 @@
   }-*/;

   @Override
-  public int getBodyOffsetLeft(Document doc) {
+  public double getSubpixelBodyOffsetLeft(Document doc) {
     return getClientLeft(doc.getViewportElement());
   }

   @Override
-  public int getBodyOffsetTop(Document doc) {
+  public double getSubpixelBodyOffsetTop(Document doc) {
     return getClientTop(doc.getViewportElement());
   }

diff --git a/user/src/com/google/gwt/dom/client/Element.java b/user/src/com/google/gwt/dom/client/Element.java
index 7d1fd5b..cd48085 100644
--- a/user/src/com/google/gwt/dom/client/Element.java
+++ b/user/src/com/google/gwt/dom/client/Element.java
@@ -202,22 +202,22 @@
   /**
* Returns the inner height of an element in pixels, including padding but not
    * the horizontal scrollbar height, border, or margin.
-   *
+   *
    * @return the element's client height
    */
-  public final native int getClientHeight() /*-{
-    return this.clientHeight;
-  }-*/;
+  public final int getClientHeight() {
+    return (int) getSubpixelClientHeight() | 0;
+  }

   /**
* Returns the inner width of an element in pixels, including padding but not
    * the vertical scrollbar width, border, or margin.
-   *
+   *
    * @return the element's client width
    */
-  public final native int getClientWidth() /*-{
-    return this.clientWidth;
-  }-*/;
+  public final int getClientWidth() {
+    return (int) getSubpixelClientWidth() | 0;
+  }

   /**
    * Specifies the base direction of directionally neutral text and the
@@ -301,17 +301,17 @@
   /**
    * The height of an element relative to the layout.
    */
-  public final native int getOffsetHeight() /*-{
-     return this.offsetHeight || 0;
-   }-*/;
+  public final int getOffsetHeight() {
+    return (int) getSubpixelOffsetHeight() | 0;
+  }

   /**
* The number of pixels that the upper left corner of the current element is
    * offset to the left within the offsetParent node.
    */
-  public final native int getOffsetLeft() /*-{
-     return this.offsetLeft || 0;
-   }-*/;
+  public final int getOffsetLeft() {
+    return (int) getSubpixelOffsetLeft() | 0;
+  }

   /**
    * Returns a reference to the object which is the closest (nearest in the
@@ -325,16 +325,16 @@
* The number of pixels that the upper top corner of the current element is
    * offset to the top within the offsetParent node.
    */
-  public final native int getOffsetTop() /*-{
-     return this.offsetTop || 0;
-   }-*/;
+  public final int getOffsetTop() {
+    return (int) getSubpixelOffsetTop() | 0;
+  }

   /**
    * The width of an element relative to the layout.
    */
-  public final native int getOffsetWidth() /*-{
-     return this.offsetWidth || 0;
-   }-*/;
+  public final int getOffsetWidth() {
+    return (int) getSubpixelOffsetWidth() | 0;
+  }

   /**
    * The element immediately preceeding this element. If there is no such
@@ -407,16 +407,16 @@
   /**
    * The height of the scroll view of an element.
    */
-  public final native int getScrollHeight() /*-{
-     return this.scrollHeight || 0;
-   }-*/;
+  public final int getScrollHeight() {
+    return (int) getSubpixelScrollHeight() | 0;
+  }

   /**
* The number of pixels that an element's content is scrolled from the left.
    *
    * <p>
- * If the element is in RTL mode, this method will return a negative value of
-   * the number of pixels scrolled from the right.
+ * If the element is in RTL mode, this method will return a negative value of the number of pixels
+   * scrolled from the right.
    * </p>
    */
   public final int getScrollLeft() {
@@ -426,16 +426,16 @@
   /**
* The number of pixels that an element's content is scrolled from the top.
    */
-  public final native int getScrollTop() /*-{
-     return this.scrollTop || 0;
-   }-*/;
+  public final int getScrollTop() {
+    return (int) getSubpixelScrollTop() | 0;
+  }

   /**
    * The width of the scroll view of an element.
    */
-  public final native int getScrollWidth() /*-{
-     return this.scrollWidth || 0;
-   }-*/;
+  public final int getScrollWidth() {
+    return (int) getSubpixelScrollWidth() | 0;
+  }

   /**
    * Gets a string representation of this element (as outer HTML).
@@ -457,6 +457,129 @@
    }-*/;

   /**
+ * Gets an element's absolute bottom coordinate in the document's coordinate
+   * system.
+   */
+  public final double getSubpixelAbsoluteBottom() {
+    return getSubpixelAbsoluteTop() + getSubpixelOffsetHeight();
+  }
+
+  /**
+ * Gets an element's absolute left coordinate in the document's coordinate
+   * system.
+   */
+  public final double getSubpixelAbsoluteLeft() {
+    return DOMImpl.impl.getSubpixelAbsoluteLeft(this);
+  }
+
+  /**
+ * Gets an element's absolute right coordinate in the document's coordinate
+   * system.
+   */
+  public final double getSubpixelAbsoluteRight() {
+    return getSubpixelAbsoluteLeft() + getSubpixelOffsetWidth();
+  }
+
+  /**
+   * Gets an element's absolute top coordinate in the document's coordinate
+   * system.
+   */
+  public final double getSubpixelAbsoluteTop() {
+    return DOMImpl.impl.getSubpixelAbsoluteTop(this);
+  }
+
+  /**
+ * Returns the inner height of an element in pixels, including padding but not
+   * the horizontal scrollbar height, border, or margin.
+   *
+   * @return the element's client height
+   */
+  public final native double getSubpixelClientHeight() /*-{
+    return this.clientHeight;
+  }-*/;
+
+  /**
+ * Returns the inner width of an element in pixels, including padding but not the vertical
+   * scrollbar width, border, or margin.
+   *
+   * @return the element's client width
+   */
+  public final native double getSubpixelClientWidth() /*-{
+    return this.clientWidth;
+  }-*/;
+
+  /**
+   * The height of an element relative to the layout.
+   */
+  public final native double getSubpixelOffsetHeight() /*-{
+    return this.offsetHeight || 0;
+  }-*/;
+
+  /**
+ * The number of pixels that the upper left corner of the current element is
+   * offset to the left within the offsetParent node.
+   */
+  public final native double getSubpixelOffsetLeft() /*-{
+    return this.offsetLeft || 0;
+  }-*/;
+
+  /**
+   * Returns a reference to the object which is the closest (nearest in the
+   * containment hierarchy) positioned containing element.
+   */
+  public final native Element getSubpixelOffsetParent() /*-{
+    return this.offsetParent;
+  }-*/;
+
+  /**
+ * The number of pixels that the upper top corner of the current element is
+   * offset to the top within the offsetParent node.
+   */
+  public final native double getSubpixelOffsetTop() /*-{
+    return this.offsetTop || 0;
+  }-*/;
+
+  /**
+   * The width of an element relative to the layout.
+   */
+  public final native double getSubpixelOffsetWidth() /*-{
+    return this.offsetWidth || 0;
+  }-*/;
+
+  /**
+   * The height of the scroll view of an element.
+   */
+  public final native double getSubpixelScrollHeight() /*-{
+    return this.scrollHeight || 0;
+  }-*/;
+
+  /**
+ * The number of pixels that an element's content is scrolled from the left.
+   *
+   * <p>
+ * If the element is in RTL mode, this method will return a negative value of the number of pixels
+   * scrolled from the right.
+   * </p>
+   */
+  public final double getSubpixelScrollLeft() {
+    return DOMImpl.impl.getSubpixelScrollLeft(this);
+  }
+
+  /**
+ * The number of pixels that an element's content is scrolled from the top.
+   */
+  public final native double getSubpixelScrollTop() /*-{
+    return this.scrollTop || 0;
+  }-*/;
+
+  /**
+   * The width of the scroll view of an element.
+   */
+  public final native double getSubpixelScrollWidth() /*-{
+    return this.scrollWidth || 0;
+  }-*/;
+
+  /**
    * The index that represents the element's position in the tabbing order.
    *
* @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-tabindex";>W3C HTML Specification</a> diff --git a/user/src/com/google/gwt/dom/client/NativeEvent.java b/user/src/com/google/gwt/dom/client/NativeEvent.java
index 3954c26..cfcd4e6 100644
--- a/user/src/com/google/gwt/dom/client/NativeEvent.java
+++ b/user/src/com/google/gwt/dom/client/NativeEvent.java
@@ -242,6 +242,42 @@
   }

   /**
+   * Gets the mouse x-position within the browser window's client area.
+   *
+   * @return the mouse x-position
+   */
+  public final double getSubpixelClientX() {
+    return DOMImpl.impl.eventGetSubpixelClientX(this);
+  }
+
+  /**
+   * Gets the mouse y-position within the browser window's client area.
+   *
+   * @return the mouse y-position
+   */
+  public final double getSubpixelClientY() {
+    return DOMImpl.impl.eventGetSubpixelClientY(this);
+  }
+
+  /**
+   * Gets the mouse x-position on the user's display.
+   *
+   * @return the mouse x-position
+   */
+  public final double getSubpixelScreenX() {
+    return DOMImpl.impl.eventGetSubpixelScreenX(this);
+  }
+
+  /**
+   * Gets the mouse y-position on the user's display.
+   *
+   * @return the mouse y-position
+   */
+  public final double getSubpixelScreenY() {
+    return DOMImpl.impl.eventGetSubpixelScreenY(this);
+  }
+
+  /**
    * Get an array of touches which have changed since the last touch event.
    *
    * @return array of touches which have changed since the last touch event

--
To view, visit https://gwt-review.googlesource.com/3090
To unsubscribe, visit https://gwt-review.googlesource.com/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I27e98f0ad3c1c236b2d85d24f197719fa4cd352a
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: John Ahlroos <j...@vaadin.com>

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
--- You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to