Skip to content

Commit 83e238c

Browse files
author
jossonsmith
committed
Fix document.body.clientHeight on XHTML Strict mode
1 parent b13b08f commit 83e238c

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/internal/browser/OS.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,4 +675,18 @@ public static void updateCSSClass(Object el, String cssClazz, boolean kept) {
675675
*/ {}
676676
}
677677
}
678+
679+
public static int fixBodyClientHeight() {
680+
Element b = document.body;
681+
Element p = b.parentNode;
682+
int bcHeight = b.clientHeight;
683+
int pcHeight = p.clientHeight;
684+
if (OS.isIE) { // && !OS.isOpera
685+
return (pcHeight == 0) ? bcHeight : pcHeight;
686+
} else if (OS.isFirefox) {
687+
return (pcHeight == p.offsetHeight
688+
&& pcHeight == p.scrollHeight) ? bcHeight : pcHeight;
689+
}
690+
return bcHeight;
691+
}
678692
}

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/internal/dnd/ShellFrameDND.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package org.eclipse.swt.internal.dnd;
1515

16+
import org.eclipse.swt.internal.browser.OS;
1617
import org.eclipse.swt.internal.xhtml.Element;
1718
import org.eclipse.swt.internal.xhtml.HTMLEvent;
1819
import org.eclipse.swt.internal.xhtml.document;
@@ -162,7 +163,7 @@ public boolean dragging(DragEvent e) {
162163
int xx = this.sourceX + e.deltaX ();
163164
int yy = this.sourceY + e.deltaY ();
164165

165-
int gHeight = document.body.clientHeight;
166+
int gHeight = OS.fixBodyClientHeight(); //document.body.clientHeight;
166167
int gWidth = document.body.clientWidth;
167168
/*
168169
* On mozilla, the mousemove event can contain mousemove

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Decorations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2256,7 +2256,7 @@ public void _updateMonitorSize() {
22562256
Element el = monitor.handle;
22572257
if (el == document.body) {
22582258
monitor.clientWidth = document.body.clientWidth;
2259-
monitor.clientHeight = document.body.clientHeight;
2259+
monitor.clientHeight = OS.fixBodyClientHeight(); //document.body.clientHeight;
22602260
monitor.x = 0;
22612261
monitor.y = 0;
22622262
monitor.width = window.screen.availWidth;

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Display.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,7 @@ Shell getModalDialogShell () {
17251725
monitor.handle = document.body;
17261726
monitor.clientWidth = document.body.clientWidth;
17271727
monitor.width = window.screen.availWidth;
1728-
monitor.clientHeight = document.body.clientHeight;
1728+
monitor.clientHeight = OS.fixBodyClientHeight(); //document.body.clientHeight;
17291729
monitor.height = window.screen.availHeight;
17301730
monitor.clientX = monitor.x = 0;
17311731
monitor.clientY = monitor.y = 0;
@@ -1752,7 +1752,7 @@ protected static void registerElementAsMonitor(Element el) {
17521752
monitor.handle = document.body;
17531753
monitor.clientWidth = document.body.clientWidth;
17541754
monitor.width = window.screen.availWidth;
1755-
monitor.clientHeight = document.body.clientHeight;
1755+
monitor.clientHeight = OS.fixBodyClientHeight(); //document.body.clientHeight;
17561756
monitor.height = window.screen.availHeight;
17571757
monitor.clientX = monitor.x = 0;
17581758
monitor.clientY = monitor.y = 0;

0 commit comments

Comments
 (0)