4 "../var/documentElement",
6 ], function( jQuery, document, documentElement, support ) {
9 var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal,
10 container = document.createElement( "div" ),
11 div = document.createElement( "div" );
13 // Finish early in limited (non-browser) environments
19 // Style of cloned element affects source element cloned (#8908)
20 div.style.backgroundClip = "content-box";
21 div.cloneNode( true ).style.backgroundClip = "";
22 support.clearCloneStyle = div.style.backgroundClip === "content-box";
24 container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
25 "padding:0;margin-top:1px;position:absolute";
26 container.appendChild( div );
28 // Executing both pixelPosition & boxSizingReliable tests require only one layout
29 // so they're executed at the same time to save the second computation.
30 function computeStyleTests() {
32 // Support: Android 2.3
33 // Vendor-prefix box-sizing
34 "-webkit-box-sizing:border-box;box-sizing:border-box;" +
35 "display:block;position:absolute;" +
36 "margin:0;margin-top:1%;margin-right:50%;" +
37 "border:1px;padding:1px;" +
38 "top:1%;width:50%;height:4px";
40 documentElement.appendChild( container );
42 var divStyle = window.getComputedStyle( div );
43 pixelPositionVal = divStyle.top !== "1%";
44 boxSizingReliableVal = divStyle.height === "4px";
45 pixelMarginRightVal = divStyle.marginRight === "4px";
47 documentElement.removeChild( container );
50 jQuery.extend( support, {
51 pixelPosition: function() {
52 // This test is executed only once but we still do memoizing
53 // since we can use the boxSizingReliable pre-computing.
54 // No need to check if the test was already performed, though.
56 return pixelPositionVal;
58 boxSizingReliable: function() {
59 if ( boxSizingReliableVal == null ) {
62 return boxSizingReliableVal;
64 pixelMarginRight: function() {
65 // Support: Android 4.0-4.3
66 // We're checking for boxSizingReliableVal here instead of pixelMarginRightVal
67 // since that compresses better and they're computed together anyway.
68 if ( boxSizingReliableVal == null ) {
71 return pixelMarginRightVal;
73 reliableMarginRight: function() {
75 // Support: Android 2.3
76 // Check if div with explicit width and no margin-right incorrectly
77 // gets computed margin-right based on width of container. (#3333)
78 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
79 // This support function is only executed once so no memoizing is needed.
81 marginDiv = div.appendChild( document.createElement( "div" ) );
83 // Reset CSS: box-sizing; display; margin; border; padding
84 marginDiv.style.cssText = div.style.cssText =
85 // Support: Android 2.3
86 // Vendor-prefix box-sizing
87 "-webkit-box-sizing:content-box;box-sizing:content-box;" +
88 "display:block;margin:0;border:0;padding:0";
89 marginDiv.style.marginRight = marginDiv.style.width = "0";
90 div.style.width = "1px";
91 documentElement.appendChild( container );
93 ret = !parseFloat( window.getComputedStyle( marginDiv ).marginRight );
95 documentElement.removeChild( container );
96 div.removeChild( marginDiv );