Fixes issue 1357
For each browser, computes client size correctly in the presence of a) Standards/Quirks mode b) Scrollbars/no scrollbars.
Review by:knorton
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1528 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImpl.java b/user/src/com/google/gwt/user/client/impl/DOMImpl.java
index 61d401a..0ea3949 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImpl.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImpl.java
@@ -408,9 +408,7 @@
*
* @return the window's client height
*/
- public native int windowGetClientHeight() /*-{
- return $doc.body.clientHeight;
- }-*/;
+ public abstract int windowGetClientHeight();
/**
* Gets the width of the browser window's client area excluding the vertical
@@ -418,7 +416,5 @@
*
* @return the window's client width
*/
- public native int windowGetClientWidth() /*-{
- return $doc.body.clientWidth;
- }-*/;
+ public abstract int windowGetClientWidth();
}
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImplIE6.java b/user/src/com/google/gwt/user/client/impl/DOMImplIE6.java
index 0f8f946..dc2d47a 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImplIE6.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImplIE6.java
@@ -330,4 +330,17 @@
elem.onerror = (bits & 0x10000) ? $wnd.__dispatchEvent : null;
elem.onmousewheel = (bits & 0x20000) ? $wnd.__dispatchEvent : null;
}-*/;
+
+ @Override
+ public native int windowGetClientHeight() /*-{
+ // IE standard mode || IE quirks mode.
+ return $doc.documentElement.clientHeight || $doc.body.clientHeight;
+ }-*/;
+
+ @Override
+ public native int windowGetClientWidth() /*-{
+ // IE standard mode || IE quirks mode.
+ return $doc.documentElement.clientWidth || $doc.body.clientWidth;
+ }-*/;
+
}
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java b/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java
index eafde43..08a7778 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImplMozilla.java
@@ -151,6 +151,28 @@
return outer;
}-*/;
+ @Override
+ public native int windowGetClientHeight() /*-{
+ // Standards mode:
+ // doc.body.clientHeight --> client height with scrollbars.
+ // doc.documentElement.clientHeight --> client height without scrollbars.
+ // Quirks mode:
+ // doc.body.clientHeight --> client height without scrollbars.
+ // doc.documentElement.clientHeight --> document height.
+ // So, must switch value on compatMode.
+ return ($doc.compatMode == 'BackCompat')?
+ $doc.body.clientHeight:
+ $doc.documentElement.clientHeight;
+ }-*/;
+
+ @Override
+ public native int windowGetClientWidth() /*-{
+ // See comment for windowGetClientHeight.
+ return ($doc.compatMode == 'BackCompat')?
+ $doc.body.clientWidth:
+ $doc.documentElement.clientWidth;
+ }-*/;
+
protected native void initMozilla() /*-{
$wnd.addEventListener(
'mouseout',
@@ -177,4 +199,5 @@
$wnd.addEventListener('DOMMouseScroll', $wnd.__dispatchCapturedMouseEvent,
true);
}-*/;
+
}
diff --git a/user/src/com/google/gwt/user/client/impl/DOMImplOpera.java b/user/src/com/google/gwt/user/client/impl/DOMImplOpera.java
index 17a95ee..70ce86a 100644
--- a/user/src/com/google/gwt/user/client/impl/DOMImplOpera.java
+++ b/user/src/com/google/gwt/user/client/impl/DOMImplOpera.java
@@ -1,12 +1,12 @@
/*
* Copyright 2007 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -83,4 +83,16 @@
}
return top;
}-*/;
+
+
+
+ @Override
+ public native int windowGetClientHeight() /*-{
+ return $doc.body.clientHeight;
+ }-*/;
+
+ @Override
+ public native int windowGetClientWidth() /*-{
+ return $doc.body.clientWidth;
+ }-*/;
}