scratch – Diff between revs 58 and 125

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 58 Rev 125
Line 1... Line 1...
1 define( [ 1 define([
2 "../core", 2 "../core",
3 "../var/document", -  
4 "../var/documentElement", -  
5 "../var/support" 3 "../var/support"
6 ], function( jQuery, document, documentElement, support ) { 4 ], function( jQuery, support ) {
Line 7... Line -...
7   -  
8 "use strict"; -  
9   5  
10 ( function() { -  
11   -  
12 // Executing both pixelPosition & boxSizingReliable tests require only one layout -  
13 // so they're executed at the same time to save the second computation. -  
14 function computeStyleTests() { -  
15   -  
16 // This is a singleton, we need to execute it only once -  
17 if ( !div ) { -  
18 return; -  
19 } -  
20   -  
21 div.style.cssText = -  
22 "box-sizing:border-box;" + -  
23 "position:relative;display:block;" + -  
24 "margin:auto;border:1px;padding:1px;" + -  
25 "top:1%;width:50%"; -  
26 div.innerHTML = ""; -  
27 documentElement.appendChild( container ); -  
28   -  
29 var divStyle = window.getComputedStyle( div ); 6 (function() {
30 pixelPositionVal = divStyle.top !== "1%"; -  
31   -  
32 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 -  
33 reliableMarginLeftVal = divStyle.marginLeft === "2px"; -  
34 boxSizingReliableVal = divStyle.width === "4px"; -  
35   -  
36 // Support: Android 4.0 - 4.3 only -  
37 // Some styles come back with percentage values, even though they shouldn't -  
38 div.style.marginRight = "50%"; -  
39 pixelMarginRightVal = divStyle.marginRight === "4px"; -  
40   7 var pixelPositionVal, boxSizingReliableVal,
41 documentElement.removeChild( container ); -  
42   -  
43 // Nullify the div so it wouldn't be stored in the memory and -  
44 // it will also be a sign that checks already performed -  
45 div = null; -  
46 } -  
47   -  
48 var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal, 8 docElem = document.documentElement,
49 container = document.createElement( "div" ), 9 container = document.createElement( "div" ),
Line 50... Line -...
50 div = document.createElement( "div" ); -  
51   10 div = document.createElement( "div" );
52 // Finish early in limited (non-browser) environments 11  
53 if ( !div.style ) { 12 if ( !div.style ) {
Line 54... Line 13...
54 return; 13 return;
55 } 14 }
56   15  
57 // Support: IE <=9 - 11 only 16 // Support: IE9-11+
58 // Style of cloned element affects source element cloned (#8908) 17 // Style of cloned element affects source element cloned (#8908)
Line 59... Line 18...
59 div.style.backgroundClip = "content-box"; 18 div.style.backgroundClip = "content-box";
60 div.cloneNode( true ).style.backgroundClip = ""; 19 div.cloneNode( true ).style.backgroundClip = "";
61 support.clearCloneStyle = div.style.backgroundClip === "content-box"; 20 support.clearCloneStyle = div.style.backgroundClip === "content-box";
Line -... Line 21...
-   21  
-   22 container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" +
-   23 "position:absolute";
-   24 container.appendChild( div );
-   25  
-   26 // Executing both pixelPosition & boxSizingReliable tests require only one layout
-   27 // so they're executed at the same time to save the second computation.
-   28 function computePixelPositionAndBoxSizingReliable() {
-   29 div.style.cssText =
-   30 // Support: Firefox<29, Android 2.3
-   31 // Vendor-prefix box-sizing
-   32 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
-   33 "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
-   34 "border:1px;padding:1px;width:4px;position:absolute";
-   35 div.innerHTML = "";
-   36 docElem.appendChild( container );
-   37  
-   38 var divStyle = window.getComputedStyle( div, null );
-   39 pixelPositionVal = divStyle.top !== "1%";
-   40 boxSizingReliableVal = divStyle.width === "4px";
-   41  
-   42 docElem.removeChild( container );
62   43 }
63 container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" + 44  
-   45 // Support: node.js jsdom
-   46 // Don't assume that getComputedStyle is a property of the global object
-   47 if ( window.getComputedStyle ) {
-   48 jQuery.extend( support, {
64 "padding:0;margin-top:1px;position:absolute"; 49 pixelPosition: function() {
65 container.appendChild( div ); 50  
66   51 // This test is executed only once but we still do memoizing
67 jQuery.extend( support, { 52 // since we can use the boxSizingReliable pre-computing.
-   53 // No need to check if the test was already performed, though.
68 pixelPosition: function() { 54 computePixelPositionAndBoxSizingReliable();
-   55 return pixelPositionVal;
69 computeStyleTests(); 56 },
70 return pixelPositionVal; 57 boxSizingReliable: function() {
71 }, 58 if ( boxSizingReliableVal == null ) {
-   59 computePixelPositionAndBoxSizingReliable();
72 boxSizingReliable: function() { 60 }
73 computeStyleTests(); 61 return boxSizingReliableVal;
-   62 },
-   63 reliableMarginRight: function() {
-   64  
74 return boxSizingReliableVal; 65 // Support: Android 2.3
-   66 // Check if div with explicit width and no margin-right incorrectly
-   67 // gets computed margin-right based on width of container. (#3333)
-   68 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
-   69 // This support function is only executed once so no memoizing is needed.
-   70 var ret,
75 }, 71 marginDiv = div.appendChild( document.createElement( "div" ) );
-   72  
-   73 // Reset CSS: box-sizing; display; margin; border; padding
-   74 marginDiv.style.cssText = div.style.cssText =
76 pixelMarginRight: function() { 75 // Support: Firefox<29, Android 2.3
-   76 // Vendor-prefix box-sizing
-   77 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
-   78 "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
-   79 marginDiv.style.marginRight = marginDiv.style.width = "0";
-   80 div.style.width = "1px";
77 computeStyleTests(); 81 docElem.appendChild( container );
-   82  
-   83 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
78 return pixelMarginRightVal; 84  
79 }, 85 docElem.removeChild( container );
-   86 div.removeChild( marginDiv );
80 reliableMarginLeft: function() { 87  
Line 81... Line 88...
81 computeStyleTests(); 88 return ret;
Line 82... Line 89...
82 return reliableMarginLeftVal; 89 }