|
@@ -15,47 +15,49 @@ |
15 |
15 |
|
*/ |
16 |
16 |
|
package com.google.gwt.widgetideas.client.impl; |
17 |
17 |
|
|
18 |
|
- |
import com.google.gwt.user.client.Element; |
19 |
|
- |
import com.google.gwt.widgetideas.client.GlassPanel; |
|
18 |
+ |
import com.google.gwt.user.client.*; |
|
19 |
+ |
import com.google.gwt.widgetideas.client.*; |
20 |
20 |
|
|
21 |
21 |
|
/** |
22 |
22 |
|
* Safari implementation of {@link GlassPanelImpl}. |
23 |
23 |
|
*/ |
24 |
|
- |
public class GlassPanelImplSafari extends GlassPanelImplStandard { |
25 |
|
- |
private static native void implMatchDocumentSize(Element elem) |
26 |
|
- |
/*-{ |
27 |
|
- |
var scrollWidth = @com.google.gwt.widgetideas.client.impl.GlassPanelImpl::getWindowScrollWidth()(); |
28 |
|
- |
var scrollHeight = @com.google.gwt.widgetideas.client.impl.GlassPanelImpl::getWindowScrollHeight()(); |
29 |
|
- |
|
30 |
|
- |
var width = Math.max($wnd.innerWidth, scrollWidth); |
31 |
|
- |
var height = Math.max($wnd.innerHeight, scrollHeight); |
32 |
|
- |
|
33 |
|
- |
var computedStyle = $doc.defaultView.getComputedStyle($doc.documentElement, null); |
34 |
|
- |
var marginLeft = parseInt(computedStyle.getPropertyValue("margin-left")); |
35 |
|
- |
var marginTop = parseInt(computedStyle.getPropertyValue("margin-top")); |
36 |
|
- |
|
37 |
|
- |
// TODO Verify 'negative HTML element margins' case |
38 |
|
- |
elem.style.marginLeft = -marginLeft + "px"; |
39 |
|
- |
elem.style.marginTop = -marginTop + "px"; |
40 |
|
- |
|
41 |
|
- |
elem.style.width = (width + marginLeft) + "px"; |
42 |
|
- |
elem.style.height = (height + marginTop) + "px"; |
43 |
|
- |
}-*/; |
44 |
|
- |
|
45 |
|
- |
// TODO remove once GWT issue 1981 is fixed |
46 |
|
- |
// http://code.google.com/p/google-web-toolkit/issues/detail?id=1981 |
47 |
|
- |
@Override |
48 |
|
- |
public native boolean isCSS1Compat() |
49 |
|
- |
/*-{ |
50 |
|
- |
// Safari does not implement $doc.compatMode. |
51 |
|
- |
// Use a CSS test to determine rendering mode. |
52 |
|
- |
var elem = $doc.createElement('div'); |
53 |
|
- |
elem.style.cssText = "width:0px;width:1"; |
54 |
|
- |
return parseInt(elem.style.width) != 1; |
55 |
|
- |
}-*/; |
56 |
|
- |
|
57 |
|
- |
@Override |
58 |
|
- |
public void matchDocumentSize(GlassPanel glassPanel, boolean dueToResize) { |
59 |
|
- |
implMatchDocumentSize(glassPanel.getElement()); |
60 |
|
- |
} |
|
24 |
+ |
public class GlassPanelImplSafari extends GlassPanelImplStandard |
|
25 |
+ |
{ |
|
26 |
+ |
private static native void implMatchDocumentSize( Element elem ) |
|
27 |
+ |
/*-{ |
|
28 |
+ |
var scrollWidth = @com.google.gwt.widgetideas.client.impl.GlassPanelImpl::getWindowScrollWidth()(); |
|
29 |
+ |
var scrollHeight = @com.google.gwt.widgetideas.client.impl.GlassPanelImpl::getWindowScrollHeight()(); |
|
30 |
+ |
|
|
31 |
+ |
var width = Math.max( $wnd.innerWidth, scrollWidth ); |
|
32 |
+ |
var height = Math.max( $wnd.innerHeight, scrollHeight ); |
|
33 |
+ |
|
|
34 |
+ |
var computedStyle = $doc.defaultView.getComputedStyle( $doc.documentElement, null ); |
|
35 |
+ |
var marginLeft = parseInt( computedStyle.getPropertyValue( "margin-left" ) ); |
|
36 |
+ |
var marginTop = parseInt( computedStyle.getPropertyValue( "margin-top" ) ); |
|
37 |
+ |
|
|
38 |
+ |
// TODO Verify 'negative HTML element margins' case |
|
39 |
+ |
elem.style.marginLeft = -marginLeft + "px"; |
|
40 |
+ |
elem.style.marginTop = -marginTop + "px"; |
|
41 |
+ |
|
|
42 |
+ |
elem.style.width = (width + marginLeft) + "px"; |
|
43 |
+ |
elem.style.height = (height + marginTop) + "px"; |
|
44 |
+ |
}-*/; |
|
45 |
+ |
|
|
46 |
+ |
// TODO remove once GWT issue 1981 is fixed |
|
47 |
+ |
// http://code.google.com/p/google-web-toolkit/issues/detail?id=1981 |
|
48 |
+ |
@Override |
|
49 |
+ |
public native boolean isCSS1Compat() |
|
50 |
+ |
/*-{ |
|
51 |
+ |
// Safari does not implement $doc.compatMode. |
|
52 |
+ |
// Use a CSS test to determine rendering mode. |
|
53 |
+ |
var elem = $doc.createElement( 'div' ); |
|
54 |
+ |
elem.style.cssText = "width:0px;width:1"; |
|
55 |
+ |
return parseInt( elem.style.width ) != 1; |
|
56 |
+ |
}-*/; |
|
57 |
+ |
|
|
58 |
+ |
@Override |
|
59 |
+ |
public void matchDocumentSize( GlassPanel glassPanel, boolean dueToResize ) |
|
60 |
+ |
{ |
|
61 |
+ |
implMatchDocumentSize( glassPanel.getElement() ); |
|
62 |
+ |
} |
61 |
63 |
|
} |